Styling background added by Phaser

Hey! How can I style this background added by:
this.load.image(‘bg’,‘Assets/bg.jpg’);
this.add.image(0,0,‘bg’).setOrigin(0,0);
I want to change transparency and I dont know how

this.add.image(0,0,‘bg’)
  .setOrigin(0,0)
  .setAlpha(0.5)

Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque.

I have one more issue. I have about 3-4px spacing between my bg and left/top side but it is set on 0,0. How can I move my bg more to the corner? https://imgur.com/a/1vOseXo
It’s not .png issue btw

The best thing to do would be to modify your image.

Or you do

this.add.image(-4,-4,‘bg’)
  .setOrigin(0,0)
  .setAlpha(0.5)

I said that it is not background fault - it is correctly cutted. ;/ https://imgur.com/a/9S7uCLb you see?

So it’s the html?
Try to reset the padding and margin of the html and body tag.

Your css:

html,
body {
  margin: 0;
  padding: 0;
}

oh now it works, thanks a lot

Niice. Glad it works now :slight_smile:

Do not forget to check the :ballot_box_with_check: on the post that solved your question. Use the :heart: to like a post.

1 Like