Some optimization questions

Discussion and feedback on Construct 2

Post » Mon Apr 29, 2013 10:39 am

Hi!
I read many themes about optimization, but I still have few questions:
1) Somewhere I saw, that Ashley says that "delete" action makes "trash" in javaskript code. So what can I do?
If I no longer needed some sprite, I can replace it with "set position" action, but it not good, because I remeber that set position/angle/size/opasity... are optimization killers.
And what can I do with bullet or fume animation, to example? "Spawn/delete-Spawn/delete-Spawn/delete..." or "set position to gun" on launch and "set position (-1000, -1000)" when it hit another object?
It's difficult to understand... especially with my English ((

2) And anybody know what sprite limit has C2 for internet or mobile games?
I mean they are not on the screen at once. On screen just ststic backplane and hero with one enemy which have very many animation frames. It's , haven't scroll, haven't physics, or smth difficult like that, just many animation frames. So how many can I store in C2? 200, 300...?
B
55
S
19
G
8
Posts: 191
Reputation: 8,831

Post » Mon Apr 29, 2013 11:33 am

1. This is incorrect - C2 handles all of this for you. Delete as much as you like!

2. Depends on the hardware, sprite size, memory, etc. There's no 'hard limit'.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Mon Apr 29, 2013 1:30 pm

1) Don't worry about this. We handle it in the engine for you, so you don't need to worry about it when using Construct 2. Position, angle, opacity and size are not optimisation killers on many platforms too. See performance tips.

2) Construct 2 does not impose any limit, so it's as many as the device hardware can handle.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,630

Post » Mon Apr 29, 2013 2:13 pm

Thanks for response!
I'm asking for a reason, because, to example, this game -

http://www.scirra.com/arcade/games/addicting-puzzle-games/4590/space-n-time

lagged on notebooks and on some of mobile devices. I'm trying to find the cause. I not use "for each" , physics, particles, effects, colizions(okey, only 3 times), I'm not creating many objects, it haven't too many events, because its free edition... maybe, I make an error somewhere and can't see it yet. It looks like smth "eat" my fps))Kurz2013-04-29 14:15:40
B
55
S
19
G
8
Posts: 191
Reputation: 8,831

Post » Mon Apr 29, 2013 2:26 pm

If you share the .capx file it will make it easier for us to find the problems.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Mon Apr 29, 2013 3:56 pm

[QUOTE=Ashley] 1) Don't worry about this. We handle it in the engine for you, so you don't need to worry about it when using Construct 2. Position, angle, opacity and size are not optimisation killers on many platforms too. See performance tips.

2) Construct 2 does not impose any limit, so it's as many as the device hardware can handle.[/QUOTE]

I thought the size of sprite objects affected memory usage, or am I wrong? I remembered have background images that were 1024x512, but then when changed to 512x512, I saved around 3-5mb of memory usage
B
18
S
4
G
3
Posts: 436
Reputation: 4,801

Post » Mon Apr 29, 2013 4:29 pm

@retrodude - yes, the size of the source image affects memory usage. But I meant using one image and stretching it at runtime. Most desktop computers can do that with no performance impact, even if the sprite is stretched really big. I guess some mobile devices would struggle if you stretch images really big (it uses more of the overdraw budget), but generally the size, position, angle and opacity are not especially important for performance.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,630

Post » Mon Apr 29, 2013 5:20 pm

@Ashley
Oh I see, that's good to hear then

B
18
S
4
G
3
Posts: 436
Reputation: 4,801

Post » Tue Apr 30, 2013 2:44 pm

And last question - Is "unbounded scrolling" makes FPS to down?
Or is not affected by this?
B
55
S
19
G
8
Posts: 191
Reputation: 8,831

Post » Tue Apr 30, 2013 3:27 pm

@kurz

my Newgrounds submission has about 200 or so objects on the screen at the same time (mostly static), but still gets about 60 fps on the ipad (though it can lag a bit on mobile phones, but this is probably down to bad programming and wasteful memory management on my behalf). I do get a bit of slowdown when the enemies spin off the screen (due to using rotate, probably), but it's only brief and acceptable.

I have discovered that sometimes just one small mistake in the programming can be enough to half your frame rate. For example, during the early stages of creating my game I accidentally had it set to constantly move one of the sprites to the top of the layer. As soon as I added 'trigger once' to the event, the frame rate doubled.

I did encounter issues when originally trying out your Space N Time game on the ipad (shortly after it was submitted) - I basically got an explosion of noise all at once. When I first added music to my game I got the exact same thing, but soon discovered I had the music constantly trying to play itself again and again. So a lot of the time the performance issues are call by good ol' fashioned inexperience on our behalf. Also, the fact that different browsers seem to have different strengths and weaknesses really doesn't help keep things consistent.

Anyway, best of luck with the competition. It's been really nice to see such a wide variety of games.
B
12
S
3
G
1
Posts: 235
Reputation: 2,053

Next

Return to Construct 2 General

Who is online

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