Sprite opacity / alpha

Im having trouble understanding how to make sprites with less than 100% opacity. Ive tried tint, stroke, fill etc but nothing have an impact on my sprites. Tint just makes the while screen tinted except the text. Any ideas?


function createFood()
    setBackground()
    setFontStyle("button")
    bp = HEIGHT/(#food+1)
    h = HEIGHT
    
  
    
    for k, v in pairs(food) do
        --print("title = "..v.title)
        bw, bh = textSize(v.title)
        print("bw = "..bw)
        local iconWidth = WIDTH/2+bw/2+32
        text(v.title, WIDTH/2, h-bp*k)
        --sprite(v.picture, WIDTH/2, HEIGHT/2)
        
        for kk, vv in pairs(v.required) do
            sprite(vv.picture, iconWidth, h-bp*kk, 24, 24)
            iconWidth = iconWidth + 40
            --print("player = "..vv.player)
            --print("item = "..vv.title)
        end
    end
end

I think tint(128,128,128,128) before sprint should do it?

The alpha value (fourth number in the colour) controls opacity. Reduce it to increase transparency.

I don’t see how your code snippet helps in any way. As Ignatz says, the fourth parameter is alpha.

Alpha starts at 255 for no transparency, and goes down to 0 for complete transparency.

Example:

--       Red    Green    Blue    Alpha
tint(   255,    127,       127,    127    ) -- Tint sprites a color.
sprite("Cargo Bot:Codea Icon", WIDTH / 2, HEIGHT / 2) -- Draw the Codea icon at the middle of the screen, with full red, half green, and half blue. And with half alpha, so partially transparent.
noTint() -- Remove sprite tinting.
sprite("Cargo Bot:Codea Icon", WIDTH / 2, HEIGHT / 2) -- Draw the Codea icon at the middle of the screen, with full colors and full alpha, so no transparency,

@Jmv38 tint(128, 128, 128, 128) makes the whole screen tinted not just the sprite.

I know how the alpha value works but for some reason it doesnt work for my code. Ive run out of ideas since tint is supposed to work.

Ok, this fixed the whole screen not being tinted.

            tint(128,128,128,128)
            sprite(vv.picture, iconWidth, h-bp*kk, 24, 24)
            noTint()

Thanks for the support guys.