View Full Version : [AS3] hit testing
billowillo
07-09-2009, 05:12 PM
well, for a maze game. you move the character with the keys through the maze. what im trying to do is have all the walls be one mc. but then the bounding box goes around the thing as one big wall, which doesnt really work. how can you have it test each lil box separately in it or how else can this be achieved?
You can hit test a point. That's probably what I'd do.
billowillo
07-09-2009, 08:02 PM
thanks for the repy
but thats not what i mean, doing that would involve the same ammount of code. im asking if theres a way i can check all of the walls at once instead of in seperate hit tests.
so instead of like
mcChar.hitTestObject(mcWall1)
mcChar.hitTestObject(mcWall2)
mcChar.hitTestObject(mcWall3)
have it all in one hit test
Put all the walls in an array and for loop through them.
But unless there was a reason I needed to know which wall I hit, I would probably just hit test a point.
runawayprisoner
07-10-2009, 08:25 AM
Been mentioned before. Hit test the center (or if you're really attentive to details then the corners/edges) of the moving sprite against the wall with shape flag.
That'll be done after one line of code: hitTestPoint(x,y,shapeFlag)
It's recommended that you split up the maze into tiles for performance purposes, though. Hit testing a large shape with complex alpha properties might hurt performance a lot.
billowillo
07-10-2009, 03:28 PM
ok i see, thanks for the help guys
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.