Sam 🕹️ Profile picture
Art, code, and assets in GameMaker!

Jan 26, 2023, 9 tweets

If you want to make your sprites stretch and scale like this, then you should be using nineslices! There's lots of uses for them. Here's how I use them in #gamemaker as a #gamedev
A thread🧵👇

A nine slice sprite is one that you can divide into nine sections. When you do, the sprite can stretch to different sizes while maintaining the shape of the outside edges. This is great for UI, and how they're usually used. Dialogue boxes, inventories, etc.

The corners will stay unstretched, but you can choose set the inner sections to "stretch" or "repeat." This let's us do interesting things, too. Here I've set the top to stretch and the bottom to repeat. Notice how it looks when I change the size of the sprite!

If I need this sprite to be 500 pixels tall, I can nineslice it along the shaft of the arrow, then just stretch it. Saves my texture page page for something more important. You might have to adjust the section borders a bit to get the desired result.

...and you can also scale the sprite or object in the room editor, and you'll see the effect, too! Here I used the sprite to define the min/max bounds of the spiky ball. It's great to have visual representation of this in the room editor!

This is my absolute favorite way of building levels! I don't get stressed out thinking about large, complicated buildings. I think of structures in small, modular pieces that can be scaled and reused. Feels like playing with blocks or Lego.

You can assign the sprites to an object, of course, and the nineslice sprite will STILL do its magic when you change the scale using image_xscale/image_yscale. A nineslice sprite can also be drawn with different sizes with draw_sprite_stretched() or draw_sprite_ext()

Like everything else, it's not a solution for every game, but it certainly works for me here. I have so much fun making new modular elements and building levels. This is all possible with nineslices! You can read more about them here: manual.yoyogames.com/GameMaker_Lang…

Comment and tell me about the cool ways you've used them in your projects!

Share this Scrolly Tale with your friends.

A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.

Keep scrolling