Author: Not specified Language: javascript
Description: Not specified Timestamp: 2013-06-06 02:52:42 +0000
View raw paste Reply
  1. ig.module(
  2.   // The name of the module which is the relative path of this Javascript file.
  3.   // For example:
  4.   'games.games'
  5.   // It means this module is located at lib/games/games.js.
  6. )
  7. .requires(
  8.   // The modules that are required by this module. For example:
  9.   'impact.game',
  10.   'plugins.touch-button'
  11. )
  12. .define(function() {
  13.   // The actual Javascript object is defined here.
  14.   // For example: ig.games is the root game type which inherits ig.Game class.
  15.   ig.games = ig.Game.extend({
  16.  
  17.     // Image and sound files defined here will be preloaded by ImpactJS framework when the game starts.
  18.     // For example:
  19.     backgroundImg: new ig.Image('media/common/img/background.jpg'),
  20.     mainTheme: new ig.Sound('media/slot/common/snd/background.*', false ),
  21.  
  22.     // This module is a ImpactJS game instance since it inherits ig.Game.
  23.     // When this game starts it'll first preload resources and then run init().
  24.     init: function() {
  25.       // Place initialization logic here.
  26.     },
  27.  
  28.     // This method is called for each frame and updates all entities, BackgroundMaps and tileset animations.
  29.     update: function() {
  30.       // From http://impactjs.com/documentation/class-reference/class#this-parent:
  31.       // Inside a method, this.parent always refers to the method with the same name of the super class - if present. I.e. when overwriting a method of a super class, you can still call it from within the sub classes method with this.parent().
  32.       this.parent();
  33.     },
  34.  
  35.     // This method is called for each frame and draws all BackgroundMaps and entities.
  36.     // The sequence of the drawing call defines the layer hierarchy.
  37.     draw: function() {
  38.       // Calling this.parent() draws all BackgroundMaps and entities of this game.
  39.       this.parent();
  40.       // Place drawSomething() here will draw on top of all BackgroundMaps and entities.
  41.       drawSomething();
  42.     },
  43.  
  44.     // Custom functions
  45.     drawSomething: function() {
  46.  
  47.     }
  48.  
  49.   });
  50.  
  51. });
View raw paste Reply