Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Tween a Sprites Colour to White? — Gideros Forum

Tween a Sprites Colour to White?

NinjadoodleNinjadoodle Member
edited January 2014 in General questions
Hi Guys

I'm trying to figure out how to tint a sprites colour using Gtween. On the forums, I found the code below, but when I try it it doesn't seem to do anything.

Any ideas on what I'm doing wrong?

Also, is there a way to do this using Gideros Movieclips?

Thank you in advance!

**********

local sprite = Bitmap.new(Texture.new("box.png"))
stage:addChild(sprite)

GTween.new(sprite, 5, {redMultiplier=255, greenMultiplier=0, blueMultiplier=0})

Comments

  • talistalis Guru
    edited December 2013
    In my test this code totaly working:

    Are you sure that you add gtween.lua to your project?
    local sprite = Bitmap.new(Texture.new("test.jpg"))
    stage:addChild(sprite)
     
    GTween.new(sprite, 5, {redMultiplier=255, greenMultiplier=0, blueMultiplier=0})
    Edit: Just to be sure i also tested with a png file it is also working correctly.
  • loucsamloucsam Member
    edited December 2013
    I tried it on a mostly yellow image:

    if redMultiplier = 255 it transitions to red
    if greenMultiplier = 255 it transitions to green
    if blueMultiplier = 255 it transitions to black

    Why black? What is happening there?

    Actually, the 1 pixel or so black border around the image goes blue and all the yellow colours inside the border go black.

    If all 3 multipliers are 0 then the entire image goes black(border included)
  • works perfectly for me with full yellow color image can you post that image or make video so we can see what's happening
  • loucsamloucsam Member
    edited December 2013
    Just try 255 for red, rerun 255 as green, then 255 as blue.

    Then see a slight difference between blue=255 and all as 0.

    local sprite = Bitmap.new(Texture.new("images/Rook_yellow.png"))
    stage:addChild(sprite)

    GTween.new(sprite, 5, {redMultiplier=255, greenMultiplier=0, blueMultiplier=0})

    local sprite1 = Bitmap.new(Texture.new("images/Rook_yellow.png"))
    stage:addChild(sprite1)
    sprite1:setX(100)
    sprite1:setY(100)
    GTween.new(sprite1, 5, {redMultiplier=0, greenMultiplier=255, blueMultiplier=0})

    local sprite2 = Bitmap.new(Texture.new("images/Rook_yellow.png"))
    sprite2:setX(200)
    sprite2:setY(200)
    stage:addChild(sprite2)
    GTween.new(sprite2, 5, {redMultiplier=0, greenMultiplier=0, blueMultiplier=255})

    // also 0,0,0
    Rook_yellow.png
    60 x 60 - 4K
  • NinjadoodleNinjadoodle Member
    edited December 2013
    Hi Guys

    Thank you all for you help, I've just tried it again in a new test (this time on a movieclip) and it works perfectly :)

    Now the only problem I have is that, I can't seem to tint the movieclip to white.

    I want to "flash" the movieclip to white quickly and then fade back to normal.

    Any ideas?

    Thank you in advance!
  • Hmmm,
    Possible workaround hence 255,255,255 is not working.

    Add one more totaly white image to stage with alpha = 0.

    Then gtween it is alpha on top of all images to 1 quicly and back to 0 again then remove it from stage :D
  • NinjadoodleNinjadoodle Member
    edited December 2013
    Thank for the workaround :) I will definitely do this if I can't figure out another way of tinting.

    Do you guys have any other ideas on how to tint a movie clip to a completely white colour using a tween?
  • Actually I don't think that link is helpful lol, and also the values should be between 0 and 1 for the multipliers, but replace 255 with 1, same issue.
  • Strange, I know it is possible with Tween Max using a Color Transform. Is there any equivalent in Gideros?
  • ar2rsawseenar2rsawseen Maintainer
    edited December 2013
    @Ninjadoodle
    as folks replied, then yes it is possible, but only using color multipliers

    and currently there is a limitation, which clips the provided values to 1

    So for example, you have a #666666 color, in red channel you have 66, so you want it to drop down to 33, you provide multiplier 0.5 (as in 33/66 = 0.5)
    But what if you want to make it to white color?, you would actually want to increase the value with 2.5 multiplier (as in FF/66 = 2.5), but in open GL 1.0 you have a limitation that the maximum value is 1. So you could never reach a color higher than 66 in red channel.

    But it has been fixed in developer preview which uses OpenGL 2 and thus will be fixed in Gideros 2.0

    And for now, if you want to fully change the colors of the image to any other color, you would need to take channels with maximum possible values as (#FFFFFF) or basically using white image

    Hope that helps ;)
  • NinjadoodleNinjadoodle Member
    edited December 2013
    @ar2rsawseen

    Thank you for the detailed answer, I really appreciate it! Looking forward to trying Gideros 2 :)
  • NinjadoodleNinjadoodle Member
    edited January 2014
    Hi guys

    @ar2rsawseen, I understand what you've detailed above, but I still can't seem to figure out a simple way of doing this :(

    Does anybody possibly have an example/workaround I could have a look at?

    Thank you again for your help?
Sign In or Register to comment.