From 2d6594cb182b8edceae27d079f6593cf5b243631 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Thu, 1 Feb 2024 14:02:10 +0000 Subject: [PATCH] Added setSlotAlpha to Spine 3 plugin --- .../spine/src/gameobject/SpineGameObject.js | 45 ++++++++++++++----- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/plugins/spine/src/gameobject/SpineGameObject.js b/plugins/spine/src/gameobject/SpineGameObject.js index 8ddc119ca..dbb06d95b 100644 --- a/plugins/spine/src/gameobject/SpineGameObject.js +++ b/plugins/spine/src/gameobject/SpineGameObject.js @@ -284,6 +284,8 @@ var SpineGameObject = new Class({ * * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. * + * To set the alpha of a specific attachment, use the `setSlotAlpha` method instead. + * * @method SpineGameObject#setAlpha * @since 3.19.0 * @@ -291,22 +293,41 @@ var SpineGameObject = new Class({ * * @return {this} This Game Object instance. */ - setAlpha: function (value, slotName) + setAlpha: function (value) { if (value === undefined) { value = 1; } - if (slotName) - { - var slot = this.findSlot(slotName); + this.alpha = value; - if (slot) - { - slot.color.a = Clamp(value, 0, 1); - } - } - else + return this; + }, + + /** + * Set the Alpha level for the given attachment slot. + * + * The alpha controls the opacity of the slot as it renders. + * + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * + * To set the alpha for the whole skeleton, use the `setAlpha` method instead. + * + * @method SpineGameObject#setSlotAlpha + * @since 3.80.0 + * + * @param {string} slotName - The name of the slot to find. + * @param {number} [value=1] - The alpha value used for the slot. + * + * @return {this} This Game Object instance. + */ + setSlotAlpha: function (value, slotName) + { + if (value === undefined) { value = 1; } + + var slot = this.findSlot(slotName); + + if (slot) { - this.alpha = value; + slot.color.a = Clamp(value, 0, 1); } return this; @@ -995,6 +1016,8 @@ var SpineGameObject = new Class({ { this.setAnimation(0, animationName, loop, ignoreIfPlaying); + this.preUpdate(0, 16.66667); + return this; },