Sprite performance question

Discussion and feedback on Construct 2

Post » Thu May 30, 2013 1:28 am

Like many others have in the past, I'm considering creating a random background with a single sprite object repeated randomly across a layout (think: starry sky).

Is there any way to make a sprite object static, where the only thing it holds is essentially just an array of coordinates, and the only thing it updates is drawing those coordinates to the screen?

It's my impression that all sprite objects have a whole bunch of extra stuff that gets updated, with a bunch of unnecessary checks for something that never moves or needs to be checked for collision.

What kind of overhead would this produce? What's the solution with maximum efficiency?

Thanks!
B
11
S
2
Posts: 55
Reputation: 807

Post » Thu May 30, 2013 1:24 pm

The Construct 2 engine is well-optimised. A sprite with a single animation with a single frame (or an animation speed of 0) that does not move does no work other than copying its cached co-ordinates every frame. That involves a negligible amount of CPU work.

If the object has more than one animation or more than one frame and the animation speed is above 0, the engine will process it every tick to run the animation. This also involves a probably negligible amount of work (it's very simple logic), but if you're talking about vast numbers of sprites, it might be something to be aware of. Note also if you change the animation speed so it's not 0 any more, the engine will start ticking it. (The animation speed 0 thing is intended so that tile based games using lots of animations and frames for static tiles which do not animate are still handled efficiently.)

If you move the object, it will keep re-calculating the vertex co-ordinates. This is also probably a negligible amount of work (it's highly optimised since movement is frequent).

So sprites which don't move or animate are blazingly fast. You probably don't need to worry about it.
Scirra Founder
B
402
S
238
G
89
Posts: 24,628
Reputation: 196,023

Post » Thu May 30, 2013 5:28 pm

Thanks, good to know!
B
11
S
2
Posts: 55
Reputation: 807

Post » Thu May 30, 2013 7:49 pm

@Ashley I'm curious, If one sprite with a lot of animation folders against multi-sprites with one animation... Does it make difference on performance?
B
99
S
35
G
29
Posts: 3,139
Reputation: 28,421


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 2 guests