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


Java TextureRegion.getRegionHeight方法代码示例

本文整理汇总了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;
}
 
开发者ID:mingwuyun,项目名称:cocos2d-java,代码行数:22,代码来源:Sprite.java

示例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);
    }
}
 
开发者ID:ezet,项目名称:penguins-in-space,代码行数:20,代码来源:RenderSystem.java

示例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;
		}
	}
}
 
开发者ID:chrisj42,项目名称:miniventure,代码行数:21,代码来源:TileTouchCheck.java

示例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
}
 
开发者ID:CypherCove,项目名称:gdx-cclibs,代码行数:23,代码来源:Poly.java

示例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;
}
 
开发者ID:MMORPG-Prototype,项目名称:MMORPG_Prototype,代码行数:25,代码来源:GameObjectHighlightGraphic.java

示例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();
	}
}
 
开发者ID:mingwuyun,项目名称:cocos2d-java,代码行数:11,代码来源:Sprite.java

示例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;
}
 
开发者ID:CypherCove,项目名称:gdx-cclibs,代码行数:30,代码来源:Poly2D.java

示例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;
}
 
开发者ID:kyperbelt,项目名称:KyperBox,代码行数:35,代码来源:TransitionManager.java

示例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);
        }
    }
 
开发者ID:DaanVanYperen,项目名称:odb-artax,代码行数:51,代码来源:MyAnimRenderSystem.java

示例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;
        
    }
    
    
}
 
开发者ID:cn-s3bit,项目名称:TH902,代码行数:80,代码来源:CircularProgress.java

示例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);
        }
    }
 
开发者ID:DaanVanYperen,项目名称:odb-little-fortune-planet,代码行数:51,代码来源:MyAnimRenderSystem.java

示例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));
}
 
开发者ID:cn-s3bit,项目名称:TH902,代码行数:18,代码来源:CircularProgress.java


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