Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to mark a scene as a preload scene #53

Closed
ItsGravix opened this issue Jul 4, 2020 · 7 comments
Closed

Option to mark a scene as a preload scene #53

ItsGravix opened this issue Jul 4, 2020 · 7 comments

Comments

@ItsGravix
Copy link

It would be great if there was a checkbox to mark a scene as "Preload", which will move the generated sprite code over to the specified preload method instead of the create method. Currently, I have to manually write code to display sprites in my preload scene.

@PhaserEditor2D
Copy link
Owner

Please, can you write some code examples? I don't get what's your proposition.

@ItsGravix
Copy link
Author

ItsGravix commented Jul 5, 2020

My proposition is to bring back this feature from Phaser Editor v1. Enabling a scene as a preloader will make it so all the sprites are created in the preload method.

preload() {
    this.add.sprite(0, 0, "phaser", "loading_dino");
}

https://help.phasereditor2d.com/v1/canvas.html?highlight=preload#preloader-state-configuration

@PhaserEditor2D
Copy link
Owner

You can do that!

Look in the Compiler Scene Settings you can change the name of the method to preload the assets and create the objects. So, you can say the editor to generate a _preload method and a _create method, then, you can write your scene like this:

class Level extends Phaser.Scene {
	
	_preload() {
		// generated by the compiler

		this.load.pack(...)
	}

	_create() {
		// generated by the compiler

		this.add.image(...)
	}

	// start user code

	preload() {
		this._create();
		this._preload();
	}

	// end user code
}

@PhaserEditor2D
Copy link
Owner

BTW, I just fixed an issue with the dialog to select the asset pack files to preload. I think I will do a point release with this fix. In the meantime, you can test it following these steps.

@PhaserEditor2D
Copy link
Owner

Hi @ItsGravix

Is it find the solution I pointed in previous comments?

@ItsGravix
Copy link
Author

@PhaserEditor2D Yes that solution works fine!

@PhaserEditor2D
Copy link
Owner

Great, I am closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants