0
votes

So I am making an endless runner type game, and I cannot get the hitTest to work. I have the main character just standing still, if you hit the up arrow he jumps and that all works. I also have a spike symbol that starts off screen and it has an in-symbol tween (if that makes sense) so that it comes across the screen when you get to the frame its on. Ive tried a lot of different ways to get the hitTest to work, but none of them are. this is on the spike

onClipEvent(enterFrame){
if(_root.char.hitTest(this)){
trace("hit");
}
}

on the character its the same thing just replace char with spike. And yes the instance names are the same as in the code.

I have also tried _parent instead of _root. and I have tried the code not on any symbols, just on the frame like this:

if(_root.char.hitTest(_root.spike){
trace("hit");
}
1

1 Answers

0
votes

you need a closing parentheses

    if(this.char.hitTest(_root.spike)**)**{
    trace("hit");                     
    }