// // RUTextureAttachmentLoader.hpp // red_utils // // Created by RedInfinity on 2024/1/16. // #ifndef RUTextureAttachmentLoader_hpp #define RUTextureAttachmentLoader_hpp ///第三方库 #include "editor-support/spine/AttachmentLoader.h" #include "editor-support/spine/RegionAttachment.h" #include "editor-support/spine/MeshAttachment.h" #include "editor-support/spine/BoundingBoxAttachment.h" #include "editor-support/spine/PathAttachment.h" #include "editor-support/spine/PointAttachment.h" #include "editor-support/spine/ClippingAttachment.h" #include "editor-support/spine/Skin.h" #include "editor-support/spine/Attachment.h" #include "editor-support/spine/SpineString.h" ///项目代码 #include "RUDefine.h" NS_RU_BEGIN /** * 描述:使用非图集纹理的spine附件加载器 */ class TextureAttachmentLoader final : public spine::AttachmentLoader { public: /** * 功能:获取非图集纹理的spine附件加载器 * 返回值:非图集纹理的spine附件加载器实例对象 */ static TextureAttachmentLoader* getInstance(); /** * 功能:销毁非图集纹理的spine附件加载器 */ static void destoryInstance(); /** * 功能:重新绑定spine附件使用的纹理 * 参数 attachment:需要重新绑定纹理的spine附件对象 * 参数 imageName:单图的文件名称 */ void rebindAttachmentTexture(spine::Attachment* attachment, const spine::String& imageName); virtual spine::RegionAttachment* newRegionAttachment(spine::Skin& skin, const spine::String& name, const spine::String& path) override; virtual spine::MeshAttachment* newMeshAttachment(spine::Skin& skin, const spine::String& name, const spine::String& path) override; virtual spine::BoundingBoxAttachment* newBoundingBoxAttachment(spine::Skin& skin, const spine::String& name) override; virtual spine::PathAttachment* newPathAttachment(spine::Skin& skin, const spine::String& name) override; virtual spine::PointAttachment* newPointAttachment(spine::Skin& skin, const spine::String& name) override; virtual spine::ClippingAttachment* newClippingAttachment(spine::Skin& skin, const spine::String& name) override; virtual void configureAttachment(spine::Attachment* attachment) override; private: TextureAttachmentLoader() = default; ~TextureAttachmentLoader() = default; /** * 功能:重新绑定spine区域附件使用的纹理 * 参数 attachment:需要重新绑定纹理的spine区域附件对象 * 参数 imageName:单图的文件名称 */ void _rebindRegionAttachmentTexture(spine::RegionAttachment* attachment, const spine::String& imageName); /** * 功能:重新绑定spine网格附件使用的纹理 * 参数 attachment:需要重新绑定纹理的spine网格附件对象 * 参数 imageName:单图的文件名称 */ void _rebindMeshAttachmentTexture(spine::MeshAttachment* attachment, const spine::String& imageName); /** * 功能:配置区域附件 * 参数 attachment:区域附件对象 */ void _configureRegionAttachment(spine::RegionAttachment* attachment); /** * 功能:配置网格附件 * 参数 attachment:网格附件对象 */ void _configureMeshAttachment(spine::MeshAttachment* attachment); private: ///非图集纹理的spine附件加载器实例 static TextureAttachmentLoader* _instance; }; NS_RU_END #endif /* RUTextureAttachmentLoader_hpp */