From 78cf362c363b4f21d6c6c7d7715065b03bccffde Mon Sep 17 00:00:00 2001 From: SadiQURT Date: Sun, 10 Dec 2017 10:40:23 +0200 Subject: [PATCH 1/2] Added a bezier path tween. Added the ability to tween an actor based on Actuate's bezier path. --- com/stencyl/models/Actor.hx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/com/stencyl/models/Actor.hx b/com/stencyl/models/Actor.hx index 5afb9fbd..b09dce99 100644 --- a/com/stencyl/models/Actor.hx +++ b/com/stencyl/models/Actor.hx @@ -55,6 +55,7 @@ import com.stencyl.models.GameModel; import com.stencyl.utils.Utils; import motion.Actuate; +import motion.MotionPath; import motion.easing.Back; import motion.easing.Cubic; import motion.easing.Elastic; @@ -3601,6 +3602,20 @@ class Actor extends Sprite Actuate.tween(tweenLoc, duration, {x:x, y:y}).ease(easing).onComplete(onTweenPositionComplete); } + public function bezierPathMoveTo(destX:Float, destY:Float, controlX:Float, controlY:Float, duration:Float = 1, easing:Dynamic = null ) + { + var path = new MotionPath().bezier (destX, destY, controlX, controlY); + tweenLoc.x = getX(false); + tweenLoc.y = getY(false); + if(easing == null) + { + easing = Linear.easeNone; + } + activePositionTweens++; + + Actuate.motionPath(tweenLoc,duration,{x:path.x,y:path.y}).ease(easing).onComplete(onTweenPositionComplete); + } + //In degrees public function spinBy(angle:Float, duration:Float = 1, easing:Dynamic = null) { From c8c68a912e2ea323fccaa93a39b8fe33e0d23220 Mon Sep 17 00:00:00 2001 From: SadiQURT Date: Tue, 12 Dec 2017 11:35:42 +0200 Subject: [PATCH 2/2] Added the ability to tween an actor based on a bezier curve. The actor will now touch the control points. --- com/stencyl/models/Actor.hx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/com/stencyl/models/Actor.hx b/com/stencyl/models/Actor.hx index b09dce99..097c8394 100644 --- a/com/stencyl/models/Actor.hx +++ b/com/stencyl/models/Actor.hx @@ -3602,9 +3602,15 @@ class Actor extends Sprite Actuate.tween(tweenLoc, duration, {x:x, y:y}).ease(easing).onComplete(onTweenPositionComplete); } + //The actor will touch the control point public function bezierPathMoveTo(destX:Float, destY:Float, controlX:Float, controlY:Float, duration:Float = 1, easing:Dynamic = null ) { - var path = new MotionPath().bezier (destX, destY, controlX, controlY); + var x1 = getX(false); + var y1 = getY(false); + var tempX = Math.round(((x1 + destX) / 2)); + var tempY = Math.round(((y1 + destY) / 2)); + var tempCX = (tempX + ((cx - tempX) * 2)); + var tempCY = (tempY + ((cy - tempY) * 2)); tweenLoc.x = getX(false); tweenLoc.y = getY(false); if(easing == null) @@ -3612,7 +3618,7 @@ class Actor extends Sprite easing = Linear.easeNone; } activePositionTweens++; - + var path = new MotionPath().bezier(destX, destY, tempCX, tempCY); Actuate.motionPath(tweenLoc,duration,{x:path.x,y:path.y}).ease(easing).onComplete(onTweenPositionComplete); }