johnatm / itween

Automatically exported from code.google.com/p/itween
1 stars 2 forks source link

Enhancement - more information accessible #84

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Had to add these to my iTween implementation so I could keep track of iTween 
from external functions.  There are two functions to read private variables, 
and one to be able to predict the path, i.e. if I wanted some other game object 
to follow or lead the object on the path without having to sync multiple iTween 
instances.
-Julien

//Julien added these functions/////////////////////////
    public float getCurrentPercentage()
    {
        return percentage;
    }

    public Vector3 getPointOnCurrentPath(float targetPercentage)
    {
        targetPercentage = ease(0, 1, Mathf.Min(1f, targetPercentage));
        return path.Interp(Mathf.Clamp(targetPercentage, 0, 1));
    }

    public EaseType getEaseType()
    {
        return easeType;
    }

    ////////////////////////////////////////////////////

Original issue reported on code.google.com by brandon....@gmail.com on 9 Aug 2011 at 7:11

GoogleCodeExporter commented 8 years ago
One more bit of code, if you'd like it.  Don't know if you do the 
iTweenEvent.cs visual editor as well, but I could not find a way to get the 
parameters from the iTween event, so I wrote this snippet to do it:

    /// <summary>
    /// Returns a parameter for this iTweenEvent as set in the visual editor.  Returns an object that needs to be converted to the appropriate type (float, string, etc.).
    /// For instance, to get the event time, use (float)movement.getEventParameter("time");
    /// </summary>
    /// <param name="nameOfParameter">The name of the parameter, e.g. 'time' or 'orienttopath'</param>
    /// <returns>The value of the parameter as an object</returns>
    public object getEventParameter(string nameOfParameter)
    {
        if (Values.ContainsKey(nameOfParameter))
            return Values[nameOfParameter];
        else
            throw new System.ArgumentException("No parameter with the name '" + nameOfParameter + "' could be found in the iTweenEvent named '" + tweenName + "'");
    }

BTW, I just wanted to let you know that I don't come from a programming 
background (I'm an engineer), and I learn more reading through your scripts 
than I did in a semester of programming in school.  Awesome stuff.

Original comment by brandon....@gmail.com on 10 Aug 2011 at 5:22