ADDED LINK TO STORYBOARD PROJECT WITH ERROR
I have tried changing scenes so many times, it either makes the player glitch and move around anywhere, or I have attempt to applyforce (blah blah blah (don’t remember)) a nil value, or bad argument expected proxy, and all this other crazy stuff. To keep things simpler for the both of us I’ve sent you the code without the scene changing as it is a complete mess. I’ve been trying to do this for weeks but can’t get it right. I know it feels like I’m not doing anything by asking you what seems like impossible code, but I can’t get the scene to change without tons of errors. Please tell me the code to do
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
If you really don’t want to do the code for me I’m willing to pay at this point
I just want to get past this… please
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 )