valentinaCom Posted October 5, 2014 Report Share Posted October 5, 2014 There is a way to duplicate a group? I need 2 groups in my game, that contains the same objects (if I add something to one of them, it's need to be added to the other group too) Quote Link to comment Share on other sites More sharing options...
xerver Posted October 5, 2014 Report Share Posted October 5, 2014 You mean like "linking" them together so they share the same children? No, currently this is not possible. Each object in PIXI may only have 0 or 1 parent. **EDIT** Well, it may not work but you can try to hack it together with something like "group2.children = group1.children" so two groups have a reference to the same array. That may work? Quote Link to comment Share on other sites More sharing options...
hyude Posted October 7, 2014 Report Share Posted October 7, 2014 I have the same problem. My workaround is to only have 1 "dummy-group" which contains all the children, and 2 array to store the children (the array representing your original 2 group).I then apply the logic to the array. here is a simple snippet for my List class.List = function(){ this.arr = [];};List.prototype = { add : function(child){ this.arr.push(child); }, insertAt : function(child, idx){ this.arr.splice(idx, 0, child); }, remove : function(child){ var idx = this.getID(child); if(idx != -1){this.arr.splice(idx,1)}; }, removeAt : function(idx){ this.arr.splice(idx, 1); }, getChild : function(idx){ return (idx < this.arr.length ? this.arr[idx] : null); }, getID : function(child){ for(var i = 0; i < this.arr.length; i++){ if(this.arr[i] == child){ return i; } } return -1; }, toString : function(){ return this.arr.toString(); }}; 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.