本文整理汇总了Java中com.badlogic.gdx.utils.StringBuilder.setLength方法的典型用法代码示例。如果您正苦于以下问题:Java StringBuilder.setLength方法的具体用法?Java StringBuilder.setLength怎么用?Java StringBuilder.setLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.utils.StringBuilder
的用法示例。
在下文中一共展示了StringBuilder.setLength方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildActivationRequirements
import com.badlogic.gdx.utils.StringBuilder; //导入方法依赖的package包/类
@Override
protected void buildActivationRequirements(GameCharacter character,
StringBuilder fsb) {
super.buildActivationRequirements(character, fsb);
ObjectMap<String, Boolean> foci = spell.getFoci();
if (foci.size > 0) {
addLine();
addLine(Strings.getString(Spell.STRING_TABLE, "foci"), style.headingStyle);
Inventory inventory = character.getInventory();
for (Entry<String, Boolean> entry : foci.entries()) {
fsb.append(InventoryItem.getItemPrototype(entry.key).getName());
if (entry.value) {
fsb.append(" (");
fsb.append(Strings.getString(Spell.STRING_TABLE, "consumed"));
fsb.append(")");
}
addLine(fsb.toString(),
inventory.getItem(entry.key) != null ? style.reqsReachedStyle
: style.reqsNotReachedStyle);
fsb.setLength(0);
}
}
}
示例2: buildLearnRequirements
import com.badlogic.gdx.utils.StringBuilder; //导入方法依赖的package包/类
protected void buildLearnRequirements(GameCharacter character, StringBuilder fsb) {
addLine();
addLine(Strings.getString(Perk.STRING_TABLE, "learnRequirements"), style.subheadingStyle);
fsb.append(Strings.getString(ModifiableStat.STRING_TABLE, "level"));
fsb.append(": ");
fsb.append(Integer.toString(perk.getLevelRequirement()));
if (perk.getLevelRequirement() > character.stats().getLevel()) {
addLine(fsb.toString(), style.reqsNotReachedStyle);
} else {
addLine(fsb.toString(), style.reqsReachedStyle);
}
fsb.setLength(0);
Array<ConditionResult> learnReqs = perk.evaluateLearnRequirements(character);
if (learnReqs != null) {
for (ConditionResult result : learnReqs) {
addLine(result.conditionName, result.passed ? style.reqsReachedStyle : style.reqsNotReachedStyle);
}
}
}
示例3: toString
import com.badlogic.gdx.utils.StringBuilder; //导入方法依赖的package包/类
@Override
public String toString() {
StringBuilder builder = algorithm.stringBuilder.get();
builder.setLength(0);
int v;
char c;
for (byte b : value) {
v = (b & 0xf0) >> 4;
c = (v < 10) ? (char) ('0' + v) : (char) ('a' + v - 10);
builder.append(c);
v = b & 0x0f;
c = (v < 10) ? (char) ('0' + v) : (char) ('a' + v - 10);
builder.append(c);
}
return builder.toString();
}
示例4: buildName
import com.badlogic.gdx.utils.StringBuilder; //导入方法依赖的package包/类
@Override
protected void buildName(GameCharacter ic, StringBuilder fsb) {
fsb.append(item.getName());
if (item.getInventory() != null) {
fsb.append(": ");
fsb.append(item.getTradingCost(ic, merchant, merchant.equals(item
.getInventory().getParentContainer())));
fsb.append(" ");
fsb.append(Strings.getString(InventoryItem.STRING_TABLE,
"GoldPiecesAbbreviation"));
}
addLine(fsb.toString(), style.headingStyle);
fsb.setLength(0);
}
示例5: buildName
import com.badlogic.gdx.utils.StringBuilder; //导入方法依赖的package包/类
protected void buildName(StringBuilder fsb) {
fsb.append(perk.getName());
if (!perk.isActivated()) {
fsb.append(" (");
fsb.append(Strings.getString(Perk.STRING_TABLE, "passive"));
fsb.append(")");
}
addLine(fsb.toString(), style.headingStyle);
fsb.setLength(0);
}
示例6: act
import com.badlogic.gdx.utils.StringBuilder; //导入方法依赖的package包/类
@Override
public void act (float delta) {
int newValue = getValue();
if (oldValue != newValue) {
oldValue = newValue;
StringBuilder sb = getText();
sb.setLength(appendIndex);
sb.append(oldValue);
invalidateHierarchy();
}
super.act(delta);
}
示例7: act
import com.badlogic.gdx.utils.StringBuilder; //导入方法依赖的package包/类
@Override
public void act (float delta) {
float newValue = getValue();
if (oldValue != newValue) {
oldValue = newValue;
StringBuilder sb = getText();
sb.setLength(appendIndex);
sb.append(oldValue);
invalidateHierarchy();
}
super.act(delta);
}
示例8: act
import com.badlogic.gdx.utils.StringBuilder; //导入方法依赖的package包/类
@Override
public void act (float delta) {
T newValue = getValue();
if (!oldValue.equals(newValue)) {
copyValue(newValue, oldValue);
StringBuilder sb = getText();
sb.setLength(appendIndex);
sb.append(oldValue);
invalidateHierarchy();
}
super.act(delta);
}
示例9: encodeFloatBits
import com.badlogic.gdx.utils.StringBuilder; //导入方法依赖的package包/类
public static String encodeFloatBits(float value) {
StringBuilder builder = stringBuilder.get();
builder.setLength(0);
builder.append("0x");
builder.append(String.format("%08X", Float.floatToRawIntBits(value)));
builder.append("|");
builder.append(value);
return builder.toString();
}
示例10: encodeDoubleBits
import com.badlogic.gdx.utils.StringBuilder; //导入方法依赖的package包/类
public static String encodeDoubleBits(double value) {
StringBuilder builder = stringBuilder.get();
builder.setLength(0);
builder.append("0x");
builder.append(String.format("%016X", Double.doubleToRawLongBits(value)));
builder.append("|");
builder.append(value);
return builder.toString();
}
示例11: getStatus
import com.badlogic.gdx.utils.StringBuilder; //导入方法依赖的package包/类
protected void getStatus (final StringBuilder stringBuilder) {
stringBuilder.setLength(0);
stringBuilder.append("GL calls: ");
stringBuilder.append(GLProfiler.calls);
glCallsLabel.setText(stringBuilder);
stringBuilder.setLength(0);
stringBuilder.append("Draw calls: ");
stringBuilder.append(GLProfiler.drawCalls);
drawCallsLabel.setText(stringBuilder);
stringBuilder.setLength(0);
stringBuilder.append("Shader switches: ");
stringBuilder.append(GLProfiler.shaderSwitches);
shaderSwitchesLabel.setText(stringBuilder);
stringBuilder.setLength(0);
stringBuilder.append("Texture bindings: ");
stringBuilder.append(GLProfiler.textureBindings);
textureBindsLabel.setText(stringBuilder);
stringBuilder.setLength(0);
stringBuilder.append("Vertices: ");
stringBuilder.append(GLProfiler.vertexCount.total);
vertexCountLabel.setText(stringBuilder);
stringBuilder.setLength(0);
stringBuilder.append("Lights: ");
stringBuilder.append(environment.directionalLights.size + environment.pointLights.size);
stringBuilder.append(", Directional: ");
stringBuilder.append(environment.directionalLights.size);
stringBuilder.append(", Point: ");
stringBuilder.append(environment.pointLights.size);
lightsLabel.setText(stringBuilder);
GLProfiler.reset();
stringBuilder.setLength(0);
super.getStatus(stringBuilder);
}
示例12: getStatus
import com.badlogic.gdx.utils.StringBuilder; //导入方法依赖的package包/类
protected void getStatus (final StringBuilder stringBuilder) {
stringBuilder.setLength(0);
stringBuilder.append("GL calls: ");
stringBuilder.append(GLProfiler.calls);
glCallsLabel.setText(stringBuilder);
stringBuilder.setLength(0);
stringBuilder.append("Draw calls: ");
stringBuilder.append(GLProfiler.drawCalls);
drawCallsLabel.setText(stringBuilder);
stringBuilder.setLength(0);
stringBuilder.append("Shader switches: ");
stringBuilder.append(GLProfiler.shaderSwitches);
shaderSwitchesLabel.setText(stringBuilder);
stringBuilder.setLength(0);
stringBuilder.append("Texture bindings: ");
stringBuilder.append(GLProfiler.textureBindings);
textureBindsLabel.setText(stringBuilder);
stringBuilder.setLength(0);
stringBuilder.append("Vertices: ");
stringBuilder.append((int)GLProfiler.vertexCount.total);
vertexCountLabel.setText(stringBuilder);
GLProfiler.reset();
stringBuilder.setLength(0);
stringBuilder.append("FPS: ").append(Gdx.graphics.getFramesPerSecond());
}
示例13: buildActivationRequirements
import com.badlogic.gdx.utils.StringBuilder; //导入方法依赖的package包/类
protected void buildActivationRequirements(GameCharacter character, StringBuilder fsb) {
Array<ConditionResult> activationReqs = perk.evaluateActivationRequirements(character);
if (activationReqs != null || perk.isCombatOnly()) {
addLine();
addLine(Strings.getString(Perk.STRING_TABLE, "useRequirements"), style.subheadingStyle);
if (perk.isCombatOnly()) {
addLine(Strings.getString(Perk.STRING_TABLE, "combatOnly"), GameState.isCombatInProgress() ? style.reqsReachedStyle : style.reqsNotReachedStyle);
}
if (activationReqs != null) {
for (ConditionResult result : activationReqs) {
addLine(result.conditionName, result.passed ? style.reqsReachedStyle : style.reqsNotReachedStyle);
}
}
}
addLine();
addLine(Strings.getString(Perk.STRING_TABLE, "cost"), style.subheadingStyle);
fsb.append(Strings.getString(ModifiableStat.STRING_TABLE, "actionPoints"));
fsb.append(": ");
fsb.append(Integer.toString(perk.getApCost(character)));
addLine(fsb.toString(), !GameState.isCombatInProgress() || (character.stats().getAPAct() >= perk.getApCost(character)) ? style.reqsReachedStyle : style.reqsNotReachedStyle);
fsb.setLength(0);
if (perk.getHpCost() != 0) {
fsb.append(Strings.getString(ModifiableStat.STRING_TABLE, "hitPoints"));
fsb.append(": ");
fsb.append(Integer.toString(perk.getHpCost()));
addLine(fsb.toString(), character.stats().getHPAct() >= perk.getHpCost() ? style.reqsReachedStyle : style.reqsNotReachedStyle);
fsb.setLength(0);
}
if (perk.getSpCost() != 0) {
fsb.append(Strings.getString(ModifiableStat.STRING_TABLE, "stamina"));
fsb.append(": ");
fsb.append(Integer.toString(perk.getSpCost()));
addLine(fsb.toString(), character.stats().getSPAct() >= perk.getSpCost() ? style.reqsReachedStyle : style.reqsNotReachedStyle);
fsb.setLength(0);
}
if (perk.getMpCost(character) != 0) {
fsb.append(Strings.getString(ModifiableStat.STRING_TABLE, "mana"));
fsb.append(": ");
fsb.append(Integer.toString(perk.getMpCost(character)));
addLine(fsb.toString(), character.stats().getMPAct() >= perk.getMpCost(character) ? style.reqsReachedStyle : style.reqsNotReachedStyle);
fsb.setLength(0);
}
}
示例14: recalculateInfo
import com.badlogic.gdx.utils.StringBuilder; //导入方法依赖的package包/类
private void recalculateInfo() {
// STATS
// hp
hp.setText(Strings.getString(GameCharacter.STRING_TABLE, "hpMaxAndRecovery", race.getMaxHPGain(), race.getHPRecovery()));
// mp
mp.setText(Strings.getString(GameCharacter.STRING_TABLE, "mpMaxAndRecovery", race.getMaxMPGain(), race.getMPRecovery()));
// sp
sp.setText(Strings.getString(GameCharacter.STRING_TABLE, "spMaxAndRecovery", race.getMaxSPGain(), race.getSPRecovery()));
// ap
ap.setText(Integer.toString(race.getMaxAP()));
// exp
exp.setText(MathUtil.toUIString(race.getExperienceGainMultiplier()));
// ENCUMBERANCE
maxEncumberance.setText(Strings.getString(GameCharacter.STRING_TABLE,
"encumberanceValues", MathUtil.toUIString(race.getMaxEncumbrance() / 1000f),
race.getMaxRations(), race.getMaxWater()));
// SPEED
speed.setText(Strings.getString(GameCharacter.STRING_TABLE,
"speedValues", race.getWalkSpeed(),
race.getDetectingTrapsSpeed(), race.getSneakingSpeed()));
// SURVIVAL
// sleep
sleep.setText(race.getSleepPeriod() > 0 ? Strings.getString(GameCharacter.STRING_TABLE, "sleepValues",
race.getSleepPeriod(), race.getMoreTiredAfter()) : Strings.getString(GameCharacter.STRING_TABLE,
"noNeedToSleep"));
// hunger
hunger.setText(race.getHungerPeriod() > 0 ? Strings.getString(GameCharacter.STRING_TABLE, "hungerValues",
race.getAmountEaten(), race.getHungerPeriod(), race.getHungerRecovery()) : Strings.getString(
GameCharacter.STRING_TABLE, "noNeedToEat"));
// thirst
thirst.setText(race.getThirstPeriod() > 0 ? Strings.getString(GameCharacter.STRING_TABLE, "thirstValues",
race.getAmountDrank(), race.getThirstPeriod(), race.getThirstRecovery()) : Strings.getString(
GameCharacter.STRING_TABLE, "noNeedToDrink"));
// SKILLS
StringBuilder fsb = StringUtil.getFSB();
Array<String> skills = new Array<String>();
Skills inherentSkills = race.getInherentSkills();
for (Skill skill : Skill.values()) {
int rank = inherentSkills.getSkillRank(skill);
if (rank != 0) {
skills.add(skill.toUIString()+" "+rank);
}
}
fsb.append(skills.toString(", "));
this.skills.setText(fsb.toString());
fsb.setLength(0);
// INVENTORY
if (inventory != null) {
Array<InventoryItem> items = race.getInventory().getAllItems();
Array<String> itemNames = new Array<String>();
for (InventoryItem item : items) {
itemNames.add(item.getName());
}
fsb.append(itemNames.toString(", "));
this.inventory.setText(fsb.toString());
}
StringUtil.freeFSB(fsb);
}
示例15: freeFSB
import com.badlogic.gdx.utils.StringBuilder; //导入方法依赖的package包/类
public static void freeFSB(StringBuilder fsb) {
fsb.setLength(0);
stringBufferPool.free(fsb);
}