Android Open Source - CatchDROP Key Sequence






From Project

Back to project page CatchDROP.

License

The source code is released under:

GNU General Public License

If you think the Android project CatchDROP 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 projects.nerdybuzz.catchdrop;
/*from  w w  w  .  j a v  a2  s  .c o  m*/
import java.util.ArrayList;
import java.util.Arrays;

import com.badlogic.gdx.InputAdapter;

public class KeySequence extends InputAdapter {
  private ArrayList<Integer> sequence, keysPressed;
  public boolean sequenceFound = false;
  
  public KeySequence(ArrayList<Integer> sequence) {
    this.sequence = sequence;
    this.keysPressed = new ArrayList<Integer>();
  }
  
  public boolean sequenceFound() {
    return sequenceFound;
  }
  
  public boolean keyDown(int keycode) {
    System.out.println("keyDown from KeySequence is called.");
    keysPressed.add(keycode);
    System.out.println(keysPressed);
    /*
    if(Arrays.equals(sequence.toArray(), keysPressed.toArray())) {
      keysPressed.clear();
      System.out.println("Well, this worked...");
      sequenceFound = true;
    } else {
      sequenceFound = false;
    }
    // */
    return true;
  }
  
  public void update() {
    for(int i=0;i<sequence.toArray().length;i++){
      if(i < keysPressed.toArray().length && keysPressed.toArray()[i] != null) {
        if(keysPressed.toArray()[i] != sequence.toArray()[i]) keysPressed.clear();
      }
    }
    
    if(Arrays.equals(sequence.toArray(), keysPressed.toArray())) {
      keysPressed.clear();
      sequenceFound = true;
    }
  }
  
  public void reset() {
    keysPressed.clear();
    sequenceFound = false;
  }
}




Java Source Code List

android.UnusedStub.java
com.google.example.games.basegameutils.BaseGameActivity.java
com.google.example.games.basegameutils.BaseGameUtils.java
com.google.example.games.basegameutils.GameHelperUtils.java
com.google.example.games.basegameutils.GameHelper.java
projects.nerdybuzz.catchdrop.BurntToastObj.java
projects.nerdybuzz.catchdrop.CDGame.java
projects.nerdybuzz.catchdrop.ClassicGame.java
projects.nerdybuzz.catchdrop.EndScreen.java
projects.nerdybuzz.catchdrop.FallingAct.java
projects.nerdybuzz.catchdrop.FallingRect.java
projects.nerdybuzz.catchdrop.GameScreen.java
projects.nerdybuzz.catchdrop.KeySequence.java
projects.nerdybuzz.catchdrop.MainMenuScreen.java
projects.nerdybuzz.catchdrop.PoisonDrop.java
projects.nerdybuzz.catchdrop.SettingsScreen.java
projects.nerdybuzz.catchdrop.TimePowerUp.java
projects.nerdybuzz.catchdrop.ZenGame.java
projects.nerdybuzz.catchdrop.android.AndroidLauncher.java
projects.nerdybuzz.catchdrop.client.HtmlLauncher.java
projects.nerdybuzz.catchdrop.desktop.AppletLauncher.java
projects.nerdybuzz.catchdrop.desktop.DesktopLauncher.java
projects.nerdybuzz.catchdrop.googleservices.DesktopGoogleServices.java
projects.nerdybuzz.catchdrop.googleservices.IGoogleServices.java