Scroll-Resistant Sprite?


I am experimenting with the parallax scrolling and am wondering, is it possible to have a sprite image that remains on screen in a fixed position while the background and game elements scroll horizontally? I am trying to create a bit more depth, and while I can take the majority of my background and give it a slight bit of movement as the player scrolls, I’d like the moon to stay put in the corner of the screen to add that much more depth.

Right now, The player is walking through a forest trail. The background scrolls at a slower rate than the player’s area. I have trees that scroll slower in the background, and are on layer 1 behind the player (layer 2), and I have larger silhouette trees that the player disappears behind as he walks (layer 3).

Just wondering if this is possible at all. If only a label or energy bar could be a sprite of my own choosing, this would resolve my intense desire to finally be happy in life.

One idea I just thought of…Maybe I could make a moon sprite that exactly followed the player’s movement? So if the player jumped up or walked right, the moon would do the same and create that effect of staying in place?

Is this possible, great and wonderful FlowLab gurus?


You could switch to the top layer and that would work, but it would go above everything. Your idea is close to the best idea though. I think I might have an idea. Go to the moon object and add 2 extractors to extract the X and Y of the player. Have each of them connect to a number (set) and an always to the number (in).
Connect the X number and Y number to a position X and Y. That will make the moon stay exactly behind you all the time. Now you need 2 equations. Do you know how those work? Have the X number go to A and edit, put any number for Being, then make the equation be A+B. Connect always to the last button it’s like check or something under B. Repeat this for Y, and use these for the position instead. Keep changing the numbers in the equation until the moon stays where you want it.

Thanks. I will take a look and try out your idea later today!

Ah… I found a very simple way to do what I was shooting for. I just put the moon image on the GUI layer. :slight_smile: Of course, if you let your player jump as high as the moon, they will jump behind it due to the layer order. But I intend to correct that by limiting the jump height.

Here is a rough idea of what I’ve been talking about:

Arrow keys move 4 ways (well, eventually, the UP will allow you to enter places or interact with people/things), SPACE to jump.

Interesting note: Right now, if you repeatedly jump, you can levitate and flap your arms not unlike a chicken.

Now, my next question: I’ve noticed that the tree silhouettes don’t always clear the screen before disappearing. Any idea what I am doing wrong?


Argh… quick second question to anyone who can help: I’ve noticed that it is glitchy whether or not it tiles my background scene as you scroll. Sometimes it works, sometimes it reverts to only the grey background. Any idea why the background would disappear? Such interesting quirks to figure out! :slight_smile:


And sorry, Mhx Ar, I just realized you mentioned this moon-on-GUI approach in your previous message. Thanks!

Turn on the scroll view autoscroll Y and then the parallax will turn on.
As for the trees disappearing, grazer made an update where objects off screen disappear so they won’t lag you, but bigger objects use the top left corner as the main block, so when that corner goes off screen, the whole object disappears. Don’t worry, it’s not you.

The weird thing that happens is when I turn on the Y parallax, too, the objects on my screen (the path and some trees) float up a few squares and so alignment is off. Could one of the object characteristics (maybe involving gravity) be causing this? If so, why not also when I remove the Y scroll?

This is tricky, since this first level (as I imagine it) involves scrolling right and then heading downward a ways, which will need the Y scroll function.

Drag. If only the update erased the objects once the very last onscreen part left the view. I guess this will add to the quirkiness of my game? :slight_smile:

Yes, I know backgrounds are a pain. Maybe add some trees on the game layer so it’s a thicker forrest and you won’t notice the background trees float up.

Hey Paskeyland,

Really nice looking start. Mhx is right that the trees disappearing is a glitch related to an optimization, that is something that should be fixable on my end. I looked for the floating trees you described, but didn’t see them - are they fixed or am I looking at the wrong thing?

I know exactly what he’s talking about. When you have a background, and you make your level have more depth so you can go down, the background floats up as you go down, and auto starts 1 block up by default. The background matches his road and tree height, but when you add depth, the background goes up and everything is out of place now.

The camera position drops to the height of the player,
but before it would be the center of the screen, above the player.

Hi grazer! Mhx Ar has the issue correct. At the end of this level I want the character to fall down a great height into the underground game world, but when I add level scroll area below the game screen, it throws off some objects’ Y positioning. Right now it displays okay because I removed the extra area. I might try a workaround where the ground opens, the character falls and then a new level begins where the character is falling. Thanks for your help!

I have another idea. How about a camera? Remember that whole thing about the extractors and the moon? Do that with an invisible, non solid object.

(camera object behaviors) Always — extractors for x and y of player — equations of whatever number for A+B — position x and y.

Then a camera will always follow you from above, and give that camera the scroll cam instead. It can be like that annoying fairy in Legend of Zelda games too, if you wanted that.

You could actually probably skip that junk and instead just do
(Player) Attacher — camera object,
and give (camera object) Always — number 500 — (+Y) Position (Pixels) or something like that.
Try that, the attacher may help better. Camera object gets the scroll cam now.

Mhx Ar, are you talking about the stationary moon idea, or for getting around the Y scroll issue? Thanks!

Intriguing start Paskeyland, looks good. Looking forward to seeing how the game develops.

Thanks MuddyApples! I have half of the ridiculous idea written. We’ll see… :slight_smile:

Y scroll. Make a new object and give it the scroll cam instead. Have that object always stay above you, and you fixed your problem.