Last active
December 18, 2015 11:18
-
-
Save figengungor/5774390 to your computer and use it in GitHub Desktop.
scene1
This file contains hidden or 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
| local storyboard = require ("storyboard") --import storyboard | |
| local scene = storyboard.newScene() --create a new scene | |
| function scene:createScene(event) --create your objects here | |
| local group = self.view --In scene's view, we'll add(insert) our 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) -- if we don't add display object to scene's view, it won't be displayed | |
| 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) | |
| end | |
| local function go() | |
| storyboard.gotoScene("scene2") | |
| 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 | |
| function scene:enterScene(event) --do actions here | |
| timer.performWithDelay(1000,decreaseTime,3) --call decreaseTime 3 times with 1 second delay | |
| end | |
| --add scene listener for scene's special functions | |
| scene:addEventListener( "createScene", scene ) | |
| scene:addEventListener("enterScene",scene) | |
| return scene --finally return the scene so we can view it. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment