blizzardmuffin Posted February 23, 2015 Share Posted February 23, 2015 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 More sharing options...
Nepoxx Posted February 24, 2015 Share Posted February 24, 2015 I posted a similar question here: http://www.html5gamedevs.com/topic/9160-infinite-game/Hopefully the answers help you out (I never were able to achieve what I wanted, but there are good alternatives in there) Link to comment Share on other sites More sharing options...
ZoomBox Posted February 26, 2015 Share Posted February 26, 2015 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 playerthis.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 More sharing options...
Recommended Posts