A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: variable changing

  1. #1
    The next Squaresoft
    Join Date
    Sep 2004
    Location
    Zanarkand
    Posts
    215

    variable changing

    yes, as easy as it looks, im having prblems!

    you see, i put in a frame that covers the entire battle
    scene the general variable( HP = 100

    then on a certain frame(like frame 3)
    it reduces the HP amount by 5( HP-=5

    then, on the same general frame, the one with HP = 100
    i put in an if script that detects if HP<=0;
    then it goes to frame 5(you lose)

    but i doesnt work! soes it work only on MCs or did i miss
    a lot?
    "Are those gummy worms? Can I have some?"

    "Nevermind, I just saw one move by itself..."

  2. #2
    Member
    Join Date
    Oct 2003
    Location
    Finland
    Posts
    84
    You'll have to check "if (HP<=0);" every frame. Right now it checks it one time, (unless the frame with the condition is played several times) when you've just set HP to 100.

    Instead either use a frame loop, or put the condition into an onEnterFrame, e.g.

    code:

    _root.onEnterFrame=function(){
    if(HP<=0){
    _root.gotoAndStop(5)
    }
    }


  3. #3
    The next Squaresoft
    Join Date
    Sep 2004
    Location
    Zanarkand
    Posts
    215
    hmmm you see,

    i put the HP=100 on my first frame, and so is the HP<=0

    now when i attack, it goes to frame 3 and reduces HP by 5

    after that attck, it goes back again to my first frame

    so, maybe its just my scripting?
    "Are those gummy worms? Can I have some?"

    "Nevermind, I just saw one move by itself..."

  4. #4
    Member
    Join Date
    Oct 2003
    Location
    Finland
    Posts
    84
    Originally posted by Zirclesoft
    hmmm you see,

    i put the HP=100 on my first frame, and so is the HP<=0

    now when i attack, it goes to frame 3 and reduces HP by 5

    after that attck, it goes back again to my first frame

    so, maybe its just my scripting?

    Wouldn't that put your HP back at 100 since you set it to 100 on the same frame as your condition. So your HP would go; 100 then 95 then 100 again, then 95 etc...

  5. #5
    The next Squaresoft
    Join Date
    Sep 2004
    Location
    Zanarkand
    Posts
    215
    yeah, i just found out about that,

    but if i seperate it, the frame will go automatically
    to frame 5!

    how do you seperate it safely?
    "Are those gummy worms? Can I have some?"

    "Nevermind, I just saw one move by itself..."

  6. #6
    Member
    Join Date
    Oct 2003
    Location
    Finland
    Posts
    84
    I made this example:
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center