mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-05 16:02:20 +02:00
Fix item icons not displaying in shop due to asynchronous sprite loading
This commit is contained in:
parent
1042b528ec
commit
6b3ce8487a
1
package-lock.json
generated
1
package-lock.json
generated
@ -39,7 +39,6 @@
|
|||||||
"lefthook": "^1.11.5",
|
"lefthook": "^1.11.5",
|
||||||
"msw": "^2.7.3",
|
"msw": "^2.7.3",
|
||||||
"phaser3spectorjs": "^0.0.8",
|
"phaser3spectorjs": "^0.0.8",
|
||||||
"rollup": "^4.40.1",
|
|
||||||
"typedoc": "^0.28.1",
|
"typedoc": "^0.28.1",
|
||||||
"typescript": "^5.8.2",
|
"typescript": "^5.8.2",
|
||||||
"typescript-eslint": "^8.28.0",
|
"typescript-eslint": "^8.28.0",
|
||||||
|
@ -763,7 +763,26 @@ class ModifierOption extends Phaser.GameObjects.Container {
|
|||||||
this.add(this.itemContainer);
|
this.add(this.itemContainer);
|
||||||
|
|
||||||
const getItem = () => {
|
const getItem = () => {
|
||||||
const item = globalScene.add.sprite(0, 0, "items", this.modifierTypeOption.type?.iconImage);
|
const iconKey = this.modifierTypeOption.type?.iconImage;
|
||||||
|
const item = globalScene.add.sprite(0, 0, "items", iconKey);
|
||||||
|
item.setVisible(false);
|
||||||
|
|
||||||
|
const showItemSprite = () => {
|
||||||
|
if (globalScene.textures.get("items").has(iconKey)) {
|
||||||
|
item.setFrame(iconKey);
|
||||||
|
} else {
|
||||||
|
item.setTexture("default_icon");
|
||||||
|
}
|
||||||
|
item.setVisible(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (globalScene.textures.get("items").has(iconKey)) {
|
||||||
|
showItemSprite();
|
||||||
|
} else {
|
||||||
|
globalScene.load.once("complete", showItemSprite);
|
||||||
|
globalScene.load.start();
|
||||||
|
}
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user