Jump to content

Phaser.Cache.getImage: Key "p1walk01" not found in Cache.


Sergim
 Share

Recommended Posts

Hello guys,

I just started playing around with phaser and i`m stuck now with this error message and I couldn't find the solution on the web so far. It happens when it reaches the animation.add line.

Nothing seems to be wrong with my json or png files... I am using a JSON Hash and not JSON Array, so this should work..


Error:     Phaser.Cache.getImage: Key "p1walk01" not found in Cache.

My Code: 
 

preload: function () {

        //this.game.load.spritesheet('player', 'BODY_male.png', 50, 65, 36);
        //this.load.spritesheet('player', 'asset/BODY_male.png', 50, 51, 36, 10, 14);
        this.load.image('background', 'asset/beach.jpg');
        this.load.image('ball', 'asset/Volleyball.png');
        this.load.image('net', 'asset/vnet.png');
        this.load.atlasJSONHash('player1', 'asset/sprites.png', 'asset/sprites.json');
    
    },

    create: function () {
/*
        // Add logo to the center of the stage
        this.logo = this.add.sprite(
            this.world.centerX, // (centerX, centerY) is the center coordination
            this.world.centerY,
            'logo');
        // Set the anchor to the center of the sprite
        this.logo.anchor.setTo(0.5, 0.5);
*/
 
        //this.game.stage.backgroundColor = '#0072bc';
        this.world.setBounds(0, 0, 1200, 800);

        this.game.physics.startSystem(Phaser.Physics.ARCADE);
        this.game.physics.arcade.gravity.y = 200;
 

        this.background = this.add.tileSprite(0, 0, 1200, 800, 'background');
        this.background.fixedToCamera = true;

        this.player = this.game.add.sprite(this.world.centerY + this.world.centerY - 10 , 'player1', 'p1walk01');
        this.ball = this.game.add.sprite(100, 400, 'ball');
        this.game.physics.enable([this.ball,this.player], Phaser.Physics.ARCADE);
         
         
        //     
        //this.game.Animation.generateFrameNames('playerwalk', 1, 2,undefined,2);
        //
        //this.player.scale.setTo(1, 1);
        this.player.animations.add('playerwalk', Phaser.Animation.generateFrameNames('p1walk', 0, 2, '', 2), 5, true);

 

 

 

Link to comment
Share on other sites

p1walk01 is a frame inside player.

i loaded it inside preload function, it was supposed to be in cache, right?

and if i remove it, the following error occurs:

phaser.js:67201 Uncaught TypeError: Cannot read property 'getFrameIndexes' of null

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...