0
import Phaser from 'phaser'
export default class extends Phaser.Sprite {
constructor ({ game, x, y, asset }) {
super(game, x, y, asset)
this.game = game
this.anchor.setTo(0.5)
}
update() {
this.angle += 1
}
}
だから私はこのようなPhaser.Textクラスでこれを複製しようとした:
import Phaser from 'phaser'
export default class extends Phaser.Text {
constructor({game, x, y, text, style}){
super(game, x, y, text, style)
this.game = game
this.anchor.setTo(0.5)
}
}
してからちょうど例のように、Game.jsファイルにそれを呼んだ:
this.texto = new Texto({
game: this,
x: 0,
y:0,
text:"hola mundo"
})
this.game.add.existing(this.texto)
が、T結果は次のようになります。
Uncaught TypeError: Cannot read property 'resolution' of undefined
正しくPhaser.Textを拡張するか、再利用可能なクラスを作成するにはどうすればよいですか?
私は間違っていますか?
ありがとうございます!
を変更してみたらどう
あなたがエラーがテキストオブジェクトで発生していますか?解像度はテキストのプロパティですが、問題はどこかにTextオブジェクトが存在しないようです –