Colouring in GS

20041842004184 Member Posts: 14
edited November -1 in Working with GS (Mac)
I've been looking everywhere to find the solution, but didn't find anything yet.

I've created a game in which you need to fill actors with a certain colour. You can pick the colour in the colourmenu. I want this: if you click on a colour, and after that you click on the actor, that the actor becomes the colour you clicked on. I saw several games with something like this in it, but I can't figure out how to do this in GameSalad!
Hope someone is willing to help me, many thanks in advance!

- Mareille

Comments

  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    http://gamesalad.com/game/play/1534
    You can download my project there. Pretty much, one or more actors control game attributes for Red/Green/Blue values (which are real type values between 0 and 1), and your actor uses those game attributes to change its own color attributes.
  • 20041842004184 Member Posts: 14
    You guys are great, I'll look at it later!!
    Many thanks!
  • 20041842004184 Member Posts: 14
    I tried what you said, tshirtbooth, but now when I click on my actor that needs to change, it just changes. I don't need to click on the red actor first. Did I do something wrong? I added a rule to my change-actor which says, when touch is pressed AND when game.changecolour = 1, change image. And to do that AND-part, I just clicked the plus-sign next to the 'touch is pressed' rule, so that the game.changecolour = 1 came beneath it. Is that the right way to do it? Or did I do something else wrong?
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    if game.changecolour is an integer and 1=red and 2=pink and 3=seafoam green ... then your rule in the character will always be "active" because that game.changecolour will always equal something. So I would just make it so that when the app starts, color number 1 is already selected (however you plan to show that visually) so that a person knows what will happen if they don't select a different color. So if 1=red then have the red color selector button highlighted or already pushed in.
  • 20041842004184 Member Posts: 14
    Yeah that was my plan too, to do it with integers. Now I have given all my colour-actors a rule which says when mousebutton is down, change attribute to 1 (or 2,3,4 ..... 9). And on the actor that is supposed to get the colour chosen, I created a rule which says: when touch is pressed, change image to red image (or orange or yellow etc.). But that doesn't work in one way or another.. I can't figure out what I've done wrong..
  • 20041842004184 Member Posts: 14
    Someone who can help me please??
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Your rule in the in the actor to be colored needs to say

    RULE (ALL)
    when touch is pressed
    attribute game.color = 1

    change attribute self.color to whatever

    RULE (ALL)
    when touch is pressed
    attribute game.color = 2

    change attribute self.color to whatever

    and so on for each color and in each actor to be colored. Lot of rules but it should work.
  • 20041842004184 Member Posts: 14
    Yeah I tried that I think.. But it doesn't work. When I click on the t-shirt it just turns red, I don't need to click on the colour red first.. And other colours don't work too.. My actor, that needs to be coloured, contains rules which contain behaviors which change the image of the actor. When touch is pressed and game.changecolour = 1, image changes..
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    My advice is to figure it out by simplifying as much as possible. Create a new project. import two different images. create a game attribute (integer) called colortest or something.

    In the actor have a rule that says

    Rule (ALL)
    when touch is pressed
    when attribute game.colortest = 1
    change image to image1

    ----------

    Rule (ALL)
    when touch is pressed
    when attribute game.colortest = 2
    change image to image2

    Then drop this in a scene. Go into the attributes and manually set colortest to 1.

    Then preview it and click on the actor. Does image1 appear?

    Go back into the attributes manually change it 2. Preview it. Click on the actor does image2 show up? This will tell you if the above rules are correct. If this works than something else is wrong in your app.

    The other thing to try in the project you are working on is to have an actor that has a text display behavior and have it display the game integer attribute you are using. does it show the game attribute correctly when you select a color? maybe your color selection rules aren't correct?
  • 20041842004184 Member Posts: 14
    Can you change your attribute only once? Because I tried the things you said, with the text display, and when I click on red, the game.changecolour attribute changes to one. But when I click on orange, the attribute doesn't change to two, while the rules are exactly the same..
    Oh and thanks for all your help so far!
  • 20041842004184 Member Posts: 14
    And when I click the first time on e.g. orange, the attribute changes to 1 too, instead to 2! I checked my game.changecolour attribute, and it's really a integer-type. That must be correct right?
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    What exactly does the rule say?

    When touched is pressed
    change attribute game.changecolor to 2
  • 20041842004184 Member Posts: 14
    It works!!!! Omg I'm so happy it finally works! Indeed, I needed to change the mousebutton is down into when touch is pressed!!!
    Thank you so, so much!!
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    no problem. Mouse button down always needs to be paired with mouse position inside. Touch is pressed doesn't need to be paired with anything and when you put it on the web it works the same as mouse down/inside so I have pretty much stopped using mouse rules at all (even for web games)
Sign In or Register to comment.