Add sound, see #2

Convert the sounds to ogg (just ogg and mo3 is supported by Inpact)
and play it on the events.
This commit is contained in:
Aaron Mueller 2012-06-27 22:53:55 +02:00
parent a9ab110611
commit a40f9d600a
15 changed files with 16 additions and 1 deletions

View file

@ -6,6 +6,13 @@ ig.module(
)
.defines(function(){
EntityBall = ig.Entity.extend({
hitSounds: [
new ig.Sound('media/sounds/hit1.ogg'),
new ig.Sound('media/sounds/hit2.ogg'),
new ig.Sound('media/sounds/hit3.ogg'),
new ig.Sound('media/sounds/hit4.ogg'),
],
wallSound: new ig.Sound('media/sounds/wall.ogg'),
name: 'ball',
size: {x: 24, y: 24},
collides: ig.Entity.COLLIDES.ACTIVE,
@ -33,9 +40,16 @@ ig.module(
// the paddles y movement is added to the ball,
// so that players can give the ball a spin
this.vel.y += other.vel.y/2;
this.hitSounds[Math.floor(Math.random()*4)].play();
}
},
handleMovementTrace: function(res) {
if (res.collision.y) this.wallSound.play();
this.parent(res);
},
reset: function() {
this.randomVel();
this.pos.x = this.startPos.x;

View file

@ -6,6 +6,7 @@ ig.module(
)
.defines(function(){
EntityGoal = ig.Entity.extend({
looseSound: new ig.Sound('media/sounds/loose.ogg'),
height: 90,
size: {x:48, y:48},
checkAgainst: ig.Entity.TYPE.B,
@ -18,6 +19,7 @@ ig.module(
if (other.name == 'ball') {
ig.game.score[this.owner] -= 1;
other.reset();
this.looseSound.play();
}
}
});

View file

@ -21,7 +21,6 @@ EntityPaddle = ig.Entity.extend({
init: function( x, y, settings ) {
this.parent( x, y, settings );
this.addAnim( 'idle', 1, [0] );
}

BIN
dev/media/sounds/hit1.ogg Normal file

Binary file not shown.

Binary file not shown.

BIN
dev/media/sounds/hit2.ogg Normal file

Binary file not shown.

Binary file not shown.

BIN
dev/media/sounds/hit3.ogg Normal file

Binary file not shown.

Binary file not shown.

BIN
dev/media/sounds/hit4.ogg Normal file

Binary file not shown.

Binary file not shown.

BIN
dev/media/sounds/loose.ogg Normal file

Binary file not shown.

Binary file not shown.

BIN
dev/media/sounds/wall.ogg Normal file

Binary file not shown.

Binary file not shown.