Search the Community
Showing results for tags 'LinePath2D'.
-
I'm having a problem when adding more points to the LinePath2D points array. A jump in the movement animation happens when new points are added. I'm using the example code from the docs and added a button, so when the button is pressed the new points are added. Here is my code: import com.greensock.*; import com.greensock.easing.*; import com.greensock.motionPaths.*; import flash.geom.Point; import flash.events.MouseEvent; var path:LinePath2D = new LinePath2D([new Point(0, 0), new Point(100, 100), new Point(350, 150), new Point(50, 200), new Point(550, 400)]); path.autoUpdatePoints=true; addChild(path); path.addFollower(createSquare(10, 0xFF0000), path.getSegmentProgress(2, 0.5)); TweenMax.to(path, 20, {progress:1}); function createSquare(size:Number, color:uint=0xFF0000):Shape { var s:Shape = new Shape(); s.graphics.beginFill(color, 1); s.graphics.drawRect(-size / 2, -size / 2, size, size); s.graphics.endFill(); this.addChild(s); return s; } function addMorePoints(e:MouseEvent){ btn.visible=false; var pathNew:Array = [new Point(700, 400), new Point(700, 600)]; path.appendMultiplePoints(pathNew); } btn.addEventListener(MouseEvent.MOUSE_DOWN, addMorePoints); Thanks for the help
-
Would you consider updating the class by including more data from the fl.motion:KeyFrameBase (http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fl/motion/KeyframeBase.html ), specifically : rotationConcat color alpha I was considering using Tweenlite for my Starling game. Llevels are imported from swf and then parsed during runtime. Those levels contain movieclips with motion tweens (+ rotation along the path). With tweenlite it's possible to rotate only one way or another, not have a rotation value per each frame, not to mention other things like color values.
-
Hi there, i'm about to switch to Starling Framework for my new projects. For a game i animated an object with autorotate=true like this so far (simplified): points = [new Point(50, 35), new Point(500, 35), new Point(500, 300)]; path = new LinePath2D(points); var f:PathFollower = path.addFollower(object, 0, true, 90); tween = TweenMax.to(f, time, {progress: 1, onUpdate:onUpdateTween, ease:Linear.easeNone}); The object started with an initial rotation of 90° to the right and after reaching the 2nd point it was rotated again by 90° for reaching the final point. Now with Starling the same approach doesn't work anymore, since there rotations are calculated using radians. Therefore the rotation at point 2 will not look correctly anymore: points = [new Point(50, 35), new Point(500, 35), new Point(500, 300)]; path = new LinePath2D(points); var f:PathFollower = path.addFollower(object, 0, true, deg2rad(90)); // this allows the initial rotation tween = TweenMax.to(f, time, {progress: 1, onUpdate:onUpdateTween, ease:Linear.easeNone}); Is there a way how rotation can be handled correctly for a Starling Image/Sprite object with Greensock ? Btw. how can a LinePath2D object be added to a Starling Sprite ? At the moment i get the error "Implicit coercion of a value of type com.greensock.motionPaths:LinePath2D to an unrelated type starling.display:DisplayObject." Thank you for your help. Bests valley
- 1 reply
-
- Starling
- PathFollower
-
(and 2 more)
Tagged with: