0
\$\begingroup\$

I'm looking to make my clouds wrap around the screen in my game (like the picture).

enter image description here

Right now it just continues off the screen. The current movement code is:

Cloud.center = CGPointMake(Cloud.center.x +0.032, Cloud.center.y)
\$\endgroup\$
2
\$\begingroup\$

One simple options is to just draw everything twice.

Consider a screenful of your background clouds and other stuff that you want to scroll:

+------+
| CC   |
|    RR|
+------+

(Assume that CC represents a cloud, and maybe RR represents a rock or some other background object.)

If you have a "second copy" (logically or physically) of this background data, you can arrange them so they're adjacent:

First:  Second:
+------+------+
| CC   | CC   |
|    RR|    RR|
+------+------+

You scroll the two tiles of background scenery across the view until one of them falls entirely out of view. At this point, you move (again, logically or physically) the background tile that is entirely off the screen back behind the tile that is currently entirely on the screen, and continue scrolling.

|improve this answer|||||
\$\endgroup\$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.