Be a Supporter!

Making a bar to represent variable?

  • 316 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? 2011-05-17 21:36:36 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? 2011-05-17 23:23:51 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? 2011-05-17 23:25:56 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? 2011-05-20 20:38:23 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? 2011-05-20 20:39:54 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? 2011-05-20 23:17:51 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? 2011-05-20 23:21:27 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? 2011-05-21 00:02:08 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
Programmer
Response to Making a bar to represent variable? 2011-05-21 02:42:39 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