Search Unity

How can I score system for 2d game

Discussion in 'Getting Started' started by gstahsn, Jan 21, 2015.

  1. gstahsn

    gstahsn

    Joined:
    Dec 26, 2014
    Posts:
    11
    Hi. I have two objects named stick. (stickLeft and stickUp) . I have two objects and I apply this to my scripts. (stickLeftScripts and stickUpScripts) .

    The purpose of the script, the pictures clicked scoretext addition to 5 points. (This images names LeftButtonImage and UpButtonImage).

    But UpButtonImage runs when LeftButtonImage don't work.
    But stickUpScripts was disable when stickLeftScripts worked.

    Note !! Sticks are controlled through pictures
     
  2. DustyMcp

    DustyMcp

    Joined:
    May 23, 2013
    Posts:
    25
    You could have a manager object in your scene and attach a script onto that.
    Code (CSharp):
    1. public static int score;
    2.  
    3. void Start() {
    4. score = 0;
    5. }
    6.  
    7.  
    Now if you want to add points you can access the manager script with
    Code (CSharp):
    1. scriptName.score++;
    2. scriptName.score += 2;
    3. scriptName.score = variable;
    4.  
    And add any number to it and it will hold the number until the scene ends.

    Hope it made sense good luck!