dcsimg
A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Dying and death screen?

  1. #1
    Junior Member
    Join Date
    Jul 2009
    Posts
    3

    Dying and death screen?

    Im using Flash 8

    I have a problem. Im trying to make it so that when my character dies, it goes to a "Game Over" screen which I have made. The only problem is no matter how I change the code it does nothing.
    Here is the code:

    if (_root.dead) {
    this.gotoAndStop("dead");

    } else {
    speed *= .85;
    if (dir == "right" && !_root.leftblock.hitTest(this._x+20, this._y, true)) {
    _root.health._x += speed;
    _root.score._x += speed;
    this._x += speed;
    _root._x -= speed;
    }
    Ok so under the if (_root.dead) part is has the this.gotoAndStop("dead");.
    Im not very experienced with actionscript so I tried changing it to gotoAndStop(3); frame 3 on the main timeline being the "Game Over" screen.

    It does not work and trying to google something as specific as this to go with my coding failed.

    Can anyone help?

    Jack

  2. #2
    5+5=55 Schfifty Five's Avatar
    Join Date
    Jun 2006
    Posts
    698
    If you put a trace statement inside the if(_root.dead), does it do anything?

  3. #3
    Junior Member
    Join Date
    Jul 2009
    Posts
    3
    I dont think I have used a trace statement before so I wouldnt know how to put it in :S Sorry

    I just realised that the gotoAndStop(blah); refers to the frames IN the char movieclip. How would I get it to refer to the main timeline?

  4. #4
    5+5=55 Schfifty Five's Avatar
    Join Date
    Jun 2006
    Posts
    698
    By trace I mean something like:

    PHP Code:
    if (_root.dead) {
    trace("Is this working?");
    this.gotoAndStop("dead");
    }
    ... 
    Which will output "Is this working?" to the console depending on whether or not _root.dead is true.
    http://livedocs.adobe.com/flash/8/ma...=00001778.html

    To refer to the main timeline, use _root.gotoAndStop(n);

  5. #5
    Junior Member
    Join Date
    Jul 2009
    Posts
    3
    Ah ok. The Trace statement works, I had loads of "Is this working?" messages pop up.

    I think I will just use the _root.gotoAndStop("over") and bring the screen back to the start.

    Thanks for your help

  6. #6
    Senior Member
    Join Date
    Jun 2009
    Posts
    171
    _root.gotoAndStop(3); //brings you to main timeline at frame 3

    _root.instanceName.gotoAndPlay(5); //brings you within "instanceName" at frame 5

    _root.instanceName.instanceName2.gotoAndPlay(1); //brings you within "instanceName2" at frame 1, which is within "instanceName"

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