Hey, I’m working on some collision testing, and I have three “bars”
like so:
__
| . |
The dot travels constatly upward, and changes direction, based on user input.
The probelm, is that the top bar is the only one that detects collision, the left and right don’t.
Heres my code:
onClipEvent (enterFrame) {
this._y--;
}
on (keyPress "<Right>") {
this._x += 5;
}
on (keyPress "<Left>") {
this._x -= 5;
}
on (keyPress "<Up>") {
this._y -= 5;
}
on (keyPress "<Down>") {
this._y += 5;
}
onClipEvent (enterFrame) {
if (_root.hero, hitTest(_root.rblock)) {
_root.text = ("Collision on right Detected");
} else {
_root.text = ("No Collision");
}
}
onClipEvent (enterFrame) {
if (_root.hero, hitTest(_root.lblock)) {
_root.text = ("Collision on left Detected");
} else {
trace = ("No Collision");
}
}
onClipEvent (enterFrame) {
if (_root.hero, hitTest(_root.tblock)) {
_root.text = ("Collision at top Detected");
} else {
_root.text = ("No Collision");
}
}
This is all on the “dot” which is a mc titled “hero” the three bars, are titled rblock, lblock, and tblock, and are also movie clips.
Thanks for any help