Basic

Change editor theme :

 
1
var renderer = PIXI.autoDetectRenderer(800, 600,{backgroundColor : 0x1099bb});
2
document.body.appendChild(renderer.view);
3
4
// create the root of the scene graph
5
var stage = new PIXI.Container();
6
7
// create a texture from an image path
8
var texture = PIXI.Texture.fromImage('_assets/basics/bunny.png');
9
10
// create a new Sprite using the texture
11
var bunny = new PIXI.Sprite(texture);
12
13
// center the sprite's anchor point
14
bunny.anchor.x = 0.5;
15
bunny.anchor.y = 0.5;
16
17
// move the sprite to the center of the screen
18
bunny.position.x = 200;
19
bunny.position.y = 150;
20
21
stage.addChild(bunny);
22
23
// start animating
24
animate();
25
function animate() {
26
    requestAnimationFrame(animate);
27
28
    // just for fun, let's rotate mr rabbit a little
29
    bunny.rotation += 0.1;
30
31
    // render the container
32
    renderer.render(stage);
33
}
34
Pixi.js version : Download the example code

Would you like to create a new example ? Head over to the examples repo on GitHub