Android Open Source - AndroidFramework Main Menu Screen






From Project

Back to project page AndroidFramework.

License

The source code is released under:

This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a co...

If you think the Android project AndroidFramework 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.mdobbins.sample;
/*from w  ww . ja  v a2s .  co  m*/
import java.util.List;

import com.mdobbins.framework.Game;
import com.mdobbins.framework.Graphics;
import com.mdobbins.framework.Screen;
import com.mdobbins.framework.Input.TouchEvent;


public class MainMenuScreen extends Screen {
    public MainMenuScreen(Game game) {
        super(game);
    }


    @Override
    public void update(float deltaTime) {
        Graphics g = game.getGraphics();
        List<TouchEvent> touchEvents = game.getInput().getTouchEvents();


        int len = touchEvents.size();
        for (int i = 0; i < len; i++) {
            TouchEvent event = touchEvents.get(i);
            if (event.type == TouchEvent.TOUCH_UP) {


                if (inBounds(event, 0, 0, 250, 250)) {
                    //START GAME
                                game.setScreen(new GameScreen(game));              
      }


            }
        }
    }


    private boolean inBounds(TouchEvent event, int x, int y, int width,
            int height) {
        if (event.x > x && event.x < x + width - 1 && event.y > y
                && event.y < y + height - 1)
            return true;
        else
            return false;
    }


    @Override
    public void paint(float deltaTime) {
        Graphics g = game.getGraphics();
        g.drawImage(Assets.menu, 0, 0);
    }


    @Override
    public void pause() {
    }


    @Override
    public void resume() {


    }


    @Override
    public void dispose() {


    }


    @Override
    public void backButton() {
        //Display "Exit Game?" Box


    }
}




Java Source Code List

com.mdobbins.framework.Audio.java
com.mdobbins.framework.Audio.java
com.mdobbins.framework.FileIO.java
com.mdobbins.framework.FileIO.java
com.mdobbins.framework.Game.java
com.mdobbins.framework.Game.java
com.mdobbins.framework.Graphics.java
com.mdobbins.framework.Graphics.java
com.mdobbins.framework.Image.java
com.mdobbins.framework.Image.java
com.mdobbins.framework.Input.java
com.mdobbins.framework.Input.java
com.mdobbins.framework.Music.java
com.mdobbins.framework.Music.java
com.mdobbins.framework.Pool.java
com.mdobbins.framework.Pool.java
com.mdobbins.framework.Screen.java
com.mdobbins.framework.Screen.java
com.mdobbins.framework.Sound.java
com.mdobbins.framework.Sound.java
com.mdobbins.implementation.framework.AndroidAudio.java
com.mdobbins.implementation.framework.AndroidFastRenderView.java
com.mdobbins.implementation.framework.AndroidFileIO.java
com.mdobbins.implementation.framework.AndroidGame.java
com.mdobbins.implementation.framework.AndroidGraphics.java
com.mdobbins.implementation.framework.AndroidImage.java
com.mdobbins.implementation.framework.AndroidInput.java
com.mdobbins.implementation.framework.AndroidMusic.java
com.mdobbins.implementation.framework.AndroidSound.java
com.mdobbins.implementation.framework.MultiTouchHandler.java
com.mdobbins.implementation.framework.SingleTouchHandler.java
com.mdobbins.implementation.framework.TouchHandler.java
com.mdobbins.sample.Assets.java
com.mdobbins.sample.GameScreen.java
com.mdobbins.sample.LoadingScreen.java
com.mdobbins.sample.MainMenuScreen.java
com.mdobbins.sample.SampleGame.java