2012年6月13日 星期三

Java Game Development(31) - Intro to Mouselook


import java.awt.*;
import java.awt.event.*;
import javax.swing.ImageIcon;
import javax.swing.SwingUtilities;

public class Look extends Core implements MouseMotionListener, KeyListener {

public static void main(String[] args) {
new Look().run();
}

private Image bg;
private Robot robot;
private Point mouse; 鼠標的位置
private Point center; 屏幕中心的位置
private Point image; 圖像的位置
private boolean centering;

//init
public void init() {
super.init();
mouse = new Point();
center = new Point();
image = new Point();
centering = false;

try {
robot = new Robot();
recenterMouse();
mouse.x = center.x;
mouse.y = center.y;
} catch (Exception ex) {
System.out.println("Exception 1");
}

Window w = s.getFullScreenWindow();
w.addMouseMotionListener(this);
w.addKeyListener(this);
bg = new ImageIcon("C://baby.png").getImage();
}
}

沒有留言:

張貼留言