Sprite not appearing on a specific circumstance

Hold on let me change to the phaser.js so it’s easier to do

Found it, now I just click the line then refresh?

Indeed.

the issue seems to be at line… 143 of the stage, this snipet specifically?

this.runDust = this.effects.create(0, 0, "sprintDust").setVisible(false)

it’s weird, as this line of code does work properly.

After that one, I get to the troublemaking I’m trying to fix, is marking the snippet I just sent at the start of this thread

If you look at the value of key while the debugger is paused on return this.list['__MISSING'], that’s the bad texture key.

It’s marking down to a key that is actually used by the hearts (as how I placed it before for testing if it was actually the key) If this is the bad key, should it be broken in all instances, and if this is the bad key, why does the snippet breaks any other already working key just in this specific instance

So unless I’m missing something, I don’t see where you actually load an image or anything with the key “heart_full”. Can you show me where that is?

EDIT: Also, is heart_full an animation as well? I don’t see an animation with that key either.

If the key looks correct but still “missing,” it’s possible you’re trying to use the key before the texture has downloaded. Or that you removed the texture somehow, but that’s unusual.

I mean… it already preloads the json animation pack before anything with the preloader, let me get the json code…

{
    "anims":[
        {
            "key": "appleHeart",
            "frames": [
                { "frame": 2 }
            ],
            "frameRate": 10,
            "repeat": -1,
            "defaultTextureKey": "heartHud"
        },
        {
            "key": "heart_full",
            "frames": [
                { "frame": 0 }
            ],
            "frameRate": 10,
            "repeat": -1,
            "defaultTextureKey": "heartHud"
       },
        {
            "key": "heart_broken",
            "frames": [
                { "frame": 1 }
            ],
            "frameRate": 10,
            "repeat": -1,
            "defaultTextureKey": "heartHud"
        }
       
    ]
}

So, this is the json animation pack, which handles all health-related stuff, this would be the preloader:

export class Preloader extends Phaser.Scene{
    constructor(){
        super({key: "preloader"})
    }
    preload(){
        this.load.pack("stage1Tiles", "assets/stage1/tiles.json")
        this.load.tilemapTiledJSON("stage1Tilemap", "leveldata/stage1.json");

        this.load.pack("sfx", "audio/sfx/sfx.json")
        this.load.pack("music", "audio/music/music.json")
        this.load.spritesheet('bomb_hoots', 'assets/player/bomb.png', {frameWidth: 16, frameHeight: 16})
        this.load.spritesheet('effects_hoots', 'assets/player/dusts.png', {frameWidth: 16, frameHeight: 16})


        this.load.spritesheet("heartHud", "assets/global/hearts.png", {frameWidth: 16, frameHeight: 16})
        this.load.spritesheet('objectHearts', 'assets/global/objects.png', {frameWidth: 16, frameHeight: 16})

        this.load.animation("globalObj", "assets/global/global.json")

        
        this.load.spritesheet('hoots', 'assets/player/hoots.png', {frameWidth: 16, frameHeight: 16});
        this.load.animation('hootsAnims', 'assets/player/player.json')
        this.load.image('pauseText', 'assets/global/pauseText.png')

    }

    create(){

        this.scene.launch("stage1")

    }

}

the this.load.animation("globalObj", "assets/global/global.json") is the one loading the assets for the health-related stuff (aka, life hud and the heart containers you collect in the game). Also, this preloader is always loaded before anything, so I doubt that the texture hasn’t downloaded yet. If i were to try and put another key in the code snippet that’s making the issue, it would still not be able to load the key properly, even if the key is functional (for example, if I were to place the “heart_broken” key from the hud scene, it would still load except for the objects in the main scene.)

In the OP, you have this though:

const heartApple = this.physics.add.sprite(obj.x, obj.y, "heart_full")

I see the animation “heart_full” now, but I think you’re getting the missing texture box because you need a sprite with that key. “heart_full” is an animation on the texture “heartHud”. If you comment this line out, does the green box go away?

Yes, it looks like heart_full is an animation key and not a texture key. So you want to use

const heartApple = this.physics.add.sprite(obj.x, obj.y, "heartHud")

instead.

Ok, now it somewhat works? It does display a texture now, but it’s unable to change to other frame of the animation whatsoever, if I place an anims.play()it wont display the animation key whatsoever.

Edit: I could make it so it uses it’s own texture buuut it won’t make me able to animate it.

Double edit: if I try to add a collider to the objects with the player they straight up don’t work, although this is unrelated

You should use either play() or setFrame() but not both (or else stop the animation first), because an endlessly playing animation will keep changing frames.

heartApple.setFrame(0); // full
heartApple.setFrame(1); // broken
heartApple.setFrame(2); // apple

The play() straight doesn’t work, it defaults to the first frame in the texture file instead of going to any other animation.

If play() is unexpectedly switching to the first frame of the texture, it could be because a texture frame in the animation definition doesn’t exist, and you would see a warning in the console (except for frame name 0).

There is no warning whatsoever except for this (ignore the favicon.icon, that’s the icon for the website) and it really doesn’t change of frame, I think my best shot is to not include this and make the game a bit easier.