[Resolved] Images disappearing in build

I am getting crashes when I build my app for a device or for the Xcode simulator. The problem is, certain images do not display in Xcode simulator, and when I build for device, when you would go to the scene in director with the disappearing image, it would crash. For example, here is my credits screen. All it should do is display the credits background image, and a back button. When I build it in Xcode simulator, when I go to my credits page, the background does not show up. Then when I build it for my device and import it onto my phone, when I click the credits button, the app closes itself. This is a difficult problem because I do not know how to even go about diagnosing this problem because I do not get any errors. I should note that it runs fine on Corona’s simulator and the images display properly.

[lua]
module(…, package.seeall);

function new()
local Scene = display.newGroup();

local GUI = display.newGroup();

Scene:insert(GUI);

–Background Images
local bg_rect = display.newRect(0,0,_H * 1.5,_W * 1.5);
local back_btn = display.newText(“back”, 0, 0, “Chalkduster”, 48)
back_btn:setTextColor(0, 0, 0);
back_btn.x = 0 + (back_btn.width * 0.5); back_btn.y = (_H * 0.9);
local background_img = display.newImage(“images/credits_bg2.png”, true);
background_img.x = _W * 0.5; background_img.y = _H * 0.5;

bg_rect.x = _W * 0.5; bg_rect.y = _H * 0.5;
bg_rect:setFillColor(0, 174, 239);

back_btn.scene = “menu”;

GUI:insert(bg_rect);
GUI:insert(background_img);
GUI:insert(back_btn);

local function changeScene(e)
if(e.phase == “ended” or e.phase == “cancelled”) then
director:changeScene(e.target.scene);
end
end

back_btn:addEventListener(“touch”, changeScene);

Scene:insert(GUI);

return Scene
end[/lua]

Any insight would be appreciated even if it is not a solution because I don’t even know how to go about solving this. [import]uid: 50511 topic_id: 25584 reply_id: 325584[/import]

I should also point out that when I comment out the lines 16, 17, and 25, it works fine, but, I do not have my credits image. I’ve cross-referenced how I imported and initialized images in other scenes and they are done that same way. Also the dimensions of the background_img image is W: 480 H: 320. [import]uid: 50511 topic_id: 25584 reply_id: 103401[/import]

Hey Roy,

First thing, make sure you have the name correct, including caps. If it’s correct and still not working try moving it into the main project folder instead of a sub folder and let me know results, please?

If you still have issues then there is likely a problem with the actual image that isn’t showing up until it builds (in which case you may see something in the terminal while building).

Let me know,

Peach :slight_smile: [import]uid: 52491 topic_id: 25584 reply_id: 103493[/import]

I don’t think this is related to your problem but I noticed that you have the following line in your code twice.

[lua]Scene:insert(GUI);[/lua]

-Mark [import]uid: 117098 topic_id: 25584 reply_id: 103509[/import]

@Peach, I tried moving the file to the main directory and then correcting the file path to no success. I then tried to rename the file but that didn’t work either. I am also noticing that I have another image doing the same thing in my levelSelection scene. I have little boxes for the user to select and they are all the same but for some reason one of them doesn’t work. I’m beginning to think the image file is corrupted or something.

@Mark thanks! while it may not have fixed my problem I think it may have caused other problems down the road that I would be unaware of! [import]uid: 50511 topic_id: 25584 reply_id: 103553[/import]

In line 16 there is a space after the underscore, like this: background_ image

In line 17 and 25 there are no space: background_image

I guess this will solve your problem. [import]uid: 129287 topic_id: 25584 reply_id: 103571[/import]

Oops! Thanks Dr. Mabuse, but I actually just messed that up typing it in the forum. In the code there is no space. I edited the original post to remove that space. Sorry about that!

The only work around I was able to come up with that fixed the issue was to delete the specific image (in this case “credits_bg2.png”) and re-create it. Just to be safe I saved it as a different name and it works now, with the same exact code. I was leaning towards something being wrong with the image but I do not know how that happened. [import]uid: 50511 topic_id: 25584 reply_id: 103577[/import]

Sometimes images just “break”, not in relation to Corona but when saving them in Photoshop etc. Not often but I’ve had it happen before - normally though you’d see a print in the terminal during build.

Either way am happy to hear you got it sorted, marking as resolved.

Peach :slight_smile: [import]uid: 52491 topic_id: 25584 reply_id: 103668[/import]