本文整理汇总了Java中com.badlogic.gdx.graphics.g2d.TextureRegion类的典型用法代码示例。如果您正苦于以下问题:Java TextureRegion类的具体用法?Java TextureRegion怎么用?Java TextureRegion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TextureRegion类属于com.badlogic.gdx.graphics.g2d包,在下文中一共展示了TextureRegion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: pauseGame
import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入依赖的package包/类
private void pauseGame() {
if (paused)
return;
paused = true;
final Window.WindowStyle pauseWindowStyle = new Window.WindowStyle();
pauseWindowStyle.titleFont = game.getFonts().get("moonhouse64");
pauseWindowStyle.background = new TextureRegionDrawable(new TextureRegion(background));
pauseWindow = new PauseWindow(pauseWindowStyle, game.getFonts().get("moonhouse64"), new Runnable() {
@Override
public void run() {
unpauseGame();
}
}, new Runnable() {
@Override
public void run() {
save();
}
}, game, uiAssets, button);
pauseWindow.setBounds(viewport.getWorldWidth() / 2 - viewport.getWorldWidth() / 3, viewport.getWorldHeight() / 2 - viewport.getWorldHeight() / 3, viewport.getWorldWidth() / 3 * 2, viewport.getWorldHeight() / 3 * 2);
stage.addActor(pauseWindow);
}
示例2: addChangeFaction
import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入依赖的package包/类
private void addChangeFaction(){
groupChangeFaction = new Group();
Image background = new Image(new TextureRegion(manager.getAssetsSettings().getTexture(NameFiles.extensionImgBackground)));
background.setSize(Width - Width * 0.03f, Height * 0.1f);
background.setPosition(Width / 2 - background.getWidth() / 2, Height * 0.3f);
groupChangeFaction.addActor(background);
Label labelFac = new Label("Change Faction",new Label.LabelStyle(Font.getFont((int)(Height*0.025f)),Color.WHITE));
labelFac.setPosition(background.getX()+background.getWidth()*0.05f,background.getY()+background.getHeight()/2-labelFac.getHeight()/2);
labelFac.addListener(new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y) {
manager.loadAssetsChoiceFaction();
gameManager.setScreen(new ScreenCircleLoading(gameManager,new ScreenChoiceFaction(gameManager),manager.getAssetsChoiceFaction()));
}
});
groupChangeFaction.addActor(labelFac);
}
示例3: createHighlightingGraphic
import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入依赖的package包/类
private Texture createHighlightingGraphic(TextureRegion textureRegion)
{
TextureData textureData = textureRegion.getTexture().getTextureData();
textureData.prepare();
Pixmap sourcePixmap = textureData.consumePixmap();
Pixmap destinationPixmap = new Pixmap(textureRegion.getRegionWidth(), textureRegion.getRegionHeight(), Format.RGBA8888);
Color color = new Color();
for (int x = 0; x < textureRegion.getRegionWidth(); x++)
{
for (int y = 0; y < textureRegion.getRegionHeight(); y++)
{
int colorInt = sourcePixmap.getPixel(textureRegion.getRegionX() + x, textureRegion.getRegionY() + y);
Color.rgba8888ToColor(color, colorInt);
destinationPixmap.setColor(1.0f, 1f, 1.0f, 1);
if (color.a > 0.004f)
destinationPixmap.drawPixel(x, y);
}
}
Texture result = new Texture(destinationPixmap);
textureData.disposePixmap();
destinationPixmap.dispose();
return result;
}
示例4: TileTouchCheck
import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入依赖的package包/类
private TileTouchCheck(Pixmap pixelMap, TextureRegion region) {
this.width = region.getRegionWidth();
this.height = region.getRegionHeight();
map = new int[width * height];
int i = -1;
// pixmap coordinates have the origin in the top left corner; shift it so it goes from the bottom left instead
for (int x = 0; x < width; x++) {
for (int y = height-1; y >= 0; y--) {
Color color = new Color(pixelMap.getPixel(region.getRegionX() + x, region.getRegionY() + y));
i++;
if(color.a == 0) continue; // set to zero, tile doesn't matter
if(color.equals(Color.WHITE)) // the tile must be different from the center tile
map[i] = WHITE;
else if(color.equals(Color.BLACK)) // the tile must be equal to the center tile
map[i] = BLACK;
}
}
}
示例5: build
import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入依赖的package包/类
@Override
public void build() {
Core.scene.table().addRect((a, b, w, h) -> {
Draw.color();
TextureRegion back = Draw.region("background");
float backscl = Unit.dp.scl(5f);
Draw.alpha(0.7f);
Core.batch.draw(back, w/2 - back.getRegionWidth()*backscl/2 +240f, h/2 - back.getRegionHeight()*backscl/2 + 250f,
back.getRegionWidth()*backscl, back.getRegionHeight()*backscl);
float logoscl = (int)Unit.dp.scl(7);
TextureRegion logo = Core.skin.getRegion("logotext");
float logow = logo.getRegionWidth()*logoscl;
float logoh = logo.getRegionHeight()*logoscl;
Draw.color();
Core.batch.draw(logo, w/2 - logow/2, h - logoh + 15, logow, logoh);
}).visible(() -> GameState.is(State.menu)).grow();
}
示例6: y
import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入依赖的package包/类
private static TextureRegion y(Area area, int x_y, int y_y, int z_y) {
int i = 0;
if (exists(area, x_y + 1, y_y, z_y - 1))
i |= A;
if (exists(area, x_y + 1, y_y, z_y))
i |= B;
if (exists(area, x_y + 1, y_y, z_y + 1))
i |= C;
if (exists(area, x_y, y_y, z_y - 1))
i |= D;
if (exists(area, x_y, y_y, z_y + 1))
i |= E;
y_1(area, x_y, y_y, z_y, i);
return loadedRegions[i];
}
示例7: VRCamera
import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入依赖的package包/类
public VRCamera(int width, int height, int viewportWidth, int viewportHeight) {
leftCamera = new PerspectiveCamera(90, viewportWidth, viewportHeight);
rightCamera = new PerspectiveCamera(90, viewportWidth, viewportHeight);
leftBuffer = new FrameBuffer(Pixmap.Format.RGBA8888, width, height, true);
rightBuffer = new FrameBuffer(Pixmap.Format.RGBA8888, width, height, true);
leftTexture = new TextureRegion();
rightTexture = new TextureRegion();
batch = new SpriteBatch();
this.width = width;
this.height = height;
this.viewportWidth = viewportWidth;
this.viewportHeight = viewportHeight;
tmpVector3 = new Vector3();
position = new Vector3(250, 20, 250);
positionLeft = new Vector3(249.5f, 20, 250);
positionRight = new Vector3(250.5f, 20, 250);
direction = new Vector3();
up = new Vector3(0, 1, 0);
eyeDistance = 0.5f;
}
示例8: setTextureRegion
import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入依赖的package包/类
public void setTextureRegion(TextureRegion textureRegion, boolean setNewDimension) {
TextureRegion oldTextureRegion = this.textureRegion;
this.textureRegion = textureRegion;
if (oldTextureRegion == this.textureRegion) {
// we dont need to notify listeners
return;
}
if (setNewDimension) {
// set new width and height
this.positionComponent.setDimension(textureRegion.getRegionWidth(), textureRegion.getRegionHeight());
}
this.textureRegionChangedListenerList.stream().forEach(listener -> {
// check if dev mode is enabled
/*
* if (DevMode.isEnabled()) { //log listener
* System.out.println("DrawTextureRegionComponent call listener: " +
* listener.getClass().getName()); }
*/
listener.onTextureRegionChanged(oldTextureRegion, this.textureRegion);
});
}
示例9: draw
import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入依赖的package包/类
public void draw(Coordinates<Integer> coords, Pixmap map) {
int terrainID = world.get(coords.y).get(coords.x);
// tileID runs 0 through 8, conveniently in the
// same order as our split tiles texture...
int ty = (int) terrainID / 3;
int tx = terrainID % 3;
TextureRegion tileRegion = tileRegions[ty][tx];
map.drawPixmap(tilesPixmap,
coords.x * tileSize,
coords.y * tileSize,
tileRegion.getRegionX(),
tileRegion.getRegionY(),
tileRegion.getRegionWidth(),
tileRegion.getRegionHeight());
}
示例10: initBall
import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入依赖的package包/类
private void initBall() {
float radius = 26;
mBall = new Circle(0.f, 0.f, radius);
mBallTextureRegion = new TextureRegion(new Texture(Gdx.files.internal("ball.png")));
// create physics body
BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyDef.BodyType.DynamicBody;
bodyDef.position.set(mBall.x, mBall.y);
CircleShape ballShape = new CircleShape();
ballShape.setRadius(mBall.radius - 2.f);
mBallBody = mWorld.createBody(bodyDef);
mBallBody.setUserData(new BodyUserDate(BODY_USER_DATA_TYPE_BALL));
Fixture fixture = mBallBody.createFixture(ballShape, 0.5f);
fixture.setFriction(BALL_FRICTION_BASE);
fixture.setRestitution(0.4f);
ballShape.dispose();
}
示例11: processEntity
import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入依赖的package包/类
@Override
protected void processEntity(Entity entity, float deltaTime) {
TransformComponent transform = transformMapper.get(entity);
DrawableComponent drawable = drawableMapper.get(entity);
TextureRegion region = drawable.texture;
float width = region.getRegionWidth();
float height = region.getRegionHeight();
float originX = width * 0.5f;
float originY = height * 0.5f;
float x = transform.position.x - originX;
float y = transform.position.y - originY;
if (debug) drawBounds(entity);
batch.draw(drawable.texture, x, y, originX, originY, width, height, transform.scale.x, transform.scale.y, transform.rotation.angle());
PlayerClass playerClass = playerMapper.get(entity);
if (playerClass != null && !playerClass.isSelf) {
font.draw(batch, playerClass.displayName, x, y, width, -1, true);
}
}
示例12: addBackground
import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入依赖的package包/类
private void addBackground(){
decalBackground = Decal.newDecal(new TextureRegion(managerAssets.getAssetsCrafting().getTexture(NameFiles.backgroundCrafting)));
decalBackground.setDimensions(100,200);
decalBackground.setPosition(0,0,0);
environment = new Environment();
// environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 1f, 1f, 1f, 1f));
environment.set(new ColorAttribute(ColorAttribute.Diffuse));
environment.set(new ColorAttribute(ColorAttribute.Specular));
environment.set(new ColorAttribute(ColorAttribute.Reflection));
environment.add(new DirectionalLight().set(0.51f, 0.5f, 0.5f, 0f, -2f, -30f));
Model model = managerAssets.getAssetsRaider().getModel(NameFiles.raiderFull);
model.nodes.get(2).translation.set(-12,28.6f,-5.5f);
// model.nodes.get(0).translation.set(0,28f,29.2f);
// model.nodes.get(2).translation.set(0,13,-1);
instance = new ModelInstance(model);
instance.transform.trn(0,-20,25).rotate(0,1,0,-25);
instance.transform.scale(1.5f,1.5f,1.5f);
}
示例13: addTestCombat
import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入依赖的package包/类
private void addTestCombat(){
groupTestCombat = new Group();
Image background = new Image(new TextureRegion(manager.getAssetsSettings().getTexture(NameFiles.extensionImgBackground)));
background.setSize(Width - Width * 0.03f, Height * 0.1f);
background.setPosition(Width / 2 - background.getWidth() / 2, Height * 0.15f);
groupChangeFaction.addActor(background);
Label labelFac = new Label("Combat Training",new Label.LabelStyle(Font.getFont((int)(Height*0.025f)),Color.WHITE));
labelFac.setPosition(background.getX()+background.getWidth()*0.05f,background.getY()+background.getHeight()/2-labelFac.getHeight()/2);
labelFac.addListener(new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y) {
manager.loadAssetsEnklaveScreen();
new GetEnklaveDetails().makeRequest(16066, manager);
gameManager.screenEnklave.setEnklave3D(new Vector2(0,0));
gameManager.setScreen(new ScreenCircleLoading(gameManager,gameManager.screenEnklave,manager.getAssertEnklaveScreen()));;
}
});
groupChangeFaction.addActor(labelFac);
}
示例14: setObjectives
import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入依赖的package包/类
public void setObjectives(Objective[] objectives, boolean[] objectiveStatus)
{
this.objectives = objectives;
this.objectiveStatus = objectiveStatus;
if(objectives.length != objectiveStatus.length)
throw new IllegalArgumentException();
getContentTable().clearChildren();
getBackground().setMinHeight(200 + 100 * objectives.length);
getContentTable().setDebug(false);
for(int i = 0; i < objectives.length; i++)
{
ImageButton imgCheck = new ImageButton(new TextureRegionDrawable(
new TextureRegion((Texture)
hexpert.assetManager.get(objectiveStatus[i] ? TEXTURE_CORRECT : TEXTURE_BAD
))));
Label labelObjective = new Label(objectives[i].toString(hexpert.i18NBundle), getSkin());
getContentTable().add(imgCheck).width(100).height(80);
imgCheck.getImageCell().expand().fill();
getContentTable().add(labelObjective);
getContentTable().row();
}
}
示例15: CharacterSheet
import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入依赖的package包/类
public CharacterSheet(TextureRegion[] idle, TextureRegion[] forward, TextureRegion[] backward, TextureRegion[] attack, TextureRegion[] in, TextureRegion[] out) {
this.idle = idle;
this.forward = forward;
this.backward = backward;
this.attack = attack;
this.in = in;
this.out = out;
}