Object creation at runtime, best approach

Get help using Construct 2

Post » Fri Jan 20, 2012 10:53 pm

Hey,
I'm adding explosions and gnarly effects in my game, but, being someone just starting in Construct, I just found out that there's a need to have an instance of an object present in the game world in order to create/spawn it in other places, like in the tutorial (the bullet part).

Now, I can accept this no problem with recurring items, whether enemies, bullets or pickups, because they are used fairly often. But for an object that is spawned/created when the player dies (an explosion, in this case) we can get to the point where we get objects in memory that we can never use. EVER!

I assume there's no way around this, yes? So, in my mind I see that the best approach is to add these one-off items in a back-behind-the -background layer so they are not seen (I *hate* having stuff outside the layout, seems clumsy and sloppy).

Thoughts?
B
25
S
8
G
7
Posts: 184
Reputation: 6,040

Post » Fri Jan 20, 2012 10:55 pm

you can use a separate layout..

I made one just called "all objects" it has no event sheet, just every object placed in a grid.

You can use it to set the default values for all objects upon creation, also you don't have to worry about destroying loads of things on start up.
B
28
S
8
G
1
Posts: 469
Reputation: 4,683

Post » Fri Jan 20, 2012 10:56 pm

Hum that's interesting... so you're suggesting that we shouldn't have to have an instance of every object on the layout for it to exist. I agree with you, as we have the "Objects" bar with all the objects there, so why do we need it on the layout also?
B
83
S
21
G
15
Posts: 1,039
Reputation: 15,134

Post » Fri Jan 20, 2012 10:58 pm

7soul, in the error message that pops up it says it will be fixed in a future build.
B
28
S
8
G
1
Posts: 469
Reputation: 4,683

Post » Fri Jan 20, 2012 11:30 pm

[QUOTE=keepee] you can use a separate layout..

I made one just called "all objects" it has no event sheet, just every object placed in a grid.

You can use it to set the default values for all objects upon creation, also you don't have to worry about destroying loads of things on start up.[/QUOTE]
I am using a separate layer, one at 0, with all the items that are not permanent/discardable.

[QUOTE=7Soul] Hum that's interesting... so you're suggesting that we shouldn't have to have an instance of every object on the layout for it to exist. I agree with you, as we have the "Objects" bar with all the objects there, so why do we need it on the layout also?[/QUOTE]
Nah, I'm not suggesting anything. I'm looking for ways to improve this mechanic, but I don't really think there is any, though strangely, all items, present in a layer or not, appear on the event list. So I assume we can get them somehow even if they are not hidden in a frame?
B
25
S
8
G
7
Posts: 184
Reputation: 6,040

Post » Sat Jan 21, 2012 12:44 am

I always just use the outside-layout trick. I guess it does look kinda sloppy, but then again, so is everything else in my life.
B
20
S
9
G
6
Posts: 607
Reputation: 6,112

Post » Sat Jan 21, 2012 4:42 am

Now that there's families, you can put all your fx sprites and stuff like that in a family and do
[code]System: On start of layout
-> fxFamily: Destroy[/code]
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Sun Jan 22, 2012 12:33 am

Hm... Guess I'll have to read about that, then.
B
25
S
8
G
7
Posts: 184
Reputation: 6,040


Return to How do I....?

Who is online

Users browsing this forum: Kagubro, Yahoo [Bot] and 33 guests