The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Results 1 to 5 of 5

Thread: score variable link with levels?

  1. #1

    score variable link with levels?

    Hi,
    I'm having a problem with my game. Theres a score system that works fine but I have many levels now and I've noticed that at the begining of each level the score resets. I know it has something to do with the timeline code;
    _root.score = 0;

    I know I need to adjust it but I don't know how?

    I'll need the score from previous level. And also i'll need the same for the lives
    _root.lives = 10;

    please reply! xx

  2. #2
    Jephz's Avatar
    106
    posts
    The Penguin n00b
    Well, usually variables stay the same on each frame unless you change them. Where you put the the _root.score = 0 code? My advice is to put that on the play button so it doesn't interfere with the game.
    Don't you ever, ever, EVER call me a Noob. I mean it!

  3. #3
    You'll need to post more of your code so we can see exactly what is going on. It looks like _root.score = 0; is being set on every frame or inside of a function somewhere but It should only be set once.

  4. #4
    In this scenarios i prefer using a global variable , _global.score=0. But in your case, you must be using a onLoad or such to execute some initialisations and setting the _root.score=0; and thats why the problem arises!!! We, as others said, can't really help much without looking at your code, but till you show us the code, try this:-

    Wherever you have:-
    _root.score=0;

    Replace it with:-
    Code:
    if(not(_root.score>=0))
      _root.score=0;
    but i do suggest you use _global.score instead of _root.score for an increased scope of the variable.
    MY BLOG

    I need a SPRITER who can do pixel arts for an arcade fighter project. If you can help out, please pm me.
    I also need someone who can write simple xml files.


  5. #5
    i use 2 variables : score and levelScore

    you increment score and incremnet levelScore but when levelScore is bigger than than x i go up a level and subtract from levelScore - the game player does not know levelScore exist


    something like this (not tested)
    Code:
    function addScore(){
    score+=scoreAmount;
    score_txt.text=score;
    levelScore+=scoreAmount;
    if(levelScore>200){
    level++;
    levelScore-=200;
    }
    }
    hope this helps

Thread Information

Users Browsing this Thread

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012