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

2012/5/29

Greenfoot shooting ERROR i need a bit of help

Charlie Charlie

2012/5/29

#
I am creating a game where you are flying in a rocket and you have to shoot boms and the things that try to attack you there will be 20 lvls but i bumped in the this mistake in my code and i want to find the awnser to it
/**
      * Fire the rockets Gun
      */
      
      private void fire(){
    }
       Bom bom - new bom();
      getWorld().addObject(bom. getX(). getY()); 
          
        }
Up there where it says bom bom - bom(); is highlighted RED and it says ';' expected did i do every thing right or did i make a little mistake ?
MatheMagician MatheMagician

2012/5/29

#
well first of all Bom bom - new bom(); is supposed to be Bom bom = new bom();, also, instead of periods you need to have commas. However, once you do this substitution you will still get an error as this code does not work in a class extending Actor. It only works for World. The simple solution is to replace
Bom bom = new bom();
getWorld().addObject(bom, getX(), getY());
with
getWorld().addObject(new bom(), getX(), getY());
Charlie Charlie

2012/5/30

#
Not working.......
Charlie Charlie

2012/5/30

#
Can someone plz reply so i can get on with my game
davmac davmac

2012/5/30

#
You need to indent your code properly, and post it. And you need to explain more than just "not working".
MatheMagician MatheMagician

2012/5/30

#
It appears you have to0 many brackets, though you could have just copied an extra one over while posting it. Also, is the name of the class Bom or bom?
You need to login to post a reply.