Created
April 14, 2017 20:35
-
-
Save mattroberts297/96fd2d46ba7ecff78167fcccc17dbdf1 to your computer and use it in GitHub Desktop.
Pixi tutorial step 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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