PDA

View Full Version : Looking for a new hitTest.



JoMan
August 25th, 2004, 10:31 PM
I have been using the "single line hitTest " method for a LONG while:td:, and I was wondering if anyone could teach me a better hitTest method. But please teach it to me in onClipHandlers (I dont like functions ;) ). Thanks in advance.



peace

JoMan
August 26th, 2004, 05:44 PM
Okay, I made one of my own, but it is REALLY messed and I dont know why.... Anyone know?



onClipEvent (enterFrame) {
b = this.getBounds(this);
if (_root.limits.hitTest(_x+x+b.xmin+5, _y+y+b.ymin+5, true)) {
_x += 6;
}
if (_root.limits.hitTest(_x+x+b.xmax-5, _y+y+b.ymin+5, true)) {
_x -= 6;
}
if (_root.limits.hitTest(_x+x+b.xmin+5, _y+y+b.ymax-5, true)) {
_y -= 6;
}
if (_root.limits.hitTest(_x+x+b.xmax-5, _y+y+b.ymax-5, true)) {
_y += 6;
}
}

MoNgOlIaN
August 27th, 2004, 04:26 AM
You're forgetting the first curly brackets after the conditions.

:)

JoMan
August 27th, 2004, 12:34 PM
I have those, but I think you have to scroll the coding box to see the curly brackets

MoNgOlIaN
August 27th, 2004, 01:51 PM
You cant scroll it left or right... double check to see if you put them

JoMan
August 27th, 2004, 01:54 PM
Here, I put it on regular:


onClipEvent (enterFrame) {
b = this.getBounds(this);
if (_root.limits.hitTest(_x+x+b.xmin+5, _y+y+b.ymin+5, true)) {
_x += 6;
}
if (_root.limits.hitTest(_x+x+b.xmax-5, _y+y+b.ymin+5, true)) {
_x -= 6;
}
if (_root.limits.hitTest(_x+x+b.xmin+5, _y+y+b.ymax-5, true)) {
_y -= 6;
}
if (_root.limits.hitTest(_x+x+b.xmax-5, _y+y+b.ymax-5, true)) {
_y += 6;
}
}