Jump to content

Clone the PIXI Container


Giedrius
 Share

Recommended Posts

Hi all,

I am trying to clone an PIXI Container so that it will have no relationship with the original one, except that they both should share the same prototypes - DisplayObject, EventEmitter, Object. But somehow I loose the original Container, see demo: 

 

 

 

Link to comment
Share on other sites

I am creating a venue designer where user can create sectors of seats, customize them and duplicate to place on the other side of the venue. It would be convenient and time saving feature. So the sector is a container which holds row containers with seat objects inside.

As I understand, one way would be to make a manual copy, creating an new Container and assigning properties of the original Container.

Link to comment
Share on other sites

That's where OOP help (I work with typescript but same can be done in javascript), just make your seat objects extends whatever they are (Sprite?, Container?) and add a clone method in there, in that clone method make it duplicate relevant properties and assets and return the result in a new object and you are done. Cloning is the simplest thing in any technology, binary cloning is harder but I don't think it's an option in javascript.

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.

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

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