Hello Guest

Author Topic: SpriteCollection - Mobile Optimization  (Read 4293 times)

madclouds

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 17
    • View Profile
SpriteCollection - Mobile Optimization
« on: July 21, 2015, 06:32:18 pm »
Hey 2DTK!

I'm working on a large task of converting my Unity3d project VetIsland.com to use 2DTK and I had some questions about mobile optimization.  I'm getting lots of reports of the first gen iPad mini's and iPhone 4's crashing, which is why I'm refactoring the project to use 2DTK which will hopefully fix the memory issues.

In my game, there are 6 environments and 16 animals.

What is the best way to organize Sprite Collections to be as effective as possible?
Should I have 1 sprite collection per Environment?  Or 1 sprite collection containing all environments?  (note, all environment assets can't fit inside a single 2048^2 atlas)
Should I have 1 sprite collection per animal?  Or 1 sprite collection containing all the animals?

Static batching sprite collections:
I use a parallax effect in my environments.  Should I static batch each layer of the parallax?  Does that gain me anything?

My environments are built by duplicating and tiling a large number of sprites.  Are there any settings I should be aware of for this to be better optimized?

As always, thanks for the great plugin and constant support!

Cheers,
Erik


unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: SpriteCollection - Mobile Optimization
« Reply #1 on: July 22, 2015, 04:18:19 pm »
Hi,

1 sprite collection per env probably makes sense.
If you can fit all animals in one collection then all of those would be most efficient.

If your environment is built out of duplicating larg numbers of sprites, then consider using a static sprite batcher - it will improve performance massively.

madclouds

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: SpriteCollection - Mobile Optimization
« Reply #2 on: July 23, 2015, 04:45:52 am »
Thanks for the advice.  I feel so much better moving forward in my project knowing the correct way to group things.

I do have a follow up questions, I'm having trouble sorting sprites in my static sprite batcher.  Is there a trick to it?  I have a collection of trees in the background and I would like some rocks to display above them.  When put them all on the same sorting order, the rocks go behind the trees regardless of their hierarchy order.  When I change the rock sprite sorting order and try to commit the batcher, i get the attached error.

Anything I can do here, or should I just create 2 static batchers instead?

madclouds

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: SpriteCollection - Mobile Optimization
« Reply #3 on: July 23, 2015, 05:07:04 am »
I believe I've figured it out.  Looks like the hierarchy order does affect the static sprite batcher order.  Before hitting commit, some sprites look out of order, but after committing, they pop back into the order I have them laid out in the hierarchy view.

It also looks like I can use the Z position to sort the sprites and then use "Flatten Depth" on the static sprite batcher to get the child sprites in the order I want.

Yay  :D
« Last Edit: July 23, 2015, 05:23:29 am by madclouds »