Hi, how can I make an sprite move exactly 600 units to the right using behaviors MoveTo or Custom Movement?
I can't use 'Go to position (x+600,y)', because I need the sprite to get out of the layout so it wraps horizontally.
Develop games in your browser. Powerful, performant & highly capable.
Let's make this a bit easier: instead of using Custom Movement or MoveTo, you can just calculate the position the Sprite needs to go since you know the width of the Layout.
This just works if I understood you correctly and you want to push the Sprite 600 pixels to the right to make it appear again on the left.
So, the action you need is the following:
Sprite: set X to: 600-(LayoutWidth-Sprite.X)[/code:1du7vroh]
That's it, basically.
What happens here?
[i]LayoutWidth-Sprite.X[/i] calculates the x distance needed to move the current Sprite.X to the edge of the Layout.
When that gets substracted from 600, you get the distance from the left edge of the layout (x=0) to the wanted x position.
This works for your layout scale. If your layout is bigger than what is displayed, you can use [i]WindowWidth[/i] instead.
I hope I could help. :)