Can’t get the issue , please help me out , i’m using phaser 3
Use this.game
instead.
You haven’t created a global game
variable, so game
is undefined there.
in main.js i created that game global as var game,and although i did this.game then also it’s not solved.
If you just want the width and height of the game then you might want to use the ScaleManager instead:
const width = this.scale.width
const height = this.scale.height
// then...
this.add.sprite(width * 0.5, height * 0.5, 'boy')
sorry not work same error now instead of config it showing ‘width’.
what is this
if you log it out? console.log(this)
Does not appear this
is a Scene in your case. A Scene should have references to both game
and scale
. Unless you have a custom version of Phaser 3?
Also, you have var game
declared globally but then you create another var game
in window.onload
so your global game
is not set.
Hi, your var is scoped in the function and lost, try…
window.game = new Phaser.....
Please open the browser console and screenshot the error message.
sorry , i tried this but not work
Use the latest Phaser, v3.23.0.
Then use this.game.config.width
or this.scale.width
etc.
also did but not work
What happened?