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


Java TextureRegion.split方法代码示例

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


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

示例1: initialize

import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入方法依赖的package包/类
@Override
public void initialize() {
    //Allocate a pixmap big enough to accommodate four banks of pattern
    //tables (bg and spr each for all four banks)
    patternTablePixmap = new Pixmap(128, 1024, Pixmap.Format.RGBA8888);
    //Set blending to none so we can rewrite the pixmap and draw it to the
    //pattern table texture when graphics are regenerated.
    patternTablePixmap.setBlending(Pixmap.Blending.None);

    //Allocate a pixmap the size of one tile for live CHR-RAM updates.
    patternPixmap = new Pixmap(8, 8, Pixmap.Format.RGBA8888);
    patternPixmap.setBlending(Pixmap.Blending.None);

    patternTableTexture = new Texture(patternTablePixmap, false);
    TextureRegion[][] textureRegions = TextureRegion.split(patternTableTexture, 8, 8);
    patternTableSprites = new Sprite[128][16];
    for(int row = 0; row < 128; row++) {
        for(int column = 0; column < 16; column++) {
            TextureRegion textureRegion = textureRegions[row][column];
            patternTableSprites[row][column] = new Sprite(textureRegion);
        }
    }
    initializeMonochromePalette();
}
 
开发者ID:gradualgames,项目名称:ggvm,代码行数:25,代码来源:ChrRamPatternTableManager.java

示例2: initialize

import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入方法依赖的package包/类
/**
 * Initializes the pattern table textures and pixmap.
 */
public void initialize() {
    //Allocate a pixmap big enough to accommodate both pattern tables.
    patternTablePixmap = new Pixmap(128, 256, Pixmap.Format.RGBA8888);
    //Set blending to none so we can rewrite the pixmap and draw it to the
    //pattern table texture when graphics are regenerated.
    patternTablePixmap.setBlending(Pixmap.Blending.None);

    //Allocate a pixmap the size of one tile for live CHR-RAM updates.
    patternPixmap = new Pixmap(8, 8, Pixmap.Format.RGBA8888);
    patternPixmap.setBlending(Pixmap.Blending.None);

    patternTableTexture = new Texture(patternTablePixmap, false);
    TextureRegion[][] textureRegions = TextureRegion.split(patternTableTexture, 8, 8);
    patternTableSprites = new Sprite[32][16];
    for(int row = 0; row < 32; row++) {
        for(int column = 0; column < 16; column++) {
            TextureRegion textureRegion = textureRegions[row][column];
            patternTableSprites[row][column] = new Sprite(textureRegion);
        }
    }
    initializeMonochromePalette();
}
 
开发者ID:gradualgames,项目名称:ggvm,代码行数:26,代码来源:PatternTableManager.java

示例3: createAnimationFromTexture

import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入方法依赖的package包/类
public static Animation<TextureRegion> createAnimationFromTexture(Texture texture, float duration, int rows,
        int cols) {
    // split texture into texture regions
    TextureRegion[][] tmp = TextureRegion.split(texture, texture.getWidth() / cols, texture.getHeight() / rows);

    TextureRegion[] frames = new TextureRegion[cols * rows];
    int index = 0;

    for (int i = 0; i < rows; i++) {
        for (int j = 0; j < cols; j++) {
            frames[index++] = tmp[i][j];
        }
    }

    // create new animation
    Animation<TextureRegion> animation = new Animation<TextureRegion>(duration, frames);

    return animation;

}
 
开发者ID:opensourcegamedev,项目名称:SpaceChaos,代码行数:21,代码来源:AnimationTextureUtils.java

示例4: Create

import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入方法依赖的package包/类
/**
 * @param color
 *            0 - blue; 1 - red; 2 - green; 3 - yellow
 */
public static Entity Create(Vector2 position, int color, int maxhp, Component... Ves) {
	if (color < 0 || color > 3) {
		throw new IllegalArgumentException("Color of the enemy (sprite) should be between 0 and 3!");
	}
	Entity entity = Entity.Create();
	Transform transform = new Transform(position, new Vector2(0.5f, 0.5f));
	entity.AddComponent(transform);
	BaseSprite component = new BaseSprite();
	component.selfColor = color;
	component.animation = new AnimationDrawable();
	if (texture != ResourceManager.enemies.get(0)) {
		texture = ResourceManager.enemies.get(0);
		regions = TextureRegion.split(texture, texture.getWidth() / 12, texture.getHeight() / 4);
	}
	component.animation.setAnimation(new Animation<TextureRegion>(1, regions[color]));
	EnemyHP hp = new EnemyHP(maxhp);
	entity.AddComponent(hp);
	entity.AddComponent(new EnemyJudgeCircle(48 * transform.scale.x, hp));
	entity.AddComponent(new EnemyChaseable(hp));
	entity.AddComponent(component);
	for (Component tmpc : Ves) {
		entity.AddComponent(tmpc);
	}
	return entity;
}
 
开发者ID:cn-s3bit,项目名称:TH902,代码行数:30,代码来源:BaseSprite.java

示例5: inserted

import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入方法依赖的package包/类
@Override
public void inserted(int entityId, RenderSystem renderSystem) {
    RenderComponent render = renderSystem.getMapperRender().get(entityId);
    PositionComponent position = renderSystem.getMapperPosition().get(entityId);
    if (render.animations.size == 0) {
        for (Map.Entry<String, RenderComponent.RenderTemplate.AnimationTemplate> entry : render.renderTemplate.animationTemplates.entrySet()) {
            TextureRegion texture = renderSystem.getLevelAssets().get(entry.getValue().texture);

            TextureRegion[][] tmp = texture.split(
                    +texture.getRegionWidth() / entry.getValue().frameColumns,
                    +texture.getRegionHeight() / entry.getValue().frameRows);
            TextureRegion[] frames = new TextureRegion[entry.getValue().frameColumns * entry.getValue().frameRows];
            int index = 0;
            for (int i = 0; i < entry.getValue().frameRows; i++) {
                for (int j = 0; j < entry.getValue().frameColumns; j++) {
                    frames[index++] = tmp[i][j];
                }
            }
            render.animations.put(entry.getKey(), new Animation<TextureRegion>(entry.getValue().frameDuration, new Array<>(frames), Animation.PlayMode.LOOP));
        }
    }
    Decal decal = Decal.newDecal(render.width, render.height, render.getCurrentKeyFrame(renderSystem.getStateTime()), render.transparent);
    decal.rotateX(renderSystem.getWorldDegree());
    decal.setPosition(position.position.x, position.position.y, 0);
    renderSystem.getDecalMap().put(entityId, decal);
}
 
开发者ID:EtherWorks,项目名称:arcadelegends-gg,代码行数:27,代码来源:BulletRenderer.java

示例6: Entity

import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入方法依赖的package包/类
/**
 * Creates a player and assigns a texture to it.
 * Creates an animation by splitting the given sprite sheet into an array of TILE_WIDTHxTILE_HEIGHT dimension.
 * ERROR should be 9x4 but ends up being 4x2
 * @param playerTexture
 * @param dynamicEntity
 */
public Entity(Texture playerTexture, DynamicEntity dynamicEntity) {
    int orientation = dynamicEntity.getDirection().getCode();
    TextureRegion[][] playerTextures = TextureRegion.split(playerTexture,TILE_WIDTH,TILE_HEIGHT);
    this.dynamicEntity = dynamicEntity;
    switch (orientation) {
        case Direction.UP:
            animation = new Animation<TextureRegion>(FRAME_DURATION,playerTextures[0][0], playerTextures[0][1], playerTextures[0][2],playerTextures[0][3],playerTextures[0][4]);//,playerTextures[0][5],playerTextures[0][6],playerTextures[0][7],playerTextures[0][8]);
            break;
        case Direction.DOWN:
            animation = new Animation<TextureRegion>(FRAME_DURATION,playerTextures[2][0], playerTextures[2][1], playerTextures[2][2],playerTextures[2][3],playerTextures[2][4]);//,playerTextures[0][5],playerTextures[0][6],playerTextures[0][7],playerTextures[0][8]);
            break;
        case Direction.LEFT:
            animation = new Animation<TextureRegion>(FRAME_DURATION,playerTextures[1][0], playerTextures[1][1], playerTextures[1][2],playerTextures[1][3],playerTextures[1][4]);//,playerTextures[0][5],playerTextures[0][6],playerTextures[0][7],playerTextures[0][8]);
            break;
        case Direction.RIGHT:
            animation = new Animation<TextureRegion>(FRAME_DURATION,playerTextures[3][0], playerTextures[3][1], playerTextures[3][2],playerTextures[3][3],playerTextures[3][4]);//,playerTextures[0][5],playerTextures[0][6],playerTextures[0][7],playerTextures[0][8]);
            break;
        default:
            animation = new Animation<TextureRegion>(FRAME_DURATION,playerTextures[0][0], playerTextures[0][1], playerTextures[0][2],playerTextures[0][3],playerTextures[0][4]);//,playerTextures[0][5],playerTextures[0][6],playerTextures[0][7],playerTextures[0][8]);
    }
    animation.setPlayMode(Animation.PlayMode.LOOP);
}
 
开发者ID:cderienzo,项目名称:Hackerman,代码行数:30,代码来源:Entity.java

示例7: initialize

import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入方法依赖的package包/类
public void initialize() {
	// Load SpriteSheet
	spriteSheet = new Texture(Gdx.files.internal(filePath));
	
	// Extract Sprites
	TextureRegion[][] tmp = TextureRegion.split(spriteSheet, spriteSheet.getWidth() / frameCols, spriteSheet.getHeight() / frameRows);
	
	// Place into 1D array
	animationSprites = new TextureRegion[columnCutOff * rowCutOff];
	int index = 0;
	for (int i = 0; i < rowCutOff; i++) {
		for (int j = 0; j < columnCutOff; j++) {
			animationSprites[index++] = tmp[i][j];
		}
	}
	
	// Load animation frames
	animationTextureRegion = new Animation<TextureRegion>(frameLengthTime, animationSprites);
	
}
 
开发者ID:ja-brouil,项目名称:StarshipFighters,代码行数:21,代码来源:Animator.java

示例8: init

import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入方法依赖的package包/类
public void init() {
	
	// Bullet Upgrades
	doubleBullets = false;
	tripleBullets = false;
	
	// GamePlay
	damageValue = -100;
	
	// Graphics || Might rewrite this later if it lags too much. Create a static method for this? Or have a permanent object
	// with all the variables already.
	allTexture = new Texture(Gdx.files.internal(pathname));
	TextureRegion[][] tmp = TextureRegion.split(allTexture, allTexture.getWidth() / 2, allTexture.getHeight() / 1);
	bulletTexture = new TextureRegion[1];
	bulletTexture[0] = tmp[0][0];
	
	// Rectangle
	collisionBounds = new Rectangle();
	collisionBounds.set(x, y, 4f, 9f);
	
}
 
开发者ID:ja-brouil,项目名称:StarshipFighters,代码行数:22,代码来源:PlayerBullets.java

示例9: init

import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入方法依赖的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

示例10: init

import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入方法依赖的package包/类
private void init() {
	
	// Graphics
	allTexture = new Texture(Gdx.files.internal(pathName));
	TextureRegion[][] tmp = TextureRegion.split(allTexture, allTexture.getWidth() / 2, allTexture.getHeight() / 1);
	enemyBulletTexture = new TextureRegion[2];
	enemyBulletTexture[0] = tmp[0][0];
	enemyBulletTexture[1] = tmp[0][1];
	
	// HitBox
	collisionBounds = new Rectangle(x, y, 4f, 9f);
	
	// Play Sound
	soundManager = playState.getGSM().getGame().getSoundManager();
	soundManager.addSound(enemyBulletSoundPathname, enemyBulletSoundName);
	soundManager.playSound(enemyBulletSoundName, 1f);
	
}
 
开发者ID:ja-brouil,项目名称:StarshipFighters,代码行数:19,代码来源:EnemyBullets.java

示例11: createAnimation

import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入方法依赖的package包/类
/**
 * Creates the animation used for this PowerUp Type.
 *
 * @param game the game this view belongs to. Needed to access the
 *             asset manager to get textures.
 * @param fileName the path to the file that contains the animation sheet.
 * @return the animation used for this PowerUp
 */
private Animation<TextureRegion> createAnimation(Armadillo game, String fileName) {
    Texture texture = game.getAssetManager().get(fileName);
    TextureRegion[][] regions = TextureRegion.split(texture, texture.getWidth() / NUM_FRAMES, texture.getHeight());

    TextureRegion[] frames = new TextureRegion[NUM_FRAMES];
    System.arraycopy(regions[0], 0, frames, 0, NUM_FRAMES);

    return new Animation<>(FRAME_TIME, frames);
}
 
开发者ID:AndreFCruz,项目名称:feup-lpoo-armadillo,代码行数:18,代码来源:PowerUpView.java

示例12: createObstacleDestroyedAnimation

import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入方法依赖的package包/类
private Array<TextureRegion> createObstacleDestroyedAnimation() {
    Array<TextureRegion> explosions = new Array<>();
    Texture texture = assetService.getTexture(AssetService.TextureAsset.OBSTACLE_EXPLOSION);
    TextureRegion[][] split = TextureRegion.split(texture, 64, 64);
    for (TextureRegion[] row : split) {
        for (TextureRegion region : row) {
            explosions.add(region);
        }
    }
    return explosions;
}
 
开发者ID:ezet,项目名称:penguins-in-space,代码行数:12,代码来源:AnimationFactory.java

示例13: createShortExplosion

import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入方法依赖的package包/类
private Array<TextureRegion> createShortExplosion() {
    Array<TextureRegion> explosions = new Array<>();
    Texture texture = assetService.getTexture(AssetService.TextureAsset.BOMB_EXPLOSION);
    TextureRegion[][] split = TextureRegion.split(texture, 128, 128);
    for (TextureRegion[] row : split) {
        for (TextureRegion region : row) {
            explosions.add(region);
            explosions.add(region);
        }
    }
    return explosions;
}
 
开发者ID:ezet,项目名称:penguins-in-space,代码行数:13,代码来源:AnimationFactory.java

示例14: createLongExplosion

import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入方法依赖的package包/类
private Array<TextureRegion> createLongExplosion() {
    Array<TextureRegion> explosions = new Array<>();
    Texture texture = assetService.getTexture(AssetService.TextureAsset.EXPLOSION);
    TextureRegion[][] split = TextureRegion.split(texture, 100, 100);
    for (TextureRegion[] row : split) {
        for (TextureRegion region : row) {
            explosions.add(region);
        }
    }
    return explosions;
}
 
开发者ID:ezet,项目名称:penguins-in-space,代码行数:12,代码来源:AnimationFactory.java

示例15: PlayerReimu

import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入方法依赖的package包/类
public PlayerReimu(int type) {
	mType = type;
	Texture texture = ResourceManager.textures.get("Reimu");
	TextureRegion[][] splitted = TextureRegion.split(texture, texture.getWidth() / 8, texture.getHeight() / 3);
	animationStay = new Animation<TextureRegion>(5, splitted[0]);
	animationStay.setPlayMode(PlayMode.LOOP);
	animationLeft = new Animation<TextureRegion>(4, splitted[1]);
	animationLeft.setPlayMode(PlayMode.LOOP);
	animationRight = new Animation<TextureRegion>(4, splitted[2]);
	animationRight.setPlayMode(PlayMode.LOOP);
}
 
开发者ID:cn-s3bit,项目名称:TH902,代码行数:12,代码来源:PlayerReimu.java


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