Parallax Background Issues

This forum is currently in read-only mode.
From the Asset Store
Set of 10 Parallax Background to make pixel art game.
  • I've made a quick video to show the problem,

    I'm starting to throw things together to see what works. It's all work in progress of course, animations, sprites, textures, blah blah blah the usual "please don't crucify my artwork just yet" comments <img src="smileys/smiley17.gif" border="0" align="middle">

    I have two issues with the scrolling background at the moment. The first is that it always seems to 'snap' to the edge of the screen, and 'snap' out again when I move away from the edge. I could always have the player's starting position sufficiently into the level so that the edge of the screen is never encountered, but I would rather figure out what's causing the issue and learn how to avoid it in the future.

    Secondly, the Y axis looks a little funky. I think it's because all the layers are set to 100% Y scroll speed, so my eye is telling me that it looks odd since they all move up or down at the same speed - whereas they should be slightly offset. However, changing the Y axis scroll speed led to my background appearing at odd locations (I could just about see the tops of the trees. The rest of the background was buried below the player's position).

    Any advice on how to deal with Parallax backgrounds? The only tutorials I could find were for C2.

    Bonus Question: Those tree roots my wolf runs right over? I want them to have collision detection. Easy enough - I've created small invisible boxes with the 'solid' attribute, the standard approach in CC platformers. But what I also want to do is have a sprint ability where holding down Left Shift makes the wolf run faster and ignore small obstacles like the tree roots, running right over them unhindered. I looked for a way to disable the solid attribute through events, but couldn't see the option. Eg:

    Left Shift button is down --> Obstacle: Disable Solid Attribute

    Left Shift button is released --> Obstacle: Enable Solid Attribute

    Is there any way to achieve this?

    Many thanks for reading, and for any advice you can provide <img src="smileys/smiley12.gif" border="0" align="middle">

  • I don't know if you use images or build the parallax layers with lots of sprites.

    I've used looping images all my dev years and all I do is "set X to ScrollXLeft/2" and such. Super-simple, but only really good for smaller and undynamic textures.

  • They are looping images, yes. I have four large images with transparency (png files) each on their own layer. I then have each layer set to scroll 10% slower than the layer in front. So the first background layer scrolls at 90% speed, the second at 80%, etc.

    You can only see the first two layers of the background in the video. The third and fourth are of the tree tops leading into the distance, viewable when the player reaches higher sections of the level. I then want a FIFTH layer showing mountains in the really far distance.

    They're large images (each 2048 pixels wide, and either 1024 or 2048 high) so I might have to cut back on the ambition in order to save VRAM. I'm testing it on three different systems, and so far getting smooth gameplay on all three. It's early days though, and I've obviously got a heck of a lot more to add before it's anything like a playable game.

  • Set your layout scrolling properties to unbounded, and it will get rid of the snapping. Then use invisible walls or something to prevent leaving the layout/seeing black edges.

    Sadly, setting the scroll speed % is probably the best way I've found of handling parallax. It does mean you'll need trial and error to make your maps, or create an in-game map creator though.

    As for the bonus question, maybe have private variables for each object storing their start/old X and Y. When sprinting, move them to -10000,-10000 or whatever and then place them back at their starting/old X and Y when done. Have to make sure the player doesn't stop sprinting in the middle of one though I guess.

    As for the image sizes, can you break them into smaller tiles? Like 512 by 256 or 512? It does mean lower quality images if you choose to just shrink the graphics and scale them up in-game though.

    These are fairly short answers, so any further explaining I'd be happy to give when I next have time. Hope this helps though.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Haha! Oh man...

    So I've checked the unbounded scrolling box, and used an invisible wall to stop the player getting in view of the black edges. Pretty much exactly the same solution I already had: starting the player roughly 1000 pixels into the level and using an invisible wall. But I may as well tick the unbounded option too in case someone with an insane screen resolution plays. Better to see a black edge than have snapping backgrounds.

    I've also had to bite the bullet and just learn through trial and error where the backgrounds need to be placed on the Y axis when using varying Y scroll speeds. Took a while, but it's all working well on various resolutions now (from 1280x720, right up to 1920x1080), so yay!

    The crazy issue now is the bonus question(!) I asked about. Thanks to JayJay I got the Obstacle boxes to vanish and appear at will. But his guess about the issues that would lead to were a little off:

    "Have to make sure the player doesn't stop sprinting in the middle of one though I guess."

    Stopping in the middle turns out to be fine. The player just gets moved up a bit as the object appears from beneath him. Nothing catastrophic there. But... Pressing the shift button to start sprinting while already on top of an obstacle (such as a big tree root) not only teleports the obstacle box off the screen, but also takes the player along for the ride <img src="smileys/smiley17.gif" border="0" align="middle" />

    Time for some coffee. My brain hates problem solving without a caffeine injection.

  • MY FRIEND TO DISABLE A COLLISION WITH THE USE SOLID OBJECTS IN ITS SPRINTES IVISIVEIS VARIABLES VARIABLE VARIABLE IMPACT ABILITA a "0" DISABLE COLLISION ... IF YOU NEED HELP COMMAND A TUTORIAL.

    ramosalvaro

    MEU AMIGO PARA DESABILITAR A COLIS�O COM OS OBJETOS SOLIDOS UTILIZE VARIAVEIS EM SEUS SPRINTES IVISIVEIS VARIAVEL 1 ABILITA COLIS�O VARIAVEL" 0" DESABILITA COLIS�O...SE PRECISAR DE AJUDA TE MANDO UM TUTORIAL.

    ramosalvaro

  • Glad to hear it's mostly working. Maybe try using a private variable system for the player too, so they are set to the exact position they started in right after the box is moved?

    Either that, or try moving the box down and right out of the map, so that it doesn't "pull up" on the player, as the platform movement tries to ride anything that moves above it.

    Still, that bug could turn out to be a really cool feature when making rocket elevators/teleport lifts in games, just move the block the player stands on and they go with it!

  • Still, that bug could turn out to be a really cool feature when making rocket elevators/teleport lifts in games, just move the block the player stands on and they go with it!

    This is true! Thanks for your help with the other issues. Guess this one is just going to take more experimentation than usual before I get it working well.

    Sounds like Ramosalvaro knows the answer! <img src="smileys/smiley4.gif" border="0" align="middle" />

    But he only speaks Caps Lock Spanish <img src="smileys/smiley19.gif" border="0" align="middle" />

  • No problem -Silver- glad to help! I think moving the box to +10000, +10000 should work, then it doesn't try to move through the player.

    Hopefully that'll work out for you!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)