美文网首页
cocos creator局部换装

cocos creator局部换装

作者: 凡凡的小web | 来源:发表于2023-02-21 15:19 被阅读0次
        let slot: sp.spine.Slot = this.ske.findSlot("ORENGE");
        let attachment: sp.spine.RegionAttachment = slot.getAttachment() as sp.spine.RegionAttachment;
        if (!slot || !attachment) {
            cc.error('error...');
            return;
        }

        
        // let region: sp.spine.TextureAtlasRegion = attachment.region as sp.spine.TextureAtlasRegion;
        
        let texture = await this.loadRes(diningTable.img)

        var tex = new sp.SkeletonTexture()

        tex.setRealTexture(texture)

        let region: sp.spine.TextureAtlasRegion = attachment.region as sp.spine.TextureAtlasRegion;

        region.u = 0;
        region.v = 0;
        region.u2 = 1;
        region.v2 = 1;
        region.width = texture.width;
        region.height = texture.height;
        region.originalWidth = texture.width;
        region.originalHeight = texture.height;
        region.rotate = false;
        region.texture = tex;
        region.page = null;
        attachment.width = region.width;
        attachment.height = region.height;
        attachment.setRegion(region);

        
        attachment.region.texture = tex

        slot.setAttachment(attachment);
        // skeleton如果使用了缓存模式则需要刷新缓存
        this.ske.invalidAnimationCache();

// 这个没有考虑旋转和大小的问题 但有助于理解
https://forum.cocos.org/t/cocos-creator-spine/67676

//这个实现完全
https://blog.csdn.net/u012338130/article/details/111409597
//论坛的
https://forum.cocos.org/t/topic/138623

相关文章

网友评论

      本文标题:cocos creator局部换装

      本文链接:https://www.haomeiwen.com/subject/csznkdtx.html