Search in sources :

Example 41 with TextureRegion

use of com.badlogic.gdx.graphics.g2d.TextureRegion in project libgdx by libgdx.

the class NinePatchTest method newULQuadPatch.

// Make a upper-left "quad" patch (only 4 patches defined in the top-left corner of the ninepatch)
static NinePatch newULQuadPatch() {
    final int patchSize = 8;
    final int pixmapSize = patchSize * 2;
    TextureRegion tr = newPatchPix(patchSize, pixmapSize);
    return new NinePatch(tr, patchSize, 0, patchSize, 0);
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) NinePatch(com.badlogic.gdx.graphics.g2d.NinePatch)

Example 42 with TextureRegion

use of com.badlogic.gdx.graphics.g2d.TextureRegion in project commons-gdx by gemserk.

the class SpriteUtilsTest method shouldReturnIsAliasWhenRegionEquals.

@Test
public void shouldReturnIsAliasWhenRegionEquals() {
    TextureRegion region1 = new TextureRegion(texture512x512, 50, 30, 40f, 40f);
    TextureRegion region2 = new TextureRegion(texture512x512, 50, 30, 40f, 40f);
    Sprite sprite1 = new Sprite(region1);
    Sprite sprite2 = new Sprite(region2);
    assertTrue(SpriteUtils.isAliasSprite(sprite1, sprite2));
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) AtlasSprite(com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasSprite) Sprite(com.badlogic.gdx.graphics.g2d.Sprite) Test(org.junit.Test)

Example 43 with TextureRegion

use of com.badlogic.gdx.graphics.g2d.TextureRegion in project commons-gdx by gemserk.

the class SpriteUtilsTest method shouldReturnFalseIfSpriteNull.

@Test
public void shouldReturnFalseIfSpriteNull() {
    TextureRegion region1 = new TextureRegion(texture512x512, 50, 30, 40f, 40f);
    Sprite sprite1 = new Sprite(region1);
    assertFalse(SpriteUtils.isAliasSprite(sprite1, null));
    assertFalse(SpriteUtils.isAliasSprite(null, sprite1));
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) AtlasSprite(com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasSprite) Sprite(com.badlogic.gdx.graphics.g2d.Sprite) Test(org.junit.Test)

Example 44 with TextureRegion

use of com.badlogic.gdx.graphics.g2d.TextureRegion in project commons-gdx by gemserk.

the class TextureRegionUtilsTest method testRegionEquals.

@Test
public void testRegionEquals() {
    TextureRegion region1 = new TextureRegion(texture512x512, 50, 30, 40f, 40f);
    TextureRegion region2 = new TextureRegion(texture512x512, 50, 30, 40f, 40f);
    TextureRegion region3 = new TextureRegion(texture512x512, 60, 30, 40f, 40f);
    TextureRegion region4 = new TextureRegion(texture512x512, 50, 40, 40f, 40f);
    TextureRegion region5 = new TextureRegion(texture512x512, 50, 30, 50f, 40f);
    TextureRegion region6 = new TextureRegion(texture512x512, 50, 30, 40f, 20f);
    assertTrue(TextureRegionUtils.textureRegionEquals(region1, region1));
    assertTrue(TextureRegionUtils.textureRegionEquals(region1, region2));
    assertFalse(TextureRegionUtils.textureRegionEquals(region1, region3));
    assertFalse(TextureRegionUtils.textureRegionEquals(region1, region4));
    assertFalse(TextureRegionUtils.textureRegionEquals(region1, region5));
    assertFalse(TextureRegionUtils.textureRegionEquals(region1, region6));
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) Test(org.junit.Test)

Example 45 with TextureRegion

use of com.badlogic.gdx.graphics.g2d.TextureRegion in project Entitas-Java by Rubentxu.

the class AnimationSystem method execute.

@Override
public void execute(float deltaTime) {
    for (GameEntity e : _groupAnimation.getEntities()) {
        Animations animations = e.getAnimations();
        TextureView view = e.getTextureView();
        animations.time += deltaTime;
        Animation<TextureRegion> animation = animations.currentAnimation;
        if (animation != null) {
            view.texture = animation.getKeyFrame(animations.time);
        }
    }
}
Also used : GameEntity(ilargia.egdx.logicbricks.gen.game.GameEntity) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) Animations(ilargia.egdx.logicbricks.component.game.Animations) TextureView(ilargia.egdx.logicbricks.component.game.TextureView)

Aggregations

TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)115 Texture (com.badlogic.gdx.graphics.Texture)57 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)22 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)18 Stage (com.badlogic.gdx.scenes.scene2d.Stage)18 Sprite (com.badlogic.gdx.graphics.g2d.Sprite)13 GdxRuntimeException (com.badlogic.gdx.utils.GdxRuntimeException)13 OrthographicCamera (com.badlogic.gdx.graphics.OrthographicCamera)11 NinePatch (com.badlogic.gdx.graphics.g2d.NinePatch)11 AtlasSprite (com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasSprite)11 AtlasRegion (com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion)10 Image (com.badlogic.gdx.scenes.scene2d.ui.Image)10 Skin (com.badlogic.gdx.scenes.scene2d.ui.Skin)10 Pixmap (com.badlogic.gdx.graphics.Pixmap)8 Color (com.badlogic.gdx.graphics.Color)7 ShapeRenderer (com.badlogic.gdx.graphics.glutils.ShapeRenderer)7 TextureRegionDrawable (com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable)7 Test (org.junit.Test)7 FileHandle (com.badlogic.gdx.files.FileHandle)6 TextureAtlas (com.badlogic.gdx.graphics.g2d.TextureAtlas)6