Skip to content

Commit

Permalink
Animated load screen
Browse files Browse the repository at this point in the history
  • Loading branch information
metalx1000 committed Jun 21, 2015
1 parent b04de58 commit 041f61c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
7 changes: 6 additions & 1 deletion js/hud.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ function preload_hud(){
game.load.image('player_death','res/images/hud_player_death.png');
game.load.image('kill_bonus','res/images/hud_kill_bonus.png');
game.load.image('excellent','res/images/hud_excellent.png');
game.load.image('loading','res/images/hud_loading.png');

game.load.spritesheet('loading', 'res/sprites/hud_loading.png', 446, 81);
}

function create_hud(){
Expand All @@ -23,13 +24,17 @@ function update_hud(){
function message(msg,timeout){
//if timeout not set, default to 3 seconds
if(typeof timeout === 'undefined'){timeout = 3000}
if(typeof animation === 'undefined'){animation = false}
//destroy any exisiting messages
destroy_messages();

//display new message
msg = msgs.create(game.width/2,game.height/2,msg);
msg.anchor.setTo(.5,.5);

//if animation is true then animate it
msg.animations.add('ani');
msg.animations.play('ani', 3, true)
//set timeout for msg
msg.timeout = game.time.now + timeout;
}
Expand Down
3 changes: 2 additions & 1 deletion js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ function update(){
update_enemy();
update_weapons();
update_hud();
}else{
}else if(typeof load_msg === 'undefined'){
load_msg = true;
message('loading',100);
}
}
Expand Down
Binary file added res/sprites/hud_loading.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 041f61c

Please sign in to comment.