Hi. I’m using ui.lua to create buttons to my game. Is there a way to change the image of the button when the game is running? if yes, how can I do that? [import]uid: 40281 topic_id: 14019 reply_id: 314019[/import]
is not possible. UI use display objects as images and image of a display object can’t be changed. so the available option is to remove the old object and insert a new own.
see the sample below
[lua]local ui = require(“ui”)
local playBTN
local function gotogame()
playBTN:removeSelf()
playBTN = ui.newButton{
default = “newimage1.png”,
over = “newimage2.png”,
onRelease = gotogame
}
playBTN.x = display.contentWidth /2
playBTN.y = 210
end
playBTN = ui.newButton{
default = “image1.png”,
over = “image2.png”,
onRelease = gotogame
}
playBTN.x = display.contentWidth /2
playBTN.y = 210[/lua] [import]uid: 71210 topic_id: 14019 reply_id: 51672[/import]
Ok. Thank you very much. [import]uid: 40281 topic_id: 14019 reply_id: 51832[/import]