Java 和遊戲控制器 (一)
at July 9th, 2004 by 小影
前言:這是小影的Java遊戲系列第一彈!至於這第一彈能否完成和有沒有第二彈還要看看我的意志力和心情了
制作遊戲最重要的是甚麼?3D 顯示?音樂音效?對於遊戲來說最重要的還是操作,一個設計多好的遊戲如果操作很差也會讓人玩不下去,所以操作器支援對遊戲制作是至為重要的。
這一篇將會介紹JInput的背景、安裝和寫一個簡單示範程式顯示所有己連接的控制器;接著的文章會為逐步增加一個控制元件應有的功能,最後成為一個可以用文字檔在執行時自訂的通用控制完件。
12 Responses to “Java 和遊戲控制器 (一)”
By sit ka ho on Dec 10, 2005 | Reply
hi!!!
By randyvai on Dec 25, 2005 | Reply
您好.請問您論壇中所提到的
/jinput.jar
/jutils.jar
/controller/dxinput.jar
/controller/dxinput.dll
Jinput跟controller是資料夾的意思嗎?
“接著開一個Command Prompt,轉到下輸入指令”
By 小影 on Dec 25, 2005 | Reply
是資料夾的意思。你的問題是甚麼?
By randyvai on Dec 26, 2005 | Reply
您好..我遇到雖然執行時能讀取滑鼠和鍵盤且皆有反應..卻無法讀到搖桿的問題..謝謝您
By 小影 on Dec 26, 2005 | Reply
你在「控制台」> 「遊戲控制器」中見到你的搖桿嗎?JInput是用Direct X去存取控制器,理論上Keyboard/Mouse和Joypad是一樣的。
By randyvai on Dec 27, 2005 | Reply
恩,在控制台見的到搖桿—我們現在遇到的問題有兩個.1.我們插著搖桿再執行不會跳出那三個視窗,—2.不插搖桿執行跳出的三個視窗後再插入搖桿,只有鍵盤跟滑鼠的視窗有資訊,搖桿的視窗雖然有出來不過是空白的內容,謝謝您
By randyvai on Dec 27, 2005 | Reply
.
.
Found candidate class: net/java/games/input/DirectInputEnvironmentPlugin.class
Adding class to plugins:net.java.games.input.DirectInputEnvironmentPlugin
Examining file : net/java/games/input/DirectInputKeyboard.class
Examining file : net/java/games/input/DirectInputMouse$BallAxis.class
Examining file : net/java/games/input/DirectInputMouse$BallImpl.class
Examining file : net/java/games/input/DirectInputMouse$ButtonImpl.class
Examining file : net/java/games/input/DirectInputMouse$ButtonsImpl.class
Examining file : net/java/games/input/DirectInputMouse.class
Found candidate class: net/java/games/input/DirectInputEnvironmentPlugin.class
Adding class to plugins:net.java.games.input.DirectInputEnvironmentPlugin
Examining file : net/java/games/input/DirectInputKeyboard.class
Examining file : net/java/games/input/DirectInputMouse$BallAxis.class
Examining file : net/java/games/input/DirectInputMouse$BallImpl.class
Examining file : net/java/games/input/DirectInputMouse$ButtonImpl.class
Examining file : net/java/games/input/DirectInputMouse$ButtonsImpl.class
Examining file : net/java/games/input/DirectInputMouse.class
By randyvai on Dec 27, 2005 | Reply
剛剛去買了有驅動程式的香菇頭搖桿,其中改變為Creating USB Vibration Joystick polling = true,原本為flase,
也多出了
Reseting rumbler Y axis before exit
Reseting rumbler Rz axis before exit
Reseting rumbler X axis before exit
Reseting rumbler Z axis before exit
不過還是沒跳出可以輸入的三個視窗
By randyvai on Dec 27, 2005 | Reply
這是我們執行所產生的資訊,如果可以的話煩請您幫我們看看,謝謝您
Microsoft Windows XP [版本 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\Den>cd C:\j2sdk1.4.2_10\jre\lib\ext\JINPUT
C:\j2sdk1.4.2_10\jre\lib\ext\JINPUT>java -classpath “.;jinput.jar;jutils.jar” ne
t.java.games.input.test.ControllerReadTest
Scanning jar: dxinput.jar
Examining file : META-INF/
Examining file : META-INF/MANIFEST.MF
Examining file : net/
Examining file : net/java/
Examining file : net/java/games/
Examining file : net/java/games/input/
Examining file : net/java/games/input/DirectInputAxis.class
Examining file : net/java/games/input/DirectInputDevice.class
Examining file : net/java/games/input/DirectInputEnvironmentPlugin.class
Found candidate class: net/java/games/input/DirectInputEnvironmentPlugin.class
Adding class to plugins:net.java.games.input.DirectInputEnvironmentPlugin
Examining file : net/java/games/input/DirectInputKeyboard.class
Examining file : net/java/games/input/DirectInputMouse$BallAxis.class
Examining file : net/java/games/input/DirectInputMouse$BallImpl.class
Examining file : net/java/games/input/DirectInputMouse$ButtonImpl.class
Examining file : net/java/games/input/DirectInputMouse$ButtonsImpl.class
Examining file : net/java/games/input/DirectInputMouse.class
OS name is: Windows XP
DX8 plugin is supported
OS name is: Windows XP
DX8 plugin is supported
Creating USB Vibration Joystick polling = true
Supported effects: Constant force Ramp force Periodic force Periodic force Perio
dic force Periodic force Periodic force Condition force Condition force Conditio
n force Condition force Custom force
effect is in the rz axis
Supported effects: Constant force Ramp force Periodic force Periodic force Perio
dic force Periodic force Periodic force Condition force Condition force Conditio
n force Condition force Custom force
effect is in the z axis
Supported effects: Constant force Ramp force Periodic force Periodic force Perio
dic force Periodic force Periodic force Condition force Condition force Conditio
n force Condition force Custom force
effect is in the y axis
Supported effects: Constant force Ramp force Periodic force Periodic force Perio
dic force Periodic force Periodic force Condition force Condition force Conditio
n force Condition force Custom force
effect is in the x axis
Exception in thread “main” java.lang.NoSuchMethodError: java.lang.String.contain
s(Ljava/lang/CharSequence;)Z
at net.java.games.input.DirectInputAxis.(DirectInputAxis.java:140)
at net.java.games.input.DirectInputAxis.createAxis(DirectInputAxis.java:
237)
at net.java.games.input.DirectInputDevice.addAxis(DirectInputDevice.java
:152)
at net.java.games.input.DirectInputDevice.enumObjects(Native Method)
at net.java.games.input.DirectInputDevice.initDirectInputAxes(DirectInpu
tDevice.java:131)
at net.java.games.input.DirectInputDevice.(DirectInputDevice.java:
122)
at net.java.games.input.DirectInputDevice.createDevice(DirectInputDevice
.java:223)
at net.java.games.input.DirectInputEnvironmentPlugin.addDevice(DirectInp
utEnvironmentPlugin.java:184)
at net.java.games.input.DirectInputEnvironmentPlugin.enumDevices(Native
Method)
at net.java.games.input.DirectInputEnvironmentPlugin.enumControllers(Dir
ectInputEnvironmentPlugin.java:148)
at net.java.games.input.DirectInputEnvironmentPlugin.(DirectInputE
nvironmentPlugin.java:115)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
orAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
onstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at java.lang.Class.newInstance0(Class.java:308)
at java.lang.Class.newInstance(Class.java:261)
at net.java.games.input.DefaultControllerEnvironment.scanControllersAt(D
efaultControllerEnvironment.java:231)
at net.java.games.input.DefaultControllerEnvironment.scanControllers(Def
aultControllerEnvironment.java:212)
at net.java.games.input.DefaultControllerEnvironment.access$000(DefaultC
ontrollerEnvironment.java:59)
at net.java.games.input.DefaultControllerEnvironment$1.run(DefaultContro
llerEnvironment.java:112)
at java.security.AccessController.doPrivileged(Native Method)
at net.java.games.input.DefaultControllerEnvironment.getControllers(Defa
ultControllerEnvironment.java:110)
at net.java.games.input.test.ControllerReadTest.(ControllerReadTes
t.java:250)
at net.java.games.input.test.ControllerReadTest.main(ControllerReadTest.
java:299)
Reseting rumbler Y axis before exit
Reseting rumbler Rz axis before exit
Reseting rumbler X axis before exit
Reseting rumbler Z axis before exit
C:\j2sdk1.4.2_10\jre\lib\ext\JINPUT>
By 小影 on Dec 28, 2005 | Reply
你試試用5.0的JVM再試試…
By randyvai on Dec 28, 2005 | Reply
好的.我試試看.謝謝您
By randyvai on Dec 28, 2005 | Reply
可以了!!!!!!真是太感謝了!!!!您真是我們的救命恩人阿~~~!!!謝謝!!