Performance: Spawn or visibillity or animation.

Get help using Construct 2

Post » Mon Jul 14, 2014 3:38 pm

Hello guys,

Working on a game and I have 3 options to do something.
1 Use spawn and destroy sprite (72 different sprites)
2 Set visibility on and off (72 different sprites)
3 Use animation (12 different sprites, each 6 animations.)

What will be the best option regarding performance?
Only found one topic about it, but the answer wasn't clear to me, so please enlighten me :lol:

Thanks!
Daan
B
7
S
2
G
1
Posts: 77
Reputation: 727

Post » Tue Jul 15, 2014 9:44 am

No one knows???
B
7
S
2
G
1
Posts: 77
Reputation: 727

Post » Tue Jul 15, 2014 5:26 pm

Stil no one?
B
7
S
2
G
1
Posts: 77
Reputation: 727

Post » Tue Jul 15, 2014 5:40 pm

For me, the best way to know is to preview it in debug mode, then click profile to your right to see cpu utilisation. FPS is also a good indicator to evaluate the performance.
B
28
S
8
G
4
Posts: 553
Reputation: 4,924

Post » Tue Jul 15, 2014 6:03 pm

DuckfaceNinja wrote:For me, the best way to know is to preview it in debug mode, then click profile to your right to see cpu utilisation. FPS is also a good indicator to evaluate the performance.


Thanks for the reply!

I know that is probably the best way to do it....the problem is that 72 sprites in 3 different ways is a lot of coding for me. It will take me a couple of days to check it. I kinda thought that someone knew what would be better. Currently i got my the 72 sprites in the screen (and turn visibillity off and on) and the memory usage is very high(90). That is my biggest concern. Would the other methods: animition or..... load them on a not used layout and spawn and destroy, lower the memory usage?
B
7
S
2
G
1
Posts: 77
Reputation: 727

Post » Tue Jul 15, 2014 9:17 pm

I'm not sure on what you are trying to achieve here, I can't really see how animating sprites can be replaced by spawning/deleting.

My thoughts:
1- Spawn/Destroy, if you are going to spawn 72 objects in 1 frame, that may cause a significant fps drop depending on the objects.
2- Having 72 sprites on the screen is quite a bit of sprites, if you have collisions or another interaction between them, could be a problem.
3- Animating? I don't really get how it can solve your problem, do you mean moving them out of sight?

It's hard to tell you the best way without further details on the project, maybe a little more explaining or some screenshots may help.
Please tag me with @caiorosisca if your post is refering to me :). I don't always follow the topics I answer.
B
11
S
4
G
1
Posts: 272
Reputation: 1,643

Post » Wed Jul 16, 2014 8:43 am

caiorosisca wrote:I'm not sure on what you are trying to achieve here, I can't really see how animating sprites can be replaced by spawning/deleting.

My thoughts:
1- Spawn/Destroy, if you are going to spawn 72 objects in 1 frame, that may cause a significant fps drop depending on the objects.
2- Having 72 sprites on the screen is quite a bit of sprites, if you have collisions or another interaction between them, could be a problem.
3- Animating? I don't really get how it can solve your problem, do you mean moving them out of sight?

It's hard to tell you the best way without further details on the project, maybe a little more explaining or some screenshots may help.


Thanks for the help!

About the game:
It is a point and click game so collisions are already enabled. 12 different objects are showing that you each can upgrade 6 times. So in total there are 72 different objects but only 12 are showed at the same time. That is the reason there are 3 ways to do the upgrading.

animation: When object is upgrade(simple click) go the next frame of the animation.
Spawn and destroy: 72 objects on a different unused layout. At start of game spawn the first 12 objects. When you upgrade(simple click) it destroys 1 object and spawns another at the same position.
Visibility: 72 objects on the current layout. Turn visibility off for 60 objects so only 12 are visibile. When you upgrade(simple click) it will turn visibility of 1 object off and will turn it of 1 object back on.

See there are 3 ways to do achieve the same result.
The problem is there is no information about which one could be better used. It's a shame because this will probably help so many people! Especially when you work with things like upgrades.

So what do you think?
B
7
S
2
G
1
Posts: 77
Reputation: 727

Post » Wed Jul 16, 2014 9:03 am

@ddaan9

Here is how I would assess the options:-

animation: uses more memory as all 72 frames are loaded (I think), probably no fps spike on changing frame
spawn/destroy: uses less memory as only 12 images loaded, may cause fps spike when spawning (depending on size of images)
invisibility: uses more memory as all 72 images loaded, requires extra checks for collision/clicks/etc.

If the images are small enough to not impact memory too much (e.g. are 128x128 or less), I'd personally choose animation and keep the objects upgrades as frames of the object, otherwise:

If memory is an issue, use spawn/destroy.

If fps is an issue, use animation.
Find all the Construct 2 games that were on Steam Greenlight here
B
35
S
9
G
7
Posts: 468
Reputation: 6,866

Post » Wed Jul 16, 2014 9:11 am

OddConfection wrote:@ddaan9

Here is how I would assess the options:-

animation: uses more memory as all 72 frames are loaded (I think), probably no fps spike on changing frame
spawn/destroy: uses less memory as only 12 images loaded, may cause fps spike when spawning (depending on size of images)
invisibility: uses more memory as all 72 images loaded, requires extra checks for collision/clicks/etc.

If the images are small enough to not impact memory too much (e.g. are 128x128 or less), I'd personally choose animation and keep the objects upgrades as frames of the object, otherwise:

If memory is an issue, use spawn/destroy.

If fps is an issue, use animation.


Awsome reply!

I already was thinking to use spawn and destroy. Because only one upgrade is done at the time i think the fps spike will not effect the game huge and memory usage is my problem.

Thanks for the reply!

And guys if you think otherwise or think the same, post it here. This will help a lot of new users!
B
7
S
2
G
1
Posts: 77
Reputation: 727

Post » Wed Jul 16, 2014 12:01 pm

Spawn & destroy is probably not a good idea, as it uses memory AND CPU in the end.
If memory is an issue read about this blog article and make sure you're not overdoing it.

Also, you talk about 72 different objects, but in the end you could have 12 different sprites containing each 6 different animations. This maybe won't have impact on the memory usage, but at least it sounds like a better programming practice.
Posting your capx would probably be the best way to telling you definitely what's going wrong.

But I suspect 72 frames causing memory issues just means you are using too big textures as explained in the blog article.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
294
S
117
G
96
Posts: 7,312
Reputation: 71,092

Next

Return to How do I....?

Who is online

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