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

2017/4/18

non-static method setRotation(int) cannot be referenced from a static context

7oel 7oel

2017/4/18

#
What im trying to do is make the bullet rotate to the same as the airplane.
danpost danpost

2017/4/18

#
7oel wrote...
What im trying to do is make the bullet rotate to the same as the airplane.
You are not getting a reference to the bullet you are creating, to change its rotation. So, the compiler is taking 'bullet' as a class name and not as anything to do with the bullet object (obviously you cannot rotate a class). Do this:
// instead of
getWorld().addObject(new bullet(), getX(), getY());
// use this
bullet b = new bullet();
getWorld().addObject(b, getX(), getY());
Then, set the rotation of the bullet 'b' -- the reference to the bullet object.
danpost danpost

2017/4/18

#
Next time you have a question, copy/paste the code here instead of using an image hosting site. Click here to see how to post code.
7oel 7oel

2017/4/19

#
Thank you
You need to login to post a reply.