Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Grhyll on December 09, 2013, 09:26:03 AM

Title: Tiled-sliced sprite ?
Post by: Grhyll on December 09, 2013, 09:26:03 AM
Hello !

I was considering implementing a tiled-sliced sprite (with constant borders and a center that is tiled), but then it will be annoying to keep my changes when updating ngui... Would it be possible to include such a feature in the release version?
Title: Re: Tiled-sliced sprite ?
Post by: ArenMook on December 09, 2013, 02:45:19 PM
Don't.

Create a widget (ALT+SHIFT+W).

Add children sprites to this widget.


No code necessary.
Title: Re: Tiled-sliced sprite ?
Post by: Nicki on December 09, 2013, 03:40:39 PM
I made this, since I was screwing around with the code anyhow.
"Advanced sprite" is a mix of tiled and sliced. You can choose to tile or slice the edges and the center independently or disable the center like on a regular sliced sprite.

This was made on 3.0.6 f7, so I'm not sure if it breaks everything when using 3.0.7+, so user beware. 
Title: Re: Tiled-sliced sprite ?
Post by: ArenMook on December 09, 2013, 04:10:45 PM
http://www.youtube.com/watch?v=fyIpbMMUOFw
Title: Re: Tiled-sliced sprite ?
Post by: Grhyll on December 10, 2013, 03:40:22 AM
ArenMook : Thank you for your answer, however the point of my request was to avoid such a complicate process (with 9 sprites!) by having just one sprite and everything done automatically.

Thank you Nicki, I will take a look at your work, it could help me! Nice to share :)
Title: Re: Tiled-sliced sprite ?
Post by: Grhyll on December 10, 2013, 05:22:34 AM
Just to add another reason why tiled-sliced sprites are a good thing compared to the 9 pieces solution, tiled sprites need to have a very weak compression (like 32 bits), or there are artefacts at each repetition of the sprites (when compressed to PVRTC4 for example) ; if only the center of a sprite is tiled, this problem won't show up anymore.

Edit : And even with a 32 bits compression, there are still artefacts when the tiled sprite is used as a image button or when it's dragged... I think I'll go with your solution Nicki (I think it will fix all this), but it would have been better if it was included in the officiel package for the updates.
Title: Re: Tiled-sliced sprite ?
Post by: Nicki on December 10, 2013, 07:03:04 AM
Score 1 for me. :P

Just make sure you don't use too small tiles, since there's no sanity check on the code - it will make however many vertices it needs, which can become quite a lot.
Title: Re: Tiled-sliced sprite ?
Post by: Grhyll on December 10, 2013, 08:07:45 AM
Thanks for the advice, did not think of that!
Title: Re: Tiled-sliced sprite ?
Post by: Grhyll on December 10, 2013, 11:19:51 AM
I have been trying many different solutions for this issue today, and this advanced sprite script (with a few modification to adapt it to current NGUI version) is by far the best : the most simple and with the nicest results.  I definitely think it should be in the release version :)
Title: Re: Tiled-sliced sprite ?
Post by: ArenMook on December 10, 2013, 09:46:14 PM
Well, if Nicki submits a pull request for it in the latest version, I'll have a look ;)
Title: Re: Tiled-sliced sprite ?
Post by: Nicki on December 11, 2013, 04:09:14 AM
He just might. ;)
Title: Re: Tiled-sliced sprite ?
Post by: Grhyll on December 11, 2013, 09:14:45 AM
Great! Thanks :)