Hello Guest

Author Topic: Sprite Collections and you...  (Read 4939 times)

monoclesociety

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 12
    • View Profile
Sprite Collections and you...
« on: April 17, 2014, 10:55:36 am »
So I’ve been getting used to 2DToolkit for a while now and I have to say, it’s fantastic! the multi-platform asset support is a killer feature.

I don’t have any issue with 2DToolkit in regards to collections or animations, but I do have a bunch of questions and a dilemma. First the delima:

I am making a game that is a matching + bejeweled like game. You start out with a grid of donuts, as seen in Fig. 1. Once you tap on them they flip over to show a unique donut. When you get past the current level and go to the next, we add in more unique donuts (see: Fig. 2). We originally put the first 6 donuts in a single sprite collection, however now that we have many more to add in, we’re noticing that we’re going to run out of 4096x4096 for that collection.

1. Is there anything to gain from having all donuts in a single collection?
2. Would it make sense to have another collection with a bunch of other donuts in there? (keep in mind that all donuts will be used as time goes on)
3. Is there any problem in having every single donut animation in a single animation collection?

Also, we created unique prefabs for each donut, but realized that we should do object pooling. We’re thinking of using one prefab for the donut, and switching the collection/animations, but it brought up these questions

4. When we change the animation, it changed the sprites displayed. Is there even a reason to change the default collection programmatically?
5. am i going to dramatically increase the draw calls if i put each donut in their own sprite collection?

Below are screenshots to illustrate what I mean:

Fig. 1


Fig. 2
« Last Edit: April 17, 2014, 10:57:20 am by monoclesociety »

tibithegreat

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Sprite Collections and you...
« Reply #1 on: April 17, 2014, 01:16:17 pm »
Sprites that are in the same collection are usually packed in the same atlas texture. This means that unity will be able to easily batch the draw calls for multiple objects if they are in the same collections (because they share the same texture).

You have to trade-off memory for performance basically. If you put all the sprites in the same collections you will have better performance because opengl won't have the unload the texture and load the new texture every time. It will just load that one texture in memory and use it for every draw call. The disadvantage here is that there may be cases where you want to draw one specific object but you will load the whole atlas in the video card memory even though you only use like 5% of it.

monoclesociety

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Sprite Collections and you...
« Reply #2 on: April 17, 2014, 06:44:13 pm »
True, and I'm used to having to make those decisions in the games I make. I guess I'm wondering if there is anything that I wouldn't know because I didn't make 2DToolkit ;-)

Also, the issue of prefabbing but with different sprite collections and sprite animations is the one i'm curious the most about.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Sprite Collections and you...
« Reply #3 on: April 18, 2014, 05:09:43 am »
The prefab thing isn't going to be an issue either way. I don't think the difference in performance is going to be appreciable. You obviously don't want to keep destroying and recreating game objects, so certainly do pool, but for startup, I doubt its going to be different either way.