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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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