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)
- DOM Object Visibility Incompatible with Nested Containers
- Scaling Tween on Phaser 3.70 not smooth compared to Phaser 3.60 HOT 1
- weightedPick sometimes returns undefined HOT 2
- Audio set to loop infinitely stops, when next loop triggers while switched to another tab.
- When using setOrigin() on a Phaser.GameObjects.Group each object origin is adjusted instead of setting the an origin for the group HOT 3
- Phaser3 crashes on Android (Google Chrome) when using createLayer (Tilemap) HOT 1
- Some PostFX Shaders creating a freak frame at shader activation and persistent issues on game resize for Phaser.Scale.NONE / Phaser.Scale.RESIZE HOT 2
- fx wipe example click back to menu trigger "TypeError: Cannot read properties of undefined (reading 'sys')" HOT 1
- Normal maps not working with some initial image rotation HOT 2
- Replacing old twitter logo with new icon HOT 1
- createFromTiles should take into account flip/rotation from tiled
- When providing frames with duration to anims.create(), 41.6ms is added to every frame (1 frame time @24 FPS) HOT 8
- Changing Nineslice size using setSize causes hitareas to be incorrect HOT 2
- setCrop keep position relative to GameObject HOT 1
- a problem with the bitmap text when the maxWidth is set and the last letter is space
- 2d Lights - Not going to add if lights goes added 10+ HOT 2
- Text at certain font sizes renders as a black box for render: { mipmapFilter: 'LINEAR_MIPMAP_LINEAR' } HOT 1
- Layer destroy throwing error on scene end HOT 4
- Phaser 3 Video lagging on "old" iOS versions HOT 1
- Resetting a static body should reapply the offset 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.