Created
June 13, 2013 15:41
-
-
Save figengungor/5774745 to your computer and use it in GitHub Desktop.
director scene1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module(..., package.seeall) | |
local director = require("director") | |
function new() --all objects and functions should be inside this function | |
local group = display.newGroup() --create a group object to keep display objects | |
time = 3 -- count down from 3 | |
--Text will be displayed when time is up! | |
gogogo = display.newText("Go go go!", 0, 0, "James Fajardo", 100) | |
gogogo.alpha=0 --is not visible | |
gogogo.x=W/2 | |
gogogo.y=H/2 | |
group:insert(gogogo) --add them to group, if you don't add, it won't be displayed on the scene | |
timeSound=audio.loadSound("button.wav") | |
game = display.newText("Game Starts", 0, 0,"James Fajardo", 100 ) | |
game.x=W/2 | |
game.y=300 | |
group:insert(game) | |
local function go() | |
director : changeScene("scene2") --go to second scene | |
end | |
local function decreaseTime() | |
local count = display.newText(time.."", 0, 0, "James Fajardo", 300) | |
count.x=W/2 | |
count.y=H/2 | |
time = time-1 | |
transition.to(count, {time=1000, alpha=0} ) | |
local channel = audio.play(timeSound) | |
if(time==0) then | |
transition.to(gogogo, {time=2000, delay=1000, alpha=1, onComplete=go} ) | |
transition.to(game, {time=1000, alpha=0} ) | |
end | |
end | |
timer.performWithDelay(1000,decreaseTime,3) | |
return group --finally return the group, so we can view the scene | |
end --end of new function | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment