cocos2d::middleware::Texture2D 和 cc.Texture2D 不是一个类型吧
jsb-adapter 里面把一些函数参数的 cc.Texture2D 转成了 cocos2d::middleware::Texture2D,你可以看一下 jsb-adapter 的源码
我是上述代码写的,(我的图片有透明的地方,原spine局部也有透明的地方,图片的规格是同一样大的)换成之后图片变大了,怎么解决呢
你好,我的spine里面也是 MeshAttachment,请问这种情况怎么改呢
好久没用了,官方好像推出了spine的插槽换皮方式吧,可以去看看
经过实测,只能更换大小相同的图片,否则大小显示不对,比如原始图100100,替换为200200的图片,结果图片会自动缩放到100*100大小,基本上没法用。
MeshAttachment 也是差不多的用法,判断一下是什么Attachment;然后强转成对应的Attachment
if (attachment != NULL && attachment->getRTTI().instanceOf(RegionAttachment::rtti)) {
RegionAttachment *regionAttachment = static_cast<RegionAttachment *>(attachment);
AttachmentVertices *attachV = (AttachmentVertices *)regionAttachment->getRendererObject();
if (attachV->_texture == texture_temp) {
return;
}
CC_SAFE_RELEASE(attachV->_texture);
attachV->_texture = texture_temp;
CC_SAFE_RETAIN(texture_temp);
regionAttachment->updateOffset();
}
else if (attachment != NULL && attachment->getRTTI().instanceOf(MeshAttachment::rtti)) {
MeshAttachment *mesh = static_cast<MeshAttachment *>(attachment);
AttachmentVertices *attachV = (AttachmentVertices *)mesh->getRendererObject();
if (attachV->_texture == texture_temp) {
return;
}
CC_SAFE_RELEASE(attachV->_texture);
attachV->_texture = texture_temp;
CC_SAFE_RETAIN(texture_temp);
}
2.4版本不行,有好的解决版本么
mark骨骼动画挂皮
谢谢分享~顶一下
mark!
native的MeshAttachment可不可以替换page和atlasRegion?
mark~
Mark一下
支持插槽替换个外部的spine动画上去吗?
mark~~
native的MeshAttachment无法更换有排查建议吗,RegionAttachment的可以,也没报错之类,不知道怎么看
同求,这个问题不解决,很多地方也用不成
3.x 版本的局部换装的 native上更换 MeshAttachment 方案,(目前)需要定制引擎
在 3.4.0以上版本,合并以下PR
- 修改 engine cocos/spine/skeleton.ts 文件
platforms/native/engine/jsb-spine-skeleton.js 文件 - 修改 engine-native
cocos/editor-support/spine-creator-support/SkeletonRenderer.cpp
cocos/editor-support/spine-creator-support/SkeletonRenderer.h
cocos/editor-support/spine/Attachment.cpp
cocos/editor-support/spine/Attachment.h
cocos/editor-support/spine/MeshAttachment.cpp
cocos/editor-support/spine/RegionAttachment.cpp
tools/tojs/spine.ini
备注
- 修改engine后,记得在编辑器顶部菜单栏点击编译引擎
- 修改engine-native后,记得运行 engine-native\tools\tojs目录下的genbindings.py脚本,重新生成绑定
- 用户脚本上,直接调用 changeSlotSkin(slotName, tex2d)函数完成换肤
mark~