Closed shibekin69 closed 6 years ago
I must've forgotten to paste the solution (at least for me) here. This is for the createCombinedSkin() function:
Spine.prototype.createCombinedSkin = function (newSkinName) {
var skinNames = [];
for (var _i = 1; _i < arguments.length; _i++) {
skinNames[_i - 1] = arguments[_i];
}
if (skinNames.length === 0) {
console.warn('Unable to combine skins when no skins are passed...');
return;
}
var newSkin = new spine.Skin(newSkinName);
for (var i = 0; i < skinNames.length; i++) {
var skinName = skinNames[i];
var skin = this.skeleton.data.findSkin(skinName);
if (!skin) {
console.warn("Skin not found: " + skinName);
return;
}
for (var key in skin.attachments) {
var slotKeyPair = key.split(':');
var slotIndex = parseInt(slotKeyPair[0]);
//var attachmentName = slotKeyPair[1];
//CHANGE
var attachmentName = Object.keys(skin.attachments[key])[0];
//var attachment = skin.attachments[key];
//CHANGE
var attachment = skin.attachments[key][attachmentName];
console.log(key);
console.log(attachment);
if (undefined === slotIndex || undefined === attachmentName) {
console.warn('something went wrong with reading the attachments index and/or name');
return;
}
if (newSkin.getAttachment(slotIndex, attachmentName) !== undefined) {
//CHANGE: IMPORTANT! COMMENT THESE OUT! OR ELSE WON'T SEE COMBINED SKINS.
//console.warn('Found double attachment for: ' + skinName + '. Skipping');
//continue;
}
newSkin.addAttachment(slotIndex, attachmentName, attachment);
console.log(newSkin);
}
}
this.skeleton.data.skins.push(newSkin);
return newSkin;
};
I think you pasted it here: https://github.com/orange-games/phaser-spine/issues/70#issuecomment-323509123 :p
This seems to work :)
Seems like this function likes to give me this error in the console:
I'm not sure what the problem with this one is tho.
EDIT: I looked into this. It seems attachmentName is 'undefined'
You can test it with this: