Hi folks, I’m making a mockup for a simple game. I use transition.to to move two characters towards eachother, and when they collide, pause physics and cancel the ‘losing’ characters transition. Eventually, I’d like to place spritesheets, but for now I’m just using newRects for placeholders.
On collision, this is what is giving me an issue;
function onCollision( event ) if(event.object1.myName == "dude1" and event.object2.myName == "dude2") then if dude1.x \> display.contentWidth \* 0.5 or dude2.x \> display.contentWidth \* 0.5 then print( "you win!" ) physics.pause() transition.cancel(moveDude2) elseif dude1.x \< display.contentWidth \* 0.5 or dude2.x \< display.contentWidth \* 0.5 then print( "you lose!") physics.pause() transition.cancel(moveDude1) end end
If there is no input from the user, when ‘dude2’ collides with ‘dude1’, moveDude1 has not been called and produces an error. Input is via a widget button, and ‘dude2’ moves after the screen has been active for two seconds.
Any help would be appreciated, at the moment I’m not quite sure how to go about this, though.