public void reset() { textureLifeSpan.setRegion( new Texture((Gdx.files.internal(Config.asString("lifeSpanTexture"))))); texture = new Texture(Gdx.files.internal(Config.asString(texturePath))); currentLife = lifeSpan; timer.timeCountDown = initTimer; currentRatio = targetRatio = beginingRatio; cutStep = 0; cutLeft = false; cutRight = false; while (textOutList.size() > 0) { PoolStore.textPool.free(textOutList.get(0)); textOutList.remove(0); } }
public void draw( SpriteBatch spriteBatch, BitmapFont font, TextureRegion leftTexture, TextureRegion rightTexture) { finishAnimation = true; if (currentRatio > targetRatio) { currentRatio -= 0.05; } else currentRatio = targetRatio; // render the life span if (!bomb) spriteBatch.draw( textureLifeSpan, this.x + 50, height - 50, 0f, 0f, textureLifeSpan.getRegionWidth(), textureLifeSpan.getRegionHeight(), currentRatio, 1f, 0f); if (currentRatio == 0) { if (textBonus == null) { RunningScreen.score += 50; textBonus = PoolStore.textPool.obtain(); textBonus.x = 0; textBonus.y = 0; } textBonus.text = " Bonus 50 points "; font.draw(spriteBatch, textBonus.text, this.x + 100, height - 150 + textBonus.y); textBonus.y += 2; if (textBonus.y >= 40) { PoolStore.textPool.free(textBonus); textBonus = null; } else finishAnimation = false; } // render timer timer.render(spriteBatch, font, this.x + width - 50, this.y + height - 50); // render the texture of object if (!Setting.debug) spriteBatch.draw(textureRegion, this.x + 50, height - 400); else spriteBatch.draw(textureRegion, this.x + 50, height - 300); // render the damage text for (index = 0; index < textOutList.size(); index++) { TextOutput temp = textOutList.get(index); font.draw(spriteBatch, temp.text, this.x + 50, height - 150 + temp.y); temp.y += 2; if (temp.y == 20) { textOutList.remove(index); PoolStore.textPool.free(temp); } else finishAnimation = false; } // render the cut animation if (cutRight) { if (!Setting.debug) spriteBatch.draw(leftTexture, this.x + 50 + 20 * cutStep, height - 300); else spriteBatch.draw(leftTexture, this.x + 50 + 20 * cutStep, height - 300); cutStep++; if (cutStep > 10) { cutRight = false; cutStep = 0; } else finishAnimation = false; } else if (cutLeft) { if (!Setting.debug) spriteBatch.draw( rightTexture, this.x + textureRegion.getRegionWidth() + 50 - 20 * cutStep, height - 300); else spriteBatch.draw( rightTexture, this.x + textureRegion.getRegionWidth() + 50 - 20 * cutStep, height - 100); cutStep++; if (cutStep > 10) { cutLeft = false; cutStep = 0; } else finishAnimation = false; } }
// public void setPool(Pool<TextOutput> pool){ // this.pool=pool; // } public void decreaseTime() { timer.decreaseTime(); }