Search in sources :

Example 21 with Rectangle

use of com.badlogic.gdx.math.Rectangle in project commons-gdx by gemserk.

the class CameraRestrictedImpl method setWorldBounds.

public void setWorldBounds(Rectangle rectangle) {
    this.worldBounds = new Rectangle(rectangle);
    recalculatePosition();
    recalculateZoom();
}
Also used : Rectangle(com.badlogic.gdx.math.Rectangle)

Example 22 with Rectangle

use of com.badlogic.gdx.math.Rectangle in project commons-gdx by gemserk.

the class CameraRestrictedImpl method setWorldBounds.

public void setWorldBounds(float x1, float y1, float x2, float y2) {
    this.worldBounds = new Rectangle(x1, y1, x2 - x1, y2 - y1);
    recalculatePosition();
    recalculateZoom();
}
Also used : Rectangle(com.badlogic.gdx.math.Rectangle)

Example 23 with Rectangle

use of com.badlogic.gdx.math.Rectangle in project commons-gdx by gemserk.

the class ToggleableImageButtonTest method shouldNotToggleIfPointerIsNotPressed.

@Test
public void shouldNotToggleIfPointerIsNotPressed() {
    MockPointer pointer = new MockPointer();
    MockToggleHandler toggleHandler = new MockToggleHandler();
    ToggleableImageButton toggleableImageButton = new ToggleableImageButton() {

        @Override
        protected void recalculateBounds() {
        }
    };
    toggleableImageButton.setPointer(pointer);
    toggleableImageButton.setToggleHandler(toggleHandler);
    toggleableImageButton.setPosition(0f, 0f);
    toggleableImageButton.setBounds(new Rectangle(20, 20, 100, 100));
    pointer.wasReleased = false;
    toggleableImageButton.update();
    assertThat(toggleHandler.toggleCalled, IsEqual.equalTo(false));
}
Also used : Rectangle(com.badlogic.gdx.math.Rectangle) MockPointer(com.gemserk.commons.gdx.input.MockPointer) Test(org.junit.Test)

Example 24 with Rectangle

use of com.badlogic.gdx.math.Rectangle in project commons-gdx by gemserk.

the class CameraRestrictedImplTest method shouldRecalculateZoomIfBoundsChanged3.

@Test
public void shouldRecalculateZoomIfBoundsChanged3() {
    CameraRestrictedImpl camera = new CameraRestrictedImpl(0f, 0f, 40f, 0f, 800f, 480f, new Rectangle(0f, 0f, 20f, 12f));
    assertThat(camera.getZoom(), IsEqual.equalTo(40f));
    camera.setZoom(1f);
    assertThat(camera.getZoom(), IsEqual.equalTo(40f));
}
Also used : Rectangle(com.badlogic.gdx.math.Rectangle) Test(org.junit.Test)

Example 25 with Rectangle

use of com.badlogic.gdx.math.Rectangle in project libgdx by libgdx.

the class SplitPane method layout.

@Override
public void layout() {
    if (!vertical)
        calculateHorizBoundsAndPositions();
    else
        calculateVertBoundsAndPositions();
    Actor firstWidget = this.firstWidget;
    if (firstWidget != null) {
        Rectangle firstWidgetBounds = this.firstWidgetBounds;
        firstWidget.setBounds(firstWidgetBounds.x, firstWidgetBounds.y, firstWidgetBounds.width, firstWidgetBounds.height);
        if (firstWidget instanceof Layout)
            ((Layout) firstWidget).validate();
    }
    Actor secondWidget = this.secondWidget;
    if (secondWidget != null) {
        Rectangle secondWidgetBounds = this.secondWidgetBounds;
        secondWidget.setBounds(secondWidgetBounds.x, secondWidgetBounds.y, secondWidgetBounds.width, secondWidgetBounds.height);
        if (secondWidget instanceof Layout)
            ((Layout) secondWidget).validate();
    }
}
Also used : Layout(com.badlogic.gdx.scenes.scene2d.utils.Layout) Actor(com.badlogic.gdx.scenes.scene2d.Actor) Rectangle(com.badlogic.gdx.math.Rectangle)

Aggregations

Rectangle (com.badlogic.gdx.math.Rectangle)35 Test (org.junit.Test)6 TiledMapTileLayer (com.badlogic.gdx.maps.tiled.TiledMapTileLayer)5 MockPointer (com.gemserk.commons.gdx.input.MockPointer)4 Circle (com.badlogic.gdx.math.Circle)3 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)2 Cell (com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell)2 GdxRuntimeException (com.badlogic.gdx.utils.GdxRuntimeException)2 CoreEntity (com.ilargia.games.entitas.core.CoreEntity)2 View (com.ilargia.games.logicbrick.component.View)2 PlayerSoldier (me.dumfing.multiplayerTools.PlayerSoldier)2 FishColour (ca.hiphiparray.amazingmaze.FishCell.FishColour)1 AssetManager (com.badlogic.gdx.assets.AssetManager)1 FileHandle (com.badlogic.gdx.files.FileHandle)1 Camera (com.badlogic.gdx.graphics.Camera)1 Color (com.badlogic.gdx.graphics.Color)1 Pixmap (com.badlogic.gdx.graphics.Pixmap)1 Batch (com.badlogic.gdx.graphics.g2d.Batch)1 Glyph (com.badlogic.gdx.graphics.g2d.BitmapFont.Glyph)1 TextBounds (com.badlogic.gdx.graphics.g2d.BitmapFont.TextBounds)1