2
0

Skeleton.lua 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. require "Polycode/Entity"
  2. class "Skeleton" (Entity)
  3. function Skeleton:Skeleton(...)
  4. local arg = {...}
  5. if type(arg[1]) == "table" and count(arg) == 1 then
  6. if ""..arg[1].__classname == "Entity" then
  7. self.__ptr = arg[1].__ptr
  8. return
  9. end
  10. end
  11. for k,v in pairs(arg) do
  12. if type(v) == "table" then
  13. if v.__ptr ~= nil then
  14. arg[k] = v.__ptr
  15. end
  16. end
  17. end
  18. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  19. self.__ptr = Polycode.Skeleton(unpack(arg))
  20. end
  21. end
  22. function Skeleton:BlankSkeleton()
  23. local retVal = Polycode.Skeleton_BlankSkeleton(self.__ptr)
  24. if retVal == nil then return nil end
  25. local __c = _G["Skeleton"]("__skip_ptr__")
  26. __c.__ptr = retVal
  27. return __c
  28. end
  29. function Skeleton:loadSkeleton(fileName)
  30. local retVal = Polycode.Skeleton_loadSkeleton(self.__ptr, fileName)
  31. end
  32. function Skeleton:playAnimationByName(animName, weight, once, restartIfPlaying)
  33. local retVal = Polycode.Skeleton_playAnimationByName(self.__ptr, animName, weight, once, restartIfPlaying)
  34. end
  35. function Skeleton:playAnimation(animation, weight, once, restartIfPlaying)
  36. local retVal = Polycode.Skeleton_playAnimation(self.__ptr, animation.__ptr, weight, once, restartIfPlaying)
  37. end
  38. function Skeleton:setBaseAnimationByName(animName)
  39. local retVal = Polycode.Skeleton_setBaseAnimationByName(self.__ptr, animName)
  40. end
  41. function Skeleton:setBaseAnimation(animation)
  42. local retVal = Polycode.Skeleton_setBaseAnimation(self.__ptr, animation.__ptr)
  43. end
  44. function Skeleton:stopAllAnimations()
  45. local retVal = Polycode.Skeleton_stopAllAnimations(self.__ptr)
  46. end
  47. function Skeleton:getBaseAnimation()
  48. local retVal = Polycode.Skeleton_getBaseAnimation(self.__ptr)
  49. if retVal == nil then return nil end
  50. local __c = _G["SkeletonAnimation"]("__skip_ptr__")
  51. __c.__ptr = retVal
  52. return __c
  53. end
  54. function Skeleton:addAnimation(name, fileName)
  55. local retVal = Polycode.Skeleton_addAnimation(self.__ptr, name, fileName)
  56. end
  57. function Skeleton:getAnimation(name)
  58. local retVal = Polycode.Skeleton_getAnimation(self.__ptr, name)
  59. if retVal == nil then return nil end
  60. local __c = _G["SkeletonAnimation"]("__skip_ptr__")
  61. __c.__ptr = retVal
  62. return __c
  63. end
  64. function Skeleton:stopAnimationByName(name)
  65. local retVal = Polycode.Skeleton_stopAnimationByName(self.__ptr, name)
  66. end
  67. function Skeleton:stopAnimation(animation)
  68. local retVal = Polycode.Skeleton_stopAnimation(self.__ptr, animation.__ptr)
  69. end
  70. function Skeleton:Update()
  71. local retVal = Polycode.Skeleton_Update(self.__ptr)
  72. end
  73. function Skeleton:getBoneByName(name)
  74. local retVal = Polycode.Skeleton_getBoneByName(self.__ptr, name)
  75. if retVal == nil then return nil end
  76. local __c = _G["shared_ptr<Bone>"]("__skip_ptr__")
  77. __c.__ptr = retVal
  78. return __c
  79. end
  80. function Skeleton:bonesVisible(val)
  81. local retVal = Polycode.Skeleton_bonesVisible(self.__ptr, val)
  82. end
  83. function Skeleton:getNumBones()
  84. local retVal = Polycode.Skeleton_getNumBones(self.__ptr)
  85. return retVal
  86. end
  87. function Skeleton:getBone(index)
  88. local retVal = Polycode.Skeleton_getBone(self.__ptr, index)
  89. if retVal == nil then return nil end
  90. local __c = _G["shared_ptr<Bone>"]("__skip_ptr__")
  91. __c.__ptr = retVal
  92. return __c
  93. end
  94. function Skeleton:addBone(bone)
  95. local retVal = Polycode.Skeleton_addBone(self.__ptr, bone.__ptr)
  96. end
  97. function Skeleton:removeBone(bone)
  98. local retVal = Polycode.Skeleton_removeBone(self.__ptr, bone.__ptr)
  99. end
  100. function Skeleton:getBoneIndexByBone(bone)
  101. local retVal = Polycode.Skeleton_getBoneIndexByBone(self.__ptr, bone.__ptr)
  102. return retVal
  103. end
  104. function Skeleton:__delete()
  105. if self then Polycode.delete_Skeleton(self.__ptr) end
  106. end