spine换肤

cc.loader.loadRes('clickBtn',cc.Texture2D,(err,texture)=>{

  const component = this.spineNode.getComponent(sp.Skeleton);

  const slot = component.findSlot('right-hand-item2');

  const region = new sp.spine.TextureAtlasRegion();

  region.width = texture.width;

  region.height = texture.height;

  region.originalWidth = texture.width;

  region.originalHeight = texture.height;

  region.rotate = false;

  region.u = 0;

  region.v = 0;

  region.u2 = 1;

  region.v2 = 1;

  region.x = 0;

  region.y = 0;

  //非mesh插槽;

  const attachment = new sp.spine.RegionAttachment('11');

  attachment.path = '11';

  attachment.width = region.width;

  attachment.height = region.height;

  attachment.rotation = 90;

  region.texture = {

    _image:{width:texture.width,height:texture.height},

    _texture:texture

  };

  attachment.setRegion(region);

  slot.setAttachment(attachment);

  attachment.updateOffset();

});

上一篇:IOS之——快速获取苹果设备UDID(插曲)


下一篇:Java设计模式-合成模式