Author Topic: SOLVED: How to get character.height?  (Read 246 times)  Share 

SOLVED: How to get character.height?
« on: 20 Jun 2012, 17:31 »
I need the sprite height from the current character.Frame.

edit:
ok found the solution from monkey in another codesnippet somewhere: :)
Code: Adventure Game Studio
  1. ViewFrame *frame = Game.GetViewFrame(cGuard_1.View,cGuard_1.Loop, cGuard_1.Frame);
  2. int sprite_height = (Game.SpriteHeight[frame.Graphic]);

« Last Edit: 20 Jun 2012, 17:38 by Rocco »

monkey_05_06

  • AGS Project Admins
  • Has left the building.
Re: SOLVED: How to get character.height?
« Reply #1 on: 20 Jun 2012, 21:12 »
Blast! That guy's always leaving code snippets laying around. :P

Just for anyone reading this, don't forget about the Character.BlockingHeight property if that's what you really need, but if you're just looking for the height of the character's current frame, you would just grab the ViewFrame first.

P.S. I'm pretty sure I would never have put parenthesis around just Game.SpriteHeight itself (although I do like to use them a lot, some may say excessively, to make operational precedence clear and invariable). User preference though as it will work out the same. ;)
Let's be honest. Most people suck at coding. I suck at coding, but at least my code is readable. To Hell with anyone too lazy to maintain consistent formatting in their code. I could deal with bad interfaces and structure if I could even read your horrible code. And that's putting it nicely. -monkey

Re: SOLVED: How to get character.height?
« Reply #2 on: 20 Jun 2012, 21:33 »
no you didnt -> http://www.adventuregamestudio.co.uk/yabb/index.php?topic=37906.msg498141#msg498141
and i neither, it was just for quicktesting, so i didnt mess around with unnecessary parenthesis. :) :P
cause i made a function of it:

Code: Adventure Game Studio
  1. function Get_Character_Height(this Character*)
  2. {
  3.   ViewFrame *frame = Game.GetViewFrame(this.View, this.Loop, this.Frame);
  4.   return Game.SpriteHeight[frame.Graphic];
  5. }

Blast! That guy's always leaving code snippets laying around. :P
This is the greatest thing about AGS, codesnippets are laying around everywhere. :-D
« Last Edit: 22 Jun 2012, 11:47 by Rocco »