Zetcode.com Java: Spaceinvaders Player don't move anymore after I shot a bullet -
i tried programm spaceinvaders tutorial: spaceinvaders
everything okay far, could'nt find out how set focus again on player after did shot. player not move anymore. tried allready couple of hours , know keyevents working - until shoot. (system.out.println
- testing events ok)
i can move player fast befor shot, afterwards no chance. can shots again, vk_left` nor vk_right react anymore.
i work eclipse luna , java build 1.8.0_40, , use original code, made me little pngs. specified iterator<alien> = aliens.iterator();
, changed: // imageicon ii = new imageicon(this.getclass().getresource(shot));
to:
imageicon ii = new imageicon(shot);
because otherwise nullpointer exception.
this tried in board.class: workes litte better, player still want move time want. bothers me is, works times , without can find reason, player stop , want move anymore.
private class tadapter extends keyadapter { @override public void keyreleased(keyevent e) { //original code //player.keyreleased(e); //works better, still not expected if(ingame) { if (e.getkeycode() == keyevent.vk_left || e.getkeycode() == keyevent.vk_right ) { player.keyreleased(e); } if(e.getkeycode()== keyevent.vk_alt) { player.x += player.dx; if (player.x <= 2) player.x = 2; if (player.x >= board_width -2*player.width) player.x= board_width - 2*player.width; } } }
i hope can me. nice regards c.
Comments
Post a Comment