All Objects Must Be On Layout>

Discussion and feedback on Construct 2

Post » Sat Mar 30, 2013 9:29 am

Hi all,
this is just a general question that I can't seam to find a conclusive answer to.

I was under the impression that every layout had to have the objects it will be using, so in my project each layout has a hidden AssetsLayer for this purpose - no problems.

However I have decided to add a particle object to my game and was about to go through and add this object to each layout - again no problem.

So I tested this new particle object on the first layout to get the settings happening to my liking and I just thought I would see what happens on a layout that doesn't have the object added yet - and it works!

So this has prompted this topic.

While I am more than happy to add the object to each layout if I have to, the project has 40 levels so I'm just wondering if I do need to do it.

Thanks for any input...
If it can be done, someone on the web will show you how to do it!

CDASI Games Mentality Break Splat-a-bug FlapFleet Challenge
B
28
S
9
G
5
Posts: 304
Reputation: 5,588

Post » Sat Mar 30, 2013 9:36 am

Hi,

i keep all my assets in one layout then create each level on its own layout, copying the required assets into each level.

Anything which is spawned in the level and not placed at the design sstage just remains in the asset layout. No need to copy to each level.
B
45
S
15
G
9
Posts: 1,096
Reputation: 11,038

Post » Sat Mar 30, 2013 10:19 am

Hi spongehammer,

Yeah, that is similar to what I have been doing.

I was just curious as to the fact that the layouts that I have not added the object to still created the particle anyway....
If it can be done, someone on the web will show you how to do it!

CDASI Games Mentality Break Splat-a-bug FlapFleet Challenge
B
28
S
9
G
5
Posts: 304
Reputation: 5,588

Post » Sat Mar 30, 2013 12:13 pm

Create an Asset layout.
Never load the Asset layout ever.

using System.CreateObject or Object.SpawnObject. It will create the object on the current layout. The requirement of having created assets like sprites on a layout is an old formality of the system design. I hear it's on the way out.

At some point you can add Objects without them being on any layout. Similar to how Diction/Array and similar plugins work.

So you don't need to add the particles to the layout until you actually need them at run time(or if you actually need them for things like flickering flames...)
B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834

Post » Sat Mar 30, 2013 4:58 pm

Object types are actually global. You can create any object from any layout on any other layout.

Note if an object is placed on any layer in a layout, Construct 2 will pre-load the images for the object when the layout starts. So make sure you avoid placing objects the layout doesn't need, otherwise it may waste memory.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Sun Mar 31, 2013 4:52 am

OK, sorry to labour this.

In my project each of the 40 levels(layouts)use some objects all the time - like background, players etc. Obviously these should be present on each layout, and thus can be easily arranged as required.

In addition I have several Particle objects(for various effects) and Sprite objects(bullets etc) that each layout uses periodically, but they are always created\destroyed when required. These all have the Destroy Outside Layout behaviour. - So would it be best practice to just have these on an AssetsLayout only and just create them when required in each LevelLayout for the game.michael2013-03-31 04:53:37
If it can be done, someone on the web will show you how to do it!

CDASI Games Mentality Break Splat-a-bug FlapFleet Challenge
B
28
S
9
G
5
Posts: 304
Reputation: 5,588

Post » Sun Mar 31, 2013 11:53 am

If they aren't placed in the layout, then the object is not pre-loaded when the layout starts. This means if you create an object not placed on the layout, Construct 2 will load its images at the moment you create it. This can cause a noticeable pause, especially on mobile. So if you intend to use an object on a layout, it should be placed on that layout, even if it is destroyed immediately on startup.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Sun Mar 31, 2013 11:16 pm

Ashley - got it - thanks for the clarification.
If it can be done, someone on the web will show you how to do it!

CDASI Games Mentality Break Splat-a-bug FlapFleet Challenge
B
28
S
9
G
5
Posts: 304
Reputation: 5,588


Return to Construct 2 General

Who is online

Users browsing this forum: zenox98 and 16 guests