Director + UI.lua + Dynamic Image Resolution

Hi,
I have this problem and can’t find the solution.

I want to have button with normal and HD graphic, I use Dynamic Image Resolution @2 function in config.lua file. It works for all the images but I get error with buttons:

Error: bad argument #2 to display.newImageRect(): width expected, but got nil.

I do specify height and width so don’t know what is the problem. Could some one post a code example how it should look like? I just want to say that I did try set width and height with “” and without.

this is my button at the moment.

[code]
local bt_start = ui.newButton{
default = “button_start1.png”, defaultX = 196 , defaultY = 57,
over = “button_start1.png”, overX = 10 , overY = 10,
onEvent = bt_start_e,

}
bt_start.x = display.contentWidth / 2
bt_start.y = display.contentHeight *0.5 + 5
localGroup:insert(bt_start)
[/code] [import]uid: 27699 topic_id: 8664 reply_id: 308664[/import]

You should look into your ui.lua file and check out the newButton function, because the answer to this question depends on what version of ui.lua you are using.

The basic answer to your problem is that you aren’t entering a width or height for the button. Here’s an example of what my button definitions look like:

[lua]local backButton = ui.newButton{
defaultSrc = “BackButton.png”,
overSrc = “BackButtonOver.png”,
onRelease = mainMenuRelease,
width = contentWidth * .127,
height = contentHeight * .1125,
x = contentWidth * .085,
y = contentHeight* .07
}[/lua]

And here’s the relevant part of my version of ui.lua.

[lua]function newButton( params )
local button, defaultSrc , defaultX , defaultY, width, height, overSrc , overX , overY , size, font, textColor, offset

local default, over
if params.defaultSrc then
button = display.newGroup()
print( params.defaultSrc , params.width , params.height)
default = display.newImageRect ( params.defaultSrc , params.width , params.height )
print(default)
button:insert( default, true )
end

if params.overSrc then
over = display.newImageRect ( params.overSrc , params.width , params.height )
over.isVisible = false
button:insert( over, true )
end

…[/lua] [import]uid: 10211 topic_id: 8664 reply_id: 32030[/import]