How do I pick an object from a dynamic string?

Get help using Construct 2

Post » Fri Aug 30, 2013 5:50 pm

Hello there, maybe someone can help me out here?

I want the following thing:

Step 1 : Write an object name to a string variable, e.g. "wood"

Step 2 : Do stuff with the object (for example create, destroy, rotate, etc.) based on this string variable.

I have a lot of different objects and want to write functions that can efficiently do the same thing to different kinds of objects, based on what is written dynamically to this string. I have - so far - not found a convenient way to do this without having to write down EVERY SINGLE case, beforehand, like this:

If string variable = "wood", pick object wood, etc. etc.

I hope you understand my problem. Is there some sort of plugin that can help?

Thanks so much for helping!

kbm
B
5
S
2
Posts: 29
Reputation: 483

Post » Fri Aug 30, 2013 11:16 pm

capx? screenshot?
B
12
S
3
G
1
Posts: 347
Reputation: 2,866

Post » Fri Aug 30, 2013 11:30 pm

you could use function's to get it work
B
18
S
6
G
3
Posts: 197
Reputation: 4,129

Post » Fri Aug 30, 2013 11:44 pm

Families let you group similar objects together and perform similar operations. Also, the nickname plugin allows you to pick by name.
ImageImageImage
B
71
S
21
G
233
Posts: 3,696
Reputation: 130,368

Post » Sat Aug 31, 2013 12:48 am

I would probably put them all in a family, and name the default animation the same as the name of the sprite.
Then "Pick by Evaluate" use the family, and the evaluation as
Family.AnimationName="Sprite"

edit: (actually I do this all the time, but instead of a family, I usually have all the sprites as separate animations in the same Object. Then picking by animation name is easy.)Paradox2013-08-31 00:52:21
B
231
S
62
G
33
Posts: 902
Reputation: 40,348


Return to How do I....?

Who is online

Users browsing this forum: David181, senecaa and 20 guests