-
[MX04] [Problem] swap depths don't work properly
Hi guys,
I have a frustrating problem! I have created a "hero" that I can move with cursor keys and an animated "baddie" that just walks around at the moment. Inside the animated bad guy there is 2 movie clips, one movie clip to make the "hero" appear in front of the baddie with this code.
onClipEvent(enterFrame){
if(this.hitTest(_root.man.hit_area) and _global.ogre_in_front == true){
_root.ogre.swapDepths(_root.man);
_global.ogre_in_front = false;
}
}
And the MC that pushes the "hero" to the background is
_global.ogre_in_front = false;
onClipEvent(enterFrame){
if(this.hitTest(_root.man.hit_area) and _global.ogre_in_front == false){
_root.ogre.swapDepths(_root.man);
_global.ogre_in_front = true;
}
}
The problem is that the "hero" doesn't always go behind when he should the swap depths seem to get confused very quickly and some times they don't seem to swap at all. Does anyone have any ideas? Thanks in advance!
-
....he's amazing!!!
Can the two hitTests be positive at the same time?
(ignore the ogre_in_front variable, just look at the hitTests)
-
Tried it but without the in_front variable the character just seems to flicker
-
....he's amazing!!!
I think that will happen either way if the two hittests can be activated at the same time.
use trace statements in each function to find out whats happening, but I think you'll find that the two functions are swapping depths continuously.
-
Senior Member
Also is this correct?
if(this.hitTest(_root.man.hit_area) and _global.ogre_in_front == false){
To me that looks wrong. I always seperate different condition tests with parenthesis:
if((this.hitTest(_root.man.hit_area)) and (_global.ogre_in_front == false)){
-
maybe that's why the code wasn't playing properly in the first place?
-
_global.ogre_in_front = false; or true
maybe the problem is in the part of code which decides when ogre is in front or the back?
-
M.D.
does the hero go behind an ogre when he's above it (vertically higher?) if so just use the _y property to swap depths
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|