Combining multiple sprites into one "Sprite"

Discussion and feedback on Construct 2

Post » Sun Apr 14, 2013 6:31 am

Yo!
So, I have my project, which I've made a system that consists of having characters that are customisable, and generally may contain about 20 sprites being positioned onto the body. This works fine, and I'm not having much trouble- Until I decide I want to create more characters at once, which is needed. When I reach about 10 characters (20*10=200 sprites being individually positioned and angled), it's completely obliterating the fps!

Sooo... the way round it... Is there a way to sort of "combine" sprites at runtime (during runtime so the player has the freedom to customize still) and have them animate as if they were just a regular sprite?
I sure hope this is possible.
B
45
S
19
G
10
Posts: 562
Reputation: 9,543

Post » Sun Apr 14, 2013 10:13 pm

Bump!
I have found the plugin "Canvas" created by R0J0hound, and this is almost exactly what I needed, but I'm not sure what the most efficient way of making animations with this. Is there a way to sort of temporarily store the data in a canvas so it could be animated?

EDIT: I think I may have figured this all out. I'll edit again when I have done it for sure.Jase002013-04-14 22:37:43
B
45
S
19
G
10
Posts: 562
Reputation: 9,543

Post » Sun Apr 28, 2013 3:23 am

Bumpity
Yeah it's probably not good practise to triple post, but I'd like to ask something since I needed opinions/technical advice.

So, I implemented the Canvas object and here's the method I done:
-Have all the sprites that make up the character positioned offscreen.
-Canvas positions to the offscreen sprites whenever there's a new frame of animation on the character and pastes all the sprites onto the canvas.
-Canvas always positions at Player object.

This works, pretty well to be honest. The framerate comparison from having 10 character detailed with Canvas is like 80fps compared to 25fps if I was using the sprites onscreen without a canvas
(usually framerate is much higher, 120fps+)

Thing is, each time the frame of the character changes, it's got to erase, then paste about 20 sprites into the Canvas, which I believe would be a big hit on performance. Am I right? I believe having all frames be pre-rendered in the canvas, then switching between the pre-rendered frames. Even though I don't think a plugin like that currently exists, would this all technically be a big deal?

I had another question, but I've literally forgotten it (it is 3:22am here at the moment) but yeah, any input is good input :)
Thanks!
B
45
S
19
G
10
Posts: 562
Reputation: 9,543

Post » Sun Apr 28, 2013 4:50 pm

200 sprites is nothing for a desktop computer, usually you can reach 1000 and still get 60 FPS. Are you running your game on mobile?
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Sun Apr 28, 2013 5:21 pm

@Ashley - That's what I thought; but it seems that whenever the sprites are onscreen, things get really laggy when around 5+ characters enter the screen. I've not optimised it so that characters are deactivated offscreen, so they behave just as they would onscreen and offscreen as of now, but it's just when the character is being rendered onscreen that it lags badly. Iirc I can get about 30 characters possibly whilst they are offscreen. I'm not sure why. The only event that is run at every tick is a "For Each" loop for each and every clothing sprite, to position itself on the character, and set its angle to the bodypart that it is on.
Everything else, layering, changing animation, changing animation frame, all happens on the "On frame changed" trigger from the body of the character. I've done other small things too, like disable collisions for the clothing sprites, but it hasn't done too much lol.
Thanks for your input!
B
45
S
19
G
10
Posts: 562
Reputation: 9,543

Post » Sun Apr 28, 2013 5:46 pm

Share your .capx so we can take a look.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Sun Apr 28, 2013 6:50 pm

I guess that would be the best idea... I will have to empty out the project though, it's pretty big, not sure when I'll have the time to do that, but I shall! Thanks!
B
45
S
19
G
10
Posts: 562
Reputation: 9,543


Return to Construct 2 General

Who is online

Users browsing this forum: Andres941, tayxd and 11 guests