Java Code Examples for com.codename1.ui.Display#GAME_LEFT
The following examples show how to use
com.codename1.ui.Display#GAME_LEFT .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlackBerryImplementation.java From CodenameOne with GNU General Public License v2.0 | 6 votes |
public int getGameAction(int keyCode) { switch (keyCode) { // the enter key should also map to fire case '\n': case GAME_KEY_CODE_FIRE: return Display.GAME_FIRE; case GAME_KEY_CODE_UP: return Display.GAME_UP; case GAME_KEY_CODE_DOWN: return Display.GAME_DOWN; case GAME_KEY_CODE_LEFT: return Display.GAME_LEFT; case GAME_KEY_CODE_RIGHT: return Display.GAME_RIGHT; } return 0; }
Example 2
Source File: GameCanvasImplementation.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
/** * @inheritDoc */ public int getKeyCode(int gameAction) { if (portableKeyCodes == null) { portableKeyCodes = new int[]{Display.GAME_DOWN, Display.GAME_LEFT, Display.GAME_RIGHT, Display.GAME_UP, Display.GAME_FIRE}; portableKeyCodeValues = new int[5]; int currentValue = -500; int offset = 0; while (offset < portableKeyCodeValues.length) { currentValue--; try { if (canvas.getGameAction(currentValue) != 0) { continue; } } catch (IllegalArgumentException ignor) { // this is good, the game key is unassigned } portableKeyCodeValues[offset] = currentValue; offset++; } } for (int iter = 0; iter < portableKeyCodes.length; iter++) { if (portableKeyCodes[iter] == gameAction) { return portableKeyCodeValues[iter]; } } return 0; }
Example 3
Source File: TestRecorder.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
private String toGameKeyConstant(int k) { switch(k) { case Display.GAME_DOWN: return "Display.GAME_DOWN"; case Display.GAME_LEFT: return "Display.GAME_LEFT"; case Display.GAME_RIGHT: return "Display.GAME_RIGHT"; case Display.GAME_UP: return "Display.GAME_UP"; case Display.GAME_FIRE: return "Display.GAME_FIRE"; } return null; }
Example 4
Source File: BlackBerryImplementation.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
public int getKeyCode(int gameAction) { switch (gameAction) { case Display.GAME_FIRE: return GAME_KEY_CODE_FIRE; case Display.GAME_UP: return GAME_KEY_CODE_UP; case Display.GAME_DOWN: return GAME_KEY_CODE_DOWN; case Display.GAME_LEFT: return GAME_KEY_CODE_LEFT; case Display.GAME_RIGHT: return GAME_KEY_CODE_RIGHT; } return 0; }
Example 5
Source File: ImageViewer.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public void keyReleased(int key) { if(swipeableImages != null) { int gk = Display.getInstance().getGameAction(key); if((gk == Display.GAME_LEFT || gk == Display.GAME_UP) && (cycleLeft || swipeableImages.getSelectedIndex() > getImageLeftPos())) { new AnimatePanX(-1, getImageLeft(), getImageLeftPos()); return; } if(gk == Display.GAME_RIGHT || gk == Display.GAME_RIGHT && (cycleRight || swipeableImages.getSelectedIndex() < getImageRightPos())) { new AnimatePanX(2, getImageRight(), getImageRightPos()); return; } } }
Example 6
Source File: MultiComboBox.java From CodenameOne with GNU General Public License v2.0 | 4 votes |
/** * {@inheritDoc} */ public void keyPressed(int keyCode) { // scrolling events are in keyPressed to provide immediate feedback if (!handlesInput()) { return; } int gameAction = Display.getInstance().getGameAction(keyCode); int keyFwd; int keyBck; if (getOrientation() != HORIZONTAL) { keyFwd = Display.GAME_DOWN; keyBck = Display.GAME_UP; if (gameAction == Display.GAME_LEFT || gameAction == Display.GAME_RIGHT) { setHandlesInput(false); } } else { if (isRTL()) { keyFwd = Display.GAME_LEFT; keyBck = Display.GAME_RIGHT; } else { keyFwd = Display.GAME_RIGHT; keyBck = Display.GAME_LEFT; } if (gameAction == Display.GAME_DOWN || gameAction == Display.GAME_UP) { setHandlesInput(false); } } int selectedIndex = model.getSelectedIndex(); if (gameAction == keyBck) { if (selectedIndex>0) { if (model.getItemAt(selectedIndex-1) instanceof String) { if (selectedIndex==1) { // First item is an optgroup return; } model.setDirection(-1); selectedIndex--; model.setSelectedIndex(selectedIndex); } } } else if (gameAction == keyFwd) { if (selectedIndex<size()-1) { if (model.getItemAt(selectedIndex+1) instanceof String) { if (selectedIndex==size()-2) { //Last item is an optgroup return; } model.setDirection(1); selectedIndex++; model.setSelectedIndex(selectedIndex); } } } super.keyPressed(keyCode); model.setDirection(0); }
Example 7
Source File: MapComponent.java From CodenameOne with GNU General Public License v2.0 | 2 votes |
/** * Returns true if this is a left keycode * * @param keyCode * @return true if this is a left keycode */ protected boolean isLeftKey(int keyCode) { int game = Display.getInstance().getGameAction(keyCode); return game == Display.GAME_LEFT; }