2013-04-18 13:16:18 +00:00
|
|
|
/// <reference path="../../Phaser/Phaser.ts" />
|
2013-04-12 16:19:56 +00:00
|
|
|
|
|
|
|
(function () {
|
|
|
|
|
2013-04-18 13:16:18 +00:00
|
|
|
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
2013-04-12 16:19:56 +00:00
|
|
|
|
|
|
|
function init() {
|
|
|
|
|
|
|
|
myGame.loader.addSpriteSheet('mummy', 'assets/sprites/metalslug_mummy37x45.png', 37, 45, 18);
|
|
|
|
//myGame.loader.addSpriteSheet('coin', 'assets/sprites/coin.png', 32, 32);
|
|
|
|
myGame.loader.addSpriteSheet('monster', 'assets/sprites/metalslug_monster39x40.png', 39, 40);
|
|
|
|
|
|
|
|
myGame.loader.load();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-04-18 13:16:18 +00:00
|
|
|
var car: Phaser.Sprite;
|
2013-04-12 16:19:56 +00:00
|
|
|
|
|
|
|
function create() {
|
|
|
|
|
|
|
|
car = myGame.createSprite(200, 300, 'monster');
|
|
|
|
|
|
|
|
car.animations.add('spin', null, 30, true);
|
|
|
|
|
|
|
|
//car.animations.play('spin', 30, true);
|
|
|
|
car.animations.play('spin');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function update() {
|
|
|
|
|
|
|
|
car.renderDebugInfo(16, 16);
|
|
|
|
|
|
|
|
car.velocity.x = 0;
|
|
|
|
car.velocity.y = 0;
|
|
|
|
car.angularVelocity = 0;
|
|
|
|
car.angularAcceleration = 0;
|
|
|
|
|
2013-04-18 13:16:18 +00:00
|
|
|
if (myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
2013-04-12 16:19:56 +00:00
|
|
|
{
|
|
|
|
car.angularVelocity = -200;
|
|
|
|
}
|
2013-04-18 13:16:18 +00:00
|
|
|
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
2013-04-12 16:19:56 +00:00
|
|
|
{
|
|
|
|
car.angularVelocity = 200;
|
|
|
|
}
|
|
|
|
|
2013-04-18 13:16:18 +00:00
|
|
|
if (myGame.input.keyboard.isDown(Phaser.Keyboard.UP))
|
2013-04-12 16:19:56 +00:00
|
|
|
{
|
2013-04-18 13:16:18 +00:00
|
|
|
car.velocity.copyFrom(myGame.motion.velocityFromAngle(car.angle, 200));
|
2013-04-12 16:19:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})();
|