[SOLVED] Parallax Scrolling with Actors' Layer

gcarne

  • Posts: 111
I am using several background layers mixed with several tile layers to make an advanced parallax scrolling. I want the actors to follow a scroll with a speed depending on the layer where the actors are set.

To simplify my question, assume that I have one background LayerID 1 and one tile layer LayerID 2. Actor types are placed on LayerID 2. I can set LayerID 1, which is a background, to scroll using the block "set autoscroll speed for background. . .". How do I make LayerID 2 to scroll with the same speed as LayerID 1? Changing the scroll factor setting on a tile layer does not itself move the tile layer and there is no block to scroll a tile layer.

I am not using the camera.

Thanks.

« Last Edit: December 31, 2020, 03:34:46 am by gcarne »

Luyren

  • *
  • Posts: 2506
https://luyren.itch.io/luyrens-miscellaneous-stencyl-behaviors
There is a behavior here for individual actor parallax scrolling. Attach it to your actor, configure the parallax scrolling with a bit of trial and error and the instructions on the attributes. You might be able to achieve what you need with it.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

gcarne

  • Posts: 111
Thanks Luyren. Will try it out before the end of the year.  :)

gcarne

  • Posts: 111
Hi Luyren,

I did attach the Actor Parallax to one actor and tried different values. The actor makes a little jump when created, but it does not scroll. Does it only work in connection with using a camera (I am not using camera)?

The actor in question is set to "move normal", "cannot rotate" and "no gravity."

« Last Edit: December 30, 2020, 02:06:32 pm by gcarne »

Luyren

  • *
  • Posts: 2506
Yes, it is tied to the camera movement.

So you have backgrounds scrolling and want to create actors to move? In that case you just have to set their speeds appropriately. If that's not it then I'm afraid I don't understand your desired result.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

gcarne

  • Posts: 111
Correct. I have three backgrounds at different scroll speeds. Then I have layers with actors between the backgrounds and one layer with actors on top. The actors on all three actor layers should scroll with different speeds depending on the background layer behind the actor creating a nice 3D-effect. Originally I thought that I could scroll an actor layer, but that does not seem to be possible. I now have to figure out if I can perhaps use a camera following an invisible actor and with your behavior attached to the other actors, or if I shall push each actor individually using a "slide actor self" block in a behavior. I have almost 100 actors so I need to look for the solution that gives me the least programming effort.

Luyren

  • *
  • Posts: 2506
You could create a behavior with a map attribute. Each key for the map is the layer name or ID (depending on your preference), and its values is the time to slide your actor. Then, retrieve that value based on the actor's layer and slide your actors. That's the best I got given your description.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

gcarne

  • Posts: 111
Just tried the block "set x-speed for actor" which I can use use for available actors and in a behaviors for last created actor or self, perhaps combining it with what you suggested above. It is like peeling an onion, one layer at a time. Once the actors are off the screen, I guess I have to kill them in order not to overload resources.

I do truly appreciate your support and when I am not battling immediate problems, I will look at your pdf, There might be things in there that I could use. I would then also revisit you website. 

gcarne

  • Posts: 111
Apparently tile layers cannot be scrolled. I have no need for a camera and cannot therefore use the Luyren's Parallax behavior. Therefore I will use the set speed block for each actor.

« Last Edit: December 31, 2020, 03:34:15 am by gcarne »