FlixelStringUtil
View sourceclass
org.flixelgdx.util.FlixelStringUtil
Handy utility class for manipulating strings more efficiently.
Methods
contentEquals(CharSequence, CharSequence)
Compares the content of two CharSequences for equality. This works for Strings, StringBuilders, and any CharSequences.
Parameters:
| Name | Description |
|---|---|
a | The first CharSequence to compare. |
b | The second CharSequence to compare. |
Returns: true if the content of the two CharSequences is equal, false otherwise.
appendFloatRounded(CharArray, float, int)
Appends value rounded to decimals decimal places using only CharArray primitive appenders, avoiding Float.toString(...) and other helpers that allocate String objects.
Non-finite values fall back to CharArray.append(...).
When decimals is zero or negative, the value is rounded to the nearest integer and no decimal point is written.
Fractional digits are zero-padded on the left so the output always has exactly decimals digits after the decimal point (for example, 3.05f with decimals = 2 produces "3.05", not "3.5").
Because this method uses long arithmetic internally, meaningful precision is still limited to roughly seven significant digits (the range of a float).
Parameters:
| Name | Description |
|---|---|
out | Destination buffer. For FlixelString callers, prefer FlixelString.concatFloatRounded(float, int) or FlixelString.setFloatRounded(float, int) instead of reaching for a raw CharArray. |
value | Value to format. |
decimals | Number of digits after the decimal point; values of zero or less produce an integer with no decimal point. |
appendFloatRoundedOneDecimal(CharArray, float)
Appends value rounded to one decimal place (nearest tenth). Convenience wrapper for FlixelStringUtil.appendFloatRounded(...) with decimals = 1.
Non-finite values fall back to CharArray.append(...).
Parameters:
| Name | Description |
|---|---|
out | Destination buffer. For FlixelString, callers prefer FlixelString.concatFloatRoundedOneDecimal(float) or FlixelString.setFloatRoundedOneDecimal(float) instead of reaching for a raw CharArray. |
value | Value to format. |