Simple question...

Non-platform specific questions.

Simple question...

Postby Troodon » Wed Jan 18, 2006 4:20 pm

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____________________|
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Postby BeyondtheTech » Wed Jan 18, 2006 4:27 pm

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.
User avatar
BeyondtheTech
 
Posts: 270
Joined: Wed Mar 30, 2005 6:34 am
Location: Edison, NJ
Score: 4 Give a positive score

re:

Postby Troodon » Wed Jan 18, 2006 4:36 pm

Thank you! It works!
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

re:

Postby Troodon » Wed Jan 18, 2006 4:45 pm

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.
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Postby BeyondtheTech » Wed Jan 18, 2006 6:54 pm

it should be

if (x<0) x+=640;
User avatar
BeyondtheTech
 
Posts: 270
Joined: Wed Mar 30, 2005 6:34 am
Location: Edison, NJ
Score: 4 Give a positive score

re:

Postby Troodon » Thu Jan 19, 2006 2:43 pm

It's not working...
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron