|
-
hitTest repeating ...
I have several objects in a separate movie and want to perform a hitTest with them and my other object 'knexman' which is noted below in the script.
Basically what's happening is that when I trace the output of the hitTest, it increments about 5 or 6 at a time with each enemy collision running into the knexman object. All I want to do is when objects run into the 'knexman', to increment and trace it by one. Once I get it to increment by one I can accurately conditionalize how many lives are left etc.
onClipEvent (load) {
function reset(){
this._y=0;
this._x=random(600)+300;
enemySpeed=random(15)+5;
this.gotoAndStop(1);
}
reset();
}
onClipEvent (enterFrame) {
this._y+=enemySpeed;
if (this._y>800) {
reset();
}
hitting = false;
cntr = 0;
if (_root.knexman.hitTest(_x, _y, true))
{
if (!hitting)
{
cntr = 1;
trace(cntr);
hitting = true;
_root.remove_life_from_stage("life", --_root.tries_remain);
_parent.knexman.gotoAndPlay(145);
}
else
{
hitting = false;
}
}
}
Last edited by justinc; 10-25-2010 at 06:59 PM.
JC
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|