UNPKG

phaser3-rex-plugins

Version:
2 lines (1 loc) 4.52 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).rexparticlesalongboundsplugin=t();}(undefined,(function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,(o=n.key,i=void 0,"symbol"==typeof(i=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return ("string"===t?String:Number)(e)}(o,"string"))?i:String(i)),n);}var o,i;}function t(e){return t=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},t(e)}function r(e,t){return r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},r(e,t)}function n(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function o(e){var r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return !1;if(Reflect.construct.sham)return !1;if("function"==typeof Proxy)return !0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return !1}}();return function(){var o,i=t(e);if(r){var a=t(this).constructor;o=Reflect.construct(i,arguments,a);}else o=i.apply(this,arguments);return n(this,o)}}var i,a,c,u=Phaser.Utils.Objects.GetValue,s=Phaser.Geom.Rectangle,f=Phaser.Utils.Objects.GetValue,l=function(e,t){void 0===i&&(i=new s),a=function(e,t){return void 0===e&&(e=0),void 0===t&&(t={}),"number"==typeof e?(t.left=e,t.right=e,t.top=e,t.bottom=e):(t.left=u(e,"left",0),t.right=u(e,"right",0),t.top=u(e,"top",0),t.bottom=u(e,"bottom",0)),t}(f(t,"padding",0),a);var r=e.width,n=e.height,o=-r/2-a.left,c=-n/2-a.top;r+=a.left+a.right,n+=a.top+a.bottom,i.setTo(o,c,r,n);var l=f(t,"stepRate",10);return i.getPoints(0,l)},p=Phaser.Utils.Objects.GetValue,d=1e3/60,y=Phaser.GameObjects.Particles.ParticleEmitter.prototype.preUpdate,v=Phaser.Utils.Objects.GetValue,h=Phaser.Math.Vector2,b=function(e){void 0===c&&(c={x:0,y:0}),e.getCenter(c),this.setPosition(c.x,c.y).setScale(e.scaleX,e.scaleY).setAngle(e.angle).setAlpha(e.alpha),this.depth!==e.depth&&this.setDepth(e.depth);},g=function(e,t){void 0===t&&(t={});var r=function(e,t){var r=l(e,t),n={blendMode:p(t,"blendMode","ADD"),emitZone:{type:"edge",source:{getPoints:function(){return r}},yoyo:p(t,"yoyo",!1)},speed:p(t,"spread",10)},o=p(t,"lifespan",1e3);n.lifespan=o;var i=p(t,"duration",void 0);if(void 0!==i){var a=i-o;if(a<=0)n.quantity=r.length;else {var c=a/r.length;c<=d?n.quantity=Math.ceil(d/c):n.frequency=c;}}var u=(1+p(t,"repeat",0))*r.length;n.hasOwnProperty("frequency")?n.emitCallback=function(e,t){(u-=1)<=0&&t.stop();}:n.stopAfter=u;var s=p(t,"textureFrames",void 0);s&&(n.frame={frames:s,cycle:p(t,"textureFrameCycle",!0)});var f=p(t,"scale",void 0);void 0!==f&&(n.scale=f);var y=p(t,"alpha",void 0);void 0!==y&&(n.alpha=y);var v=p(t,"tint",void 0);return void 0!==v&&(n.tint=v),n}(e,t),n=e.scene.add.particles(0,0,t.textureKey,r);return function(e,t,r){var n=v(r,"gravityX",0),o=v(r,"gravityY",0),i=0!==n||0!==o;e.preUpdate=function(r,a,c){if(t.scene){if(b.call(e,t),i){var u,s;if(0!==t.rotation){var f=new h;f.setTo(n,o).rotate(-t.rotation),u=f.x,s=f.y;}else u=n,s=o;e.setParticleGravity(u,s);}y.call(e,r,a,c);}else this.destroy();}.bind(e);}(n,e,t),n.once("complete",(function(){n.destroy();})),n};return function(t){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&r(e,t);}(u,Phaser.Plugins.BasePlugin);var n,i,c=o(u);function u(e){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,u),c.call(this,e)}return n=u,(i=[{key:"start",value:function(){this.game.events.on("destroy",this.destroy,this);}},{key:"startEffect",value:function(e,t){return g(e,t)}}])&&e(n.prototype,i),Object.defineProperty(n,"prototype",{writable:!1}),u}()}));