vazono4ok Posted January 14, 2016 Share Posted January 14, 2016 Hello. I'm newbie to Phaser. I need to create countdown timer for game starting. It should looks like counting from 3 to 1, then the game should be started. I'll be using images as a numbers. i Have the following game state's Boot StartMenu Game GameOver I thought that i need to create state "PreGame", where will be countdown timer code. Is this correct? And help me pls with writing timer using images. Could someone help me with this. Quote Link to comment Share on other sites More sharing options...
P.Uri.Tanner Posted January 14, 2016 Share Posted January 14, 2016 Welcome! You can modify/steal from the examples. Here is an example for generic preloader:http://phaser.io/examples/v2/loader/load-events I created a small pen to illustrate some steps towards a countdown for you:http://codepen.io/Fenchurchh/pen/PZKdWa If you want to render the countdown using images you might want to check out the sprite or text examples (http://phaser.io/examples/v2/category/text) Quote Link to comment Share on other sites More sharing options...
vazono4ok Posted January 14, 2016 Author Share Posted January 14, 2016 42 minutes ago, P.Uri.Tanner said: Welcome! You can modify/steal from the examples. Here is an example for generic preloader:http://phaser.io/examples/v2/loader/load-events I created a small pen to illustrate some steps towards a countdown for you:http://codepen.io/Fenchurchh/pen/PZKdWa If you want to render the countdown using images you might want to check out the sprite or text examples (http://phaser.io/examples/v2/category/text) Thnx for your response i've already written the counter, but could i create state e.g. "PreGame" where will be the counter and onComplete i'll start my main game state or there were other possibilities in Phaser to create countdown in the same game state? Quote Link to comment Share on other sites More sharing options...
P.Uri.Tanner Posted January 14, 2016 Share Posted January 14, 2016 Exactly as you said! game.state.add('countdownState', {...} ) // your countdown game.state.add('game', {...}) // your gamestate // start the countdown game.state.start('countdownState') // after your countdown completes game.state.start('game') For a small use case you could just wrap the render and update functions to only render the countdown XOR the game. Quote Link to comment Share on other sites More sharing options...
vazono4ok Posted January 14, 2016 Author Share Posted January 14, 2016 Thank you for help. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.