Sign in to follow this  
ichbinkaizoku

Key " " not found in Cache.

Recommended Posts

Hi guys, I just started out with Phaser and I was thinking about creating a basic game with a guy jumping around from scratch. I searched this website for an answer but I couldn't actually find one that fits or I was too stupid to understand it. So why when I want to create an image on the canvas it says "Phaser.Cache.getImage: Key "jucator" not found in Cache." ? 

Here's my code:

<html>
<head>
<meta charset="UTF-8" />
<title>Dani Mocanu runs</title>
<script type="text/javascript" src="JS/phaser.min.js"></script>
</head>
<body>
<script type="text/javascript">
 
var player;
 
new Phaser.Game(800, 600, Phaser.AUTO, '', {
preload: function(){
 
this.game.stage.backgroundColor = '#85b5e1';
this.game.add.image('platforma', 'assets/platform.jpg');
this.game.add.image('jucator', 'assets/player.jpg');
},
 
create: function(){
 
player = this.game.add.sprite(0,0,'jucator');
},
 
update: function(){
 
}
})
</script>
</body>
</html>

I'm using WAMP in order to 'host' the game. Thanks for the info and if you have any advice about how should I be learning Phaser in a better way or any advice about anything for a beginner please let me know. Thank you! 

Share this post


Link to post
Share on other sites

It is actually a syntax error, and its because you did not use the "load" function in the preload. So here is the fix code. 

<html>
<head>
<meta charset="UTF-8" />
<title>Dani Mocanu runs</title>
<script type="text/javascript" src="JS/phaser.min.js"></script>
</head>
<body>
<script type="text/javascript">
 
var player;
 
new Phaser.Game(800, 600, "Phaser.AUTO '', {
preload: function(){
 
game.load.image('platforma', 'assets/platform.jpg');
game.load.image('jucator', 'assets/player.jpg');
},
 
create: function(){
this.game.stage.backgroundColor = '#85b5e1';
player = this.game.add.sprite(0, 0, 'jucator');
},
 
update: function(){
 
}
});
</script>
</body>
</html>

Share this post


Link to post
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...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.