コード例 #1
0
ファイル: Sprites.java プロジェクト: DONGChuan/LGame
 /**
  * 创建UI图像
  *
  * @param g
  */
 public void createUI(final LGraphics g, final int x, final int y) {
   if (!visible) {
     return;
   }
   int minX, minY, maxX, maxY;
   int clipX = g.getClipX();
   int clipY = g.getClipY();
   int clipWidth = g.getClipWidth();
   int clipHeight = g.getClipHeight();
   if (this.isViewWindowSet) {
     g.setClip(x, y, this.width, this.height);
     minX = this.viewX;
     maxX = minX + this.width;
     minY = this.viewY;
     maxY = minY + this.height;
   } else {
     minX = x;
     maxX = x + clipWidth;
     minY = y;
     maxY = y + clipHeight;
   }
   g.translate(x - this.viewX, y - this.viewY);
   for (int i = 0; i < this.size; i++) {
     ISprite spr = sprites[i];
     if (spr.isVisible()) {
       int layerX = spr.x();
       int layerY = spr.y();
       int layerWidth = spr.getWidth();
       int layerHeight = spr.getHeight();
       if (layerX + layerWidth < minX
           || layerX > maxX
           || layerY + layerHeight < minY
           || layerY > maxY) {
         continue;
       }
       spr.createUI(g);
     }
   }
   g.translate(-(x - this.viewX), -(y - this.viewY));
   if (this.isViewWindowSet) {
     g.setClip(clipX, clipY, clipWidth, clipHeight);
   }
 }