Change Actor images

Hello,

I'm beginner with GS, I created an actor that change it's color to 5 different colors, I have few issues with this ,
first of all I would like the image of the color to change in sequence and repeat this cycle again, I don't want the white square to appear
second I would like the falling object color to match the color of the actor so it destroy it and when it's not the same color I would like it to game over it, I have done this but the problem is that all the colors doesn't match, even it's the same colors, but the falling ball, I'm pretty sure I have done it quite well, but the problem is with the actor itself, I would like the actor to know the match correct color of the falling ball

Comments

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

    How are you changing the color of the actor? Are you using imported images or the actors' self.Color.____ attributes?

    What behavior(s) are you using to change the color?

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

  • Pirate OSPirate OS Member Posts: 8

    real attribute with imported colors, the actor is plain shape, as square, I just need to change the square color so it matches the ball falling color

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

    Okay so you made the graphics in a third-party program (e.g. Photoshop) and imported them in? And now you want another actor's color to match the color of the imported graphic? If so, you'd need the RGB color values for the imported graphic. You can then set them to be the same on the square actor using Change Attribute self.Color.Red to _____, self.Color.Green to _____, and self.Color.Blue to _____.

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

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

    Here's what it looks like in Photoshop:

    And here's what it looks like in GameSalad (note that you can change it using the actor's RGB sliders or using Change Attribute behaviors):

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

  • Pirate OSPirate OS Member Posts: 8
    edited May 2017

    you didn't get what I'm trying to explain , this is what I'm doing.

    http://imgur.com/a/tVk4z

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

    I think I get it but I don't see where you're setting the value of game.Color. One point I'd make is that although you're working with colors, your question is really: "why don't the numbers match?" Because you're assigning color values as integers. GameSalad isn't comparing colors at all, it's comparing those integers.

    Have you set up DisplayText to watch the values of your actor attributes and game.Color to see if they are what you think they should be? You can also use Log Debugging Statements at key points in your rules (open the Debugging Window) to see those values.

    If you're stuck and don't mind posting a link to download your project file (.zip it first), I can take a look at it for you.

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

  • Pirate OSPirate OS Member Posts: 8
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited May 2017

    In the Wheel actor, you're changing self.Image to self.CurrentWheelColor+1 and since that attribute has a random value from 1 to 5, self.Image is going to be 2, 3, 4, 5, or 6. The reason you're getting a white square for that actor is because 6.png isn't a valid image file in your Library. So you either need to change the range of values for that actor's image or import an image named 6.png.

    In that same actor, the every 0 Timer is basically creating a constraint so why not just do Constrain Attribute self.currentWheelColor to game.Color? Then again, those two rules conflict with each other... the first one is setting self.currentWheelColor to a value form 1 to 6 and the second is constantly setting self.currentWheelColor to game.Color. Which are you trying to do? Personally, I don't think you need the Timer/constraint at all.

    I still don't see anywhere you're changing the value of game.Color. Whichever actor is supposed to set the color (e.g. by picking a random number) should also change game.Color to that value. I assume that's the Wheel actor. If so, then in the first mouse is down rule, you'd need to change attribute game.Color to self.currentWheelColor right after you change/set the value of self.currentWheelColor.

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

  • SocksSocks London, UK.Member Posts: 12,822

    @tatiang said:
    In the Wheel actor, you're changing self.Image to self.CurrentWheelColor+1 and since that attribute has a random value from 1 to 5, self.Image is going to be 2, 3, 4, 5, or 6. The reason you're getting a white square for that actor is because 6.png isn't a valid image file in your Library. So you either need to change the range of values for that actor's image or import an image named 6.png.

    . . . or stick a modulus function in there somewhere ?

    In that same actor, the every 0 Timer is basically creating a constraint

    That's how I see an 'Every 0 seconds' Timer too, basically a poor man's Constrain behaviour, in fact it's not even as good as a Constrain behaviour in that it only fires once every two frames (30fps), so it's half as accurate as a Constrain ! ;)

    (not sure why I put a winking emoticon, it's not the right sort of comment to warrant a winking emoticon, but it's done now and there's no going back).

  • Pirate OSPirate OS Member Posts: 8

    Sorry, but I'm trying to do, I'm trying to get rid of the random and do it in sequence , I would like the colors to appear as follows, 1,2,3,4,5, and that's it, I don't have six and I don't want,
    the other thing is that I want the ball of the color match the wheel color so it destroy it and considered one point score, and I would like it when the ball colors doesn't match the wheel colors the game over is true, and I would like the player to change wheel color so it matches the ball falling colors, but I would like it in sequence, so color number 1 then 2 then 3 then 4 then 5 and then again 1, then 2 and so on, hopefully you get me now

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

    To increase the value sequentially and repeat, use this:

    Change Attribute self.CurrentWheelColor to mod(self.CurrentWheelColor,5)+1

    The mod() function, also symbolized as %, returns the remainder of a division so...

    1%5=1
    2%5=2
    3%5=3
    4%5=4
    5%5=0

    and then you add one so you're getting a value one higher except when self.CurrentWheelColor is 5, then you're getting 1 again and the whole thing starts over.

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

  • Pirate OSPirate OS Member Posts: 8

    okay I did that, and it's fantastic method, but how can I let the color of the ball matches the colors of the wheel !! sorry , but I'm new to GS, and by the way there is something wrong with the coding, the wheel doesn't change its color when I did you change attribute !

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

    The code for the wheel would look something like this:

    When Touch is Pressed
         Change Attribute self.CurrentWheelColor to mod(self.CurrentWheelColor,5)+1
         Change Attribute self.Image to self.CurrentWheelColor
         Change Attribute game.Color to self.CurrentWheelColor

    And for the ball, it would be similar but without the last change attribute behavior.

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

  • Pirate OSPirate OS Member Posts: 8

    WoooooooW man, fantastic

Sign In or Register to comment.