Jump to content

duplicate group


valentinaCom
 Share

Recommended Posts

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?

Link to comment
Share on other sites

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();    }};
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...