Replacing Objects

Discussion and feedback on Construct 2

Post » Mon Apr 22, 2013 10:56 pm

In almost every situation when I want to replace an object in the script, and that line contains an expression using the object being replaced, I keep having to go in and manually change the name. I think it's better to automatically rename the expression object of the same name as well by default. Thoughts?
Jack of all trades, and master of some.
B
29
S
9
G
7
Posts: 174
Reputation: 7,601

Post » Mon Apr 22, 2013 11:32 pm

Already in ... Right click on the action to remplace the object in it ... you can even replace conditions ...
B
34
S
16
G
16
Posts: 2,222
Reputation: 16,564

Post » Tue Apr 23, 2013 12:03 am

That's not what I'm asking for. You never noticed the word "expression" I think.JoyfulDreamer2013-04-23 00:04:28
Jack of all trades, and master of some.
B
29
S
9
G
7
Posts: 174
Reputation: 7,601

Post » Tue Apr 23, 2013 12:10 am

Not necessary. Take a look at this example

SpriteA -> set height to SpritA.Height + 10

but You want to change it to

SpriteB -> set height to SpritA.Height + 10

Sometimes You want to change only an object but keep expression intact.

For what You want You could use
SpriteA -> set height to self.Height + 10 - that way expression will be valid for any replaced object.
ImageImageImageImage
B
140
S
58
G
36
Posts: 2,547
Reputation: 31,170

Post » Tue Apr 23, 2013 12:12 am

Well, sorry, but I've never seen a reason to keep the same object name for a different object (I think your example is a little contrived from reality ;) ). Anyhow, I guess 'Self' is better practice actually, I completely forgot about that! LOL. ;)JoyfulDreamer2013-04-23 00:13:35
Jack of all trades, and master of some.
B
29
S
9
G
7
Posts: 174
Reputation: 7,601

Post » Tue Apr 23, 2013 12:18 am

[QUOTE=JoyfulDreamer] (I think your example is a little contrived from reality ;) [/QUOTE]

Actually it's not. It all depends what are You developing/prototyping.
And btw that example, I used that few hours ago ;)
ImageImageImageImage
B
140
S
58
G
36
Posts: 2,547
Reputation: 31,170

Post » Tue Apr 23, 2013 12:19 am

You may have, but I'm sure 98% of the time it's not the case. ;) I think it's better to change the names by default and let the developer change it back, since that's the expected result in probably 98% of the cases. But, that's probably a moot point now since best practice is probably to use "Self". ;)JoyfulDreamer2013-04-23 00:21:51
Jack of all trades, and master of some.
B
29
S
9
G
7
Posts: 174
Reputation: 7,601

Post » Tue Apr 23, 2013 12:31 pm

Construct 2 already does this. I just checked, and it does update the names of objects in expressions when replacing.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,478

Post » Tue Apr 23, 2013 7:28 pm

You mean when right clicking an action and selecting "replace object"? Didn't work for me.
Jack of all trades, and master of some.
B
29
S
9
G
7
Posts: 174
Reputation: 7,601

Post » Tue Apr 23, 2013 9:25 pm

Yeah, it worked for me. Can you provide a specific example of it not working? (Share a .capx and say which event to replace object on)
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,478

Next

Return to Construct 2 General

Who is online

Users browsing this forum: newt and 10 guests