Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Obj(data){
- var hash = objs[data.type] ? objs[data.type] : objs[data.type] = {};
- this.expensiveProperty = data;
- //other logic
- hash[json.id] = this;
- }
- function Player(data, socket){
- var thisObj = this;
- Obj.call(this, data);
- this.vars.private['name'] = data.name;
- socket.player = this;
- this.socket = socket;
- }
- Player.prototype = Object.create(Obj.prototype);
- Player.prototype.constructor = Obj;
- Player.prototype.emit = function(data){
- this.socket.emit(data);
- }
- new Player({type:'type1', ...});
- new Player({type:'type2', ...});
- new Player({type:'type3', ...});
- function instancePlayer(){
- return Object.create( objs['player']['type1'] );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement