Merge branch 'main' into beta

This commit is contained in:
David Capello 2022-08-30 14:20:11 -03:00
commit 65e3207427
2 changed files with 26 additions and 2 deletions

View File

@ -109,3 +109,28 @@ do
-- listener instead of doing nothing.
expect_eq(2, i)
end
-- Accessing Sprite.events when closing the same sprite will call
-- push_sprite_events() creating a new app::script::SpriteEvents
-- instance again even when we've just destroyed the old one (because
-- we're just closing the sprite).
do
local s = Sprite(32, 32)
function onSpriteChange()
-- Do nothing
end
-- Here we access s.events for first time, creating the
-- app::script::SpriteEvents for this sprite.
s.events:on('change', onSpriteChange)
function onSiteChange()
-- Accessing s.events again on 'sitechange' when we're just
-- closing the sprite, re-generating its SpriteEvents instance.
-- We've to have special care of this case.
s.events:off(onSpriteChange)
end
app.events:on('sitechange', onSiteChange)
-- Closing the sprite will create a 'sitechange' event calling
-- onSiteChange() function.
s:close()
app.events:off(onSiteChange)
end

View File

@ -6,8 +6,7 @@
function fix_test_img(testImg, scale, fileExt, cm, c1)
-- With file formats that don't support alpha channel, we
-- compare totally transparent pixels (alpha=0) with black.
if fileExt == "bmp" or (fileExt == "tga" and
cm == ColorMode.GRAYSCALE) then
if fileExt == "tga" and cm == ColorMode.GRAYSCALE then
local pixel
if cm == ColorMode.RGB then
pixel = c1.rgbaPixel