I’m using daily build 825, and I tried to create a button that uses imageSheet. I followed the instruction from this tutorial/blog post: http://blog.anscamobile.com/2012/05/adding-buttons-to-your-games-and-apps/
I am able to create a button when I don’t use imageSheet, but when I use imageSheet, it won’t show the image at all.
Here’s how I create a button with two images:
-- myFontSize and myFont are predefined variable
-- this button looks and works as expected
local myButton = widget.newButton{
default = "PNG/btnBlue.png",
over = "PNG/btnBlueOver.png",
width = 200,
height = 60,
label = "MY BUTTON",
labelColor = { default={255}, over={255} },
fontSize = myFontSize,
font = myFont,
onRelease = changeScene,
emboss = true
}
myButton.x = 0.5\*display.contentWidth; myButton.y = 0.5\*display.contentHeight;
localGroup:insert(myButton);
Here’s how I create a button with an imageSheet:
local mySheetOption = {
width = 200,
height = 60,
numFrames = 2,
sheetContentWidth = 200,
sheetContentHeight = 120
}
local mySheet = graphics.newImageSheet( "PNG/btnBlueSheet.png", mySheetOption )
-- myFontSize and myFont are predefined variable
-- this button does not show imageSheet, but instead, looks like a white rounded rectangle with black stroke
local myButton = widget.newButton{
sheet = mySheet,
defaultIndex = 1,
overIndex = 2,
width = 200,
height = 60,
label = "MY BUTTON",
labelColor = { default={255}, over={255} },
fontSize = myFontSize,
font = myFont,
onRelease = changeScene,
emboss = true
}
myButton.x = 0.5\*display.contentWidth; myButton.y = 0.5\*display.contentHeight;
localGroup:insert(myButton);
What am I don’t wrong with the imageSheet version?
Naomi [import]uid: 67217 topic_id: 26852 reply_id: 326852[/import]