This site requires JavaScript, please enable it in your browser!
Greenfoot back
Manoj_Nishantha
Manoj_Nishantha wrote ...

2014/1/3

Please Help!!! Shooting Problem

Manoj_Nishantha Manoj_Nishantha

2014/1/3

#
Hey guys, I'm relatively new so could you please keep the language quite simple so I don't get confused, thanks. At the moment in my game I am trying to shoot left and to shoot right, the code for shooting right seems to be fine but when i want to shoot left it only does the same thing as shooting right... (btw shooting2 is meant to shoot left) private int shootingCounter = 1; public boolean shooting() { if(Greenfoot.isKeyDown("z") && shootingCounter <= 0 && direction ==1) { getWorld().addObject(new Shootright(), getX(), getY()); shootingCounter = 10; return true; } return false; } public boolean shooting2() { if(Greenfoot.isKeyDown("x") && shootingCounter <= 0 && direction ==-1) { getWorld().addObject(new Shootleft(), getX(), getY()); shootingCounter = 10; return true; } return false; } what is wrong with my code guys or do i need to edit my shooting manager: public void remove() { Actor walls = getOneIntersectingObject(Platform.class); if (getX() <=1 || getX() >= getWorld().getWidth() -1) { getWorld().removeObject(this); } else if(walls !=null) { getWorld().removeObject(this); } } public boolean checkToSeeIfShot(Class clss) { Actor actor = getOneObjectAtOffset(0,0, clss); return actor !=null; } public void kill(Class clss) { Actor actor = getOneObjectAtOffset(0, 0, clss); if( actor != null) { getWorld().removeObject(actor); } } thanks in advance
You need to login to post a reply.