|  | @@ -19,13 +19,40 @@
 | 
												
													
														
															|  |   * along with Pandora.  If not, see <https://www.gnu.org/licenses/>.
 |  |   * along with Pandora.  If not, see <https://www.gnu.org/licenses/>.
 | 
												
													
														
															|  |   *************************************************************************/
 |  |   *************************************************************************/
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  | 
 |  | +/**'
 | 
												
													
														
															|  | 
 |  | + * The {@code TweenData} class represents the data that a Tween GameObject needs to
 | 
												
													
														
															|  | 
 |  | + * interpolate a given property.
 | 
												
													
														
															|  | 
 |  | + * 
 | 
												
													
														
															|  | 
 |  | + * @author Pedro Schneider
 | 
												
													
														
															|  | 
 |  | + * 
 | 
												
													
														
															|  | 
 |  | + * @class
 | 
												
													
														
															|  | 
 |  | + */
 | 
												
													
														
															|  |  class TweenData
 |  |  class TweenData
 | 
												
													
														
															|  |  {
 |  |  {
 | 
												
													
														
															|  | 
 |  | +    /**
 | 
												
													
														
															|  | 
 |  | +     * @constructor
 | 
												
													
														
															|  | 
 |  | +     * Creates a TweenData Object with the specified parameters.
 | 
												
													
														
															|  | 
 |  | +     * 
 | 
												
													
														
															|  | 
 |  | +     * @param {Object} target                   Object that has the property to be interpolated.
 | 
												
													
														
															|  | 
 |  | +     * @param {String} property                 name of the property of target to be interpolated.
 | 
												
													
														
															|  | 
 |  | +     *                                          target[property] should be number, Vector2 or Color. 
 | 
												
													
														
															|  | 
 |  | +     * @param {PROPERTY_TYPE} propertyType      type of the property to be interpolated. 
 | 
												
													
														
															|  | 
 |  | +     * @param {number, Vector2, Color} initVal  initial value for the interpolation.
 | 
												
													
														
															|  | 
 |  | +     *                                          Should be the same type as target[property].
 | 
												
													
														
															|  | 
 |  | +     * @param {number, Vector2, Color} finalVal final value for the interpolation.
 | 
												
													
														
															|  | 
 |  | +     *                                          Should be the same type as target[property].
 | 
												
													
														
															|  | 
 |  | +     * @param {number} duration                 duration in seconds of the interpolation. 
 | 
												
													
														
															|  | 
 |  | +     * @param {TRANS_TYPE} transType            transition type of the interpolation. 
 | 
												
													
														
															|  | 
 |  | +     * @param {EASE_TYPE} easeType              easing type of the interpolation.
 | 
												
													
														
															|  | 
 |  | +     * @param {number} delay                    delay in seconds for the interpolation to start. 
 | 
												
													
														
															|  | 
 |  | +     */
 | 
												
													
														
															|  |      constructor(target, property, propertyType, initVal, finalVal, duration, transType, easeType, delay)
 |  |      constructor(target, property, propertyType, initVal, finalVal, duration, transType, easeType, delay)
 | 
												
													
														
															|  |      {
 |  |      {
 | 
												
													
														
															|  | -        this.target = target;
 |  | 
 | 
												
													
														
															|  | -        this.property = property;
 |  | 
 | 
												
													
														
															|  | -        this.propertyType = propertyType;
 |  | 
 | 
												
													
														
															|  | 
 |  | +        this.target = target; // Object that has the property to be interpolated.
 | 
												
													
														
															|  | 
 |  | +        this.property = property; // Name of the property to be interpolated.
 | 
												
													
														
															|  | 
 |  | +        this.propertyType = propertyType; // Type of the property to be interpolated.
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +        // Initializes new objects for final value and initial value depending on the type.
 | 
												
													
														
															|  |          switch (this.propertyType)
 |  |          switch (this.propertyType)
 | 
												
													
														
															|  |          {
 |  |          {
 | 
												
													
														
															|  |              case PROPERTY_TYPE.COLOR:
 |  |              case PROPERTY_TYPE.COLOR:
 | 
												
											
												
													
														
															|  | @@ -41,15 +68,16 @@ class TweenData
 | 
												
													
														
															|  |                  this.finalVal = finalVal;
 |  |                  this.finalVal = finalVal;
 | 
												
													
														
															|  |                  break;
 |  |                  break;
 | 
												
													
														
															|  |          }
 |  |          }
 | 
												
													
														
															|  | -        this.duration = duration;
 |  | 
 | 
												
													
														
															|  | -        this.transType = transType;
 |  | 
 | 
												
													
														
															|  | -        this.easeType = easeType;
 |  | 
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  | -        this.t = -delay;
 |  | 
 | 
												
													
														
															|  | -        this.playing = false;
 |  | 
 | 
												
													
														
															|  | -        this.done = false;
 |  | 
 | 
												
													
														
															|  | 
 |  | +        this.duration = duration; // Duration in seconds of the interpolation
 | 
												
													
														
															|  | 
 |  | +        this.transType = transType; // Type of the transition.
 | 
												
													
														
															|  | 
 |  | +        this.easeType = easeType; // Type of the easing.
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  | -        this.p = [];
 |  | 
 | 
												
													
														
															|  | 
 |  | +        this.t = -delay; // Current time of the interpolation.
 | 
												
													
														
															|  | 
 |  | +        this.playing = false; // Is the interpolation playing?
 | 
												
													
														
															|  | 
 |  | +        this.done = false; // Is the interpolation done?
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +        this.p = []; // List of sub-properties to be interpolated depending on the type.
 | 
												
													
														
															|  |          switch (this.propertyType)
 |  |          switch (this.propertyType)
 | 
												
													
														
															|  |          {
 |  |          {
 | 
												
													
														
															|  |              case PROPERTY_TYPE.COLOR:
 |  |              case PROPERTY_TYPE.COLOR:
 | 
												
											
												
													
														
															|  | @@ -65,7 +93,7 @@ class TweenData
 | 
												
													
														
															|  |                  break;
 |  |                  break;
 | 
												
													
														
															|  |          }
 |  |          }
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  | -        this.trans = "";
 |  | 
 | 
												
													
														
															|  | 
 |  | +        this.trans = ""; // String for the transition type.
 | 
												
													
														
															|  |          switch (this.transType)
 |  |          switch (this.transType)
 | 
												
													
														
															|  |          {
 |  |          {
 | 
												
													
														
															|  |              case TRANS_TYPE.LINEAR:
 |  |              case TRANS_TYPE.LINEAR:
 | 
												
											
												
													
														
															|  | @@ -103,7 +131,7 @@ class TweenData
 | 
												
													
														
															|  |                  break;
 |  |                  break;
 | 
												
													
														
															|  |          }
 |  |          }
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  | -        this.ease = "";
 |  | 
 | 
												
													
														
															|  | 
 |  | +        this.ease = ""; // String for the easing type.
 | 
												
													
														
															|  |          if (this.transType == TRANS_TYPE.LINEAR) this.ease = "ease";
 |  |          if (this.transType == TRANS_TYPE.LINEAR) this.ease = "ease";
 | 
												
													
														
															|  |          else
 |  |          else
 | 
												
													
														
															|  |          {
 |  |          {
 | 
												
											
												
													
														
															|  | @@ -123,8 +151,23 @@ class TweenData
 | 
												
													
														
															|  |      }
 |  |      }
 | 
												
													
														
															|  |  }
 |  |  }
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  | 
 |  | +/**
 | 
												
													
														
															|  | 
 |  | + * The {@code Tween} class represents a Tween GameObject that has functionality to
 | 
												
													
														
															|  | 
 |  | + * interpolate any property of another GameObject if the properties are of the type
 | 
												
													
														
															|  | 
 |  | + * number, Vector2 or Color.
 | 
												
													
														
															|  | 
 |  | + * 
 | 
												
													
														
															|  | 
 |  | + * @author Pedro Schneider
 | 
												
													
														
															|  | 
 |  | + * 
 | 
												
													
														
															|  | 
 |  | + * @class
 | 
												
													
														
															|  | 
 |  | + */
 | 
												
													
														
															|  |  class Tween extends GameObject
 |  |  class Tween extends GameObject
 | 
												
													
														
															|  |  {
 |  |  {
 | 
												
													
														
															|  | 
 |  | +    /**
 | 
												
													
														
															|  | 
 |  | +     * @constructor
 | 
												
													
														
															|  | 
 |  | +     * Creates an empty Tween GameObject.
 | 
												
													
														
															|  | 
 |  | +     * 
 | 
												
													
														
															|  | 
 |  | +     * @param {String} name name of the Tween GameObject. 
 | 
												
													
														
															|  | 
 |  | +     */
 | 
												
													
														
															|  |      constructor(name)
 |  |      constructor(name)
 | 
												
													
														
															|  |      {
 |  |      {
 | 
												
													
														
															|  |          super(name);
 |  |          super(name);
 | 
												
											
												
													
														
															|  | @@ -134,12 +177,40 @@ class Tween extends GameObject
 | 
												
													
														
															|  |          this.done = false;
 |  |          this.done = false;
 | 
												
													
														
															|  |      }
 |  |      }
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  | 
 |  | +    /**
 | 
												
													
														
															|  | 
 |  | +     * Add a new TweenData Object to this Tween with the necessary information to interpolate
 | 
												
													
														
															|  | 
 |  | +     * the target's property.
 | 
												
													
														
															|  | 
 |  | +     * 
 | 
												
													
														
															|  | 
 |  | +     * @param {Object} target                   Object that has the property to be interpolated.
 | 
												
													
														
															|  | 
 |  | +     * @param {String} property                 name of the property of target to be interpolated.
 | 
												
													
														
															|  | 
 |  | +     *                                          target[property] should be number, Vector2 or Color. 
 | 
												
													
														
															|  | 
 |  | +     * @param {PROPERTY_TYPE} propertyType      type of the property to be interpolated. 
 | 
												
													
														
															|  | 
 |  | +     * @param {number, Vector2, Color} initVal  initial value for the interpolation.
 | 
												
													
														
															|  | 
 |  | +     *                                          Should be the same type as target[property].
 | 
												
													
														
															|  | 
 |  | +     * @param {number, Vector2, Color} finalVal final value for the interpolation.
 | 
												
													
														
															|  | 
 |  | +     *                                          Should be the same type as target[property].
 | 
												
													
														
															|  | 
 |  | +     * @param {number} duration                 duration in seconds of the interpolation. 
 | 
												
													
														
															|  | 
 |  | +     * @param {TRANS_TYPE} transType            transition type of the interpolation.
 | 
												
													
														
															|  | 
 |  | +     *                                          Default is TRANS_TYPE.LINEAR.
 | 
												
													
														
															|  | 
 |  | +     * @param {EASE_TYPE} easeType              easing type of the interpolation.
 | 
												
													
														
															|  | 
 |  | +     *                                          Default is EASY_TYPE.IN_OUT.
 | 
												
													
														
															|  | 
 |  | +     * @param {number} delay                    delay in seconds for the interpolation to start.
 | 
												
													
														
															|  | 
 |  | +     *                                          Default is 0. 
 | 
												
													
														
															|  | 
 |  | +     */
 | 
												
													
														
															|  |      interpolateProperty(target, property, propertyType, initVal, finalVal, duration, transType = 1, easeType = 3, delay = 0)
 |  |      interpolateProperty(target, property, propertyType, initVal, finalVal, duration, transType = 1, easeType = 3, delay = 0)
 | 
												
													
														
															|  |      {
 |  |      {
 | 
												
													
														
															|  | -        this.done = false;
 |  | 
 | 
												
													
														
															|  | 
 |  | +        this.done = false; // Are all TweenData on this Tween done?
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +        // Adding a new TweenData.
 | 
												
													
														
															|  |          this.tweenData.push(new TweenData(target, property, propertyType, initVal, finalVal, duration, transType, easeType, delay));
 |  |          this.tweenData.push(new TweenData(target, property, propertyType, initVal, finalVal, duration, transType, easeType, delay));
 | 
												
													
														
															|  |      }
 |  |      }
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  | 
 |  | +    /**
 | 
												
													
														
															|  | 
 |  | +     * Given a TweenData, sets its interpolation's target's property to the appropriate value for
 | 
												
													
														
															|  | 
 |  | +     * the current time of the interpolation.
 | 
												
													
														
															|  | 
 |  | +     * 
 | 
												
													
														
															|  | 
 |  | +     * @param {TweenData} td    reference to the TweenData Object. 
 | 
												
													
														
															|  | 
 |  | +     */
 | 
												
													
														
															|  |      interpolate(td)
 |  |      interpolate(td)
 | 
												
													
														
															|  |      {
 |  |      {
 | 
												
													
														
															|  |          if (td.propertyType == PROPERTY_TYPE.NUMBER)
 |  |          if (td.propertyType == PROPERTY_TYPE.NUMBER)
 | 
												
											
												
													
														
															|  | @@ -151,42 +222,81 @@ class Tween extends GameObject
 | 
												
													
														
															|  |          }
 |  |          }
 | 
												
													
														
															|  |      }
 |  |      }
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  | -    start()
 |  | 
 | 
												
													
														
															|  | 
 |  | +    /**
 | 
												
													
														
															|  | 
 |  | +     * Starts interpolating all TweenData Objectcs currently added to this Tween.
 | 
												
													
														
															|  | 
 |  | +     */
 | 
												
													
														
															|  | 
 |  | +    startAll()
 | 
												
													
														
															|  |      {
 |  |      {
 | 
												
													
														
															|  |          for (let i = 0; i < this.tweenData.length; i++)
 |  |          for (let i = 0; i < this.tweenData.length; i++)
 | 
												
													
														
															|  |              this.tweenData[i].playing = true;
 |  |              this.tweenData[i].playing = true;
 | 
												
													
														
															|  |      }
 |  |      }
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  | 
 |  | +    /**
 | 
												
													
														
															|  | 
 |  | +     * Starts interpolating a specific TweenData Object based on its index.
 | 
												
													
														
															|  | 
 |  | +     * 
 | 
												
													
														
															|  | 
 |  | +     * ! Since TwennData are not GameObjects, this is the only way to query
 | 
												
													
														
															|  | 
 |  | +     * ! for them. The index refera to the order you added the TweenData to
 | 
												
													
														
															|  | 
 |  | +     * ! this Tween, starting at 0.
 | 
												
													
														
															|  | 
 |  | +     * 
 | 
												
													
														
															|  | 
 |  | +     * @param {number} idx  index of the desired TweenData to start.
 | 
												
													
														
															|  | 
 |  | +     */
 | 
												
													
														
															|  |      startByIndex(idx)
 |  |      startByIndex(idx)
 | 
												
													
														
															|  |      {
 |  |      {
 | 
												
													
														
															|  |          if (idx < 0 && idx >= this.tweenData.length) return;
 |  |          if (idx < 0 && idx >= this.tweenData.length) return;
 | 
												
													
														
															|  |          this.tweenData[idx].playing = true;
 |  |          this.tweenData[idx].playing = true;
 | 
												
													
														
															|  |      }
 |  |      }
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  | 
 |  | +    /**
 | 
												
													
														
															|  | 
 |  | +     * Stops interpolating all TweenData Objects currently added to this Tween.
 | 
												
													
														
															|  | 
 |  | +     */
 | 
												
													
														
															|  |      stopAll()
 |  |      stopAll()
 | 
												
													
														
															|  |      {
 |  |      {
 | 
												
													
														
															|  |          for (let i = 0; i < this.tweenData.length; i++)
 |  |          for (let i = 0; i < this.tweenData.length; i++)
 | 
												
													
														
															|  |              this.tweenData[i].playing = false;
 |  |              this.tweenData[i].playing = false;
 | 
												
													
														
															|  |      }
 |  |      }
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  | 
 |  | +    /**
 | 
												
													
														
															|  | 
 |  | +     * Stops interpolating a specific TweenData Object based on its index.
 | 
												
													
														
															|  | 
 |  | +     * 
 | 
												
													
														
															|  | 
 |  | +     * ! Since TwennData are not GameObjects, this is the only way to query
 | 
												
													
														
															|  | 
 |  | +     * ! for them. The index refera to the order you added the TweenData to
 | 
												
													
														
															|  | 
 |  | +     * ! this Tween, starting at 0.
 | 
												
													
														
															|  | 
 |  | +     * 
 | 
												
													
														
															|  | 
 |  | +     * @param {number} idx  index of the desired TweenData to stop.
 | 
												
													
														
															|  | 
 |  | +     */
 | 
												
													
														
															|  |      stopByIndex(idx)
 |  |      stopByIndex(idx)
 | 
												
													
														
															|  |      {
 |  |      {
 | 
												
													
														
															|  |          if (idx < 0 && idx >= this.tweenData.length) return;
 |  |          if (idx < 0 && idx >= this.tweenData.length) return;
 | 
												
													
														
															|  |          this.tweenData[idx].playing = false;
 |  |          this.tweenData[idx].playing = false;
 | 
												
													
														
															|  |      }
 |  |      }
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  | 
 |  | +    /**
 | 
												
													
														
															|  | 
 |  | +     * Resumes interpolating all TweenData currently added to this Tween.
 | 
												
													
														
															|  | 
 |  | +     */
 | 
												
													
														
															|  |      resumeAll()
 |  |      resumeAll()
 | 
												
													
														
															|  |      {
 |  |      {
 | 
												
													
														
															|  |          for (let i = 0; i < this.tweenData.length; i++)
 |  |          for (let i = 0; i < this.tweenData.length; i++)
 | 
												
													
														
															|  |              this.tweenData[i].playing = true;
 |  |              this.tweenData[i].playing = true;
 | 
												
													
														
															|  |      }
 |  |      }
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  | 
 |  | +    /**
 | 
												
													
														
															|  | 
 |  | +     * Resumes interpolating a specific TweenData Object based on its index.
 | 
												
													
														
															|  | 
 |  | +     * 
 | 
												
													
														
															|  | 
 |  | +     * ! Since TwennData are not GameObjects, this is the only way to query
 | 
												
													
														
															|  | 
 |  | +     * ! for them. The index refera to the order you added the TweenData to
 | 
												
													
														
															|  | 
 |  | +     * ! this Tween, starting at 0.
 | 
												
													
														
															|  | 
 |  | +     * 
 | 
												
													
														
															|  | 
 |  | +     * @param {number} idx  index of the desired TweenData to resume.
 | 
												
													
														
															|  | 
 |  | +     */
 | 
												
													
														
															|  |      resumeByIndex(idx)
 |  |      resumeByIndex(idx)
 | 
												
													
														
															|  |      {
 |  |      {
 | 
												
													
														
															|  |          if (idx < 0 && idx >= this.tweenData.length) return;
 |  |          if (idx < 0 && idx >= this.tweenData.length) return;
 | 
												
													
														
															|  |          this.tweenData[idx].playing = true;
 |  |          this.tweenData[idx].playing = true;
 | 
												
													
														
															|  |      }
 |  |      }
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  | 
 |  | +    /**
 | 
												
													
														
															|  | 
 |  | +     * Resets all TweenData currently added to this Tween.
 | 
												
													
														
															|  | 
 |  | +     */
 | 
												
													
														
															|  |      resetAll()
 |  |      resetAll()
 | 
												
													
														
															|  |      {
 |  |      {
 | 
												
													
														
															|  |          this.doneTweens = 0;
 |  |          this.doneTweens = 0;
 | 
												
											
												
													
														
															|  | @@ -198,6 +308,15 @@ class Tween extends GameObject
 | 
												
													
														
															|  |          }
 |  |          }
 | 
												
													
														
															|  |      }
 |  |      }
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  | 
 |  | +    /**
 | 
												
													
														
															|  | 
 |  | +     * Resets a specific TweenData Object based on its index.
 | 
												
													
														
															|  | 
 |  | +     * 
 | 
												
													
														
															|  | 
 |  | +     * ! Since TwennData are not GameObjects, this is the only way to query
 | 
												
													
														
															|  | 
 |  | +     * ! for them. The index refera to the order you added the TweenData to
 | 
												
													
														
															|  | 
 |  | +     * ! this Tween, starting at 0.
 | 
												
													
														
															|  | 
 |  | +     * 
 | 
												
													
														
															|  | 
 |  | +     * @param {number} idx  index of the desired TweenData to reset.
 | 
												
													
														
															|  | 
 |  | +     */
 | 
												
													
														
															|  |      resetByIndex(idx)
 |  |      resetByIndex(idx)
 | 
												
													
														
															|  |      {
 |  |      {
 | 
												
													
														
															|  |          if (idx < 0 && idx >= this.tweenData.length) return;
 |  |          if (idx < 0 && idx >= this.tweenData.length) return;
 | 
												
											
												
													
														
															|  | @@ -207,18 +326,36 @@ class Tween extends GameObject
 | 
												
													
														
															|  |          this.tweenData[idx].done = false;
 |  |          this.tweenData[idx].done = false;
 | 
												
													
														
															|  |      }
 |  |      }
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  | 
 |  | +    /**
 | 
												
													
														
															|  | 
 |  | +     * Removes all TweenData currently added to this Tween.
 | 
												
													
														
															|  | 
 |  | +     */
 | 
												
													
														
															|  |      removeAll()
 |  |      removeAll()
 | 
												
													
														
															|  |      {
 |  |      {
 | 
												
													
														
															|  |          while (this.tweenData.length > 0)
 |  |          while (this.tweenData.length > 0)
 | 
												
													
														
															|  |              this.tweenData.pop();
 |  |              this.tweenData.pop();
 | 
												
													
														
															|  |      }
 |  |      }
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  | 
 |  | +    /**
 | 
												
													
														
															|  | 
 |  | +     * Removes a specific TweenData Object based on its index.
 | 
												
													
														
															|  | 
 |  | +     * 
 | 
												
													
														
															|  | 
 |  | +     * ! Since TwennData are not GameObjects, this is the only way to query
 | 
												
													
														
															|  | 
 |  | +     * ! for them. The index refera to the order you added the TweenData to
 | 
												
													
														
															|  | 
 |  | +     * ! this Tween, starting at 0.
 | 
												
													
														
															|  | 
 |  | +     * 
 | 
												
													
														
															|  | 
 |  | +     * @param {number} idx  index of the desired TweenData to remove.
 | 
												
													
														
															|  | 
 |  | +     */
 | 
												
													
														
															|  |      removeByIndex(idx)
 |  |      removeByIndex(idx)
 | 
												
													
														
															|  |      {
 |  |      {
 | 
												
													
														
															|  |          if (idx < 0 && idx >= this.tweenData.length) return;
 |  |          if (idx < 0 && idx >= this.tweenData.length) return;
 | 
												
													
														
															|  |          this.tweenData.splice(idx, 1);
 |  |          this.tweenData.splice(idx, 1);
 | 
												
													
														
															|  |      }
 |  |      }
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  | 
 |  | +    /**
 | 
												
													
														
															|  | 
 |  | +     * Sets the current time of all TweenData currently added to this Tween
 | 
												
													
														
															|  | 
 |  | +     * to the specified time.
 | 
												
													
														
															|  | 
 |  | +     * 
 | 
												
													
														
															|  | 
 |  | +     * @param {number} time time in seconds to seek all TweenData on this Tween. 
 | 
												
													
														
															|  | 
 |  | +     */
 | 
												
													
														
															|  |      seekAll(time)
 |  |      seekAll(time)
 | 
												
													
														
															|  |      {
 |  |      {
 | 
												
													
														
															|  |          if (time < 0) return;
 |  |          if (time < 0) return;
 | 
												
											
												
													
														
															|  | @@ -226,18 +363,47 @@ class Tween extends GameObject
 | 
												
													
														
															|  |              this.tweenData[i].t = min(time, this.tweenData[i].duration);
 |  |              this.tweenData[i].t = min(time, this.tweenData[i].duration);
 | 
												
													
														
															|  |      }
 |  |      }
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  | 
 |  | +    /**
 | 
												
													
														
															|  | 
 |  | +     * Sets the current time of a specific TweenData Object, based on its index,
 | 
												
													
														
															|  | 
 |  | +     * to the specified time. 
 | 
												
													
														
															|  | 
 |  | +     * 
 | 
												
													
														
															|  | 
 |  | +     * ! Since TwennData are not GameObjects, this is the only way to query
 | 
												
													
														
															|  | 
 |  | +     * ! for them. The index refera to the order you added the TweenData to
 | 
												
													
														
															|  | 
 |  | +     * ! this Tween, starting at 0.
 | 
												
													
														
															|  | 
 |  | +     * 
 | 
												
													
														
															|  | 
 |  | +     * @param {number} idx  index of the TweenData to seek to the time.
 | 
												
													
														
															|  | 
 |  | +     * @param {number} time time in seconds to seek the specified TweenData
 | 
												
													
														
															|  | 
 |  | +     */
 | 
												
													
														
															|  |      seekByIndex(idx, time)
 |  |      seekByIndex(idx, time)
 | 
												
													
														
															|  |      {
 |  |      {
 | 
												
													
														
															|  |          if (idx < 0 && idx >= this.tweenData.length) return;
 |  |          if (idx < 0 && idx >= this.tweenData.length) return;
 | 
												
													
														
															|  |          this.tweenData[idx].t = min(time, this.tweenData[idx].duration);
 |  |          this.tweenData[idx].t = min(time, this.tweenData[idx].duration);
 | 
												
													
														
															|  |      }
 |  |      }
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  | 
 |  | +    /**
 | 
												
													
														
															|  | 
 |  | +     * Called once every time all TweenData on this Tween are completed.
 | 
												
													
														
															|  | 
 |  | +     * Emits the tweenDataAllCompleted signal.
 | 
												
													
														
															|  | 
 |  | +     */
 | 
												
													
														
															|  |      allDone()
 |  |      allDone()
 | 
												
													
														
															|  |      {
 |  |      {
 | 
												
													
														
															|  |          this.emitSignal("tweenAllCompleted");
 |  |          this.emitSignal("tweenAllCompleted");
 | 
												
													
														
															|  |          this.done = true;
 |  |          this.done = true;
 | 
												
													
														
															|  |      }
 |  |      }
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  | 
 |  | +    /**
 | 
												
													
														
															|  | 
 |  | +     * @override
 | 
												
													
														
															|  | 
 |  | +     * Adds default signals for the Tween GameObject and serves as a caller
 | 
												
													
														
															|  | 
 |  | +     * to the _initSignals() callback.
 | 
												
													
														
															|  | 
 |  | +     * 
 | 
												
													
														
															|  | 
 |  | +     * @signal tweenAllCompleted    Emited once when all TweenData on this Tween
 | 
												
													
														
															|  | 
 |  | +     *                              are done.
 | 
												
													
														
															|  | 
 |  | +     * @signal tweenCompleted       Emited once when one TweenData on this Tween
 | 
												
													
														
															|  | 
 |  | +     *                              is done. Passes the completed TweenData as a
 | 
												
													
														
															|  | 
 |  | +     *                              parameter.
 | 
												
													
														
															|  | 
 |  | +     * @signal tweenStarted         Emited once when one TweenData on this Tween
 | 
												
													
														
															|  | 
 |  | +     *                              starts. Passes the started TweenData as a 
 | 
												
													
														
															|  | 
 |  | +     *                              parameter.
 | 
												
													
														
															|  | 
 |  | +     */
 | 
												
													
														
															|  |      initSignals()
 |  |      initSignals()
 | 
												
													
														
															|  |      {
 |  |      {
 | 
												
													
														
															|  |          this.addSignal("tweenAllCompleted");
 |  |          this.addSignal("tweenAllCompleted");
 | 
												
											
												
													
														
															|  | @@ -246,23 +412,34 @@ class Tween extends GameObject
 | 
												
													
														
															|  |          this._initSignals();
 |  |          this._initSignals();
 | 
												
													
														
															|  |      }
 |  |      }
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  | 
 |  | +    /**
 | 
												
													
														
															|  | 
 |  | +     * @override
 | 
												
													
														
															|  | 
 |  | +     * Updates all TweenData added to this Tween and recursively calls the _update(delta)
 | 
												
													
														
															|  | 
 |  | +     * callback for this GameObject and all of it's children.
 | 
												
													
														
															|  | 
 |  | +     * @param {*} delta 
 | 
												
													
														
															|  | 
 |  | +     */
 | 
												
													
														
															|  |      update(delta)
 |  |      update(delta)
 | 
												
													
														
															|  |      {
 |  |      {
 | 
												
													
														
															|  | 
 |  | +        // Checks if all TweenData are done.
 | 
												
													
														
															|  |          if (!this.done && this.doneTweens == this.tweenData.length) this.allDone();
 |  |          if (!this.done && this.doneTweens == this.tweenData.length) this.allDone();
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  |          for (let i = 0; i < this.tweenData.length; i++)
 |  |          for (let i = 0; i < this.tweenData.length; i++)
 | 
												
													
														
															|  |          {
 |  |          {
 | 
												
													
														
															|  | 
 |  | +            // Ignores TweenData that aren't playing.
 | 
												
													
														
															|  |              if (!this.tweenData[i].playing) continue;
 |  |              if (!this.tweenData[i].playing) continue;
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | 
 |  | +            
 | 
												
													
														
															|  | 
 |  | +            // Interpolates TweenData that are out of the delay.
 | 
												
													
														
															|  |              if (this.tweenData[i].t >= 0)
 |  |              if (this.tweenData[i].t >= 0)
 | 
												
													
														
															|  | -            {
 |  | 
 | 
												
													
														
															|  |                  this.interpolate(this.tweenData[i]);
 |  |                  this.interpolate(this.tweenData[i]);
 | 
												
													
														
															|  | -            }
 |  | 
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  | -            if (this.tweenData[i].t < 0 && this.tweenData[i].t + delta >= 0)
 |  | 
 | 
												
													
														
															|  | 
 |  | +            // Checks if the TweenData just went out of the delay (just started).
 | 
												
													
														
															|  | 
 |  | +            if (this.tweenData[i].t <= 0 && this.tweenData[i].t + delta >= 0)
 | 
												
													
														
															|  |                  this.emitSignal("tweenStarted", this.tweenData[i]);
 |  |                  this.emitSignal("tweenStarted", this.tweenData[i]);
 | 
												
													
														
															|  | 
 |  | +            
 | 
												
													
														
															|  | 
 |  | +            // Updates TweenData's current time.
 | 
												
													
														
															|  |              this.tweenData[i].t = min(this.tweenData[i].t + delta, this.tweenData[i].duration);
 |  |              this.tweenData[i].t = min(this.tweenData[i].t + delta, this.tweenData[i].duration);
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  | 
 |  | +            // Checks if the TweenData is done.
 | 
												
													
														
															|  |              if (!this.tweenData[i].done && this.tweenData[i].t == this.tweenData[i].duration)
 |  |              if (!this.tweenData[i].done && this.tweenData[i].t == this.tweenData[i].duration)
 | 
												
													
														
															|  |              {
 |  |              {
 | 
												
													
														
															|  |                  this.emitSignal("tweenDone", this.tweenData[i]);
 |  |                  this.emitSignal("tweenDone", this.tweenData[i]);
 |