2DPhysics_PointCollision.lua 643 B

1234567891011121314151617181920
  1. screen = PhysicsScreen(10, 60)
  2. lastEntity = nil
  3. for i=0,50 do
  4. shape = ScreenShape(SHAPE_RECT, 30,15)
  5. shape:setRotation(random(360))
  6. shape:setPosition(random(640), random(480))
  7. screen:addCollisionChild(shape, ENTITY_RECT)
  8. end
  9. function Update(e)
  10. if lastEntity ~= nil then lastEntity:setColor(1.0,1.0,1.0,1.0) end
  11. local mouse = Services.Core:getInput():getMousePosition()
  12. local entity = screen:getEntityAtPosition(mouse.x, mouse.y)
  13. if entity ~= nil then
  14. entity:setColor(1.0, 0.0, 0.0, 1.0)
  15. lastEntity = entity
  16. end
  17. delete(mouse)
  18. end