void SkeletonAnimation::SetSlotTexture(unsigned index, const std::string& slot_name, const std::string& attach_name, const std::string& texture_path)
{
if (index >= _custom_pages.size())
{
_custom_pages.resize(index + 1, 0);
}
spAtlasPage* old_page = _custom_pages[index];
if (old_page)
{
//just return if new page equals old page
if (strcmp(old_page->name, texture_path.c_str()) == 0)
{
return;
}
//release old page
else
{
spAtlasPage_dispose(old_page);
}
}
spAtlasPage* new_page = spAtlasPage_create(_atlas, texture_path.c_str());
new_page->magFilter = new_page->minFilter = SP_ATLAS_LINEAR;
new_page->uWrap = new_page->vWrap = SP_ATLAS_CLAMPTOEDGE;
_spAtlasPage_createTexture(new_page, texture_path.c_str());
// cache new_page
_custom_pages[index] = new_page;
int tw = new_page->width;
int th = new_page->height;
/*
spAtlasRegion*
基于Spine3.3的换装(纸娃娃,avatar)功能
最新推荐文章于 2023-05-27 21:10:37 发布
本文详细介绍了如何在Cocos2d-x项目中利用Spine3.3框架实现换装(纸娃娃,avatar)功能。通过`SetSlotTexture`函数动态更换角色皮肤,包括处理纹理页、设置UV坐标、更新附件信息等关键步骤。
摘要由CSDN通过智能技术生成