Sesame
1
I’m trying to make an enemy patrol, I need to track the end and start points of the path, but all I got was, help (
create() {
path = new Phaser.Curves.Path()
path.lineTo(100, 0)
follower = this.add.follower(path, 100, 100, 'enemy').startFollow({ duration: 3000, loop: -1, yoyo: true, positionOnPath: false, rotateToPath: false })
}
update() {
let tan = path.getTangent(follower.pathTween.getValue())
if (tan.x > 0) follower.setFlipX(false)
else if (tan.x < 0) follower.setFlipX(true)
}
samme
2
What do you want to happen?
Sesame
3
I need the sprite to move from point A to point B, at point B turn around to point A and back
Sesame
5
Nothing, doesn’t work, just 1
samme
6
It’s moving correctly but there’s no flipping.
if (follower.pathTween.data[0].state === Phaser.Tweens.PLAYING_BACKWARD) {
tan.scale(-1);
}
1 Like
Sesame
7
if (follower.pathTween.data[0].state === Phaser.Tweens.PLAYING_BACKWARD)
wow it worked, thanks!