本文整理汇总了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);
}
示例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;
}
示例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)));
}
示例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);
}
}
示例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)));
}
示例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)));
}
示例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)));
}
示例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();
}