I am trying to pass in random values into the shotPath function. Things work as expected on the first shot, but subsequent shots start from the end point of the previous path, and then things dance around.
-
How do I reset it so it always generates a fresh path from the 540, 1550 coordinate?
-
How can I clear the ball?
Destroy is not documented at all. There are no notes, but apparently this completely destroys it and you can’t use it again. I don’t see a rest or clear function. ball.stopFollow() does something, but not what I want.
shotPath(finX, finY, curveWidth, curveHeight);
ballpath = new Phaser.Curves.Path(540, 1550);
ball = this.add.follower(ballpath, 540, 1550, 'ball');
function shotPath(finX,finY, curveWidth, curveHeight) {
ballpath.quadraticBezierTo(finX, finY, curveWidth, curveHeight);
ball.startFollow({
from: 0,
positionOnPath: false,
duration: 3000,
repeat: 0
});
}
Side note: Pasting from WebStorm on macOS doesn’t work on to the forum, I have to paste in another window first.
Edit: It appears gets appended instead of replaced, so I am ended up with concatenated curves like this:
ballpath.quadraticBezierTo(finX, finY, curveWidth, curveHeight).quadraticBezierTo(finX, finY, curveWidth, curveHeight).quadraticBezierTo(finX, finY, curveWidth, curveHeight);
I am looking for something like delete ballpath.Curves[0];