Author Topic: Should i tween Panels or Widgets for better performance ?  (Read 5334 times)

Sahkan

  • Jr. Member
  • **
  • Thank You
  • -Given: 9
  • -Receive: 0
  • Posts: 74
    • View Profile
Should i tween Panels or Widgets for better performance ?
« on: January 27, 2015, 07:45:37 AM »
And does it even matters if there is only one sprite under that panel ?

The thing is, i have a system with a lot of sprites that tweens all over the screen, should i use a panel for each one ? or normal sprite is enough ?
« Last Edit: January 27, 2015, 08:00:19 AM by Sahkan »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Should i tween Panels or Widgets for better performance ?
« Reply #1 on: January 28, 2015, 01:33:48 AM »
Depends what you're tweening. Tweening panel's position rotation or scale is a cheap operation. Tweening alpha is the same throughout. If there is only one sprite under that panel then it doesn't matter whether you tween the panel or the sprite itself.

If something changes on the sprite, it will cause all other sprites in the same draw call to be rebuilt as well. If you have 1000 sprites, but only 1 is changing every frame, then you should move it to its own panel. If you have 1000 sprites and all 1000 of them are changing every frame then it doesn't matter -- it's the same as having only 1 changing in a panel that has 1000. Either way all 1000 need to be rebuilt.

Sahkan

  • Jr. Member
  • **
  • Thank You
  • -Given: 9
  • -Receive: 0
  • Posts: 74
    • View Profile
Re: Should i tween Panels or Widgets for better performance ?
« Reply #2 on: January 28, 2015, 02:18:27 AM »
Thank you very much for the detailed answer !  :)