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?
Label: corona android iphone ipad building error inmobi problem display screen View image tableView failed object physics touch button game lua config event listener |
Change Button Image during the game(ui.lua)
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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 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 |
Ok. Thank you very much.
views:2868 update:2011/10/11 15:24:38
热门文章
GameCenter LeaderBoards and Achievements Enabled Through OpenFeint
send message and call to a person
Forum: Report Spam + PM
[INSTALL_PARSE_FAILED_NO_CERTIFICATES]
[SOLVED] Director ERROR: Failed to execute new( params ) function on 'screen1'
Too many (200) local variables
Corona SVG Level Builder released. Drag and drop physics level editor with Inkscape and SVG.
Small bug in Collectible Items example
Pivot Joints and apparent elasticity
Can't make removeSelf() delayed
send message and call to a person
Forum: Report Spam + PM
[INSTALL_PARSE_FAILED_NO_CERTIFICATES]
[SOLVED] Director ERROR: Failed to execute new( params ) function on 'screen1'
Too many (200) local variables
Corona SVG Level Builder released. Drag and drop physics level editor with Inkscape and SVG.
Small bug in Collectible Items example
Pivot Joints and apparent elasticity
Can't make removeSelf() delayed
corona forums © 2003-2011