Jump to content

Can I use require only once (in game.main)


imkost
 Share

Recommended Posts

Look at Panda's Flying Dog example https://github.com/ekelokorpi/flyingdog

Every module has it's own require:

 

game.module('game.objects').require('engine.renderer').body(function() { ... })
game.module('game.scenes').require('engine.scene').body(function() { ... })
game.module('game.main').require('game.assets', 'game.objects', 'game.scenes').body(function() { ... })
 
If you gather all requires into one module (game.main)
 
game.module('game.objects').body(function() { ... })
game.module('game.scenes').body(function() { ... })
game.module('game.main').require('game.assets', 'game.objects', 'game.scenes', 'engine.renderer', 'engine.scene').body(function() { ... })
 
then everything still works.
 
I find second method more convenient to use: you say what you want to use only once then just use it.
 
Is there any advantages of the first method over the second one? Maybe there are reasons why second method is wrong?

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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