Flash Advisor logo
:: Desktop Shortcut
:: Flash Help
Advice from Experts

Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1

    Default Tracking user score in a game....

    Hi i am making a simple word game in flash and would like to know how do i track the users score through this game?

    when the user gets a correct answer it must increase by 10 and when incorrects decrease by 5.......

    thankyou

  2. # ADS
    Join Date
    Always
    Posts
    Many
     
  3. #2
    Join Date
    May 2004
    Location
    U.S.A.
    Posts
    2,890

    Default

    Hi,

    Without a better description of how the game works, it is hard to suggest a way to score. Will the scoreing be done with an onRelease event or how do you determine when to add and when to subtract from the score? One method is to toggle a boolean variable....
    Code:
    correct = true;
    score = 0;
    myButton.onRelease=function(){
    if (correct){
    score+= 10;
    }else{
    score-=5;
    }
    }
    Then toggle the "correct" variable to true or false depending on game play.

  4. #3

    Default game...

    the game is a simple crossword and on a correct answer it will use the "goto" to a different layer and it will be done on the click of a button.

    so if the answer is correct it will go to the right screen and if incorrect it will go to the wrong screen through the use of the "goto" and "If Else " command used to set the condition.

    What i basically need help on is how do i make a counter so when it goes to the right screen it goes up by 10 always and when wrong it goes down by ten. Also this counter has to be made visible on every screen. If i use a text box with the same name in every screen will this stay constant and update on a right and wrong answer?

    thankyou for your help

  5. #4
    Join Date
    May 2004
    Location
    U.S.A.
    Posts
    2,890

    Default

    Hi,

    The code I posted should work, it just needs to be called from the correct place. How are you determining what is a correct answer and what is an incorrect answer? Once you have that established, it is just a matter of passing true or false to the boolean variable "correct".
    Code:
    correct = ""; 
    score = 0; 
    myButton.onRelease=function(){ 
    //if correct = true, add 10 points
    if (correct){ 
    score+= 10; 
    }else{ 
    //correct is not true, subtract 10 points
    score-=10; 
    } 
    }
    It could be coded into a function that can be called from a button. Maybe something like this.....

    Code:
    ckScore = function () {
    	if (correct) {
    		// if correct = true, add 10 points
    		score += 10;
    	} else {
    		// correct is not true, subtract 10 points
    		score -= 10;
    	}
    }
    myButton.onRelease = function() {
    	if (answer == correctAnswer) {
    		correct = true;
    	} else {
    		correct = false;
    	}
    	ckScore();
    }
    Kind of shooting in the dark here. Maybe post some code on how you are determining if the answer is correct or incorrect. Once you have that established, adding or subtracting the score is relativly easy. Instead of using a textfield with the same name on different scenes, it might be easier to use a movieclip with an onEnterFrame event that will keep the score updated every frame.

  6. #5

    Default tracking user game score

    hi thanks for your reply's......i am new user to flash and the aim of this game is not very complicated. The game is simmilar to a crossword but each question is written on the screen seperatley giving the user clues to the right answer.....the user is given an input box in to which they type the answer and click a "submit" button which will determine if the answer is correct or not.

    the code to take them to a right or wrong screen is written below. This code is for a specific question and the conditions will change for different questions:

    on (press, release) {
    if (inputbox == "roony") {
    gotoAndPlay ("roony");
    } else {
    gotoAndPlay ("Wrong");
    }
    }

    I am using this way for every question....so on a right answer it goes to the "roony" label and if wrong goes to the "wrong label" in the movie.

    I need to know if the code you posted, can i have that set in every button and will that update the score if the answer is right or worng? Also will the name of the dynamic text box i use be the same in every screen if i use this code?

    I really dont know any other way of doing it. Maybe there is a simple other way of doing this but i dont know of it. My flash knowledge is limited and this is the limited info i know in making this game. If there is an easier way please tell me and if i can be cheeky show me how it's done....

    anyway hope the way i have done this the game will work and once i have made the screens i can send you the file so you can see what it's actually doing.

    thankyou

  7. #6
    Join Date
    May 2004
    Location
    U.S.A.
    Posts
    2,890

    Default

    Hi,

    I have to step out for a few. If you post a demo file I will take a look. Pretty sure you just need to increment the score , either with a boolean variable, or possibly on the actual frame that you send the playhead to. For example, if you send the playhead to a "correct" frame, on that frame just add...

    score+=10

    and on the frame that you send the playhead to if it is a wrong answer

    score-=10

    This will increase or decrease the score each time the playhead is sent to the appropriate frame.

    You can also play around with a score variable to see how incrementing it might work....
    pseudo test code
    score=0;
    _root.onMouseDown() {
    _score+=10;
    }

    myMC.onRollOver=function(){
    score-=10;
    }

    myButton.onRelease=function(){
    if(correct==true){
    score+=10;
    }else{
    score-=10;
    }

    Play around with those codes in a test movie to see how incrementing a score might work best.


    NTD

  8. #7

    Default flash file.....

    i tried to send you the source .fla file but i dont think it sent properley....can i send it to another email address??

  9. #8
    Join Date
    May 2004
    Location
    U.S.A.
    Posts
    2,890

    Default

    Hi,
    If your using Flash MX or higher, give your button an instance name and look into frame code instead of object code. Frame code is much easier to organize in one place which allows for easier updating and overall management. The following code also has press and release in the same event. Press will fire the code so the release part is never used....
    Object code on a button...
    Code:
    on (press, release) { 
    if (inputbox == "roony") { 
    gotoAndPlay ("roony"); 
    } else { 
    gotoAndPlay ("Wrong"); 
    } 
    }
    Frame code place on frame 1 of the movie.....

    Code:
    score=0;
    _root.buttonName.onRelease=function(){
    if (inputbox == "roony") { 
    score+=10;
    gotoAndPlay ("roony"); 
    } else { 
    score-=10;
    gotoAndPlay ("Wrong"); 
    } 
    trace(score);
    }

  10. #9

    Default it works!!!

    thanks for your help mate. It works a treat.

  11. #10

    Default

    im making a similar kind of game, using a similar scoring, and this has helped a lot, im just wondering if you can shed light on one more thing -- i'm trying to then print the score out to a textBox of similar at the end of the round... just wondering if you can point me in the right direction with this??

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Animated Graphic Score (Need Help)!
    By Dr_Spankenstein in forum Sound and Music
    Replies: 1
    Last Post: 04-02-2006, 04:26 AM
  2. Score function
    By sji1981 in forum Advanced Flash
    Replies: 2
    Last Post: 10-05-2004, 11:54 PM
  3. End User Help
    By Louise in forum General Flash
    Replies: 1
    Last Post: 08-13-2004, 07:05 PM
  4. Tracking X coordinate
    By Ninchilla in forum Flash Scripting
    Replies: 1
    Last Post: 03-03-2004, 09:01 AM
  5. flash high score board (perl)
    By dave-j in forum Advanced Flash
    Replies: 1
    Last Post: 09-29-2003, 11:30 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Sponsors
Create Speaking Characters for your website and Flash movies. 15 Day Free Trial