【发布时间】:2022-09-28 19:30:34
【问题描述】:
每当我单击鼠标时,我都会尝试轻弹,但input.on 上的变量在单击鼠标时返回 undefined 这里是 sn-p。 Phaser对我来说是新的
w : number;
h : number;
velocity:number;
sprite = null;
totalDelta = null;
constructor() {
super({ key: \'Init\' });
}
preload(){
this.w = Number(this.game.config.width);
this.h = Number(this.game.config.height);
this.velocity = Number(this.game.config.physics.arcade.gravity.y);
this.createBG();
}
createBG(){
this.add.image(0,0,\'background\').setOrigin(0);
}
createSprite(){
var x = this.w * 0.1;
this.sprite = this.physics.add.sprite(x ,this.h/2,\'sprite\').setOrigin(0);
}
create(){
this.createSprite();
this.input.on(\"pointerdown\",this.flick);
}
flick(){
this.sprite.body.velocity.y = -this.velocity;
}
标签: angular typescript phaser-framework