Character exiting the screen

I would like to ask for help. How will I make my character when he exits on the left part of the screen, he will appear on the right part of the screen and vice versa? Any suggestions? Thanks a lot
Game Editor discussion board
http://game-editor.com/forum/
x+=(view.width+width) * ((x>view.x+view.width) - (x<view.x));
skydereign wrote:You can add this event to the player.
player -> Out of Vision -> Script Editor
- Code: Select all
x+=(view.width+width) * ((x>view.x+view.width) - (x<view.x));
What it does is move the player by the view's width plus the actor's width forward or backward when it leaves the view. That way it will appear to the right or left of the view. The (x>view.x+view.width)-(x<view.x) part returns a 1 or -1 during an out of vision event, and that is used to determine which direction the actor needs to move in.
x-=(view.width+width) * ((x>view.x+view.width) - (x<view.x));
((x>view.x+view.width) - (x<view.x));
// that's pretty much saying (to the right of the screen) - (to the left of the screen)