Lua 从system.Documents目录加载映像时出错
我试图从system.Documents目录加载映像,但收到此错误消息Lua 从system.Documents目录加载映像时出错,lua,coronasdk,corona-storyboard,corona-director,Lua,Coronasdk,Corona Storyboard,Corona Director,我试图从system.Documents目录加载映像,但收到此错误消息 WARNING: Failed to find image(C:\Users\beri\AppData\Roaming\Corona Labs\Corona S imulator\Sandbox\jet shooter - pro-B1C630B0B5247780928E75EA15C69ABF\Documents\cu stomJet.png) 我正在使用此代码创建图像并再次显示它,但我收到错误消息说图像不存在 -- C
WARNING: Failed to find image(C:\Users\beri\AppData\Roaming\Corona Labs\Corona S
imulator\Sandbox\jet shooter - pro-B1C630B0B5247780928E75EA15C69ABF\Documents\cu
stomJet.png)
我正在使用此代码创建图像并再次显示它,但我收到错误消息说图像不存在
-- Creating the image
local screenBounds =
{
xMin = 0,
xMax = 800,
yMin = 116.5,
yMax = 360,
}
local customJet = display.captureBounds( screenBounds )
local baseDir = system.DocumentsDirectory;
display.save( customJet, "customJet.png", baseDir)
-- Loading the image
local path = system.pathForFile( "customJet.png", system.DocumentsDirectory )
local jetOne = display.newImage(path)
有什么帮助吗 +1但您可能应该解释原因:newImage希望文件名与baseDir相对,baseDir的默认值为system.ResourceDir。在您的情况下,png位于documents文件夹中,因此您必须覆盖您在回答中显示的内容。谢谢你的发帖。
-- Creating the image
local screenBounds =
{
xMin = 0,
xMax = 800,
yMin = 116.5,
yMax = 360,
}
local customJet = display.captureBounds( screenBounds )
local baseDir = system.DocumentsDirectory;
display.save( customJet, "customJet.png", baseDir)
-- Loading the image
local jetOne = display.newImage( "customJet.png", system.DocumentsDirectory )