Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: ntopia on April 11, 2014, 07:36:40 AM

Title: Why can't I make a sprite with width 1 ?
Post by: ntopia on April 11, 2014, 07:36:40 AM
Why 'UIWidget.minWidth' == 2 ???
Title: Re: Why can't I make a sprite with width 1 ?
Post by: ArenMook on April 11, 2014, 07:52:16 AM
For the sake of centering things evenly the dimensions should be dividable by two so you never get half-pixel positions.
Title: Re: Why can't I make a sprite with width 1 ?
Post by: ntopia on April 11, 2014, 08:01:29 AM
Thank you!
Then..
For drawing a sprite with width 1, what should I do?

When I make an atlas from img with width 1, NGUI makes sprite's width to 2 automatically.
So the result sprite in game is stretched and its width is 2.

Sorry for my poor english.
Title: Re: Why can't I make a sprite with width 1 ?
Post by: helmesjo on April 11, 2014, 02:03:52 PM
Question: How can one tell that a sprite with size 2x2 is stretched? :D
Title: Re: Why can't I make a sprite with width 1 ?
Post by: ntopia on April 11, 2014, 11:50:08 PM
Question: How can one tell that a sprite with size 2x2 is stretched? :D

The original img is a vertical bar with size 1x100.
I make an atlas from that img.
And make a sprite by using that atlas.

In result, a stretched vertical bar is printed with size 2x100.

The original img : 1x100 pixels showing
In game : 2x100 pixels showing ( with stretched )

So, I can tell that it is stretched.

Thank you!
Title: Re: Why can't I make a sprite with width 1 ?
Post by: ArenMook on April 12, 2014, 04:53:27 AM
NGUI adds 1 pixel of padding anyway if the dimensions are odd (not dividable by two). In your case you should do that by editing the sprite and giving it some padding -- 1 pixel vertically will be enough.
Title: Re: Why can't I make a sprite with width 1 ?
Post by: ntopia on April 17, 2014, 06:52:22 AM
Sorry for posting again.

But how about Tiled sprite?

I want to draw a line like this.
(http://i59.tinypic.com/jv2ljt.png)

So I made a 3x1 img that one pixel is gray pixel and other 2 pixels are empty pixel.
And I made an atlas from that img.
After making an atlas, it converted to 1x2 img with right-border 2. (I don't understand it first)
And I printed it by tiled sprite and nothing was printed.

After that, I remembered your answer. So I added a 1 pixel to bottom-border of that img.
But it was same. Nothing was changed.

Am I going to wrong way?
Title: Re: Why can't I make a sprite with width 1 ?
Post by: ntopia on April 17, 2014, 07:06:02 AM
I asked a question about Tiled sprite 1 year ago.
http://www.tasharen.com/forum/index.php?topic=4190

I think that my question in this thread shows a necessary of padding in Tiled sprite.

Thank you!
Title: Re: Why can't I make a sprite with width 1 ?
Post by: ArenMook on April 17, 2014, 11:27:12 AM
It's not a good idea to use such tiny sprites. NGUI has to create 2 triangles for every repeat of the image. Use a larger sprite.

Also when adding the sprite to the atlas there is the "Trim Alpha" option. Uncheck it if you don't want it trimmed.