ui problems

I have no clue what I’m doing wrong here. The “Play” button doesn’t show up on the simulator.
It tells me to put line 33 as a nil value.

[code]
module(…, package.seeall)

function new()
local menuGroup = display.newGroup()

local ui = require (“ui”)

local playBtn
local settings
local gameModes
local highscores
local title
–local achievements

local background = display.newImageRect(“background.png”, 800, 400)
background.x = display.contentWidth/2
background.y = display.contentHeight / 2
menuGroup:insert(background)

local title = display.newImage(“title.png”)
title.x = display.contentWidth/2
title.y = 50
menuGroup:insert(title)
local touchPlayBtn = function(event)
if event.phase == “release” and playBtn.isActive == true then
playBtn.isActive = false
director:changeScene(“game”)
end
end

playBtn = ui.newButton{
defaultSrc = “playBtn.png”,
defaultX = 125,
defaultY = 42,
overSrc = “playBtn-over.png”,
overX = 145,
overY = 62,
onEvent = touchPlayBtn,
id = “playBtn”,
}

playBtn.xOrigin = 25
playBtn.yOrigin= 600
transition.to (playBtn, { time = 1000, y = display.contentHeight/2, transition = easing.inOutExpo})
playBtn.isActive = true
menuGroup:insert(playBtn)

return menuGroup
end [import]uid: 114389 topic_id: 29507 reply_id: 329507[/import]

I see its returning a group called menuGroup, I assume you are calling that correctly. You should use the widget class and it would look something like this:

module(..., package.seeall)   
   
function new()   
 local menuGroup = display.newGroup()   
  
 local widget = require ("widget")   
  
 local playBtn  
 local settings  
 local gameModes  
 local highscores  
 local title   
 --local achievements   
  
 local background = display.newImageRect("background.png", 800, 400)   
 background.x = display.contentWidth/2  
 background.y = display.contentHeight / 2  
 menuGroup:insert(background)  
  
 local title = display.newImage("title.png")   
 title.x = display.contentWidth/2  
 title.y = 50  
 menuGroup:insert(title)   
   
   
local touchPlayBtn = function(event)  
 if event.phase == "release" and playBtn.isActive == true then   
 playBtn.isActive = false  
 director:changeScene("game")   
 end   
end  
  
 playBtn = widget.newButton{   
 default = "playBtn.png",   
 left = 125,   
 top = 42,   
 over = "playBtn-over.png",   
 onEvent = touchPlayBtn,   
 id = "playBtn",   
 }  
  
 playBtn.xOrigin = 25  
 playBtn.yOrigin= 600   
 transition.to (playBtn, { time = 1000, y = display.contentHeight/2, transition = easing.inOutExpo})   
 playBtn.isActive = true   
 menuGroup:insert(playBtn)  
  
 return menuGroup   
end   

I haven’t tested out this code but it should get the button on the screen for you. [import]uid: 58885 topic_id: 29507 reply_id: 118520[/import]