当前位置: 首页>>代码示例>>Java>>正文


Java StringBuilder.setLength方法代码示例

本文整理汇总了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);
		}
	}
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:26,代码来源:SpellTooltip.java

示例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);
		}
	}
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:22,代码来源:PerkTooltip.java

示例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();
}
 
开发者ID:code-disaster,项目名称:libgdx-snippets,代码行数:21,代码来源:SHA1.java

示例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);
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:15,代码来源:TradingItemTooltip.java

示例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);
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:11,代码来源:PerkTooltip.java

示例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);
}
 
开发者ID:jsjolund,项目名称:GdxDemo3D,代码行数:13,代码来源:IntValueLabel.java

示例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);
}
 
开发者ID:jsjolund,项目名称:GdxDemo3D,代码行数:13,代码来源:FloatValueLabel.java

示例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);
}
 
开发者ID:jsjolund,项目名称:GdxDemo3D,代码行数:13,代码来源:ObjectValueLabel.java

示例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();
	}
 
开发者ID:code-disaster,项目名称:libgdx-snippets,代码行数:13,代码来源:JsonFloatSerializer.java

示例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();
	}
 
开发者ID:code-disaster,项目名称:libgdx-snippets,代码行数:13,代码来源:JsonFloatSerializer.java

示例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);
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:41,代码来源:Benchmark3DTest.java

示例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());
}
 
开发者ID:if1live,项目名称:amatsukaze,代码行数:32,代码来源:BaseGame.java

示例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);
	}
	
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:50,代码来源:PerkTooltip.java

示例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);
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:71,代码来源:RaceInfoPanel.java

示例15: freeFSB

import com.badlogic.gdx.utils.StringBuilder; //导入方法依赖的package包/类
public static void freeFSB(StringBuilder fsb) {
	fsb.setLength(0);
	stringBufferPool.free(fsb);
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:5,代码来源:StringUtil.java


注:本文中的com.badlogic.gdx.utils.StringBuilder.setLength方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。