Mercurial > hg > Members > tatsuki > Alice
view src/alice/test/topology/movement/KeyInput.java @ 93:6601f8854126 working
can KeyInputCodeSegment
author | sugi |
---|---|
date | Tue, 05 Jun 2012 16:33:28 +0900 |
parents | 33a19ca88e43 |
children | 21e68300e205 |
line wrap: on
line source
package alice.test.topology.movement; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import javax.media.j3d.Transform3D; import javax.media.j3d.TransformGroup; import javax.vecmath.Vector3f; public class KeyInput implements KeyListener{ int KeyCode = 0; Vector3f vector; Transform3D transform; TransformGroup transformGroup; public KeyInput(){ transform = new Transform3D(); transformGroup= new TransformGroup(); transformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); vector = new Vector3f(0.0f,0.0f,0.0f); } @Override public void keyPressed(KeyEvent event) { // TODO Auto-generated method stub KeyCode = event.getKeyCode(); switch(KeyCode) { case 37: vector.x -= 0.1f; break; case 38: vector.y += 0.1f; break; case 39: vector.x += 0.1f; break; case 40: vector.y -= 0.1f; break; } transform.setTranslation(vector); transformGroup.setTransform(transform); } @Override public void keyReleased(KeyEvent arg0) { // TODO Auto-generated method stub } @Override public void keyTyped(KeyEvent arg0) { // TODO Auto-generated method stub } }