Pixi bunny with mouse offset

by Felix Schoeler

HTML

<script src="http://www.goodboydigital.com/pixijs/examples/8/pixi.js"></script>

CSS

margin: 0;
			padding: 0;
			background-color: #000000;

JavaScript

// create an new instance of a pixi stage
	window.stage = new PIXI.Stage(0x97c56e, true);
	// create a renderer instance
	var renderer = PIXI.autoDetectRenderer(window.innerWidth, window.innerHeight, null);
	
	// add the renderer view element to the DOM
	document.body.appendChild(renderer.view);
	renderer.view.style.position = "absolute";
	renderer.view.style.top = "0px";
	renderer.view.style.left = "0px";
	requestAnimFrame( animate );
	
	// create a texture from an image path
	var texture = PIXI.Texture.fromImage("../../../../img/initializing@2x.png");
	
	for (var i=0; i < 10; i++) 
	{
		createSprite(Math.random() * window.innerWidth, Math.random() * window.innerHeight)
	};

    shuffle(window.stage.children);

function shuffle(array) {
  var currentIndex = array.length, temporaryValue, randomIndex ;

  // While there remain elements to shuffle...
  while (0 !== currentIndex) {

    // Pick a remaining element...
    randomIndex = Math.floor(Math.random() * currentIndex);
    currentIndex -= 1;

    // And swap it with the current element.
    temporaryValue = array[currentIndex];
    array[currentIndex] = array[randomIndex];
    array[randomIndex] = temporaryValue;
  }

  return array;
}
	
	
	function createSprite(x, y)
	{
		// create our little bunny friend..
		var bunny = new PIXI.Sprite(texture);
		//	bunny.width = 300;
		// enable the bunny to be interactive.. this will allow it to respond to mouse and touch events		
		bunny.interactive = true;
		// this button mode will mean the hand cursor appears when you rollover the bunny with your mouse
		bunny.buttonMode = true;
		
		// center the bunnys anchor point
		bunny.anchor.x = 0.5;
		bunny.anchor.y = 0.5;
		// make it a bit bigger, so its easier to touch
		bunny.scale.x = bunny.scale.y = 0.5;
		
		// use the mousedown and touchstart
		bunny.mousedown = bunny.touchstart = function(data)
		{
	//		data.originalEvent.preventDefault()
			// store a refference to the data
			// The reason for this is because of...