When i change a layer of an object it sticks on the screen ,how can I prevent this ?
That’s the point of layers, they each have their own camera. If you want the camera of that layer to move you got to move it.
I wanna add an effect on an object, how can i do it without layers or changing the animation ?
one of the implementation options: create a new object with an effect, increase its z position (thereby raising its render above the others), then change its position in relation to the main object
Use layers… don’t over think the camera part, it’s really simple.
Do all your fancy logic for the camera in the base layer.
For each additional layer you add that should be in sync with the base layer just add two actions:
Change X Position of Camera (layer:“Foreground”): set to CameraX()
Change Y Position of Camera (layer:“Foreground”): set to CameraY()
Just change Foreground to your new layer name. It will be in Sync and you can create a layer per effect and just move your sprites between those layers to add or remove the effect.
Here’s an advanced example (which is part of an example game I’m working on).
Ignore the condition for right now, but I have 5 different layers (and therefore 5 different cameras) I’m working with:
Death Effect layer
Dash Effect layer
BG1 and 2 are parallax layers, meaning that the move slower than the main layer but still follow it.
Death and Dash effect are layers that are used explicitly for objects to have an effect when it’s moved to it. Since those layers need to exactly mirror the main layer so that any objects swapped to the effects layers are still in the same place I expect them to be, their camera events are identical.