I would like to know how to take a defined image (e.g. a tile) in the LOVE game engine and draw it with a transparency that may vary per-frame. Stencils seem to only work for completely hiding parts of an image; I need to make an entire tile translucent, and the degree of translucency needs to be able to vary during gameplay.

(purpose: I am messing around with a game idea that involves partial information during fog-of-war, represented by superimposing all tiles that might be somewhere based on what you currently know)

up vote 1 down vote accepted

Just set the color to white-with-less-than-full alpha before drawing the image. For instance, this would draw your image at around 50% opacity:

love.graphics.setColor(255, 255, 255, 128)
love.graphics.draw(image, 0, 0)

The easiest way to work with this if you want to fade something in / out is to have a fractional multiplier value from 0 to 1 and set the alpha component to 255 * that, i.e.

love.graphics.setColor(255, 255, 255, 255 * someMultiplier)

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.