From 1a0b80a3dc48c28a8b1e0fcec15323a3543d94ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ruben=20M=C3=BCller?= Date: Thu, 18 Apr 2013 21:36:49 +0200 Subject: [PATCH] alpha fade for the pause screen --- dev/lib/game/main.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/dev/lib/game/main.js b/dev/lib/game/main.js index 23b414a..a2e77b1 100755 --- a/dev/lib/game/main.js +++ b/dev/lib/game/main.js @@ -15,7 +15,9 @@ .defines(function(){ RunningGame = ig.Game.extend({ font: new ig.Font( 'media/04b03.font.png' ), - pauseDialog: new ig.Image('media/pause_screen.png'), + pauseDialogAlpha: 0, + pauseDialog: new ig.AnimationSheet( 'media/pause_screen.png', 624, 384 ), + pauseDialogAnim: null, showPause: false, clearColor: null, @@ -41,6 +43,9 @@ ig.input.bind(ig.KEY.W, 'up'); ig.input.bind(ig.KEY.S, 'down'); + // init graphics + this.pauseDialogAnim = new ig.Animation( this.pauseDialog, 0, [0] ) + // Load the level this.loadLevel(LevelLevel1); }, @@ -55,6 +60,7 @@ if (ig.input.pressed('enter')) { this.showPause = false; + this.pauseDialogAlpha = 0; return; } } @@ -80,7 +86,15 @@ this.font.draw(ig.global.score.human, 350, 25, ig.Font.ALIGN.CENTER); if (this.showPause) { - this.pauseDialog.draw(0, 0); + if(this.pauseDialogAlpha < 1) { + this.pauseDialogAlpha += .1; + if(this.pauseDialogAlpha > 1) this.pauseDialogAlpha = 1; + + console.log(this.pauseDialogAlpha); + this.pauseDialogAnim.alpha = this.pauseDialogAlpha; + } + + this.pauseDialogAnim.draw(0, 0); } } });