我有一个精灵组合
this.photons = this.physics.add.group({
key: "photon",
repeat: 11,
setXY: { x: 50, y: 50, stepX: 32 },
});
this.photons.children.iterate(function (child) {
child.body.bounce.set(1);
child.setVelocity(Phaser.Math.Between(300, 500),20);
child.body.collideWorldBounds = true;
});
编辑:
子元素们以this.physics.add.collider(this.photons, this.photons);
比1的速度相互碰撞
编辑:摄像机代码
const cursors = this.input.keyboard.createCursorKeys();
const controlConfig = {
camera: this.cameras.main,
left: cursors.left,
right: cursors.right,
up: cursors.up,
down: cursors.down,
acceleration: 0.06,
drag: 0.0005,
maxSpeed: 1.0,
};
this.controls = new Phaser.Cameras.Controls.SmoothedKeyControl(
controlConfig
);
我如何才能让每个子元素面对他们的矢量的方向,改变每一次碰撞?