电晕作曲家背景下一个场景不显示
corona composer background next scene not showing
我在 composer 方面遇到了很多困难...这并不容易!
我之前的场景是"game"(game.lua)一切正常
当我在我的游戏中使用这个片段进入我的场景 "recolt" 时 lua :
local function goTo()
print("gotoscene")
composer.gotoScene( "recolt", { time = 1000, effect = "fromRight", params = params } )
end
timer.performWithDelay( 1000, 转到 )
: 问题是我在我的反击场景后面看到了我以前的场景,我看不到我的背景,但我看到我的圈子谁在动???但是我的场景组是正确的:
sceneGroup:insert(background,circle)
当我这样做时:
sceneGroup:insert(circle,background)
我看到我的背景隐藏了我以前的场景和我的圈子。 > 预期行为
怎么了?我想在 y "recolt" 场景中看到我的背景和圈子。你可以帮帮我吗 ?非常感谢...在片段下方 "recolt.lua".
--recolt.lua
local composer = require( "composer" )
local scene = composer.newScene()
function scene:create( event )
local sceneGroup = self.view
params = event.params
local background=display.newImageRect("back02.png",display.contentWidth*.5,d isplay.contentHeight*.5,320,480)
background.x,background.y=display.contentWidth*.5,display.contentHeight*.5
background.xScale,background.yScale=2,2
background.alpha=1
local circle = display.newCircle(120,100,100)
sceneGroup:insert(background,circle)
timeT=150
local function tr4()
transition.to(circle,{time=timeT,x=200,y=300,alpha=1,transition=easing.linear, xScale=1,yScale=1})
end
local function tr3()
transition.to(circle,{time=200,x=100,y=300,transition=easing.linear, xScale=.2 ,yScale=.5,onComplete=tr4})
end
local function tr2()
transition.to(circle,{time=200,x=200,y=295,transition=easing.linear, xScale=.2 ,yScale=.2,alpha=.2,onComplete=tr3})
end
local function tr1()
transition.to(circle,{time=timeT,x=300,y=300,transition=easing.linear, xScale= .5,yScale=.5,onComplete=tr2})
end
timer.performWithDelay(700,tr1,-1)
end
function scene:show( event )
local sceneGroup = self.view
params = event.params
if event.phase == "did" then
--physics.start()
end
end
function scene:hide( event )
local sceneGroup = self.view
if event.phase == "will" then
--
-- Remove enterFrame listeners here
--
--physics.stop()
end
end
function scene:destroy( event )
local sceneGroup = self.view
end
---------------------------------------------------------------------------------
-- END OF YOUR IMPLEMENTATION
---------------------------------------------------------------------------------
scene:addEventListener( "create", scene )
scene:addEventListener( "show", scene )
scene:addEventListener( "hide", scene )
scene:addEventListener( "destroy", scene )
return scene
您需要查看文档:object:insert()
问题是你只能用insert()函数往场景中添加1个物体,所以你只需要改变
sceneGroup:insert(background,circle)
到
sceneGroup:insert(background)
sceneGroup:insert(circle)
顺序很重要,您创建的第一个对象回到场景中。
我在 composer 方面遇到了很多困难...这并不容易!
我之前的场景是"game"(game.lua)一切正常 当我在我的游戏中使用这个片段进入我的场景 "recolt" 时 lua :
local function goTo()
print("gotoscene")
composer.gotoScene( "recolt", { time = 1000, effect = "fromRight", params = params } )
end
timer.performWithDelay( 1000, 转到 ) : 问题是我在我的反击场景后面看到了我以前的场景,我看不到我的背景,但我看到我的圈子谁在动???但是我的场景组是正确的:
sceneGroup:insert(background,circle)
当我这样做时:
sceneGroup:insert(circle,background)
我看到我的背景隐藏了我以前的场景和我的圈子。 > 预期行为
怎么了?我想在 y "recolt" 场景中看到我的背景和圈子。你可以帮帮我吗 ?非常感谢...在片段下方 "recolt.lua".
--recolt.lua
local composer = require( "composer" )
local scene = composer.newScene()
function scene:create( event )
local sceneGroup = self.view
params = event.params
local background=display.newImageRect("back02.png",display.contentWidth*.5,d isplay.contentHeight*.5,320,480)
background.x,background.y=display.contentWidth*.5,display.contentHeight*.5
background.xScale,background.yScale=2,2
background.alpha=1
local circle = display.newCircle(120,100,100)
sceneGroup:insert(background,circle)
timeT=150
local function tr4()
transition.to(circle,{time=timeT,x=200,y=300,alpha=1,transition=easing.linear, xScale=1,yScale=1})
end
local function tr3()
transition.to(circle,{time=200,x=100,y=300,transition=easing.linear, xScale=.2 ,yScale=.5,onComplete=tr4})
end
local function tr2()
transition.to(circle,{time=200,x=200,y=295,transition=easing.linear, xScale=.2 ,yScale=.2,alpha=.2,onComplete=tr3})
end
local function tr1()
transition.to(circle,{time=timeT,x=300,y=300,transition=easing.linear, xScale= .5,yScale=.5,onComplete=tr2})
end
timer.performWithDelay(700,tr1,-1)
end
function scene:show( event )
local sceneGroup = self.view
params = event.params
if event.phase == "did" then
--physics.start()
end
end
function scene:hide( event )
local sceneGroup = self.view
if event.phase == "will" then
--
-- Remove enterFrame listeners here
--
--physics.stop()
end
end
function scene:destroy( event )
local sceneGroup = self.view
end
---------------------------------------------------------------------------------
-- END OF YOUR IMPLEMENTATION
---------------------------------------------------------------------------------
scene:addEventListener( "create", scene )
scene:addEventListener( "show", scene )
scene:addEventListener( "hide", scene )
scene:addEventListener( "destroy", scene )
return scene
您需要查看文档:object:insert()
问题是你只能用insert()函数往场景中添加1个物体,所以你只需要改变
sceneGroup:insert(background,circle)
到
sceneGroup:insert(background)
sceneGroup:insert(circle)
顺序很重要,您创建的第一个对象回到场景中。