Dynamic Text Box
- TheMasterOfSprites
-
TheMasterOfSprites
- Member since: Dec. 14, 2002
- Offline.
-
- Forum Stats
- Member
- Level 12
- Blank Slate
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
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
- Denvish
-
Denvish
- Member since: Apr. 25, 2003
- Offline.
-
- Send Private Message
- Browse All Posts (15,977)
- Block
-
- Forum Stats
- Member
- Level 46
- Blank Slate
- TheMasterOfSprites
-
TheMasterOfSprites
- Member since: Dec. 14, 2002
- Offline.
-
- Forum Stats
- Member
- Level 12
- Blank Slate
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
You specify the variable in this box on the dynamic text box not name it that etc.
- TheMasterOfSprites
-
TheMasterOfSprites
- Member since: Dec. 14, 2002
- Offline.
-
- Forum Stats
- Member
- Level 12
- Blank Slate
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
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
Try something like this.
InstanceName.text = "HP:"+hp;
InstanceName being the instance name of the textbox.
- TheMasterOfSprites
-
TheMasterOfSprites
- Member since: Dec. 14, 2002
- Offline.
-
- Forum Stats
- Member
- Level 12
- Blank Slate
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
- Kevvy
-
Kevvy
- Member since: Mar. 30, 2009
- Offline.
-
- Forum Stats
- Member
- Level 01
- Blank Slate
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
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
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.


