Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint

Modules

Impact’s source code is organized into modules. Since JavaScript itself does not have an include() function that can load other JavaScript source files into an object, Impact has its own system. A module typically looks like this:

1    ig.module(
2        'game.my-file'
3    )
4    .requires(
5        'impact.game',
6        'impact.image',
7        'game.other-file'
8    )
9    .defines(function(){
10        // code for this module
11    });

The first block defines the module name 'game.my-file', which directly corresponds to the file name. Modules and their dependencies typically reside in the lib/ folder of your Impact project directory, and subdirectories are included in a path to these files using object-model dot syntax. Therefore, the my-file.js file sits in the lib/game/my-file.js.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial