Jump to content

Images didn't find in cache


Caikozolyv
 Share

Recommended Posts

Hello everybody,

I'm new in javascript and doing a phaser tutorial to make a virtual pet game. 

I cut my code into different files (Boot, Preload, Menu and Game) but I got this error :

" phaser.js:71363Phaser.Cache.getImage: Key "background" not found in Cache. "

I think that my GameState.js is loaded before my PreloadState.js ...

Here is my code :

var PreloadState = {

    preload: function () {

        this.logo = this.add.sprite(this.game.world.centerX, this.game.world.centerY, 'logo');
        this.logo.anchor.setTo(0.5);

        this.preloadBar = this.add.sprite(this.game.world.centerX, this.game.world.centerY + 128, 'preloadBar');
        this.preloadBar.anchor.setTo(0.5);
        this.load.setPreloadSprite(this.preloadBar);

        this.load.image('background', 'resources/img/background.svg', 800, 600);

        this.load.image('apple', 'resources/img/apple2.png');
        this.load.image('candy', 'resources/img/candy2.png');
        this.load.image('rotate', 'resources/img/rotate2.png');
        this.load.image('toy', 'resources/img/toy2.png');

        this.load.spritesheet('girl', 'resources/img/PlayerSprite0.png', 65, 70, 1, 1);

    },
    create: function () {
        this.state.start('GameState');
    },
};

Thank you for answering me

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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