Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Infinite World Bounds?


blizzardmuffin
 Share

Recommended Posts

I have an infinitely scrolling tile sprite as the background for my game. I want to use a camera to move instead of creating the illusion of movement by using: bg.tilePosition.x -= player.spd

 

But, since the background is infinite and I need to set the world bounds, it can't be an infinite world. What would be the best way to do this?

 

Thanks

Link to comment
Share on other sites

Have you tried what's been tried in some doodle jump like games:

  • A world that is 2 times larger and higher than the camera "window"
  • Camera follows the player
this.game.camera.follow(this.player);this.game.camera.focusOnXY(0, player.position.y);
  • Constantly move the world bounds
//Position and size the worldthis.game.world.setBounds(windowWidth + player.position.x, windowHeight + player.position.y, windowWidth*2, windowHeight*2);//Move the tilesprite (fixed to camera) depending on the player's positiontileSprite.tilePosition.y = -camera.view.y;
It should do the trick.
I never use tile map with tiles positionned so I can't help you with this. But with "normal" sprites manually positionned it should work fine. We define the world's bounds but objects position are still relative to where they first were.
 
I have already done it before, only in a doodle-jump like game but this should also work on the horizontal axis.
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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