Jump to content

Move tilesprite when camera changes position


GregDev
 Share

Recommended Posts

Hi guys, I'm new to the framework but I googled around abit and couldn't find an answer to this:  

I’m making a tile mapped game where the player needs to make their way through a tiled level by moving upwards.

To achieve this the camera follows the player around a rectangular world

1.thumb.png.147bbcc33f1302466b3b32cb9ac32496.png

My question is about creating 2 background TileSprites that scroll with the camera BUT not at the same speed as the camera to achieve the effect of having a background with TileSprite 1 in the distance and TileSprite 2 in the far distance 

Maybe something like an event handler that works like this:

onCameraPositionChange(yDistance){
    backgroundTileSprite1.scrollY -=  yDistance/2 
    backgroundTileSprite2.scrollY -=  yDistance/4 
}

Right now my setup is like this:

TileSprite 1 -> moves with the camera 

TileSprite 2 -> stays still in background using TileSprite.fixedToCamera

 

It looks okay right now, but I think this would convey a more convincing sense of distance.

Cheers and thank you!  

Edited by GregDev
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...