Spawn Instance by Name?!?

Get help using Construct 2

Post » Wed Dec 07, 2011 2:06 pm

I am trying to build a "Spawner-Sprite" that is more or less generic and uses an Array to pick the "Name" of another object (ie. Sprite) and the "Probability" to spawn.

The Spawn "new Object" does not allow to give the "Instance Name" on the fly - you have to pick it during programing. Is there another way to use the "Spawn new Object"?

B
42
S
19
G
12
Posts: 723
Reputation: 13,911

Post » Wed Dec 07, 2011 2:37 pm

maybe its not what your looking for but what if you used a multiframed sprite and calculate the probability on the amount of frames and then set the frame of that spawned image, this is how i deal with multi identity's, then you only need do deal with one sprite and compare the frame to know what is what
ImageImage
B
61
S
19
G
6
Posts: 809
Reputation: 9,028

Post » Wed Dec 07, 2011 2:38 pm

That wont help, since I realy want to spawn different "objects"...
B
42
S
19
G
12
Posts: 723
Reputation: 13,911

Post » Wed Dec 07, 2011 2:51 pm

well if you have different "objectsnames" as a string in you array, you can trigger it for example every x seconds , pick array value at x

if that equels a certain "object1"
create sprite1

if that equels a certain "object2"
create sprite2

i dont think you can have a string directly spawn a sprite
ImageImage
B
61
S
19
G
6
Posts: 809
Reputation: 9,028

Post » Wed Dec 07, 2011 2:53 pm

that's a usefull work-around. Thanks for the hint. I will use a case structur...
B
42
S
19
G
12
Posts: 723
Reputation: 13,911

Post » Mon Feb 25, 2013 7:25 pm

I am struggling with this same problem. I need to spawn a sprite based on a value(string) that I have stored in an array.
B
4
Posts: 5
Reputation: 785


Return to How do I....?

Who is online

Users browsing this forum: makkancs and 23 guests