Suggestion. Change object drop down for an Act,Con,Exp

Discussion and feedback on Construct 2

Post » Tue Nov 17, 2015 6:39 pm

In the C2 coding panel, if I want the same logic done for a second object, I should be able to right click and do a 'change object'. For example, let's say I have 'if Pirate is less than 100 from Ship' logic block with multiple sub conditions. If I want to do the same logic for 'Captain' I should be able to copy paste the block for Pirate and do a 'change all pirate to captain' (one object to another object, all the logic remaining same). I feel this could speed up coding in C2 considerably. Please let me know your thoughts on this, or let me know if there is an easy way out for this.
B
10
S
2
Posts: 21
Reputation: 665

Post » Wed Nov 18, 2015 4:01 am

You can already do that and actually it's one of the best features of the event sheet editor!
Just double click to edit the condition and press back until you get at the "page" where you can select a different object. You will notice that when you press next, all the expressions remain intact.

EDIT: It seems I didn't read your post carefully. You can do the above but only for one condition. Still, it's very useful.
B
13
S
5
G
1
Posts: 116
Reputation: 1,805

Post » Wed Nov 18, 2015 5:22 am

You can do this already.

First select all the relevant events.
Then right click on the selection and click "replace object".
It will then let you pick the object to replace and what to replace it with.

There are restrictions though. Like you can only replace sprites with sprites or tiledbg with tiledbg objects. And if any of the events access a variable or behavior, the object you replace it with needs it too.
B
92
S
32
G
109
Posts: 5,290
Reputation: 70,991

Post » Wed Nov 18, 2015 5:48 am

@R0J0hound to the rescue! I would never notice there's such a thing if you didn't mention, so thanks man, not only for this but for your whole contribution to this community!
B
13
S
5
G
1
Posts: 116
Reputation: 1,805

Post » Wed Nov 18, 2015 12:31 pm

It's an anti-feature to help people duplicate logic, since it reduces maintainability. In your example, now you have to maintain two identical sets of events, so if you ever change one, then you have to make the same change to the other. If you do this 20x over, then you have a real mess. Families are a better solution: put both objects in a family, then the same set of events applies to all the objects with no duplicated logic.
Scirra Founder
B
397
S
236
G
88
Posts: 24,418
Reputation: 194,540

Post » Wed Nov 18, 2015 2:51 pm

That helps! Thanks Ashley and R0J0hound!!
B
10
S
2
Posts: 21
Reputation: 665


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 17 guests