Skip to content
Browse files

bounce effect added

  • Loading branch information...
1 parent 03e4858 commit e61f0e0a6382b7caa63034b0cd685b33be235184 @BlackScorp committed Mar 20, 2012
Showing with 17 additions and 5 deletions.
  1. +1 −1 assets/js/loader.js
  2. +15 −3 assets/js/player.js
  3. +1 −1 assets/js/sounds.js
View
2 assets/js/loader.js
@@ -113,7 +113,7 @@ Crafty.extend({
}else if(obj.attachEvent){
obj.attachEvent('oncanplaythrough',pro);
}else{
- obj.oncanplaythrough=pro;
+ //obj.oncanplaythrough=pro;
}
//
} else if (ext === "jpg" || ext === "jpeg" || ext === "gif" || ext === "png") {
View
18 assets/js/player.js
@@ -27,6 +27,7 @@ Crafty.c("Player",{
bars:{},
infos:{},
preparing:true,
+ bounce:false,
init:function(){
this.bars = {
hp:$('#hp'),
@@ -41,6 +42,7 @@ Crafty.c("Player",{
shield:this.bars.shield.find('.text'),
alert:$('.alert')
}
+ var stage = $('#cr-stage');
this.bars.hp.addClass('green');
this.bars.shield.addClass('green');
this.bars.heat.addClass('green');
@@ -103,6 +105,7 @@ Crafty.c("Player",{
}
}
+
})
.bind("Killed",function(points){
@@ -111,6 +114,17 @@ Crafty.c("Player",{
})
.bind("Hurt",function(dmg){
if(this.flicker) return;
+ if(this.bounce == false) {
+ this.bounce = true;
+ var t = this;
+ stage.effect('bounce',{},100,function(){
+ $(this).css({
+ 'left':'50%',
+ 'marginLeft':'-300px'
+ });
+ t.bounce = false;
+ });
+ }
Crafty.e("Damage").attr({
x:this.x,
y:this.y
@@ -204,11 +218,9 @@ Crafty.c("Player",{
if(this.lives <= 0){
this.destroy();
this.infos.alert.show().text('Game Over!').effect('pulsate',500);
- Crafty.audio.stop("space");
- Crafty.audio.play("gameover",-1);
gameHooks.endGame(this.score);
- // Crafty.pause();
+ Crafty.pause();
}else{
this.reset();
View
2 assets/js/sounds.js
@@ -31,5 +31,5 @@ Crafty.audio.add("space",[
game_path + "media/music/through-space.ogg"
]);
-Crafty.audio.add("gameover", game_path + "media/music/ambient.ogg");
+
Crafty.audio.add("spaceship", game_path + "media/music/spaceship.mp3"); //Will work only Safari/IE

0 comments on commit e61f0e0

Please sign in to comment.
Something went wrong with that request. Please try again.