Change Attribute using button

chrisalchrisal Member Posts: 74
edited November -1 in Working with GS (Mac)
Hi,

This is my first post on here, and before i begin I would like to thank you all for he how to's and all the info on the forums, and thanks for such a great games engine...

OK so here goes, I have spent a while on this but can not find a solution.

I would like to change another actors attribute by the pressing of a button, ie pic, colour, size.
I have seen Weswog's tutorial drawing with colours
http://gamesalad.com/game/play/38606
(it is the sort of thing I am trying to achieve), but when I try to download it, it sends me a chess game. Does anybody know any good tutorials for this.

Many Thanks in advance
Chris

Comments

  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    when you download the file change the extension....(I think to .zip)

    otherwise yes they will open up in Chess for some reason. (Chess comes with all Macs).

    As for changing attributes, (it varies a little depending n exactly what you want to do)

    Lots of info in the support section, try here:
    http://gamesalad.com/wiki/how_tos:gsc_use_attributes

    also do a search on the forum, keep changing the wording til you find what you want, you can use the magnifying glass in the top right to search (if you'd not already seen it).

    ...basics for a toggle button:

    .................

    make a game attribute (lets choose 'boolean') and name it 'actor_button_value'.

    then on your button add a rule, (this is your toggle button)
    if touch = pressed
    change attribute 'game.actor_button_value' to '(game.actor_button_value+1)%2'

    Then on your other actor, add a rule,

    Rule:
    if attrbute game.actor_button_value = 1
    Change attribute ??? to ???

    and in the 'other' box which drops down,

    add a rule,

    if attribute game.actor_button_value = 0
    Change attribute ??? to ???? (back to original value)

    .................

    Hope that is of some use.
  • BarkBarkCoBarkBarkCo Member Posts: 1,400
    draper3000,

    That "change" expression works on a boolean attribute? I could have sworn that I did something like that and it worked, but then I read somewhere on the forum that said GS's boolean is not "bitwise", and that you have to use `true` and `false`...

    If that does work, the only advantage to using an integer to store the "state" of a variable is that you get access to more than 2 options (on/off). Of course, there is still the issue of the extra memory an integer requires...
  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    yeah agree with barkbark, edit what I said, use integer....my bad....
  • chrisalchrisal Member Posts: 74
    Thank you so much for the info, I managed last night to get over the first hurdle and now I can start experimenting.

    Gamesalad is just so addictive.

    Cheers
    Chris
Sign In or Register to comment.