/** * 入口方法 * * @param savedInstanceState Bundle对象 */ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // 设置屏幕恒为纵向 setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // 获得屏幕分辨率 dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); SystemData.setCurrentComponentLevel(clevel); pauseb.setActionListener(new PauseListener()); clevel.add(pauseb); pauseb.setVisible(true); }
/** * 设置相应操作 * * @param x x坐标 * @param y y坐标 * @param z z坐标 */ public void act(float x, float y, float z) { final int n = 10; final int m = 40; x2 = x2 - (int) x * n; y2 = y2 + (int) y * n; if (x2 <= 0) { x2 = 0; } if (y2 <= 0) { y2 = 0; } if (x2 >= dm.widthPixels - m) { x2 = dm.widthPixels - m; } if (y2 >= dm.heightPixels - m) { y2 = dm.heightPixels - m; } pauseb.setX(x2); pauseb.setY(y2); }