alexKirilov Posted September 23, 2016 Share Posted September 23, 2016 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 ? Lolomancer 1 Link to comment Share on other sites More sharing options...
rich Posted September 23, 2016 Share Posted September 23, 2016 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 More sharing options...
alexKirilov Posted September 23, 2016 Author Share Posted September 23, 2016 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 More sharing options...
samme Posted September 24, 2016 Share Posted September 24, 2016 Should be `game.load.image`. Link to comment Share on other sites More sharing options...
alexKirilov Posted September 24, 2016 Author Share Posted September 24, 2016 I am a moron. If anyone else gets into a simular issue , just remember , as a programmer its usually your fault, for me the case was that I was using game.load.images(..). ... -.- and somehow managed to miss it the thousand times I looked trough the 5 lines of code ... Link to comment Share on other sites More sharing options...
Recommended Posts