當前位置: 首頁>>代碼示例>>Java>>正文


Java KeyEvent.VK_W屬性代碼示例

本文整理匯總了Java中java.awt.event.KeyEvent.VK_W屬性的典型用法代碼示例。如果您正苦於以下問題:Java KeyEvent.VK_W屬性的具體用法?Java KeyEvent.VK_W怎麽用?Java KeyEvent.VK_W使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在java.awt.event.KeyEvent的用法示例。


在下文中一共展示了KeyEvent.VK_W屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: keyReleased

@Override
public void keyReleased(final @NonNull KeyEvent e) {
    switch (e.getKeyCode()) {
        case KeyEvent.VK_UP:
        case KeyEvent.VK_W: {
            map.getPlayer().move(0, -1);
            break;
        }
        case KeyEvent.VK_DOWN:
        case KeyEvent.VK_S: {
            map.getPlayer().move(0, 1);
            break;
        }
        case KeyEvent.VK_LEFT:
        case KeyEvent.VK_A: {
            map.getPlayer().move(-1, 0);
            break;
        }
        case KeyEvent.VK_RIGHT:
        case KeyEvent.VK_D: {
            map.getPlayer().move(1, 0);
            break;
        }
    }
}
 
開發者ID:Valkryst,項目名稱:VRoguelike,代碼行數:25,代碼來源:GameScreen.java

示例2: keyReleased

public boolean keyReleased(KeyReleasedEvent e) {
    switch(e.getKey()) {
        case KeyEvent.VK_W:
        up = false;
        return true;
        case KeyEvent.VK_SPACE:
        up = false;
        return true;
        case KeyEvent.VK_A:
        left = false;
        return true;
        case KeyEvent.VK_S:
        return true;
        case KeyEvent.VK_D:
        right = false;
        return true;
    }
    return false;
}
 
開發者ID:ritcat14,項目名稱:The-Mysterious-Mind-Of-Jack,代碼行數:19,代碼來源:Player.java

示例3: keyPressed

public boolean keyPressed(KeyPressedEvent e) {
    switch(e.getKey()) {
        case KeyEvent.VK_W:
         up = true;
         return true;
        case KeyEvent.VK_SPACE:
         up = true;
         return true;
        case KeyEvent.VK_A:
         left = true;
         return true;
        case KeyEvent.VK_S:
         return true;
        case KeyEvent.VK_D:
         right = true;
         return true;
    }
    return false;
}
 
開發者ID:ritcat14,項目名稱:The-Mysterious-Mind-Of-Jack,代碼行數:19,代碼來源:Player.java

示例4: keyPressed

/**
 * Notification from AWT that a key has been pressed. Note that
 * a key being pressed is equal to being pushed down but *NOT*
 * released. Thats where keyTyped() comes in.
 * 
 * @param e
 *            The details of the key that was pressed
 */
@Override
public void keyPressed(KeyEvent e) {
	switch (e.getKeyCode()) {
	// Jump
	case KeyEvent.VK_W:
	// climb e jump
	case KeyEvent.VK_SPACE:
		game.player.startClimb();
		break;
	// move left
	case KeyEvent.VK_A:
		game.player.startLeft(e.isShiftDown());
		break;
	// move right
	case KeyEvent.VK_D:
		game.player.startRight(e.isShiftDown());
		break;
	}
}
 
開發者ID:DreamBlocks,項目名稱:DreamBlocks,代碼行數:27,代碼來源:AwtEventsHandler.java

示例5: keyReleased

/**
 * Notification from AWT that a key has been released.
 * 
 * @param e
 *            The details of the key that was released
 */
@Override
public void keyReleased(KeyEvent e) {
	switch (e.getKeyCode()) {
	case KeyEvent.VK_W:
	case KeyEvent.VK_SPACE:
		game.player.endClimb();
		break;
	case KeyEvent.VK_A:
		game.player.stopLeft();
		break;
	case KeyEvent.VK_D:
		game.player.stopRight();
		break;
	// pressed ESC to return to the game menu
	case KeyEvent.VK_ESCAPE:
		if (game.isInInventory()) {
			game.closeInventory();
		} else {
			game.goToMainMenu();
		}
		break;
	}
}
 
開發者ID:DreamBlocks,項目名稱:DreamBlocks,代碼行數:29,代碼來源:AwtEventsHandler.java

示例6: toggle

/**
	  * This method is used to turn keyboard key presses into actions
	  */
	 private void toggle(KeyEvent ke, boolean pressed) {
		  if ( ke.getKeyCode( ) == KeyEvent.VK_NUMPAD8 ) up.toggle( pressed ); //press keypad 8, moves up
		  if ( ke.getKeyCode( ) == KeyEvent.VK_NUMPAD2 ) down.toggle( pressed ); //press keypad 2, moves down
		  if ( ke.getKeyCode( ) == KeyEvent.VK_NUMPAD4 ) left.toggle( pressed ); //press keypad 4, moves left
		  if ( ke.getKeyCode( ) == KeyEvent.VK_NUMPAD6 ) right.toggle( pressed ); //press keypad 6, moves right
		  if ( ke.getKeyCode( ) == KeyEvent.VK_W ) up.toggle( pressed ); //press W, moves up
		  if ( ke.getKeyCode( ) == KeyEvent.VK_S ) down.toggle( pressed ); //press S, moves down
		  if ( ke.getKeyCode( ) == KeyEvent.VK_A ) left.toggle( pressed ); //press A, moves left
		  if ( ke.getKeyCode( ) == KeyEvent.VK_D ) right.toggle( pressed ); //press D, moves right
		  if ( ke.getKeyCode( ) == KeyEvent.VK_UP ) up.toggle( pressed ); //press up arrow, moves up
		  if ( ke.getKeyCode( ) == KeyEvent.VK_DOWN ) down.toggle( pressed ); //press down arrow, moves down
		  if ( ke.getKeyCode( ) == KeyEvent.VK_LEFT ) left.toggle( pressed ); //press left arrow, moves left
		  if ( ke.getKeyCode( ) == KeyEvent.VK_RIGHT ) right.toggle( pressed ); //press right arrow, moves right

//		  if ( ke.getKeyCode( ) == KeyEvent.VK_TAB ) menu.toggle( pressed ); //press Tab, menu toggled
//		  if ( ke.getKeyCode( ) == KeyEvent.VK_ALT ) menu.toggle( pressed ); //press Alt, menu toggled
		  if ( ke.getKeyCode( ) == KeyEvent.VK_ALT_GRAPH ) menu.toggle( pressed ); //press Alt-Graph, menu toggled
		  if ( ke.getKeyCode( ) == KeyEvent.VK_SPACE ) attack.toggle( pressed ); //press space, attack toggled
		  if ( ke.getKeyCode( ) == KeyEvent.VK_CONTROL ) attack.toggle( pressed ); //press Ctrl, attack toggled
		  if ( ke.getKeyCode( ) == KeyEvent.VK_NUMPAD0 ) attack.toggle( pressed ); //press keypad 0, attack toggled
		  if ( ke.getKeyCode( ) == KeyEvent.VK_INSERT ) attack.toggle( pressed ); //press Insert, attack toggled
		  if ( ke.getKeyCode( ) == KeyEvent.VK_ENTER ) menu.toggle( pressed ); //press Enter, attack toggled
		  
		  if ( ke.getKeyCode( ) == KeyEvent.VK_X ) menu.toggle( pressed ); //press X, menu toggled
		  if ( ke.getKeyCode( ) == KeyEvent.VK_C ) attack.toggle( pressed ); // press C, attack toggled
	 }
 
開發者ID:BrianGaucher,項目名稱:Camasia,代碼行數:29,代碼來源:InputHandler.java

示例7: keyReleased

private void keyReleased(KeyEvent e) {
	int key = e.getKeyCode();
	
	switch (key) {
		case KeyEvent.VK_W: // up
			System.out.println("W pressed.");
			_board.handleUp("W" );
			break;
		case KeyEvent.VK_S: // down
			System.out.println("S pressed.");
			_board.handleDown("S");
			break;
		case KeyEvent.VK_A: // left
			System.out.println("A pressed.");
			_board.handleLeft("A");
			break;
		case KeyEvent.VK_D: // right
			System.out.println("D pressed.");
			_board.handleRight("D");
			break;
		default:
	}		
}
 
開發者ID:lukealba,項目名稱:2048-java-swing,代碼行數:23,代碼來源:Main.java

示例8: keyPressed

/**
 * Wir überschreiben was beim drücken einer Taste passiert.
 * hat den nachteil das ohne unser zutun sonst nix mehr passiert
 * z.B. ESC oder ähnliches.
 * @param e 
 */
@Override
public void keyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_S) {
        setKey_down(true);
    }
    if (e.getKeyCode() == KeyEvent.VK_W) {
        setKey_up(true);
    }
    if (e.getKeyCode() == KeyEvent.VK_D) {
        setKey_right(true);
    }
    if (e.getKeyCode() == KeyEvent.VK_A) {
        setKey_left(true);
    }
    if(e.getKeyCode() == KeyEvent.VK_ESCAPE){
        System.exit(0);
    }
}
 
開發者ID:Marc-Reis,項目名稱:CitizenOfTheStars2D,代碼行數:24,代碼來源:Frame.java

示例9: keyReleased

/**
 * Gleiches spiel nur für das Loslassen einer Taste
 * @param e 
 */
@Override
public void keyReleased(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_S) {
        setKey_down(false);
    }
    if (e.getKeyCode() == KeyEvent.VK_W) {
        setKey_up(false);
    }
    if (e.getKeyCode() == KeyEvent.VK_D) {
        setKey_right(false);
    }
    if (e.getKeyCode() == KeyEvent.VK_A) {
        setKey_left(false);
    }
}
 
開發者ID:Marc-Reis,項目名稱:CitizenOfTheStars2D,代碼行數:19,代碼來源:Frame.java

示例10: update

public void update() {
	up = keys[KeyEvent.VK_UP] || keys[KeyEvent.VK_W];		
	down = keys[KeyEvent.VK_DOWN] || keys[KeyEvent.VK_S];		
	left = keys[KeyEvent.VK_LEFT] || keys[KeyEvent.VK_A];
	right = keys[KeyEvent.VK_RIGHT] || keys[KeyEvent.VK_D];
	
	dash = keys[KeyEvent.VK_CONTROL];
}
 
開發者ID:Samanimkr,項目名稱:KingdomKing,代碼行數:8,代碼來源:Keyboard.java

示例11: keySet

public static void keySet(int i, boolean b) {
	if(i == KeyEvent.VK_UP) keyState[UP] = b;
	else if(i == KeyEvent.VK_LEFT) keyState[LEFT] = b;
	else if(i == KeyEvent.VK_DOWN) keyState[DOWN] = b;
	else if(i == KeyEvent.VK_RIGHT) keyState[RIGHT] = b;
	else if(i == KeyEvent.VK_W) keyState[BUTTON1] = b;
	else if(i == KeyEvent.VK_E) keyState[BUTTON2] = b;
	else if(i == KeyEvent.VK_R) keyState[BUTTON3] = b;
	else if(i == KeyEvent.VK_F) keyState[BUTTON4] = b;
	else if(i == KeyEvent.VK_ENTER) keyState[ENTER] = b;
	else if(i == KeyEvent.VK_ESCAPE) keyState[ESCAPE] = b;
}
 
開發者ID:tonikolaba,項目名稱:BatBat-Game,代碼行數:12,代碼來源:Keys.java

示例12: keyCodeToInput

private Inputs keyCodeToInput(int keyCode, int keyLocation) {
    switch (keyCode) {
        case KeyEvent.VK_UP:
            return Inputs.RightDPadUp;
        case KeyEvent.VK_DOWN:
            return Inputs.RightDPadDown;
        case KeyEvent.VK_LEFT:
            return Inputs.RightDPadLeft;
        case KeyEvent.VK_RIGHT:
            return Inputs.RightDPadRight;
        case KeyEvent.VK_I:
            return Inputs.RightDPadUp;
        case KeyEvent.VK_K:
            return Inputs.RightDPadDown;
        case KeyEvent.VK_J:
            return Inputs.RightDPadLeft;
        case KeyEvent.VK_L:
            return Inputs.RightDPadRight;
        case KeyEvent.VK_W:
            return Inputs.LeftDPadUp;
        case KeyEvent.VK_S:
            return Inputs.LeftDPadDown;
        case KeyEvent.VK_A:
            return Inputs.LeftDPadLeft;
        case KeyEvent.VK_D:
            return Inputs.LeftDPadRight;
        case KeyEvent.VK_SPACE:
            return Inputs.Select;
        case KeyEvent.VK_ENTER:
            return Inputs.Start;
        case KeyEvent.VK_F:
            return Inputs.A;
        case KeyEvent.VK_H:
            return Inputs.B;
        case KeyEvent.VK_E:
            return Inputs.L;
        case KeyEvent.VK_U:
            return Inputs.R;
        case KeyEvent.VK_CONTROL:
            if (keyLocation == KeyEvent.KEY_LOCATION_RIGHT) {
                return Inputs.A;
            }
            break;
        case KeyEvent.VK_NUMPAD0:
            return Inputs.B;
        case KeyEvent.VK_B:
            return Inputs.LowBattery;
    }
    return null;
}
 
開發者ID:gilles-duboscq,項目名稱:jvb,代碼行數:50,代碼來源:DefaultSwingInputProvider.java

示例13: handleCtrlKey

/**
 * Handle the keyboard events when Control key is pressed.
 *
 * @param key the key code
 */
private void handleCtrlKey(int key) {
    switch (key) {
        case KeyEvent.VK_A:
            // decrease left
            changeSize(1, 0, 0, 0);
            break;

        case KeyEvent.VK_W:
            // decrease top
            changeSize(0, 1, 0, 0);
            break;

        case KeyEvent.VK_D:
            // decrease right
            changeSize(0, 0, -1, 0);
            break;

        case KeyEvent.VK_S:
            // decrease bottom
            changeSize(0, 0, 0, -1);
            break;

        default:
            // do nothing
            break;
    }
}
 
開發者ID:buni-rock,項目名稱:Pixie,代碼行數:32,代碼來源:BoundingBoxWindow.java

示例14: handleAltKey

/**
 * Handle the keyboard events when Alt key is pressed.
 *
 * @param key the key code
 */
private void handleAltKey(int key) {
    switch (key) {
        case KeyEvent.VK_A:
            // increase left
            changeSize(-1, 0, 0, 0);
            break;

        case KeyEvent.VK_W:
            // increase top
            changeSize(0, -1, 0, 0);
            break;

        case KeyEvent.VK_D:
            // increase right
            changeSize(0, 0, 1, 0);
            break;

        case KeyEvent.VK_S:
            // increase bottom
            changeSize(0, 0, 0, 1);
            break;

        case KeyEvent.VK_Z:
            // decrease box
            changeSize(1, 1, -1, -1);
            break;

        case KeyEvent.VK_X:
            // increase box
            changeSize(-1, -1, 1, 1);
            break;

        default:
            // do nothing
            break;
    }
}
 
開發者ID:buni-rock,項目名稱:Pixie,代碼行數:42,代碼來源:BoundingBoxWindow.java

示例15: handleNormalKey

/**
 * Handle the keyboard events.
 *
 * @param key the key code
 */
private void handleNormalKey(int key) {
    switch (key) {
        case KeyEvent.VK_DELETE:
            deleteObject();
            break;

        case KeyEvent.VK_A:
            // move the box to the left                            
            moveObject(-1, 0);
            break;

        case KeyEvent.VK_D:
            // move the box to the right
            moveObject(1, 0);
            break;

        case KeyEvent.VK_W:
            // move the box up
            moveObject(0, -1);
            break;

        case KeyEvent.VK_S:
            // move the box down
            moveObject(0, 1);
            break;

        default:
            // do nothing
            break;
    }
}
 
開發者ID:buni-rock,項目名稱:Pixie,代碼行數:36,代碼來源:BoundingBoxWindow.java


注:本文中的java.awt.event.KeyEvent.VK_W屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。