本文整理汇总了Java中com.badlogic.gdx.utils.StringBuilder.append方法的典型用法代码示例。如果您正苦于以下问题:Java StringBuilder.append方法的具体用法?Java StringBuilder.append怎么用?Java StringBuilder.append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.utils.StringBuilder
的用法示例。
在下文中一共展示了StringBuilder.append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSceneFile
import com.badlogic.gdx.utils.StringBuilder; //导入方法依赖的package包/类
private FileHandle createSceneFile(float width,float height,String name) throws IOException {
if (!path.isDirectory()){
path = path.parent();
}
StringBuilder filePath = new StringBuilder();
filePath.append(path.path());
filePath.append("/");
filePath.append(name);
filePath.append(".");
filePath.append(Config.sceneExtension);
FileHandle fileHandle = new FileHandle(filePath.toString());
if (fileHandle.file().exists()) fileHandle.delete();
fileHandle.file().createNewFile();
Writer writer = new FileWriter(fileHandle.file());
FileUtils.createScene(writer,width,height,name);
writer.close();
return fileHandle;
}
示例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: renderLoadingIndicator
import com.badlogic.gdx.utils.StringBuilder; //导入方法依赖的package包/类
public static int renderLoadingIndicator(float stateTime, int numberOfDots, SpriteBatch batch, BitmapFont font, String text) {
if (stateTime > 0.3f) {
++numberOfDots;
if (numberOfDots > 3) {
numberOfDots = 0;
}
}
StringBuilder fsb = StringUtil.getFSB();
fsb.append(text);
for (int i=0; i <numberOfDots; ++i) {
fsb.append(".");
}
batch.begin();
font.draw(batch, fsb.toString(), Gdx.graphics.getWidth()/2-50, Gdx.graphics.getHeight()/2+30);
batch.end();
StringUtil.freeFSB(fsb);
return numberOfDots;
}
示例4: getValue
import com.badlogic.gdx.utils.StringBuilder; //导入方法依赖的package包/类
@Override
Coordinate getValue() {
StringBuilder sb = new StringBuilder();
SnapshotArray<Actor> childs = this.getChildren();
for (Actor actor : childs) {
if (actor == null) {
sb.append(" ");
} else {
if (actor instanceof VisTextButton) {
sb.append(((VisTextButton) actor).getText());
} else if (actor instanceof VisLabel) {
sb.append(((VisLabel) actor).getText());
}
}
}
sb = sb.replace("OstW", "").replace("NordW", " ").replace("Zone", " ");
//switch Zone to first block
String s[] = sb.toString().split(" ");
String utmStr = s[2] + " " + s[0] + " " + s[1];
return new Coordinate(utmStr);
}
示例5: useItem
import com.badlogic.gdx.utils.StringBuilder; //导入方法依赖的package包/类
private void useItem(InventoryItem item, GameCharacter user) {
Array<ConditionResult> results = item.canBeUsedBy(user);
if (Condition.areResultsOk(results)) {
calculateTargetAndUseItem((UsableItem)item);
} else {
StringBuilder fsb = StringUtil.getFSB();
for (ConditionResult result : results) {
if (!result.passed) {
fsb.append(result.conditionName);
fsb.append(", ");
}
}
String failedConditions = fsb.substring(0, fsb.lastIndexOf(", "));
StringUtil.freeFSB(fsb);
Log.logLocalized("cannotUseItem", LogType.INVENTORY, user.getName(),
item.getName(), failedConditions);
}
}
示例6: getEffectsAsString
import com.badlogic.gdx.utils.StringBuilder; //导入方法依赖的package包/类
/**
* Gets the effects of this Perk as a human
* readable string.
*
* This does not include any modifiers
* associated with this Perk.
*
* @return null if there are no associated effects, the string otherwise
*/
public static String getEffectsAsString(EffectContainer ec, Object user) {
ObjectMap<Effect, Array<EffectParameter>> effects = ec.getEffects();
if (effects.size == 0) {
return null;
}
StringBuilder fsb = StringUtil.getFSB();
int i = 0;
for (Effect effect : effects.keys()) {
String desc = effect.getDescription(user, effects.get(effect));
if (desc == null) {
continue;
}
if (i > 0) {
fsb.append("\n");
}
fsb.append(desc);
++i;
}
String returnValue = fsb.toString();
StringUtil.freeFSB(fsb);
return returnValue;
}
示例7: toString
import com.badlogic.gdx.utils.StringBuilder; //导入方法依赖的package包/类
/**
* Prints this Modifier into a user-friendly string.
*
* If includeName is set to true, the resulting string
* will also include the name of the Modifier.
*
* @param includeName
* @return
*/
public String toString(boolean includeName) {
StringBuilder fsb = StringUtil.getFSB();
if (includeName) {
fsb.append(getName());
fsb.append(": ");
}
for (ModifiableStat mod : ModifiableStat.values()) {
fsb.append(modToString(mod, ", "));
}
String returnValue = fsb.toString();
StringUtil.freeFSB(fsb);
if (returnValue.endsWith(": ")) {
returnValue = "";
} else if (returnValue.endsWith(", ")) {
returnValue = returnValue.substring(0, returnValue.lastIndexOf(", "));
}
return returnValue;
}
示例8: modToString
import com.badlogic.gdx.utils.StringBuilder; //导入方法依赖的package包/类
private String modToString(ModifiableStat mod, String separator) {
float value = getMod(mod);
boolean multiply = mod.isMultiplier();
if ((value == 0 && !multiply) || (multiply && value == 1)) {
return "";
}
StringBuilder fsb = StringUtil.getFSB();
fsb.append(mod.toUIString());
fsb.append(": ");
fsb.append(getModAsString(mod));
if (separator != null) {
fsb.append(separator);
}
String returnValue = fsb.toString();
StringUtil.freeFSB(fsb);
return returnValue;
}
示例9: getModifiersAsString
import com.badlogic.gdx.utils.StringBuilder; //导入方法依赖的package包/类
/**
* Prints all the Modifiers in the suppled ModifierContainer
* in a user-friendly String. The supplied separator
* is used to separate individual Modifiers. If includeNames
* is true, the Modifiers names will also be printed.
* @param mc
* @param separator
* @param includeNames
* @return
*/
public static String getModifiersAsString(ModifierContainer mc, String separator, boolean includeNames) {
StringBuilder builder = StringUtil.getFSB();
Iterator<Modifier> modifiers = mc.getModifiers();
int i = 0;
while (modifiers.hasNext()) {
Modifier modifier = modifiers.next();
if (modifier.isNonZero()) {
if (i > 0) {
builder.append(separator);
}
builder.append(modifier.toString(includeNames));
}
++i;
}
String returnValue = builder.toString();
StringUtil.freeFSB(builder);
return returnValue;
}
示例10: 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);
}
}
}
示例11: writeString
import com.badlogic.gdx.utils.StringBuilder; //导入方法依赖的package包/类
public static void writeString(FileHandle file, String text) throws IOException {
StringBuilder builder = new StringBuilder(text.length());
String newLine = Host.os != Host.OS.Windows ? "\n" : "\r\n";
try (BufferedReader reader = new BufferedReader(new StringReader(text))) {
String line;
while ((line = reader.readLine()) != null) {
if (builder.length() > 0) {
builder.append(newLine);
}
builder.append(line);
}
}
file.writeString(builder.toString(), false);
}
示例12: 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();
}
示例13: appendFieldString
import com.badlogic.gdx.utils.StringBuilder; //导入方法依赖的package包/类
private static void appendFieldString (StringBuilder sb, Task<?> task, TaskAttribute ann, Field field) {
// prefer name from annotation if there is one
String name = ann.name();
if (name == null || name.length() == 0) name = field.getName();
Object value;
try {
field.setAccessible(true);
value = field.get(task);
} catch (ReflectionException e) {
Gdx.app.error("", "Failed to get field", e);
return;
}
sb.append(name).append(":");
Class<?> fieldType = field.getType();
if (fieldType.isEnum() || fieldType == String.class) {
sb.append('\"').append(value).append('\"');
} else if (Distribution.class.isAssignableFrom(fieldType)) {
sb.append('\"').append(DAs.toString((Distribution)value)).append('\"');
} else
sb.append(value);
}
示例14: save
import com.badlogic.gdx.utils.StringBuilder; //导入方法依赖的package包/类
public void save(String sceneName){
if(!isDirty)
return;
if(sceneName == null || sceneName.isEmpty())
return;
Scene.log("Save "+sceneName);
if(!sceneName.contains(basePackage) && !sceneName.contains("gdxstudio"))
sceneName = basePackage+sceneName;
StringBuilder sb = new StringBuilder();
for(Actor actor: getChildren()){
sb.append(json.toJson(actor));
sb.append("\n");
}
sb.append(json.toJson(getRoot().findActor(this.sceneName)));//??Warning
scenesMap.put(sceneName, sb.toString());
Gdx.files.local(Asset.basePath+"scene").writeString(json.toJson(scenesMap, ArrayMap.class,
String.class), false);
sb = null;
isDirty = false;
}
示例15: showChatMessages
import com.badlogic.gdx.utils.StringBuilder; //导入方法依赖的package包/类
public void showChatMessages(StringBuilder sb) {
for (ChatMessage chat : chatMessages) {
long elapsed = TimeUtils.timeSinceMillis(chat.createTime);
if (elapsed >= chatMessageLifeTime) {
chatMessages.removeValue(chat, true);
} else {
sb.append("\n[");
if (chat.playerId == -1) {
sb.append("Server");
} else {
sb.append("Player ").append(chat.playerId);
}
sb.append("]: ").append(chat.text);
}
}
}