/// <summary> /// Tweens a numeric property. If this method has already been called, the values will be overwritten. /// </summary> /// <param name="obj">The object containing the property.</param> /// <param name="property">The name of the property.</param> /// <param name="to">Value to tween to.</param> /// <param name="duration">Duration of the tween.</param> /// <param name="ease">Optional easer function.</param> public void Tween(object obj, string property, float to, float duration, Easer ease = null) { _info = new VarTweenInfo(obj, property); _start = _info.Value; _range = to - _start; _target = duration; _ease = ease; Start(); }
/// <summary> /// Tweens multiple numeric properties /// </summary> /// <param name="obj">The object containing the properties. </param> /// <param name="values"> /// An anonymous type object containing key/value pairs of properties and target values. /// Example: new { X = 100, Y = 50 } /// </param> /// <param name="duration">Duration of the tween. </param> /// <param name="ease">Optional Easer function.</param> /// <param name="delay"></param> public void Tween(object obj, object values, float duration, Easer ease = null, float delay = 0) { _object = obj; foreach (PropertyInfo property in values.GetType().GetProperties()) { var info = new VarTweenInfo(_object, property.Name); var to = new VarTweenInfo(values, property.Name, VarTweenInfo.Options.Read); float start = info.Value; float range = to.Value - start; _vars.Add(info); _start.Add(start); _range.Add(range); } // FIXME: delay does nothing! _target = duration; _ease = ease; Start(); }