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

2018/7/4

Aiming at objects

grnft grnft

2018/7/4

#
I know, this topic has already filled lots of discussions, but mine doesn't work. The Voldemort class needs to shoot an AvadaKedavra that aims for the Harry class. That's what my code acutally looks like:
    private void fire()
    {
        AvadaKedavra avadaKedavra =  new  AvadaKedavra();
        avadaKedavra.setRotation(Greenfoot.getRandomNumber(10) - 100);
        getWorld().addObject(avadaKedavra, getX(), getY());
        turnTowards(harry.getX(),harry.getY());
    }
The error message just tells me that there's something wrong with the turnTowards method.
grnft grnft

2018/7/4

#
Oh and you can just ignore the forth line, that was a mistake.
danpost danpost

2018/7/4

#
grnft wrote...
The error message just tells me that there's something wrong with the turnTowards method.
Yeah. What does harry refer to? That is, where is the variable (or field) being declared and what is being set to it?
You need to login to post a reply.