[Tutorial] How to use NinePatch

Any community contributions to libgdx go here! Some may get included in the core API when permission is granted.

[Tutorial] How to use NinePatch

Postby joaoneto » Mon Oct 31, 2011 1:51 am

Hello Guys !!
Added to the Beginner's tutorials:
http://code.google.com/p/libgdx-users/w ... oNinePatch
Last edited by joaoneto on Mon Oct 31, 2011 4:26 pm, edited 1 time in total.
joaoneto
 
Posts: 371
Joined: Sat Oct 01, 2011 11:26 am

Re: [How -To] How to use NinePatch

Postby NateS » Mon Oct 31, 2011 6:46 am

Cool. :)

Instead of using TextureRegion.split and some other code, you can use NinePatch(Texture texture, int left, int right, int top, int bottom) or NinePatch(TextureRegion region, int left, int right, int top, int bottom). With these you specify the pixels from the left, right, top, and bottom edges of the texture or region, and it figures out all the splits. So for your example it would be:

new NinePatch(texture, 8, 8, 8, 8);
NateS
 
Posts: 1980
Joined: Fri Nov 12, 2010 11:08 am

Re: [How -To] How to use NinePatch

Postby joaoneto » Mon Oct 31, 2011 11:09 am

Thanks for the tip Master Nates, I'll add this to the example to simplify more.
joaoneto
 
Posts: 371
Joined: Sat Oct 01, 2011 11:26 am


Return to Libgdx Contributions

Who is online

Users browsing this forum: No registered users and 1 guest

cron