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

2017/4/3

Whats the problem?

Nokhaido Nokhaido

2017/4/3

#
I wrote this code, to make the actor follow my mouse: private int mausY=0; private int mausX=0; private int button= false; public void drehenZurMaus(){ MouseInfo maus = Greenfoot.getMouseInfo(); if(maus!=null){ MouseInfo button == maus.getButton(); if(button == 1 && Greenfoot.mouseClicked(null)) { mausX=maus.getX(); mausY=maus.getY(); turnTowards(mausX, mausY); move(); } } } But in this line: MouseInfo button == maus.getButton(); there is a ; expected between button and == Whats the problem with this?
danpost danpost

2017/4/3

#
Nokhaido wrote...
But in this line: MouseInfo button == maus.getButton(); there is a ; expected between button and == Whats the problem with this?
Multiple issues with the line. First off, you use a single equal sign to assign a value to a variable (the double equal sign is for comparing for equality). Secondly, the 'getButton' method returns an 'int' value; but, you are attempting to assign it to a variable that you declare as type MouseInfo (should be 'int button = maus.getButton();'.
You need to login to post a reply.