Change actor's layer during the game

touchcreamtouchcream Member Posts: 63
edited November -1 in Working with GS (Mac)
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

  • AfterBurnettAfterBurnett Member Posts: 3,474
    You're welcome... unfortunately I have bad news on this one. You can't change layers mid game as far as I'm aware. I may be wrong... but it would be a first :P
  • touchcreamtouchcream Member Posts: 63
    That's what I tought, maybe in the next version. :)
  • PhoticsPhotics Member Posts: 4,172
    You could do a neat trick.

    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! :-)
  • AfterBurnettAfterBurnett Member Posts: 3,474
    Photics is right, there are workarounds for just about everything... some worth doing, others... not so much.

    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 ;-)
Sign In or Register to comment.