Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
you@paste.org web/email now available. Want one? Go here.
Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez
Obey the Epel!

Paste

Pasted as JavaScript by autemox ( 7 years ago )
ngOnInit() {
PIXI.loader
.add([
'assets/images/chicken.png', // load sprite textures (note a TON more configurations and options not shown here)
'assets/images/chick.png' // note you do not have to use array, you can chain multiple .add('myPath') together
])
.on("progress", this.loadProgressHandler)
.load(this.setup.bind(this));
}
loadProgressHandler(loader, resource) { // handles progress for loading (optional)
console.log(`loaded ${resource.url}. Loading is ${loader.progress}% complete.`);
}
setup() { // runs when textures are done loading
const bunny:Sprite = new PIXI.Sprite(
PIXI.loader.resources['assets/images/chicken.png'].texture // create a new Sprite from an image path
);
bunny.position.set(this.app.renderer.view.width / 2, this.app.screen.height / 2); // move the sprite to the center of the screen
this.app.stage.addChild(bunny); // adds the sprite to the stage
}

 

Revise this Paste

Your Name: Code Language: