// http://pixijs.github.io/examples/required/assets/basics/bunny.png
var renderer = PIXI.autoDetectRenderer( 320, 240 , {backgroundColor : 0x1099bb } );
document.body.appendChild(renderer.view);
renderer.view.id = 'demo';
console.log( renderer, PIXI );
// create the root of the scene graph
var stage = new PIXI.Container();
var container = new PIXI.Container();
stage.addChild(container);
function presetActions(bunny){
bunny.interactive = true;
bunny.on('mousedown', function(){
bunny.destroy()
});
bunny.on('touchstart', function(){
bunny.destroy()
});
};
for (var j = 0; j < 6; j++) {
for (var i = 0; i < 12; i++) {
var bunny = PIXI.Sprite.fromImage('http://pixijs.github.io/examples/required/assets/basics/bunny.png');
bunny.scale.set( 0.6,0.6);
bunny.x = 25 * i;
bunny.y = 25 * j;
presetActions(bunny);
container.addChild(bunny);
};
};
console.log( container , new PIXI.Point( 100, 100 ) );
/*
* All the bunnies are added to the container with the addChild method
* when you do this, all the bunnies become children of the container, and when a container moves,
* so do all its children.
* This gives you a lot of flexibility and makes it easier to position elements on the screen
*/
container.x = 15;
container.y = 20;
// start animating
animate();
function animate() {
requestAnimationFrame(animate);
// render the root container
renderer.render(stage);
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.