Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Tweening along bezier curve: getting data in real-time


ForgeableSum
 Share

Recommended Posts

Suppose I am tweening a sprite along a quadratic bezier curve like so:

 

var controlX = attacker.x;var controlY = attacker.y - 100; var time = 5000; var demoTween = game.add.tween(projectile).to({x : [attacker.x, controlX, moveX],y : [attacker.y, controlY, moveY],}, time, Phaser.Easing.Quadratic.Out, true) .interpolation(function(v, k) {return Phaser.Math.bezierInterpolation(v, k);});
 
Is there any way I can get data about the bezier curve in real time? I understand there is a callback function for whenever the tween is updated (onUpdateCallback), but I'm trying to extract data related to where the sprite is on the curve. If you look at the diagram below, I have a need to get the "Q1" coordinate ... 
 
post-12134-0-02112200-1425253268.png
 
demoTween.onUpdateCallback(function() {// need to get Q1 here }); 
 
Any ideas? I need q1 to determine how much the sprite will be rotated (it's an arrow). 
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...