Buttons, and widget.NewButton

Hello - 

As I wrote in my introductory post, I am going through the tutorials and porting one of my apps from another engine in to Corona.

The game scene has four buttons - left, right, thrust, fire.  I have a doubt concerning building the buttons.  I required the widget at the beginning lines of game.lua (multiple scenes).  Further down the code, I try to create the buttons, but am getting a NilValue error when trying to build the second button.  The code is as follows:

– Create buttons with widget

local btnLeft = widget.newButton(

    {

        width = 100,

        height = 100,

        defaultFile = “BtnLeft.png”,

        onEvent = handlebtnLeftEvent

    }

)

btnLeft.x = 100

btnLeft.y = 580

local btnRight= widget.NewButton(

    {

        width = 100,

        height = 100,

        defaultFile = “BtnRight.png”,

        onEvent = handlebtnRightEvent

    }

)

btnRight.x=160

btnRight.y=580

local btnThrust= widget.NewButton(

    {

        width = 100,

        height = 100,

        defaultFile = “BtnThrust.png”,

        onEvent = handlebtnThrustEvent

    }

)

btnRight.x=950

btnRight.y=580

local btnFire= widget.NewButton(

    {

        width = 100,

        height = 100,

        defaultFile = “BtnFire.png”,

        onEvent = handlebtnFireEvent

    }

)

btnRight.x=1080

btnRight.y=580

When doing so, I get a NilValue error at “local btnRight= widget.NewButton(” .  I am beginning to wonder if I invoke widget.NewButton only once and list the different buttons below.  I’ve tried to find an example which has several buttons (I need to detect if buttons are kept pressed (to rotate and thrust my ship), but haven’t found one et.

Can you tell by the code incuded what I am doing wrong?

Thanks, regards.

it’s widget.newButton, not NewButton

It worked like a charm (and I noticed some other mixups during copy-paste).  Thanks much!

your welcome lol  :wink:

it’s widget.newButton, not NewButton

It worked like a charm (and I noticed some other mixups during copy-paste).  Thanks much!

your welcome lol  :wink: