user682217
user682217

Reputation: 291

corona sdk button's images not visible/misplaced

I just installed the sdk and run in creating sample app project. I ended up with a folder full of icons and 3 classes that were to show me how things work.

The problem I noticed is that the code creates buttons that should have a background image but only the text is visible. Images are in the same folder and spelling is correct.

The auto-generated code looks like this:

    playBtn = widget.newButton{
    label="Play Now",
    labelColor = { default={255}, over={128} },
    default="button.png",
    over="button-over.png",
    width=154, height=40,
    onRelease = onPlayBtnRelease    -- event listener function
}
playBtn.x = display.contentWidth*0.5
playBtn.y = display.contentHeight - 125

Also the text doesn't change color. When I added another button below with my image below the auto created one I was able to see my tiny part of my image in the top left corner. The button was also visible when moving to net scene. How come?

Upvotes: 2

Views: 723

Answers (1)

Fernker
Fernker

Reputation: 2288

To help solve your color issue you need to change the values. Corona recently changed to decimal colors, the range is from 0 to 1 versus 0 to 255. Anything over 1 will result in a 1 being used for the color.

So basically your colors need to be divided by 255 to get the proper value. You can either have the code divide it or you can divide the value yourself. You can read a post about it here.

Upvotes: 1

Related Questions