mirror of
https://github.com/photonstorm/phaser
synced 2024-12-18 09:03:29 +00:00
1 line
218 KiB
JavaScript
1 line
218 KiB
JavaScript
|
var Phaser;(function(Phaser){var Basic=(function(){function Basic(game){this.name="";this._game=game;this.ID=-1;this.exists=true;this.active=true;this.visible=true;this.alive=true;this.isGroup=false;this.ignoreDrawDebug=false}Basic.prototype.destroy=function(){};Basic.prototype.preUpdate=function(){};Basic.prototype.update=function(){};Basic.prototype.postUpdate=function(){};Basic.prototype.render=function(camera,cameraOffsetX,cameraOffsetY){};Basic.prototype.kill=function(){this.alive=false;this.exists=false};Basic.prototype.revive=function(){this.alive=true;this.exists=true};Basic.prototype.toString=function(){return""};return Basic})();Phaser.Basic=Basic})(Phaser||(Phaser={}));var Phaser;(function(Phaser){var SignalBinding=(function(){function SignalBinding(signal,listener,isOnce,listenerContext,priority){if(typeof priority==="undefined"){priority=0}this.active=true;this.params=null;this._listener=listener;this._isOnce=isOnce;this.context=listenerContext;this._signal=signal;this.priority=priority||0}SignalBinding.prototype.execute=function(paramsArr){var handlerReturn;var params;if(this.active&&!!this._listener){params=this.params?this.params.concat(paramsArr):paramsArr;handlerReturn=this._listener.apply(this.context,params);if(this._isOnce){this.detach()}}return handlerReturn};SignalBinding.prototype.detach=function(){return this.isBound()?this._signal.remove(this._listener,this.context):null};SignalBinding.prototype.isBound=function(){return(!!this._signal&&!!this._listener)};SignalBinding.prototype.isOnce=function(){return this._isOnce};SignalBinding.prototype.getListener=function(){return this._listener};SignalBinding.prototype.getSignal=function(){return this._signal};SignalBinding.prototype._destroy=function(){delete this._signal;delete this._listener;delete this.context};SignalBinding.prototype.toString=function(){return"[SignalBinding isOnce:"+this._isOnce+", isBound:"+this.isBound()+", active:"+this.active+"]"};return SignalBinding})();Phaser.SignalBinding=SignalBinding})(Phaser||(Phaser={}));var Phaser;(function(Phaser){var Signal=(function(){function Signal(){this._bindings=[];this._prevParams=null;this.memorize=false;this._shouldPropagate=true;this.active=true}Signal.VERSION="1.0.0";Signal.prototype.validateListener=function(listener,fnName){if(typeof listener!=="function"){throw new Error("listener is a required param of {fn}() and should be a Function.".replace("{fn}",fnName))}};Signal.prototype._registerListener=function(listener,isOnce,listenerContext,priority){var prevIndex=this._indexOfListener(listener,listenerContext);var binding;if(prevIndex!==-1){binding=this._bindings[prevIndex];if(binding.isOnce()!==isOnce){throw new Error("You cannot add"+(isOnce?"":"Once")+"() then add"+(!isOnce?"":"Once")+"() the same listener without removing the relationship first.")}}else{binding=new Phaser.SignalBinding(this,listener,isOnce,listenerContext,priority);this._addBinding(binding)}if(this.memorize&&this._prevParams){binding.execute(this._prevParams)}return binding};Signal.prototype._addBinding=function(binding){var n=this._bindings.length;do{--n}while(this._bindings[n]&&binding.priority<=this._bindings[n].priority);this._bindings.splice(n+1,0,binding)};Signal.prototype._indexOfListener=function(listener,context){var n=this._bindings.length;var cur;while(n--){cur=this._bindings[n];if(cur.getListener()===listener&&cur.context===context){return n}}return -1};Signal.prototype.has=function(listener,context){if(typeof context==="undefined"){context=null}return this._indexOfListener(listener,context)!==-1};Signal.prototype.add=function(listener,listenerContext,priority){if(typeof listenerContext==="undefined"){listenerContext=null}if(typeof priority==="undefined"){priority=0}this.validateListener(listener,"add");return this._registerListener(listener,false,listenerContext,priority)};Signal.prototype.addOnce=function(listener,listenerContext,priority){if(typeof listenerContext==="undefined"){listenerContext=null}if(typeof priority==="undefined"){priority=0}this.validateListener(listener,"addOnce");return this._regist
|