-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBubble.lua
More file actions
56 lines (41 loc) · 1.16 KB
/
Bubble.lua
File metadata and controls
56 lines (41 loc) · 1.16 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
-- Bubble.lua
local const = require 'constants'
local globalData = require 'globalData'
local Bubble = {}
Bubble.__index = Bubble
function Bubble.new(x, y, label)
local dim = globalData.dim
local o = {}
setmetatable(o, Bubble)
o.label = label
o.grp = display.newGroup()
globalData.gridGroup:insert(o.grp)
o.grp.x, o.grp.y = x, y
o.grp.alpha = 0.75
o.circle = display.newCircle(o.grp, 0, 0,dim.quarterQ)
o.circle:setFillColor(unpack(globalData.colorTile))
local fontSize
if string.len(o.label) > 3 then -- eg '+100'
fontSize = dim.Q / 5
else
fontSize = dim.Q / 4
end
o.text = display.newText({
parent = o.grp,
text = o.label,
x = 0,
y = 0,
font = const.FONTS.ACME,
fontSize = fontSize,
align = 'center',
})
o.text:setFillColor(0,0,0)
return o
end
function Bubble:fadeOut()
transition.scaleTo(self.grp, {xScale=0.1, yScale=0.1, time=1000, transition=easing.inQuart, onComplete=function() self.grp:removeSelf() end})
end
function Bubble:flyTo(x, y)
transition.moveTo(self.grp, {x=x, y=y, time=4000, transition=easing.outQuart, onComplete=function() self.grp:removeSelf() end})
end
return Bubble