A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: outcome depending on score AS2.0

  1. #1
    Junior Member
    Join Date
    Aug 2009
    Posts
    19

    outcome depending on score AS2.0

    Hi there,
    Im trying to make a simple game, but I want 3 different endings, depending on the players end score, how can I code the game so that, at the final question, the player is directed to one of 3 endings depending on their score (I have a counter in place)

    Kinda like an
    If score=3000 (or more)
    gotoandplay (ending 1)

    if score=2000-2999
    gotoandplay (ending 2)

    Can anyone explain how I can go about this?

    Thanks in advance!

  2. #2
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    at the final question, the button which makes you continue, or move further, you probably have some sort of code to make it goto and play to another frame. In that code to make the button do something, use this code:

    Actionscript Code:
    if(score >= 3000){
        gotoAndPlay("ending1");
    } else if(score >= 2000 && score <= 2999){
        gotoAndPlay("ending2");
    } else {
        gotoAndPlay("ending3");
    }
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  3. #3
    Junior Member
    Join Date
    Aug 2009
    Posts
    19
    Thank you so much for the help!

  4. #4
    Senior Member
    Join Date
    Jan 2011
    Posts
    171
    You can try this concept:

    Actionscript Code:
    var scoreLimit:Array = new Array({start:2000, end:3000-1}, {start:3000, end:10000-1}, {start:10000, end:20000});
    var prize:Array = new Array("iPod", "iPhone", "iPad");

    function CheckScore(scoreValue) {
        var gameLimit:Array = new Array();
        for (var i = 0; i<scoreLimit.length; i++) {
            if (scoreLimit[i].start>scoreValue || scoreLimit[i].end<scoreValue) {
                gameLimit.push(scoreLimit[i].start+"-"+scoreLimit[i].end);
            } else {
                trace("You won "+prize[i]+" on score value of "+scoreValue);
            }
            if (i == scoreLimit.length-1) {
                for (var j = 0; j<gameLimit.length; j++) {
                    trace(gameLimit[j]);
                }
            }
        }
    }

    CheckScore(10000-1);




    arkitx

Tags for this Thread

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