[SOLVED] blockingwidth is always zero

Started by suicidal pencil, Sat 04/08/2012 17:59:37

Previous topic - Next topic

suicidal pencil

This is really [EXPLETIVE DELETED] annoying...

Whenever I call "player.BlockingWidth", it's always zero. I can set it but because the width changes with the character animation, it can't be static. It isn't called or set in any other part of the script. Changing the sprite doesn't change the blocking width. I've even changed the graphics driver and colour depth to see if it'd do anything (it didn't). Solid & Clickable are set to true for the character.

What would cause this to be set to zero (without me actually setting it to zero), instead of the width of the sprite that the player is?

geork

Quote from the manual:

QuoteIf this [the blocking width] is set to 0 (the default), then the blocking rectangle is automatically calculated to be the character's width, and 5 pixels high.

Hope that answers it!

suicidal pencil

#2
It does not. Setting it to 0 only keeps it at 0. It doesn't set it to the character's width.

It's called like this:
Code: AGS

if(dsBG.GetPixel(player.x + (player.BlockingWidth / 2) + x_movement, player.y) != 0){
  //etc...
}


also, I wouldn't post if I didn't already look through the manual and search the forums :P

edit: this is for collision checking so I kinda need the player's width to be accurate, not zero

Calin Leafshade

just get the width of the sprite instead

Code: ags

int GetWidth(this Character*)
{
    ViewFrame *vf = Game.GetViewFrame(this.View, this.Loop, this.Frame);
    return Game.SpriteWidth[vf.Graphic];
}



Then just replace player.BlockingWidth with player.GetWidth()

suicidal pencil

Tested working, thanks for the workaround Calin :)

The question remains, though: why is it set to zero when it shouldn't be? I either missed something important or found an annoying little bug. I prefer to think I missed something important, because that's the likeliest of possible problems.

SMF spam blocked by CleanTalk