Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
When using the Phaser library, do we always have to separate the loading and creating functions?
The spritesheet is loaded inside function preload() using the following function: game.load.spritesheet(arg0,arg1,arg2,arg3). After it's loaded, then we can print to the Canvas inside the addItems() function using createItem(arg0,arg1,arg2).
The spritesheet is loaded inside one function and printed to the Canvas inside a second function. Would it be possible to do this inside only ONE function.
Re: this is related to the following video:
Would it be possible to do something like this:
It seems like that would lead to messy code, which isn't good. If you have to come back to the code at a later time, or a colleague has to edit the code at a later time, you want it easy to read. This makes life (coding) easier.