PhysicsScreenEvent.lua 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. require "Polycode/Event"
  2. class "PhysicsScreenEvent" (Event)
  3. EVENT_NEW_SHAPE_COLLISION = 0
  4. EVENT_END_SHAPE_COLLISION = 1
  5. EVENT_SOLVE_SHAPE_COLLISION = 3
  6. function PhysicsScreenEvent:__index__(name)
  7. if name == "localCollisionNormal" then
  8. retVal = Physics2D.PhysicsScreenEvent_get_localCollisionNormal(self.__ptr)
  9. if Polycore.__ptr_lookup[retVal] ~= nil then
  10. return Polycore.__ptr_lookup[retVal]
  11. else
  12. Polycore.__ptr_lookup[retVal] = Vector2("__skip_ptr__")
  13. Polycore.__ptr_lookup[retVal].__ptr = retVal
  14. return Polycore.__ptr_lookup[retVal]
  15. end
  16. elseif name == "worldCollisionNormal" then
  17. retVal = Physics2D.PhysicsScreenEvent_get_worldCollisionNormal(self.__ptr)
  18. if Polycore.__ptr_lookup[retVal] ~= nil then
  19. return Polycore.__ptr_lookup[retVal]
  20. else
  21. Polycore.__ptr_lookup[retVal] = Vector2("__skip_ptr__")
  22. Polycore.__ptr_lookup[retVal].__ptr = retVal
  23. return Polycore.__ptr_lookup[retVal]
  24. end
  25. elseif name == "localCollisionPoint" then
  26. retVal = Physics2D.PhysicsScreenEvent_get_localCollisionPoint(self.__ptr)
  27. if Polycore.__ptr_lookup[retVal] ~= nil then
  28. return Polycore.__ptr_lookup[retVal]
  29. else
  30. Polycore.__ptr_lookup[retVal] = Vector2("__skip_ptr__")
  31. Polycore.__ptr_lookup[retVal].__ptr = retVal
  32. return Polycore.__ptr_lookup[retVal]
  33. end
  34. elseif name == "impactStrength" then
  35. return Physics2D.PhysicsScreenEvent_get_impactStrength(self.__ptr)
  36. elseif name == "frictionStrength" then
  37. return Physics2D.PhysicsScreenEvent_get_frictionStrength(self.__ptr)
  38. end
  39. end
  40. function PhysicsScreenEvent:__set_callback(name,value)
  41. if name == "impactStrength" then
  42. Physics2D.PhysicsScreenEvent_set_impactStrength(self.__ptr, value)
  43. return true
  44. elseif name == "frictionStrength" then
  45. Physics2D.PhysicsScreenEvent_set_frictionStrength(self.__ptr, value)
  46. return true
  47. end
  48. return false
  49. end
  50. function PhysicsScreenEvent:PhysicsScreenEvent(...)
  51. if type(arg[1]) == "table" and count(arg) == 1 then
  52. if ""..arg[1]:class() == "Event" then
  53. self.__ptr = arg[1].__ptr
  54. return
  55. end
  56. end
  57. for k,v in pairs(arg) do
  58. if type(v) == "table" then
  59. if v.__ptr ~= nil then
  60. arg[k] = v.__ptr
  61. end
  62. end
  63. end
  64. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  65. self.__ptr = Physics2D.PhysicsScreenEvent(unpack(arg))
  66. Polycore.__ptr_lookup[self.__ptr] = self
  67. end
  68. end
  69. function PhysicsScreenEvent:getFirstEntity()
  70. local retVal = Physics2D.PhysicsScreenEvent_getFirstEntity(self.__ptr)
  71. if retVal == nil then return nil end
  72. if Polycore.__ptr_lookup[retVal] ~= nil then
  73. return Polycore.__ptr_lookup[retVal]
  74. else
  75. Polycore.__ptr_lookup[retVal] = ScreenEntity("__skip_ptr__")
  76. Polycore.__ptr_lookup[retVal].__ptr = retVal
  77. return Polycore.__ptr_lookup[retVal]
  78. end
  79. end
  80. function PhysicsScreenEvent:getSecondEntity()
  81. local retVal = Physics2D.PhysicsScreenEvent_getSecondEntity(self.__ptr)
  82. if retVal == nil then return nil end
  83. if Polycore.__ptr_lookup[retVal] ~= nil then
  84. return Polycore.__ptr_lookup[retVal]
  85. else
  86. Polycore.__ptr_lookup[retVal] = ScreenEntity("__skip_ptr__")
  87. Polycore.__ptr_lookup[retVal].__ptr = retVal
  88. return Polycore.__ptr_lookup[retVal]
  89. end
  90. end
  91. function PhysicsScreenEvent:__delete()
  92. Polycore.__ptr_lookup[self.__ptr] = nil
  93. Physics2D.delete_PhysicsScreenEvent(self.__ptr)
  94. end