I have a picture like this
the original file is png format.
thx for reply
I have a picture like this
the original file is png format.
thx for reply
Using a graphic loaded from texturepacker, I do it this way:
– Utility method, everyone should use
function unrequire(m)
package.loaded[m] = nil
rawset(_G, m, nil)
– Search for the shared library handle in the registry and erase it
local registry = debug.getregistry()
local nMatches, mKey, mt = 0, nil, registry[’_LOADLIB’]
for key, ud in pairs(registry) do
if type(key) == ‘string’ and type(ud) == ‘userdata’ and getmetatable(ud) == mt and string.find(key, “LOADLIB: .*” … m) then
nMatches = nMatches + 1
if nMatches > 1 then
return false, “More than one possible key for module '” … m … “’. Can’t decide which one to erase.”
end
mKey = key
end
end
if mKey then
registry[mKey] = nil
end
return true
end
– What I think is a proper way to load a sprite from Texturepacker
function(indexname)
local ImageNfo = require(“someinfofile”)
local ImageSheet = graphics.newImageSheet( “spritesheet.png”, ImageNfo :getSheet() )
local imageRect = display.newImageRect(
ImageSheet,
ImageNfo:getFrameIndex(indexname),
228,
228
)
– reduce memory usage. no longer needed after loading image
unrequire(“someinfofile”) – unrequire is from
ImageSheet = nil
end
– Actual code to produce shadow effect
local shadow = rptirect(indexname)
panegroup:insert(shadow)
shadow.x = x
shadow.y = y
shadow:setFillColor(0,0,0) – this is the key
Using a graphic loaded from texturepacker, I do it this way:
– Utility method, everyone should use
function unrequire(m)
package.loaded[m] = nil
rawset(_G, m, nil)
– Search for the shared library handle in the registry and erase it
local registry = debug.getregistry()
local nMatches, mKey, mt = 0, nil, registry[’_LOADLIB’]
for key, ud in pairs(registry) do
if type(key) == ‘string’ and type(ud) == ‘userdata’ and getmetatable(ud) == mt and string.find(key, “LOADLIB: .*” … m) then
nMatches = nMatches + 1
if nMatches > 1 then
return false, “More than one possible key for module '” … m … “’. Can’t decide which one to erase.”
end
mKey = key
end
end
if mKey then
registry[mKey] = nil
end
return true
end
– What I think is a proper way to load a sprite from Texturepacker
function(indexname)
local ImageNfo = require(“someinfofile”)
local ImageSheet = graphics.newImageSheet( “spritesheet.png”, ImageNfo :getSheet() )
local imageRect = display.newImageRect(
ImageSheet,
ImageNfo:getFrameIndex(indexname),
228,
228
)
– reduce memory usage. no longer needed after loading image
unrequire(“someinfofile”) – unrequire is from
ImageSheet = nil
end
– Actual code to produce shadow effect
local shadow = rptirect(indexname)
panegroup:insert(shadow)
shadow.x = x
shadow.y = y
shadow:setFillColor(0,0,0) – this is the key