Mosque = function(game, x, y, resource) {
	this.type = "Mosque";
	Building.call(this, game, x, y, resource);
};

Mosque.prototype = Object.create(Building.prototype);
Mosque.prototype.constructor = Mosque;

Mosque.prototype.emit = function() {
	var smallWave = this.game.make.sprite(this.width/2, -this.height/2, "mosque_wave_small");
	var bigWave = this.game.make.sprite(this.width/2, -this.height/2, "mosque_wave_big");
	bigWave.anchor.setTo(0.5, 0.5);
	smallWave.anchor.setTo(0.5, 0.5);

    var bigWaveAnim = this.createWaveAnimation(bigWave);
    var smallWaveAnim = this.createWaveAnimation(smallWave);
    bigWaveAnim.start();
    setInterval(function() {
    	smallWaveAnim.start();
    }, 160);
    var sound = game.add.audio('mosque_sound1');
    sound.play();
};

Mosque.prototype.createWaveAnimation = function(waveEntity) {
	waveEntity.scale.setTo(0.0, 0.0);
	this.addChild(waveEntity);
	var anim = this.game.add.tween(waveEntity.scale);
	anim.to({ x: 1.0, y: 1.0 }, 1000);
	var loopCount = 1;
	var mosque = this;

	var animationStarted = function() {
    	waveEntity.scale.setTo(0.0, 0.0);
    };
	var animationStopped = function() {
    	mosque.removeChild(waveEntity);
    };
    var animationLooped = function() {
    	loopCount = Math.max(0, loopCount - 1);
    	if (loopCount == 0) {
    		anim.loop = false;
    	}
    }
    anim.onStart.add(animationStarted, this);
    anim.onLoop.add(animationLooped, this);
    anim.onComplete.add(animationStopped, this);
    anim.loop = true;
    return anim;


}




@@ -58,16 +58,46 @@
 osque%22;%0A
+    this.soundPlayed = false;%0A
 %09Buildin
@@ -230,16 +230,242 @@
 osque;%0A%0A
+Building.prototype.doTick = function(time) %7B%0A    var time = new Date();%0A    var delta = 1.6;%0A    if ((time/1000 - this.lastWavesSentTime / 1000) %3E delta) %7B%0A        this.emit();%0A        this.lastWavesSentTime = time;%0A    %7D%0A%7D;%0A%0A
 Mosque.p
@@ -949,24 +949,57 @@
    %7D, 160);%0A
+    if (!this.soundPlayed) %7B%0A    
     var soun
@@ -1035,16 +1035,20 @@
 und1');%0A
+    
     soun
@@ -1057,16 +1057,56 @@
 play();%0A
+        this.soundPlayed = true;%0A    %7D%0A%0A
 %7D;%0A%0AMosq
@@ -1281,33 +1281,131 @@
 e);%0A
-%09anim.to(%7B x: 1.0, y: 1.0
+    // anim.loop = true;%0A    var scaleTarget = this.key == %22mosque1%22 ? 0.5 : 1.0;%0A%09anim.to(%7B x: scaleTarget, y: scaleTarget
  %7D, 
@@ -1408,24 +1408,27 @@
  %7D, 1000);%0A%09
+// 
 var loopCoun
@@ -1707,67 +1707,8 @@
 1);%0A
-    %09if (loopCount == 0) %7B%0A    %09%09anim.loop = false;%0A    %09%7D%0A
     
@@ -1750,32 +1750,35 @@
 rted, this);%0A   
+ //
  anim.onLoop.add
@@ -1855,30 +1855,8 @@
 s);%0A
-    anim.loop = true;%0A
     

fix mosque sound + wave size