giorg Posted September 11, 2018 Share Posted September 11, 2018 hi there, using phaser 3, kinda newbie on this framework. I was using this piece of code for some test: class Boot extends Phaser.Scene { constructor (globalObject) { super({key: 'Boot', pack: { files: [{ type: 'image', key: 'logo', url: 'assets/common/logosetstudio.jpg' }] }, }); } which worked perfectly. Now I'm integrating my game into php laravel framework, and paths are changed. That url parameter I'm passing doesn't get loaded anymore while game is loading, but if I check the full path against an empty tab, I can see the image, so the path is correct. Wondering what that url should be, any help? thanks a lot Link to comment Share on other sites More sharing options...
rich Posted September 11, 2018 Share Posted September 11, 2018 Open Dev Tools, inspect network requests, load the page - where is it _trying_ to get the file from? Because the laravel routing sounds like it's forcing it through a different location than in your code. Link to comment Share on other sites More sharing options...
giorg Posted September 12, 2018 Author Share Posted September 12, 2018 Hey rich, thanks for your answer. I already did that, unfortunately there is no 404 or anything... weird thing is, later in the code I do something like this.load.bitmapFont('fontciccione', '../games/magicd/assets/common/s4fontciccione.png', '../games/magicd/assets/common/s4fontciccione.xml') which has the same path, and it works! so the bitmapFont function and the constructor somehow work in a different way... thanks Link to comment Share on other sites More sharing options...
giorg Posted September 12, 2018 Author Share Posted September 12, 2018 btw I tried different paths, all directly reachable by browser, like window.location.href + '/games/magicd/assets/common/logosetstudio.jpg' or just /images/logosetstudio.jpg but no way... cannot understand. thanks Link to comment Share on other sites More sharing options...
rich Posted September 12, 2018 Share Posted September 12, 2018 Is there’s nothing in the network requests then the Scene config isn’t valid (by the time it gets to the scene) so it’s skipping loading Link to comment Share on other sites More sharing options...
giorg Posted September 12, 2018 Author Share Posted September 12, 2018 I understand this, but I don't know how to debug it... and if the url parameter is a pasted into a new tab shows me the image, don't know what else to try... thanks Link to comment Share on other sites More sharing options...
rich Posted September 12, 2018 Share Posted September 12, 2018 Load the asset in the preload function instead? The config posted in your first message is correct, there's nothing wrong with it. And if it works outside of putting it into your Laravel app then it's nothing to do with Phaser either really. Link to comment Share on other sites More sharing options...
iKest Posted September 12, 2018 Share Posted September 12, 2018 you need use "public" folder for assets in laravel project. Link to comment Share on other sites More sharing options...
giorg Posted September 12, 2018 Author Share Posted September 12, 2018 Hi iKest, thanks for your answer, all assets are in a subfolder of "public", all those inside the preloader function are correctly shown, only this one inside the constructor it's not... Link to comment Share on other sites More sharing options...
iKest Posted September 13, 2018 Share Posted September 13, 2018 just this code part non informative for make solution. need working code on labs.phaser.io or codepen.io Link to comment Share on other sites More sharing options...
giorg Posted September 13, 2018 Author Share Posted September 13, 2018 hi, thanks for your help, there we go with full code: https://codepen.io/giorg/pen/aaKJqZ all the pictures in the preload function are working, only the one in the constructor is not... thanks a lot! Link to comment Share on other sites More sharing options...
iKest Posted September 13, 2018 Share Posted September 13, 2018 del. Link to comment Share on other sites More sharing options...
giorg Posted September 13, 2018 Author Share Posted September 13, 2018 hello iKest, thanks but not working as well... also, that code is working outside laravel, in a simple folder, so seems somehow laravel-related. But if all others in preload function are working, I don't see why this one should not thanks a lot Link to comment Share on other sites More sharing options...
rich Posted September 13, 2018 Share Posted September 13, 2018 Yeah, your code is correct (depending on which version of Phaser 3 you're using, but as it works outside of Laravel I reckon that's right too - worth checking though!) Try this - in your Scene init (or create) function, log out the contents of 'this.sys.settings' and also `this.sys.config` and check the objects there, do they have the pack object in, un-touched? Link to comment Share on other sites More sharing options...
giorg Posted September 14, 2018 Author Share Posted September 14, 2018 hey rich, I do not understand what u mean with pack object untouched... this is settings: active: true cameras: null data: Object { } files: false isBooted: true isTransition: false key: "Boot" loader: Object { } map: Object { game: "game", anims: "anims", cache: "cache", … } physics: {} <prototype>: Object { … } plugins: false status: 5 transitionAllowInput: true transitionDuration: 0 transitionFrom: null visible: true <prototype>: Object { … } and this is config: {…} key: "Boot" pack: Object { files: (1) […] } <prototype>: Object { … } thanks Link to comment Share on other sites More sharing options...
iKest Posted September 14, 2018 Share Posted September 14, 2018 can you try this code class Boot extends Phaser.Scene { constructor (globalObject) { super({key: 'Boot', pack: { files: [{ type: 'image', key: 'logo', url: 'games/magicd/assets/common/logosetstudio.jpg', extension: 'jpg' }] }, }); } Link to comment Share on other sites More sharing options...
rich Posted September 14, 2018 Share Posted September 14, 2018 There's no 'pack' object in your Settings output, but you have a 'files' object, which means you're using a really old version of Phaser 3, likely 3.6.0 or earlier, which is why this doesn't work. You need 3.8.0 or above to use the pack loader config option. Double, triple-check which version of Phaser is being used in the laravel bundled version, because it's super out of date. Link to comment Share on other sites More sharing options...
giorg Posted September 14, 2018 Author Share Posted September 14, 2018 rich thanks a lot!!! I did replace my phaser with the latest "silica", and it works like a charm!! thanks again Link to comment Share on other sites More sharing options...
rich Posted September 14, 2018 Share Posted September 14, 2018 ? Link to comment Share on other sites More sharing options...
Recommended Posts