A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: [BETA][PROBLEM]Cannot get lives variable to function properly!

  1. #1
    Member
    Join Date
    Jan 2005
    Posts
    60

    [BETA][PROBLEM]Cannot get lives variable to function properly!

    I'm trying to make it so in my game, when variable lives < 0, it goes to frame three.
    http://img235.exs.cx/my.php?loc=img2...terspace8o.swf
    (Arrow keys, space to fire, and 700 score=1 life)
    I've tried many things, such as
    if (_root.lives<0){
    gotoAndPlay(3)
    }
    if(_root.lives<0){
    gotoAndPlay("gameover")
    }
    if(lives==-1)
    gotoAndPlay(3)
    }
    And many other combinations, but it JUST doesn't work!

    Can someone PLEASE help me very soon?

  2. #2
    my x booty it is that BIG
    Join Date
    Jun 2004
    Location
    New York
    Posts
    696
    replace this
    code:

    if (_root.lives<0){
    gotoAndPlay(3)
    }
    if(_root.lives<0){
    gotoAndPlay("gameover")
    }
    if(lives==-1)
    gotoAndPlay(3)
    }


    with this
    code:

    if (_root.lives<=0){
    gotoAndPlay(3)
    }
    if(_root.lives<=0){
    gotoAndPlay("gameover")
    }


    and if frame 3 is the same frame as the gameover frame

    code:

    if (_root.lives<=0){
    gotoAndPlay(3)
    }

    Project||[GAME]-on hold for now
    ------------------
    [Hero]-80%
    [Enemies]-1%
    [Weapons]-90%
    [Items]-0%
    [Levels]-10%

  3. #3
    Member
    Join Date
    Jan 2005
    Posts
    60
    Yes, I tried that and it still doesn't work. I'm wondering if I should put it in another MC, I put it on the tank one.
    EDIT: I just put it on the ballon MCs, no difference.

    I'm really lost here...
    Last edited by [username here]; 03-13-2005 at 12:10 AM.

  4. #4
    Member
    Join Date
    Jan 2005
    Posts
    60
    *bump* (I'm sorry, but I just have to get this done in a certain time frame, very tight).

  5. #5
    Style Through Simplicity alillm's Avatar
    Join Date
    Mar 2004
    Location
    Wales
    Posts
    1,988
    What are you trying to send to frame 3? are you sending the character to a death animation or are you sending the _root to a game over screen. if your doing that then use
    code:

    if (_root.lives<0) {
    _root.gotoAndStop(3)
    }



    Otherwise im not sure. are you sure the lives variable is on the _root?

    Ali

  6. #6
    Member
    Join Date
    Jan 2005
    Posts
    60
    I've tried that to no avail. It seems it sees frame 1 as frame three, becuase when lives<0, it goes to frame 1. And I've checked everything on frame three to make sure there are no "play" commands to make it go to frame 1.

  7. #7
    Member
    Join Date
    Jan 2005
    Posts
    60
    I just did _root.play() instead of _root.gotoAndPlay and I got it to work. I still don't know why the hell it didn't work, though.

  8. #8
    Style Through Simplicity alillm's Avatar
    Join Date
    Mar 2004
    Location
    Wales
    Posts
    1,988
    Well do you have a stop() command? There is no reason why the code shouldnt work.

    Are you sure your changing the lives variable at all? you might just be changing the text display. try putting
    code:

    if (_root.lives <0) {
    trace (_root.lives)
    }


    if that doesnt work then the lives variable isnt working.

    Ali

    [edit]
    didnt see last post

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