What is the best practice?

Get help using Construct 2

Post » Fri Jan 29, 2016 11:58 pm

I would like to know what is more interesting...
Put the objects that will appear only with the 'create object' action in a separated layout, or just put outside the layout that it will appear?
Thanks.
B
20
S
4
Posts: 387
Reputation: 2,274

Post » Sat Jan 30, 2016 5:56 am

I think it's more organized to have it all in one layout dedicated to just having those objects, but it's up to you
B
84
S
22
G
15
Posts: 1,039
Reputation: 15,249

Post » Sat Jan 30, 2016 4:01 pm

Zathan wrote:I would like to know what is more interesting...
Put the objects that will appear only with the 'create object' action in a separated layout, or just put outside the layout that it will appear?
Thanks.


The best practice would be is to put everything that the Layout needs including the objects that will be created using "System ->Create Object(X,Y)". And on start of layout, if the object is not needed yet , destroy it.

Because if you don't have the object in the layout and create it using "System ->Create Object(X,Y)" it will make a laggy pause because the object isn't preloaded.
Only the objects present in the layout during editing will be preloaded. It is still okay if you put it outside the Layout White Paper as long it is on the Layout Page.

Note: Do not put your objects in a separate layout that isn't run during gameplay.

(Example of a bad practice!!! is to make a Layout where the game happens and make a separate layout for storage of the objects that will be created by "System ->Create Object(X,Y)" for the reason of not making the Main Game Layout look messy. ) - Wrong! The objects will not be preloaded and plus a Layout that is not used and made a storage for objects makes it worse.

For more info, read Ashley's Optimization tips below:

Ashley's posts:

https://www.scirra.com/blog/83/optimisa ... -your-time

https://www.scirra.com/tutorials/298/pe ... bile-games
The Things you can create is only limited by your imagination. If you don't have the skills then use your motivation as a natural force to exceed all expectations. Chadori RebornXD
B
67
S
22
G
90
Posts: 1,125
Reputation: 60,036

Post » Sat Jan 30, 2016 8:23 pm

chadorireborn wrote:
Zathan wrote:I would like to know what is more interesting...
Put the objects that will appear only with the 'create object' action in a separated layout, or just put outside the layout that it will appear?
Thanks.


The best practice would be is to put everything that the Layout needs including the objects that will be created using "System ->Create Object(X,Y)". And on start of layout, if the object is not needed yet , destroy it.

Because if you don't have the object in the layout and create it using "System ->Create Object(X,Y)" it will make a laggy pause because the object isn't preloaded.
Only the objects present in the layout during editing will be preloaded. It is still okay if you put it outside the Layout White Paper as long it is on the Layout Page.

Note: Do not put your objects in a separate layout that isn't run during gameplay.

(Example of a bad practice!!! is to make a Layout where the game happens and make a separate layout for storage of the objects that will be created by "System ->Create Object(X,Y)" for the reason of not making the Main Game Layout look messy. ) - Wrong! The objects will not be preloaded and plus a Layout that is not used and made a storage for objects makes it worse.

For more info, read Ashley's Optimization tips below:

Ashley's posts:

https://www.scirra.com/blog/83/optimisa ... -your-time

https://www.scirra.com/tutorials/298/pe ... bile-games

Wow, are you sure that the objects stored in a separated layout are not preloaded? I was almost sure that they are... and it would be much more organized.

How do you know that they aren't?
B
20
S
4
Posts: 387
Reputation: 2,274

Post » Sun Jan 31, 2016 12:48 am

I am sure they are. Try to put a lot of assets to the second layout and try to switch between them with System -> go to layout. You will notice that the first time you go to layout 2 takes time, but already second time is very fast (at least on the devices which have enough RAM to hold the data).

I think it's pretty good practice to put the assets on the first layout because it's the only one layout where you can implement the progressbar, so player at least see that something is being loaded.

But! It obviously depends on the project size. I think it's a good practice only in a medium size projects. For small projects there is no point since there are usually few small assets. ,
Now in big projects you might have really a lot of stuff which would be really a pain for user to wait for all of them being loaded. In such case you should have it organized on the layouts that use them.
ImageImageImage
B
32
S
19
G
82
Posts: 1,039
Reputation: 46,232

Post » Sun Jan 31, 2016 9:44 am

Zathan wrote:Wow, are you sure that the objects stored in a separated layout are not preloaded? I was almost sure that they are... and it would be much more organized.

How do you know that they aren't?


I exactly did what you did. I made a Separate layout to put all my objects and load them secretly on startup (loader layout) but when I tested it, it was very poor in performance. That was in my previous game and it became a complete fail. And I then realized my mistake when I read Ashley's optimization posts.
The Things you can create is only limited by your imagination. If you don't have the skills then use your motivation as a natural force to exceed all expectations. Chadori RebornXD
B
67
S
22
G
90
Posts: 1,125
Reputation: 60,036

Post » Thu Feb 04, 2016 10:33 pm

Hm... Well, I like the organization of making a layout for these objects, but if it isn't the best practice here, I will not do this hehe
Thank you!
B
20
S
4
Posts: 387
Reputation: 2,274

Post » Thu Feb 04, 2016 11:41 pm

@chadorireborn
This is quite an important information to me, so I need to be 100% sure about it. I've read the posts from Ashley at least 3 times in the past, and I just re-read them just now, and I don't see anything in them that would make me think it is a bad idea to create a layout dedicated to stocking objects. Could you quote the part of the articles which make you think it is?

I myself am using such a layout in all my project and didn't have had any problem until now. Of course, if it turns out that it is really bad practice, I will change that.
Actually I already asked the exact same questions nearly one year ago, and the globally admitted reply is that such layouts were good practice.
how-to-reduce-the-number-of-crashes-mobile_p896579?#p896579
(second paragraph is the question)

Thanks for the information!
B
33
S
6
G
1
Posts: 355
Reputation: 2,850

Post » Fri Feb 05, 2016 7:41 am

Rable wrote:@chadorireborn
Could you quote the part of the articles which make you think it is?


https://www.scirra.com/manual/134/performance-tips

Ashley said:
(Not placing all used objects in the layout)
If objects are not placed in a layout but are created by events, Construct 2 will load the textures for those objects the moment you create them. This can cause a momentary pause or "jank" and make the game feel less responsive. This can be avoided by placing any used objects in the layout. They can be placed off-screen and destroyed on startup to avoid interfering with the gameplay. Then Construct 2 will preload all their textures when the layout starts, avoiding any "jank" as they are created and destroyed at runtime.
The Things you can create is only limited by your imagination. If you don't have the skills then use your motivation as a natural force to exceed all expectations. Chadori RebornXD
B
67
S
22
G
90
Posts: 1,125
Reputation: 60,036

Post » Fri Feb 05, 2016 7:55 am

Rable wrote:@chadorireborn
I don't see anything in them that would make me think it is a bad idea to create a layout dedicated to stocking objects.


Stocking objects is not bad when you are still editing and it is the first instance per object that you are putting there and this should only be temporary because this is only used to make construct 2 familiar with the size, opacity and other properties of your object / sprite and later on you will have to move it to the layout that is going to need it afterwards. And this is only applicable for games with many layouts. And every optimization freaks out there that is concerned with code optimization knows that you shouldn't leave something in your program that is not going to be needed. So if you think about it, if you want to have a more optimized game then you should delete that object layout on export.

"NOTE: When a game leaves the layout. It releases images from memory that is not going to be needed in the next layout to make space for the new images for the next layout. This is necessary for optimization of games. Think about it, if you don't flush it for the next layout and keeps adding more images. Sooner or later it's gonna overload and crash or have fps spike and etc."

If you think I am wrong, please correct me. Btw, I did not made this statement based on my observation only, I made a lot of test on this before just to prove this and this is also based on my experience. I had a game before that became so slow because of misunderstanding how ram memory works and by not reading the manual. And I learned my mistakes the hard way.

:D

@Rable
The Things you can create is only limited by your imagination. If you don't have the skills then use your motivation as a natural force to exceed all expectations. Chadori RebornXD
B
67
S
22
G
90
Posts: 1,125
Reputation: 60,036

Next

Return to How do I....?

Who is online

Users browsing this forum: FaberCastell, Google [Bot], Ryan Kocourek and 23 guests