Collision detection in actionscript help!
Hi guys, I want that my enemy cars don't overlap, this is the link
http://www.miviro.com/cg/
this is my enemy layer:
createEnemy = function(type, x, y)
{
var nm = "enemy" + enemyCount;
enemyLayer.attachMovie(type, nm, enemyCount);
enemyLayer[nm]._x = x;
enemyLayer[nm].xline = x;
enemyLayer[nm]._y = y;
enemyLayer[nm].dy = Math.random() * 3 + 10;
enemyLayer[nm].onEnterFrame = function()
{
this._x = this.xline;
this._y += this.dy;
if (this._currentframe == 1 && car.hitTest(this._x, this._y, true))
{
counter = 1;
doCounter();
car.play();
}
if (this._y > 750) this.removeMovieClip();
}
enemyCount ++;
enemyCount %= 10;
}
ok, and, inside this, i want to put:
if ((enemyLayer("bob", x, y)).hitTest((enemyLayer("bus", x, y)),true)) {
trace ("collision!!");
}
I'm not right cause it doesn't work, but am I close??
thank u guys!!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement