Add sprite rexUI example

  var header = scene.rexUI.add.label({
        orientation: 'y',
        icon: scene.rexUI.add.roundRectangle(0, 0, 100, 100, 5, COLOR_LIGHT),
        text: scene.add.text(0, 0, data.name),

        space: {
            icon: 10,
        }
    });

hi, i want to add a sprite as background instead of setting plain color. I’ve loaded the sprite in my scene preloader but not sure how to use it with rexUI. Can you provide me some examples please?

1 Like

Since background might be stretched, a nine-patch game object is better then a sprite. Here is an example.

Edit:
To use sprite as background, replace line 28 this.rexUI.add.ninePatch(...) to this.add.sprite(...)

1 Like

Edit:
I was confused what to pass as parameters to
this.add.sprite();
but i figured out that for example ‘row’ is the key to the image that i loaded in preload.
scene.add.image(0, 0, ‘row’).

Make sure that background game object is below other game objects via setting depth.

1 Like