当前位置: 首页>>代码示例>>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;未经允许,请勿转载。