Questionaire. Please help!!

natclarkenatclarke Brisbane, AustraliaMember, PRO Posts: 243
I am creating a quiz with 10 questions and scenes.

On each scene there are three buttons to press for the answer. Button 1 (10 Points), Button 2 (5 Points) & Button 3 (0 points)

How do you total up the score on the final page to show a final total out of 100 (%)

What attributes are required so that it works well?

Thanks for your help.

Nat Clarke
Life Cleansing

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    You keep track of the score with a game attribute such as game.Score (type integer or index). Each time the player answers correctly, do Change Attribute game.Score to game.Score+[button value].

    On the final page, add an actor with a DisplayText behavior, click on the expression editor (the 'e' button) and type this: floor(game.Score/game.PossiblePoints*100).

    You can substitute an actual number for game.PossiblePoints if you prefer. Floor rounds the number down, while Ceil rounds it up. You can also concatenate a percent symbol by typing the formula above and adding .."%" after it (include those two periods).

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • natclarkenatclarke Brisbane, AustraliaMember, PRO Posts: 243
    Thank you. It works great!

    Nat Clarke
    Life Cleansing

  • natclarkenatclarke Brisbane, AustraliaMember, PRO Posts: 243
    Are there any attributes that I need to add to stop two buttons being pressed at the same time?

    Nat Clarke
    Life Cleansing

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    You can check the value of game.devices.touches and only allow a guess if it is equal to one.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • natclarkenatclarke Brisbane, AustraliaMember, PRO Posts: 243
    Not sure how to :
    You can check the value of game.devices.touches and only allow a guess if it is equal to one.

    Where do you go? Is it under devices? Do I need to add a new attribute?

    thanks
    Nat

    Nat Clarke
    Life Cleansing

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Sorry, I was doing that from memory as I wasn't at my computer. Yes, it's under devices and it's actually called game.Touches.Count. You do not need to add an attribute, as this one is built-in.

    The rule would be:
    When [All] conditions are valid
    .....Touch is Pressed
    .....attribute game.Touches.Count = 1
    ..........[check for correct answer]

    Keep in mind that if the player taps the correct answer while touching some other part of the screen (not another incorrect answer), that rule will not run and nothing will happen. That's somewhat unlikely to happen, but it's certainly possible.

    If you want a tighter rule, you might do something like:
    [create an attribute game.numberOfTouches (index or integer) and set it to 3
    When Touch is Pressed
    .....change attribute game.numberOfTouches (integer/index) to game.numberOfTouches+1
    Otherwise
    .....change attribute game.numberOfTouches to game.numberOfTouches-1.
    When [All] conditions are valid
    .....Touch is Pressed
    .....game.numberOfTouches=1
    ..........[check for correct answer]


    *The reason that the attribute is set to 3 initially is because each actor is subtracting 1 when not touched, so when no actors are touched, the value of that attribute is 3-3=0. When one actor is touched, 3-2=1; when two actors are touched, 3-1=2; when three actors are touched, 3-3=0.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • natclarkenatclarke Brisbane, AustraliaMember, PRO Posts: 243
    Hi. Thanks for your help. I have added most of it but having challenge in the tighter rule with:

    When [All] conditions are valid
    .....Touch is Pressed
    .....game.numberOfTouches=1
    ..........[check for correct answer]


    I can not find under attributes when touch is pressed or check for the correct answer. Do I have to create an attribute for these?

    Nat Clarke
    Life Cleansing

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited January 2013
    image

    [check for correct answer] is where your code goes. And yes, you would need to create at least one attribute. If this is your first app with GameSalad, you might want to start with someone a bit simpler until you have the basics down (e.g. Touch conditions).

    My tutorials may be of help: http://tinyurl.com/GameSaladTutorials, as well as the Cookbook and GSHelper.com tutorials.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Sign In or Register to comment.