Forum Topic: Carry over HP value to next frame

(103 views • 6 replies)

This topic is 1 page long.

<< < > >>
None

RustySpoons95

Reply To Post Reply & Quote

Posted at: 10/13/09 10:14 PM

RustySpoons95 EVIL LEVEL 03

Sign-Up: 05/31/07

Posts: 64

So basically, my code detects a button press, takes one away from 400 (max hp var), and decreases hp bar size. Since actions for it say HP = 400 on load frame, it resets. How can I modify script in second frame so it carries over HP value to next frame?

This post was made using Linux.

BBS Signature

None

jfig111

Reply To Post Reply & Quote

Posted at: 10/13/09 10:26 PM

jfig111 LIGHT LEVEL 10

Sign-Up: 03/17/07

Posts: 52

At 10/13/09 10:14 PM, RustySpoons95 wrote: So basically, my code detects a button press, takes one away from 400 (max hp var), and decreases hp bar size. Since actions for it say HP = 400 on load frame, it resets. How can I modify script in second frame so it carries over HP value to next frame?

Use _global variables.

e.g.

_global.hp=100;


None

Yambanshee

Reply To Post Reply & Quote

Posted at: 10/13/09 11:49 PM

Yambanshee DARK LEVEL 11

Sign-Up: 10/05/08

Posts: 1,608

i usually just do

if(HP == undefined){
var hp:Number = 400
}

AS2||AS3||Motox
Thanks to hdxmike for the sig :]

BBS Signature

Resigned

hdxmike

Reply To Post Reply & Quote

Posted at: 10/14/09 06:47 AM

hdxmike LIGHT LEVEL 09

Sign-Up: 09/11/09

Posts: 1,840

At 10/13/09 11:49 PM, Yambanshee wrote: i usually just do

if(HP == undefined){
var hp:Number = 400
}

Wouldnt that have the same effect as resseting ?
_global variables or work in one frame

OOP AS3 || Flash 8,CS3,CS4 || *sigh* || The new forum on the block : FLASH SEED !

BBS Signature

None

Yambanshee

Reply To Post Reply & Quote

Posted at: 10/14/09 07:40 AM

Yambanshee DARK LEVEL 11

Sign-Up: 10/05/08

Posts: 1,608

At 10/14/09 06:47 AM, hdxmike wrote:
At 10/13/09 11:49 PM, Yambanshee wrote: i usually just do

if(HP == undefined){
var hp:Number = 400
}
Wouldnt that have the same effect as resseting ?
_global variables or work in one frame

oops, forgot the caps on the second variable. Once its defined as a variable, it will never again be undefined

AS2||AS3||Motox
Thanks to hdxmike for the sig :]

BBS Signature

None

hdxmike

Reply To Post Reply & Quote

Posted at: 10/14/09 08:00 AM

hdxmike LIGHT LEVEL 09

Sign-Up: 09/11/09

Posts: 1,840

At 10/14/09 07:40 AM, Yambanshee wrote:
At 10/14/09 06:47 AM, hdxmike wrote:
At 10/13/09 11:49 PM, Yambanshee wrote: i usually just do

if(HP == undefined){
var hp:Number = 400
}
Wouldnt that have the same effect as resseting ?
_global variables or work in one frame
oops, forgot the caps on the second variable. Once its defined as a variable, it will never again be undefined

i suggest keeping one layer for the constant code
or in AS3 just set it as a constant variable
const myVar:int = 12345

OOP AS3 || Flash 8,CS3,CS4 || *sigh* || The new forum on the block : FLASH SEED !

BBS Signature

None

KaynSlamdyke

Reply To Post Reply & Quote

Posted at: 10/14/09 08:12 AM

KaynSlamdyke LIGHT LEVEL 16

Sign-Up: 06/25/04

Posts: 4,926

At 10/14/09 08:00 AM, hdxmike wrote: or in AS3 just set it as a constant variable
const myVar:int = 12345

Oh wow. That totally works.
If you NEVER want to change a HP value throughout the game.

Current build for ThreedeeTiles : Monkey
Previous: Lamprey, Mountain Goat (Dead Fork)


All times are Eastern Standard Time (GMT -5) | Current Time: 01:59 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!