user2455722 user2455722 - 4 years ago 273
iOS Question

Corona SDK Screen Transition Not Working*Solved*

I need to have my game transition from one scene to another in the storyboard api when the button pbtn is pressed. Here is my code.

local storyboard = require "storyboard"
local scene = storyboard.newScene()

--Forward References

local title

local centerX = display.contentCenterX
local centerY = display.contentCenterY
display.setStatusBar(display.HiddenStatusBar)

function anim_pbtn(event)
transition.to(pbtn, {time = 500, alpha = 0, xScale = 2, yScale = .6})
storyboard.gotoScene("game", "fade", 1000)
end

function scene:createScene(event)
local screenGroup = self.view

mbg = display.newImage("mbg.png")
mbg.x = centerX
mbg.y = centerY
mbg.width = display.width
mbg.height = display.height

title = display.newImage("title.png")
title.xScale = .7
title.yScale = .7
title.x = centerX

pbtn = display.newImage("play_btn.png")
pbtn.xScale = .7
pbtn.yScale = .7
pbtn.x = centerX
pbtn.y = display.contentHeight - 210

ibtn = display.newImage("ins_btn.png")
ibtn.xScale = .7
ibtn.yScale = .7
ibtn.x = centerX
ibtn.y = display.contentHeight - 130

cbtn = display.newImage("cre_btn.png")
cbtn.xScale = .7
cbtn.yScale = .7
cbtn.x = centerX
cbtn.y = display.contentHeight - 50
end

function scene:enterScene(event)
pbtn:addEventListener("tap", anim_pbtn)
end

function scene:exitScene(event)

end

function scene:destroyScene(event)

end



scene:addEventListener("createScene", scene)
scene:addEventListener("enterScene", scene)
scene:addEventListener("exitScene", scene)
scene:addEventListener("destroyScene", scene)

return scene


I just needed to add this to the screenGroup for the transition to take place.

Answer Source

I just added all of my images to my group called screenGroup and everything worked fine!!!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download