diff --git a/bin/install.js b/bin/install.js index 267b41d..c697845 100755 --- a/bin/install.js +++ b/bin/install.js @@ -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++; diff --git a/src/scripts/entity/preload-bar.ts b/src/scripts/entity/preload-bar.ts index 2383a1f..650c8d0 100644 --- a/src/scripts/entity/preload-bar.ts +++ b/src/scripts/entity/preload-bar.ts @@ -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); + } } -} +} \ No newline at end of file diff --git a/src/scripts/state/preloader.ts b/src/scripts/state/preloader.ts index 6636800..43e53f4 100644 --- a/src/scripts/state/preloader.ts +++ b/src/scripts/state/preloader.ts @@ -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); }