Skip to content

NineSlice setFrame() doesnt work when updateSize is false #7110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ChrisCPI opened this issue Apr 15, 2025 · 1 comment
Open

NineSlice setFrame() doesnt work when updateSize is false #7110

ChrisCPI opened this issue Apr 15, 2025 · 1 comment

Comments

@ChrisCPI
Copy link

Version

  • Phaser Version:
    3.88.2
  • Operating system:
    macOS 15.3.1
  • Browser:
    Google Chrome

Description

When setFrame() is called on a NineSlice game object, and the updateSize parameter is set to false, the frame does not appear to update.

Example Test Code

https://phaser.io/sandbox/3r6cWwMn

Additional Information

In the above sandbox, there is one normal image and one nineslice, both with the same texture and frame. Both have the exact same interactive and listeners set to them, where the frame changes on pointerover and on pointerout. However, only the normal image appears to have its frame changed.

@ChrisCPI
Copy link
Author

ChrisCPI commented May 23, 2025

Looking into this a little, I discovered that this can be fixed if setSizeToFrame() is called on the nineslice after setFrame.

            image.setFrame(frame, false, true)
            image.setSizeToFrame()

Which is weird, because the documentation for this method on the NineSlice object says:

This method is included but does nothing for the Nine Slice Game Object, because the size of the object isn't based on the texture frame. You should not call this method.

Edit: I realize that this may be an obvious realization, since this is probably what it does when updateSize is false. But if this supposedly "does nothing" like the documentation says, then why would it hinder it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant