coter Posted September 17, 2015 Share Posted September 17, 2015 I can extends DisplayObject. But why can't I extends EventEmitter? Quote Link to comment Share on other sites More sharing options...
PixelPicoSean Posted September 17, 2015 Share Posted September 17, 2015 Yes you can extend it, which is available as PIXI.utils.EventEmitter. coter 1 Quote Link to comment Share on other sites More sharing options...
coolblue Posted September 18, 2015 Share Posted September 18, 2015 in version 3.0PIXI.utils.EventEmitter // undefined Quote Link to comment Share on other sites More sharing options...
coter Posted September 18, 2015 Author Share Posted September 18, 2015 Yes you can extend it, which is available as PIXI.utils.EventEmitter.You about these https://github.com/pixijs/pixi.js/tree/master/src/core/utils utils?There is not even a mention... in version 3.0PIXI.utils.EventEmitter // undefinedYes. v 3.0.7 also undefined Quote Link to comment Share on other sites More sharing options...
coter Posted September 18, 2015 Author Share Posted September 18, 2015 I had to climb in pixi.js and manually import EventEmitter class in core... Quote Link to comment Share on other sites More sharing options...
coolblue Posted September 18, 2015 Share Posted September 18, 2015 ooh! ooh!... I learned a new thing! DisplayObject.prototype = Object.create(EventEmitter.prototype);If you follow the prototype chain on a DisplayObject you will see the EventEmitter interface __proto__: EventEmitter_events: undefinedaddListener: on(event, fn, context)constructor: EventEmitter()emit: emit(event, a1, a2, a3, a4, a5)listeners: listeners(event, exists)off: removeListener(event, fn, context, once)on: on(event, fn, context)once: once(event, fn, context)removeAllListeners: removeAllListeners(event)removeListener: removeListener(event, fn, context, once)setMaxListeners: setMaxListeners() So, you should be able to use a DisplayObject as a dispatcher.Or you can just do this...var myEventEmitter = Object.create(Object.getPrototypeOf(Object.getPrototypeOf(new PIXI.DisplayObject()))) coter 1 Quote Link to comment Share on other sites More sharing options...
coter Posted September 18, 2015 Author Share Posted September 18, 2015 ooh! ooh!... I learned a new thing! DisplayObject.prototype = Object.create(EventEmitter.prototype);If you follow the prototype chain on a DisplayObject you will see the EventEmitter interface __proto__: EventEmitter_events: undefinedaddListener: on(event, fn, context)constructor: EventEmitter()emit: emit(event, a1, a2, a3, a4, a5)listeners: listeners(event, exists)off: removeListener(event, fn, context, once)on: on(event, fn, context)once: once(event, fn, context)removeAllListeners: removeAllListeners(event)removeListener: removeListener(event, fn, context, once)setMaxListeners: setMaxListeners() So, you should be able to use a DisplayObject as a dispatcher.Or you can just do this...var myEventEmitter = Object.getPrototypeOf(Object.getPrototypeOf(new PIXI.DisplayObject())) It's too tiring.Easier sources to correct. Just EventEmitter not in public. I wonder why the authors hid... Quote Link to comment Share on other sites More sharing options...
coolblue Posted September 18, 2015 Share Posted September 18, 2015 Its actualy third party...https://github.com/primus/eventemitter3 Quote Link to comment Share on other sites More sharing options...
PixelPicoSean Posted September 18, 2015 Share Posted September 18, 2015 Sorry I forgot that EventEmitter is only exposed as PIXI.utils.EventEmitter on the dev branch, but it's really easy to make this happen, simply add one line in the source code and compile it or compile and use the dev branch. Quote Link to comment Share on other sites More sharing options...
xerver Posted September 19, 2015 Share Posted September 19, 2015 It's too tiring.Easier sources to correct. Just EventEmitter not in public. I wonder why the authors hid... We didn't hide it, it is EventEmitter3 (https://github.com/primus/eventemitter3). Just use it in your module. We expose it in the next version so that it is easier to access, but you can just use the module yourself if you want. If you extend any of the Pixi display objects then you will have an emitter anyway though. Anything that extends DO is an emitter. coter 1 Quote Link to comment Share on other sites More sharing options...
coter Posted September 19, 2015 Author Share Posted September 19, 2015 We didn't hide it, it is EventEmitter3 (https://github.com/p...s/eventemitter3). I use the Google translator, which distorts the speech. I didn't mean that You hide using eventemitter3.I am saying that if you don't add so - (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.PIXI = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){(function (global){require('./polyfill');var core = module.exports = require('./core');//core.EventEmitter = require('eventemitter3'); <<<<<<<<<<<<<<core.extras = require('./extras');core.filters = require('./filters');core.interaction = require('./interaction');core.loaders = require('./loaders');core.mesh = require('./mesh');core.loader = new core.loaders.Loader();Object.assign(core, require('./deprecation'));global.PIXI = core;}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})},{"eventemitter3":11,"./core":29,"./deprecation":78,"./extras":85,"./filters":102,"./interaction":117,"./loaders":120,"./mesh":126,"./polyfill":130}],2:[function(require,module,exports){ I can't import it to my code. And he needed me for a single custom model. Quote Link to comment Share on other sites More sharing options...
xerver Posted September 19, 2015 Share Posted September 19, 2015 We expose it in the next version so that it is easier to access, but you can just use the module yourself if you want. coter 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.