Create new, clone or copy?

Discussion and feedback on Construct 2

Post » Tue Jul 23, 2013 7:30 pm

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.
B
17
S
6
G
3
Posts: 370
Reputation: 3,942

Post » Tue Jul 23, 2013 9:14 pm

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.

But I don't know which one is "best", sorry.
Bl4ckSh33p-Soft - Custom Software and Indie Games
B
55
S
16
G
6
Posts: 735
Reputation: 9,269

Post » Tue Jul 23, 2013 10:28 pm

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
B
66
S
22
G
14
Posts: 1,484
Reputation: 16,511


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 13 guests