Java Code Examples for com.codename1.ui.Display#GAME_FIRE

The following examples show how to use com.codename1.ui.Display#GAME_FIRE . 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 vote down vote up
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: MultiComboBox.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
/**
 * {{@inheritDoc}}
 */
public void keyReleased(int keyCode) {
    // other events are in keyReleased to prevent the next event from reaching the next form

    int gameAction = Display.getInstance().getGameAction(keyCode);
    if ((multiple) && (gameAction == Display.GAME_FIRE)) {
        boolean h = handlesInput();
        //setHandlesInput(!h);
        if (h) {
            fireActionEvent();
        }
        repaint();
        return;
    } else {
        super.keyReleased(keyCode);
    }
}
 
Example 3
Source File: GameCanvasImplementation.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @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 4
Source File: TestRecorder.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
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 5
Source File: BlackBerryImplementation.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
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 6
Source File: ContainerList.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void keyReleased(int keyCode) {
    super.keyReleased(keyCode);
    if(Display.getInstance().getGameAction(keyCode) == Display.GAME_FIRE) {
        fireActionEvent(new ActionEvent(ContainerList.this, keyCode));
    }
}
 
Example 7
Source File: Ads.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void keyReleased(int code) {
    if (Display.getInstance().getGameAction(code) == Display.GAME_FIRE) {
        launchAd();
        requestAd();
    }
}