Author Topic: about height width and offset  (Read 1804 times)

Esti

  • Active Member
  • ***
  • Posts: 104
  • Karma: +0/-0
    • View Profile
about height width and offset
« on: Tue, Mar 6, 2012 »
I would like to know if I understand this right, I have this sprite that is for example 32x32 pixels and I load it and set the width and height lower;16x16.

I want the blue square to be the hitbox, is this ok? thanks.


Check it out on Mochi!

test84

  • Key Contributor
  • *****
  • Posts: 1328
  • Karma: +0/-0
  • ت
    • View Profile
    • My personal site.
Re: about height width and offset
« Reply #1 on: Tue, Mar 6, 2012 »
that 16x16 will be it's "hitbox". If you want to move it for example to middle of your character, use offset.x and offset.y.
blog, twitter, Check out my award winning game, Rot Gut:

Esti

  • Active Member
  • ***
  • Posts: 104
  • Karma: +0/-0
    • View Profile
Re: about height width and offset
« Reply #2 on: Tue, Mar 6, 2012 »
thanks, I also found a function called centerOffsets. I just wanted to know if the theory was right because in practice the colission sometimes feels glitchy.

Check it out on Mochi!

test84

  • Key Contributor
  • *****
  • Posts: 1328
  • Karma: +0/-0
  • ت
    • View Profile
    • My personal site.
Re: about height width and offset
« Reply #3 on: Tue, Mar 6, 2012 »
What's the problem?
blog, twitter, Check out my award winning game, Rot Gut:

Esti

  • Active Member
  • ***
  • Posts: 104
  • Karma: +0/-0
    • View Profile
Re: about height width and offset
« Reply #4 on: Wed, Mar 7, 2012 »


I have this bat and I want the blue square to overlap with the player so I set the dimensions but somehow it doesn't work well.

I use: loadgraphic(blabla,blabla,32,30)

width=16
height=11
offset.y=12

The white box is bigger than the image because it is animated and it takes more space in other frames.

Check it out on Mochi!

test84

  • Key Contributor
  • *****
  • Posts: 1328
  • Karma: +0/-0
  • ت
    • View Profile
    • My personal site.
Re: about height width and offset
« Reply #5 on: Wed, Mar 7, 2012 »
So do you see the actual bounding boxes in debug mode? the ` key and the top right box icon that shows bounding boxes.
blog, twitter, Check out my award winning game, Rot Gut:

ayashiboi

  • Member
  • **
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Re: about height width and offset
« Reply #6 on: Thu, Mar 8, 2012 »
what you said earlier is correct, it should pretty much center a 16x16 square. Adding on what to test84 said, displaying bounding boxes will help verify any glitchyness.

Also keep in mind that if you flip the sprite (ex. facing = right), it flips according to the top left corner (where 0,0 is)

Esti

  • Active Member
  • ***
  • Posts: 104
  • Karma: +0/-0
    • View Profile
Re: about height width and offset
« Reply #7 on: Thu, Mar 8, 2012 »
So do you see the actual bounding boxes in debug mode? the ` key and the top right box icon that shows bounding boxes.

Wow thanks didn't know I can do that.

what you said earlier is correct, it should pretty much center a 16x16 square. Adding on what to test84 said, displaying bounding boxes will help verify any glitchyness.

Also keep in mind that if you flip the sprite (ex. facing = right), it flips according to the top left corner (where 0,0 is)

great, thanks

Check it out on Mochi!

Jeff

  • Active Member
  • ***
  • Posts: 127
  • Karma: +0/-0
    • View Profile
    • Entertainment Evolution
Re: about height width and offset
« Reply #8 on: Sat, Apr 21, 2012 »
A couple of sprite parameters didn't affect what I thought they would so I have a couple of questions related to this too.

- Is it possible to define from which end of the sprite the parameters height and width are counted from? It would simplify things if this could be changed. At first I thought "origin" would do this, but that seems to affect rotation only.

- At first I thought "offset" would just define the offset from which the sprite's bounding box is started but it seems like I was wrong. It affects where the sprite itself is drawn. This wouldn't matter if the bounding box always stayed the same, but when it changes, this causes some extra trouble. Probably the only way to deal with this is to manually change the position of the whole sprite, right? It does work, but feels a bit like a clumsy workaround, so I'm just wondering if there is a better way to do things.

Actually, thinking about what I've seen in some not-so-polished games, it seems like they've had a similar problem and haven't done the workaround (not sure if they've been flixel-based though).
Please give me feedback for my latest game in progress:
Blog: Entertainment Evolution