|
|
|
#1 |
|
Member
Join Date: Feb 2002
Location: Chicago, Atlanta
Posts: 57
|
Maze hitTest
Im making a maze that ball travels through. I am succesful on one wall. But when I come down to the other side it brings it up. How do make the side a hitTest? or can give me advice if theres better solutions. Thanks....
I have attached it to the ball named circle. I have include the file //the hitTest if (hitTest(_level0.wall)==true) { _y = _y-10; this below is the full code onClipEvent (enterFrame) { if (Key.isDown(37)) { _x=_x-10; } if (Key.isDown(38)) { _y=_y-10; } if (Key.isDown(39)) { _x=_x+10; } if (Key.isDown(40)) { _y=_y+10; } //the hit test if (hitTest(_level0.wall)==true) { _y = _y-10; } } |
|
|
|
|
|
#2 |
|
Senior Member
Join Date: Feb 2004
Location: Los Angeles
Posts: 2,920
|
I would do a coordinate based hit test which checks the direction you are trying to travel in.
Your current makes an adjustment to the position, and then does an 'undo' on that adjustment if there is a hit. I would check to see if there is a hit on the target coordinates before making the actual adjustment, like so:
Also, there's another way to do it, the method I used in these mazes: http://krazydad.com/fungames.php In these mazes, I don't use hitTest at all, instead I keep track of where the valid paths exiting each cell are and only allow movement along the valid paths, tweening from the center of one cell to the next. So rather than using hitTest, I am checking a data structure to see if a bit is set that corresponds to the desired direction of movement. - Jim |
|
|
|
|
|
#3 |
|
Member
Join Date: Feb 2002
Location: Chicago, Atlanta
Posts: 57
|
Thanks you
Thanks so very much for the help.
|
|
|
|
|
|
#4 |
|
Junior Member
Join Date: Mar 2005
Location: minds playin tricks on me
Posts: 18
|
http://www.actionscript.org/tutorial...es/index.shtml
I remembered seeing this, thought you might be interested. webg
__________________
minds playin tricks on me |
|
|
|
![]() |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|