This is ridiculous. Why doesn’t this code work??? It crashes during playFirst on my phone and crashes Corona randomly on all scenes. The other ones rarely work when they want to. What is going on? And I am not getting any errors from Corona or Director.
[lua]module( …,package.seeall )
– LOCAL VARIABLES
local deviceWidth = display.contentWidth
local deviceHeight = display.contentHeight
local centered = {x = deviceWidth * 0.5, y = deviceHeight * 0.5}
local localTransitions = {}
local localTimers = {}
local myParams = {}
– MAIN GROUP
local sceneGroup = display.newGroup()
function delaySkip()
function sceneGroup:tap( event )
scenes:changeScene(“stageScreen”, “fade”, params, localTransitions, localTimers)
end
sceneGroup:addEventListener(“tap”, sceneGroup)
end
localTimers[“delaySkip1”] = timer.performWithDelay(1000, delaySkip)
– ANIMATE FUNCTIONS
– SCENES
– SCENE ONE
local function playFirst()
sceneGroup:removeEventListener(“tap”, sceneGroup)
function delaySkip()
function sceneGroup:tap( event )
scenes:changeScene(“playScreen”, “fade”, params, localTransitions, localTimers)
end
sceneGroup:addEventListener(“tap”, sceneGroup)
end
localTimers[“delaySkip1”] = timer.performWithDelay(1000, delaySkip)
local scene = display.newGroup()
sceneGroup:insert(scene)
local bg1 = display.newImage(“scene1_1a.png”, true)
sceneGroup:insert(bg1)
bg1.x, bg1.y = centered.x, centered.y
local bg2, bg3, bg4, bg5 = nil
local function transition1()
bg2 = display.newImage(“scene1_1b.png”, true)
sceneGroup:insert(bg2)
bg2.x, bg2.y = centered.x, centered.y
end
local function transition2()
bg3 = display.newImage(“scene1_2.png”, true)
sceneGroup:insert(bg3)
bg3.x, bg3.y = centered.x, centered.y
end
local function transition3()
bg4 = display.newImageRect(“scene5_4.jpg”, 480, 320)
scene:insert(bg4)
bg4.x, bg4.y = centered.x, centered.y
bg4.alpha = 0
localTransitions[“scene5_4a”] = transition.to(bg3, {time = 500, alpha = 0})
localTransitions[“scene5_4b”] = transition.to(bg4, {time = 500, alpha = 1, onComplete = function() bg3:removeSelf() end})
end
local function transition4()
localTransitions[“scene5_5”] = transition.to(bg4, {time = 500, alpha = 0, onComplete = function() bg4:removeSelf() end})
end
local function transition5()
bg5 = display.newGroup()
scene:insert(bg5)
bg5.alpha = 0
local s1 = display.newImageRect(“scene5_5_01.png”, 480, 349)
bg5:insert(s1)
s1.x, s1.y = centered.x, centered.y
local s2 = display.newImageRect(“scene5_5_02.png”, 480, 439)
bg5:insert(s2)
s2.x, s2.y = centered.x, s1.y + s2.height * 0.895
local s3 = display.newImageRect(“scene5_5_03.png”, 480, 393)
bg5:insert(s3)
s3.x, s3.y = centered.x, s2.y + 416
localTransitions[“scene5_6”] = transition.to(bg5, {time = 500, alpha = 1})
end
local function transition6()
localTransitions[“scene5_5”] = transition.to(bg5, {time = 5000, y = -bg5.height * 0.7125})
end
local function transition7()
bg6 = display.newImageRect(“thend.png”, 320, 480)
scene:insert(bg6)
bg6.x, bg6.y = centered.x, centered.y
bg6.alpha = 0
localTransitions[“scene5_fine”] = transition.to(bg6, {time = 500, alpha = 1})
end
– SCENE FOUR PLAY
localTimers[“scene5_1”] = timer.performWithDelay(2000, transition1)
localTimers[“scene5_2”] = timer.performWithDelay(3500, transition2)
–localTimers[“scene5_3”] = timer.performWithDelay(5000, transition3)
–localTimers[“scene5_4”] = timer.performWithDelay(6500, transition4)
–localTimers[“scene5_5”] = timer.performWithDelay(9000, transition5)
–localTimers[“scene5_6”] = timer.performWithDelay(11000, transition6)
–localTimers[“scene5_7”] = timer.performWithDelay(12000, transition7)
end
– SCENE TWO
local function playSecond()
print(“PLaying Second Clip”)
local scene = display.newGroup()
sceneGroup:insert(scene)
local bg1 = display.newImageRect(“scene2_1.jpg”, 480, 320)
scene:insert(bg1)
bg1.x, bg1.y = centered.x, centered.y
bg1.alpha = 1
local bg2, bg3 = nil
local function transition1()
localTransitions[“scene2_1”] = transition.to(bg1, {time = 500, alpha = 0})
end
–raining
local function transition2()
bg2 = display.newGroup()
scene:insert(bg2)
bg2.alpha = 0
local bg2a = display.newImageRect(“scene2_2.jpg”, 480, 320)
bg2:insert(bg2a)
bg2a.x, bg2a.y = centered.x, centered.y
local function rain()
local rain1 = display.newImageRect(“scene2_2screen.png”, 480, 320)
bg2:insert(rain1)
rain1.x, rain1.y = centered.x, centered.y
rain1.alpha = .3
end
rain()
localTransitions[“scene2_2”] = transition.to(bg2, {time = 500, alpha = 1, onComplete = function() bg1:removeSelf() end})
end
local function transition3()
localTransitions[“scene2_2”] = transition.to(bg2, {time = 500, alpha = 0, onComplete = function() bg2:removeSelf() end})
end
local function transition4()
bg3 = display.newImageRect(“scene2_3.jpg”, 480, 320)
scene:insert(bg3)
bg3.x, bg3.y = centered.x, centered.y
bg3.alpha = 0
localTransitions[“scene2_3”] = transition.to(bg3, {time = 500, alpha = 1})
end
local function transition5()
localTransitions[“scene2_fine”] = transition.to(bg3, {time = 500, alpha =0, onComplete = function() bg3:removeSelf(); scenes:changeScene(“stageScreen”, “fade”, params, localTransitions, localTimers) end })
end
– SCENE TWO PLAY
localTimers[“scene2_1”] = timer.performWithDelay(2000, transition1)
localTimers[“scene2_2”] = timer.performWithDelay(3000, transition2)
localTimers[“scene2_3”] = timer.performWithDelay(8000, transition3)
localTimers[“scene2_4”] = timer.performWithDelay(8000, transition4)
localTimers[“scene2_fine”] = timer.performWithDelay(12000, transition5)
end
– SCENE THREE
local function playThird()
local scene = display.newGroup()
sceneGroup:insert(scene)
local bg1 = display.newImageRect(“scene3_1.jpg”, 806, 320)
scene:insert(bg1)
bg1.x, bg1.y = centered.x + bg1.width * 0.2, centered.y
local bg2, bg3, bg4 = nil
local function transition1()
localTransitions[“scene3_1”] = transition.to(bg1, {time = 1000, x = centered.x - bg1.width * 0.2})
end
local function transition2()
bg2 = display.newImageRect(“scene3_2.jpg”, 806, 320)
bg2.x, bg2.y = bg1.x, bg1.y
end
local function transition3()
localTransitions[“scene3_1b”] = transition.to(bg2, {time = 1000, x = centered.x + bg2.width * 0.2, onComplete = function() bg1:removeSelf() end})
end
local function transition4()
localTransitions[“scene3_fine”] = transition.to(bg2, {time = 500, alpha =0, onComplete = function() bg2:removeSelf(); scenes:changeScene(“stageScreen”, “fade”, params, localTransitions, localTimers) end })
end
– SCENE THREE PLAY
localTimers[“scene3_1”] = timer.performWithDelay(2000, transition1)
localTimers[“scene3_1a”] = timer.performWithDelay(4500, transition2)
localTimers[“scene3_1b”] = timer.performWithDelay(6000, transition3)
localTimers[“scene3_fine”] = timer.performWithDelay(9000, transition4)
end
– SCENE FOUR
local function playFourth()
local scene = display.newGroup()
sceneGroup:insert(scene)
local bg1 = display.newImage(“scene4_1.jpg”, true)
scene:insert(bg1)
bg1.x, bg1.y = 545, centered.y
local function transition1()
localTransitions[“scene4_1”] = transition.to(bg1, {time = 2500, x = -55})
end
–[[
local function transition2()
localTransitions[“scene4_1b”] = transition.to(bg1, {time = 1000, x = 100, xScale =.7, yScale = .7})
end
]]–
local function transition4()
localTransitions[“scene4_fine”] = transition.to(bg1, {time = 500, alpha =0, onComplete = function() bg1:removeSelf(); scenes:changeScene(“stageScreen”, “fade”, params, localTransitions, localTimers) end })
end
– SCENE FOUR PLAY
localTimers[“scene4_1a”] = timer.performWithDelay(2000, transition1)
localTimers[“scene4_fine”] = timer.performWithDelay(7000, transition4)
–[[
localTimers[“scene4_1b”] = timer.performWithDelay(7000, transition2)
localTimers[“scene4_1c”] = timer.performWithDelay(6000, transition3)
]]–
end
– SCENE FIFTH
local function playFifth()
sceneGroup:removeEventListener(“tap”, sceneGroup)
function delaySkip()
function sceneGroup:tap( event )
scenes:changeScene(“playScreen”, “fade”, params, localTransitions, localTimers)
end
sceneGroup:addEventListener(“tap”, sceneGroup)
end
localTimers[“delaySkip1”] = timer.performWithDelay(1000, delaySkip)
local scene = display.newGroup()
sceneGroup:insert(scene)
local bg1 = display.newImage(“scene5_1.jpg”, true)
scene:insert(bg1)
bg1.x, bg1.y = centered.x, centered.y
local bg2, bg3, bg4, bg5 = nil
local function transition1()
bg2 = display.newImageRect(“scene5_2.jpg”, 480, 320)
scene:insert(bg2)
bg2.x, bg2.y = centered.x, centered.y
bg2.alpha = 0
localTransitions[“scene5_2a”] = transition.to(bg1, {time = 500, alpha = 0})
localTransitions[“scene5_2b”] = transition.to(bg2, {time = 500, alpha = 1, onComplete = function() bg1:removeSelf() end})
end
local function transition2()
bg3 = display.newImageRect(“scene5_3.jpg”, 480, 320)
scene:insert(bg3)
bg3.x, bg3.y = centered.x, centered.y
bg3.alpha = 0
localTransitions[“scene5_3a”] = transition.to(bg2, {time = 500, alpha = 0})
localTransitions[“scene5_3b”] = transition.to(bg3, {time = 500, alpha = 1, onComplete = function() bg2:removeSelf() end})
end
local function transition3()
bg4 = display.newImageRect(“scene5_4.jpg”, 480, 320)
scene:insert(bg4)
bg4.x, bg4.y = centered.x, centered.y
bg4.alpha = 0
localTransitions[“scene5_4a”] = transition.to(bg3, {time = 500, alpha = 0})
localTransitions[“scene5_4b”] = transition.to(bg4, {time = 500, alpha = 1, onComplete = function() bg3:removeSelf() end})
end
local function transition4()
localTransitions[“scene5_5”] = transition.to(bg4, {time = 500, alpha = 0, onComplete = function() bg4:removeSelf() end})
end
local function transition5()
bg5 = display.newGroup()
scene:insert(bg5)
bg5.alpha = 0
local s1 = display.newImageRect(“scene5_5_01.png”, 480, 349)
bg5:insert(s1)
s1.x, s1.y = centered.x, centered.y
local s2 = display.newImageRect(“scene5_5_02.png”, 480, 439)
bg5:insert(s2)
s2.x, s2.y = centered.x, s1.y + s2.height * 0.895
local s3 = display.newImageRect(“scene5_5_03.png”, 480, 393)
bg5:insert(s3)
s3.x, s3.y = centered.x, s2.y + 416
localTransitions[“scene5_6”] = transition.to(bg5, {time = 500, alpha = 1})
end
local function transition6()
localTransitions[“scene5_5”] = transition.to(bg5, {time = 5000, y = -bg5.height * 0.7125})
end
local function transition7()
bg6 = display.newImageRect(“thend.png”, 320, 480)
scene:insert(bg6)
bg6.x, bg6.y = centered.x, centered.y
bg6.alpha = 0
localTransitions[“scene5_fine”] = transition.to(bg6, {time = 500, alpha = 1})
end
– SCENE FOUR PLAY
localTimers[“scene5_1”] = timer.performWithDelay(2000, transition1)
localTimers[“scene5_2”] = timer.performWithDelay(3500, transition2)
localTimers[“scene5_3”] = timer.performWithDelay(5000, transition3)
localTimers[“scene5_4”] = timer.performWithDelay(6500, transition4)
localTimers[“scene5_5”] = timer.performWithDelay(9000, transition5)
localTimers[“scene5_6”] = timer.performWithDelay(11000, transition6)
–localTimers[“scene5_7”] = timer.performWithDelay(12000, transition7)
end
– GET STORYBOARD
local function storyboard( w )
if w == 1 then playFirst()
elseif w == 2 then playSecond()
elseif w == 3 then playThird()
elseif w == 4 then playFourth()
elseif w == 5 then playFifth()
end
end
– NEW FUNCTION
new = function( params )
myParams = params or nil
storyboard(myParams.world)
return sceneGroup
end[/lua]
Edit:: I noticed that I get this:
Invalid memory access of location 0x0 eip=0x0
Before my bus error and the game continues to crash when reopening corona.
[import]uid: 54716 topic_id: 15633 reply_id: 57908[/import]