私は単純なプラットフォームゲームをプログラミングしていますが、私はプレーヤーの動きをプログラムして設定しています。ここに私の更新機能があります:フェイザー - 複数のキーイベントを許可できません
update: function() {
game.physics.arcade.collide(this.player, this.platform);
game.camera.follow(this.player);
if(this.cursor.right.isDown){
this.player.body.velocity.x= 200;
this.player.animations.play('correr', 5, true);
this.player.scale.x=1;
}
else if(this.cursor.left.isDown){
this.player.body.velocity.x= -200;
this.player.animations.play('correr', 5, true);
this.player.scale.x=-1;
}
else if(this.jump.isDown && this.player.body.wasTouching.down) {
this.player.body.velocity.y= -400
}
else if((this.cursor.right.isDown || this.cursor.left.isDown) && this.jump.isDown){
this.player.body.velocity.x= 200;
this.player.body.velocity.y=-200;
}
else{
this.player.body.velocity.x = 0;
this.player.animations.stop();
this.player.frame = 4;
}
}
すべてが正常に動作しますが、私の最後の他に、プレイヤーがジャンプして歩くが、それは動作しないべきであると仮定した場合!私の意図は、ジャンプキー+左または右のキーを押しながら歩いている間にジャンプすることができるプレイヤーです。今はちょうど最初にジャンプして歩くことができます。
私は最初のif節でそれを移動しようとしたため、この最後のelseが実行されていないことはわかりませんが、完全に機能しましたが、エラーを特定できません。
ありがとうございます。
感謝を見つけることをお勧めします、私はその方法を試してみます。しかし、私はそれを動かすように修正しました else if((this.cursor.right.isDown || this.cursor.left.isDown)&& this.jump.isDown) 最初の条件を評価し、すべてを解決しました。 – Santiago