A plugin for the Impact javascript game engine (http://impactjs.com/). This plugin extends ig.Game and ig.Entity with functions to directly manipulate the z index.
JavaScript
Pull request Compare This branch is 15 commits ahead, 1 commit behind boneheadmed:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
README
zmagic.js

README

A plugin for the Impact javascript game engine (http://impactjs.com/). This 
plugin extends ig.Game and ig.Entity with functions to directly manipulate the 
z index. This fork is an extension of the original plugin developed by boneheadmed.
Special thanks to him for making this plugin!

How to use:
Create a new plugins folder if one does not exist: lib/plugins
Create a new folder called zmagic: lib/plugins/zmagic
Place the zmagic.js file within that folder.
Within the main.js file, require: 'plugins.zmagic.zmagic'

Usage:

1) Initialize zmagic:

Within your main game's init function:

  init: function(){
        ....
        new ig.Zmagic();
        ....
  }

2) The Entity class has had 4 new methods injected into it:

  .moveToBack()

    Moves the Entity to the beginning of the ig.game.entities array, which
    causes its .draw() to be called first. Thus, the Entity will be drawn
    before all other Entities at the back of the canvas.

  .moveToFront()

    Moves the Entity to the end of the ig.game.entities array, which
    causes its .draw() to be called last. Thus, the Entity will be drawn
    after all other Entities at the front of the canvas.

  .setzIndex( newZ )

    Takes and sets a new .zIndex for the Entity and re-inserts it in the proper
    sequence within the ig.game.entities array.

  .swapzIndex( ent )

    Takes an Entity and swaps it with the calling Entity in the ig.game.entities
    array.