Howdy folks. I need help figuring out why when moving from one layout to another, the transition seems to work fine the first time but the second time the layers are getting rendered out of z order and with parallax disabled.
If you take a look at the linked capx file, start the project from Floor2 and then click the laptop button that appears on the HUD layer. That opens the Laptop layout. Click the red X to close the Laptop layout and it will send you back to the Floor 2 layout. Click the laptop again and once again close it. This time you see the HUD seems to be missing. If you move the player to the top left corner of the map you can see the HUD sprite in the background but it's behind some layers. It needs to on top and should stay in place when moving the player around like it does when you start the game.
Thanks for taking the time to read my post. I appreciate any help you can offer.
If I start the game in the Laptop layout and close it out, it loads up the Floor2 layout fine. But if I start it in Floor2, go to the laptop layout and close it out, the transition back to Floor2 exposes the problem.
A look at the debug output shows the layer index numbers are not changing but the Z index when rendered seems to be changing. How can i check the rendered Z indexes?
Please help, I cannot progress any further without solving this problem. I plan to have more of these type transitions and I must know how to fix them to make it worth spending any more time on this project.
I just noticed when moving back to Floor2 from Laptop, the Laptop layout is still rendered but sits behind the Floor2 layout. Shouldn't the previous layout be destroyed once another layout is called? Can we destroy layouts using events?
It because your global spr_HUD is on different levels. Keep the same number of levels across layouts and it fixes the problem. Otherwise C2 sees the object moved to layer 1, and when it goes back again, it's still on level 1. A side effect of Global objects I guess.
Thank you very much for taking the time to help me blackhornet. I tried adding the additional layers and named them the same as they are on the other layouts but I still have a problem I don't know how to fix. The HUD layer now seems to remain in place, but objects from the Laptop layout remain on the screen after moving back to Floor2. I have replaced the capx with the current version. Would you be kind enough to fix it and make it available to me for download please?
Here is another experiment that is very close to being perfect. I left the HUD on it's own layer and moved all the Laptop sprites to their own layer. The only problem with this one is the spr_HUD sprite moves if you go back and forward between layouts.
You've done it again. You have 8 layers on Laptop, but only 7 on the others. I personally don't use Global objects. They are more trouble than they are worth.
Sorry, I forgot to mention that I tried duplicating the 7 layers and still had problems. I'll do it again when I get home later and report back. I stumbled across the 8 layer solution after trying the 7. Still problems with both. Can you get the 7 layer version to work properly?
Yes. I'm not sure why you are using Global objects anyway. You are placing the spr_HUD object on each layout, so it's pointless making it Global. spr_lenovo_icon also gets confused. Making it non-global fixes that glitch too.
Develop games in your browser. Powerful, performant & highly capable.
Thanks again for your help. Converting it non-global seems to have solved my problems! I guess I am confused at what global means. I thought by creating an object as global I could use it on numerous layouts instead of creating one object per layout?