2013-06-11 20:30:15 +00:00
|
|
|
/// <reference path="../../Phaser/Game.ts" />
|
|
|
|
(function () {
|
|
|
|
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
|
|
|
|
function init() {
|
2013-06-12 18:53:48 +00:00
|
|
|
game.load.spritesheet('mummy', 'assets/sprites/metalslug_mummy37x45.png', 37, 45, 18);
|
2013-06-11 20:30:15 +00:00
|
|
|
game.load.start();
|
|
|
|
}
|
|
|
|
var sprite;
|
|
|
|
var rotate = false;
|
|
|
|
function create() {
|
|
|
|
game.stage.backgroundColor = 'rgb(0,0,0)';
|
2013-06-12 18:53:48 +00:00
|
|
|
sprite = game.add.sprite(game.stage.centerX, game.stage.centerY, 'mummy');
|
|
|
|
sprite.animations.add('walk');
|
|
|
|
sprite.animations.play('walk', 20, true);
|
|
|
|
sprite.transform.scale.setTo(4, 4);
|
2013-06-11 20:30:15 +00:00
|
|
|
game.input.onTap.add(rotateIt, this);
|
|
|
|
}
|
|
|
|
function rotateIt() {
|
|
|
|
if(rotate == false) {
|
|
|
|
rotate = true;
|
|
|
|
} else {
|
|
|
|
rotate = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function update() {
|
|
|
|
if(rotate) {
|
|
|
|
sprite.rotation++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function render() {
|
|
|
|
game.stage.context.save();
|
2013-06-12 18:53:48 +00:00
|
|
|
game.stage.context.fillStyle = 'rgb(255,0,255)';
|
|
|
|
game.stage.context.fillText('x: ' + Math.round(sprite.transform.upperLeft.x) + ' y: ' + Math.round(sprite.transform.upperLeft.y), sprite.transform.upperLeft.x, sprite.transform.upperLeft.y);
|
|
|
|
game.stage.context.fillText('x: ' + Math.round(sprite.transform.upperRight.x) + ' y: ' + Math.round(sprite.transform.upperRight.y), sprite.transform.upperRight.x, sprite.transform.upperRight.y);
|
|
|
|
game.stage.context.fillText('x: ' + Math.round(sprite.transform.bottomLeft.x) + ' y: ' + Math.round(sprite.transform.bottomLeft.y), sprite.transform.bottomLeft.x, sprite.transform.bottomLeft.y);
|
|
|
|
game.stage.context.fillText('x: ' + Math.round(sprite.transform.bottomRight.x) + ' y: ' + Math.round(sprite.transform.bottomRight.y), sprite.transform.bottomRight.x, sprite.transform.bottomRight.y);
|
|
|
|
game.stage.context.fillRect(sprite.transform.center.x, sprite.transform.center.y, 2, 2);
|
|
|
|
game.stage.context.fillRect(sprite.transform.upperLeft.x, sprite.transform.upperLeft.y, 2, 2);
|
|
|
|
game.stage.context.fillRect(sprite.transform.upperRight.x, sprite.transform.upperRight.y, 2, 2);
|
|
|
|
game.stage.context.fillRect(sprite.transform.bottomLeft.x, sprite.transform.bottomLeft.y, 2, 2);
|
|
|
|
game.stage.context.fillRect(sprite.transform.bottomRight.x, sprite.transform.bottomRight.y, 2, 2);
|
|
|
|
game.stage.context.strokeStyle = 'rgb(255,255,0)';
|
|
|
|
game.stage.context.strokeRect(sprite.cameraView.x, sprite.cameraView.y, sprite.cameraView.width, sprite.cameraView.height);
|
2013-06-11 20:30:15 +00:00
|
|
|
game.stage.context.restore();
|
|
|
|
}
|
|
|
|
})();
|