相位器 3 街机:将摄像机跟随玩家的 Y 设置为固定



我从一个无尽的亚军游戏开始,玩家的位置是固定的,物体向左移动。我使用camera.startFollowing(player)跟随玩家,但当我跳跃时,相机会随着玩家移动。但相机Y位置必须固定。

尝试按setFollowOffset();设置偏移量 我尝试使用冲击物理,但 Phaser 找不到this.impact. 我使用相位器 3。

我已经从下面的代码片段中删除了不相关的代码。

var player, ground, camera;
function create(){
ground = this.physics.add.image(0, 568, 'ground').setScale(2, 2).setGravity(0);
player = this.physics.add.sprite(100, 510, 'dude');
player.setBounce(0);
ground.setCollideWorldBounds(true);
this.physics.add.collider(ground, player);
camera = this.cameras.main;
camera.startFollow(player);
camera.setFollowOffset(-300, 225);
}
function update(){
if (cursors.up.isDown && player.body.touching.down)
{
player.setVelocityY(-275);
}  
}

var config = {
type: Phaser.AUTO,
width: 800,
height: 600,
backgroundColor: '#ffff9c',
physics:{
default: 'arcade',
arcade:{
gravity: {y: 600},
debug: false,
}
},
scene:{
preload: preload,
create: create,
update: update
}
};
var game = new Phaser.Game(config);

解决了,我补充说:

camera.setLerp(0,0);

最新更新