【发布时间】:2015-01-08 11:15:42
【问题描述】:
我目前正在为我的 uni 模块开发一款游戏,但似乎不知道如何解决这个问题。有人可以帮帮我吗?该游戏是 2D 平台游戏,我试图在敌人的生命值
这是我的敌人代码:
package
{
import flash.display.MovieClip;
/**
* ...
* @author Umeer
*/
public class Enemy extends MovieClip
{
public var health:int = 100;
public function Enemy()
{
this.graphics.beginFill(0xFF1100, 1);
this.graphics.drawCircle(this.x, this.y, 25);
this.graphics.endFill();
}
public function CheckObj(obj:Player,bullets:Array):void
{
if (Math.abs(obj.x - x) < obj.width / 2 + width / 2 && Math.abs(obj.y - y) < obj.height / 2 + height / 2)
obj.health --;
for (var i:int = 0; i < bullets.length; i++)
{
if (Math.abs(bullets[i].x - x) < width / 2 && Math.abs(bullets[i].y - y) < height / 2)
health -= 50;
}
if (health <= 0)
return true;
return false;
}
}
}
【问题讨论】:
标签: actionscript-3 flashdevelop 2d-games