Skeleton.lua 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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:playAnimationByName(animName, weight, once, restartIfPlaying)
  23. local retVal = Polycode.Skeleton_playAnimationByName(self.__ptr, animName, weight, once, restartIfPlaying)
  24. end
  25. function Skeleton:setBaseAnimationByName(animName)
  26. local retVal = Polycode.Skeleton_setBaseAnimationByName(self.__ptr, animName)
  27. end
  28. function Skeleton:stopAllAnimations()
  29. local retVal = Polycode.Skeleton_stopAllAnimations(self.__ptr)
  30. end
  31. function Skeleton:stopAnimationByName(name)
  32. local retVal = Polycode.Skeleton_stopAnimationByName(self.__ptr, name)
  33. end
  34. function Skeleton:Update(elapsed)
  35. local retVal = Polycode.Skeleton_Update(self.__ptr, elapsed)
  36. end
  37. function Skeleton:getBoneByName(name)
  38. local retVal = Polycode.Skeleton_getBoneByName(self.__ptr, name)
  39. if retVal == nil then return nil end
  40. local __c = _G["shared_ptr<Bone>"]("__skip_ptr__")
  41. __c.__ptr = retVal
  42. return __c
  43. end
  44. function Skeleton:bonesVisible(val)
  45. local retVal = Polycode.Skeleton_bonesVisible(self.__ptr, val)
  46. end
  47. function Skeleton:getNumBones()
  48. local retVal = Polycode.Skeleton_getNumBones(self.__ptr)
  49. return retVal
  50. end
  51. function Skeleton:getBone(index)
  52. local retVal = Polycode.Skeleton_getBone(self.__ptr, index)
  53. if retVal == nil then return nil end
  54. local __c = _G["shared_ptr<Bone>"]("__skip_ptr__")
  55. __c.__ptr = retVal
  56. return __c
  57. end
  58. function Skeleton:addBone(bone)
  59. local retVal = Polycode.Skeleton_addBone(self.__ptr, bone.__ptr)
  60. end
  61. function Skeleton:removeBone(bone)
  62. local retVal = Polycode.Skeleton_removeBone(self.__ptr, bone.__ptr)
  63. end
  64. function Skeleton:getBoneIndexByBone(bone)
  65. local retVal = Polycode.Skeleton_getBoneIndexByBone(self.__ptr, bone.__ptr)
  66. return retVal
  67. end
  68. function Skeleton:__delete()
  69. if self then Polycode.delete_Skeleton(self.__ptr) end
  70. end