[How to respawn after last instance is destroyed?

Get help using Construct 2

Post » Sun Dec 22, 2013 7:04 am


Hi!!

I'm creating a catapult game where a single instance projectile is present on the start of the layout.

When the catapult is touched the projectile would be positioned to the catapult.

The projectile is destroyed when it hits an enemy. When the catapult is clicked, the projectile would re-spawn on the catapult as long as another projectile as long as there is an instance of the projectile somewhere on the screen.

Problem:
How to spawn the same projectile after destroying the projectile's last instance.

SORRY for my english. Thanks :)

B
2
Posts: 7
Reputation: 164

Post » Sun Dec 22, 2013 8:05 am

An instance of the object has to be present on the layout on start.

you could use:
on start of layout - system destroy object

After that you will be able to spawn and create it.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sun Dec 22, 2013 9:22 am

Yes the object is on the layout but my catapult doesn't work like the bullet example in Construct 2 where spawn is used for firing the bullets.

My project has the single instance of the projectile object reposition itself on the catapult once the catapult is clicked, and when thrown, the object would then be destroyed if it collides with an enemy.

This means that there is no instance left once the object is destoyed. I was wondering if it is possible to spawn another instance even if this is so.

I'm using the catapult template of construct 2 btw.





majikk2013-12-22 09:23:20
B
2
Posts: 7
Reputation: 164

Post » Sun Dec 22, 2013 9:26 am

Yes, it's possible, as long as there has been an instance on the layout.

Just use system create object.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sun Dec 22, 2013 10:15 am

Hi @majikk

From your description I suspect that you are asking the projectile to respawn itself ;-) - and so it can only work if the projectile exists somewhere in the current scene.

You can get any other object to spawn the projectile for you - e.g. catapult -> Spawn another object, or use sytem->create object as suggested above.

Cheers,
Greg
B
18
S
3
G
3
Posts: 83
Reputation: 3,736

Post » Mon Dec 23, 2013 10:43 am

@LittleStain It tried your suggestion and for it to work, at least a single instance of the object is needed to be present somewhere on the layout. Thanks anyways :)

@CJK Thank you I tried this and it worked. :)
B
2
Posts: 7
Reputation: 164

Post » Mon Dec 23, 2013 10:53 am

@Majikk

My solution works perfectly well if you choose to create an object instead of spawning it.

With System create object, there is no need to have an instance on the layout.

With spawning there is no need to have an instance either. You just have to make sure the object that is doing the spawning is on the layout. So only if this happens to be another instance of the object is it necessary to have that instance on the layout, but because you were talking about a catapult, I would expect the spawning to happen there.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775


Return to How do I....?

Who is online

Users browsing this forum: mekonbekon, NadeemAbbass and 7 guests