Hello,
I have an actor called "DonkeyKong" and he shoots bullets from a class named "Weapons"
DonkeKong has 3 Images, left, right and up
How do i make it that if he looks left the bullets go left?
DonkeyKong Class (Shooting Bullet Part)
Weapons Class
1 2 3 4 5 6 7 8 9 10 11 | if (!spaceDown && Greenfoot.isKeyDown( "space" )) { spaceDown = true ; Weapons bullet = new Weapons(); getWorld().addObject(bullet, getX() + 60 , getY() - 15 ); } if (spaceDown && !Greenfoot.isKeyDown( "space" )) { spaceDown = false ; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | public void act() { this .setLocation( this .getX() + 5 , this .getY()); this .touchingEnemy(); } public void touchingEnemy() { Actor ast = getOneIntersectingObject(Enemies. class ); if (ast != null ) { if ( this .isTouching(Enemies. class )) { getWorld().removeObject(ast); getWorld().removeObject( this ); } } else if ( this .atWorldEdge()) { this .getWorld().removeObject( this ); } } |