Change actor's layer during the game
touchcream
Member Posts: 63
Hi, I just discovered layers (thanks to POLYGAMe ) and I'm wondering if it's possible to change actor's layer during the game. There's no attribute or behaviour for that so is there an other way ?
Comments
Actor 1 = the actor you want to move to a new layer
Actor 2 = an actor hanging out in the layer you want Actor 1 be in
New Boolean Attribute = Jumper
New Real Attribute = Jump-X
New Real Attribute = Jump-Y
So, when you want to jump to a layer... like when the "J" key was pressed...
Actor 1...
If "J" key is down,
change attribute "Jumper" to true
change Jump-X to self.Posistion.X
change Jump-Y to self.Posistion.Y
delete actor
Actor 2...
If attribute "Jumper" is true,
spawn Actor1 at Jump-X & Jump-Y (relative to scene)
If your game is running smoothly, it should be a clean jump.
If you like that, I have more cool "Limit Smashing" tricks like that in my GameSalad Textbook...
AVAILABLE SOON! :-)
It really depends on what you're trying to achieve. I'd suggest planning the layers properly and precisely placing the actors within the layers so you don't need such "limit smashing" tricks... though I'm not sure how using the basic behaviours is smashing any limits...
There may be a few times where Photics idea could be made to work, though... like say in Shinobi, when he jumps up and over a fence to land on the other side. I'd try and destroy/spawn at the top of the jump though as GS still isn't incredibly accurate and may trigger a slight pause (not to mention the issues with movement continuity between the two actors). Basically, you're just adding more actors and behaviours that you probably don't need, thus slowing the game down and creating headaches. Spawning is also very costly and, according to a lot of accounts here, even when an actor is destroyed it doesn't clear the RAM, so if you kept using this method it would continually increase RAM usage, eventually making the game unplayable.
What you COULD do is have two identical actors constrained on top of each other (in separate layers) and adjust the alpha of the one on top so if he jumps behind a wire fence, you just see the actor in the back layer. You could even make this actor slightly darker and interpolate the top actor's alpha, as if he were jumping into shadows!
Concentrate on optimising and keeping code as simple as poss ;-)