@Zeomne Whoa thanks! :O (Today)

@ADAMATOMIC @theBanov @infinite_ammo hahahahahh #busted (Today)

@infinite_ammo @redlettermedia @ChevyRay @NoelFB WHAAAAAAAAAATT?? (Today)

@BriProv Been using Spine but mostly because they had ready to roll code to drop into my engine to use their animation data. (Today)

@infinite_ammo don't play with my heart (Today)

@BenRuiz on the 420 bloodmoon all of the world money will turn into weed buy your dlc now before it too late (Today)

Why do I get so mad when I see DLC advertisements on the Steam store page of a game that isn't even out yet? (Today)

@kertgartner Just have an annotation link to your current work in the first 10 seconds ;D (Today)

@konjak @NoelFB @scutheotaku1 why the fuck are we all still using skype (Yesterday)

@konjak @NoelFB Every chat program seems to have the same fate. Start simple, turn into bloated bullshit software over the next 5 years. (Yesterday)

@Fruckert I think there's a mysql hiccup on my webhost for the time being. (Yesterday)

Oh snap today's t.co/1Z1U1YF72t is a triple kill: t.co/iYuqX0xwkU :D (Yesterday)

RT @rabbit_nabokov: t.co/p6kSLCHJtd Momodora 3 is already over 80% on Steam Greenlight! Please consider voting if you haven't! http… (2 days ago)

@KnechtsLevel Hit up chair@igdaphx.org and we can talk details about what you want to do. ;D (2 days ago)

@KnechtsLevel We don't really venture into downtown phoenix for meetings. We used to but attendance in downtown wasn't that great. (2 days ago)

@GarretRandell chevy is the god of the bloodmoon? #whoknew (2 days ago)

I turn to the blood moon tonight for guidance... merciful god of the blood moon, should I use A* or BFS for my path finding (2 days ago)

BLOOD MOON TONIGHT (2 days ago)

@konjak Yeah it's much easier just having 6. (3 days ago)

@infinite_ammo A kickstarter for you to reappear. (3 days ago)

follow
search

2013 - 3 - 6 / 2:14 pm / general

A Flashpunk 9-Slice Object

A Flashpunk 9-Slice Object

As I've been working on this Global Game Jam game remake, I've been trying to come up with solutions for problems that I can hopefully reuse for more projects in the future. One of the things I've been thinking a lot about is managing and drawing the various user interfaces for the game. Even though I'm not quite sure how much UI stuff this game will need, I wanted to have some sort of solid base to start with so that I could get stuff up and running quickly.

One of the most basic core structures of drawing a cool UI (in my opinion!) is a 9-slice graphic object. What's a 9-slice graphic object?! Well, here's a quick example of one that I have working in Flashpunk right now.

Image
The box that is being drawn above the red player rectangle is a working example of my NineSlice class. It's being drawn from a source image of nine tiles. The source file has four tiles for the corners, four tiles for the sides, and one tile for the center. Here's what the source looks like (blown up 4x because it is tiny.)

Image
This is incredibly useful because it's now possible for me to draw stylized boxes for potential UI components at any size without having to draw each one individually. One thing that I wish that I had spent more time on in Offspring Fling is the UI for the menus, so in the future I want to make my menus and interfaces as awesome as they can be, and having some functions do a lot of the fancy work for me is a big step in that direction. Here's what it looks like right now: NineSlice.as

Here are some snippets of code from the example shown above:

//initial set up
private var nineSliceTest:NineSlice = new NineSlice(Assets.IMG_NINE_SLICE_TEST, 3, 3, 3, 3);
//in the entity's constructor
nineSliceTest.scrollX = nineSliceTest.scrollY = 0;
nineSliceTest.width = 40;
nineSliceTest.height = 40;
nineSliceTest.x = 50;
nineSliceTest.y = 50;
//in the entity's render function
nineSliceTest.render();

Right now this is a very rough first pass on this kind of thing. Ideally it would be some sort of Flashpunk graphic extension that would plug directly into the Flashpunk rendering system. For now it makes use of the Flashpunk Draw class, and some utility functions that I've written for myself. Feel free to use it or improve it, and if you end up improving it then let me know!

2 Comments
Avatar

2013 - 3 - 11 3:45 PM

fedyfausto

excuse me but i see a diagonal tile how can i dothat in FP?

Avatar

2013 - 3 - 11 8:02 PM

Kyle

I posted about slopes a few weeks ago, if you just go back through the posts in February you'll find some info about that.

Avatar

Post your comment!

POST COMMENT

about

About

Hi there, my name is Kyle, and I'm a 27 year old kid with adult powers. I'm making video games and living the indie game developer life in Tempe, Arizona. Here you will find my thoughts, games, websites, doodles, and other stuff like that. I worked on Snapshot, Offspring Fling, and a whole bunch of other games. I also created and maintain Otter, a 2d game making framework. If you want to get a hold of me use the form on the bottom of the page, leave a comment, or just tweet at me. I try to post three times a week. Thanks for stoppin' by! You're the coolest.

facebook

videos

Do you want to make a Let's Play of one of my games, or a just a video featuring footage of my games? You have my full permission to do so! Even if you are monetizing your videos, you still have my full permission to use any footage from any of my games. Go for it!

contact

Your message has been sent! Thanks :)
SEND MESSAGE