Jump to content

Recommended way to create an infinitely scrolling game


Martti Laine
 Share

Recommended Posts

I originally tweeted this but @photonstorm suggested me to post it here so there's space to answer. Maybe it'll be easier to find on Google too.

 

What would the recommended way be for building a game that scrolls infinitely? An example that I can think of is Mega Jump for iOS, or Winter Bells.

 

I can think of a few different ways. If I were to build this from scratch, I would (1) most likely just move the obstacles/entities down, excluding the player.

 

However, I think with Phaser one should utilize the built-in physics. One possibility is to (2) position the player fixed to the camera and then move the camera. This isn't a very good solution, at least in my tests, as the world has to be large (and in fact infinity isn't a native option at all) and the fixed positioning can mess up collision detection.

 

Another solution would be to (3) use gravity to pull the entities down. This seems a bit hacky to me. It might have unexpected downsides.

 

Are there any other solutions? Is there a built-in way to do this?

Link to comment
Share on other sites

I would suggest taking a look at the different Flappy Bird tutorials out there, specifically those by codevinsky or lessmilk, because really it's the same as what you need but you just have to flip it vertically. The same object re-spawning, etc would apply. You can find links to them all in the pinned tutorials section in this forum, or on the phaser home page if you dig through the news list a little bit.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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