Android Open Source - LucyTheMoocher Loop Pause From Project Back to project page LucyTheMoocher .
License The source code is released under:
MIT License
If you think the Android project LucyTheMoocher 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.lucythemoocher.loops;
/ * f r o m w w w . j a v a 2 s . c o m * /
import android.view.KeyEvent;
import com.lucythemoocher.R;
import com.lucythemoocher.Globals.Globals;
import com.lucythemoocher.controls.GlobalController;
import com.lucythemoocher.controls.KeysListener;
import com.lucythemoocher.gui.MenuButton;
import com.lucythemoocher.gui.MenuButtonListener;
import com.lucythemoocher.util.Timer;
public class LoopPause extends Loop implements MenuButtonListener, KeysListener {
private MenuButton buttonResume_;
private MenuButton buttonLeaveGame_;
private Timer lifeTime_;
private LoopGame game_;
private final static int RESUMEINDEX = 1;
private final static int LEAVEGAMEINDEX = 4;
private final static float RESUMEPERCENT_Y = 20;
private final static float LEAVEGAMEPERCENT_Y = 40;
public LoopPause(LoopGame game) {
buttonResume_ = new MenuButton(30, 30, RESUMEINDEX, R.drawable.mainmenu_button_newgame_normal,
R.drawable.mainmenu_button_newgame_focussed, R.drawable.mainmenu_button_newgame_clicked, this );
buttonLeaveGame_ = new MenuButton(30, 30, LEAVEGAMEINDEX, R.drawable.mainmenu_button_leave_normal,
R.drawable.mainmenu_button_leave_focussed, R.drawable.mainmenu_button_leave_clicked, this );
registerKeys();
lifeTime_ = new Timer(0);
game_ = game;
game_.pause();
}
public void update() {
buttonResume_.centerOn(Globals.getInstance().getCamera().w() / 2,
(Globals.getInstance().getCamera().h() / 100) * RESUMEPERCENT_Y);
buttonLeaveGame_.centerOn(Globals.getInstance().getCamera().w() / 2,
(Globals.getInstance().getCamera().h() / 100) * LEAVEGAMEPERCENT_Y);
}
public void render() {
Globals.getInstance().getGame().render();
buttonResume_.draw();
buttonLeaveGame_.draw();
}
public void onButtonClicked(int buttonIndex) {
switch (buttonIndex) {
case RESUMEINDEX:
game_.resume();
changeCurrentLoop(game_);
break ;
case LEAVEGAMEINDEX:
Globals.getInstance().stopGame();
changeCurrentLoop(new InitMenuLoop());
break ;
}
}
public void onLeaveLoop() {
buttonLeaveGame_.destroy();
buttonResume_.destroy();
unregisterKeys();
}
public void registerKeys() {
GlobalController.getInstance().registerKey(this );
}
public void unregisterKeys() {
GlobalController.getInstance().unregisterKey(this );
}
public void onKeyDown(int KeyCode, KeyEvent event) {
if (KeyCode == KeyEvent.KEYCODE_BACK && lifeTime_.timeFromCreation() > 100 && event.getRepeatCount() == 0) {
game_.resume();
changeCurrentLoop(game_);
}
}
}
Java Source Code List com.lucythemoocher.LucyTheMoocherActivity.java com.lucythemoocher.FX.FXManager.java com.lucythemoocher.FX.FX.java com.lucythemoocher.Globals.Globals.java com.lucythemoocher.actors.Actor.java com.lucythemoocher.actors.ActorsManager.java com.lucythemoocher.actors.Monster.java com.lucythemoocher.actors.MonstersManager.java com.lucythemoocher.actors.PlayerCharacter.java com.lucythemoocher.actors.Projectile.java com.lucythemoocher.actors.ProjectilesManager.java com.lucythemoocher.actors.Tank.java com.lucythemoocher.actors.TargetCharacter.java com.lucythemoocher.actors.maincharacter.state.StateAttack.java com.lucythemoocher.actors.maincharacter.state.StateFalling.java com.lucythemoocher.actors.maincharacter.state.StateJumping.java com.lucythemoocher.actors.maincharacter.state.StateNone.java com.lucythemoocher.actors.maincharacter.state.StateRunning.java com.lucythemoocher.actors.maincharacter.state.StateWallSliding.java com.lucythemoocher.actors.maincharacter.state.StateWallWalking.java com.lucythemoocher.actors.maincharacter.state.State.java com.lucythemoocher.controls.AIController.java com.lucythemoocher.controls.ActionController.java com.lucythemoocher.controls.ButtonListener.java com.lucythemoocher.controls.Controllable.java com.lucythemoocher.controls.Controller.java com.lucythemoocher.controls.GlobalController.java com.lucythemoocher.controls.KeysListener.java com.lucythemoocher.controls.TouchListener.java com.lucythemoocher.events.EventNormal.java com.lucythemoocher.events.EventSlow.java com.lucythemoocher.events.Event.java com.lucythemoocher.game.GameThread.java com.lucythemoocher.game.Game.java com.lucythemoocher.game.LevelLoader.java com.lucythemoocher.graphics.ActorDrawer.java com.lucythemoocher.graphics.Animation.java com.lucythemoocher.graphics.Background.java com.lucythemoocher.graphics.Camera.java com.lucythemoocher.graphics.Drawable.java com.lucythemoocher.graphics.Grid.java com.lucythemoocher.graphics.HUD.java com.lucythemoocher.graphics.Image.java com.lucythemoocher.graphics.PersistentEffect.java com.lucythemoocher.graphics.PersistentPic.java com.lucythemoocher.graphics.PictureContainer.java com.lucythemoocher.gui.MenuButtonListener.java com.lucythemoocher.gui.MenuButtonTouchListener.java com.lucythemoocher.gui.MenuButton.java com.lucythemoocher.loops.CreditsLoop.java com.lucythemoocher.loops.GameOverLoop.java com.lucythemoocher.loops.InitMenuLoop.java com.lucythemoocher.loops.LivesMenuLoop.java com.lucythemoocher.loops.LoopGame.java com.lucythemoocher.loops.LoopPause.java com.lucythemoocher.loops.Loop.java com.lucythemoocher.loops.MasterLoop.java com.lucythemoocher.physics.Box.java com.lucythemoocher.physics.Cinematic.java com.lucythemoocher.physics.Map.java com.lucythemoocher.sounds.SoundManager.java com.lucythemoocher.sounds.SoundsState.java com.lucythemoocher.sounds.StateLevel1.java com.lucythemoocher.sounds.StateLevel2.java com.lucythemoocher.sounds.StateLevel3.java com.lucythemoocher.sounds.StateNormal.java com.lucythemoocher.util.Direction.java com.lucythemoocher.util.MathUtil.java com.lucythemoocher.util.Resources.java com.lucythemoocher.util.Timer.java