From 243a5aa075161154c79793069c080aa75fa5a4f1 Mon Sep 17 00:00:00 2001 From: Steven Barker Date: Sun, 29 Apr 2012 21:00:47 -0700 Subject: [PATCH] Change Motion tween to have a "object" property. The x and y values computed by the Tween will be automatically applied to the object's x and y properties too. The object can have any type, as long as it allows assignment to its x and y properties (so instances of Entity, Point, or Image will all work). The change is backwards compatible, and can be used as before regardless of whether the object is set. --- net/flashpunk/tweens/motion/Motion.as | 34 +++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/net/flashpunk/tweens/motion/Motion.as b/net/flashpunk/tweens/motion/Motion.as index 0675fa2..df7f0ff 100644 --- a/net/flashpunk/tweens/motion/Motion.as +++ b/net/flashpunk/tweens/motion/Motion.as @@ -10,12 +10,38 @@ /** * Current x position of the Tween. */ - public var x:Number = 0; + public function get x():Number { return _x; } + public function set x(value:Number):void + { + _x = value; + if (_object) + _object.x = _x; + } /** * Current y position of the Tween. */ - public var y:Number = 0; + public function get y():Number { return _y; } + public function set y(value:Number):void + { + _y = value; + if (_object) + _object.y = _y; + } + + /** + * Target object for the tween. Must have an x and a y property. + */ + public function get object():Object { return _object; } + public function set object(value:Object):void + { + _object = value; + if (_object) + { + _object.x = _x; + _object.y = _y; + } + } /** * Constructor. @@ -28,5 +54,9 @@ { super(duration, type, complete, ease); } + + protected var _x:Number = 0; + protected var _y:Number = 0; + protected var _object:Object; } } \ No newline at end of file