~~NOTOC~~ ====== SXMotionTween ====== ---- dataentry extension ---- type : extension # or 'mod' if it requires changing the Sparrow source author_mail : bruno.basseto@uol.com.br Bruno basseto description : A Tween to move any SPDisplayObject along an arbitrary Bezier path lastupdate_dt : 2011-04-18 compatible : v1.1 # the Sparrow version you tested the extension with depends : # if the ext. depends on others, list them here tags : Animation homepage_url : https://github.com/BrunoBasseto/SXMotionTween download_url : https://github.com/BrunoBasseto/SXMotionTween ---- ===== Usage ===== This class is similar to **SPTween**, making it easy to move any object around a Bezier path. The __//adjustAngle//__ property makes **SXMotionTween** to change object's rotation to the path's tangent automatically. __**Public Classes**__ \\ * **SXMotionTween**, the animation object you add to a juggler * //tweenWithTarget: andPath:// constructor creates the tween and associates it with a path * //isComplete//, //delay// and //loop// properties are similar to **SPTween** properties * //adjustAngle// makes the target to rotate accordingly to the path * Use //angleOffset// to position the heading of the image at will * //offsetX// and //offsetY// are used to locate the initial point * **SXMotionTweenPath**, the object containing an animation path you add to one or many SXMotionTween objects (when you reuse a **SXMotionTweenPath** you must //retain// it to prevent the juggler from releasing!) * //startPoint:// moves object to a point without animation * //addLiteToPoint:// insert a linear animation segment to the specified point * //addArcToPoint:// insert a parabolic bezier line to the point, defined by the focal point * //addCurveToPoint:// insert a cubic bezier line to the point, defined by the two control points ===== Example ===== SXMotionTweenPath *path = [SXMotionTweenPath path]; [path startPoint: [SPPoint pointWithX: 10 y: 10]]; [path addLineToPoint: [SPPoint pointWithX: 250 y: 10] duration: 1.0]; [path addLineToPoint: [SPPoint pointWithX: 250 y: 250] duration: 1.0]; [path addLineToPoint: [SPPoint pointWithX: 10 y: 250] duration: 1.0]; [path addLineToPoint: [SPPoint pointWithX: 10 y: 10] duration: 1.0]; SXMotionTween *tween = [SXMotionTween tweenWithTarget: mySprite andPath: path]; tween.delay = 1; // wait one second tween.adjustAngle = YES; // make the image rotate along the path tween.angleOffset = 3.14/2; // adjust facing position [self.stage.juggler addObject: tween]; ===== Changelog ===== * //2011/04/18 18:55//: First public version ===== Discussion ===== //No comments so far. Feel free to edit this part of the page.//