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


Java Texture.getWidth方法代码示例

本文整理汇总了Java中com.badlogic.gdx.graphics.Texture.getWidth方法的典型用法代码示例。如果您正苦于以下问题:Java Texture.getWidth方法的具体用法?Java Texture.getWidth怎么用?Java Texture.getWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.badlogic.gdx.graphics.Texture的用法示例。


在下文中一共展示了Texture.getWidth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: draw

import com.badlogic.gdx.graphics.Texture; //导入方法依赖的package包/类
@Override
public void draw (Texture texture, float x, float y, int srcX, int srcY, int srcWidth, int srcHeight) {
	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).region(u, v, u2, v2);
}
 
开发者ID:CypherCove,项目名称:gdx-cclibs,代码行数:11,代码来源:CompliantBatch.java

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: ActionBar

import com.badlogic.gdx.graphics.Texture; //导入方法依赖的package包/类
/**
 * default constructor
 */
public ActionBar(float itemWidth, float itemHeight, int rows, int cols, Texture bgTexture, Texture blankTexture,
        BitmapFont font) {
    this.itemWidth = itemWidth;
    this.itemHeight = itemHeight;
    this.rows = rows;
    this.cols = cols;

    this.bgTexture = bgTexture;

    // create new blank item
    this.blankItem = new ActionBarItem(blankTexture, font);

    this.items = new ActionBarItem[rows][cols];

    float lastX = startX;
    float lastY = startY;

    for (int i = 0; i < rows; i++) {
        lastY += paddingBottom;

        for (int j = 0; j < cols; j++) {
            // set blank item
            items[i][j] = new ActionBarItem(blankTexture, font);

            lastX += paddingLeft;

            // calculate position and dimension
            items[i][j].setDimension(itemWidth, itemHeight);
            items[i][j].onMoveGroup(getX(), getY());
            items[i][j].setPosition(lastX, lastY);

            lastX += itemWidth + paddingRight;
        }

        lastY += itemHeight + paddingTop;
    }

    // calculate dimension
    float width = bgTexture.getWidth();
    float height = bgTexture.getHeight();
    setDimension(width, height);

    this.font = font;
}
 
开发者ID:opensourcegamedev,项目名称:SpaceChaos,代码行数:48,代码来源:ActionBar.java

示例12: Level5

import com.badlogic.gdx.graphics.Texture; //导入方法依赖的package包/类
public Level5(GameStateManager gsm, int c) {
    super(gsm);
    a = c;
    // INITIALIZING ANIMALS
    if (a == 1) {
        sheep = new Sheep(150, 60);
    }
    if (a == 2) {
        cow = new Cow(150, 60);
    }
    if (a == 3) {
        pig = new Pig(150, 60);
    }
    if (a == 4) {
        bunny = new Bunny(150, 60);
    }
    if (a == 5) {
        chick = new Chick(150, 60);
    }

    sky = new Texture("CitySky.png");
    farmer = new Farmer(-60,60);
    buildings = new Texture("UpdatedCityBuildings.png");
    ground = new Texture("CityGround.png");
    cam.setToOrtho(false, GameTutorial.WIDTH / 2, GameTutorial.HEIGHT / 2);
    groundPos1 = new Vector2(cam.position.x - cam.viewportWidth / 2 - ground.getWidth(), 0);
    groundPos2 = new Vector2(ground.getWidth() + groundPos1.x, 0);
    groundPos3 = new Vector2(ground.getWidth() + groundPos2.x, 0);
    skyPos = new Vector2(cam.position.x - cam.viewportWidth / 2 - sky.getWidth(), 0);
    skyPos2 = new Vector2(sky.getWidth() + skyPos.x, 0);
    buildingsPos = new Vector2(cam.position.x - cam.viewportWidth / 2 - BUILDINGS_WIDTH, 0);
    buildingsPos2 = new Vector2(buildingsPos.x + BUILDINGS_WIDTH, 0);
    buildingsPos3 = new Vector2(2 * BUILDINGS_WIDTH + buildingsPos.x, 0);
    buildingsPos4 = new Vector2(3 * BUILDINGS_WIDTH + buildingsPos.x, 0);
    buildingsPos5 = new Vector2(4 * BUILDINGS_WIDTH + buildingsPos.x, 0);

    //Obstacles
    greyTexture = new Texture("CarGrey.png");
    greyCar = new Obstacle(greyTexture, 700, 48, 1, 0.5f);
    mushroomTexture = new Texture("Mushroom.png");
    mushroom = new Obstacle(mushroomTexture, 2000, 70, 2, 0.2f);
    mushroomIsTouched = false;
    cherryTexture = new Texture("Cherry2_0.35.png");
    cherry = new Obstacle(cherryTexture, 1000, 150, 2, 0.35f);
    cherryIsTouched = false;
    spikeTexture = new Texture("SPIKES2.0.18.png");
    spikes = new Obstacle(spikeTexture, 1700, 50, 2, 0.5f);
    startTime = System.currentTimeMillis();
    batch = new SpriteBatch();
    font = new BitmapFont();
}
 
开发者ID:MissionBit,项目名称:summer17-android,代码行数:52,代码来源:Level5.java

示例13: Level2

import com.badlogic.gdx.graphics.Texture; //导入方法依赖的package包/类
public Level2(GameStateManager gsm, int c) {
    super(gsm);
    a = c;
    cam.setToOrtho(false, GameTutorial.WIDTH / 2, GameTutorial.HEIGHT / 2);
    // INITIALIZING ANIMALS
    if (a == 1){
        sheep = new Sheep(150, 60);
    }
    if (a == 2){
        cow = new Cow(150, 60);
    }
    if (a == 3){
        pig = new Pig(150, 60);
    }
    if (a == 4){
        bunny = new Bunny(150, 60);
    }
    if (a == 5){
        chick = new Chick(150, 60);
    }
    farmer = new Farmer(-50, 60);
    ground = new Texture("CornFieldGround.png");
    background = new Texture("CornField.png");
    groundPos1 = new Vector2(cam.position.x - cam.viewportWidth / 2 - ground.getWidth(), GROUND_Y_OFFSET);
    groundPos2 = new Vector2(ground.getWidth() + groundPos1.x, GROUND_Y_OFFSET);
    bgPos1 = new Vector2(cam.position.x - cam.viewportWidth / 2 - bg_width, 0);
    bgPos2 = new Vector2(background.getWidth() + bgPos1.x, 0);
    bgPos3 = new Vector2(background.getWidth() + bgPos2.x, 0);

    //Obstacles
    mushroomTexture = new Texture("Mushroom.png");
    mushroom = new Obstacle(mushroomTexture, 700, 70, 2, 0.3f);
    mushroomIsTouched = false;
    mud = new Mud(260, 37);
    appleTexture = new Texture("Apple.png");
    apple = new Obstacle(appleTexture, 1000, 150, 2, 0.5f);
    appleIsTouched = false;
    barrel = new Barrel(300, 60);
    startTime = System.currentTimeMillis();
    batch = new SpriteBatch();
    font = new BitmapFont();
}
 
开发者ID:MissionBit,项目名称:summer17-android,代码行数:43,代码来源:Level2.java

示例14: Level1

import com.badlogic.gdx.graphics.Texture; //导入方法依赖的package包/类
public Level1(final GameStateManager gsm, int c) {
    super(gsm);
    a = c;
    cam.setToOrtho(false, GameTutorial.WIDTH / 2, GameTutorial.HEIGHT / 2);
    bg = new Texture("FarmBG1.png");
    // INITIALIZING ANIMALS
    if (a == 1) {
        sheep = new Sheep(150, 60);
    }
    if (a == 2) {
        cow = new Cow(150, 60);
    }
    if (a == 3) {
        pig = new Pig(150, 60);
    }
    if (a == 4) {
        bunny = new Bunny(150, 60);
    }
    if (a == 5) {
        chick = new Chick(150, 60);
    }
    farmer = new Farmer(-50, 60);
    ground = new Texture("FarmBG6.png");
    trees = new Texture("FarmBG3.png");
    trees2 = new Texture("FarmBG4.png");
    trees3 = new Texture("FarmBG5.png");
    barn = new Texture("FarmBG1.png");
    shed = new Texture("FarmBG2.png");
    background = new Texture("Sky1.png");
    groundPos1 = new Vector2(cam.position.x - cam.viewportWidth / 2, GROUND_Y_OFFSET);
    groundPos2 = new Vector2(ground.getWidth() + groundPos1.x, GROUND_Y_OFFSET);
    treePos1 = new Vector2(cam.position.x - cam.viewportWidth / 2, 0);
    treePos2 = new Vector2(trees.getWidth() + treePos1.x, 0);
    treePos3 = new Vector2(trees.getWidth() + treePos2.x, 0);
    barnPos = new Vector2(50, 0);
    shedPos = new Vector2(350, 0);
    bgPos1 = new Vector2(cam.position.x - cam.viewportWidth / 2, 0);
    bgPos2 = new Vector2(background.getWidth() + bgPos1.x, 0);
    batch = new SpriteBatch();
    font = new BitmapFont();

    //OBSTACLES
    haybaleTexture = new Texture("haybale3.png");
    haybale = new Obstacle(haybaleTexture, 1300, 50, 1, 0.5f);
    poop = new Poop(260, 60);
    cherry = new Cherry(500, 150);
    cherryIsTouched = false;
    startTime = System.currentTimeMillis();
}
 
开发者ID:MissionBit,项目名称:summer17-android,代码行数:50,代码来源:Level1.java

示例15: Level3

import com.badlogic.gdx.graphics.Texture; //导入方法依赖的package包/类
public Level3(GameStateManager gsm, int c) {
    super(gsm);
    a = c;
    cam.setToOrtho(false, GameTutorial.WIDTH / 2, GameTutorial.HEIGHT / 2);
    // INITIALIZING ANIMALS
    if (a == 1){
        sheep = new Sheep(150, 60);
    }
    if (a == 2){
        cow = new Cow(150, 60);
    }
    if (a == 3){
        pig = new Pig(150, 60);
    }
    if (a == 4){
        bunny = new Bunny(150, 60);
    }
    if (a == 5){
        chick = new Chick(150, 60);
    }
    farmer = new Farmer(-50, 60);
    ground = new Texture("plains-ground.png");
    groundPos1 = new Vector2(cam.position.x - cam.viewportWidth / 2, 0);
    groundPos2 = new Vector2(ground.getWidth(), 0);
    groundPos3 = new Vector2(ground.getWidth() + groundPos2.x, 0);
    sky = new Texture("plains-background.png");
    skyPos = new Vector2(cam.position.x - cam.viewportWidth / 2, 0);
    skyPos2 = new Vector2(sky.getWidth() + skyPos.x, 0);
    hills = new Texture("plains-hills2.png");
    hillsPos = new Vector2(cam.position.x - cam.viewportWidth / 2, 0);
    hillsPos2 = new Vector2(hills_width + hillsPos.x, 0);
    hillsPos3 = new Vector2(2 * hills_width + hillsPos.x, 0);
    hillsPos4 = new Vector2(3 * hills_width + hillsPos.x, 0);
    hillsPos5 = new Vector2(4 * hills_width + hillsPos.x, 0);
    //OBSTACLES
    Texture spikeTexture = new Texture("SPIKES2.0.18.png");
    spikes = new Obstacle(spikeTexture, 400, 50, 2, 0.5f);
    startTime = System.currentTimeMillis();
    mudTexture = new Texture("mud.png");
    mud = new Obstacle(mudTexture, 700, 58, 1, 0.5f);
    carrotTexture = new Texture("Carrott.png");
    carrot = new Obstacle(carrotTexture, 500, 150, 2, 0.3f);
    spikesTexture = new Texture("SPIKES2.0.18.png");
    spikes = new Obstacle(spikesTexture, 1700, 50, 2, 0.5f);
    carrotIsTouched = false;
    batch = new SpriteBatch();
    font = new BitmapFont();
}
 
开发者ID:MissionBit,项目名称:summer17-android,代码行数:49,代码来源:Level3.java


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