Search code examples
androidandenginecountdownscenetimedelay

A simple countdown number screen to andengine game


I am working on andengine framework, What I want is a simple scene that display countdown numbers text from 1,2,3 or 3,2,1 when play button pressed and before the game scene (between play button and GameScene) start. I am bit confused, do I have to implement a separate scene and number images for this or is there any easy way to this all , what I have done so far is a small around 8 sec delay when button play button pressed. and I want 1,2,3 text change on black screen before game scene start , any tutorial, referance , code , ideas will be really great and helpful and thanks in advance

// Button play
    final Text btnPlay= new Text(0, 0, Main.mFont, "Play"){
        private boolean down= false;
        public boolean onAreaTouched(TouchEvent event, float pTouchAreaLocalX, float pTouchAreaLocalY) {


            if(event.isActionDown()){
                this.setColor(0.7f, 0.7f, 0.7f);
                down= true;
            }

            else if(down && event.isActionUp()){
                this.setColor(1, 1, 1);
                down= false;

                new Timer().schedule(new TimerTask() {          
                    @Override
                            public void run() {

             // Launch game screen when tapped

                        SceneManager.setScene(GameScene.run());
                             }
            }, 8000);

                     } 
            return true;

        }

    };
    btnPlay.setPosition(GameConstants.CAMERA_WIDTH/2- btnPlay.getWidth()/2,   bestText.getY()+ bestText.getHeight()+ 10);
    btnPlay.setColor(1, 1, 1);
    scene.attachChild(btnPlay);
    scene.registerTouchArea(btnPlay);

Solution

  • http://www.matim-dev.com/full-game-tutorial---part-10.html

    look at the loading scene. u can use this in combination with a timer, which update your text after a specified time to 3,2,1 - go