I am running into problems while learning the sdk. I am following this tutorial http://www.flemingermedia.com/2012/03/14/create-a-calculator-with-corona-p-1/ on how to build a calculator. I think the problem is the tutorial is a little bit old so I am sure a change in the sdk has made it no longer run. About 40% through the first page he asks you to run the code you have which should generate a button with the number 5 in the middle of it. However when I run it I am getting an error.
Here is the main lua file
--require the button constructor class local btnClass = require "buttons"; ------------------------ --define text parameters ------------------------ --create the parameter table local testParams = {}; --add parameters to the table testParams.labelTxt = "5"; ------------------------ --create a test button ------------------------ local tempButton = btnClass.newBtn(testParams) ------------------------ --position the test button at the middle of the screen ------------------------ tempButton.x , tempButton.y = display.contentWidth\*.5 , display.contentHeight\*.5;
and here is the button class lua file
local class = {}; function class.newBtn(params) --this function creates a new generic button --get parameters or set defaults local width = params.width or 50; local height = params.height or 35 local labelTxt = params.labelTxt or ""; local bgColor = params.bgColor or {100,100,200}; local txtColor = params.txtColor or {255,255,255}; --our button display object local btn = display.newGroup(); --button background local bg = display.newRoundedRect(0,0,width,height,4); bg:setFillColor(bgColor[1],bgColor[2],bgColor[3]); --position the bg bg:setReferencePoint(display.CenterReferencePoint); bg.x , bg.y = 0,0; --insert the background to the button group:insert btn:insert(bg); --create the button's label local label = display.newText(labelTxt,0,0,native.systemFont, 18) label:setTextColor(txtColor[1],txtColor[2],txtColor[3]); --position the label label:setReferencePoint(display.CenterReferencePoint); label.x , label.y = 0 , 0; --insert the label into the button group btn:insert(label); btn:setReferencePoint(display.CenterReferencePoint); return btn; end
Any help on figuring out what is happening would be great