java - e.getX(); does not work accurately -
so have run problem where, when read mouse position , try manipulate goes hell !
here code disaster.
public class loadscreen implements mouselistener{ int x,y; public void begin(graphics g, jpanel def) { def.addmouselistener(this); font font = new font("serif", font.plain, 50); g.setfont(font); g.drawstring("welcome faivacodex's live interaction game shell", 30, 200); font font2=new font("triplex",font.plain, 17); g.setfont(font2); g.drawstring("enjoy making game, more gameshells availible send email flaivaflaves@gmail.com ", 30, 230); g.fillrect(x-5,y-5,x+10,y+10); } @override public void mouseentered(mouseevent arg0) { x=arg0.getx(); y=arg0.gety(); } @override public void mouseclicked(mouseevent arg0) { } @override public void mouseexited(mouseevent arg0) { } @override public void mousepressed(mouseevent arg0) { } @override public void mousereleased(mouseevent arg0) { } } and there image of produces cant post images yet. want 10*10 pixel box mouse is, can tell is....this rectangle huge.
the parameters fillrect(...) coordinates x, y , size width , height, means if x = 100 , y = 100 code product 110x110 rectangle starting @ x 100, y 100.
if want create 10x10 rectangle starting @ mouse's pointer, use this:
g.fillrect(x,y,10,10);
Comments
Post a Comment