instance spawn another instance of itself

Get help using Construct 2

Post » Mon Jan 16, 2012 5:45 pm

Hi,

I want an instance to spawn another instance same as itself but different size on a condition on the first instance.

I have a bug with collision with a bullet I want to spawn another smaller bug and destroy the original bug.

how can i do that?

thanks.
B
20
S
5
G
5
Posts: 37
Reputation: 4,072

Post » Mon Jan 16, 2012 6:11 pm

have you tried the system event create object?
B
42
S
19
G
12
Posts: 723
Reputation: 13,911

Post » Mon Jan 16, 2012 9:08 pm

You need a kind of flag to differenciate the two for picking.
Create the boolean instance variable 'destroyed' on your object with default false
and then
[code]Mouse: on object left click
-> Object: set destroyed to true
-> Object: create object on layer 0 at Object.X+50,Object.Y
Object: is destroyed
-> Destroy[/code]
This way, when you left click on the object, another one should be created 50px to the right and this one should disappear into nothingness.Yann2012-01-16 21:09:19
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Mon Jan 16, 2012 9:42 pm

thanks Yann.

also is it possible to do a loop if i want to create multiple instances?
or just do multiple actions of create object?
B
20
S
5
G
5
Posts: 37
Reputation: 4,072

Post » Mon Jan 16, 2012 9:58 pm

[code]Mouse: on object left click
-> Object: set destroyed to true
System: repeat 10 times
    -> Object: create object on layer 0 at Object.X+50,Object.Y
Object: is destroyed
-> Destroy[/code]

hmmmm should work
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Mon Jan 16, 2012 10:16 pm

works.
i wonder why i didnt even try it.

also in case someone will find this useful
instead of bool for destroyed i used int value that is decreasing on new instances from the main obj and on the main obj it becomes 0.
on each obj that reaches 0 i destroy it.
then i can multiple levels from big bugs to lowest and then destroyed.

thanks.
B
20
S
5
G
5
Posts: 37
Reputation: 4,072


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 0 guests