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; }
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(); }
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); } } }
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; }
public void off() { int width = image.getWidth(); rectSrc.setBounds(0, 0, width / 2, image.getHeight()); }
// 绘制玩家手中的牌 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); } } }
@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); } } } } }
public int getOriginalImageWidth() { return image.getWidth(); }