Create new, clone or copy?

0 favourites
  • 3 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • If I have two text objects on the layout, e.g. one saying "balance" and the other saying "stake". I have 3 options:

    1) insert two new text objects

    2) insert one text object, then clone it & change text

    3) insert one text object, and copy and paste it & change text.

    All three methods seem to work, but which is best?

    I'm guessing copying is best, as it puts less objects in the "object types" project tree so is easier to navigate, but what are the gotchas to this approach? I.e. what are the limitations?

    I even seem to be able to assign different values of instance variables to copied (not cloned) objects.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Until now I created a new Textobject for every menu object or Textbox I needed. Didn't know that copy worked to set a different text for new instances. I thought it was shared. <img src="smileys/smiley24.gif" border="0" align="middle" />

    But I don't know which one is "best", sorry.

  • Your first and second method are equivalents since cloning means creating a new objecttype but based on the properties of the instance you cloned from instead of starting from default properties.

    So in the end we're down to using multiple instances or multiple objecttypes.

    First, I don't think there's any difference in terms of performance. The text plugin uses some cache system to avoid garbage collection, but this cache system is shared by all the objecttypes created from this plugin. So performance shouldn't be considered here.

    Now in term of project management, indeed, creating instances (copy) lower the number of object type to handle.

    The catch is when you want to manage them by event: if you use one objecttype by text, you don't have to worry about filtering them using conditions (picking).

    To me, that's not really a problem though.

    I try to use instances of one objecttype when this objecttype represents the same "conceptual" idea, and I just use instance variables to tell them appart.

    For instance, for a quizz game, I could have a "question" objecttype and an "answer" objecttype and put in the layout one instance of "question" and 4 instances of "answer", put an instance variable to tell which is which, and using events pick them one by one (in a loop) and then fill them during runtime.

    (and instance variable isn't that necessary here, you could use the IID)

    So my answer would be that there's no best way. Just pick the one that makes the most sens to you at the moment

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)