Skip to content
aron edited this page Sep 8, 2011 · 18 revisions

jj

This the global object (it stands for JavaScript Jungle) this is where the jungle environment is controlled. You can use it to get the size of the jungle, listen to global events or even fire your own.

jj.createCreature(name, func)

This is the main method you'll use to create new creatures. A creature is just a layer (

) in the jungle.
name - A name for your creature, it needs to be unique to the jungle.
func - A function that will be passed your creature object to work on.

Example

jj.createCreature('billy', function (creature) {
   // Give your creature a size.
   creature.size({width: 50, height: 50});
   
   // Center your creature in the world.
   var worldCenter = jj.center();
   creature.position({
     top:  worldCenter.top  - 25,
     left: worldCenter.left - 25 
   });
});

jj.size()

This grabs the size of the world and returns you an object with a width and height property {width: 1024, height: 780}.

Example

var worldSize = jj.size();
Clone this wiki locally