adregalus
August 1st, 2009, 03:13 PM
Hi, I'm currently making a simple side scrolling hack & slash game in which the player and enemies can move up and down the stage while creating a sense of "3D" perspective, ala Final Fight, Golden Axe, etc, etc.
To explain the problem in it's most simplest way, here's an example:
On the stage there are three layers, each with one movieClip, example:
Layer 3 = Contains an MC with the instance name: "npc3"
Layer 2 = Contains an MC with the instance name: "npc2"
Layer 1 = Contains an MC with the instance name: "npc1"
Each have their own :"onClipEvent(enterFrame)" which includes this:
"this.swapDepths(this._y);"
This code causes objects which are higher on the stage to be placed behind those underneath them.
So far so good.
Here's the problem:
Once I load the flash game, their depths are strangely arranged, meaning MC's which are supposed to be ontop of another, are located behind them, - a total mess.
Everything works fine the moment after their position changes either through AI control or player control, which is nothing more than adding or subtracting to their own "._y" or "._x" speeds.
Question:
Is there a way for "this.swapDepths(this._y);" to be instantly called the moment the movie clips are loaded onto the stage - so that all MCs are properly behind/in front one another to create a sense of depth - depending on their current _y position?
I have "this.swapDepths(this._y);" under "onClipEvent(enterFrame)" as well as "onClipEvent(load)" and it only seems to work the moment an object moves - and NOT the instant they are loaded onto the stage.
Any help would be immensely grateful. Thanks in advance!
To explain the problem in it's most simplest way, here's an example:
On the stage there are three layers, each with one movieClip, example:
Layer 3 = Contains an MC with the instance name: "npc3"
Layer 2 = Contains an MC with the instance name: "npc2"
Layer 1 = Contains an MC with the instance name: "npc1"
Each have their own :"onClipEvent(enterFrame)" which includes this:
"this.swapDepths(this._y);"
This code causes objects which are higher on the stage to be placed behind those underneath them.
So far so good.
Here's the problem:
Once I load the flash game, their depths are strangely arranged, meaning MC's which are supposed to be ontop of another, are located behind them, - a total mess.
Everything works fine the moment after their position changes either through AI control or player control, which is nothing more than adding or subtracting to their own "._y" or "._x" speeds.
Question:
Is there a way for "this.swapDepths(this._y);" to be instantly called the moment the movie clips are loaded onto the stage - so that all MCs are properly behind/in front one another to create a sense of depth - depending on their current _y position?
I have "this.swapDepths(this._y);" under "onClipEvent(enterFrame)" as well as "onClipEvent(load)" and it only seems to work the moment an object moves - and NOT the instant they are loaded onto the stage.
Any help would be immensely grateful. Thanks in advance!