|
@@ -34,9 +34,9 @@
|
|
#include "cocos2d.h"
|
|
#include "cocos2d.h"
|
|
|
|
|
|
namespace spine {
|
|
namespace spine {
|
|
-
|
|
|
|
|
|
+
|
|
class AttachmentVertices;
|
|
class AttachmentVertices;
|
|
-
|
|
|
|
|
|
+
|
|
/* Draws a skeleton. */
|
|
/* Draws a skeleton. */
|
|
class SkeletonRenderer: public cocos2d::Node, public cocos2d::BlendProtocol {
|
|
class SkeletonRenderer: public cocos2d::Node, public cocos2d::BlendProtocol {
|
|
public:
|
|
public:
|
|
@@ -45,48 +45,50 @@ namespace spine {
|
|
static SkeletonRenderer* createWithData (SkeletonData* skeletonData, bool ownsSkeletonData = false);
|
|
static SkeletonRenderer* createWithData (SkeletonData* skeletonData, bool ownsSkeletonData = false);
|
|
static SkeletonRenderer* createWithFile (const std::string& skeletonDataFile, Atlas* atlas, float scale = 1);
|
|
static SkeletonRenderer* createWithFile (const std::string& skeletonDataFile, Atlas* atlas, float scale = 1);
|
|
static SkeletonRenderer* createWithFile (const std::string& skeletonDataFile, const std::string& atlasFile, float scale = 1);
|
|
static SkeletonRenderer* createWithFile (const std::string& skeletonDataFile, const std::string& atlasFile, float scale = 1);
|
|
-
|
|
|
|
- virtual void update (float deltaTime) override;
|
|
|
|
- virtual void draw (cocos2d::Renderer* renderer, const cocos2d::Mat4& transform, uint32_t transformFlags) override;
|
|
|
|
- virtual void drawDebug (cocos2d::Renderer* renderer, const cocos2d::Mat4& transform, uint32_t transformFlags);
|
|
|
|
- virtual cocos2d::Rect getBoundingBox () const override;
|
|
|
|
- virtual void onEnter () override;
|
|
|
|
- virtual void onExit () override;
|
|
|
|
-
|
|
|
|
- Skeleton* getSkeleton();
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ void update (float deltaTime) override;
|
|
|
|
+ void draw (cocos2d::Renderer* renderer, const cocos2d::Mat4& transform, uint32_t transformFlags) override;
|
|
|
|
+ cocos2d::Rect getBoundingBox () const override;
|
|
|
|
+ void onEnter () override;
|
|
|
|
+ void onExit () override;
|
|
|
|
+
|
|
|
|
+ Skeleton* getSkeleton() const;
|
|
|
|
+
|
|
void setTimeScale(float scale);
|
|
void setTimeScale(float scale);
|
|
float getTimeScale() const;
|
|
float getTimeScale() const;
|
|
-
|
|
|
|
|
|
+
|
|
/* */
|
|
/* */
|
|
void setDebugSlotsEnabled(bool enabled);
|
|
void setDebugSlotsEnabled(bool enabled);
|
|
bool getDebugSlotsEnabled() const;
|
|
bool getDebugSlotsEnabled() const;
|
|
-
|
|
|
|
|
|
+
|
|
void setDebugBonesEnabled(bool enabled);
|
|
void setDebugBonesEnabled(bool enabled);
|
|
bool getDebugBonesEnabled() const;
|
|
bool getDebugBonesEnabled() const;
|
|
-
|
|
|
|
|
|
+
|
|
void setDebugMeshesEnabled(bool enabled);
|
|
void setDebugMeshesEnabled(bool enabled);
|
|
bool getDebugMeshesEnabled() const;
|
|
bool getDebugMeshesEnabled() const;
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ void setDebugBoundingRectEnabled(bool enabled);
|
|
|
|
+ bool getDebugBoundingRectEnabled() const;
|
|
|
|
+
|
|
// --- Convenience methods for common Skeleton_* functions.
|
|
// --- Convenience methods for common Skeleton_* functions.
|
|
void updateWorldTransform ();
|
|
void updateWorldTransform ();
|
|
-
|
|
|
|
|
|
+
|
|
void setToSetupPose ();
|
|
void setToSetupPose ();
|
|
void setBonesToSetupPose ();
|
|
void setBonesToSetupPose ();
|
|
void setSlotsToSetupPose ();
|
|
void setSlotsToSetupPose ();
|
|
-
|
|
|
|
|
|
+
|
|
/* Returns 0 if the bone was not found. */
|
|
/* Returns 0 if the bone was not found. */
|
|
Bone* findBone (const std::string& boneName) const;
|
|
Bone* findBone (const std::string& boneName) const;
|
|
/* Returns 0 if the slot was not found. */
|
|
/* Returns 0 if the slot was not found. */
|
|
Slot* findSlot (const std::string& slotName) const;
|
|
Slot* findSlot (const std::string& slotName) const;
|
|
-
|
|
|
|
|
|
+
|
|
/* Sets the skin used to look up attachments not found in the SkeletonData defaultSkin. Attachments from the new skin are
|
|
/* Sets the skin used to look up attachments not found in the SkeletonData defaultSkin. Attachments from the new skin are
|
|
* attached if the corresponding attachment from the old skin was attached.
|
|
* attached if the corresponding attachment from the old skin was attached.
|
|
* @param skin May be empty string ("") for no skin.*/
|
|
* @param skin May be empty string ("") for no skin.*/
|
|
void setSkin (const std::string& skinName);
|
|
void setSkin (const std::string& skinName);
|
|
/** @param skin May be 0 for no skin.*/
|
|
/** @param skin May be 0 for no skin.*/
|
|
void setSkin (const char* skinName);
|
|
void setSkin (const char* skinName);
|
|
-
|
|
|
|
|
|
+
|
|
/* Returns 0 if the slot or attachment was not found. */
|
|
/* Returns 0 if the slot or attachment was not found. */
|
|
Attachment* getAttachment (const std::string& slotName, const std::string& attachmentName) const;
|
|
Attachment* getAttachment (const std::string& slotName, const std::string& attachmentName) const;
|
|
/* Returns false if the slot or attachment was not found.
|
|
/* Returns false if the slot or attachment was not found.
|
|
@@ -94,52 +96,50 @@ namespace spine {
|
|
bool setAttachment (const std::string& slotName, const std::string& attachmentName);
|
|
bool setAttachment (const std::string& slotName, const std::string& attachmentName);
|
|
/* @param attachmentName May be 0 for no attachment. */
|
|
/* @param attachmentName May be 0 for no attachment. */
|
|
bool setAttachment (const std::string& slotName, const char* attachmentName);
|
|
bool setAttachment (const std::string& slotName, const char* attachmentName);
|
|
-
|
|
|
|
|
|
+
|
|
/* Enables/disables two color tinting for this instance. May break batching */
|
|
/* Enables/disables two color tinting for this instance. May break batching */
|
|
void setTwoColorTint(bool enabled);
|
|
void setTwoColorTint(bool enabled);
|
|
/* Whether two color tinting is enabled */
|
|
/* Whether two color tinting is enabled */
|
|
bool isTwoColorTint();
|
|
bool isTwoColorTint();
|
|
-
|
|
|
|
|
|
+
|
|
/* Sets the vertex effect to be used, set to 0 to disable vertex effects */
|
|
/* Sets the vertex effect to be used, set to 0 to disable vertex effects */
|
|
void setVertexEffect(VertexEffect* effect);
|
|
void setVertexEffect(VertexEffect* effect);
|
|
-
|
|
|
|
|
|
+
|
|
/* Sets the range of slots that should be rendered. Use -1, -1 to clear the range */
|
|
/* Sets the range of slots that should be rendered. Use -1, -1 to clear the range */
|
|
void setSlotsRange(int startSlotIndex, int endSlotIndex);
|
|
void setSlotsRange(int startSlotIndex, int endSlotIndex);
|
|
-
|
|
|
|
|
|
+
|
|
// --- BlendProtocol
|
|
// --- BlendProtocol
|
|
- virtual void setBlendFunc (const cocos2d::BlendFunc& blendFunc)override;
|
|
|
|
- virtual const cocos2d::BlendFunc& getBlendFunc () const override;
|
|
|
|
- virtual void setOpacityModifyRGB (bool value) override;
|
|
|
|
- virtual bool isOpacityModifyRGB () const override;
|
|
|
|
-
|
|
|
|
- // Frees global memory used for temporay vertex transformations.
|
|
|
|
- static void destroyScratchBuffers();
|
|
|
|
-
|
|
|
|
|
|
+ void setBlendFunc (const cocos2d::BlendFunc& blendFunc)override;
|
|
|
|
+ const cocos2d::BlendFunc& getBlendFunc () const override;
|
|
|
|
+ void setOpacityModifyRGB (bool value) override;
|
|
|
|
+ bool isOpacityModifyRGB () const override;
|
|
|
|
+
|
|
CC_CONSTRUCTOR_ACCESS:
|
|
CC_CONSTRUCTOR_ACCESS:
|
|
SkeletonRenderer ();
|
|
SkeletonRenderer ();
|
|
SkeletonRenderer(Skeleton* skeleton, bool ownsSkeleton = false, bool ownsSkeletonData = false, bool ownsAtlas = false);
|
|
SkeletonRenderer(Skeleton* skeleton, bool ownsSkeleton = false, bool ownsSkeletonData = false, bool ownsAtlas = false);
|
|
SkeletonRenderer (SkeletonData* skeletonData, bool ownsSkeletonData = false);
|
|
SkeletonRenderer (SkeletonData* skeletonData, bool ownsSkeletonData = false);
|
|
SkeletonRenderer (const std::string& skeletonDataFile, Atlas* atlas, float scale = 1);
|
|
SkeletonRenderer (const std::string& skeletonDataFile, Atlas* atlas, float scale = 1);
|
|
SkeletonRenderer (const std::string& skeletonDataFile, const std::string& atlasFile, float scale = 1);
|
|
SkeletonRenderer (const std::string& skeletonDataFile, const std::string& atlasFile, float scale = 1);
|
|
-
|
|
|
|
|
|
+
|
|
virtual ~SkeletonRenderer ();
|
|
virtual ~SkeletonRenderer ();
|
|
-
|
|
|
|
|
|
+
|
|
void initWithSkeleton(Skeleton* skeleton, bool ownsSkeleton = false, bool ownsSkeletonData = false, bool ownsAtlas = false);
|
|
void initWithSkeleton(Skeleton* skeleton, bool ownsSkeleton = false, bool ownsSkeletonData = false, bool ownsAtlas = false);
|
|
void initWithData (SkeletonData* skeletonData, bool ownsSkeletonData = false);
|
|
void initWithData (SkeletonData* skeletonData, bool ownsSkeletonData = false);
|
|
void initWithJsonFile (const std::string& skeletonDataFile, Atlas* atlas, float scale = 1);
|
|
void initWithJsonFile (const std::string& skeletonDataFile, Atlas* atlas, float scale = 1);
|
|
void initWithJsonFile (const std::string& skeletonDataFile, const std::string& atlasFile, float scale = 1);
|
|
void initWithJsonFile (const std::string& skeletonDataFile, const std::string& atlasFile, float scale = 1);
|
|
void initWithBinaryFile (const std::string& skeletonDataFile, Atlas* atlas, float scale = 1);
|
|
void initWithBinaryFile (const std::string& skeletonDataFile, Atlas* atlas, float scale = 1);
|
|
void initWithBinaryFile (const std::string& skeletonDataFile, const std::string& atlasFile, float scale = 1);
|
|
void initWithBinaryFile (const std::string& skeletonDataFile, const std::string& atlasFile, float scale = 1);
|
|
-
|
|
|
|
|
|
+
|
|
virtual void initialize ();
|
|
virtual void initialize ();
|
|
-
|
|
|
|
|
|
+
|
|
protected:
|
|
protected:
|
|
void setSkeletonData (SkeletonData* skeletonData, bool ownsSkeletonData);
|
|
void setSkeletonData (SkeletonData* skeletonData, bool ownsSkeletonData);
|
|
void setupGLProgramState(bool twoColorTintEnabled);
|
|
void setupGLProgramState(bool twoColorTintEnabled);
|
|
-
|
|
|
|
|
|
+ virtual void drawDebug (cocos2d::Renderer* renderer, const cocos2d::Mat4& transform, uint32_t transformFlags);
|
|
|
|
+
|
|
bool _ownsSkeletonData;
|
|
bool _ownsSkeletonData;
|
|
bool _ownsSkeleton;
|
|
bool _ownsSkeleton;
|
|
- bool _ownsAtlas;
|
|
|
|
|
|
+ bool _ownsAtlas = false;
|
|
Atlas* _atlas;
|
|
Atlas* _atlas;
|
|
AttachmentLoader* _attachmentLoader;
|
|
AttachmentLoader* _attachmentLoader;
|
|
cocos2d::CustomCommand _debugCommand;
|
|
cocos2d::CustomCommand _debugCommand;
|
|
@@ -150,13 +150,15 @@ namespace spine {
|
|
bool _debugSlots;
|
|
bool _debugSlots;
|
|
bool _debugBones;
|
|
bool _debugBones;
|
|
bool _debugMeshes;
|
|
bool _debugMeshes;
|
|
|
|
+ bool _debugBoundingRect;
|
|
SkeletonClipping* _clipper;
|
|
SkeletonClipping* _clipper;
|
|
VertexEffect* _effect;
|
|
VertexEffect* _effect;
|
|
-
|
|
|
|
|
|
+ cocos2d::Rect _boundingRect;
|
|
|
|
+
|
|
int _startSlotIndex;
|
|
int _startSlotIndex;
|
|
int _endSlotIndex;
|
|
int _endSlotIndex;
|
|
};
|
|
};
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
#endif /* SPINE_SKELETONRENDERER_H_ */
|
|
#endif /* SPINE_SKELETONRENDERER_H_ */
|