I have checked all the forum posts and can’t find this info, please help. I would like to move a sprite from one position to another when a different sprite is clicked. I have set a mouse click to send a message to the other sprite. This sprite has a position behaviour active on receiving the message but I cannot see where to put the value for the new position. I am a complete newbie but must not be able to see something which is obvious. My game is an educational example of canal lock keeping. Opening the lock gate (by clicking) allows the water to flow from one side to the other (new sprite position). Any advice is greatly appreciated.
The position property has a few inputs:
- “x” - send a value here to update the “x” position
- “y” - send a value here to update the “y” position
- “+x” - send a value here to increment the “x” position
- “+y” - send a value here to increment the “y” position
There is also a setting in the position behavior that allows you to use pixel or grid positions when updating.
Here is an example: http://flowlab.io/game/play/447101
Click the red button to move the three other objects. One uses grid positions, the other two use pixels. I also added an example of how you could use some easing to smooth the animation if desired.
Hope this helps.
Thanks. I was putting the number behaviour after the position and that is probably why it wouldn’t work. The smooth animation is exactly what I was looking for thanks.