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

2017/2/8

non static method cannot be referenced from static content

FishEvolution FishEvolution

2017/2/8

#
I get this error in my game and I dont know to solve it
   private void foundBomb()
   {
        Actor zeemijn;
        World world;  
        zeemijn = getOneObjectAtOffset(0, 0, Zeemijn.class); 
        if(zeemijn != null) 
       {
         Zeemijn.Remove();

       
      
       }
   }
thats where the error is in the Zeemijn.Remove the actor where Remove class in is this one
davmac davmac

2017/2/8

#
The variable is called "zeemijn" but you are calling the method as "Zeemijn.Remove()"; Zeemijn is a class name, which is what it means by "static context". You should change the line to:
           zeemijn.Remove();
Also, "Remove" is a method, not a class, and by convention it should also start with a lower case letter (but you would need to change the declaration as well as your reference to it here).
You need to login to post a reply.