How can I use an array to keep the score for many layouts?

0 favourites
  • 5 posts
From the Asset Store
Create the right kind of drama with Film Scoring Tools sound library!
  • I don't really understand arrays that much. All I know is, they allow information to be transfered between different layouts and event sheets, unlike global variables, which are limited to just the event sheet they are on. I am trying to keep the score going for the game as the player progresses through each layout/level. I use a text to display the score. When he gets to level 2, how do I tell it to use level 1's "Score" global variable's information and transfer it to level 2? And same for other levels, I would like to make level 3 use either level 1 or 2's "Score" global variable. I don't know how I would do that. I made separate score variables for each level. i.e. "Score" for layout 1/level 1, "Score 2" for layout 2/level 2, and so on. I tried setting "Score 2"s information to "Score" so it can keep the same score using an array. I don't know. This is how I tried doing it and it didnt work, but then again I don't really understand arrays. Does anyone know how to do this? I would greatly appreciate the help!

  • Create an event sheet called variables. Now put all your variables into that sheet.

    Now whenever you want to use a variable in an event sheet. Include the event sheet called global variables.

    Arrays are the best for data, but totally overkill for something as simple as a variable. Dictionary is better suited as it acts like a variable, but again overkill.

    Include your global variable event sheet into your level event sheets.

  • I don't really understand arrays that much. All I know is, they allow information to be transfered between different layouts and event sheets, unlike global variables, which are limited to just the event sheet they are on.

    are you sure?

    Global variables store their values between layouts. Events in any layout can access any global variable...

    Event Variables

    Arrays are the best for data, but totally overkill for something as simple as a variable....

    Create an event sheet called variables. Now put all your variables into that sheet.

    well...let's say ..I have the 100 levels in the game and want to know the Score for each level...

    I think it's better to have one Array object than 100 Variables...(Level1_Score; Level2_Score;..Level77_Score..)

    ...but I could be wrong..

  • well...let's say ..I have the 100 levels in the game and want to know the Score for each level...

    I think it's better to have one Array object than 100 Variables...(Level1_Score; Level2_Score;..Level77_Score..)

    ...but I could be wrong..

    Well in this situation a array would be best. I under the impression OP wanted to carry level 1 score to level 2 to level 3 etc.

    But, if he wants to store a score for each level then array would be best.

    Store level / score

    Array Push back "Score" on X axis

    Array Set value at (array.width-1, 1) to level

    Array set value at (array.width-1, 2) to score

    Fetch Level / score

    Array for each x element

    System compare array.at(array.curx) = "Score"

    System compare array.at(array.curx,1) = level

    Add action to return score so set text array.at(array.curx,2)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Well...I might have been misguided with

    I made separate score variables for each level. i.e. "Score" for layout 1/level 1, "Score 2" for layout 2/level 2, and so on. ...

    ..it would be best to Os better explain his problem, now that he knows that the global variable are global.. not "limited to the event sheet they are on"...it may be enough only one variable Score for all levels

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)