本文整理汇总了Java中com.badlogic.gdx.graphics.g2d.TextureRegion.getRegionHeight方法的典型用法代码示例。如果您正苦于以下问题:Java TextureRegion.getRegionHeight方法的具体用法?Java TextureRegion.getRegionHeight怎么用?Java TextureRegion.getRegionHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.graphics.g2d.TextureRegion
的用法示例。
在下文中一共展示了TextureRegion.getRegionHeight方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initWithTextureRegion
import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入方法依赖的package包/类
/**
* 使用TextureRegion创建Sprite
* @param region
* @return
*/
public boolean initWithTextureRegion(TextureRegion region) {
_recursiveDirty = true;
setDirty(true);
_opacityModifyRGB = true;
super.setAnchorPoint(0.5f, 0.5f);
super.setContentSize(region.getRegionWidth(), region.getRegionHeight());
if(_sprite != null) {
_sprite = new com.badlogic.gdx.graphics.g2d.Sprite(region);
} else {
_sprite.setRegion(region);
}
return true;
}
示例2: 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);
}
}
示例3: 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;
}
}
}
示例4: apply
import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入方法依赖的package包/类
protected int apply (float[] vertices, int vertexStartingIndex, AttributeOffsets offsets, int vertexSize) {
final PolygonRegion region = this.region;
final TextureRegion tRegion = region.getRegion();
if (!sizeSet && region != null) {
width = tRegion.getRegionWidth();
height = tRegion.getRegionHeight();
}
float color = this.color;
for (int i = 0, v = vertexStartingIndex + offsets.color0; i < numVertices; i++, v += vertexSize) {
vertices[v] = color;
}
float[] textureCoords = region.getTextureCoords();
for (int i = 0, v = vertexStartingIndex
+ offsets.textureCoordinate0, n = textureCoords.length; i < n; i += 2, v += vertexSize) {
vertices[v] = textureCoords[i];
vertices[v + 1] = textureCoords[i + 1];
}
return 0; // handled by subclass
}
示例5: 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;
}
示例6: setSpriteFrame
import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入方法依赖的package包/类
/**set a new textureRegion to the Sprite
* @param reset true 会重置尺寸/中心点数据 */
public void setSpriteFrame(TextureRegion newFrame, boolean reset) {
_sprite.setRegion(newFrame);
if(reset) {
super.setAnchorPoint(0.5f, 0.5f);
super.setContentSize(newFrame.getRegionWidth(), newFrame.getRegionHeight());
SET_DIRTY_RECURSIVELY();
}
}
示例7: apply
import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入方法依赖的package包/类
@Override
protected int apply (float[] vertices, int vertexStartingIndex, AttributeOffsets offsets, int vertexSize) {
super.apply(vertices, vertexStartingIndex, offsets, vertexSize);
final PolygonRegion region = this.region;
final TextureRegion tRegion = region.getRegion();
final float originX = this.originX;
final float originY = this.originY;
final float scaleX = this.scaleX;
final float scaleY = this.scaleY;
final float[] regionVertices = region.getVertices();
final float worldOriginX = x + originX;
final float worldOriginY = y + originY;
final float sX = width / tRegion.getRegionWidth();
final float sY = height / tRegion.getRegionHeight();
final float cos = MathUtils.cosDeg(rotation);
final float sin = MathUtils.sinDeg(rotation);
float fx, fy;
for (int i = 0, v = vertexStartingIndex + offsets.position, n = regionVertices.length; i < n; i += 2, v += vertexSize) {
fx = (regionVertices[i] * sX - originX) * scaleX;
fy = (regionVertices[i + 1] * sY - originY) * scaleY;
vertices[v] = cos * fx - sin * fy + worldOriginX;
vertices[v + 1] = sin * fx + cos * fy + worldOriginY;
}
return numVertices;
}
示例8: getTransitionObject
import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入方法依赖的package包/类
public TransitionObject getTransitionObject(Color c,boolean in, int type,TextureRegion map) {
TransitionObject o = new TransitionObject();
o.setTexture(map);
float width = map.getRegionWidth()/scale;
float height = map.getRegionHeight()/scale;
switch (type) {
case FADE:
o.setSize(width, height);
o.setPosition(0, 0);
if(in) {
o.setColor(c.r, c.g, c.b, 1f);
o.addAction(Actions.fadeOut(duration));
}else{
o.setColor(c.r,c.g,c.b,0f);
o.addAction(Actions.fadeIn(duration));
}
break;
case WIPE:
o.setSize(width, height);
o.setColor(c);
if(in) {
o.setPosition(0, 0);
o.addAction(Actions.moveBy(o.getWidth(), o.getY(), duration));
}else{
o.setPosition(width, 0);
o.addAction(Actions.moveBy(-o.getWidth(), o.getY(), duration));
}
break;
default:
break;
}
return o;
}
示例9: drawAnimation
import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入方法依赖的package包/类
private void drawAnimation(final Anim animation, final Angle angle, final Origin origin, final Pos position, String id, float scale) {
// don't support backwards yet.
if ( animation.age < 0 ) return;
final Animation<TextureRegion> gdxanim = (Animation<TextureRegion>) abstractAssetSystem.get(id);
if ( gdxanim == null) return;
final TextureRegion frame = gdxanim.getKeyFrame(animation.age, animation.loop);
float ox = frame.getRegionWidth() * scale * origin.xy.x;
float oy = frame.getRegionHeight() * scale * origin.xy.y;
if ( animation.flippedX && angle.rotation == 0)
{
// mirror
batch.draw(frame.getTexture(),
roundToPixels(position.xy.x),
roundToPixels(position.xy.y),
ox,
oy,
frame.getRegionWidth() * scale,
frame.getRegionHeight() * scale,
1f,
1f,
angle.rotation,
frame.getRegionX(),
frame.getRegionY(),
frame.getRegionWidth(),
frame.getRegionHeight(),
true,
false);
} else if ( angle.rotation != 0 )
{
batch.draw(frame,
roundToPixels(position.xy.x),
roundToPixels(position.xy.y),
ox,
oy,
frame.getRegionWidth() * scale,
frame.getRegionHeight() * scale, 1, 1,
angle.rotation);
} else {
batch.draw(frame,
roundToPixels(position.xy.x),
roundToPixels(position.xy.y),
frame.getRegionWidth() * scale,
frame.getRegionHeight() * scale);
}
}
示例10: CircularProgress
import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入方法依赖的package包/类
public CircularProgress(TextureRegion region) {
this.region = region;
/**
* 使用默认的shader
* 一般不指定ShaderProgram,我们使用SpriteBatch的时候都是使用默认的shader
*/
this.shader = SpriteBatch.createDefaultShader();
// 设置顶点数据类型为数组类型
Mesh.VertexDataType vertexDataType = Mesh.VertexDataType.VertexArray;
/**
* 只需要处理 :顶点坐标、颜色、纹理坐标
*/
VertexAttribute[] vertexAttributes = new VertexAttribute[3];
vertexAttributes[0] = new VertexAttribute(Usage.Position, POSITION_COMPONENTS, "a_position");
vertexAttributes[1] = new VertexAttribute(Usage.ColorPacked, COLOR_COMPONENTS, "a_color");
vertexAttributes[2] = new VertexAttribute(Usage.TextureCoordinates, TEXCOORD_COMPONENTS, "a_texCoord0");
this.mesh = new Mesh(vertexDataType, false, MAX_VERTICES, MAX_INDICES, vertexAttributes);
float width = region.getRegionWidth();
float height = region.getRegionHeight();
/**
* 初始化顶点数据
*/
vertices = new float[MAX_VERTICES * TOTAL_COMPONENTS];
int idx = 0;
vertices[(idx++)] = 0;
vertices[(idx++)] = 0;
idx = idx + 3;
vertices[(idx++)] = 0;
vertices[(idx++)] = (height / 2.0f);
idx = idx + 3;
vertices[(idx++)] = (width / 2.0f);
vertices[(idx++)] = (height / 2.0f);
idx = idx + 3;
vertices[(idx++)] = (width / 2.0f);
vertices[(idx++)] = 0;
idx = idx + 3;
vertices[(idx++)] = (width / 2.0f);
vertices[(idx++)] = (-height / 2.0f);
idx = idx + 3;
vertices[(idx++)] = 0;
vertices[(idx++)] = (-height / 2.0f);
idx = idx + 3;
vertices[(idx++)] = (-width / 2.0f);
vertices[(idx++)] = (-height / 2.0f);
idx = idx + 3;
vertices[(idx++)] = (-width / 2.0f);
vertices[(idx++)] = 0;
idx = idx + 3;
vertices[(idx++)] = (-width / 2.0f);
vertices[(idx++)] = (height / 2.0f);
/**
* 初始话顶点位置 与 纹理坐标
*/
for (int i = 0; i < 9; i++) {
vertices[i * 5 + 0] = (vertices[i * 5] + (width / 2.0f));
vertices[i * 5 + 1] = (vertices[i * 5 + 1] + (height / 2.0f));
Vector2 uv = getUV(region, vertices[i * 5], vertices[i * 5 + 1]);
vertices[i * 5 + 3] = uv.x;
vertices[i * 5 + 4] = uv.y;
}
}
示例11: drawAnimation
import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入方法依赖的package包/类
private void drawAnimation(final Anim animation, final Angle angle, final Origin origin, final Pos position, String id, float scale) {
// don't support backwards yet.
if ( animation.age < 0 ) return;
final Animation<TextureRegion> gdxanim = (Animation<TextureRegion>) abstractAssetSystem.get(id);
if ( gdxanim == null) return;
final TextureRegion frame = gdxanim.getKeyFrame(animation.age, animation.loop);
float ox = frame.getRegionWidth() * scale * origin.xy.x;
float oy = frame.getRegionHeight() * scale * origin.xy.y;
if ( animation.flippedX)
{
// mirror
batch.draw(frame.getTexture(),
roundToPixels(position.xy.x),
roundToPixels(position.xy.y),
ox,
oy,
frame.getRegionWidth() * scale,
frame.getRegionHeight() * scale,
1f,
1f,
angle.rotation,
frame.getRegionX(),
frame.getRegionY(),
frame.getRegionWidth(),
frame.getRegionHeight(),
true,
false);
} else if ( angle.rotation != 0 )
{
batch.draw(frame,
roundToPixels(position.xy.x),
roundToPixels(position.xy.y),
ox,
oy,
frame.getRegionWidth() * scale,
frame.getRegionHeight() * scale, 1, 1,
angle.rotation);
} else {
batch.draw(frame,
roundToPixels(position.xy.x),
roundToPixels(position.xy.y),
frame.getRegionWidth() * scale,
frame.getRegionHeight() * scale);
}
}
示例12: getUV
import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入方法依赖的package包/类
/**
* 计算纹理坐标
* @author whs
* @date 2015-11-25 下午4:24:03
* @param region
* @param x
* @param y
* @return
* @Description:
*/
private Vector2 getUV(TextureRegion region, float x, float y) {
float u = region.getU();
float v = region.getV();
float u2 = region.getU2();
float v2 = region.getV2();
return new Vector2(u + x / region.getRegionWidth() * (u2 - u), v2 - y / region.getRegionHeight() * (v2 - v));
}