Author Topic: Drawing subregions of a sprite.  (Read 3897 times)

ferretnt

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 23
    • View Profile
Drawing subregions of a sprite.
« on: October 14, 2012, 08:10:01 PM »
Is there a way to tell a sprite to draw a dynamically selected subregion of itself, e.g. for revealing a sprite in a top-down manner?

For example, suppose that I have a 64x64 sprite, and in frame n, I want to draw a 64xn subregion of the sprite, with both vertex positions and UVs forming a rectange from (0, 0) to (64, n) , so that the sprite reveals from the top down? This obviously can't be done with just a scale because I want the same screen pixel of the sprite to always correspond to the same texel.

Is there an easy way to do this in NGUI?

Thanks,
Alex

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Drawing subregions of a sprite.
« Reply #1 on: October 15, 2012, 06:29:52 AM »
Sure. Use a Filled Sprite with a Vertical fill.

ferretnt

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: Drawing subregions of a sprite.
« Reply #2 on: October 15, 2012, 10:16:16 AM »
Yes, exactly like that. Thanks!