fitness23 Posted July 29, 2017 Share Posted July 29, 2017 So I know how to draw an arc = https://phaser.io/examples/v2/display/arc But how can I get a sprite to tween along it? I could make an array of x and y points for the tween, but is there a way I can get all the x and y coordinates of the arc? Hopefully the graphic below will illustrate as to what I'm after: Link to comment Share on other sites More sharing options...
Skeptron Posted July 29, 2017 Share Posted July 29, 2017 You can pass functions to the tweening methods, so that you can do any custom behaviour. Doc : http://phaser.io/docs/2.4.4/Phaser.Tween.html#to Look at the ease function : you can pass your custom method here. Link to comment Share on other sites More sharing options...
fitness23 Posted July 29, 2017 Author Share Posted July 29, 2017 1 hour ago, Skeptron said: You can pass functions to the tweening methods, so that you can do any custom behaviour. Doc : http://phaser.io/docs/2.4.4/Phaser.Tween.html#to Look at the ease function : you can pass your custom method here. Thanks but the ease function won't have anything to do with the tween path. Link to comment Share on other sites More sharing options...
samme Posted July 30, 2017 Share Posted July 30, 2017 Link to comment Share on other sites More sharing options...
samme Posted July 31, 2017 Share Posted July 31, 2017 Or you can use Tween#generateData(frameRate) to create an array of points ([{x: x1, y: y1}, …]) and then pass that into a second tween that actually moves the sprite. Then the second tween could use any easing function. Link to comment Share on other sites More sharing options...
fitness23 Posted August 1, 2017 Author Share Posted August 1, 2017 Hmm thanks. I'm still confused as to how I'm going to get the co-ordinates of the arc in the first place though. I need to know those before I can submit them off in a tween. Link to comment Share on other sites More sharing options...
samme Posted August 2, 2017 Share Posted August 2, 2017 Here are two ways. Sorry for CoffeeScript, you can view source for the compiled JS. Link to comment Share on other sites More sharing options...
Recommended Posts