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

2014/9/5

Intersecting Object Help

cellostar47 cellostar47

2014/9/5

#
I'm trying to see if the non-static int called val (defined in block) of another instance is equal to the value of the instance checking. It can't compile because it says "Can't find symbol - variable val". HELP PLEASE!
public void checkTiles(){
        Actor a = getOneIntersectingObject(block.class);
        if(a!=null){
            if(a.val == val){
                getWorld().removeObject(a);
                val = 4;
            }
        }

    }
danpost danpost

2014/9/5

#
If 'val' is defined in the 'block' class, then 'a' must be declared as type 'block', not as type 'Actor' (see line 2).
cellostar47 cellostar47

2014/9/5

#
Lemme try that.
cellostar47 cellostar47

2014/9/5

#
IT WORKS! Thanks danpost.
You need to login to post a reply.