Skip to content
This repository has been archived by the owner on Apr 27, 2022. It is now read-only.

Commit

Permalink
Fixed missing namespace replacement
Browse files Browse the repository at this point in the history
Adding preloader
  • Loading branch information
cloakedninjas committed Dec 10, 2015
1 parent 2588bca commit fac2a0b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bin/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function updateNamespace(namespace) {
fileList.forEach(function (path) {
fs.readFile(path, function (err, data) {
data = data.toString()
.replace('module Namespace', 'module ' + namespace);
.replace('Namespace', namespace);

fs.writeFile(path, data);
rewriteCount++;
Expand Down
24 changes: 22 additions & 2 deletions src/scripts/entity/preload-bar.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
module Namespace.Entity {
export class PreloadBar {
game:Game;
width:number;
height:number;
progressBar:Phaser.BitmapData;
loaderImg:Phaser.Sprite;

constructor(game) {
this.game = game;
this.width = game.width * 0.5;
this.height = 40;

var centreX = this.width / 2;

this.progressBar = new Phaser.BitmapData(game, 'preload-bar', this.width, this.height);
this.loaderImg = game.add.sprite(game.world.centerX - centreX, (game.height * 0.9) - this.height, this.progressBar);
}

setFillPercent(percent:number) {
var ctx = this.progressBar.ctx;

}
this.progressBar.clear();
ctx.fillStyle = '#000';
ctx.strokeStyle = '#fff';
ctx.lineWidth = 1;
ctx.fillRect(0, 0, this.width, this.height);
ctx.strokeRect(0.5, 0.5, this.width - 1, this.height - 1);

ctx.fillStyle = 'green';
ctx.fillRect(1, 1, (this.width * (percent / 100)) - 2, this.height - 2);
}
}
}
}
1 change: 1 addition & 0 deletions src/scripts/state/preloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module Namespace.State {
}

create() {
this.loadingBar.setFillPercent(100);
var tween = this.game.add.tween(this.loadingBar).to({alpha: 0}, 1000, Phaser.Easing.Linear.None, true);
tween.onComplete.add(this.startGame, this);
}
Expand Down

0 comments on commit fac2a0b

Please sign in to comment.