Skip to content

AnimationManager toJSON() errors when stringified indirectly #7307

@samme

Description

@samme

Version

  • Phaser Version: 4.1.0

Description

If the Animation Manager is stringified indirectly, toJSON() will probably error because it interprets its key argument as animation identifier.

This came up when someone used a serialization library on a scene.

Example Test Code

In a scene:

JSON.stringify([ this.anims ]) // → toJSON("0")
// Uncaught TypeError: can't access property "toJSON", this.anims.get(...) is undefined
JSON.stringify({ anims: this.anims }) // → toJSON("anims")
// Uncaught TypeError: can't access property "toJSON", this.anims.get(...) is undefined

Additional Information

Probably best to remove the key argument from toJSON() and add a getJSON(animKey) method instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions