2013-05-29 20:39:08 +00:00
|
|
|
/// <reference path="../../Phaser/Game.ts" />
|
|
|
|
|
|
|
|
(function () {
|
|
|
|
|
2013-05-30 00:09:27 +00:00
|
|
|
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
|
2013-05-29 20:39:08 +00:00
|
|
|
|
|
|
|
function init() {
|
|
|
|
|
|
|
|
// Using Phasers asset loader we load up a PNG from the assets folder
|
2013-06-05 01:58:16 +00:00
|
|
|
game.load.image('atari', 'assets/sprites/atari800xl.png');
|
|
|
|
game.load.start();
|
2013-05-29 20:39:08 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var atari: Phaser.Sprite;
|
|
|
|
|
|
|
|
function create() {
|
|
|
|
|
2013-05-30 02:54:51 +00:00
|
|
|
atari = game.add.sprite(200, 300, 'atari');
|
2013-05-30 00:09:27 +00:00
|
|
|
atari.texture.alpha = 0.5;
|
2013-05-30 04:34:35 +00:00
|
|
|
//atari.scale.setTo(1.5, 1.5);
|
2013-05-30 00:09:27 +00:00
|
|
|
|
2013-05-30 12:25:48 +00:00
|
|
|
//atari.physics.shape.setSize(150, 50);
|
|
|
|
//atari.physics.shape.offset.setTo(50, 25);
|
2013-05-30 00:09:27 +00:00
|
|
|
|
2013-05-30 02:54:51 +00:00
|
|
|
//atari.physics.gravity.setTo(0, 2);
|
2013-05-31 17:21:32 +00:00
|
|
|
atari.body.bounce.setTo(0.7, 0.7);
|
|
|
|
atari.body.drag.setTo(10, 10);
|
2013-05-29 20:39:08 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function update() {
|
2013-05-30 00:09:27 +00:00
|
|
|
|
2013-05-31 17:21:32 +00:00
|
|
|
atari.body.acceleration.x = 0;
|
|
|
|
atari.body.acceleration.y = 0;
|
2013-05-30 00:09:27 +00:00
|
|
|
|
|
|
|
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
|
|
|
{
|
2013-05-31 17:21:32 +00:00
|
|
|
atari.body.acceleration.x = -150;
|
2013-05-30 00:09:27 +00:00
|
|
|
}
|
|
|
|
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
|
|
|
{
|
2013-05-31 17:21:32 +00:00
|
|
|
atari.body.acceleration.x = 150;
|
2013-05-30 00:09:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
|
|
|
|
{
|
2013-05-31 17:21:32 +00:00
|
|
|
atari.body.acceleration.y = -150;
|
2013-05-30 00:09:27 +00:00
|
|
|
}
|
|
|
|
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
|
|
|
|
{
|
2013-05-31 17:21:32 +00:00
|
|
|
atari.body.acceleration.y = 150;
|
2013-05-30 00:09:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function render() {
|
|
|
|
|
2013-05-31 17:21:32 +00:00
|
|
|
atari.body.renderDebugInfo(16, 16);
|
2013-06-07 06:35:28 +00:00
|
|
|
Phaser.DebugUtils.renderSpritePhysicsBody(atari);
|
2013-05-30 00:09:27 +00:00
|
|
|
|
2013-05-29 20:39:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
})();
|