Start the score whenever character is clicked

Helloooo!

Okay, so I'm making an endless runner game and have already created a score system. However, instead of it just starting automatically, I want it to start whenever my little character is clicked (in which he takes off vertically upwards - its a space game.) I was just wondering how I'd pair the score with the character? Because right now the score is just rising endlessly on its own.

Many thanks in advance! :blush:

Comments

  • KevinCrossKevinCross London, UKMember Posts: 1,894

    Where you have your score increasing add a rule around it saying if (game.playing = true).

    Then on the character add a rule if (touch is pressed) then set game.playing = true.

    When they die set game.playing = false.

  • GoodnightMoonGoodnightMoon Member Posts: 23

    Hi KevinCross ^_^

    I did as you said and the score is still increasing without the touch of a button!
    When you say to add a rule where my score is, does the rule also have to be 'touched if pressed?'

    I'm super new to this and it's all a bit overwhelming so sorry in advance if I sound derpy haha

    Also, if I attach the timer and display text to the character itself it works well - only problem is, the score is then stuck to the character and now at the top of the screen bahhhhh

  • KevinCrossKevinCross London, UKMember Posts: 1,894
    edited May 2016

    Attaching a screenshot of your score code to this forum post would help see how your score is increasing. Basically I'm saying this:

    Rule: if game.playing = true
    .. (your code that increases the score inside this rule)

    On your player character add this rule:

    Rule: if touch is pressed
    .. Change Attribute: game.playing = true

    Rule: if dead (amend this rule accordingly to activate when they die)
    .. Change Attribute: game.playing = false

    You will of course need amending the rules further to so that as soon as they die they can't just start a new game once they press the character without going to any end of game screens first if that's what you want.

    But that's the basics of it. It uses a game attribute (I've called it "playing" in the above example) and a rule around the code that increases your score to only increase when they're playing

    Also, if I attach the timer and display text to the character itself it works well - only problem is, the score is then stuck to the character and now at the top of the screen bahhhhh

    Are you aware of the differences between a self and game attribute? It sounds like you've got the score saved on an actor as a self attribute so you won't be able to access that from other actors. If it was a game attribute you could have the increasing score code on any actor (including your player)

  • GoodnightMoonGoodnightMoon Member Posts: 23

    Oh gosh I'm obviously doing something very wrong in the process haha

    Okay, so I'll attach a few screenshots of what my setup looks like! And no, I have no idea of the differences between self and game attribute - d'oh! :neutral:

    http://i980.photobucket.com/albums/ae290/Tiglaire/gamesaladd1.png

    http://i980.photobucket.com/albums/ae290/Tiglaire/gamesaladd2.png

  • KevinCrossKevinCross London, UKMember Posts: 1,894
    edited May 2016

    Here's a basic project where you click one actor to start the score. You'll see I have one actor at the bottom (the player) and the score displayed at the top. The score is controlled by the bottom actor.

    This is like a simple stop watch, and the logic behind it would be similar to what you want. A rule around the timer code that only starts when the game has started (game.playing = true)

    I set the project up to tap the bottom actor to stop the score. This would be the equivalent of dieing (i.e. game.playing = false)

  • GoodnightMoonGoodnightMoon Member Posts: 23

    Oh thank you so much! Another noob question errrr how do I open this in Gamesalad? It's just unzipping as a load of files atm?

    And I appreciate all this help, I really do :)

  • KevinCrossKevinCross London, UKMember Posts: 1,894

    And this paragraph from the cookbook might help clarify the differences between the different level of attributes:

    "Attributes exist for your game, your scenes, and your actors. Game attributes can be accessed by all actor prototypes and instances so that they can be seen in any scene. Scene attributes can only be accessed in a particular scene but all actor instances in that scene can individually be edited to view, use, and modify those scene attributes. Actor attributes can only be accessed by an actor instance, but can be initially defined and used in an actor prototype so that all instance of that prototype can have predefined behaviors."

    http://help.gamesalad.com/gamesalad-cookbook/2-making-it-better/2-01-attributes-in-gamesalad/

  • KevinCrossKevinCross London, UKMember Posts: 1,894

    @GoodnightMoon said:
    Oh thank you so much! Another noob question errrr how do I open this in Gamesalad? It's just unzipping as a load of files atm?

    And I appreciate all this help, I really do :)

    Try adding .gameproj at the end of the folder name if you're opening on a Mac. I put this together in the Windows version.

Sign In or Register to comment.