Update cat.js

hook into isPlaying for sounds
This commit is contained in:
James B. Pollack 2015-10-01 18:34:22 -07:00
parent 3565d96ffb
commit 6cc2df9052

View file

@ -21,29 +21,36 @@
Cat.prototype = { Cat.prototype = {
isMeowing:false, isMeowing:false,
this.injector:null,
startTouch: function() { startTouch: function() {
var _ t=this; var _ t=this;
if(this.isMeowing!==true){ if(this.isMeowing!==true){
this.meow(); this.meow();
this.isMeowing=true; this.isMeowing=true;
Script.setTimeout(function(){
_t.isMeowing=false;
},2000)
} }
}, },
update:function(){
if(this.injector!==null){
this.isMeowing = this.injector.isPlaying;
}
if(this.isMeowing===false){
this.injector=null
}
}
meow: function() { meow: function() {
this.injector = Audio.playSound(this.meowSound, {
Audio.playSound(this.meowSound, {
position: this.position, position: this.position,
volume: .1 volume: 0.1
}); });
}, },
preload: function(entityID) { preload: function(entityID) {
this.entityID = entityID; this.entityID = entityID;
this.position = Entities.getEntityProperties(this.entityID, "position").position; this.position = Entities.getEntityProperties(this.entityID, "position").position;
Script.update.connect(this.update);
}, },
unload: function() { unload: function() {