How do I Spawn an Object in a Different Layout

Get help using Construct 2

Post » Mon Jun 20, 2016 5:28 pm

Hello all.

I've looked around but can't really seem to find anything relevant to what I need to know. For my layouts, each one represents a different level that the player can have objects on. The objects spawn normally up to a certain point on the first level, but I'm at the point where I need to have a new object being spawned on the second level, being created by actions on the first level. Any idea how to do that?
B
7
S
1
G
1
Posts: 12
Reputation: 899

Post » Mon Jun 20, 2016 5:49 pm

On layout start -> Spawn X ?
B
21
S
9
G
8
Posts: 188
Reputation: 6,069

Post » Mon Jun 20, 2016 5:54 pm

You can't technically spawn something in a different layout because only one layout is really active at a time.

One way you could do it is have global variables. This would only be efficient if you are tracking a few.
spawn1 = 0
If something happens in this layout spawn1 = 1
On start of layout & spawn1 = 1 THEN spawn

There is also Global setting in the instance property:

Global
By default, all instances are destroyed when the layout ends (e.g. when going to the next layout). If Global is Yes, none of the instances of this object type will be destroyed when switching layouts.


Maybe you could spawn in this layout, set to be inactive and hidden, then have it be global to carry over to next layout, then activate it. I haven't used this though so not sure if it works that way

There is also the persist behavior. Don't believe this would help if spawning an object in a different layout but would help if wanting an object to stay the same when coming back to a layout.

https://www.scirra.com/manual/161/persist


Hope some of that is helpful
ImageImageImage
B
44
S
26
G
11
Posts: 518
Reputation: 10,502

Post » Tue Jun 21, 2016 4:58 am

Worked like a charm. Thank you very much.
B
7
S
1
G
1
Posts: 12
Reputation: 899

Post » Sun Dec 18, 2016 1:14 am

Which solution worked like a charm?
B
24
S
10
G
1
Posts: 43
Reputation: 2,288


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 6 guests