49 lines
1.1 KiB
JavaScript
49 lines
1.1 KiB
JavaScript
|
if (!this.entityLoaded) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (!this.initialized) {
|
||
|
/**
|
||
|
* Link some objects for MouseDown component
|
||
|
*/
|
||
|
this.throwerParticleEngine = this.entityLoaded.throwerParticleEngine;
|
||
|
this.beforeRender = this.entityLoaded.beforeRender;
|
||
|
this.mouseMove = this.entityLoaded.mouseMove;
|
||
|
|
||
|
if (this.subscription) {
|
||
|
this.subscription.remove();
|
||
|
this.subscription = null;
|
||
|
}
|
||
|
|
||
|
this.subscription = GameLib.Event.Subscribe(
|
||
|
GameLib.Event.AUDIO_ENDED,
|
||
|
function(data) {
|
||
|
if (data.audio.name === 'Audio - Flamethrower') {
|
||
|
if (!data.audio.paused) {
|
||
|
GameLib.Event.Emit(GameLib.Event.MOUSE_UP);
|
||
|
}
|
||
|
}
|
||
|
}.bind(this)
|
||
|
);
|
||
|
|
||
|
this.initialized = true;
|
||
|
}
|
||
|
|
||
|
this.beforeRender.mouseIsDown = true;
|
||
|
this.mouseMove.mouseIsDown = true;
|
||
|
|
||
|
this.throwerParticleEngine.enabled = true;
|
||
|
this.throwerParticleEngine.particlesPerSecond = 50;
|
||
|
this.throwerParticleEngine.updateInstance('particlesPerSecond');
|
||
|
this.throwerParticleEngine.templateParticle.speed = 300;
|
||
|
this.throwerParticleEngine.templateParticle.scale.x = 15;
|
||
|
|
||
|
GameLib.Event.Emit(
|
||
|
GameLib.Event.PLAY_AUDIO,
|
||
|
{
|
||
|
name : 'Audio - Flamethrower'
|
||
|
}
|
||
|
);
|
||
|
|
||
|
return null;
|
||
|
//@ sourceURL=mouseDown.js
|