123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- package com.darkdimension.ritle_run;
- import android.graphics.Canvas;
- import android.graphics.Paint;
- public abstract class Menu
- {
- public static enum Action
- {
- TO_MAIN_MENU,
- TO_GAME,
- TO_EXTRA,
- EXIT_GAME,
- TO_FACEBOOK,
- TO_TWITTER,
- TO_TUMBLR,
- TO_PLAY_STORE,
- SHOW_AD,
- CHANGE_CHAR,
- NO_ACTION
- }
- //Create-Destroy
- protected DiAnimation aBasic = new DiAnimation(10);
- protected Paint invisible = new Paint();
- protected Action nMenu = null;
- //Touch
- protected boolean bTouched = false;
- protected int touchX = -1, touchY = -1;
- //Draw
- protected boolean bDraw = true;
- public Menu()
- {
- //Starting invisible
- invisible.setAlpha(0);
- //Starting Menu
- aBasic.startFromBeginning();
- }
- //Input
- protected boolean touch(int x, int y)
- {
- //Apply touch
- bTouched = true;
- touchX = x;
- touchY = y;
- //No sliding
- return false;
- }
- //Update
- protected Action update()
- {
- //Animation
- if (aBasic.update())
- {
- //Invisible animations
- invisible.setAlpha(aBasic.getCounter() * 255 / aBasic.getMax());
- //Draw Changes
- bDraw = true;
- }
- //Nothing happened
- return Action.NO_ACTION;
- }
- //Draw
- protected void draw(Canvas canvas)
- {
- //Don't draw again
- bDraw = false;
- }
- //Actions
- protected void forceDraw() {bDraw = true;}
- public void destroy(Action gMenu)
- {
- //Save next menu
- nMenu = gMenu;
- //Start destroy animation
- aBasic.startFromEnd();
- }
- //Isers
- public boolean isAnimating() {return aBasic.isRunning();}
- public boolean needsToBeDrawn(){return bDraw;}
- }
|