在Phaser 3中开发新游戏,这是我第一次使用路径。
我已经使用PathBuilder
成功创建了JSON路径。非常酷的实用程序。
通过使用以下代码,我使精灵成功地遵循了路径:
this.pathTrack = new Phaser.Curves.Path(this.cache.json.get('pathTrack'));
this.followerCharacter = this.add.follower(this.pathTrack,'imageCharacter');
this.followerCharacter.startFollow({
duration: 6000,yoyo: false,repeat: -1,rotateToPath: true,rotationOffset: 90
});
这很好地证明了概念。
但是,我希望能够控制精灵沿着路径的“速度”。
例如,我想控制精灵沿路径的速度,因此我可以按住1键使其变慢,或按住2键使其变快。如果没有按下任何键,则精灵将根本不会移动。
我熟悉Phaser的input.keyboard
方法。但是,我只是不知道如何控制路径上的精灵。基本上,我试图创建一个“竞赛”游戏并确定哪个精灵首先到达终点。
感谢您的帮助!