2DPhysics_PointCollision.lua 497 B

123456789101112131415161718
  1. screen = PhysicsScreen(0.5, 60)
  2. lastEntity = nil
  3. for i=0,50 do
  4. shape = ScreenShape(ScreenShape.SHAPE_RECT, 30,15)
  5. shape:setRotation(random(360))
  6. shape:setPosition(random(640), random(480))
  7. screen:addCollisionChild(shape, PhysicsScreenEntity.ENTITY_RECT)
  8. end
  9. function onMouseMove(x,y)
  10. if lastEntity ~= nil then lastEntity:setColor(1.0,1.0,1.0,1.0) end
  11. local entity = screen:getEntityAtPosition(x,y)
  12. if entity ~= nil then
  13. entity:setColor(1.0, 0.0, 0.0, 1.0)
  14. lastEntity = entity
  15. end
  16. end