Jump to content

Loader can't load files from a local placement


NokFrt
 Share

Recommended Posts

Hi, I'm making HTML games in Phaser for a company which has a native Anroid/iOS app. They run HTML5 games in this app in a webview. They download HTML5 games from a server as a zip file, unpack them and run them locally. All Phaser 2 games work without a problem unfortunatelly a Phaser 3 game does not. The phaser 3 game is unable to load any assets. It looks like Phaser 3 loader is unable to load a file from a local placement.

For example if my scene looks like this:

export class SceneA extends Phaser.Scene {
	preload(): void {
		this.load.atlas("ATLAS", "assets/atlas0.png", "assets/atlas0.json");
	}

	create(): void {
		console.log("scene.create()");
	}

	update(): void {
	}
}

(the code is in Typescript)

The create() and update() is never reached because the loader never finish loading of atlas0.png/json.

Does anyone know about a solution for this problem? Thanks.

Link to comment
Share on other sites

Do you actually get a 404 error? Does the game run ok on a local development server? Is it even loading the scene (console.log in preload before your atlas load)?.

As far as I know a failed load will not stop a scene from progressing to the next method unless it errors out. If the loader skips the asset due to a problem it should still move on to create().

Link to comment
Share on other sites

Yes, the game works without a problem from a server. The problem is only in the native app. If I try to load a file in scene.preload() the game will never reach scene.create() and scene.update() and no error is shown in the console.

Link to comment
Share on other sites

So if you remove the file loads from the preload the game runs (albeit without image/atlas files)?  Can you debug the app in a simulated environment?  Also, can you verify that the file path where the unzipped assets are is correct?

Link to comment
Share on other sites

Yes, without loading the game works and the file path is correct. I can't debug the HTML5 game because it runs in a webview in a native Android App but I can see console output. I digged through the Phaser loader code and I found out that the XHtmlRequest calls Phaser.Loader.File.onLoad(xhr, event) with event.target.status = 0 instead of 200.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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