forked from callin2/ParticleSugar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheffect1.lua
125 lines (96 loc) · 3.12 KB
/
effect1.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
---
-- Created by IntelliJ IDEA.
-- @author [email protected]
-- @copyright 2012 임창진
--
local storyboard = require("storyboard")
local PS = require("classes.ParticleSugar").instance()
local scene = storyboard.newScene()
function scene:createScene(event)
end
-- Called immediately after scene has moved onscreen:
function scene:enterScene(event)
storyboard.removeAll()
local group = self.view
display.newText(group, "effect 1",20,20,native.systemFont, 24)
----------- particle begin -------------
Runtime:addEventListener('enterFrame', PS )
local dustEm = PS:newEmitter{
name="em1",
x=0,y=0,
rotation=0,
visible=true,
loop=false,
autoDestroy=false
}
dustEm:setParentGroup(group)
dustEm.x = 160
dustEm.y = 160
PS:newParticleType{
name="starPt",prop={
scaleStart = 1,
scaleVariation = 0,
velocityStart = 60,
velocityVariation = 30,
rotationStart = 0,
rotationVariation = 0,
directionVariation = 360,
killOutsideScreen = false,
lifeTime = 500,
alphaStart = 1,
fadeOutSpeed = -2,
fadeOutDelay = 150,
imagePath={
"image/s1.png",
},
imageWidth=10,
imageHeight=10,
}
}
PS:attachParticleType("em1", "starPt", 50, 300, 0)
----------- particle end -------------
-- button --
local caption = display.newText(group, "Prev",20,420,native.systemFont, 24)
caption:addEventListener('touch',function(event)
if event.phase == 'ended' then
storyboard.gotoScene("scene.effect6")
end
end)
local caption1 = display.newText(group, "start emit",100,420,native.systemFont, 24)
caption1:addEventListener('touch',function()
PS:startEmitter('em1')
end)
local caption2 = display.newText(group, "Next",240,420,native.systemFont, 24)
caption2:addEventListener('touch',function(event)
if event.phase == 'ended' then
storyboard.gotoScene("scene.effect2")
end
end)
-- button end --
end
-- Called when scene is about to move offscreen:
function scene:exitScene(event)
local group = self.view
Runtime:removeEventListener('enterFrame', PS )
PS:cleanUp()
end
-- If scene's view is removed, scene:destroyScene() will be called just prior to:
function scene:destroyScene(event)
local group = self.view
collectgarbage('collect')
end
-----------------------------------------------------------------------------------------
-- END OF YOUR IMPLEMENTATION
-----------------------------------------------------------------------------------------
-- "createScene" event is dispatched if scene's view does not exist
scene:addEventListener("createScene", scene)
-- "enterScene" event is dispatched whenever scene transition has finished
scene:addEventListener("enterScene", scene)
-- "exitScene" event is dispatched whenever before next scene's transition begins
scene:addEventListener("exitScene", scene)
-- "destroyScene" event is dispatched before view is unloaded, which can be
-- automatically unloaded in low memory situations, or explicitly via a call to
-- storyboard.purgeScene() or storyboard.removeScene().
scene:addEventListener("destroyScene", scene)
-----------------------------------------------------------------------------------------
return scene