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

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

Introduction

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

Prototype

public Array(boolean ordered, int capacity) 

Source Link

Usage

From source file:ca.hiphiparray.amazingmaze.MazeScreen.java

License:Open Source License

/** Create the bounding boxes for collision detection. */
private void createBoundingBoxes() {
    obstacleBoxes = new Array<Rectangle>(false, 16);
    TiledMapTileLayer objects = (TiledMapTileLayer) map.getLayers().get(MapFactory.OBJECT_LAYER);
    for (int r = 0; r < mapHeight; r++) {
        for (int c = 0; c < mapWidth; c++) {
            Cell cell = objects.getCell(c, r);
            if (cell != null) {
                obstacleBoxes.add(new Rectangle(c, r, 1, 1));
            }/*from   www  . j  a  v  a  2  s  .  co  m*/
        }
    }
    wireBoxes = new Array<Rectangle>(false, 16);
    TiledMapTileLayer wires = (TiledMapTileLayer) map.getLayers().get(MapFactory.WIRE_LAYER);
    for (int r = 0; r < mapHeight; r++) {
        for (int c = 0; c < mapWidth; c++) {
            WireCell wire = (WireCell) wires.getCell(c, r);
            if (wire != null && wire.isOn()) {
                wireBoxes.add(new Rectangle(c + 5f / 16f, r, 6f / 16f, 1));
            }
        }
    }
    fishBoxes = new Array<Rectangle>(false, 16);
    cheeseBoxes = new Array<Rectangle>(false, 16);
    TiledMapTileLayer items = (TiledMapTileLayer) map.getLayers().get(MapFactory.ITEM_LAYER);
    for (int r = 0; r < mapHeight; r++) {
        for (int c = 0; c < mapWidth; c++) {
            Cell item = items.getCell(c, r);
            if (item != null) {
                if (item.getClass() == FishCell.class) {
                    fishBoxes.add(new Rectangle(c, r, 1, 1));
                } else {
                    cheeseBoxes.add(new Rectangle(c, r, 1, 1));
                }
            }
        }
    }
}

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;/*www  .j a v a 2s . c om*/

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

From source file:com.badlogic.ashley.core.systems.SortedIteratingSystem.java

License:Apache License

/**
 * Instantiates a system that will iterate over the entities described by the Family, with a specific priority.
 * @param family The family of entities iterated over in this System
 * @param comparator The comparator to sort the entities
 * @param priority The priority to execute this system with (lower means higher priority)
 *///  w  w  w .j  a  va 2s .com
public SortedIteratingSystem(Family family, Comparator<Entity> comparator, int priority) {
    super(priority);

    this.family = family;
    sortedEntities = new Array<Entity>(false, 16);
    entities = new ImmutableArray<Entity>(sortedEntities);
    this.comparator = comparator;
}

From source file:com.blindtigergames.werescrewed.graphics.particle.ParticleEffect.java

License:Apache License

public ParticleEffect(ParticleEffect effect) {
    updatePositionOnUpdate = effect.updatePositionOnUpdate;
    removeOnComplete = effect.removeOnComplete;
    name = effect.name;/*w  w  w.  j  av  a2  s.  co  m*/
    effectName = effect.effectName;
    emitters = new Array<ParticleEmitter>(true, effect.emitters.size);
    for (int i = 0, n = effect.emitters.size; i < n; i++)
        emitters.add(new ParticleEmitter(effect.emitters.get(i)));

}

From source file:com.esotericsoftware.spine.utils.SkeletonActorPool.java

License:Open Source License

public SkeletonActorPool(SkeletonRenderer renderer, SkeletonData skeletonData, AnimationStateData stateData,
        int initialCapacity, int max) {
    super(initialCapacity, max);

    this.renderer = renderer;
    this.skeletonData = skeletonData;
    this.stateData = stateData;

    obtained = new Array(false, initialCapacity);

    skeletonPool = new Pool<Skeleton>(initialCapacity, max) {
        protected Skeleton newObject() {
            return new Skeleton(SkeletonActorPool.this.skeletonData);
        }/*from  w  w w .  j a v a  2s  .c  o m*/

        protected void reset(Skeleton skeleton) {
            skeleton.setColor(Color.WHITE);
            skeleton.setFlip(false, false);
            skeleton.setSkin((Skin) null);
            skeleton.setSkin(SkeletonActorPool.this.skeletonData.getDefaultSkin());
            skeleton.setToSetupPose();
        }
    };

    statePool = new Pool<AnimationState>(initialCapacity, max) {
        protected AnimationState newObject() {
            return new AnimationState(SkeletonActorPool.this.stateData);
        }

        protected void reset(AnimationState state) {
            state.clearTracks();
            state.clearListeners();
        }
    };
}

From source file:com.github.fauu.helix.graphics.ParticleEffect.java

License:Apache License

public ParticleEffect(ParticleEffect effect) {
    emitters = new Array(true, effect.emitters.size);
    for (int i = 0, n = effect.emitters.size; i < n; i++)
        emitters.add(new ParticleEmitter(effect.emitters.get(i)));
}

From source file:com.mangecailloux.pebble.constant.ConstantEditor.java

License:Apache License

/**
 * ConstantEditor constructor.//from  w w  w . ja  va 2  s.c o m
 * @param _manager _manager {@link ConstantManager} to display. Cannot be null.
 * @param _skin {@link Skin} to use for the UI. 
 * @param _width Initial width of the Stage.
 * @param _height Initial Height of the Stage.
 */
public ConstantEditor(ConstantManager _manager, Skin _skin, boolean _createStage) {
    if (_manager == null)
        throw new InvalidParameterException("ConstantEditor ctor : _manager must not be null");

    manager = _manager;
    // initial directory is the root.
    currentDirectory = manager.getRoot();
    open = false;
    needSave = false;
    debug = false;

    skin = _skin;
    disposeSkin = false;

    // Stage creation
    stage = (_createStage) ? new Stage() : null;

    // Pools creation
    buttonPool = new Array<TextButton>(false, 4);
    constantTablePool = new Array<ConstantTable>(false, 4);

    // get the button style
    TextButtonStyle style = null;
    if (skin.has("constantEditor", TextButtonStyle.class))
        style = skin.get("constantEditor", TextButtonStyle.class);
    else
        style = skin.get(TextButtonStyle.class);

    openButton = new TextButton("Open", style);
    openButton.addListener(buttonClickListener);

    backButton = new TextButton("Back", style);
    backButton.addListener(buttonClickListener);
    backButton.setVisible(false);
    backButton.setTouchable(Touchable.disabled);

    rootButton = new TextButton("Root", style);
    rootButton.addListener(buttonClickListener);
    rootButton.setVisible(false);
    rootButton.setTouchable(Touchable.disabled);

    saveButton = new TextButton("Save", style);
    saveButton.addListener(buttonClickListener);
    saveButton.setVisible(false);
    saveButton.setTouchable(Touchable.disabled);

    mainTable = new Table();

    if (stage != null)
        stage.addActor(mainTable);

    flickTable = new Table();
    flickTable.top();

    NinePatch patch = skin.getPatch("constantEditor-pane");
    if (patch == null)
        patch = skin.getPatch("default-pane-noborder");

    flickTable.setBackground(new NinePatchDrawable(patch));

    flickScrollpane = new ScrollPane(flickTable);
    flickScrollpane.setupOverscroll(5, 10, 15);
    flickScrollpane.setScrollingDisabled(true, false);
    flickScrollpane.setFlingTime(0.25f);

    optionsTable = new Table();

    refreshOptionTable();

    mainTable.pad(mainTablePadding);
    mainTable.add(optionsTable).expand().fill();
}

From source file:com.mangecailloux.pebble.directory.Directory.java

License:Apache License

/**
 * Create the DirectoryElement Array if we don't have one already
 *//* w w w  .j ava2s .  com*/
private void createElementArray() {
    if (elements == null)
        elements = new Array<E>(false, 4);
}

From source file:com.mangecailloux.pebble.directory.Directory.java

License:Apache License

/**
 *  Create the Directory Array if we don't have one already
 *//*from  w  w  w .j  a v a 2s .c  o m*/
private void createChildrenArray() {
    if (children == null)
        children = new Array<Directory<E>>(false, 4);
}

From source file:com.mangecailloux.pebble.entity.ComponentSet.java

License:Apache License

protected ComponentSet(Entity _entity) {
    entity = _entity;//from  w w  w .j  a  v a2 s .  c om
    components = new Array<Component>(false, 2);
    componentsByType = new ObjectMap<Class<? extends Component>, Component>(8);
}