AS3 闪存 -
嘿,我做了一个像“Flappy Bird”这样的游戏。
有人可以帮助我如何检查“字符”撞墙吗?
该游戏每 2.5 秒生成两堵墙。(墙和墙 2)
如何检查那个角色击中了它?
function newWall():void
{
var Wall:wall = new wall();
addChildAt(Wall, 1);
Wall.x = -350 + (-80 - -350) * Math.random();
Wall.y = 805;
Wall.name = "Wall1_Object";
TweenLite.to(Wall, 10, {y:-50, ease:Linear.easeNone});
var Wall2:wall = new wall();
addChildAt(Wall2, 1);
Wall2.x = Wall.x + Wall.width + 125;
Wall2.y = 805;
Wall2.name = "Wall2_Object";
TweenLite.to(Wall2, 10, {y:-50, ease:Linear.easeNone});
}
function checkDead():void
{
if (character.hitTestObject(Wall) || character.hitTestObject(Wall2))
{
trace("You dead!");
}
}
var newWallInterval:uint = setInterval(newWall,2500);
var checkDeadInterval:uint = setInterval(checkDead,500);