Language

Entity:setRotation


Entity:setRotation(int angle)

Description

Set the entity's rotation.
Experimental. Changes are only visual (hitboxes don't change).
The entity will rotate around its upper-left corner.

Will only work on text, rectangle, sprite and animation.

Parameters

angle
The angle in degrees between 0 and 360.

Examples

Rotating an entity

You spin me right round

  1. local sp = getEntity("sprite1")
  2. local angle = 0
  3.  
  4. function onReset()
  5.     angle = 0
  6. end
  7.  
  8. function onUpdate(elapsed)
  9.     angle = (angle+(elapsed*180))%360
  10.     sp:setRotation(angle)
  11. end