Position sprite or text on the center of the game

I am a beginner to phaser. Is there a way that I can position my sprite or text to the center?

Divide the height and width by 2 and use those as the y and x coords when adding the sprite to the scene. It depends how you initiated your game, but usually I create a config variable with the height and width, physics, scenes, etc. and pass that in as an argument to a game variable which initiates the new Phaser.Game. Then you can add a sprite or image to the center with this.physics.add(game.config.width / 2, game.config.height / 2, 'your key')

image

2 Likes