Beri
Beri

Reputation: 245

Corona SDK getting error when loading image from the system.DocumentsDirectory

I am trying to load image from the system.DocumentsDirectory but i get this error message.

WARNING: Failed to find image(C:\Users\beri\AppData\Roaming\Corona Labs\Corona S
imulator\Sandbox\jet shooter - pro-B1C630B0B5247780928E75EA15C69ABF\Documents\cu
stomJet.png)

I am using this code to create the image and display it again but i get the error message saying the image doesn't exist.

-- 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)

Any help?

Upvotes: 0

Views: 1018

Answers (1)

Beri
Beri

Reputation: 245

-- 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 )

Upvotes: 1

Related Questions