本文整理汇总了Java中com.badlogic.gdx.utils.Bits.length方法的典型用法代码示例。如果您正苦于以下问题:Java Bits.length方法的具体用法?Java Bits.length怎么用?Java Bits.length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.utils.Bits
的用法示例。
在下文中一共展示了Bits.length方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeEntityListener
import com.badlogic.gdx.utils.Bits; //导入方法依赖的package包/类
public void removeEntityListener (EntityListener listener) {
for (int i = 0; i < entityListeners.size; i++) {
EntityListenerData entityListenerData = entityListeners.get(i);
if (entityListenerData.listener == listener) {
// Shift down bitmasks by one step
for (Bits mask : entityListenerMasks.values()) {
for (int k = i, n = mask.length(); k < n; k++) {
if (mask.get(k + 1)) {
mask.set(k);
} else {
mask.clear(k);
}
}
}
entityListeners.removeIndex(i--);
}
}
}
示例2: getBitsString
import com.badlogic.gdx.utils.Bits; //导入方法依赖的package包/类
private static String getBitsString (Bits bits) {
StringBuilder stringBuilder = new StringBuilder();
int numBits = bits.length();
for (int i = 0; i < numBits; ++i) {
stringBuilder.append(bits.get(i) ? "1" : "0");
}
return stringBuilder.toString();
}
示例3: addEntityListener
import com.badlogic.gdx.utils.Bits; //导入方法依赖的package包/类
public void addEntityListener (Family family, int priority, EntityListener listener) {
registerFamily(family);
int insertionIndex = 0;
while (insertionIndex < entityListeners.size) {
if (entityListeners.get(insertionIndex).priority <= priority) {
insertionIndex++;
} else {
break;
}
}
// Shift up bitmasks by one step
for (Bits mask : entityListenerMasks.values()) {
for (int k = mask.length(); k > insertionIndex; k--) {
if (mask.get(k - 1)) {
mask.set(k);
} else {
mask.clear(k);
}
}
mask.clear(insertionIndex);
}
entityListenerMasks.get(family).set(insertionIndex);
EntityListenerData entityListenerData = new EntityListenerData();
entityListenerData.listener = listener;
entityListenerData.priority = priority;
entityListeners.insert(insertionIndex, entityListenerData);
}
示例4: addAndRemoveComponent
import com.badlogic.gdx.utils.Bits; //导入方法依赖的package包/类
@Test
public void addAndRemoveComponent () {
Entity entity = new Entity();
entity.add(new ComponentA());
assertEquals(1, entity.getComponents().size());
Bits componentBits = entity.getComponentBits();
int componentAIndex = ComponentType.getIndexFor(ComponentA.class);
for (int i = 0; i < componentBits.length(); ++i) {
assertEquals(i == componentAIndex, componentBits.get(i));
}
assertNotNull(am.get(entity));
assertNull(bm.get(entity));
assertTrue(am.has(entity));
assertFalse(bm.has(entity));
entity.remove(ComponentA.class);
assertEquals(0, entity.getComponents().size());
for (int i = 0; i < componentBits.length(); ++i) {
assertFalse(componentBits.get(i));
}
assertNull(am.get(entity));
assertNull(bm.get(entity));
assertFalse(am.has(entity));
assertFalse(bm.has(entity));
}
示例5: addAndRemoveAllComponents
import com.badlogic.gdx.utils.Bits; //导入方法依赖的package包/类
@Test
public void addAndRemoveAllComponents () {
Entity entity = new Entity();
entity.add(new ComponentA());
entity.add(new ComponentB());
assertEquals(2, entity.getComponents().size());
Bits componentBits = entity.getComponentBits();
int componentAIndex = ComponentType.getIndexFor(ComponentA.class);
int componentBIndex = ComponentType.getIndexFor(ComponentB.class);
for (int i = 0; i < componentBits.length(); ++i) {
assertEquals(i == componentAIndex || i == componentBIndex, componentBits.get(i));
}
assertNotNull(am.get(entity));
assertNotNull(bm.get(entity));
assertTrue(am.has(entity));
assertTrue(bm.has(entity));
entity.removeAll();
assertEquals(0, entity.getComponents().size());
for (int i = 0; i < componentBits.length(); ++i) {
assertFalse(componentBits.get(i));
}
assertNull(am.get(entity));
assertNull(bm.get(entity));
assertFalse(am.has(entity));
assertFalse(bm.has(entity));
}
示例6: getBitsString
import com.badlogic.gdx.utils.Bits; //导入方法依赖的package包/类
private static String getBitsString(Bits bits) {
StringBuilder builder = new StringBuilder();
int numBits = bits.length();
for (int i = 0; i < numBits; ++i) {
builder.append(bits.get(i) ? "1" : "0");
}
return builder.toString();
}
示例7: addAndRemoveComponent
import com.badlogic.gdx.utils.Bits; //导入方法依赖的package包/类
@Test
public void addAndRemoveComponent() {
Entity entity = new Entity();
entity.add(new ComponentA());
assertEquals(1, entity.getComponents().size());
Bits componentBits = entity.getComponentBits();
int componentAIndex = ComponentType.getIndexFor(ComponentA.class);
for (int i = 0; i < componentBits.length(); ++i) {
assertEquals(i == componentAIndex, componentBits.get(i));
}
assertNotNull(am.get(entity));
assertNull(bm.get(entity));
assertTrue(am.has(entity));
assertFalse(bm.has(entity));
entity.remove(ComponentA.class);
assertEquals(0, entity.getComponents().size());
for (int i = 0; i < componentBits.length(); ++i) {
assertFalse(componentBits.get(i));
}
assertNull(am.get(entity));
assertNull(bm.get(entity));
assertFalse(am.has(entity));
assertFalse(bm.has(entity));
}
示例8: addAndRemoveAllComponents
import com.badlogic.gdx.utils.Bits; //导入方法依赖的package包/类
@Test
public void addAndRemoveAllComponents() {
Entity entity = new Entity();
entity.add(new ComponentA());
entity.add(new ComponentB());
assertEquals(2, entity.getComponents().size());
Bits componentBits = entity.getComponentBits();
int componentAIndex = ComponentType.getIndexFor(ComponentA.class);
int componentBIndex = ComponentType.getIndexFor(ComponentB.class);
for (int i = 0; i < componentBits.length(); ++i) {
assertEquals(i == componentAIndex || i == componentBIndex, componentBits.get(i));
}
assertNotNull(am.get(entity));
assertNotNull(bm.get(entity));
assertTrue(am.has(entity));
assertTrue(bm.has(entity));
entity.removeAll();
assertEquals(0, entity.getComponents().size());
for (int i = 0; i < componentBits.length(); ++i) {
assertFalse(componentBits.get(i));
}
assertNull(am.get(entity));
assertNull(bm.get(entity));
assertFalse(am.has(entity));
assertFalse(bm.has(entity));
}