Let’s say char
is the name of your character, and deathZone
is the name of your death zone:
var life:int = 5; //Character has 5 lives
var startPoint:Point = new Point(0, 0); //Where the character starts
addEventListener(Event.ENTER_FRAME, function()
{
if(char.hitTestObject(deathZone))
{
life -= 1;
char.x = startPoint.x;
char.y = startPoint.y;
if(life <= 0)
{
trace('yourCharacterIsDead');
}
}
});
This code will make the character lose one life every time he hits the death zone, and if his lives is less than or equal to zero, it will trace ‘yourCharacterIsDead’. That should get you started.
Also, nobody will just code your game for you. You’re very lucky I answered this question, anyways.
3
solved How can i create a death zone in my platformer? [closed]