Page 1 of 1

Simple question...

PostPosted: Wed Jan 18, 2006 4:20 pm
by Troodon
I have an moving background actor. How can I make that when the actor goes out of view it returns from another direction.

|O___________________|

|_______:::O__________|

|_________________:::O|

->

|O____________________|

PostPosted: Wed Jan 18, 2006 4:27 pm
by BeyondtheTech
supposing your width of the screen is 640 pixels and your actor is moving towards the right.

if the position of the actor is greater than 640, subtract 640.

if (x>640) x-=640;

that will make your actor wrap around to the left side.

re:

PostPosted: Wed Jan 18, 2006 4:36 pm
by Troodon
Thank you! It works!

re:

PostPosted: Wed Jan 18, 2006 4:45 pm
by Troodon
I'm sorry for asking stupid questions, but how can I make the same effect for the left side? I tried to add this
if (x<640) x+=640;

but the actor only starts making some strange movements.

PostPosted: Wed Jan 18, 2006 6:54 pm
by BeyondtheTech
it should be

if (x<0) x+=640;

re:

PostPosted: Thu Jan 19, 2006 2:43 pm
by Troodon
It's not working...