【发布时间】:2019-02-17 14:48:04
【问题描述】:
我目前面临一个问题:我想让我的玩家精灵(左侧角色)移动到右侧。我已经让它工作了,但现在我想让角色在我按下按钮时移动,这是我的问题,我不知道该怎么做。
我已经尝试过使用发射器和外部布尔值。
这是部分代码
export class CombatComponent implements OnInit {
constructor() { }
public onGameReady(game: Phaser.Game): void {
this.game = game;
}
public game: Phaser.Game;
public readonly gameConfig: Phaser.Config = {
title: environment.title,
type: Phaser.AUTO,
width: 1024,
height: 512,
physics: {
default: 'arcade',
arcade: {
gravity: {y: 300},
debug: false
}
},
scene: {
preload: function() {
...
},
create: function () {
....
},
update: function() {
....
}
}
};
attack() {
//would like to make my character move here like this.player.x += 1
}
如果有人有解决方案或提示,我很乐意阅读!
【问题讨论】:
标签: typescript button phaser-framework