使用Corona SDK从system.DocumentsDirectory加载图像时出错。

我试图从 system.DocumentsDirectory 加载图像,但我得到了这个错误信息。

警告:无法找到图像(C:\Users\beri\AppData\Roaming\Corona Labs\Corona Simulator\Sandbox\jet shooter - pro-B1C630B0B5247780928E75EA15C69ABF\Documents\customJet.png)

我使用这段代码创建图像并重新显示它,但我得到了错误信息,说图像不存在。

- 创建图像
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)

-- 加载图片
local path = system.pathForFile("customJet.png", system.DocumentsDirectory)
local jetOne = display.newImage(path)

有帮助吗?

点赞
用户2370751
用户2370751
-- 创建图像
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)

-- 加载图像
local jetOne = display.newImage( "customJet.png", system.DocumentsDirectory )

将屏幕区域截取为自定义的飞行器图像,然后在文档目录中保存为“customJet.png”文件。然后,从文档目录中加载该图像,并将其创建为display对象“jetOne”。

2014-01-31 01:54:26