Home / Phaser / P02

Phaser error: 'Texture key already in use: ' + key — cause and fix

The same key is reused to call this.load.image/atlas/spritesheet in the preload of two sce

ID
P02
Engine
Phaser
Verification
源码原文(src/textures/TextureManager.js:273)
Frequency
SO score=1(另 1 帖 score=0)

Original message (verbatim)

'Texture key already in use: ' + key

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

Trigger

The same key is reused to call this.load.image/atlas/spritesheet in the preload of two scenes that run simultaneously or are re-entered, or after a page refresh the asset cache is not cleared and the same key is loaded again.

Typical cause

TextureManager.checkKey finds the key already exists in the texture list, refuses to silently overwrite the existing texture, returns false and logs the error.

Step-by-step fix

  1. Load assets shared across scenes only once in the global preload.
  2. Before loading, check this.textures.exists(key); if a reload is truly needed, call this.textures.remove(key) first.
  3. Avoid registering the same asset key repeatedly across multiple scenes with active:true.

Source links

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

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