forked from MarkHenryC/Stroople
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathletters.lua
65 lines (51 loc) · 1.34 KB
/
letters.lua
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
57
58
59
60
61
62
63
64
65
-- Mark H Carolan
--
-- Stroople project
-- © 2010 Mark H Carolan, Gregory S Hooper
module(..., package.seeall)
local chars = { 's', 't', 'r', 'o', 'o2', 'p', 'l', 'e' }
local w = display.contentWidth
local h = display.contentHeight
local startTimes = {0,.314,.520,.683,.824,.843,.935,1.098}
--local soundEndLevel = media.newEventSound( "endLevel.aif" )
function newLetters()
local letters = display.newGroup()
letters:setReferencePoint(display.TopLeftReferencePoint)
for i = 1, #chars do
local img = display.newImage(chars[i] .. ".png")
img:setReferencePoint(display.TopLeftReferencePoint)
img.id = i
letters:insert(img)
end
function letters:onComplete(event)
end
function letters:onStart(event)
end
function letters:addText(t, y)
self.text = display.newText(t, 0, 0, nil, 24)
self.text.y = y or 80
self.text.x = display.contentWidth/2
self.text:setTextColor(200, 200, 200)
end
function letters:drop(dropTo, up, time)
if up then
transition.from(self, { time = 300, y = h })
end
for i = 1, self.numChildren do
transition.to(self[i],
{
time=time,
y = dropTo,
x = self[i].x,
onStart = self,
delay = startTimes[i] * 1000,
transition = easing.inOutExpo,
onComplete = self,
})
end
if globals.isSoundOn() then
media.playSound("endLevel.aif")
end
end
return letters
end