1
\$\begingroup\$

I have a BIG problem!! I want to make something like old space shooter games like “Asteroids”, where the ship, when going out of the screen, is reappearing at the other side. For example, when the ship go out at the top of the screen, it come back at the bottom. But in my game, there’s a camera following the player, showing only a quarter of the world, and I want to simulate an infinite world this way! Here’s a picture showing what I mean :

Infinite scrolling explanation

What I thought doing was simulate the scroll by only moving game objects, stored in an array, but not the player, and calculating at every frame if the objects are out of the world boundary and re-adding them at the other end of the world (i.e going out at the left would add it back at the right).

But I don’t really like that way of doing… I’d like something more… intuitive..?

Do you guys have any idea of how doing it? Like, any tutorial on the web or just the right words to explain what I mean so I could do a bright research on google (I’m french, so I had a really hard time writing that question)!

Thank you in advance!

\$\endgroup\$
  • \$\begingroup\$ There is a perfect article written about this subject here: learn-cocos2d.com/2012/12/ways-scrolling-cocos2d-explained Perhaps LearnCocos2D can post an answer \$\endgroup\$ – congusbongus Dec 24 '13 at 4:29
  • \$\begingroup\$ intuitive is relative (and a matter of experience). You're on the right track. The real problem with this design is the camera movement. What you really need to do is to not wrap any object. Only when the player moves out of bounds you need to offset all (!) objects by the same amount (ie diff between player old and new position). The camera is always centered on the player and updated after player's position changed. \$\endgroup\$ – LearnCocos2D Dec 24 '13 at 8:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.