Fixed the States examples to reflect the new module name.

This commit is contained in:
Richard Davey 2013-04-19 09:23:36 +01:00
parent 8da04760ae
commit d5229c558a
8 changed files with 17 additions and 105 deletions

View file

@ -31,6 +31,10 @@ module Phaser {
document.body.appendChild(this.canvas);
}
// Consume default actions on the canvas
this.canvas.style.msTouchAction = 'none';
this.canvas.style['touch-action'] = 'none';
this.context = this.canvas.getContext('2d');
this.offset = this.getOffset(this.canvas);

View file

@ -96,6 +96,10 @@
<TypeScriptCompile Include="sprites\dynamic texture 1.ts" />
</ItemGroup>
<ItemGroup>
<TypeScriptCompile Include="misc\screen grab.ts" />
<Content Include="misc\screen grab.js">
<DependentUpon>screen grab.ts</DependentUpon>
</Content>
<Content Include="tweens\bounce.js">
<DependentUpon>bounce.ts</DependentUpon>
</Content>

View file

@ -16,7 +16,7 @@
<script type="text/javascript">
var myGame = new Game(this, 'game', 840, 400);
var myGame = new Phaser.Game(this, 'game', 840, 400);
myGame.switchState(MainMenu);

View file

@ -1,44 +0,0 @@
var __extends = this.__extends || function (d, b) {
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
/// <reference path="../../../Kiwi Lite/Game.ts" />
/// <reference path="../../../Kiwi Lite/State.ts" />
var FakeGame = (function (_super) {
__extends(FakeGame, _super);
function FakeGame(game) {
_super.call(this, game);
}
FakeGame.prototype.init = function () {
this.loader.addImageFile('track', '../../assets/games/f1/track.png');
this.loader.addImageFile('car', '../../assets/games/f1/car1.png');
this.loader.load();
};
FakeGame.prototype.create = function () {
this.camera.setBounds(0, 0, this.stage.width, this.stage.height);
this.createSprite(0, 0, 'track');
this.car = this.game.createSprite(180, 298, 'car');
this.car.rotation = 180;
this.car.maxVelocity.setTo(150, 150);
this.bigCam = this.createCamera(640, 0, 100, 200);
this.bigCam.follow(this.car, Camera.STYLE_LOCKON);
this.bigCam.setBounds(0, 0, this.stage.width, this.stage.height);
this.bigCam.showBorder = true;
this.bigCam.borderColor = 'rgb(0,0,0)';
this.bigCam.scale.setTo(2, 2);
};
FakeGame.prototype.update = function () {
if(this.input.keyboard.isDown(Keyboard.LEFT)) {
this.car.rotation -= 4;
} else if(this.input.keyboard.isDown(Keyboard.RIGHT)) {
this.car.rotation += 4;
}
if(this.game.input.keyboard.isDown(Keyboard.UP)) {
this.car.velocity.copyFrom(this.math.velocityFromAngle(this.car.angle, 150));
} else {
this.car.velocity.copyFrom(this.math.velocityFromAngle(this.car.angle, 60));
}
};
return FakeGame;
})(State);

View file

@ -1,5 +1,5 @@
/// <reference path="../../../Kiwi Lite/Game.ts" />
/// <reference path="../../../Kiwi Lite/State.ts" />
/// <reference path="../../../Phaser/Game.ts" />
/// <reference path="../../../Phaser/State.ts" />
class FakeGame extends State {
@ -9,8 +9,8 @@ class FakeGame extends State {
}
private car: Sprite;
private bigCam: Camera;
private car: Phaser.Sprite;
private bigCam: Phaser.Camera;
public init() {

View file

@ -1,52 +0,0 @@
var __extends = this.__extends || function (d, b) {
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
/// <reference path="../../../Kiwi Lite/Game.ts" />
/// <reference path="../../../Kiwi Lite/State.ts" />
/// <reference path="FakeGame.ts" />
var MainMenu = (function (_super) {
__extends(MainMenu, _super);
function MainMenu(game) {
_super.call(this, game);
this.isFalling = false;
this.hasClicked = false;
}
MainMenu.prototype.init = function () {
this.loader.addImageFile('car', '../../assets/pics/supercars_parsec.png');
this.loader.addSpriteSheet('monster', '../../assets/sprites/metalslug_monster39x40.png', 39, 40);
this.loader.load();
};
MainMenu.prototype.create = function () {
this.camera.backgroundColor = 'rgb(85,85,85)';
this.createSprite(80, 150, 'car');
this.monster = this.game.createSprite(80, 60, 'monster');
this.monster.animations.add('walk');
this.monster.animations.play('walk', 30, true);
this.monster.velocity.x = 50;
};
MainMenu.prototype.update = function () {
if(this.monster.x >= 710 && this.isFalling == false) {
this.isFalling = true;
this.monster.velocity.x = 20;
this.monster.acceleration.y = 200;
this.monster.angularAcceleration = 100;
this.monster.animations.stop('walk');
}
if(this.input.mouse.isDown && this.hasClicked == false) {
this.hasClicked = true;
this.game.switchState(FakeGame);
}
};
MainMenu.prototype.render = function () {
this.stage.context.fillStyle = 'rgb(0,0,0)';
this.stage.context.font = 'bold 48px Arial';
this.stage.context.textAlign = 'center';
this.stage.context.fillText('Super Racer', this.stage.centerX, 60);
this.stage.context.font = 'bold 22px Arial';
this.stage.context.textAlign = 'center';
this.stage.context.fillText('Click to "Play"', this.stage.centerX, 370);
};
return MainMenu;
})(State);

View file

@ -1,5 +1,5 @@
/// <reference path="../../../Kiwi Lite/Game.ts" />
/// <reference path="../../../Kiwi Lite/State.ts" />
/// <reference path="../../../Phaser/Game.ts" />
/// <reference path="../../../Phaser/State.ts" />
/// <reference path="FakeGame.ts" />
class MainMenu extends State {
@ -10,7 +10,7 @@ class MainMenu extends State {
}
private monster: Sprite;
private monster: Phaser.Sprite;
private isFalling: bool = false;
private hasClicked: bool = false;

View file

@ -16,7 +16,7 @@
<script type="text/javascript">
var myGame = new Game(this, 'game', 840, 400);
var myGame = new Phaser.Game(this, 'game', 840, 400);
myGame.switchState(MainMenu);