手柄dpad(dPad是什么意思)

xfxzc.comc963 20 0

一、d-pad是哪个键

十字键。十字方向键(D-Pad)是任天堂在游戏手柄方面最著名的创举,每个游戏手柄上都能看到十字方向键的存在。十字方向键的历史要追溯到宫本茂、横井军平和掌机版的《大金刚》。中间是Select、Start,下方有一枚独立配置键,3个状态灯可以对应3个不同的手柄配置,按下即可切换已保存的配置。

二、游戏手柄推荐

游戏手柄推荐XBOX手柄,因为本身就是微软出品,和Win10,XBOX都是配套开发,而且微软自己也在努力搞大闭环,所以兼容性等等都是最好的,近10年来的PC游戏只要支持手柄就没有不支持XBOX的。

XBOX手柄特点

微软一贯以外设产品的人体工学著称,XBOX非常的人体工学,可惜是欧美人那种。欧美人天生一双大手,所以我们玩起来总觉得贴合性差了一点。在PC上用大几率要额外买蓝牙接收器,再用软件模拟XBOX360的键位。

全新的Dpad设计。Dpad设计旨在改善玩家游玩方式以及操作性它是新设计中我最喜欢的部分之一,根据现在广泛的游戏类型及玩家的个人风格,Dpad的使用方法会有很多的不同。这也是为什么Elite控制器具有可互换的D-pad。

三、dPad是什么意思

dPad常见于各大安卓模拟器,相当于手机中的“上下左右中”五个按键(也可用于游戏手柄的按键)。

安卓模拟器是一款模拟软件。它能在电脑上模拟安卓手机系统,并能安装、使用、卸载安卓应用软件,让你在电脑上也能体验操作安卓系统的全过程。dPad是安卓模拟器可以模拟的一个功能

编写代码:

[xhtml] view plaincopy

<?xml version="1.0" encoding="utf-8"?>

<AbsoluteLayout

xmlns:android=""

android:orientation="vertical"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:background="#FFFFFF"

>

<Button

android:id="@+id/myButton1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="move me"

android:layout_x="20px"

android:layout_y="40px"/>

</AbsoluteLayout>

activity代码:

[java] view plaincopy

package cn.com.chenzheng_java;

import android.app.Activity;

import android.os.Bundle;

import android.util.DisplayMetrics;

import android.view.KeyEvent;

import android.widget.AbsoluteLayout;

import android.widget.Button;

import android.widget.Toast;

/**

*@description控制手机的上下左右四个方向键

*@author chenzheng_java

*

*/

public class DpadActivity extends Activity{

Button button;

DisplayMetrics metrics= new DisplayMetrics();

int screenx= 0;//屏幕宽度

int screeny= 0;//屏幕高度

int buttonWidth= 80;//按钮宽度

int buttonHeight= 40;//按钮高度

int currentX= 0;//按钮的当前x坐标

int currentY= 0;//按钮的当前Y坐标

int step= 0;//移动时候的步长

@Override

protected void onCreate(Bundle savedInstanceState){

super.onCreate(savedInstanceState);

setContentView(R.layout.dpad);

button=(Button) findViewById(R.id.myButton1);

getWindowManager().getDefaultDisplay().getMetrics(metrics);

screenx= metrics.widthPixels;

screeny= metrics.heightPixels;

/* buttonWidth= button.getWidth();

buttonHeight= button.getHeight();*/

currentX=(screenx-buttonWidth)/2;

currentY=(screeny-buttonHeight)/2;

step= 2;

button.setLayoutParams(new AbsoluteLayout.LayoutParams(buttonWidth, buttonHeight, currentX, currentY));

}

/**

*当前后左右键被按下的时候,被触发(这里可是有前提的哦,那就是当前的activity中必须没有view正在监听按键

*,例如:当前如果有一个EditText正在等待输入,当我们按下dpad时,不会触发事件哦)

* Activity.onKeyDown();

当某个键被按下时会触发,但不会被任何的该Activity内的任何view处理。

默认按下KEYCODE_BACK键后会回到上一个Activity。

*/

@Override

public boolean onKeyDown(int keyCode, KeyEvent event){

switch(keyCode){

case KeyEvent.KEYCODE_DPAD_DOWN://按向下键

moveDown();

break;

case KeyEvent.KEYCODE_DPAD_UP://按向上键

moveUp();

case KeyEvent.KEYCODE_DPAD_LEFT://按向左键

moveLeft();

case KeyEvent.KEYCODE_DPAD_RIGHT://按向右键

moveRight();

default:

break;

}

return super.onKeyDown(keyCode, event);

}

@SuppressWarnings("deprecation")

private void moveDown(){

int temp= currentY+step;

if(temp>(screeny-buttonHeight)){

showToast("到头了哦!");

button.setLayoutParams(new AbsoluteLayout.LayoutParams(buttonWidth, buttonHeight, screenx, screeny-buttonHeight));

}

else{

currentY= currentY+step;

AbsoluteLayout.LayoutParams params=

new AbsoluteLayout.LayoutParams(buttonWidth, buttonHeight, currentX, currentY);

button.setLayoutParams(params);

}

//button.setLayoutParams(new AbsoluteLayout.LayoutParams(buttonWidth, buttonHeight, currentX, currentY-2));

}

@SuppressWarnings("deprecation")

private void moveUp(){

int temp= currentY-step;

if(temp<=0){

showToast("往上到头了哦!");

button.setLayoutParams(new AbsoluteLayout.LayoutParams(buttonWidth, buttonHeight, screenx, 0));

}

else{

currentY= currentY-step;

AbsoluteLayout.LayoutParams params=

new AbsoluteLayout.LayoutParams(buttonWidth, buttonHeight, currentX, currentY);

button.setLayoutParams(params);

}

}

@SuppressWarnings("deprecation")

private void moveLeft(){

int temp= currentX-step;

if(temp<=0){

showToast("往左边到头了哦!");

button.setLayoutParams(new AbsoluteLayout.LayoutParams(buttonWidth, buttonHeight, 0, screeny));

}

else{

currentX= currentX-step;

AbsoluteLayout.LayoutParams params=

new AbsoluteLayout.LayoutParams(buttonWidth, buttonHeight, currentX, currentY);

button.setLayoutParams(params);

}

}

@SuppressWarnings("deprecation")

private void moveRight(){

int temp= currentX+step;

if(temp>=(screenx-buttonWidth)){

showToast("往右边到头了哦!");

button.setLayoutParams(new AbsoluteLayout.LayoutParams(buttonWidth, buttonHeight, screenx-buttonWidth, currentY));

}

else{

currentX= currentX+step;

AbsoluteLayout.LayoutParams params=

new AbsoluteLayout.LayoutParams(buttonWidth, buttonHeight, currentX, currentY);

button.setLayoutParams(params);

}

}

/**

*弹出提示信息

*@param text提示信息

*/

private void showToast(String text){

Toast.makeText(this, text, Toast.LENGTH_LONG).show();

抱歉,评论功能暂时关闭!