SXMotionTween

type:
extension
author:
Bruno basseto
description:
A Tween to move any SPDisplayObject along an arbitrary Bezier path
lastupdate:
2011-04-18
compatible:
v1.1
tag:
Animation
homepage:
https://github.com/BrunoBasseto/SXMotionTween
download:
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.

  extensions/sxmotiontween.txt · Last modified: 2015/09/14 11:14 (external edit)
 
Powered by DokuWiki