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

2016/11/3

Problem with mouseclick event

chandra chandra

2016/11/3

#
I am trying to fill the oval on mouseclick but its not working. Please let me know where i went wrong public DrawCircle() { image.drawOval(0,0,109,99); setImage(image); } public void act() { if(Greenfoot.mouseClicked(image)) { image.setColor(java.awt.Color.RED); //image.drawOval(10,10,109,99); image.fillOval(0,0,109,99); setImage(image); } }
danpost danpost

2016/11/3

#
Your mouseClick needs to be on the actor, not on the image. Use 'this' to refer to the actor the act method is executing for. I do not believe you need to reset the image to the actor (your last code line).
You need to login to post a reply.