Skip to content
happygiraffe edited this page Sep 8, 2011 · 9 revisions
jj.createCreature('creature', function (creature) {
  'use strict';                                                                 

  // the div element for the creature.
  var element = creature.el;                                                    

  // Set the size of your creature.
  creature.size({width: 50, height: 50});                                       

  // Set/Get the size of the creature.
  creature.size() // {width: 50, height: 50}
  // Set/Get the position of the creature.
  creature.position() // {top: 50, left: 50, zIndex: 0}
  // Set/Get any metadata.
  creature.data({hello: 'world'});                                              

  // Trigger an event on your creature.
  creature.trigger('myevent');                                                  

  // Bind to the touch event to be notified about collisions with other creatures.
  creature.bind('touch', function(touchedCreature) {

  });                                                                           

  // Get a read only version of another creature.
  var prem = jj.get('prem');                                                    

  // Bind an event on Prems creature.
  prem.bind('prems event');                                                     

  // Returns read-only copies of all creatures.
  jj.all()

  // Trigger a global event.
  jj.trigger('hello');                                                          

  // Bind to a global event.
  jj.bind('tick', function (frame) {
    // Animate here.
  });                                                                           

  jj.bind('time', function (hours, seconds) {

  });                                                                           
});                                                                             
Clone this wiki locally