-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathuiTransition.lua
executable file
·71 lines (56 loc) · 2.02 KB
/
uiTransition.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
----------------------------------
-- THE BIG 3 VIDEO GAME ---
-- [email protected] ---
----------------------------------
-- Script animates an iris-out transition inbetween scenes
local displayGroup = nil
local transition = nil
local UITransition = {
}
function UITransition:execute(scene, delay)
local sceneToLoad = scene
if( not delay ) then
delay = 0
end
local mySpriteListener = function( event )
if ( event.phase == "ended" ) then
transition:removeSelf()
transition = nil
display.remove( displayGroup )
displayGroup = nil
if( UIEndScreen_Remove ) then
UIEndScreen_Remove()
end
display.remove( self.view )
removeDisplayGroups()
storyboard.purgeAll()
storyboard.removeAll()
storyboard.gotoScene( sceneToLoad )
end
end
displayGroup = display.newGroup()
addDisplayGroup( displayGroup )
display.setDefault( "magTextureFilter", "nearest" )
display.setDefault( "minTextureFilter", "nearest" )
local spriteSheet = graphics.newImageSheet( "images/transitionAnim.png", { width=240, height=135, numFrames=25 } )
transition = display.newSprite( spriteSheet, {{ name = "sequence", start=1, count=25, time=900, loopCount=1 }} )
transition.x = display.contentCenterX
transition.y = display.contentCenterY
transition.yScale = display.actualContentHeight / transition.height
transition.xScale = transition.yScale
transition.anchorX = 0.5
transition.anchorY = 0.5
transition.alpha = 0.001
display.setDefault( "magTextureFilter", "linear" )
display.setDefault( "minTextureFilter", "linear" )
displayGroup:toFront()
local go = function()
transition:setSequence( "sequence" )
transition:play()
transition.alpha = 1
displayGroup:insert( transition )
transition:addEventListener( "sprite", mySpriteListener )
end
timer.performWithDelay( delay, go )
end
return UITransition;