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