I have created a game where a figure will be moved through the room and before each move takes place a hitTest function checks, if next step would collide with the outer boundaries which limit the room so that the figure is not falling off the stage or walking through objects...of course.
There are 4 MCs (figure walking up, down, right, left) lying above each other and one normally invisible MC called base which will be compared in the hitTest function with the boundaries.
I cannot explain all the code, thats why I have uploaded the *.fla and the *.swf so you can check everything out.
THE PROBLEM: it just doesn't work!!!!!!! It sometimes works and sometimes not...
This is so important because until now, nobody deals with games which are not tile based and depends on collision testing.
^ this is an open source of my little web site (the link in my signature), if you want to see how the hitTest is working here (btw i'm using Ed's code for that)
this is just what I looked for!! Will go through it as soon as I am home from work and give you a note if it worked for me :-) But again thanks!
BTW: AWESOME GRAPHICS!!!!!!!!!
thanks (also to EdMack)! Works GREAT!!! But how would you do a swaptDepths operation when the character walks accross the room and the furniture should swap their depths with the character depending if it is standing in front or behind?
I have tried it with the HitTest function again but then its constantly swapping depths but I only want to swap once.
If you or anybody knows where to get this info, I'd be grateful!
if (_root.hittestarea.HitTest(_root.character) {
_root.furniture.swapDepths(_root.character);
}
but everytime when the character walks in, HitTest returns constantly true what means, I've got a constant swapping of depths between the two MC's furniture and character.
What I did now is: created two layers, one above and one beyond the character with booth the exact same content and set the visibility of the above layer on false. When the character now walks behind the furniture (on the hittestarea), the beyond-layer will be set to ._visible = false and the above-layer to ._visible=true.
It's not perfect, though, but it works. Got any better idea respt. might you be more specific on your code?
Marmotte! I came across your site the other day. Very nice. Now I've found your post on collision detection. You give a link for your open source pack, but I get a 404 when I try to download it. Could you PLEASE PLEASE make it available again. Thanks in Advance!