Jump to content

Phaser.Loader error on asset load


alexKirilov
 Share

Recommended Posts

For a start I would like say hello and give my appreciation to the whole of html5gamedev's amazing and helpful community. I've been lurking here for a while and while you might not have known it, this community has already saved my tons of hours =] .

Now to my problem. I litterly JUST started with Phaser and while following ( what I could only imagine to be ) the introductory tutorial , I ran into my very first problem:

Right now I am simple trying to load a basic bg image as follows:
 

var game = new Phaser.Game(800, 600, Phaser.AUTO, '', {preload: preload, create:create, update:update});

function preload(){
	game.load.images('bg', 'assets/levels/Stage_One_Base.png');
}

function create(){}

function update(){

}

other then that my whole index consist of only including the Phaser framework and this script file.

the error I am getting is as follows : 

Phaser v2.6.2 | Pixi.js | WebGL | WebAudio     http://phaser.io ♥♥♥

GET http://localhost/workspace/phaserGame/b.png 404 (Not Found)
GET http://localhost/workspace/phaserGame/g.png 404 (Not Found)

phaser.js:74259 Phaser.Loader - image[b]: error loading asset from URL b.png
phaser.js:74259 Phaser.Loader - image[g]: error loading asset from URL g.png

This does not make any sense to me. Firstly why is it giving me error about 2 assets, while I am only loading 1.
Secondly after a quick google search, for what I have seen usually Phaser's error should contain the proper URL + filename of the img, but this b.png and g.png doesnt make any sense to me ? Am I missing something obvious ?

I verifyed the path to the img by typing the full path in the URL ( localhost/workspace/phaserGame/assets/levels/Stage_One_Base.png ) and it loads and displays just fine.

Additional info:
If this is gonna help, I am running linux mint with xampp as a webserver, installed phaser locally using npm.
The image I am trying to load would be used as a background and such is a little big ( 1524x269 ) when I open my webpage all I get is a black screen + the errors, while at the start I was getting the little square ( which while searching google, I found out , that it usually means that my image key-index is correct but phaser can't find the cached image to use ).
I am testing it on chromium.

And thanks in advance for all of your help =] . 

P.M. Maybe I should change the title of the post to something more useful/descriptive, any suggestions ?

Link to comment
Share on other sites

I suspect that what is running in the browser is not what your code shows. Try this: Stick a 'console.log("Hello!")' call into your preload function. Now refresh the browser. Do you see that log in the dev tools? If not, it's not running that code (but something else). Or it could be a cache issue? Again, working with the Dev Tools open will ensure that your files aren't cached.

Link to comment
Share on other sites

4 hours ago, rich said:

I suspect that what is running in the browser is not what your code shows. Try this: Stick a 'console.log("Hello!")' call into your preload function. Now refresh the browser. Do you see that log in the dev tools? If not, it's not running that code (but something else). Or it could be a cache issue? Again, working with the Dev Tools open will ensure that your files aren't cached.

I always have my Dev tools with disabled cache checked, and also when I put the a simple console.log() at the top of the preload function I get:

this

I know how it looks, I thought the same initially but trust me that was the first thing I checked, wouldn't have made this post otherwise =]

 

P.S: Also keep in mind this is my FIRST EVER - phaser - script , I litterly have never used Phaser before, so its not like I could have had some old code that I am executing by mistake and thats exacly why I think I might have messed up the setup somehow ?!?.. ( I only did npm install phaser ) but this error isnt giving me much to work with ;c
 

I need to used Phaser to finish the assignment for my programming entry course, but I cant even get it to load an image :(
 

P.S2: As you can see it seems to be spliting my 'bg' definition into a B and G image and trying to load them fails 
... but why .. ? I am probably making some dumb mistake ?

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...