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); } }