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

2013/3/1

Calling a method with variables

-nic- -nic-

2013/3/1

#
public boolean cansee(int x, int y,Class clss)
    {
        Actor actor = getOneObjectAtOffset(x, y, clss);
        return actor !=null;
    }
    public void Gravity()
    {
       if(! canSee(0,32,Dirt.class)||canSee(0,32,Leaves.class)||canSee(0,32,Grass.class)||canSee(0,32,Cloud.class))
       {
          setLocation(getX(),getY()+10);
       }
    }
when I use this code I get the error: "Cannot find symbol - method canSee(int,int,java.lang.Class<Dirt>)"
danpost danpost

2013/3/1

#
You named the method 'cansee', yet are trying to call it with 'canSee'. You capitalized the 'S' in the call, but not in the declared name.
-nic- -nic-

2013/3/1

#
wow, i thought i was better than this, thanks danpost
You need to login to post a reply.