Take the 2-minute tour ×

I'm trying to create a button with an image but i can't see the image. I only see a white box with my label in it. I have a image named btn.png in the same folder as main.lua.

This is my code so far:

local background = display.newRect(0,0,320,480);

local widget = require("widget");

local text = display.newText("Dit is een text", 0, 0, native.systemFont, 32);
text.x = 100;
text.y = 100;

local btn = widget.newButton{
id = "Button 1",
width = 256,
height = 256,
top = 100,
left = 50,
label = "Dit is een knopke",
labelColor = {
    default = {245,244,245},
    over = {255,145,167}
defaultFile = "btn.png",

I don't see what is wrong with my code. I also searched for it in the corona docs but i don't see what is wrong with it.

share|improve this question
The above code is perfectly working with my corona build 2013.1076. See whether 'btn.png' exists. And make sure that you are not changing the position/alpha(opacity) of the button anywhere else. –  krs Jul 12 '13 at 4:10
I tried it again but i'm getting the same problem over and over again. I didn't change the position/alpha anywhere else. This is my only code that i have. I just started to learn corona sdk because i heard very good things about it but this is realy frustrating. –  Joeri Jacobs Jul 12 '13 at 8:46
@krs: Where did you put your image? –  Joeri Jacobs Jul 12 '13 at 8:48
try to copy and paste the image name from filename. –  vovahost Jul 12 '13 at 8:52
@Joeri Jacobs: Corona is a good tool for multi-platform developers. Regarding ur code: You have to put an image named 'btn.png' in the same folder where your main.lua is placed. One more thing: Is there is any error in the console..? And please run/build it on latest build available. –  krs Jul 12 '13 at 8:54
show 5 more comments

Your Answer



Browse other questions tagged or ask your own question.