Jump to content


Photo

Showing part of a sprite in game


  • Please log in to reply
6 replies to this topic

#1 goldsonic46

goldsonic46

    GMC Member

  • GMC Member
  • 581 posts

Posted 10 January 2012 - 12:54 AM

Some computer games use a full sprite, but hide a certain amount of it until a variable tells it that it's okay to show it. I want to know how this can be done in GM?

In case you didn't know what I'm talking about, take a background/tile containing something that you want to make an object such as a bar. The bar is about 300 pixels wide and 32 pixels high at a 30 degree angle. Then take a sprite that's exactly like it, but fill the bar and place it over the tile where the bar is. When you start, only about 90 pixels would be present. When you done something specific, it goes up or down showing more of the sprite up to either 120 pixels or down to 60 pixels.

Edited by goldsonic46, 10 January 2012 - 04:58 AM.

  • 0

#2 Dangerous_Dave

Dangerous_Dave

    GMC Member

  • Global Moderators
  • 9276 posts
  • Version:Unknown

Posted 10 January 2012 - 03:44 AM

You can draw just part of a sprite by using draw_sprite_part() ;)
  • 0

#3 goldsonic46

goldsonic46

    GMC Member

  • GMC Member
  • 581 posts

Posted 10 January 2012 - 03:52 AM

Thanks. However, how do I use left and top?
  • 0

#4 Dangerous_Dave

Dangerous_Dave

    GMC Member

  • Global Moderators
  • 9276 posts
  • Version:Unknown

Posted 10 January 2012 - 03:58 AM

That's the offset. Say if you had a sprite 64x64, and you wanted to draw a 16x16 square in the bottom right corner, you would set the width and height to 16, but the left and top to 48.
  • 0

#5 goldsonic46

goldsonic46

    GMC Member

  • GMC Member
  • 581 posts

Posted 10 January 2012 - 04:22 AM

That's the offset. Say if you had a sprite 64x64, and you wanted to draw a 16x16 square in the bottom right corner, you would set the width and height to 16, but the left and top to 48.


Are you supposed to work with your sprite size limitation? You used 16 in both dimensions to represent your size, but you also used 48 as the offset so I feel that you must adjust it in order to have both the dimensions and offset to equal the sprite size.
  • 0

#6 Dangerous_Dave

Dangerous_Dave

    GMC Member

  • Global Moderators
  • 9276 posts
  • Version:Unknown

Posted 10 January 2012 - 04:35 AM

Here's a picture. The black box is the whole sprite, the red box is the part you want to cut out. The red box has it's own height and width, but it is also a certain distance from the left hand side, and a certain distance from the top. That's what those arguments represent.

Posted Image
  • 0

#7 goldsonic46

goldsonic46

    GMC Member

  • GMC Member
  • 581 posts

Posted 10 January 2012 - 04:57 AM

Thanks, now it works.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users