2DPhysics_Basic.lua 586 B

1234567891011121314151617181920
  1. -- Simple 2D Physics example
  2. screen = PhysicsScreen(10, 60)
  3. -- add a static floor shape
  4. shape = ScreenShape(ScreenShape.SHAPE_RECT, 600,30)
  5. shape:setColor(0.0,0.0,0.0,1.0)
  6. shape.position.x = 640/2
  7. shape.position.y = 400
  8. screen:addPhysicsChild(shape, PhysicsScreenEntity.ENTITY_RECT, true)
  9. -- add 200 falling blocks
  10. for i=0,200 do
  11. shape = ScreenShape(ScreenShape.SHAPE_RECT, 20,5)
  12. shape:setRotation(random(360))
  13. shape.position.x = random(640)
  14. shape.position.y = random(300)
  15. screen:addPhysicsChild(shape, PhysicsScreenEntity.ENTITY_RECT, false);
  16. end