Author Topic: Small Glitch when Resizing Sprites... How can I fix it?  (Read 3263 times)

guillopuyol

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 5
    • View Profile
Small Glitch when Resizing Sprites... How can I fix it?
« on: September 28, 2015, 02:13:59 PM »
Hello,

I have a few dark semi-transparent sprites that are anchored to other sprites.  The idea is that these semi-transparent black sprites darken the entire screen except for the area I want people to pay attention to.

Think of it this way:  I have the sprite I want to make people notice, and I surround it with sprites on top, left, right and bottom.  Then I anchor the top of the top sprite to the top of the screen and  the bottom to the top of the sprite I want to highlight...  The sprite on the left gets anchored left side to the left of the screen and right side to the left of the sprite I'm highlighting and so on.

The problem comes when one of the highlighted sprites is moving (for example in a scroll view) I get small 1 pixel glitches that show the "break" between the different see-through sprites.

Is there a better approach to this?  Is there a way I can make sure the anchoring goes to the same pixel so that there is no 1 pixel gap sometimes?

Thanks in advance for your help!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Small Glitch when Resizing Sprites... How can I fix it?
« Reply #1 on: September 29, 2015, 04:26:16 PM »
Best approach would be to create a custom widget that will draw the 4-5 sprites at once in one draw call by giving it a custom OnFill function. Since it will all be one widget drawing the several sprites together, they will always move as one and you won't get any visual artifacts.

That said, I am not sure why you are seeing the 1 pixel offsets to begin with. If nothing is scaled, there shouldn't be any glitches.

guillopuyol

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 5
    • View Profile
Re: Small Glitch when Resizing Sprites... How can I fix it?
« Reply #2 on: October 22, 2015, 02:30:13 PM »
Thank you for your response Aren. 

Best approach would be to create a custom widget that will draw the 4-5 sprites at once in one draw call by giving it a custom OnFill function. Since it will all be one widget drawing the several sprites together, they will always move as one and you won't get any visual artifacts.

Is there a video or resource where I can learn more about creating that costume widget? 


That said, I am not sure why you are seeing the 1 pixel offsets to begin with. If nothing is scaled, there shouldn't be any glitches.

I'm not sure either... but I guess they are being scaled because the sprite is a small black square I sliced and I use it to cover most of the screen... This is driving me nuts.

Love NGUI by the way... it's saved me TONS of time.  THANKS

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Small Glitch when Resizing Sprites... How can I fix it?
« Reply #3 on: October 24, 2015, 04:37:04 AM »
If there is a video covering OnFill somewhere, it's not one made by me. It's simple enough though... just examine UITexture's OnFill function, then have a look at the function it calls -- UIBasicSprite.SimpleFill. You are basically going to be adding vertices, one quad at a time.