A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Help with Health Bar

  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    2

    Unhappy Help with Health Bar

    Hello i'm new to this site and is seeing if anyone could help me with this problem..
    I am making a platformer which you use the arrow keys to move. My problem is the health bar, it works perfectly fine but, when the bar reaches zero i can't make it go to a game over frame.... Here is all of the code:

    Health Bar: (Instance name: HP)
    onClipEvent(enterFrame){
    this._xscale = _root.hp;
    if(_root.hp < 0){
    _root.hp = 0;
    }
    }


    Frame:
    Stop()
    _root.hp = 100;


    If someone could help me with this i would really appreciate it. (I have been stuck on this for a couple months now)

  2. #2
    Senior Member
    Join Date
    Sep 2004
    Posts
    633
    what about simple gotoAndStop(gameOverFrame); ?

    You may want to use function onEnterFrame() {
    game code here
    }

    on a frame on the main timeline instead on a movie clip. Possibly wrap everything within if (gameover == 0) { } ( inside that onEnterFrame function )

    then when helath bar reaches 0, set gameover = 1, and do gotoAndStop( gameOverFrame); and don't forget to set variable gameover = 0; before onEnterFrame function.

  3. #3
    Senior Member
    Join Date
    Nov 2007
    Location
    California
    Posts
    118
    Gj Mikemd :P you stole my response no hero points for me

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