gpt4 book ai didi

android - storyboard.removeScene ("scene name") 不工作

转载 作者:行者123 更新时间:2023-11-30 02:04:42 25 4
gpt4 key购买 nike

我是 corona sdk 的新手,正在尝试在其中构建示例。我想在一段时间后通过破坏我的场景自动返回主屏幕(我的意思是场景在某个特定时间后自行破坏并且用户返回主屏幕)。我知道对于某些人来说这可能听起来很愚蠢但我是 Corona 的新手

这是我的 main.lua 代码:-

local storyboard = require "storyboard"

local widget = require( "widget" )
--/**/ widget.setTheme( "widget_theme_android" )

local json = require "json"

local particleDesigner = require( "particleDesigner" )



local physics = require( "physics" )
physics.start()

-------------------------------------------------------------------------------

local sky = display.newImage( "sky.jpg",contentCenterX,display.contentCenterY)



local emitter

emitter = particleDesigner.newEmitter("air_stars.json")
emitter.x = (contentCenterX)
emitter.y = (contentCenterY)

local button = {}

y= -50

for count = 1,3 do
y = y + 110
x = 20

for insideCount = 1,3 do
x = x + 110

button[count] = display.newImage("1.png")

button[count].x = x
button[count].y = y

local container = display.newContainer( 0, 0 )
container:translate(button[count].x-40, button[count].y-40)

local bkgd = display.newImage( container, "2.png" )



function buttonTap(self)
button[count].touch = transition.to(container,{time=3000, height = button[count].height+x, width = button[count].width+y, onComplete = StartGame})

function StartGame()
storyboard.purgeScene("main")
if count == 1 and insideCount == 1 then
storyboard:gotoScene("bridge")

elseif count == 1 and insideCount == 2 then

storyboard:gotoScene("Heli")
end
end
end

button[count]:addEventListener( "touch", buttonTap)
end
end
return storyboard

这是我的 bridge.lua 文件 :- ( http://piratepad.net/ep/pad/view/ro.JR1Bpt1qkA $/latest)

任何帮助将不胜感激

谢谢

最佳答案

嗨,sid,你开始了:

_W = display.contentWidth;
_H = display.contentHeight;

local button = {}

x = -20

for count = 1,3 do
x = x + 90
y = 20

for insideCount = 1,3 do
y = y + 90

button[count] = display.newImage("imgs/one.png");

button[count].x = x;
button[count].y = y;

local container = display.newContainer( 0, 0 )
container:translate(button[count].x, button[count].y)

local bkgd = display.newImage( container, "imgs/two.png" )

function buttonTap(self)
button[count].touch = transition.to(container,{time=3000, height = button[count].height+x, width = button[count].width+y})
end

button[count]:addEventListener( "touch", buttonTap )
end
end

只需将其添加到 bridge.lua 中

local function goBack()
storyboard:gotoScene("buttons")
end
timer.performWithDelay( 3000, goBack, 1 )

和这个到 main.lua

storyboard.purgeOnSceneChange = true

关于android - storyboard.removeScene ("scene name") 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30867512/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com