在我的Phaser 3游戏中,我有一个物体要绕特定半径(例如5个单位)的圆中的点(x,y)旋转。所有教程都在Phaser 2中,请帮帮我。
答案 0 :(得分:2)
You can use Phaser.Actions.RotateAroundDistance. There is an example here
In case the link breaks in the future, the parameters are
RotateAroundDistance(point, x, y, angle, distance):
And an exmple use on a group of objects is below:
Phaser.Actions.RotateAroundDistance(group.getChildren(), { x: 400, y: 300 }, 0.02, 200)
答案 1 :(得分:1)
我的猜测是将精灵的anchor
设置在实际的精灵之外。锚点是精灵上的枢轴点或“手柄”,实际上是x,y位置和角度等的偏移。设置的锚点越远,半径将越大。
然后添加补间动画以旋转角度。像这样:
// setAnchor, x offset = 10 to the right of the sprite, y offset = center of sprite
mysprite.setAnchor(10.0, 0.5);
var tween = game.tweens.add({
targets: mysprite,
angle: 360.0,
duration: 1500,
repeat: 0
});