Example usage for com.badlogic.gdx.utils Bits Bits

List of usage examples for com.badlogic.gdx.utils Bits Bits

Introduction

In this page you can find the example usage for com.badlogic.gdx.utils Bits Bits.

Prototype

public Bits() 

Source Link

Usage

From source file:com.badlogic.ashley.core.ComponentType.java

License:Apache License

/**
 * @param componentTypes list of {@link Component} classes
 * @return Bits representing the collection of components for quick comparison and matching. See
 *         {@link Family#getFor(Bits, Bits, Bits)}.
 *//*from  w w w.  jav a  2s . c  o m*/
public static Bits getBitsFor(Class<? extends Component>... componentTypes) {
    Bits bits = new Bits();

    int typesLength = componentTypes.length;
    for (int i = 0; i < typesLength; i++) {
        bits.set(ComponentType.getIndexFor(componentTypes[i]));
    }

    return bits;
}

From source file:com.badlogic.ashley.core.Entity.java

License:Apache License

/** Creates an empty Entity. */
public Entity() {
    components = new Bag<Component>();
    componentsArray = new Array<Component>(false, 16);
    immutableComponentsArray = new ImmutableArray<Component>(componentsArray);
    componentBits = new Bits();
    familyBits = new Bits();
    flags = 0;/*  w  w w  .  j av  a  2s  .c o m*/

    componentAdded = new Signal<Entity>();
    componentRemoved = new Signal<Entity>();
}

From source file:de.quadspot.beatnbrawl.systems.CollisionSystem.java

@Override
public void addedToEngine(Engine engine) {
    enemyEntities = engine/*from  www .ja  v  a 2 s  .  c  om*/
            .getEntitiesFor(Family.getFor(
                    ComponentType.getBitsFor(PositionComponent.class, CollisionComponent.class,
                            StateComponent.class, ActionComponent.class, AIComponent.class),
                    new Bits(), new Bits()));
    playerEntities = engine
            .getEntitiesFor(Family.getFor(
                    ComponentType.getBitsFor(PositionComponent.class, CollisionComponent.class,
                            StateComponent.class, ActionComponent.class, InputComponent.class),
                    new Bits(), new Bits()));
    allEntities = engine.getEntitiesFor(Family.getFor(ComponentType.getBitsFor(PositionComponent.class,
            CollisionComponent.class, StateComponent.class, ActionComponent.class), new Bits(), new Bits()));
    mapEntity = engine
            .getEntitiesFor(Family.getFor(ComponentType.getBitsFor(MapComponent.class), new Bits(), new Bits()))
            .first();

    pcm = ComponentMapper.getFor(PositionComponent.class);
    acm = ComponentMapper.getFor(AnimationComponent.class);
    ccm = ComponentMapper.getFor(CollisionComponent.class);
    mapcm = ComponentMapper.getFor(MapComponent.class);
    actcm = ComponentMapper.getFor(ActionComponent.class);
    scm = ComponentMapper.getFor(StateComponent.class);
    hcm = ComponentMapper.getFor(HealthComponent.class);

    for (int i = 0; i < allEntities.size(); ++i) {
        Entity entity = allEntities.get(i);

        ccm.get(entity).getCollidingBody()
                .set(pcm.get(entity).getPosition().cpy()
                        .add(acm.get(entity).getWidth(0) * mapcm.get(mapEntity).getMapFactor() / 2, 0, 0),
                        acm.get(entity).getWidth(0) * mapcm.get(mapEntity).getMapFactor(),
                        acm.get(entity).getHeight(0) * mapcm.get(mapEntity).getMapFactor());
        ccm.get(entity).setGround(mapcm.get(mapEntity).getGroundBody());
        //System.out.println("Aktuelle Pos:"+pcm.get(entity).getPosition()+"     x:"+ccm.get(entity).getCollidingBody().getBoundingBox().x + "   y:" +ccm.get(entity).getCollidingBody().getBoundingBox().y);
    }
}