/zoeplat

To get this branch, use:
bzr branch http://9ix.org/bzr/zoeplat

« back to all changes in this revision

Viewing changes to balloon.lua

  • Committer: Josh C
  • Date: 2013-04-21 19:52:29 UTC
  • Revision ID: josh@9ix.org-20130421195229-g23mqls3pxble7tr
update version when building

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Balloon = Group:extend{
 
2
   visible = false,
 
3
   text = Text:new{wordWrap = true, width = 50, tint = {0,0,0}},
 
4
   box = Fill:new{width = 54, border = {0,0,255}},
 
5
   onNew = function(self)
 
6
              self:add(self.box)
 
7
              self:add(self.text)
 
8
              the.view:add(self)
 
9
              the.view:moveToBack(self)
 
10
              print('new balloon')
 
11
           end,
 
12
   onUpdate = function(self)
 
13
                 if self.visible then
 
14
                    local spr = self.sprite
 
15
                    self.text:centerAround(spr.x + (spr.width/2),
 
16
                                           spr.y + (spr.height/2), --ignored
 
17
                                           'horizontal')
 
18
                    _, texth = self.text:getSize()
 
19
                    self.text.y = spr.y - texth - 4
 
20
                    self.box.x = self.text.x - 2
 
21
                    self.box.y = self.text.y - 2
 
22
                 end
 
23
              end,
 
24
   setText = function(self, text)
 
25
                self.text.text = text
 
26
                _, texth = self.text:getSize()
 
27
                self.box.height = texth + 4
 
28
             end
 
29
}
 
 
b'\\ No newline at end of file'