Skip to content

Instantly share code, notes, and snippets.

@mattroberts297
Created April 14, 2017 20:35
Show Gist options
  • Save mattroberts297/96fd2d46ba7ecff78167fcccc17dbdf1 to your computer and use it in GitHub Desktop.
Save mattroberts297/96fd2d46ba7ecff78167fcccc17dbdf1 to your computer and use it in GitHub Desktop.
Pixi tutorial step 1
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Hello World</title>
</head>
<body>
<script src="node_modules/pixi.js/dist/pixi.min.js"></script>
<script src="index.js"></script>
</body>
</html>
var stage = new PIXI.Container(),
renderer = PIXI.autoDetectRenderer(800, 600);
document.body.appendChild(renderer.view);
//Use Pixi's built-in `loader` object to load an image
PIXI.loader
.add("ship.png")
.load(setup);
//This `setup` function will run when the image has loaded
function setup() {
//Create the `ship` sprite from the texture
var ship = new PIXI.Sprite(
PIXI.loader.resources["ship.png"].texture
);
//Add the ship to the stage
stage.addChild(ship);
//Render the stage
renderer.render(stage);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment