PDA

View Full Version : Object collision (hitTest) question.



delirium
September 30th, 2003, 08:38 PM
I'm stumped with a problem I'm having with hitTest. I got the object to move around using the arrow keys, and in one test I got the object to stick to a wall and not move, but I changed some code around and now it doesn't recogize the hitTest at all.


if (key.isDown(key.DOWN)) {
if (_root.block.hitTest(this._x, (this._y+speed), false) != "true") {
this._y += speed;
}
}
The object will still move but will pass through the block(s).

http://flub.ath.cx/~delirium/test.fla is where the full code is. Any help would be much appreciated!

I'm currently using Flash MX.

Yeldarb
September 30th, 2003, 08:57 PM
if(key.isDown(key.DOWN)) {
if (_root.block.hitTest(this) == 0) {
this._y += speed;
}
}

im a little rusty, but i believe that should work...

delirium
October 2nd, 2003, 10:48 PM
What should I do to prevent the "sticking" when it does hit an object? I set
all the keyboard controls to make it not move unless it's false (==0) so
when it does hit I can't move any of them.

Any suggestions would be greatly appreciated!