Example usage for com.badlogic.gdx.math Rectangle getSize

List of usage examples for com.badlogic.gdx.math Rectangle getSize

Introduction

In this page you can find the example usage for com.badlogic.gdx.math Rectangle getSize.

Prototype

public Vector2 getSize(Vector2 size) 

Source Link

Usage

From source file:com.redtoorange.game.gameobject.GameMap.java

License:Open Source License

/**
 * Strip the rectangle objects from the TMX file and resize them to the correct scale for the game world.
 *
 * @param source      The collection of source rectangles from the TMX file.
 * @param destination The collection to place the resized rectangles.
 *///from www.  ja v  a 2  s .  com
private void pullAndAddRectangles(Array<RectangleMapObject> source, Array<Rectangle> destination) {
    for (RectangleMapObject r : source) {
        Rectangle rectangle = r.getRectangle();

        Vector2 size = new Vector2();
        Vector2 center = new Vector2();

        rectangle.getSize(size);
        rectangle.getCenter(center);

        size.scl(mapScale);
        center.scl(mapScale);

        rectangle.setSize(size.x, size.y);
        rectangle.setCenter(center.x, center.y);

        destination.add(rectangle);
    }
}