本文整理汇总了Java中com.badlogic.gdx.utils.StringBuilder.toString方法的典型用法代码示例。如果您正苦于以下问题:Java StringBuilder.toString方法的具体用法?Java StringBuilder.toString怎么用?Java StringBuilder.toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.utils.StringBuilder
的用法示例。
在下文中一共展示了StringBuilder.toString方法的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: getValue
import com.badlogic.gdx.utils.StringBuilder; //导入方法依赖的package包/类
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());
}
}
}
return new Coordinate(sb.toString());
}
示例3: getScoreHash
import com.badlogic.gdx.utils.StringBuilder; //导入方法依赖的package包/类
private String getScoreHash(IRScoreData score) {
byte[] cipher_byte;
try {
MessageDigest md = MessageDigest.getInstance("SHA-256");
md.update((hashkey + score.getSha256() + "," + score.getExscore() + "," + score.getEpg() + ","
+ score.getLpg() + "," + score.getEgr() + "," + score.getLgr() + "," + score.getEgd() + ","
+ score.getLgd() + "," + score.getEbd() + "," + score.getLbd() + "," + score.getEpr() + ","
+ score.getLpr() + "," + score.getEms() + "," + score.getLms() + "," + score.getClear() + ","
+ score.getMinbp() + "," + score.getCombo() + "," + score.getMode() + "," + score.getClearcount()
+ "," + score.getPlaycount() + "," + score.getOption() + "," + score.getRandom() + ","
+ score.getHistory() + "," + score.getDate()).getBytes());
cipher_byte = md.digest();
StringBuilder sb = new StringBuilder(2 * cipher_byte.length);
for (byte b : cipher_byte) {
sb.append(String.format("%02x", b & 0xff));
}
return "035" + sb.toString();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
示例4: getStory
import com.badlogic.gdx.utils.StringBuilder; //导入方法依赖的package包/类
/**
* Returns the history of this quest (descriptions and times
* of all its states) in a human readable string form.
*
* Returns an empty string if the quest is not started.
*
* @return
*/
public String getStory() {
StringBuilder builder = StringUtil.getFSB();
int i = 0;
for (State<QuestTransition> state : story) {
String description = state.getDescription();
if (description != null && !description.isEmpty()) {
String separator = i == story.size-1 ? "" : "\n\n";
builder.append(storyTimes.get(i).toStringNoTime());
builder.append(": ");
builder.append(description);
builder.append(separator);
}
++i;
}
String returnValue = builder.toString();
StringUtil.freeFSB(builder);
return returnValue;
}
示例5: 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;
}
示例6: 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;
}
示例7: 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;
}
示例8: 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;
}
示例9: 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();
}
示例10: toString
import com.badlogic.gdx.utils.StringBuilder; //导入方法依赖的package包/类
public String toString() {
if (size == 0)
return "{}";
StringBuilder buffer = new StringBuilder(32);
buffer.append('{');
Array<K> keys = this.keys;
for (int i = 0, n = keys.size; i < n; i++) {
K key = keys.get(i);
if (i > 0)
buffer.append(", ");
buffer.append(key);
buffer.append('=');
buffer.append(get(key));
}
buffer.append('}');
return buffer.toString();
}
示例11: mapToString
import com.badlogic.gdx.utils.StringBuilder; //导入方法依赖的package包/类
public static String mapToString (int[][] map) {
StringBuilder sb = new StringBuilder(map.length * (map[0].length + 1)); // +1 is due to the new line char
for (int x = 0; x < map.length; x++) {
for (int y = 0; y < map[0].length; y++) {
switch (map[x][y]) {
case TILE_EMPTY:
sb.append(' ');
break;
case TILE_FLOOR:
sb.append('.');
break;
case TILE_WALL:
sb.append('#');
break;
default:
sb.append('?');
break;
}
}
sb.append('\n');
}
return sb.toString();
}
示例12: generateGenericVertexShader
import com.badlogic.gdx.utils.StringBuilder; //导入方法依赖的package包/类
public static String generateGenericVertexShader (int textureCount) {
boolean v3 = Gdx.gl30 != null;
String attribute = v3 ? "in" : "attribute";
String varying = v3 ? "out" : "varying";
StringBuilder sb = new StringBuilder();
if (v3) sb.append("#version 300 es\n");
sb.append(attribute).append(" vec4 ").append(ShaderProgram.POSITION_ATTRIBUTE).append(";\n");
sb.append(attribute).append(" vec4 ").append(ShaderProgram.COLOR_ATTRIBUTE).append(";\n");
for (int i = 0; i < textureCount; i++)
sb.append(attribute).append(" vec2 ").append(ShaderProgram.TEXCOORD_ATTRIBUTE).append(i).append(";\n");
sb.append("uniform mat4 u_projTrans;\n");
sb.append(varying).append(" vec4 v_color;\n");
for (int i = 0; i < textureCount; i++)
sb.append(varying).append(" vec2 v_texCoords").append(i).append(";\n\n");
sb.append("void main()\n");
sb.append("{\n");
sb.append(" v_color = ").append(ShaderProgram.COLOR_ATTRIBUTE).append(";\n");
sb.append(" v_color.a = v_color.a * (255.0/254.0);\n");
for (int i = 0; i < textureCount; i++)
sb.append(" v_texCoords").append(i).append(" = ").append(ShaderProgram.TEXCOORD_ATTRIBUTE).append(i).append(";\n");
sb.append(" gl_Position = u_projTrans * ").append(ShaderProgram.POSITION_ATTRIBUTE).append(";\n");
sb.append("}\n");
return sb.toString();
}
示例13: generateGenericFragmentShader
import com.badlogic.gdx.utils.StringBuilder; //导入方法依赖的package包/类
public static String generateGenericFragmentShader (int textureCount) { // TODO default should only use first texture
boolean v3 = Gdx.gl30 != null;
String varying = v3 ? "in" : "varying";
String outColor = v3 ? "fragmentColor" : "gl_FragColor";
String tex2D = v3 ? "texture, " : "texture2D";
StringBuilder sb = new StringBuilder();
if (v3) sb.append("#version 300 es\n");
sb.append("#ifdef GL_ES\n");
sb.append("#define LOWP lowp\n");
sb.append("precision mediump float;\n");
sb.append("#else\n");
sb.append("#define LOWP \n");
sb.append("#endif\n\n");
sb.append(varying).append(" LOWP vec4 v_color;\n");
for (int i = 0; i < textureCount; i++)
sb.append(varying).append(" vec2 v_texCoords").append(i).append(";\n");
for (int i = 0; i < textureCount; i++)
sb.append("uniform sampler2D u_texture").append(i).append(";\n");
if (v3) sb.append("out LOWP vec4 ").append(outColor).append("\n");
sb.append("\n");
sb.append("void main()\n");
sb.append("{\n");
if (textureCount == 0)
sb.append(" ").append(outColor).append(" = v_color;\n");
else if (textureCount == 1)
sb.append(" ").append(outColor).append(" = v_color * texture2D(u_texture0, v_texCoords0);\n");
else {
sb.append("LOWP vec4 color = ").append(tex2D).append("(u_texture0, v_texCoords0);\n");
for (int i = 1; i < textureCount; i++)
sb.append("color += ").append(tex2D).append("(u_texture").append(i).append(", v_texCoords").append(i).append(");\n");
sb.append(" ").append(outColor).append(" = v_color * color / ").append(textureCount).append(";\n");
}
sb.append("}");
return sb.toString();
}
示例14: toString
import com.badlogic.gdx.utils.StringBuilder; //导入方法依赖的package包/类
@Override public String toString() {
StringBuilder result = new StringBuilder();
float radians = angle();
result.append("radians: ");
result.append(radians);
result.append(", degrees: ");
result.append(radians * MathUtils.radiansToDegrees);
return result.toString();
}
示例15: read
import com.badlogic.gdx.utils.StringBuilder; //导入方法依赖的package包/类
private DynamicShader.Info read(String name) throws IOException {
File dir = new File("shaders/");
if (!dir.exists()) dir.mkdir();
File file = new File("shaders/" + name + ".shader");
List<String> lines = Files.readAllLines(file.toPath());
StringBuilder sb = new StringBuilder();
lines.forEach(sb::append);
String json = sb.toString();
DynamicShader.Info info = Argent.serial.deserialize(json, DynamicShader.Info.class);
System.out.println(info);
return info;
}