Skip to content

Instantly share code, notes, and snippets.

@whitetigle
Created December 4, 2017 15:35
Show Gist options
  • Save whitetigle/0a5780b77e914c15df99f22a9462a8ec to your computer and use it in GitHub Desktop.
Save whitetigle/0a5780b77e914c15df99f22a9462a8ec to your computer and use it in GitHub Desktop.
Basic PixiJS sample
var app = new PIXI.Application(800, 600, {backgroundColor : 0x1099bb});
document.body.appendChild(app.view);
// create a new Sprite from an image path
var bunny = PIXI.Sprite.fromImage('required/assets/basics/bunny.png')
// center the sprite's anchor point
bunny.anchor.set(0.5);
// move the sprite to the center of the screen
bunny.x = app.renderer.width / 2;
bunny.y = app.renderer.height / 2;
app.stage.addChild(bunny);
// Listen for animate update
app.ticker.add(function(delta) {
// just for fun, let's rotate mr rabbit a little
// delta is 1 if running at 100% performance
// creates frame-independent tranformation
bunny.rotation += 0.1 * delta;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment