コード例 #1
0
ファイル: LTextureRegion.java プロジェクト: keppelcao/LGame
 public LTextureRegion(LTexture texture) {
   if (texture == null) {
     throw new IllegalArgumentException("texture cannot be null.");
   }
   this.texture = texture;
   setRegion(0, 0, texture.width(), texture.height());
 }
コード例 #2
0
ファイル: SpriteButton.java プロジェクト: ylck/LGame
 public SpriteButton(
     LTexture texture,
     float scale,
     int width,
     int height,
     String clickse,
     Sound sound,
     String storage,
     String target,
     boolean countpage,
     String exp,
     ButtonFunc func,
     int size) {
   this.image = texture;
   this.scale = scale;
   this.sound = sound;
   if (image == null) {
     rectSrc = new RectBox(0, 0, width, height);
   } else {
     rectSrc = new RectBox(0, 0, image.getWidth() / size, image.getHeight());
   }
   this.width = width;
   this.height = height;
   this.setPos(0, 0);
   this.clickse = clickse;
   this.storage = storage;
   this.target = target;
   this.countpage = countpage;
   this.exp = exp;
   this.func = func;
 }
コード例 #3
0
ファイル: Picture.java プロジェクト: wethinkall/LGame
 public Picture(LTexture image, int x, int y) {
   if (image != null) {
     this.setImage(image);
     this.width = (int) image.width();
     this.height = (int) image.height();
   }
   this.setLocation(x, y);
   this.visible = true;
 }
コード例 #4
0
ファイル: SpriteBatchSheet.java プロジェクト: keppelcao/LGame
 public SpriteBatchSheet(LTexture image, int hFrames, int vFrames, float r) {
   this.hFrames = hFrames;
   this.vFrames = vFrames;
   this.image = image;
   this.rate = r;
   this.spriteWidth = imgWidth = image.getWidth() / this.hFrames;
   this.spriteHeight = imgHeight = image.getHeight() / this.vFrames;
   this.frames = (hFrames * vFrames);
   this.spriteRect = new RectI.Range(0, 0, imgWidth, imgHeight);
   this.destRect = new RectI.Range();
 }
コード例 #5
0
ファイル: Picture.java プロジェクト: wethinkall/LGame
 public boolean equals(Picture p) {
   if (image.equals(p.image)) {
     return true;
   }
   if (this.width == p.width && this.height == p.height) {
     if (image.hashCode() == p.image.hashCode()) {
       return true;
     }
   }
   return false;
 }
コード例 #6
0
ファイル: LTextureRegion.java プロジェクト: keppelcao/LGame
 public void scroll(float xAmount, float yAmount) {
   if (xAmount != 0) {
     float width = (widthRatio - xOff) * texture.width();
     xOff = (xOff + xAmount) % 1;
     widthRatio = xOff + width / texture.width();
   }
   if (yAmount != 0) {
     float height = (heightRatio - yOff) * texture.height();
     yOff = (yOff + yAmount) % 1;
     heightRatio = yOff + height / texture.height();
   }
 }
コード例 #7
0
ファイル: LTextureRegion.java プロジェクト: keppelcao/LGame
 public void setRegion(int x, int y, int width, int height) {
   float invTexWidth = 1f;
   float invTexHeight = 1f;
   if (texture.isScale()) {
     invTexWidth = (1f / texture.width());
     invTexHeight = (1f / texture.height());
   } else {
     invTexWidth = (1f / texture.width()) * texture.widthRatio;
     invTexHeight = (1f / texture.height()) * texture.heightRatio;
   }
   setRegion(
       x * invTexWidth + texture.xOff,
       y * invTexHeight + texture.yOff,
       (x + width) * invTexWidth,
       (y + height) * invTexHeight);
 }
コード例 #8
0
ファイル: Picture.java プロジェクト: wethinkall/LGame
 @Override
 public void close() {
   if (image != null) {
     image.close();
     image = null;
   }
 }
コード例 #9
0
ファイル: SpriteBatchSheet.java プロジェクト: keppelcao/LGame
 public void updateLayout(int vFrames, int hFrames) {
   if (vFrames < 1) {
     vFrames = 1;
   } else if (vFrames > 99) {
     vFrames = 99;
   }
   if (hFrames < 1) {
     hFrames = 1;
   } else if (hFrames > 99) {
     hFrames = 99;
   }
   this.hFrames = hFrames;
   this.vFrames = vFrames;
   spriteWidth = imgWidth = image.getWidth() / this.hFrames;
   spriteHeight = imgHeight = image.getHeight() / this.vFrames;
   frames = (hFrames * vFrames);
   spriteRect.right = spriteWidth;
   spriteRect.bottom = spriteHeight;
 }
コード例 #10
0
ファイル: Player.java プロジェクト: keppelcao/LGame
  public void paintResultCards(GLEx canvas) {
    RectF.Range src = new RectF.Range();
    RectF.Range des = new RectF.Range();
    int row;
    int col;

    for (int i = 0; i < cards.length; i++) {
      row = CardsManager.getImageRow(cards[i]);
      col = CardsManager.getImageCol(cards[i]);
      cardImage = Game.getImage(CardImage.cardImages[row][col]);
      Paint paint = new Paint();
      paint.setStyle(Style.STROKE);
      paint.setColor(LColor.black);
      paint.setStrokeWidth(1);
      // 当玩家是NPC时,竖向绘制,扑克牌全是背面
      if (paintDirection == CardsType.direction_Vertical) {
        src.set(0, 0, cardImage.getWidth(), cardImage.getHeight());
        des.set(
            (int) (left * Game.SCALE_HORIAONTAL),
            (int) ((top - 40 + i * 15) * Game.SCALE_VERTICAL),
            (int) ((left + 40) * Game.SCALE_HORIAONTAL),
            (int) ((top + 20 + i * 15) * Game.SCALE_VERTICAL));
        RectF.Range rectF = new RectF.Range(des);
        canvas.rect(rectF, 5, 5, paint);
        canvas.drawBitmap(cardImage, src, des, paint);

      } else {
        src.set(0, 0, cardImage.getWidth(), cardImage.getHeight());
        des.set(
            (int) ((left + 40 + i * 20) * Game.SCALE_HORIAONTAL),
            (int) (top * Game.SCALE_VERTICAL),
            (int) ((left + 80 + i * 20) * Game.SCALE_HORIAONTAL),
            (int) ((top + 60) * Game.SCALE_VERTICAL));
        RectF.Range rectF = new RectF.Range(des);
        canvas.rect(rectF, 5, 5, paint);
        canvas.drawBitmap(cardImage, src, des, paint);
      }
    }
  }
コード例 #11
0
ファイル: BMFont.java プロジェクト: lwxcool/LGame
 public void close() {
   this.isClose = true;
   if (displayList != null) {
     displayList.close();
     displayList = null;
   }
   if (displays != null) {
     for (Display d : displays.values()) {
       if (d != null && d.cache != null) {
         d.cache.close();
         d.cache = null;
       }
     }
     displays.clear();
     displays = null;
   }
 }
コード例 #12
0
ファイル: SpriteButton.java プロジェクト: ylck/LGame
 public void off() {
   int width = image.getWidth();
   rectSrc.setBounds(0, 0, width / 2, image.getHeight());
 }
コード例 #13
0
ファイル: SpriteButton.java プロジェクト: ylck/LGame
 public void clear() {
   if (image != null) {
     image.close();
     image = null;
   }
 }
コード例 #14
0
ファイル: Player.java プロジェクト: keppelcao/LGame
  // 绘制玩家手中的牌
  public void paint(GLEx canvas) {
    //	System.out.println("id:" + playerId);
    RectF.Range src = new RectF.Range();
    RectF.Range des = new RectF.Range();

    int row;
    int col;

    // 当玩家是NPC时,竖向绘制,扑克牌全是背面
    if (paintDirection == CardsType.direction_Vertical) {
      Paint paint = new Paint();
      paint.setStyle(Style.STROKE);
      paint.setColor(LColor.black);
      paint.setStrokeWidth(1);
      LTexture backImage = Game.getImage("card_bg");

      src.set(0, 0, backImage.getWidth(), backImage.getHeight());
      des.set(
          (int) (left * Game.SCALE_HORIAONTAL),
          (int) (top * Game.SCALE_VERTICAL),
          (int) ((left + 40) * Game.SCALE_HORIAONTAL),
          (int) ((top + 60) * Game.SCALE_VERTICAL));
      RectF.Range rectF = new RectF.Range(des);
      canvas.rect(rectF, 5, 5, paint);
      canvas.drawBitmap(backImage, src, des, paint);

      // 显示剩余牌数
      paint.setStyle(Style.FILL);
      paint.setColor(LColor.white);
      paint.setTextSize((int) (20 * Game.SCALE_HORIAONTAL));
      canvas.drawText(
          "" + cards.length,
          (int) (left * Game.SCALE_HORIAONTAL),
          (int) ((top + 80) * Game.SCALE_VERTICAL),
          paint);

    } else {
      Paint paint = new Paint();
      paint.setStyle(Style.STROKE);
      paint.setColor(LColor.black);
      paint.setStrokeWidth(1);
      for (int i = 0; i < cards.length; i++) {
        row = CardsManager.getImageRow(cards[i]);
        col = CardsManager.getImageCol(cards[i]);
        cardImage = Game.getImage(CardImage.cardImages[row][col]);
        int select = 0;
        if (cardsFlag[i]) {
          select = 10;
        }
        src.set(0, 0, cardImage.getWidth(), cardImage.getHeight());
        des.set(
            (int) ((left + i * 20) * Game.SCALE_HORIAONTAL),
            (int) ((top - select) * Game.SCALE_VERTICAL),
            (int) ((left + 40 + i * 20) * Game.SCALE_HORIAONTAL),
            (int) ((top - select + 60) * Game.SCALE_VERTICAL));
        RectF.Range rectF = new RectF.Range(des);
        canvas.rect(rectF, 5, 5, paint);
        canvas.drawBitmap(cardImage, src, des, paint);
      }
    }
  }
コード例 #15
0
ファイル: Picture.java プロジェクト: wethinkall/LGame
 public void setImage(String fileName) {
   this.image = LTextures.loadTexture(fileName);
   this.width = (int) image.width();
   this.height = (int) image.height();
 }
コード例 #16
0
ファイル: LTextureRegion.java プロジェクト: keppelcao/LGame
 public int getRegionHeight() {
   float result = texture.height() * heightRatio - texture.height() * yOff;
   return (int) (result > 0 ? result : -result);
 }
コード例 #17
0
ファイル: SpriteBatchSheet.java プロジェクト: keppelcao/LGame
 public int getOriginalImageHeight() {
   return image.getHeight();
 }
コード例 #18
0
ファイル: SpriteBatchSheet.java プロジェクト: keppelcao/LGame
 public int getOriginalImageWidth() {
   return image.getWidth();
 }
コード例 #19
0
ファイル: LTextureRegion.java プロジェクト: keppelcao/LGame
 public void setRegion(LTexture texture) {
   this.texture = texture;
   setRegion(0, 0, texture.width(), texture.height());
 }
コード例 #20
0
ファイル: LTextureRegion.java プロジェクト: keppelcao/LGame
 public int getRegionWidth() {
   float result = texture.width() * widthRatio - texture.width() * xOff;
   return (int) (result > 0 ? result : -result);
 }
コード例 #21
0
ファイル: LTextureRegion.java プロジェクト: keppelcao/LGame
 public int getRegionY() {
   return (int) (yOff * texture.height());
 }
コード例 #22
0
ファイル: BMFont.java プロジェクト: lwxcool/LGame
  private void drawBatchString(
      float tx, float ty, String text, LColor c, int startIndex, int endIndex) {

    if (isClose) {
      return;
    }

    if (displays.size > DEFAULT_MAX_CHAR) {
      displays.clear();
    }

    lazyHashCode = 1;

    if (c != null) {
      lazyHashCode = LSystem.unite(lazyHashCode, c.r);
      lazyHashCode = LSystem.unite(lazyHashCode, c.g);
      lazyHashCode = LSystem.unite(lazyHashCode, c.b);
      lazyHashCode = LSystem.unite(lazyHashCode, c.a);
    }

    String key = text + lazyHashCode;

    Display display = displays.get(key);

    if (display == null) {

      int x = 0, y = 0;

      displayList.glBegin();
      displayList.setBatchPos(tx, ty);

      if (c != null) {
        displayList.setImageColor(c);
      }

      CharDef lastCharDef = null;
      char[] data = text.toCharArray();
      for (int i = 0; i < data.length; i++) {
        int id = data[i];
        if (id == '\n') {
          x = 0;
          y += getLineHeight();
          continue;
        }
        if (id >= chars.length) {
          continue;
        }
        CharDef charDef = chars[id];
        if (charDef == null) {
          continue;
        }

        if (lastCharDef != null) {
          x += lastCharDef.getKerning(id);
        }
        lastCharDef = charDef;

        if ((i >= startIndex) && (i <= endIndex)) {
          charDef.draw(x, y);
        }

        x += charDef.advance;
      }

      if (c != null) {
        displayList.setImageColor(LColor.white);
      }

      displayList.glEnd();

      display = new Display();

      display.cache = displayList.newBatchCache();
      display.text = text;
      display.width = 0;
      display.height = 0;

      displays.put(key, display);

    } else if (display.cache != null) {
      display.cache.x = tx;
      display.cache.y = ty;
      displayList.postCache(display.cache);
    }
  }
コード例 #23
0
ファイル: Picture.java プロジェクト: wethinkall/LGame
 public void setImage(LTexture image) {
   this.image = image;
   this.width = (int) image.width();
   this.height = (int) image.height();
 }
コード例 #24
0
ファイル: LTextureRegion.java プロジェクト: keppelcao/LGame
 public void close() {
   if (texture != null) {
     texture.release();
   }
 }
コード例 #25
0
ファイル: ScreenSkill.java プロジェクト: cping/LGame
	@Override
	public void Draw(SpriteBatch batch) {
		if (isInitialised) {
			super.Draw(batch);
			if (!super.isPaused) {
				float num = 0f;
				if (this.tagSelected != null) {
					num = 0.6f;
				}
				batch.draw(super.maskTexture, 0f, 0f,
						Global.Pool.getColor(1f, 1f, 1f, num));
				if (Help.profession == Help.Profession.BattleEngineer) {
					batch.draw(t2DBattleEngineer, 60f, 90f);
				} else if (Help.profession == Help.Profession.Rifleman) {
					batch.draw(t2DRifleman, 60f, 90f, LColor.white);
				}
				Vector2f v = Screen.myFont.getOrigin("" + Help.AvailSkillPoint);
				batch.drawString(Screen.myFont, "" + Help.AvailSkillPoint,
						740f, 450f, LColor.wheat, 0f, v.x, v.y, 1f);
				v = Screen.ariel14.getOrigin("" + Help.numSkill1);
				batch.drawString(Screen.ariel14, "" + Help.numSkill1,
						this.pTagAAGun.sub(30f, 5f), LColor.wheat, 0f, v, 1f);
				v = Screen.ariel14.getOrigin("" + Help.numSkill2);
				batch.drawString(Screen.ariel14, "" + Help.numSkill2,
						this.pTagAim.sub(30f, 5f), LColor.wheat, 0f, v, 1f);
				v = Screen.ariel14.getOrigin("" + Help.numSkill3);
				batch.drawString(Screen.ariel14, "" + Help.numSkill3,
						this.pTagLearning.sub(30f, 5f), LColor.wheat, 0f, v, 1f);
				v = Screen.ariel14.getOrigin("" + Help.numSkill4);
				batch.drawString(Screen.ariel14, "" + Help.numSkill4,
						this.pTagGunner.sub(30f, 5f), LColor.wheat, 0f, v, 1f);
				if (Help.profession == Help.Profession.BattleEngineer) {
					v = Screen.ariel14.getOrigin("" + Help.numSkill5);
					batch.drawString(Screen.ariel14, "" + Help.numSkill5,
							this.pTagOverRepair.sub(30f, 5f), LColor.wheat, 0f,
							v, 1f);
					v = Screen.ariel14.getOrigin("" + Help.numSkill6);
					batch.drawString(Screen.ariel14, "" + Help.numSkill6,
							this.pTagFieldRepair.sub(30f, 5f), LColor.wheat,
							0f, v, 1f);
				} else if (Help.profession == Help.Profession.Rifleman) {
					v = Screen.ariel14.getOrigin("" + Help.numSkill7);
					batch.drawString(Screen.ariel14, "" + Help.numSkill7,
							this.pTagReloading.sub(30f, 5f), LColor.wheat, 0f,
							v, 1f);
					v = Screen.ariel14.getOrigin("" + Help.numSkill8);
					batch.drawString(Screen.ariel14, "" + Help.numSkill8,
							this.pTagExtendedMag.sub(30f, 5f), LColor.wheat,
							0f, v, 1f);
				} else if (Help.profession == Help.Profession.Commander) {
					v = Screen.ariel14.getOrigin("" + Help.numSkill9);
					batch.drawString(Screen.ariel14, "" + Help.numSkill9,
							this.pTagArtillery.sub(30f, 5f), LColor.wheat, 0f,
							v, 1f);
					v = Screen.ariel14.getOrigin("" + Help.numSkill10);
					batch.drawString(Screen.ariel14, "" + Help.numSkill10,
							this.pTagBoost.sub(30f, 5f), LColor.wheat, 0f, v,
							1f);
				}
				for (Button button : super.buttonList) {
					if (!button.isPrerequisiteMet) {
						RectBox sourceRectangle = null;
						batch.draw(maskSkill, button.position, sourceRectangle,
								LColor.white, 0f, button.origin, 1f,
								SpriteEffects.None);
					}
				}
				if (this.tagSelected != null) {
					batch.draw(t2DSkillDetail, 397f, 240f, null, LColor.white,
							0f, (t2DSkillDetail.getWidth() / 2),
							(t2DSkillDetail.getHeight() / 2), 1f,
							SpriteEffects.None);
					batch.draw(this.tagSelected.texture, 210f, 190f,
							LColor.white);
					batch.drawString(Screen.myFont,
							this.tagSelected.description, 200f, 130f,
							LColor.wheat);
					batch.drawString(Screen.ariel14,
							this.tagSelected.subDescription, 320f, 190f,
							LColor.wheat);
					batch.drawString(Screen.ariel14,
							this.tagSelected.reqDescription, 320f, 275f,
							LColor.wheat);
					this.buttonCancel.Draw(batch);
					if (this.isDetailShowing) {
						this.buttonConfirm.Draw(batch);
					} else {
						batch.draw(t2DPreReqNotMet, 220f, 270f, null,
								Global.Pool.getColor(1f, 1f, 1f, 0.7f),
								MathUtils.toDegrees(-0.3926991f), 0f, 0f, 1f,
								SpriteEffects.None);
					}
				}
			}
		}
	}
コード例 #26
0
ファイル: LTextureRegion.java プロジェクト: keppelcao/LGame
 public int getRegionX() {
   return (int) (xOff * texture.width());
 }