Jump to content

duplicate group


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.




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

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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