1
votes

I'm trying to figure out how to load fonts in to a phaser scene from local assets or google fonts.

In my game, I load all the assets in the first scene(Preload scene) and I don't want to load anything in my other scene's preload function.

The problem is I have multiple scenes in my game and fonts that are loaded in the first scene but not available in the other scenes.

I tried the webfontloader plugin and also the below example in phaser labs.

How can I load fonts in my Preload Scene and use them in all the other scenes?

Thanks.

1
Have you looked at html5gamedevs.com/topic/38499-custom-font . Might you be starting your other scenes before the loading is complete.Harry Scheuerle
@HarryScheuerle I think the webfontloader plugin handles that automatically. I'll try that manually also. Thanks for your comment.tharindu_DG

1 Answers

0
votes

If you want pass the value from preload scene to other scene.

I recommend using object to save it.

This is how I pass the value to next scene.

let instance:globalParameter
class globalParameter {
    get gameData(): any {
        return this._gameData;
    }

    set gameData(value: any) {
        this._gameData = value;
    }
    private _gameData:any;

    constructor() {
    }
}

export default new globalParameter()