2DTransforms.lua 838 B

12345678910111213141516171819202122
  1. -- Simple example showing how to move, scale and rotate 2d entities
  2. screen = Screen()
  3. for i=0,9 do
  4. image = ScreenImage("Resources/polycode_logo.png")
  5. screen:addChild(image)
  6. -- Set position and position mode. Setting position mode to ScreenEntity.POSITION_CENTER, makes
  7. -- the entity's anchor point its middle, rather than its top left.
  8. -- Try commenting out that line and see how it affects the transfomrations
  9. image.position.x = 160+(42*i)
  10. image.position.y = 230
  11. image:setPositionMode(ScreenEntity.POSITION_CENTER)
  12. -- Rotate the image. You can alternatively call image:setPosition(45 * i)
  13. image.rotation.roll = 45 * i
  14. -- Set the image scale. You can alternatively call image:setScale(1.0-(0.1*i), 1.0-(0.1*i))
  15. image.scale.x = 1.0-(0.1*i)
  16. image.scale.y = 1.0-(0.1*i)
  17. end