Interpolating with the color red

BasGoodboyBasGoodboy Member, PRO Posts: 310
Hey guys,

I want to interpolate an actor when he gets hit to color red, but if i do set self-color to red, with value 0, the actor gets green?!!

What should I do to fix this?

Goodboi Gamestudios | Monster Jumper now on the App Store

Comments

  • KevinCrossKevinCross London, UKMember Posts: 1,894
    edited September 2013
    You want red as 1 and green and blue as 0.

    1 in GameSalad is the equivalent of 255 value you're probably use to seeing in art programs. 0.5 in GameSalad would be 127.5
  • BasGoodboyBasGoodboy Member, PRO Posts: 310
    Ahhhhh thats awesome. Thanks!

    Goodboi Gamestudios | Monster Jumper now on the App Store

  • BasGoodboyBasGoodboy Member, PRO Posts: 310
    And just a quick question, the red is perfect now, but after 1 second I want the original colors of the actor back. I already tried:

    When actor is hit, set game.mobhitcolor to 1

    If attribute game.mobhitcolor = 1
    (timer)for one second:
    interpolate actor (going red)

    But after the second the color overlay won't fade away.

    So i did change attribute back to game.mobhitcolor to 0.

    How should i set mobhitcolor=0 to get original colors actor back?

    Goodboi Gamestudios | Monster Jumper now on the App Store

  • KevinCrossKevinCross London, UKMember Posts: 1,894
    Add a timer after the timer you already have to activate after 1 second and put in your fade away interpolate in that, that might work. There's probably cleaner ways.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited September 2013

    Hi @BasGoodBoy

    A couple of comments first:

    • Unless you need that attribute mobhitcolor for something else, you don't need it at all to trigger the colour change if you're using overlaps or collides Rule

    • If you're using Interpolate to change the colour back, this includes a timer so you don't need a separate Timer behaviour

    • You didn't mention what the original colour of the actor is, so for the example below, I've assumed it's white.

    Rule: When Actor overlaps or collides with BaddyActor
    Change Attribute self.Color.Green to 0
    Change Attribute self.Color.Blue to 0
    Interpolate self.Color.Green to 1 Duration:1
    Interpolate self.Color.Blue to 1 Duration:1

    Hope that helps.

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • BasGoodboyBasGoodboy Member, PRO Posts: 310
    @KevinCross how do i put in the 'fade-away' you're talking about. Is it also an interpolate attribute? Can't find it.
    I really want to know how I can use interpolate to change the original colors back.

    @gyroscope the original colors are just colorful pixelarted chars, and there are different chars which spawn random to be fought with, so can't really answer on that.

    Goodboi Gamestudios | Monster Jumper now on the App Store

  • KevinCrossKevinCross London, UKMember Posts: 1,894
    Where you've got the interpolate to turn it red add something like this:

    Timer after 1 second
    Interpolate colours back to original ones (fade away)

    So:

    Interpolate: red
    Timer: After 1 second
    ..Interpolate: fade red away

    I've added dots to show interpolate is nested inside the timer

  • KevinCrossKevinCross London, UKMember Posts: 1,894
    You'll find with interpolate that it doesn't wait until it has finished before it moves down to the next bit of code, that's why I'm suggesting a timer that starts after x amount of time to fade away. Play around with the timer number to get the effect you want.
  • BasGoodboyBasGoodboy Member, PRO Posts: 310
    I might be a dummy, but idk haha.. I get your story, definately very logic, but how the hell should I get my interpole attribute to color back to original colors.
    Is it red, blue, green color to 1 or 2 or how can i do this.

    If I insert an interpole attribute, it says this:

    INTERPOLATE ATTRIBUTE: so here i put self.color.red TO ...
    DURATION:
    FUNCTION: Linear or Ease in or Ease out or Ease in/out

    So where can I set the coming back of original colors?

    Goodboi Gamestudios | Monster Jumper now on the App Store

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited September 2013

    I'll explain a bit more: any actor (even with an image) whose colour is white, has red, green and blue all set to 1. This "colour" white doesn't actually appear over the image (but does show if the actor doesn't have an image).

    You want a red colour overlaid on your graphics numbers when they collide. A red colour is made by changing the Green and the Blue to 0.

    When you want to fade back to the original colour (i.e "no colour" white on an image) you simply have to make the colours you changed back to 1 again. Interpolate is a great behaviour for changing an attribute over time. Because you need to change two attributes to get your red faded back to white (the Green & Blue), you'll need two Interpolate Behaviours, one for each of the colour attributes.

    (If other certain attributes or Rules you might add are delayed by an Interpolation behaviour waiting to finish, then put them just before the Interpolates, leaving your Interpolate behaviours as last.)

    --------

    So here's your Rules in each of your numbers as graphics:

    Rule: When Actor overlaps or collides with BaddyActor --when it collides, it triggers the following---
    Change Attribute self.Color.Green to 0
    Change Attribute self.Color.Blue to 0
    ---the above 2 change attributes changes the colour to Red as you want, placing the Red tint over your image, then carrying on below, the two interpolates changes them back to white again, over time that you require (in this case, 1 second)------

    Interpolate self.Color.Green to 1 Duration:1
    Interpolate self.Color.Blue to 1 Duration:1

    --And that's all done until the next collision.

    Hope I haven't gone overboard with my explanation again (I tend to do that); and that you understand now. :-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • KevinCrossKevinCross London, UKMember Posts: 1,894
    @gyroscope I said that it won't wait for it to finish before it moved on to the next behavior
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited September 2013
    @gyroscope I said that it won't wait for it to finish before it moved on to the next behavior
    OK, Kevin, I must have misread you, sorry! I'll edit my post accordingly now. :-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • BasGoodboyBasGoodboy Member, PRO Posts: 310
    Thanks a lot guys, I'm gonna look into this tomorrow and let you guys know!

    Goodboi Gamestudios | Monster Jumper now on the App Store

  • BasGoodboyBasGoodboy Member, PRO Posts: 310
    It works perfectly now! Thanks a lot!

    Goodboi Gamestudios | Monster Jumper now on the App Store

Sign In or Register to comment.