I am having a problem with making the player die upon collision with an enemy. Here is my code atm. Basically what happens is the player (a ball) spawns, hits the ground and the game over message comes up. What I want to happen is when the player hits Ground4 the message comes up. Here is my current code:
[code]local function loadGround4()
ground = display.newImage(“Ground.png”);
ground.x = 400;
ground.y = 108;
ground.width = 150;
ground.rotation = 90
ground.height = 30;
physics.addBody(ground, {friction=0.5});
ground.bodyType = “static”;
world:insert(ground);
end
local function onCollision( event )
if ( event.phase == “began” ) then
Runtime:removeEventListener(“enterFrame”, onEnterFrame);
Runtime:removeEventListener(“touch”, onScreenTouched);
leftButton:removeEventListener(“touch”, onLeftTouched);
rightButton:removeEventListener(“touch”, onRightTouched);
–leftButton:removeSelf();
–rightButton:removeSelf();
–hideArrow();
world.alpha = 0.5;
local gameOverText = display.newText(“Game Over!”, 0, 0, native.systemFont, 30);
gameOverText.x = 160;
gameOverText.y = 240;
elseif ( event.phase == “ended” ) then
gameOver();
end
end
Runtime:addEventListener( “collision”, onCollision )[code] [import]uid: 18727 topic_id: 5437 reply_id: 305437[/import]