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


Java Bits.length方法代码示例

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

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

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

示例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));
}
 
开发者ID:DevelopersGuild,项目名称:Planetbase,代码行数:34,代码来源:EntityTests.java

示例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));
}
 
开发者ID:DevelopersGuild,项目名称:Planetbase,代码行数:36,代码来源:EntityTests.java

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

示例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));
}
 
开发者ID:grum,项目名称:Ashley,代码行数:34,代码来源:EntityTests.java

示例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));
}
 
开发者ID:grum,项目名称:Ashley,代码行数:36,代码来源:EntityTests.java


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