コード例 #1
0
 /**
  * 绘制一个RMVX样式的游标
  *
  * @return
  */
 public static LTexture makeCursor(int w, int h) {
   LImage cursor = LImage.createImage(w, h, true);
   LGraphics g = cursor.getLGraphics();
   g.setColor(0, 0, 0, 255);
   g.fillRect(0, 0, w, h);
   g.setColor(255, 255, 255, 255);
   g.fillRect(1, 1, w - 2, h - 2);
   g.setColor(0, 0, 0, 255);
   g.fillRect(4, 4, w - 8, h - 8);
   g.setColor(0, 0, 0, 255);
   g.fillRect(w / 4, 0, w / 2, h);
   g.setColor(0, 0, 0, 255);
   g.fillRect(0, h / 4, w, h / 2);
   g.dispose();
   g = null;
   int[] basePixels = cursor.getPixels();
   int length = basePixels.length;
   int c = LColor.black.getRGB();
   for (int i = 0; i < length; i++) {
     if (basePixels[i] == c) {
       basePixels[i] = 0xffffff;
     }
   }
   cursor.setPixels(basePixels, w, h);
   LTexture texture = cursor.getTexture();
   if (cursor != null) {
     cursor.dispose();
     cursor = null;
   }
   return texture;
 }