alpha fade for the pause screen

This commit is contained in:
Ruben Müller 2013-04-18 21:36:49 +02:00
parent 6a8c1727f9
commit 1a0b80a3dc

View file

@ -15,7 +15,9 @@
.defines(function(){ .defines(function(){
RunningGame = ig.Game.extend({ RunningGame = ig.Game.extend({
font: new ig.Font( 'media/04b03.font.png' ), 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, showPause: false,
clearColor: null, clearColor: null,
@ -41,6 +43,9 @@
ig.input.bind(ig.KEY.W, 'up'); ig.input.bind(ig.KEY.W, 'up');
ig.input.bind(ig.KEY.S, 'down'); ig.input.bind(ig.KEY.S, 'down');
// init graphics
this.pauseDialogAnim = new ig.Animation( this.pauseDialog, 0, [0] )
// Load the level // Load the level
this.loadLevel(LevelLevel1); this.loadLevel(LevelLevel1);
}, },
@ -55,6 +60,7 @@
if (ig.input.pressed('enter')) { if (ig.input.pressed('enter')) {
this.showPause = false; this.showPause = false;
this.pauseDialogAlpha = 0;
return; return;
} }
} }
@ -80,7 +86,15 @@
this.font.draw(ig.global.score.human, 350, 25, ig.Font.ALIGN.CENTER); this.font.draw(ig.global.score.human, 350, 25, ig.Font.ALIGN.CENTER);
if (this.showPause) { 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);
} }
} }
}); });