Home / Phaser / P17

Phaser error: 'Animation key exists: ' + key — cause and fix

Calling anims.add(key, animation) directly to register an animation whose key already exis

ID
P17
Engine
Phaser
Verification
源码原文(src/animations/AnimationManager.js:298)
Frequency
未公开

Original message (verbatim)

'Animation key exists: ' + key

Placeholders such as %s / %d are kept verbatim from the engine source and are not replaced with concrete values.

Trigger

Calling anims.add(key, animation) directly to register an animation whose key already exists in the global AnimationManager (a different path from the create duplicate warning).

Typical cause

add() first checks this.anims.has(key); when the key is taken it only warns and returns this, without overwriting the old animation instance, so the new config does not apply.

Step-by-step fix

  1. Before registering, check this.anims.exists(key) to see whether the key is already used.
  2. To replace an animation, call this.anims.remove(key) first, then register again.
  3. Animations are global and are not cleared on scene restart; avoid adding the same key during scene init.

Source links

Per-entry sources and capture date are listed at /sources#P17.

Related errors

Related Phaser errors

Need an offline quick-reference checklist?

Atlas error library Pro pack: 123 error references (110 single + 13 merged) plus a quick-fix guide, $19 one-time purchase, delivered as electronic files.

View Pro pack / order

Back to the all-errors index Checkout and buy the Pro pack — $19.00