Be a Supporter!

Making a bar to represent variable?

  • 293 Views
  • 8 Replies
New Topic Respond to this Topic
TwentySevenPointFive
TwentySevenPointFive
  • Member since: Dec. 24, 2006
  • Offline.
Forum Stats
Member
Level 07
Artist
Making a bar to represent variable? May. 17th, 2011 @ 09:36 PM Reply

My variable is plsr, I want my rectangular shape to represent the variable by a %age.

For example:

When plsr = 0, the bar(rectangle) will show 0% size on the Y-Axis

When plsr = 100, the bar will return to 100% size on the Y-Axis

Similar to a health bar, but I just forget how to do this, I'm basically trying to show the variable increasing on the Y-Axis with a rectangular bar.

MintPaw
MintPaw
  • Member since: Jun. 11, 2006
  • Offline.
Forum Stats
Member
Level 10
Programmer
Response to Making a bar to represent variable? May. 17th, 2011 @ 11:23 PM Reply

How come a sig like that is allowed on bbs?


If ya have something to say, PM me. I have a lot of time to spare.
Also never PM egg82.

BBS Signature
MintPaw
MintPaw
  • Member since: Jun. 11, 2006
  • Offline.
Forum Stats
Member
Level 10
Programmer
Response to Making a bar to represent variable? May. 17th, 2011 @ 11:25 PM Reply

Oh yeah, and the property you're looking for is _yscale in as2 and scaleY in as3.

In as2 _Yscale goes between 0-100;
In as3 scaleY goes between 0-1;


If ya have something to say, PM me. I have a lot of time to spare.
Also never PM egg82.

BBS Signature
caseymacneil
caseymacneil
  • Member since: Nov. 19, 2008
  • Offline.
Forum Stats
Member
Level 06
Programmer
Response to Making a bar to represent variable? May. 20th, 2011 @ 08:38 PM Reply

if (Key.isDown(65))
	{
		plsr._height -= 10;
	}
caseymacneil
caseymacneil
  • Member since: Nov. 19, 2008
  • Offline.
Forum Stats
Member
Level 06
Programmer
Response to Making a bar to represent variable? May. 20th, 2011 @ 08:39 PM Reply

forgot to put that 65 is A, and you can replace the Key.isdown with a hittest or something if you want

therealsockpuppet
therealsockpuppet
  • Member since: May. 20, 2011
  • Offline.
Forum Stats
Member
Level 01
Blank Slate
Response to Making a bar to represent variable? May. 20th, 2011 @ 11:17 PM Reply

bar.scaleY == plsr*.1

therealsockpuppet
therealsockpuppet
  • Member since: May. 20, 2011
  • Offline.
Forum Stats
Member
Level 01
Blank Slate
Response to Making a bar to represent variable? May. 20th, 2011 @ 11:21 PM Reply

At 5/20/11 11:17 PM, therealsockpuppet wrote: bar.scaleY == plsr*.1

BOOOOZE! plsr/100

Torrunt
Torrunt
  • Member since: May. 3, 2007
  • Offline.
Forum Stats
Member
Level 22
Programmer
Response to Making a bar to represent variable? May. 21st, 2011 @ 12:02 AM Reply

Just some simple math:

thing.height = maxHeight * (value/valueMax);

BBS Signature
Gimmick
Gimmick
  • Member since: Aug. 20, 2008
  • Offline.
Forum Stats
Member
Level 27
Game Developer
Response to Making a bar to represent variable? May. 21st, 2011 @ 02:42 AM Reply

At 5/21/11 12:02 AM, Torrunt wrote: Just some simple math:
thing.height = maxHeight * (value/valueMax);

Don't forget that height is for Stage.height in AS2, if it's as2 then it's

thing._height = maxHeight * (value/valueMax);
//or
thing._yscale = value

Slint approves of me! | "This is Newgrounds.com, not Disney.com" - WadeFulp
"Sit look rub panda" - Alan Davies

BBS Signature