PokéRogue
    Preparing search index...

    Provides methods used for getting and setting the size of a Game Object.

    This component distinguishes between two size concepts. The native size (width and height) is the un-scaled logical size, typically derived from the Game Object's texture frame. The display size (displayWidth and displayHeight) is the actual rendered size in pixels, which factors in the Game Object's scale. Setting the display size adjusts the scale automatically, while setting the native size does not affect rendering directly.

    This component is mixed into Game Objects such as Sprites and Images by the Phaser Game Object Factory and is not intended to be used standalone.

    interface Size {
        displayHeight: number;
        displayWidth: number;
        height: number;
        width: number;
        setDisplaySize(width: number, height: number): this;
        setSize(width: number, height: number): this;
        setSizeToFrame(frame?: Frame): this;
    }

    Implemented by

    Index
    displayHeight: number

    The displayed height of this Game Object.

    This value takes into account the scale factor.

    Setting this value will adjust the Game Object's scale property.

    displayWidth: number

    The displayed width of this Game Object.

    This value takes into account the scale factor.

    Setting this value will adjust the Game Object's scale property.

    height: number

    The native (un-scaled) height of this Game Object.

    Changing this value will not change the size that the Game Object is rendered in-game. For that you need to either set the scale of the Game Object (setScale) or use the displayHeight property.

    width: number

    The native (un-scaled) width of this Game Object.

    Changing this value will not change the size that the Game Object is rendered in-game. For that you need to either set the scale of the Game Object (setScale) or use the displayWidth property.

    • Sets the display (rendered) size of this Game Object in pixels.

      Unlike setSize, which changes the native logical dimensions without affecting rendering, this method adjusts the scaleX and scaleY properties so that the Game Object appears at exactly the given pixel dimensions in-game. It is equivalent to calculating and setting the scale manually, but more convenient when you want to work in pixel values directly.

      Parameters

      • width: number

        The width of this Game Object.

      • height: number

        The height of this Game Object.

      Returns this

      This Game Object instance.

    • Sets the internal size of this Game Object, as used for frame or physics body creation.

      This will not change the size that the Game Object is rendered in-game. For that you need to either set the scale of the Game Object (setScale) or call the setDisplaySize method, which is the same thing as changing the scale but allows you to do so by giving pixel values.

      If you have enabled this Game Object for input, changing the size will not change the size of the hit area. To do this you should adjust the input.hitArea object directly.

      Parameters

      • width: number

        The width of this Game Object.

      • height: number

        The height of this Game Object.

      Returns this

      This Game Object instance.

    • Sets the size of this Game Object to be that of the given Frame or the current Frame.

      This will not change the size that the Game Object is rendered in-game. For that you need to either set the scale of the Game Object (setScale) or call the setDisplaySize method, which is the same thing as changing the scale but allows you to do so by giving pixel values.

      If you have enabled this Game Object for input with a custom hit area, changing the size of the Game Object will not change the size of the hit area. If you wish to do this, you should adjust the input.hitArea object directly. If you have enabled this Game Object for input without a custom hit area, the hit area will be automatically resized to match the size of the selected Frame.

      Parameters

      • Optionalframe: Frame

        The frame to base the size of this Game Object on. The default is the current frame of the Game Object.

      Returns this

      This Game Object instance.