Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: alexv on September 29, 2014, 02:18:00 PM

Title: stretching a sprite, missing the first top row of pixels
Post by: alexv on September 29, 2014, 02:18:00 PM
Hi there,

I'm trying to draw a solid action bar on the top of screen using a pure white 32x32 sprite as background, but the sprite is missing the first the first (top) row of pixels as shown in this screenshot:

(http://snag.gy/ia8kf.jpg)


I've got a 2D UI Root with the following settings:

Scaling Style: Constrained
Content Width: 800 fit <unchecked>
Content Height: 480 fit <checked>

I create a new atlas, import the 32x32 white box sprite, set the bitmap import settings to "point" (instead of trilinear)
type:simple, color tint: 41,41,41,255) and set its anchor to unified with the following settings

Target: UI root

left [ targets' left ] 0
right[ targets' right ] 0
top [ targets' top ] 0
bottom [target's top] -48

I set the game window to 800x480 (and verify in stats window that is actually using 800x480).

by checking the screenshot... if you count that "transparent" first line, the height is actually 48... so NGUI didn't draw the first line.

what is going on? I could make the box be 49 pixels instead of 48, and offset it 1 pixel up.. but I dont feel that's an elegant workaround.. I Rather understand what's wrong, and try to use a better solution... any ideas?

thanks!!
Title: Re: stretching a sprite, missing the first top row of pixels
Post by: ArenMook on September 30, 2014, 04:12:37 AM
If you use the measuring tool in Photoshop, your bar is actually 47 pixels, not 48. There is exactly 1 pixel missing up top. Check the sprite itself. What base dimensions does it have according to NGUI, and is there any padding?
Title: Re: stretching a sprite, missing the first top row of pixels
Post by: alexv on September 30, 2014, 11:02:04 AM
that's why I said "if you count that transparent first line" it counts 48... it is 47 without it.
the sprite itself is 32x32, no borders and no padding, the atlas itself has 4 pixels padding between sprites (if that matters).

my workaround so far was to make it 50 pixels height, and set the anchor to:

left: 0
right: 0
top: 2
bottom: -48

that way I set 2 extra pixels to avoid the issue... but still want to know how to avoid the "bug" or issue in the first place.

thanks for your support Aren!
Title: Re: stretching a sprite, missing the first top row of pixels
Post by: ArenMook on October 01, 2014, 05:00:58 PM
When you stretch a smaller sprite to larger dimensions, you get stuff like that. That's why NGUI has "sliced" and "tiled" options. Either one of them would work, provided you gave the sprite a 1 pixel border all around.