Wolfy0013
Mitglied
Code:
import...
public class game extends JPanel implements KeyListener{
collide[] collider = new collide[4];
collide collider_me = new collide();
animator ballonfire;
animator bunkerexpl;
animator[] weaponexpl = new animator[4];
//.....
game(){
MouseListener ml=new MouseAdapter(){
public void mousePressed(MouseEvent me){ mouse(me); } };
this.addMouseListener(ml); // funktioniert
this.addKeyListener(this); // funktioniert nicht
int[] money = {0,0,0,0};
setData(money,0);
}
///....
public void keyPressed(KeyEvent e) {
System.out.println("TEST"); // wird nie angezeigt
if(!intro){
//-------------BEWEGUNGEN----------------------//
if(e.getKeyCode()==KeyEvent.VK_RIGHT || e.getKeyCode()==KeyEvent.VK_LEFT){
if(e.getKeyCode()==KeyEvent.VK_LEFT){ move[0][0]=true; }
else{ move[0][1]=true; }
checkWinkel(0);
}
if(e.getKeyCode()==KeyEvent.VK_N || e.getKeyCode()==KeyEvent.VK_M){
if(e.getKeyCode()==KeyEvent.VK_N){ move[1][0]=true; }
else{ move[1][1]=true; }
checkWinkel(1);
}
//.....
}
Bitte sehr!