当前位置: 首页>>代码示例>>Java>>正文


Java TextureAtlas.findRegions方法代码示例

本文整理汇总了Java中com.badlogic.gdx.graphics.g2d.TextureAtlas.findRegions方法的典型用法代码示例。如果您正苦于以下问题:Java TextureAtlas.findRegions方法的具体用法?Java TextureAtlas.findRegions怎么用?Java TextureAtlas.findRegions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.badlogic.gdx.graphics.g2d.TextureAtlas的用法示例。


在下文中一共展示了TextureAtlas.findRegions方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onInit

import com.badlogic.gdx.graphics.g2d.TextureAtlas; //导入方法依赖的package包/类
/**
 * Inititalisiert den NPC.
 * Lädt alle Grafiken und Animationen.
 */
@Override
public void onInit()
{
    super.onInit();

    npcAtlas = new TextureAtlas(Gdx.files.internal("data/graphics/packed/" + baseName + ".atlas"));
    npcFront = npcAtlas.findRegion(baseName + "_front");
    npcSide = npcAtlas.findRegion(baseName + "_side");
    npcBack = npcAtlas.findRegion(baseName + "_back");

    npcFrontWalk = new Animation<TextureRegion>(1/5f, npcAtlas.findRegions(baseName + "_front_walk"), Animation.PlayMode.LOOP);
    npcSideWalk = new Animation<TextureRegion>(1/5f, npcAtlas.findRegions(baseName + "_side_walk"), Animation.PlayMode.LOOP);
    npcBackWalk = new Animation<TextureRegion>(1/5f, npcAtlas.findRegions(baseName + "_back_walk"), Animation.PlayMode.LOOP);
}
 
开发者ID:Entwicklerpages,项目名称:school-game,代码行数:19,代码来源:BaseNPC.java

示例2: getTextureAtlasRegions

import com.badlogic.gdx.graphics.g2d.TextureAtlas; //导入方法依赖的package包/类
private Array<AtlasRegion> getTextureAtlasRegions(String atlasName, String regionId) {
    TextureAtlas textureAtlas = getTextureAtlas(atlasName);
    Array<AtlasRegion> atlasRegions = textureAtlas.findRegions(regionId);
    for (AtlasRegion atlasRegion : atlasRegions) {
        atlasRegion.flip(false, true);
    }

    return atlasRegions;
}
 
开发者ID:alexschimpf,项目名称:joe,代码行数:10,代码来源:AssetManager.java

示例3: onInit

import com.badlogic.gdx.graphics.g2d.TextureAtlas; //导入方法依赖的package包/类
/**
 * Initialisierung
 */
@Override
public void onInit()
{
    super.onInit();

    npcAtlas = new TextureAtlas(Gdx.files.internal("data/graphics/packed/dragon.atlas"));

    npcFrontWalk = new Animation<TextureRegion>(1/5f, npcAtlas.findRegions("dragon_front"), Animation.PlayMode.LOOP);
    npcSideWalk = new Animation<TextureRegion>(1/5f, npcAtlas.findRegions("dragon_side"), Animation.PlayMode.LOOP);
    npcBackWalk = new Animation<TextureRegion>(1/5f, npcAtlas.findRegions("dragon_back"), Animation.PlayMode.LOOP);

    float[] vertices;

    if (rawObject instanceof PolygonMapObject)
    {
        PolygonMapObject polygon = (PolygonMapObject) rawObject;
        loop = true;

        vertices = polygon.getPolygon().getTransformedVertices();
    }
    else
    {
        Gdx.app.log("WARNING", objectId + ": MapObject must be a Polygon.");

        worldObjectManager.removeObject(this);

        return;
    }

    waypoints = new Vector2[vertices.length / 2];

    for (int i = 0; i < vertices.length / 2; i++)
    {
        waypoints[i] = new Vector2();
        waypoints[i].x = vertices[i * 2];
        waypoints[i].y = vertices[i * 2 + 1];
    }

    if (waypoints.length < 2)
    {
        Gdx.app.log("WARNING", objectId + ": Must have at least 2 Waypoints.");

        worldObjectManager.removeObject(this);

        return;
    }

    body = createCircleBody(waypoints[0].cpy(), 10);
    targetIndex = 1;


    handler = new AttackHandler(worldObjectManager);
    handler.setAttackedCallback(new AttackHandler.AttackedCallback()
    {
        @Override
        public boolean run(Player player, int damage)
        {
            health -= damage;

            if (health <= 0)
            {
                if (deathCallback != null)
                    deathCallback.run();

                worldObjectManager.removeObject(Dragon.this);
            } else {
                hitTimer += 0.6f;
            }

            return true;
        }
    });

    handler.createAttackFixture(body, Physics.createRectangle(64, 64, new Vector2(0, 0)));
}
 
开发者ID:Entwicklerpages,项目名称:school-game,代码行数:79,代码来源:Dragon.java

示例4: onInit

import com.badlogic.gdx.graphics.g2d.TextureAtlas; //导入方法依赖的package包/类
/**
 * Initialisierung
 */
@Override
public void onInit()
{
    super.onInit();

    direction = new Vector2(MathUtils.random(-1f, 1f), MathUtils.random(-1f, 1f)).scl(4f);

    crabAtlas = new TextureAtlas(Gdx.files.internal("data/graphics/packed/krab.atlas"));
    crabAnimation = new Animation<TextureRegion>(1/7f, crabAtlas.findRegions("krab"), Animation.PlayMode.LOOP);

    if (rawObject instanceof EllipseMapObject)
    {
        EllipseMapObject ellipseObject = (EllipseMapObject) rawObject;
        Ellipse ellipse = ellipseObject.getEllipse();

        Vector2 startPos = new Vector2(ellipse.x + ellipse.width / 2f, ellipse.y + ellipse.height / 2f);

        body = createCircleBody(startPos, 10);

        handler = new AttackHandler(worldObjectManager);
        handler.setAttackedCallback(new AttackHandler.AttackedCallback()
        {
            @Override
            public boolean run(Player player, int damage)
            {
                health -= damage;

                if (health <= 0)
                {
                    if (deathCallback != null)
                        deathCallback.run();

                    worldObjectManager.removeObject(Crab.this);
                } else {
                    hitTimer += 0.6f;
                }

                return true;
            }
        });

        handler.createAttackFixture(body, Physics.createRectangle(64, 64, new Vector2(0, 0)));

    } else {
        Gdx.app.log("WARNING", "Crab " + objectId + " must have an EllipseMapObject!");
        worldObjectManager.removeObject(this);
    }
}
 
开发者ID:Entwicklerpages,项目名称:school-game,代码行数:52,代码来源:Crab.java

示例5: onInit

import com.badlogic.gdx.graphics.g2d.TextureAtlas; //导入方法依赖的package包/类
/**
 * Initialisierung
 */
@Override
public void onInit()
{
    super.onInit();

    npcAtlas = new TextureAtlas(Gdx.files.internal("data/graphics/packed/mutated_warrior.atlas"));

    npcFrontWalk = new Animation<TextureRegion>(1/5f, npcAtlas.findRegions("warrior_front"), Animation.PlayMode.LOOP);
    npcSideWalk = new Animation<TextureRegion>(1/5f, npcAtlas.findRegions("warrior_side"), Animation.PlayMode.LOOP);
    npcBackWalk = new Animation<TextureRegion>(1/5f, npcAtlas.findRegions("warrior_back"), Animation.PlayMode.LOOP);

    float[] vertices;

    if (rawObject instanceof PolygonMapObject)
    {
        PolygonMapObject polygon = (PolygonMapObject) rawObject;
        loop = true;

        vertices = polygon.getPolygon().getTransformedVertices();
    }
    else
    {
        Gdx.app.log("WARNING", objectId + ": MapObject must be a Polygon.");

        worldObjectManager.removeObject(this);

        return;
    }

    waypoints = new Vector2[vertices.length / 2];

    for (int i = 0; i < vertices.length / 2; i++)
    {
        waypoints[i] = new Vector2();
        waypoints[i].x = vertices[i * 2];
        waypoints[i].y = vertices[i * 2 + 1];
    }

    if (waypoints.length < 2)
    {
        Gdx.app.log("WARNING", objectId + ": Must have at least 2 Waypoints.");

        worldObjectManager.removeObject(this);

        return;
    }

    body = createCircleBody(waypoints[0].cpy(), 10);
    targetIndex = 1;


    handler = new AttackHandler(worldObjectManager);
    handler.setAttackedCallback(new AttackHandler.AttackedCallback()
    {
        @Override
        public boolean run(Player player, int damage)
        {
            health -= damage;

            if (health <= 0)
            {
                if (deathCallback != null)
                    deathCallback.run();

                worldObjectManager.removeObject(Warrior.this);
            } else {
                hitTimer += 0.6f;
            }

            return true;
        }
    });

    handler.createAttackFixture(body, Physics.createRectangle(64, 64, new Vector2(0, 0)));
}
 
开发者ID:Entwicklerpages,项目名称:school-game,代码行数:79,代码来源:Warrior.java

示例6: onInit

import com.badlogic.gdx.graphics.g2d.TextureAtlas; //导入方法依赖的package包/类
/**
 * Initialisierung
 */
@Override
public void onInit()
{
    super.onInit();

    npcAtlas = new TextureAtlas(Gdx.files.internal("data/graphics/packed/skeleton.atlas"));

    npcFrontWalk = new Animation<TextureRegion>(1/7f, npcAtlas.findRegions("skeleton_front"), Animation.PlayMode.LOOP);
    npcSideWalk = new Animation<TextureRegion>(1/8f, npcAtlas.findRegions("skeleton_side"), Animation.PlayMode.LOOP);
    npcBackWalk = new Animation<TextureRegion>(1/7f, npcAtlas.findRegions("skeleton_back"), Animation.PlayMode.LOOP);

    float[] vertices;

    if (rawObject instanceof PolygonMapObject)
    {
        PolygonMapObject polygon = (PolygonMapObject) rawObject;
        loop = true;

        vertices = polygon.getPolygon().getTransformedVertices();
    }
    else
    {
        Gdx.app.log("WARNING", objectId + ": MapObject must be Polygon.");

        worldObjectManager.removeObject(this);

        return;
    }

    waypoints = new Vector2[vertices.length / 2];

    for (int i = 0; i < vertices.length / 2; i++)
    {
        waypoints[i] = new Vector2();
        waypoints[i].x = vertices[i * 2];
        waypoints[i].y = vertices[i * 2 + 1];
    }

    if (waypoints.length < 2)
    {
        Gdx.app.log("WARNING", objectId + ": Must have at least 2 Waypoints.");

        worldObjectManager.removeObject(this);

        return;
    }

    body = createCircleBody(waypoints[0].cpy(), 10);
    targetIndex = 1;


    handler = new AttackHandler(worldObjectManager);
    handler.setAttackedCallback(new AttackHandler.AttackedCallback()
    {
        @Override
        public boolean run(Player player, int damage)
        {
            health -= damage;

            if (health <= 0)
            {
                if (deathCallback != null)
                    deathCallback.run();

                worldObjectManager.removeObject(Skeleton.this);
            } else {
                hitTimer += 0.6f;
            }

            return true;
        }
    });

    handler.createAttackFixture(body, Physics.createRectangle(64, 64, new Vector2(0, 0)));
}
 
开发者ID:Entwicklerpages,项目名称:school-game,代码行数:79,代码来源:Skeleton.java

示例7: onInit

import com.badlogic.gdx.graphics.g2d.TextureAtlas; //导入方法依赖的package包/类
/**
 * Initialisierung
 */
@Override
public void onInit()
{
    super.onInit();

    npcAtlas = new TextureAtlas(Gdx.files.internal("data/graphics/packed/wolf.atlas"));

    npcFrontWalk = new Animation<TextureRegion>(1/5f, npcAtlas.findRegions("wolf_front"), Animation.PlayMode.LOOP);
    npcSideWalk = new Animation<TextureRegion>(1/5f, npcAtlas.findRegions("wolf_side"), Animation.PlayMode.LOOP);
    npcBackWalk = new Animation<TextureRegion>(1/5f, npcAtlas.findRegions("wolf_back"), Animation.PlayMode.LOOP);

    float[] vertices;

    if (rawObject instanceof PolygonMapObject)
    {
        PolygonMapObject polygon = (PolygonMapObject) rawObject;
        loop = true;

        vertices = polygon.getPolygon().getTransformedVertices();
    }
    else
    {
        Gdx.app.log("WARNING", objectId + ": MapObject must be Polygon.");

        worldObjectManager.removeObject(this);

        return;
    }

    waypoints = new Vector2[vertices.length / 2];

    for (int i = 0; i < vertices.length / 2; i++)
    {
        waypoints[i] = new Vector2();
        waypoints[i].x = vertices[i * 2];
        waypoints[i].y = vertices[i * 2 + 1];
    }

    if (waypoints.length < 2)
    {
        Gdx.app.log("WARNING", objectId + ": Must have at least 2 Waypoints.");

        worldObjectManager.removeObject(this);

        return;
    }

    body = createCircleBody(waypoints[0].cpy(), 10);
    targetIndex = 1;


    handler = new AttackHandler(worldObjectManager);
    handler.setAttackedCallback(new AttackHandler.AttackedCallback()
    {
        @Override
        public boolean run(Player player, int damage)
        {
            health -= damage;

            if (health <= 0)
            {
                if (deathCallback != null)
                    deathCallback.run();

                worldObjectManager.removeObject(Wolf.this);
            } else {
                hitTimer += 0.6f;
            }

            return true;
        }
    });

    handler.createAttackFixture(body, Physics.createRectangle(64, 64, new Vector2(0, 0)));
}
 
开发者ID:Entwicklerpages,项目名称:school-game,代码行数:79,代码来源:Wolf.java

示例8: Player

import com.badlogic.gdx.graphics.g2d.TextureAtlas; //导入方法依赖的package包/类
/**
 * Initialisierung.
 *
 * @param world Zugriff auf die Box2D Welt
 * @param name der Name des Spielers
 * @param male ist der Spieler männlich oder weiblich?
 */
public Player(SchoolGame game, World world, String name, boolean male) {
    this.health = 100;
    this.name = name;
    this.male = male;
    this.orientation = EntityOrientation.LOOK_FORWARD;

    this.cheatManager = CheatManager.getInstance();

    String player = "player_" + (this.male ? "m" : "f");

    playerAtlas = new TextureAtlas(Gdx.files.internal("data/graphics/packed/" + player + ".atlas"));
    playerFront = playerAtlas.findRegion(player + "_front");
    playerSide = playerAtlas.findRegion(player + "_side");
    playerBack = playerAtlas.findRegion(player + "_back");

    playerFrontWalk = new Animation<TextureRegion>(1/7f, playerAtlas.findRegions(player + "_front_walk"), Animation.PlayMode.LOOP);
    playerSideWalk = new Animation<TextureRegion>(1/7f, playerAtlas.findRegions(player + "_side_walk"), Animation.PlayMode.LOOP);
    playerBackWalk = new Animation<TextureRegion>(1/7f, playerAtlas.findRegions(player + "_back_walk"), Animation.PlayMode.LOOP);

    playerAttack = playerAtlas.findRegions(player + "_sword");

    /*audioManager = game.getAudioManager();
    leftStep = audioManager.createSound("walk", "grass_left.wav", true);
    rightStep = audioManager.createSound("walk", "grass_right.wav", true);*/

    BodyDef bodyDef = new BodyDef();
    bodyDef.type = BodyDef.BodyType.DynamicBody;
    bodyDef.fixedRotation = true;

    playerBody = world.createBody(bodyDef);
    playerBody.setUserData(this);

    PolygonShape playerBox = Physics.createRectangle(32f, 20f, new Vector2(0f, 5f));

    FixtureDef fixtureDef = new FixtureDef();
    fixtureDef.shape = playerBox;
    fixtureDef.density = 0.5f;
    fixtureDef.friction = 0.4f;
    fixtureDef.filter.categoryBits = Physics.CATEGORY_PLAYER;
    fixtureDef.filter.maskBits = Physics.MASK_PLAYER;

    playerBody.createFixture(fixtureDef).setUserData(this);
    playerBox.dispose();


    interfaceBatch = new SpriteBatch();
    interfaceRenderer = new ShapeRenderer();
    interfaceFont = game.getLongTextFont();
    fontLayout = new GlyphLayout();
    interfaceProjection = new Matrix4();
}
 
开发者ID:Entwicklerpages,项目名称:school-game,代码行数:59,代码来源:Player.java


注:本文中的com.badlogic.gdx.graphics.g2d.TextureAtlas.findRegions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。