Be a Supporter!

Dynamic Text Box

  • 351 Views
  • 13 Replies
New Topic Respond to this Topic
TheMasterOfSprites
TheMasterOfSprites
  • Member since: Dec. 14, 2002
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
Dynamic Text Box 2009-03-22 19:08:36 Reply

I am test programming an RPG Battle System for an upcoming game, and I have looked over several tutorials. They all say to set the dynamic text box, which I labled "HP," to a number in the first frame. So I set the dynamic text box to 100 by saying "HP=100;" yet it never shows up in the text box. This RPG will be real lame without health! Someone please help.

FrubberDucky
FrubberDucky
  • Member since: Mar. 17, 2009
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
Response to Dynamic Text Box 2009-03-22 19:13:45 Reply

On the dynamic text box look for a little box in properties(at the bottomw here you specify font) saying "var". Then on the frame go toa ctons at type:

hp = 100;

If your specifying the hp ina movie clip or button use:

_root.hp = 100;

Remember actionscript is case sensetive!

TheMasterOfSprites
TheMasterOfSprites
  • Member since: Dec. 14, 2002
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
Response to Dynamic Text Box 2009-03-22 19:19:20 Reply

Still isn't working.

Denvish
Denvish
  • Member since: Apr. 25, 2003
  • Offline.
Forum Stats
Member
Level 46
Blank Slate
Response to Dynamic Text Box 2009-03-22 19:22:24 Reply

Not label, var


- - Flash - Music - Images - -

BBS Signature
TheMasterOfSprites
TheMasterOfSprites
  • Member since: Dec. 14, 2002
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
Response to Dynamic Text Box 2009-03-22 19:24:03 Reply

I don't get what var has to do with anything.

FrubberDucky
FrubberDucky
  • Member since: Mar. 17, 2009
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
Response to Dynamic Text Box 2009-03-22 19:27:14 Reply

You specify the variable in this box on the dynamic text box not name it that etc.

Dynamic Text Box

TheMasterOfSprites
TheMasterOfSprites
  • Member since: Dec. 14, 2002
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
Response to Dynamic Text Box 2009-03-22 19:29:51 Reply

Okay, thank you, the health is appearing now. However, I want him to lose health when he is hit. So when the enemy is hit and the end of my attack animation I am using this code "_root.enemyhp = _root.enemyhp-random(30);" however it doesn't seem to be working. Anymore ideas?

TheSongSalad
TheSongSalad
  • Member since: Jan. 17, 2009
  • Offline.
Forum Stats
Member
Level 19
Audiophile
Response to Dynamic Text Box 2009-03-22 19:51:51 Reply

try

if(this.hitTest(_root.whatever)){
hp -= random(35);
}

this will randomly subtract health if there is a hitest. just be sure to change whatever to what the hitest is with.

putzpie
putzpie
  • Member since: Nov. 25, 2007
  • Offline.
Forum Stats
Member
Level 08
Musician
Response to Dynamic Text Box 2009-03-22 19:53:11 Reply

Try something like this.

InstanceName.text = "HP:"+hp;

InstanceName being the instance name of the textbox.


BBS Signature
TheMasterOfSprites
TheMasterOfSprites
  • Member since: Dec. 14, 2002
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
Response to Dynamic Text Box 2009-03-22 19:56:51 Reply

At 3/22/09 07:51 PM, TheSongSalad wrote: try

if(this.hitTest(_root.whatever)){
hp -= random(35);
}

this will randomly subtract health if there is a hitest. just be sure to change whatever to what the hitest is with.

I am not using a hit test I am using a turnbased RPG final fantasy system. So basically I want to press a button have him go through the action of attacking and then have health go down acordingly. I guess I could try working a hit test in but it has been so long I forgot how to program one.

TheMasterOfSprites
TheMasterOfSprites
  • Member since: Dec. 14, 2002
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
Response to Dynamic Text Box 2009-03-22 19:58:33 Reply

Got it to work, thank you.

Kevvy
Kevvy
  • Member since: Mar. 30, 2009
  • Offline.
Forum Stats
Member
Level 01
Blank Slate
Response to Dynamic Text Box 2009-03-30 12:54:34 Reply

Hi folks, I hope it's alright me hijacking this thread since it's fairly recent, concluded and relevant to what I'm about to ask! I used the methods described here to create a temperature gauge for a Home Ec game i'm making in Uni. So it will have to run on a plus instead of minus. For God only knows what reason simply replacing a - with a + in the code makes it go from 0 + 1 = 1 to 01, adding another one gets 011 etc etc. Any ideas? Thanks in advance!

Kevvy
Kevvy
  • Member since: Mar. 30, 2009
  • Offline.
Forum Stats
Member
Level 01
Blank Slate
Response to Dynamic Text Box 2009-03-30 13:01:37 Reply

Forgot to mention that as a minus it works fine, and also that I'm a coding simpleton, just seems strange that teh minus should work :P Thank again!

ColdLogic
ColdLogic
  • Member since: Nov. 12, 2003
  • Offline.
Forum Stats
Member
Level 19
Blank Slate
Response to Dynamic Text Box 2009-03-30 13:08:14 Reply

At 3/30/09 01:01 PM, Kevvy wrote: Forgot to mention that as a minus it works fine, and also that I'm a coding simpleton, just seems strange that teh minus should work :P Thank again!

its because + can be used to attach two strings together, so useing it with a textbox could make it do that (1+1) would come up as 11, in order to avoid this, before updateing the display do the calculation

somevar = 1 + 1;
textbox = somevar;

i hope that makes sense.