how to detect if an attribute image has changed

DigitalCaesarDigitalCaesar Member Posts: 40
edited January 2015 in Working with GS (Mac)

in order to make my game work properly I need to have something that detects in an image or an attribute has changed. Please help.

Comments

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772

    An image in your game won't change unless you tell it to change, so when you tell it to change also update a custom attribute called 'image changed', or whatever you like. Then you can check the status of that attribute when you need too.

  • HopscotchHopscotch Member, PRO Posts: 2,782
    edited January 2015

    @DigitalCaesar, you can query the self.image attribute of an actor. Use it as a text string.

    Rule (Text Expression) self.Image contains "whatever"

    Why do you not set a global attribute at the time when the image changes and act on that?

    Chaining rules (When A happens do B, when B happens do C, etc.) will cause problems down the road, as well as making your game difficult to maintain. It would be better to say when A happens do B and C.

  • DigitalCaesarDigitalCaesar Member Posts: 40

    @Hopscotch‌ what do you mean by global attribute?

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    In GameSalad, global attributes (attributes that can be "seen" by all actors) are called "game attributes." So something like game.Time or game.HasThisHappened (a custom boolean attribute) are available globally.

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

  • DigitalCaesarDigitalCaesar Member Posts: 40

    Ok thanks.

  • DigitalCaesarDigitalCaesar Member Posts: 40

    I was hoping to do something like

    if the image or attribute changes

    and the user does not click any buttons

    then the scene changes to another scene

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Right but do you understand this?

    An image in your game won't change unless you tell it to change

    When you say "if the image changes" what exactly do you mean? Can you explain how your game might work and why an image might change? That will probably help us understand better what you're trying to do.

    As it is, if you have an actor with an image it's never going to change. So what action in your game would cause the image to change? How would you fill in this sentence:

    If __________ then change the actor's image from ___________ to _____________.

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

  • DigitalCaesarDigitalCaesar Member Posts: 40
    edited January 2015

    I made a random number generator and every couple seconds it would change an image. Then the user has to tap the right buttons in order to win the game. Although in my game if the user does tap any buttons then the game keeps going on and the player can win my game by doing nothing.

    Yes I understand the image won't change unless I want it to change, I made the number generator change images according to the integer attribute I gave them.

    Thanks for your help.

  • DigitalCaesarDigitalCaesar Member Posts: 40

    I think to solve that I need a boolean attribute, If user presses button then true if user doesn't press any buttons then false. Like if the attribute or image changes and the boolean is false then you lose.

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

    If I understand correctly, you're saying that if the image changes then the player loses.

    I would do away with the need for a boolean and just use a timer. Something like this:

    Timer every 2 seconds
    Change attribute self.Image to random(1,10)
    Timer after 2 seconds
    Change Scene [You Lose scene]

    So if the player presses a button, should the image stop changing or does the player then have another two seconds to press a button before they lose?

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

  • DigitalCaesarDigitalCaesar Member Posts: 40
    edited January 2015

    The user would have an amount of time to press the correct button or they lose.

    The basics of the game is

    There will be an actor that displays a image.

    If the user does not tap on the correct image in a certain amount of time then the user loses

  • ogreofwartogreofwart Hello Everybody on the Gamesalad Planet. I come in peace, warts'n'all!!! Lancashire UKMember Posts: 281

    So the player has to distinguish if one of multiple actors have changed like a spot the difference game?

  • DigitalCaesarDigitalCaesar Member Posts: 40

    Ok I got it figured out I did some work with the timer idea that @tatiang‌ had and I is up and running. Thanks for Helping!

Sign In or Register to comment.