Remove alpha value check from ImageButton

With LOVE 11.0 it is no longer possible to retrieve an ImageData from
an Image and thus there is no posibility to retrieve the alpha value
of a single pixel.
Another solution would be to additionally supply an ImageData
to the ImageButton in order to be able to retrieve the alpha values.
This commit is contained in:
Matthias Gazzari 2018-04-22 20:00:54 +02:00
parent 8ec0e638ce
commit c11db7d444
2 changed files with 3 additions and 6 deletions

View file

@ -11,14 +11,11 @@ return function(core, normal, ...)
opt.id = opt.id or opt.normal
opt.state = core:registerMouseHit(opt.id, x,y, function(u,v)
local id = opt.normal:getData()
assert(id:typeOf("ImageData"), "Can only use uncompressed images")
u, v = math.floor(u+.5), math.floor(v+.5)
if u < 0 or u >= opt.normal:getWidth() or v < 0 or v >= opt.normal:getHeight() then
return false
end
local _,_,_,a = id:getPixel(u,v)
return a > 0
return true
end)
local img = opt.normal