Jump to content

scene and paths


giorg
 Share

Recommended Posts

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

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

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

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

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

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

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

 Share

  • Recently Browsing   0 members

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