i have my Storyboard demo working fine. But when i tried to add in Button widget, it seems doesn’t work
-- Called when the scene's view does not exist:
function scene:createScene( event )
local group = self.view
-----------------------------------------------------------------------------
-- CREATE display objects and add them to 'group' here.
-- Example use-case: Restore 'group' from previously saved state.
-----------------------------------------------------------------------------
-- SCENE MESSAGE
local txtSceneMsg = display.newText("", 0, 0, native.systemFont, 12)
txtSceneMsg:setTextColor(255, 255, 255)
txtSceneMsg.text = "INDEXSCREEN SCENE"
txtSceneMsg.size = 16
txtSceneMsg:setReferencePoint(display.TopLeftReferencePoint)
txtSceneMsg.x, txtSceneMsg.y = 0, 0
group:insert(txtSceneMsg)
-- INITIATE BUTTONS
local onButtonEvent = function (event )
if event.phase == "release" then
print( "You pressed and released a button!" )
end
end
local myButton = widget.newButton{
id = "btn001",
left = 100,
top = 200,
label = "Widget Button",
width = 150, height = 28,
cornerRadius = 8,
onEvent = onButtonEvent
}
-- Insert button into a group:
group:insert(myButton.view)
end
Terminal Error
The file sandbox for this project is located at the following folder:
(/Users/admin/Library/Application Support/Corona Simulator/demo-F467EC21866E9B1BC63ADCE935C64768)
Runtime error
...ers/admin/Dropbox/Game Development/demo/sceIndex.lua:58: ERROR: table expected. If this is a function call, you might have used '.' instead of ':'
stack traceback:
[C]: ?
[C]: in function 'insert'
...ers/admin/Dropbox/Game Development/demo/sceIndex.lua:58: in function <...ers development><br> ?: in function 'dispatchEvent'<br> ?: in function 'gotoScene'<br> ...rs/admin/Dropbox/Game Development/demo/sceSplash.lua:55: in function '_listener'<br><br>
it’s complaining line 58, which is below<br> group:insert(myButton.view)<br>
My understanding from button widget
http://developer.anscamobile.com/reference/index/widgetnewbutton
we should insert “myButton.view” instead of “myButton”, not sure wht goes wrong.
Can someone provide a pointer?
Thanks
- Weilies [import]uid: 10373 topic_id: 20455 reply_id: 320455[/import] </…ers>
