Coder Social home page Coder Social logo

addImageFile fails silently about phaser HOT 9 CLOSED

phaserjs avatar phaserjs commented on May 22, 2024
addImageFile fails silently

from phaser.

Comments (9)

BorisKozo avatar BorisKozo commented on May 22, 2024

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.

photonstorm avatar photonstorm commented on May 22, 2024

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.

BorisKozo avatar BorisKozo commented on May 22, 2024

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.

photonstorm avatar photonstorm commented on May 22, 2024

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.

BorisKozo avatar BorisKozo commented on May 22, 2024

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.

photonstorm avatar photonstorm commented on May 22, 2024

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.

BorisKozo avatar BorisKozo commented on May 22, 2024

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.

photonstorm avatar photonstorm commented on May 22, 2024

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.

BorisKozo avatar BorisKozo commented on May 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.