Language

Entity:moveTo


Entity:moveTo(int x, int y, float delay, MOVEMENT type)

Description

Will move the entity to the new x and y position over time.

Parameters

x
The new X position.
y
The new Y position.
delay
How long the animation will last in seconds.
type
The type of MOVEMENT to use.

Examples

Moving a sprite

Move a sprite 1000 pixels on the right, over 2 seconds, and with a smooth movement.

  1. local wall_spikes = getEntity("wall_spikes")
  2.  
  3. function onTrigger(name, state)
  4.     if name == "trigger_wall" and state then
  5.         wall_spikes:moveTo( wall_spikes:getPosition()[1]+1000, wall_spikes:getPosition()[2], 2.0, MOVEMENT_SMOOTH_OUT)
  6.     end
  7. end