Fixed some errors in Rectangle and more Pixi hooks added, now creating the Stage properly and rendering sprites.

This commit is contained in:
Richard Davey
2013-08-29 19:20:04 +01:00
parent 19483bafed
commit 6bf7bab917
8 changed files with 137 additions and 47 deletions
+32 -5
View File
@@ -12,12 +12,14 @@
(function () {
// In this approach we're simply using functions in the current scope to do what we need
var game = new Phaser.Game(800, 600, Phaser.RENDERER_AUTO, '', { preload: preload, create: create });
// var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update });
var bunny;
function preload() {
console.log('*** preload called');
console.log('***> preload called');
game.load.image('cockpit', 'assets/pics/cockpit.png');
game.load.image('overdose', 'assets/pics/lance-overdose-loader_eye.png');
@@ -25,8 +27,33 @@
function create() {
console.log('*** create called');
document.body.appendChild(game.cache.getImage('cockpit'));
console.log('***> create called');
// Create a basetexture
var base = new PIXI.BaseTexture(game.cache.getImage('overdose'));
var texture = new PIXI.Texture(base);
bunny = new PIXI.Sprite(texture);
// center the sprites anchor point
bunny.anchor.x = 0.5;
bunny.anchor.y = 0.5;
// move the sprite t the center of the screen
bunny.position.x = 200;
bunny.position.y = 150;
game.stage._s.addChild(bunny);
}
function update() {
if (game.paused == false)
{
bunny.rotation += 0.1;
bunny.scale.x += 0.01;
bunny.scale.y += 0.01;
}
}