PDA

View Full Version : Collision detection problem?


lowndown
10-29-2007, 07:07 PM
Need some help, I've made a ditty maze game which uses arrow keys to move an sprite around, when you get to the end there's a little prize, which when you touch takes you to another Scene (which has a "Well Done" message)!

My issue is when the sprite you guide around with the arrow keys gets to the prize at the end, nothing happens. What I want to happen is as soon as the sprite touches the prize you go to the next Scene ("Well Done") – with the "Well Done" message!

Here's the code I have which doesn't seem to work:

onClipEvent (enterFrame) {
if (_root. sprite, hitTest(_root.prize)) {
gotoAndPlay("Well Done", 1);
} else {
_root.gotoAndStop(1);
}
}

lowndown
10-29-2007, 07:09 PM
Need some help, I've made a ditty maze game which uses arrow keys to move an sprite around, when you get to the end there's a little prize, which when you touch takes you to another Scene (which has a "Well Done" message)!

My issue is when the sprite you guide around with the arrow keys gets to the prize at the end, nothing happens. What I want to happen is as soon as the sprite touches the prize you go to the next Scene ("Well Done") – with the "Well Done" message!

Here's the code I have which doesn't seem to work:

onClipEvent (enterFrame) {
if (_root. sprite, hitTest(_root.prize)) {
gotoAndPlay("Well Done", 1);
} else {
_root.gotoAndStop(1);
}
}

Draxus
10-29-2007, 08:25 PM
onClipEvent (enterFrame) {
if (this.hitTest(_root.prize)) {
gotoAndPlay("Well Done");
}
}


You had some spacing problems (dunno if that's actually in your code), a comma instead of a period, and for the gotoAndPlay you just need the frame label or number. You also don't need the else to keep telling the root to gotoAndStop(1) if there's no collision.