Phaser API Documentation

  Version: 
setSlices([width], [height], [leftWidth], [rightWidth], [topHeight], [bottomHeight])

Description:

Resets the width, height and slices for this NineSlice Game Object.

This allows you to modify the texture being used by this object and then reset the slice configuration, to avoid having to destroy this Game Object in order to use it for a different game element.

Please note that you cannot change a 9-slice to a 3-slice or vice versa.

Parameters:

name type arguments Default description
width number <optional> 256

The width of the Nine Slice Game Object. You can adjust the width post-creation.

height number <optional> 256

The height of the Nine Slice Game Object. If this is a 3 slice object the height will be fixed to the height of the texture and cannot be changed.

leftWidth number <optional> 10

The size of the left vertical column (A).

rightWidth number <optional> 10

The size of the right vertical column (B).

topHeight number <optional> 0

The size of the top horiztonal row (C). Set to zero or undefined to create a 3 slice object.

bottomHeight number <optional> 0

The size of the bottom horiztonal row (D). Set to zero or undefined to create a 3 slice object.

Returns:
Description:

This Game Object instance.

Since: 3.60.0