添加了指向情節串連圖板項目,錯誤科羅娜SDK麻煩與場景變化
項目 - http://forums.coronalabs.com/index.php?app=core&module=attach§ion=attach&attach_id=2062
原題 - http://forums.coronalabs.com/topic/46884-scene-change-pleeeeease-help/
我試圖改變場面這麼多次,它會讓玩家在任何地方出現毛病和移動,或者我試圖用力(blah blah blah(不記得))一個零值,或者一個糟糕的參數exp ected proxy,以及所有這些其他瘋狂的東西。爲了讓我們兩個人更簡單,我已經給你發送了代碼,而不會改變場景,因爲它是一個完整的混亂。我一直試圖這樣做幾個星期,但不能正確。我知道,我覺得我沒有做任何事情來問你看起來不可能的代碼,但是我不能在沒有大量錯誤的情況下改變場景。
請告訴我的代碼,這樣做:
local function onCollision(event)
if event.phase == "began" then
-- go to next lua/scene completely obliterating this one as
-- if I'm opening a whole new game
end
return true
end
如果你真的不想做我願意在這一點上要
我只是想爲我的代碼過去...請
display.setStatusBar(display.HiddenStatusBar)
local physics = require("physics")
physics.start()
physics.setGravity(0, 15) -- set x & y gravity to 0
local background = display.newImage("background.jpg")
background.x = display.contentCenterX
background.y = display.contentCenterY
local ground = display.newImage("ground.png")
ground.x = display.contentCenterX
ground.y = 480
physics.addBody(ground, "static", {density=1, friction=1, bounce=0.3 })
local flag = display.newImage("flag.png")
flag.x = display.contentCenterX
flag.y = 50
physics.addBody(flag, "static", {density=0, friction=1, bounce=0.3 })
local player = display.newImage("player.png")
player.x = display.contentCenterX
player.y = 425
physics.addBody(player, {density=0, friction=1, bounce=0.3 })
player.isFixedRotation = true
system.setAccelerometerInterval(100.0)
local tiltSpeed = 2
local function onTilt(event)
movementX = tiltSpeed * event.xGravity
player.x = player.x + movementX
-- prevent player from moving offscreen
if player.x <= 30 then
player.x = 30
elseif player.x >= 310 then
player.x = 310
end
end
local function onCollision(event)
if event.phase == "began" then
-- go to next lua/scene completely obliterating this one as if I'm opening a whole new game
end
return true
end
local function onScreenTouch(event)
if event.phase == "began" then
-- make player jump
player:applyForce(0, -4, player.x, player.y)
end
end
Runtime:addEventListener("accelerometer", onTilt)
Runtime:addEventListener("touch", onScreenTouch)
flag:addEventListener("collision", onCollision)
在另一個說明中,您應該將所有圖形真正放在一個組中,以便在故事板之間進行傳輸更加輕鬆。 – PhotoDev13