Skeleton.lua 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. require "Polycode/SceneEntity"
  2. class "Skeleton" (SceneEntity)
  3. function Skeleton:Skeleton(...)
  4. for k,v in pairs(arg) do
  5. if type(v) == "table" then
  6. if v.__ptr ~= nil then
  7. arg[k] = v.__ptr
  8. end
  9. end
  10. end
  11. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  12. self.__ptr = Polycore.Skeleton(unpack(arg))
  13. end
  14. end
  15. function Skeleton:loadSkeleton(fileName)
  16. local retVal = Polycore.Skeleton_loadSkeleton(self.__ptr, fileName)
  17. end
  18. function Skeleton:playAnimation(animName)
  19. local retVal = Polycore.Skeleton_playAnimation(self.__ptr, animName)
  20. end
  21. function Skeleton:playAnimationByIndex(index)
  22. local retVal = Polycore.Skeleton_playAnimationByIndex(self.__ptr, index)
  23. end
  24. function Skeleton:addAnimation(name, fileName)
  25. local retVal = Polycore.Skeleton_addAnimation(self.__ptr, name, fileName)
  26. end
  27. function Skeleton:getAnimation(name)
  28. local retVal = Polycore.Skeleton_getAnimation(self.__ptr, name)
  29. if Polycore.__ptr_lookup[retVal] ~= nil then
  30. return Polycore.__ptr_lookup[retVal]
  31. else
  32. Polycore.__ptr_lookup[retVal] = SkeletonAnimation("__skip_ptr__")
  33. Polycore.__ptr_lookup[retVal].__ptr = retVal
  34. return Polycore.__ptr_lookup[retVal]
  35. end
  36. end
  37. function Skeleton:Update()
  38. local retVal = Polycore.Skeleton_Update(self.__ptr)
  39. end
  40. function Skeleton:getBoneByName(name)
  41. local retVal = Polycore.Skeleton_getBoneByName(self.__ptr, name)
  42. if Polycore.__ptr_lookup[retVal] ~= nil then
  43. return Polycore.__ptr_lookup[retVal]
  44. else
  45. Polycore.__ptr_lookup[retVal] = Bone("__skip_ptr__")
  46. Polycore.__ptr_lookup[retVal].__ptr = retVal
  47. return Polycore.__ptr_lookup[retVal]
  48. end
  49. end
  50. function Skeleton:bonesVisible(val)
  51. local retVal = Polycore.Skeleton_bonesVisible(self.__ptr, val)
  52. end
  53. function Skeleton:enableBoneLabels(labelFont, size, scale, labelColor)
  54. local retVal = Polycore.Skeleton_enableBoneLabels(self.__ptr, labelFont, size, scale, labelColor.__ptr)
  55. end
  56. function Skeleton:getNumBones()
  57. local retVal = Polycore.Skeleton_getNumBones(self.__ptr)
  58. return retVal
  59. end
  60. function Skeleton:getBone(index)
  61. local retVal = Polycore.Skeleton_getBone(self.__ptr, index)
  62. if Polycore.__ptr_lookup[retVal] ~= nil then
  63. return Polycore.__ptr_lookup[retVal]
  64. else
  65. Polycore.__ptr_lookup[retVal] = Bone("__skip_ptr__")
  66. Polycore.__ptr_lookup[retVal].__ptr = retVal
  67. return Polycore.__ptr_lookup[retVal]
  68. end
  69. end
  70. function Skeleton:getCurrentAnimation()
  71. local retVal = Polycore.Skeleton_getCurrentAnimation(self.__ptr)
  72. if Polycore.__ptr_lookup[retVal] ~= nil then
  73. return Polycore.__ptr_lookup[retVal]
  74. else
  75. Polycore.__ptr_lookup[retVal] = SkeletonAnimation("__skip_ptr__")
  76. Polycore.__ptr_lookup[retVal].__ptr = retVal
  77. return Polycore.__ptr_lookup[retVal]
  78. end
  79. end