storyboard.removeScene("имя сцены") не работает
Я новичок в 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)
Любая помощь будет оценена
Спасибо
1 ответ
Решение
Привет Сид, вот и ты
_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