Ok, I’ve been hacking at this for 5 hours now. All I am trying to do is use the director class to transition from screen to screen and the UI class to draw a button that will print a Hello World on the screen. Maybe I’ve been programming in VB.NET and ASP.NET too long LOL…
main.lua
display.setStatusBar( display.HiddenStatusBar ) --Hide status bar from the beginning
-- Import director class
local director = require("director")
-- Create a main group
local mainGroup = display.newGroup()
-- Main function
local function main()
-- Add the view to the group
mainGroup:insert(director.directorView)
director:changeScene( "mainmenu" )
return true
end
-- Begin
main()
mainmenu.lua
module(..., package.seeall)
-- our new function
function new()
-- group that we are going to return to the screen
local menuGroup = display.newGroup()
-- use the UI class for our buttons
local ui = require( "ui" )
local drawScreen = function()
local startBtn
-- start button event code
local onStartTouch = function( event )
if event.phase == "release" and not isLevelSelection and startBtn.isActive then
print( "Start Button Pressed." )
local myText = display.newText( "Hello World!!!", 20, 40, native.systemFont, 36 )
myText:setTextColor( 255, 255, 255 )
end
end
-- add our start button
startBtn = ui.newButton{
defaultSrc = "start\_btn\_up.png",
defaultX = 0,
defaultY = 0,
overSrc = "start\_btn\_down.png",
overX = 0,
overY = 0,
onEvent = onStartTouch,
id = "StartButton",
text = "",
font = "Helvetica",
textColor = { 255, 255, 255, 255 },
size = 16,
emboss = false
}
startBtn.x = 0 level1Btn.y = 0
startBtn.isVisible = true
menuGroup:insert( startBtn )
end
-- load the screen
drawScreen()
-- return the menuGrp object
return menuGroup
end
If you need me to post the director and UI classes, please let me know. I mean this is pretty basic. Also the 2 images are in the same folder in the root. Any help would be much appreciated. Thanks.
Joe… [import]uid: 12765 topic_id: 4604 reply_id: 304604[/import]
