Alpha version
This commit is contained in:
parent
b84c8c8175
commit
7a977ace5c
42 changed files with 3882 additions and 3 deletions
49
src/pixi/utils/EventTarget.js
Normal file
49
src/pixi/utils/EventTarget.js
Normal file
|
@ -0,0 +1,49 @@
|
|||
/**
|
||||
* https://github.com/mrdoob/eventtarget.js/
|
||||
* THankS mr DOob!
|
||||
*/
|
||||
var PIXI = PIXI || {};
|
||||
|
||||
PIXI.EventTarget = function () {
|
||||
|
||||
var listeners = {};
|
||||
|
||||
this.addEventListener = function ( type, listener ) {
|
||||
|
||||
|
||||
if ( listeners[ type ] === undefined ) {
|
||||
|
||||
listeners[ type ] = [];
|
||||
|
||||
}
|
||||
|
||||
if ( listeners[ type ].indexOf( listener ) === - 1 ) {
|
||||
|
||||
listeners[ type ].push( listener );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.dispatchEvent = function ( event ) {
|
||||
|
||||
for ( var listener in listeners[ event.type ] ) {
|
||||
|
||||
listeners[ event.type ][ listener ]( event );
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.removeEventListener = function ( type, listener ) {
|
||||
|
||||
var index = listeners[ type ].indexOf( listener );
|
||||
|
||||
if ( index !== - 1 ) {
|
||||
|
||||
listeners[ type ].splice( index, 1 );
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue