Android Open Source - candy-drop Title Screen






From Project

Back to project page candy-drop.

License

The source code is released under:

Copyright (c) 2014, Gregory Martin All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: ...

If you think the Android project candy-drop listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.gregfmartin.facetapper.screens;
//from ww w .ja v  a2 s  .com
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.InputListener;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.gregfmartin.facetapper.GameCore;
import com.gregfmartin.facetapper.entities.Screen;
import com.gregfmartin.facetapper.utils.Gl20Utils;

/**
 * The screen where the player can choose to play the game, go to a screen where global options
 * can be configured, or exit the game.
 *
 * @author Gregory Martin
 */
public class TitleScreen extends Screen {
    private static final String TAG  = TitleScreen.class.getSimpleName();
    private static final String CTAG = TitleScreen.class.getCanonicalName();

    // UI Components
    private Table                      mRootTable; // The root container for all of the UI components
    private Label                      mGameTitleLabel; // The Label that shows the title of the game
    private TextButton                 mButtonPlay; // Starts the game
    private TextButton                 mButtonOptions; // Moves to the configuration screen for game settings
    private TextButton                 mButtonQuit; // Quits the game
    private TextButton.TextButtonStyle mButtonStyle; // The style that's used to style the TextButtons
    private FreeTypeFontGenerator      mFreeTypeFontGen; // Create BitmapFonts from TTF

    public TitleScreen(GameCore gameCore) {
        super(gameCore);
    }

    @Override public void castingCall() {
        super.castingCall();

        mFreeTypeFontGen = new FreeTypeFontGenerator(Gdx.files.internal("fonts/sawasdee/sawasdee.ttf"));
        mButtonStyle = new TextButton.TextButtonStyle(null, null, null, mFreeTypeFontGen.generateFont(30));
        mButtonStyle.fontColor = Color.BLACK;
        mRootTable = new Table();
        mGameTitleLabel = new Label("Candy Dropper", new Label.LabelStyle(mFreeTypeFontGen.generateFont(64), Color.BLACK));
        mButtonPlay = new TextButton("Play", mButtonStyle);
        mButtonOptions = new TextButton("Options", mButtonStyle);
        mButtonQuit = new TextButton("Quit", mButtonStyle);

        // Attach listeners to the buttons
        mButtonPlay.addListener(new InputListener() {
            @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
                // Move to the Arena Screen
                mGameCoreRef.setScreen(new ArenaScreen(mGameCoreRef));

                return false;
            }
        });
        mButtonQuit.addListener(new InputListener() {
            @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
                // Quit the game
                Gdx.app.exit();

                return false;
            }
        });
    }

    @Override public void rehearsal() {
        super.rehearsal();

        mRootTable.setFillParent(true);
        // mRootTable.debug();
        mRootTable.add(mGameTitleLabel).expand().top().padTop(15.0F).colspan(3);
        mRootTable.row().expandX().padBottom(15.0F);
        mRootTable.add(mButtonPlay);
        mRootTable.add(mButtonOptions);
        mRootTable.add(mButtonQuit);

        mStage.addActor(mRootTable);
    }

    @Override public void draw(float delta) {
        Gl20Utils.glClearColour(Color.WHITE);

        // Table.drawDebug(mStage);

        mStage.draw();
    }

    @Override public void dispose() {
        super.dispose();

        mStage.dispose();
        mFreeTypeFontGen.dispose();
    }
}




Java Source Code List

com.gregfmartin.facetapper.GameCore.java
com.gregfmartin.facetapper.Main.java
com.gregfmartin.facetapper.entities.CandyBase.java
com.gregfmartin.facetapper.entities.CandyDrop.java
com.gregfmartin.facetapper.entities.Pulse.java
com.gregfmartin.facetapper.entities.Screen.java
com.gregfmartin.facetapper.entities.SplashImage.java
com.gregfmartin.facetapper.entities.Sucker.java
com.gregfmartin.facetapper.screens.ArenaScreen.java
com.gregfmartin.facetapper.screens.AssociationScreen.java
com.gregfmartin.facetapper.screens.SplashScreen.java
com.gregfmartin.facetapper.screens.TitleScreen.java
com.gregfmartin.facetapper.utils.Colour.java
com.gregfmartin.facetapper.utils.CoreUtil.java
com.gregfmartin.facetapper.utils.DevSettings.java
com.gregfmartin.facetapper.utils.Gl20Utils.java
com.gregfmartin.facetapper.utils.MathEngine.java
com.gregfmartin.facetapper.utils.StagePrep.java