Comments (9)
Ok, it was my fault. I didn't call loader.load();
But that doesn't explain why create wasn't called. Do I have to call loader.load() for the create method to run?
from phaser.
If there is an init function then the boot process waits for loader.load to complete and then calls create. If you don't need to load anything I would remove init entirely. I've been thinking of renaming init to 'load' to make this more obvious, but I think you would have been ok if you had only had some docs to read :)
from phaser.
I am writing a simple Snake game and I am struggling since I don't understand the best practices of using the library. Is there some IRC channel I can ask questions at?
from phaser.
Actually thinking about it, create only doesn't get called if loader isn't started. I.e. you could have loads of code in init and so long as none of that adds anything to the loader then create should be called. There is no irc atm, sorry. The best (only?!) place is the forum and looking at as many of the tests as you can. 1.0 is fully documented I promise :)
from phaser.
I agree that the coupling between init and loader.load() is a little strange (and definitely not clear). I would even dare to say spahgettish :)
from phaser.
It actually helps keep your code significantly cleaner, but I am tempted to rename it to load, or maybe preload, as that is what you use it for. Then it's more obvious to leave it out if you don't need to load anything.
from phaser.
Why wouldn't the framework call loader.load() itself if it relies on that call for the correct flow to continue?
You can allow the user to cancel the call through a property (e.g. loader.cancelLoad) but still. If the loader.load() function isn't called then the application is stuck which is IMHO is very bad.
from phaser.
Because there are properties of the load function that I want devs to set themselves and can't be second guessed. It only relies on it if you've created an init method. If you don't need to load anything then it shouldn't exist.
from phaser.
I understand your point but don't you think it would be more elegant to put loader.load() here: https://github.com/photonstorm/phaser/blob/master/Phaser/Game.ts#L230
And put the two parameters you can supply to loader.load as properties of the loader itself.
So if previously I would do:
loader.load(fileLoadCallback, loadCompleteCallback) in the init method
And in my suggestion:
loader.fileLoadCallback = fileLoadCallback;
loader.loadCompleteCallback = loadCompleteCallback;
As a user of your library I think it would be much clearer that way.
This is my last comment on this, I promise :)
from phaser.
Related Issues (20)
- iOS displays autoCenter: Phaser.Scale.CENTER_BOTH in a way not consistent with results on android and on pc HOT 2
- TextStyle.setStyle mutates the given style parameter object HOT 4
- tilemap object position doesn't move if parent container moves position HOT 2
- iOS add sprite appear snowflake screen HOT 2
- Can background music be played in the background of webview? HOT 1
- Background Music (BGM) Fails to Resume After Closing Advertisements HOT 1
- [dom] error Arcade.Body size when Scale use ScaleModes.FIT HOT 1
- The Loader retries loading errored files HOT 2
- RoundPixels: true image scaling pixels off HOT 3
- Inconsistency between the documentation and the name of parameters for the Config.js file HOT 2
- ParticleEmitter `speedX` and `speedY` Not Updating After Initial Creation HOT 1
- camera follow with deadzone and high zoom no longer smooth on v3.85.0 Beta 2 HOT 2
- images with preFX jitter HOT 3
- Text with stroke + letter spacing issue HOT 1
- RenderTexture is broken in 3.85.0 beta 2 HOT 2
- leave fullscreen event fires twice HOT 1
- Pixel art per render instance HOT 1
- Pixels of atlas sprites breaks down when zoom ratio is high enough HOT 1
- Emulated touch events not being handled correctly HOT 1
- Global plugin always starts when mapping provided HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from phaser.