本文整理匯總了Java中com.badlogic.gdx.utils.IntMap類的典型用法代碼示例。如果您正苦於以下問題:Java IntMap類的具體用法?Java IntMap怎麽用?Java IntMap使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
IntMap類屬於com.badlogic.gdx.utils包,在下文中一共展示了IntMap類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: Basic
import com.badlogic.gdx.utils.IntMap; //導入依賴的package包/類
public Basic(Matrix4 transform, double speeed, int hp, int health, int range, float coolDown, EnumSet<Types> types, EnumSet<Effects> effects, ModelInstance instance, btCollisionWorld world, IntMap<Entity> entities, List<Vector3> path, Map<String, Sound> sounds) {
super(transform, speeed, hp, health, range, coolDown, types, effects, instance, new btCompoundShape(), world, entities, ATTACK_ANIMATION, ATTACK_OFFSET, path, sounds);
((btCompoundShape)shape).addChildShape(new Matrix4(new Vector3(0, 30, 0), new Quaternion().setEulerAngles(0, 0, 0), new Vector3(1, 1, 1)), new btBoxShape(new Vector3(75, 30, 90)));
//System.out.println(getModelInstance().getAnimation("Spider_Armature|walk_ani_vor").id);
listener = new AnimationController.AnimationListener() {
@Override
public void onEnd(AnimationController.AnimationDesc animationDesc) {
}
@Override
public void onLoop(AnimationController.AnimationDesc animationDesc) {
}
};
//animation.setAnimation("Spider_Armature|walk_ani_vor");
//animation.animate("Spider_Armature|walk_ani_vor", -1);
//animation.action("Spider_Armature|walk_ani_vor", 0, 1000, -1, 1, listener, 0);
//animation.animate("Spider_Armature|Attack", 0, 1000, 1, 1, listener, 0);
//animation.queue("Spider_Armature|walk_ani_vor", 0, 1000, -1, 1, listener, 0);
}
示例2: tick
import com.badlogic.gdx.utils.IntMap; //導入依賴的package包/類
public void tick(float delta, GameScreen screen) {
if (!started && screen.isPaused()) {
started = true;
prevTime = System.currentTimeMillis();
}
if (spawns != null && enemyIndex < spawns.size() && System.currentTimeMillis() > prevTime + spawns.get(enemyIndex).getDelay()) {
prevTime = System.currentTimeMillis();
String name = spawns.get(enemyIndex).getName();
ModelInstance instance;
try {
Class<?> c = enemyClasses.get(name);
Constructor constructor = c.getConstructor(Matrix4.class, Map.class, btCollisionWorld.class, IntMap.class, List.class, Map.class);
enemies.add((Enemy) constructor.newInstance(new Matrix4().setToTranslation(pos), models, world, entity, path, sounds));
} catch (Exception e) {
Gdx.app.log("EnemySpawner spawn enemy", e.toString());
}
enemyIndex++;
}
//for (Enemy enemy : enemies)
// enemy.tick(delta, path);
}
示例3: update
import com.badlogic.gdx.utils.IntMap; //導入依賴的package包/類
@Override
protected void update(float delta) {
if (!paused && !isLoading) {
/*for (IntMap.Entry<Entity> entry : entities.entries()) {
entry.value.tick(delta);
if (entry.value.isDead) {
entry.value.destroy();
}
}*/
Iterator<IntMap.Entry<Entity>> iterator = entities.entries().iterator();
while (iterator.hasNext()) {
IntMap.Entry<Entity> entry = iterator.next();
entry.value.tick(delta);
if (entry.value.isDead) {
iterator.remove();
}
}
enemies.tick(delta, this);
collisionWorld.performDiscreteCollisionDetection();
camHandler.update(delta);
}
}
示例4: write
import com.badlogic.gdx.utils.IntMap; //導入依賴的package包/類
public void write (Kryo kryo, Output output, IntMap map) {
int length = map.size;
output.writeVarInt(length, true);
output.writeBoolean(false); // whether type is written (in case future version of IntMap supports type awareness)
Serializer valueSerializer = null;
if (valueGenericType != null) {
if (valueSerializer == null) valueSerializer = kryo.getSerializer(valueGenericType);
valueGenericType = null;
}
for (Iterator iter = map.iterator(); iter.hasNext();) {
IntMap.Entry entry = (IntMap.Entry)iter.next();
output.writeInt(entry.key);
if (valueSerializer != null) {
kryo.writeObjectOrNull(output, entry.value, valueSerializer);
} else
kryo.writeClassAndObject(output, entry.value);
}
}
示例5: SystemInputHandler
import com.badlogic.gdx.utils.IntMap; //導入依賴的package包/類
public SystemInputHandler(InputProxy inputProxy, InputMultiplexer inputMultiplexer, Array<NhgInput> systemInputArray) {
this.inputProxy = inputProxy;
vec0 = new Vector2();
keyboardButtonInputs = new IntMap<>();
mouseButtonInputs = new IntMap<>();
touchInputs = new IntMap<>();
activeKeyboardButtonInputs = new Array<>();
activeMouseButtonInputs = new Array<>();
activeTouchInputs = new Array<>();
mapSystemInput(systemInputArray);
handleSystemInput(inputMultiplexer);
}
示例6: copyAllItemsTo
import com.badlogic.gdx.utils.IntMap; //導入依賴的package包/類
/**
* Copies all items from this inventory into the destination inventory
*/
public void copyAllItemsTo(Inventory destinationInventory) {
for (BagType bag : BagType.values()) {
IntMap<InventoryItem> sourceBag = getBag(bag);
for (Entry<InventoryItem> slot : sourceBag.entries()) {
InventoryItem item = slot.value;
if (item != null) {
InventoryItem newCopy = item.createNewInstance();
if (item.getStackSize() > 1) {
for (int i = 1; i < item.getStackSize(); ++i) {
newCopy.addToStack(newCopy.createNewInstance());
}
}
destinationInventory.addToBag(bag, newCopy, slot.key);
}
}
}
}
示例7: removeFromBag
import com.badlogic.gdx.utils.IntMap; //導入依賴的package包/類
/**
* Removes the item in the supplied slot from the bag and returns it. If the
* slot was empty, null is returned.
*
* If the item was stackable and removeWholeStack is false, its stack is
* decreased and the item removed from the stack is returned.
*
* @param bagType
* @param slot
* @param removeWholeStack
* - if true, the whole stack is removed at once
* @return
*/
public InventoryItem removeFromBag(BagType bagType, Integer slot,
boolean removeWholeStack) {
IntMap<InventoryItem> bag = bags.get(bagType);
InventoryItem existingItem = bag.get(slot);
if (existingItem == null) {
return null;
}
if (existingItem.isInfinite() || (!removeWholeStack && existingItem.getStackSize() > 1)) {
existingItem = existingItem.removeFromStack();
} else {
bag.remove(slot);
}
existingItem.setInventory(null);
onItemRemove(existingItem, bagType);
return existingItem;
}
示例8: processTouch
import com.badlogic.gdx.utils.IntMap; //導入依賴的package包/類
@Override
public void processTouch(IntMap<Int2> touch) {
int deltaX, deltaY;
for(IntMap.Entry entry:touch.entries()) {
Int2 value = (Int2)entry.value;
Int2 xy = InputHandler.getXY(entry.key);
deltaX = value.x-xy.x;
deltaY = value.y-xy.y;
if(value.x < InputHandler.vWidth/2) {
player.axisInput(-deltaX/100f,deltaY/100f);
} else {
if(player.setRot(deltaX,deltaY)) {
value.x = xy.x;
value.y = xy.y;
player.jumpCount();
}
}
}
}
示例9: disposeShader
import com.badlogic.gdx.utils.IntMap; //導入依賴的package包/類
boolean disposeShader(ShaderProgram shaderProgram){
if (shaderProgram == null)
return false;
for (IntMap.Entry<UniqueShader> entry : blurPassShaderPrograms.entries()){
UniqueShader uniqueShader = entry.value;
if (uniqueShader.shaderProgram == shaderProgram){
uniqueShader.refCount--;
if (uniqueShader.refCount < 1){
shaderProgram.dispose();
blurPassShaderPrograms.remove(entry.key);
return true;
} else {
return false;
}
}
}
//not found!
shaderProgram.dispose();
return true;
}
示例10: gatherControllers
import com.badlogic.gdx.utils.IntMap; //導入依賴的package包/類
private void gatherControllers(boolean sendEvent) {
// gather all joysticks and gamepads, remove any disconnected ones
IntMap<AndroidController> removedControllers = new IntMap<AndroidController>();
removedControllers.putAll(controllerMap);
for(int deviceId: InputDevice.getDeviceIds()) {
InputDevice device = InputDevice.getDevice(deviceId);
AndroidController controller = controllerMap.get(deviceId);
if(controller != null) {
removedControllers.remove(deviceId);
} else {
addController(deviceId, sendEvent);
}
}
for(Entry<AndroidController> entry: removedControllers.entries()) {
removeController(entry.key);
}
}
示例11: getNeighbors
import com.badlogic.gdx.utils.IntMap; //導入依賴的package包/類
private Iterable<Entity> getNeighbors(Entity empire) {
IntMap<Entity> neighbors = new IntMap<>();
// collect entities we have relations with
for (Entity e : relations.get(empire).relations.keySet())
neighbors.put(e.getId(), e);
// collect entities we share influence with
for (MapPosition p : influences.get(empire).influencedTiles)
for (Entry inf : map.getInfluenceAt(p))
if (inf.key != empire.getId() && !neighbors.containsKey(inf.key)
// may be pending insertion into world if just revolted
&& world.getEntityManager().isActive(inf.key))
neighbors.put(inf.key, world.getEntity(inf.key));
return neighbors.values();
}
示例12: setUp
import com.badlogic.gdx.utils.IntMap; //導入依賴的package包/類
@Override
public void setUp() {
if (!allLoaded) {
int npairs = ids.size;
if (lines == null) {
lines = new IPosition[npairs][];
}
IntMap<IPosition> hipMap = sg.getStarMap();
allLoaded = true;
for (int i = 0; i < npairs; i++) {
int[] pair = ids.get(i);
IPosition s1, s2;
s1 = hipMap.get(pair[0]);
s2 = hipMap.get(pair[1]);
if (lines[i] == null && s1 != null && s2 != null) {
lines[i] = new IPosition[] { s1, s2 };
} else {
allLoaded = false;
}
}
}
}
示例13: deserialize
import com.badlogic.gdx.utils.IntMap; //導入依賴的package包/類
@Override
public IntMap<T> deserialize (JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
JsonArray jsonArray = json.getAsJsonArray();
IntMap<T> intMap = new IntMap<>(jsonArray.size());
for (JsonElement element : jsonArray) {
JsonObject object = element.getAsJsonObject();
Entry<String, JsonElement> entry = object.entrySet().iterator().next();
int mapKey = Integer.parseInt(entry.getKey());
Class<?> mapObjectClass = GsonUtils.readClassProperty(object, context);
intMap.put(mapKey, context.deserialize(entry.getValue(), mapObjectClass));
}
return intMap;
}
示例14: filterCollisionSensors
import com.badlogic.gdx.utils.IntMap; //導入依賴的package包/類
private Array<CollisionSensor> filterCollisionSensors(Entity entity) {
Array<CollisionSensor> collisionSensors = new Array<CollisionSensor>();
CollisionSensorComponent collisionSensorComponent = entity.getComponent(CollisionSensorComponent.class);
if (collisionSensorComponent != null) {
IntMap.Values<ObjectSet<CollisionSensor>> values = collisionSensorComponent.sensors.values();
while (values.hasNext()) {
for (CollisionSensor sensor : values.next()) {
if (sensor.targetTag != null) {
collisionSensors.add(sensor);
}
}
}
}
return collisionSensors;
}
示例15: entityAdded
import com.badlogic.gdx.utils.IntMap; //導入依賴的package包/類
@Override
public void entityAdded(Entity entity) {
Log.debug(tag, "EntityAdded add RaySensors");
RigidBodiesComponents rigidBodiesComponent = entity.getComponent(RigidBodiesComponents.class);
RaySensorComponent raySensorComponent = entity.getComponent(RaySensorComponent.class);
if (raySensorComponent != null) {
IntMap.Values<ObjectSet<RaySensor>> values = raySensorComponent.sensors.values();
while (values.hasNext()) {
for (RaySensor sensor : values.next()) {
if (sensor.attachedRigidBody == null)
sensor.attachedRigidBody = rigidBodiesComponent.rigidBodies.first();
}
}
}
}