Jump to content

Rendering Images - Preload / Create?


megmut
 Share

Recommended Posts

Hey guys, just a quick question.. is there any reason to take preference to drawing images in the create function over the preload function?

I am aware of the order in which the init, create, preload and update loop are fired, just curious to see what other pahser dev's have made general good practice or if I'm wrong and there is a very good reason to do one, over the other!

 

Just for clarification.. I'm talking about..

preload: function() {    this.object = this.add.image(x,y,name);}

as opposed to..

create: function() {    this.object = this.add.image(x,y,name);}

Thanks!

Link to comment
Share on other sites

As long as the image actually exists and has been loaded in a previous State then there is no technical reason why it can't be instantiated inside the 'preload' method.

 

Providing you'll never need to share your code with anyone else (or post it to this forum for help) and you're happy living in a topsy turvy world where you make all your objects in a preload method, then it won't cause any harm to do so. I wouldn't call it 'bad' practise, that seems a little harsh. But it is a very strange way to do it.

Link to comment
Share on other sites

As long as the image actually exists and has been loaded in a previous State then there is no technical reason why it can't be instantiated inside the 'preload' method.

 

Providing you'll never need to share your code with anyone else (or post it to this forum for help) and you're happy living in a topsy turvy world where you make all your objects in a preload method, then it won't cause any harm to do so. I wouldn't call it 'bad' practise, that seems a little harsh. But it is a very strange way to do it.

 

You always reply to posts like these, but I have a half a dozen posts with serious technical questions about Phaser and they constantly go ignored. I'm struggling trying to use Phaser in professional projects and seeing this pattern is frustrating. Is there something I can do to get better support, or are my posts not well timed?

Link to comment
Share on other sites

If I have to approve the post for moderation (like the above was) then I'll often add a quick reply after it. If the post just appears on the forum and doesn't require moderation then yes, it's entirely down to luck if I see it or not when browsing the forum that day.

 

I'm often on the Slack channel though, as are lots of other devs, which is a good place to ask quick questions. If they require lots of debugging of your code then even on Slack I'm likely to be unable to help (otherwise I'd never get anything done).

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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