mirror of
https://github.com/wassname/phaser.git
synced 2026-08-15 12:45:11 +08:00
Fixed some errors in Rectangle and more Pixi hooks added, now creating the Stage properly and rendering sprites.
This commit is contained in:
+32
-5
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user