當前位置: 首頁>>代碼示例>>Java>>正文


Java Texture.getHeight方法代碼示例

本文整理匯總了Java中com.badlogic.gdx.graphics.Texture.getHeight方法的典型用法代碼示例。如果您正苦於以下問題:Java Texture.getHeight方法的具體用法?Java Texture.getHeight怎麽用?Java Texture.getHeight使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.badlogic.gdx.graphics.Texture的用法示例。


在下文中一共展示了Texture.getHeight方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: MapManager

import com.badlogic.gdx.graphics.Texture; //導入方法依賴的package包/類
public MapManager(Texture map){
    bkgnd = SpriteSheet.background;
    width = map.getWidth();
    height = map.getHeight();
    tiles = new short[width * height];
    if(!map.getTextureData().isPrepared())
        map.getTextureData().prepare();
    Pixmap p = map.getTextureData().consumePixmap();
    for(int y = 0; y < height; y++) {
        for(int x = 0; x < width; x++) {
            if(p.getPixel(x,y) == Tile.GRASS_COL) tiles[x + ((height - y - 1) * width)] = Tile.GRASS_ID;
            if(p.getPixel(x,y) == Tile.DIRT_COL) tiles[x + ((height - y - 1) * width)] = Tile.DIRT_ID;
            if(p.getPixel(x,y) == Tile.SAND_COL) tiles[x + ((height - y - 1) * width)] = Tile.SAND_ID;
            if(p.getPixel(x,y) == Tile.WATER_COL) tiles[x + ((height - y - 1) * width)] = Tile.WATER_ID;

        }
    }
}
 
開發者ID:elitej13,項目名稱:project-divine-intervention,代碼行數:19,代碼來源:MapManager.java

示例2: init

import com.badlogic.gdx.graphics.Texture; //導入方法依賴的package包/類
private void init() {

		// Start Shooting
		bulletCooldown = TimeUtils.millis();
		enemyBulletSpeed = 5;
		randomAttackCooldown = MathUtils.random(200, 1000);
		
		// Drop Chance | 10% chance
		dropChance = MathUtils.random(0, 9);

		// Start Sprites
		allTexture = new Texture(Gdx.files.internal(pathName));
		TextureRegion[][] tmp = TextureRegion.split(allTexture, allTexture.getWidth() / 3, allTexture.getHeight() / 1);
		rolls = new TextureRegion[3];
		for (int i = 0; i < rolls.length; i++) {
			rolls[i] = tmp[0][i];
		}

		// Start rectangle
		collisionBounds = new Rectangle(x, y, allTexture.getWidth() / 3, allTexture.getHeight());
	}
 
開發者ID:ja-brouil,項目名稱:StarshipFighters,代碼行數:22,代碼來源:BasicAlien.java

示例3: stencil

import com.badlogic.gdx.graphics.Texture; //導入方法依賴的package包/類
private void stencil(Planet planet, Texture texture, PlanetCell.CellType[] replaceTypes, int degrees, int x1, int y1) {
    final TextureData textureData = texture.getTextureData();
    textureData.prepare();

    final Pixmap pixmap = textureData.consumePixmap();
    for (int y = 0; y < texture.getHeight(); y++) {
        for (int x = 0; x < texture.getWidth(); x++) {

            tv.set(x, y).rotate(degrees).add(x1, y1);

            int color = pixmap.getPixel(x, texture.getHeight() - y);
            final PlanetCell.CellType type = getSourceCellType(planet, color);
            if (type != null) {
                replaceCell(planet, Math.round(tv.x), Math.round(tv.y), replaceTypes, type, color);
            }

        }
    }
    pixmap.dispose();
}
 
開發者ID:DaanVanYperen,項目名稱:odb-little-fortune-planet,代碼行數:21,代碼來源:PlanetStencilSystem.java

示例4: Tube

import com.badlogic.gdx.graphics.Texture; //導入方法依賴的package包/類
public Tube(float x) {
    topTube = new Texture("toptube1.png");
    bottomTube = new Texture("bottomtube1.png");
    random = new Random();

    posTopTube = new Vector2(x, random.nextInt(FLUCTUATION) + TUBE_GAP + LOWEST_OPENING);
    posBotTube = new Vector2(x, posTopTube.y - TUBE_GAP - bottomTube.getHeight());

    boundsTop = new Rectangle(posTopTube.x, posTopTube.y, topTube.getWidth(), topTube.getHeight());
    boundsBot = new Rectangle(posBotTube.x, posBotTube.y, bottomTube.getWidth(), bottomTube.getHeight());
}
 
開發者ID:RubenMateus,項目名稱:FlappyChapa,代碼行數:12,代碼來源:Tube.java

示例5: Chapa

import com.badlogic.gdx.graphics.Texture; //導入方法依賴的package包/類
public Chapa(int x, int y) {
    position = new Vector3(x, y, 0);
    velocity = new Vector3(0, 0, 0);

    texture = new Texture("chapaanimation.png");
    birdAnimation = new Animation(new TextureRegion(texture), 3, 0.5f);
    bounds = new Rectangle(x, y, texture.getWidth() / 3, texture.getHeight());
    initSounds();
}
 
開發者ID:RubenMateus,項目名稱:FlappyChapa,代碼行數:10,代碼來源:Chapa.java

示例6: Bird

import com.badlogic.gdx.graphics.Texture; //導入方法依賴的package包/類
public Bird(int x, int y){
    position = new Vector3(x, y, 0);
    velosity = new Vector3(0, 0, 0);
    texture = new Texture("Sheep-Animated-Gif4.png");
    birdAnimation = new Animation(new TextureRegion(texture), FRAME_COUNT, 0.9f);
    bounds = new Rectangle(x, y, texture.getWidth() / FRAME_COUNT, texture.getHeight());
    flap = Gdx.audio.newSound(Gdx.files.internal("sfx_wing.ogg"));
}
 
開發者ID:kirdmiv,項目名稱:Flappy-Baranus,代碼行數:9,代碼來源:Bird.java

示例7: Tube

import com.badlogic.gdx.graphics.Texture; //導入方法依賴的package包/類
public Tube(float x){
    topTube = new Texture("toptube.png");
    bottomTube = new Texture("bottomtube.png");
    rand = new Random();

    posTopTube = new Vector2(x, rand.nextInt(FLUCTUATION) + TUBE_GAP + LOWEST_OPENING);
    posBotTube = new Vector2(x, posTopTube.y - TUBE_GAP - bottomTube.getHeight());

    boundsTop = new Rectangle(posTopTube.x, posTopTube.y, topTube.getWidth(), topTube.getHeight());
    boundsBot = new Rectangle(posBotTube.x, posBotTube.y, bottomTube.getWidth(), bottomTube.getHeight());

}
 
開發者ID:kirdmiv,項目名稱:Flappy-Baranus,代碼行數:13,代碼來源:Tube.java

示例8: isEqual

import com.badlogic.gdx.graphics.Texture; //導入方法依賴的package包/類
private boolean isEqual(Texture a, Texture b) {
    if (a.getDepth() != b.getDepth()) return false;
    if (a.getHeight() != b.getHeight()) return false;
    if (a.getWidth() != b.getWidth()) return false;

    if (!a.getTextureData().getFormat().equals(b.getTextureData().getFormat())) return false;
    if (a.getTextureData().getHeight() != b.getTextureData().getHeight()) return false;
    if (a.getTextureData().getWidth() != b.getTextureData().getWidth()) return false;
    if (!a.getTextureData().getType().equals(b.getTextureData().getType())) return false;

    return true;
}
 
開發者ID:akivamu,項目名稱:libgdx-crypt-texture,代碼行數:13,代碼來源:SimpleGame.java

示例9: Barrel

import com.badlogic.gdx.graphics.Texture; //導入方法依賴的package包/類
public Barrel(int x, int y) {
    barrel = new Texture("Barrel.png");
    rand = new Random();
    posBarrel = new Vector2(rand.nextInt(FLUCTUATION) + BARREL_MIN_X, y);
    //pos2Barrel = new Vector2(rand.nextInt(FLUCTUATION)+BARREL_MIN_X+posBarrel.x,60);
    barrelBounds = new Rectangle(posBarrel.x, posBarrel.y, barrel.getWidth(), barrel.getHeight());
    //barrel2Bounds = new Rectangle(pos2Barrel.x,pos2Barrel.y,barrel.getWidth(),barrel.getHeight());
    collided = false;
}
 
開發者ID:MissionBit,項目名稱:summer17-android,代碼行數:10,代碼來源:Barrel.java

示例10: Obstacle

import com.badlogic.gdx.graphics.Texture; //導入方法依賴的package包/類
public Obstacle(Texture obstacle, float x, float y, int frames, float time) {
    this.obstacle = obstacle;
    obstacleAnimation = new Animation(new TextureRegion(obstacle), frames, time);
    posObs = new Vector2(x, y);
    boundsObs = new Rectangle(posObs.x, posObs.y, obstacle.getWidth(), obstacle.getHeight());
    hasCollided = false;
}
 
開發者ID:MissionBit,項目名稱:summer17-android,代碼行數:8,代碼來源:Obstacle.java

示例11: Cherry

import com.badlogic.gdx.graphics.Texture; //導入方法依賴的package包/類
public Cherry(int x, int y){
    cherry = new Texture("Cherry2_0.35.png");
    cherryAnimation = new Animation(new TextureRegion(cherry),2,0.5f);
    rand = new Random();
    posCherry = new Vector2(rand.nextInt(FLUCTUATION)+CHERRY_MIN_X, y);
    cherryBounds = new Rectangle(posCherry.x,posCherry.y,cherry.getWidth(),cherry.getHeight());
    collided = false;

}
 
開發者ID:MissionBit,項目名稱:summer17-android,代碼行數:10,代碼來源:Cherry.java

示例12: draw

import com.badlogic.gdx.graphics.Texture; //導入方法依賴的package包/類
@Override
public void draw (Texture texture, float x, float y, float originX, float originY, float width, float height, float scaleX,
	float scaleY, float rotation, int srcX, int srcY, int srcWidth, int srcHeight, boolean flipX, boolean flipY) {
	float invTexWidth = 1.0f / texture.getWidth();
	float invTexHeight = 1.0f / texture.getHeight();
	float u = srcX * invTexWidth;
	float v = (srcY + srcHeight) * invTexHeight;
	float u2 = (srcX + srcWidth) * invTexWidth;
	float v2 = srcY * invTexHeight;
	draw().color(color).texture(texture).position(x, y).origin(originX, originY).size(width, height).scale(scaleX, scaleY)
		.rotation(rotation).region(u, v, u2, v2).flip(flipX, flipY);
}
 
開發者ID:CypherCove,項目名稱:gdx-cclibs,代碼行數:13,代碼來源:CompliantBatch.java

示例13: GameObject

import com.badlogic.gdx.graphics.Texture; //導入方法依賴的package包/類
public GameObject(Texture lookout, long id)
{
    sprite = new Sprite(lookout);
    sprite.setRegion(lookout);
    collisionRectangle.width = lookout.getWidth();
    collisionRectangle.height = lookout.getHeight();
    this.id = id;
}
 
開發者ID:MMORPG-Prototype,項目名稱:MMORPG_Prototype,代碼行數:9,代碼來源:GameObject.java

示例14: create

import com.badlogic.gdx.graphics.Texture; //導入方法依賴的package包/類
@Override
public void create() {
    TextureComponent textureComponent = getComponentByType(TextureComponent.class);
    if (textureComponent != null) {
        Texture texture = new Texture(Gdx.files.internal(mTexturePath));
        textureComponent.textureRegion = new TextureRegion(texture);

        SizeComponent sizeComponent = getComponentByType(SizeComponent.class);
        if (sizeComponent != null && sizeComponent.height == -1.f) {
            float aspect = (float)texture.getWidth() / (float)texture.getHeight();
            sizeComponent.height = sizeComponent.width / aspect;
        }
    }
}
 
開發者ID:tgobbens,項目名稱:fluffybalance,代碼行數:15,代碼來源:SpriteEntity.java

示例15: createTorpedoProjectile

import com.badlogic.gdx.graphics.Texture; //導入方法依賴的package包/類
/**
 * Creating a new entity moving forward and causing much damage.
 *
 * @param ecs
 *            entity component system
 * @param x
 *            x start position of projectile
 * @param y
 *            y start position of projectile
 * @param texture
 *            texture of projectile
 * @return projectile entity
 */
public static Entity createTorpedoProjectile(EntityManager ecs, float x, float y, Texture texture, float moveX,
        float moveY, Entity playerEntity, Entity enemyEntity) {

    // create new entity
    Entity projectileEntity = new Entity(ecs);

    // every entity requires a position component
    projectileEntity.addComponent(new PositionComponent(x, y), PositionComponent.class);

    // add texture component to draw texture
    projectileEntity.addComponent(
            new DrawTextureComponent(texture, texture.getWidth() / 2, texture.getHeight() / 2),
            DrawTextureComponent.class);

    // add component to move entity
    projectileEntity.addComponent(new MoveComponent(moveX, moveY, 4f), MoveComponent.class);

    // add collision component, so entity can collide with other space
    // shuttles or meteorites
    projectileEntity.addComponent(new CollisionComponent(), CollisionComponent.class);
    projectileEntity.getComponent(CollisionComponent.class)
            .addInnerShape(new CCircle(texture.getWidth() / 2, texture.getHeight() / 2, texture.getWidth() / 2));

    // add attack component
    projectileEntity.addComponent(new DealDamageOnCollisionComponent(800, true, playerEntity));

    // add component to avoid camera shake, if player fires projectile (if
    // projectile starts, projectile is in player collision hull)
    projectileEntity.addComponent(new AvoidCollisionCameraShakeComponent(),
            AvoidCollisionCameraShakeComponent.class);

    // add component to avoid collision sound
    projectileEntity.addComponent(new AvoidCollisionSoundComponent(), AvoidCollisionSoundComponent.class);

    // AI
    // projectileEntity.addComponent(new
    // SimpleFollowAIMovementComponent(enemyEntity));

    // add component to auto remove projectile after a given time
    projectileEntity.addComponent(new TimedAutoRemoveComponent(3000L));

    // add component for smoke particles
    // create smoke effect
    ParticleEffect smokeEffect = new ParticleEffect();
    smokeEffect.load(Gdx.files.internal("./data/particles/smokeGrey.p"), Gdx.files.internal(""));
    BaseParticleEffect particleEffect = new MovementDirectionBasedParticleEffect(smokeEffect,
            texture.getWidth() / 2 - 12, texture.getHeight() / 2 - 12);
    projectileEntity.addComponent(new ParticleComponent(particleEffect));

    return projectileEntity;
}
 
開發者ID:opensourcegamedev,項目名稱:SpaceChaos,代碼行數:65,代碼來源:ProjectileFactory.java


注:本文中的com.badlogic.gdx.graphics.Texture.getHeight方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。