日期:2014-05-20 浏览次数:20820 次
public class MoveCanvas extends Canvas{ int x = 20; public void paint(Graphics g){ g.drawRect(x,50,20,10); } public void keyPressed(int keyCode){ int action = getGameAction(keyCode); switch(action){ case LEFT: x--; break; case RIGHT: x++; break; } repaint(); } }