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


Java TextureAtlas类代码示例

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


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

示例1: addSpriteFrameWithTextureAtlas

import com.badlogic.gdx.graphics.g2d.TextureAtlas; //导入依赖的package包/类
/**
 * 读取gdx textureAtlas文件
 * @param filePath atlas 文件路径 也可以自定义
 * @param atlas
 */
public void addSpriteFrameWithTextureAtlas(String filePath, TextureAtlas atlas) {
	if(_atlases.containsKey(filePath)) {
		CCLog.debug(this.getClass(), "file loaded : " + filePath);
		return;
	}
	
	_atlases.put(filePath, atlas);
	
	Array<AtlasRegion> rs = atlas.getRegions();
	for(AtlasRegion r : rs) {
		TextureRegion ret = _spriteFrames.put(r.name, r);
		if(ret != null) {
			CCLog.debug(this.getClass(), "region name exists : " + r.name);
		}
	}
}
 
开发者ID:mingwuyun,项目名称:cocos2d-java,代码行数:22,代码来源:SpriteFrameCache.java

示例2: extractImage

import com.badlogic.gdx.graphics.g2d.TextureAtlas; //导入依赖的package包/类
public BufferedImage extractImage(TextureAtlas.TextureAtlasData atlas, String regionName, int[] splits) {
    for (TextureAtlas.TextureAtlasData.Region region : atlas.getRegions()) {
        if(region.name.equals(regionName)) {
            TextureAtlas.TextureAtlasData.Page page = region.page;
            BufferedImage img = null;
            try {
                img = ImageIO.read(page.textureFile.file());
            } catch (IOException e) {

            }
            region.splits = splits;
            return extractNinePatch(img, region);
        }
    }
    return null;
}
 
开发者ID:whitecostume,项目名称:libgdx_ui_editor,代码行数:17,代码来源:ImageUtils.java

示例3: extractNinePatch

import com.badlogic.gdx.graphics.g2d.TextureAtlas; //导入依赖的package包/类
private BufferedImage extractNinePatch (BufferedImage page, TextureAtlas.TextureAtlasData.Region region) {
    BufferedImage splitImage = extractImage(page, region, NINEPATCH_PADDING);
    Graphics2D g2 = splitImage.createGraphics();
    g2.setColor(Color.BLACK);

    // Draw the four lines to save the ninepatch's padding and splits
    int startX = region.splits[0] + NINEPATCH_PADDING;
    int endX = region.width - region.splits[1] + NINEPATCH_PADDING - 1;
    int startY = region.splits[2] + NINEPATCH_PADDING;
    int endY = region.height - region.splits[3] + NINEPATCH_PADDING - 1;
    if (endX >= startX) g2.drawLine(startX, 0, endX, 0);
    if (endY >= startY) g2.drawLine(0, startY, 0, endY);
    if (region.pads != null) {
        int padStartX = region.pads[0] + NINEPATCH_PADDING;
        int padEndX = region.width - region.pads[1] + NINEPATCH_PADDING - 1;
        int padStartY = region.pads[2] + NINEPATCH_PADDING;
        int padEndY = region.height - region.pads[3] + NINEPATCH_PADDING - 1;
        g2.drawLine(padStartX, splitImage.getHeight() - 1, padEndX, splitImage.getHeight() - 1);
        g2.drawLine(splitImage.getWidth() - 1, padStartY, splitImage.getWidth() - 1, padEndY);
    }
    g2.dispose();

    return splitImage;
}
 
开发者ID:whitecostume,项目名称:libgdx_ui_editor,代码行数:25,代码来源:ImageUtils.java

示例4: createCachedAnimations

import com.badlogic.gdx.graphics.g2d.TextureAtlas; //导入依赖的package包/类
protected void createCachedAnimations(Map<String, Integer> map) {
    int i = 0;

    for (Map.Entry<String, Integer> entry : map.entrySet()) {
        String animationName = entry.getKey();
        int frameCounter = entry.getValue();

        // calculate duration per frame
        float durationPerFrame = this.sumDuration / frameCounter;

        // get regions
        Array<TextureAtlas.AtlasRegion> regions = this.atlas.findRegions(animationName);

        // create animation
        Animation<TextureRegion> anim = new Animation<>(durationPerFrame, regions, Animation.PlayMode.LOOP);

        // add animation to map
        this.animationMap.put(animationName, anim);

        i++;
    }
}
 
开发者ID:opensourcegamedev,项目名称:SpaceChaos,代码行数:23,代码来源:AtlasAnimationComponent.java

示例5: create

import com.badlogic.gdx.graphics.g2d.TextureAtlas; //导入依赖的package包/类
@Override
public void create () {
	entityAtlas = new TextureAtlas("sprites/entities.txt");
	tileAtlas = new TextureAtlas("sprites/tiles.txt");
	tileConnectionAtlas = new TextureAtlas("sprites/tileconnectmap.txt");
	iconAtlas = new TextureAtlas("sprites/icons.txt");
	batch = new SpriteBatch();
	font = new BitmapFont(); // uses libGDX's default Arial font
	
	for(AtlasRegion region: iconAtlas.getRegions())
		icons.put(region.name, region);
	
	game = this;
	
	this.setScreen(new MainMenuScreen());
}
 
开发者ID:chrisj42,项目名称:miniventure,代码行数:17,代码来源:GameCore.java

示例6: create

import com.badlogic.gdx.graphics.g2d.TextureAtlas; //导入依赖的package包/类
@Override
public void create() {
    batch = new SpriteBatch();

    font = new BitmapFont();
    font.setColor(0, 0, 1, 1);

    // Origin
    TextureAtlas originTextureAtlas = new TextureAtlas(ORIGIN_PATH + "/test.atlas");
    Skin originSkin = new Skin(originTextureAtlas);
    originTextureRegion = originSkin.getRegion("badlogic");

    // Encrypt
    SimpleXorCryptoEncryptor.process("123", "atlas", "encryptedAtlas");

    // Decrypt
    CryptTextureAtlas cryptTextureAtlas = new CryptTextureAtlas(crypto, ENCRYPTED_PATH + "/test.atlas");
    Skin skin = new Skin(cryptTextureAtlas);
    decryptTextureRegion = skin.getRegion("badlogic");
}
 
开发者ID:akivamu,项目名称:libgdx-crypt-texture,代码行数:21,代码来源:TestCryptTextureAtlas.java

示例7: initEntities

import com.badlogic.gdx.graphics.g2d.TextureAtlas; //导入依赖的package包/类
private void initEntities(TextureAtlas textureAtlas) {
    final float mobWidth = Polymorph.WORLD_WIDTH/4;
    player = new Player(new Vector2(Polymorph.WORLD_WIDTH/2 - mobWidth/2, Polymorph.WORLD_HEIGHT/3-mobWidth),
                        new Dimension(mobWidth, mobWidth));

    slots = new Array<Slot>();
    slotPool = new Pool<Slot>() {
        @Override
        protected Slot newObject() {
            return new Slot(new Vector2(SLOT_SPAWN_POINT),
                            new Vector2(slotVelocity),
                            new Dimension(mobWidth, mobWidth));
        }
    };

    Dimension mapSize = new Dimension(Polymorph.WORLD_WIDTH, (int)(Polymorph.WORLD_HEIGHT*1.1f));
    TextureRegion mapTexture = textureAtlas.findRegion("background");
    Map mapFront = new Map(new Vector2(0, 0), mapVelocity, mapSize, mapTexture);
    Map mapBack = new Map(new Vector2(0, -mapSize.height + 5), mapVelocity, mapSize, mapTexture);
    maps = new Map[]{mapFront, mapBack};
}
 
开发者ID:DurianHLN,项目名称:Polymorph,代码行数:22,代码来源:PolyGame.java

示例8: loadAssets

import com.badlogic.gdx.graphics.g2d.TextureAtlas; //导入依赖的package包/类
private void loadAssets() {
    InternalFileHandleResolver fileHandler = new InternalFileHandleResolver();
    assetManager = new AssetManager(fileHandler);
    assetManager.setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(fileHandler));

    assetManager.load(SKIN_PATH, Skin.class);
    assetManager.load(MASTER_PATH, TextureAtlas.class);
    assetManager.load(FONT_NORMAL_PATH, FreeTypeFontGenerator.class);
    assetManager.load(FONT_BOLD_PATH, FreeTypeFontGenerator.class);
    assetManager.load(MUSIC_PATH, Music.class);
    assetManager.load(MAIN_MENU_MUSIC_PATH, Music.class);
    assetManager.load(GOOD_PATH, Sound.class);
    assetManager.load(HALF_PATH, Sound.class);
    assetManager.load(BAD_PATH, Sound.class);
    assetManager.finishLoading();
}
 
开发者ID:DurianHLN,项目名称:Polymorph,代码行数:17,代码来源:Polymorph.java

示例9: DeathScreen

import com.badlogic.gdx.graphics.g2d.TextureAtlas; //导入依赖的package包/类
public DeathScreen(Polymorph polymorph,int playerscore) {
    AssetManager assetManager = polymorph.getAssetManager();
    TextureAtlas textureAtlas = assetManager.get(Polymorph.MASTER_PATH, TextureAtlas.class);
    this.polymorph = polymorph;
    score=playerscore;

    DeathScreenMusic = assetManager.get(Polymorph.MAIN_MENU_MUSIC_PATH);
    DeathScreenMusic.setLooping(true);

    background = textureAtlas.findRegion("mainmenu"); //TODO make a unique background for the death screen
    screenSize = new Dimension(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

    camera = new OrthographicCamera();
    camera.setToOrtho(false, screenSize.width, screenSize.height); //change this
    batch=new SpriteBatch();
    batch.setProjectionMatrix(camera.combined);

    stage = new Stage();
    stage.clear();
    font = new BitmapFont(false);

    textureAtlas = assetManager.get(Polymorph.MASTER_PATH, TextureAtlas.class);
    initButtons(score,textureAtlas);
    Gdx.input.setInputProcessor(stage);

}
 
开发者ID:DurianHLN,项目名称:Polymorph,代码行数:27,代码来源:DeathScreen.java

示例10: initButtons

import com.badlogic.gdx.graphics.g2d.TextureAtlas; //导入依赖的package包/类
public void initButtons(int score,TextureAtlas buttonAtlas) {
    Skin buttonSkin = new Skin();
    buttonSkin.addRegions(buttonAtlas);

    //TODO FIX THIS SHIT INDENTATION
    //TODO Long-term fix the magic numbers
    ImageButton playButton = new ImageButton(buttonSkin.getDrawable("playbutton"),
    		                                                        buttonSkin.getDrawable("playbutton"));
    playButton.setSize(256, 64);
    playButton.setPosition(screenSize.width/2-playButton.getWidth()/2,
    		               screenSize.height/2-playButton.getHeight()/2+50);
    playButton.addListener(new InputListener() {

    	@Override
    	public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
    		polymorph.setScreen(new GameScreen(polymorph));
    		DeathScreenMusic.stop();
    		return true;
    	}
    });

    stage.addActor(playButton);

}
 
开发者ID:DurianHLN,项目名称:Polymorph,代码行数:25,代码来源:DeathScreen.java

示例11: initHud

import com.badlogic.gdx.graphics.g2d.TextureAtlas; //导入依赖的package包/类
private void initHud() {
    hud = new Stage(viewport, batch);
    Gdx.input.setInputProcessor(new InputMultiplexer(new KeyboardInputHandler(), hud));

    //init widgets
    ColorButton[] colorButtons = createColorButtons();
    final ShapeButton[] shapeButtons = createShapeButtons(colorButtons);

    // add widgets to stage
    for (ShapeButton shapeButton : shapeButtons) {
        hud.addActor(shapeButton);
    }
    for (ColorButton colorButton : colorButtons) {
        hud.addActor(colorButton);
    }

    TextureAtlas textureAtlas = polymorph.getAssetManager().get(Polymorph.MASTER_PATH, TextureAtlas.class);
    hud.addActor(createHealthBar(textureAtlas));
    hud.addActor(createPauseButton(textureAtlas));
}
 
开发者ID:DurianHLN,项目名称:Polymorph,代码行数:21,代码来源:GameScreen.java

示例12: getDependencies

import com.badlogic.gdx.graphics.g2d.TextureAtlas; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public Array<AssetDescriptor> getDependencies(String fileName, FileHandle tmxFile,
		com.badlogic.gdx.maps.tiled.AtlasTmxMapLoader.AtlasTiledMapLoaderParameters parameter) {
	Array<AssetDescriptor> dependencies = new Array<AssetDescriptor>();
	try {
		root = xml.parse(tmxFile);

		Element properties = root.getChildByName("properties");
		if (properties != null) {
			for (Element property : properties.getChildrenByName("property")) {
				String name = property.getAttribute("name");
				String value = property.getAttribute("value");
				if (name.startsWith("atlas")) {
					FileHandle atlasHandle = Gdx.files.internal(value);
					dependencies.add(new AssetDescriptor(atlasHandle, TextureAtlas.class));
				}
			}
		}
	} catch (IOException e) {
		throw new GdxRuntimeException("Unable to parse .tmx file.");
	}
	return dependencies;
}
 
开发者ID:kyperbelt,项目名称:KyperBox,代码行数:25,代码来源:KyperMapLoader.java

示例13: onInit

import com.badlogic.gdx.graphics.g2d.TextureAtlas; //导入依赖的package包/类
/**
 * Inititalisiert den NPC.
 * Lädt alle Grafiken und Animationen.
 */
@Override
public void onInit()
{
    super.onInit();

    stoneAtlas = new TextureAtlas(Gdx.files.internal("data/graphics/packed/stone.atlas"));
    bigStone = stoneAtlas.findRegion("stone_big");

    if (rawObject instanceof RectangleMapObject)
    {
        RectangleMapObject rectObject = (RectangleMapObject) rawObject;
        Rectangle rect = rectObject.getRectangle();

        position = new Vector2(rect.getX() + rect.getWidth() / 2f, rect.getY());
        startPosition = new Vector2(rect.getX(), rect.getY());
        rectShape = Physics.createRectangle(rect.getWidth(), rect.getHeight(), new Vector2(rect.getWidth() / 2f, rect.getHeight() / 2f));

        if (activate)
            body = createEntityBody(startPosition, rectShape, BodyDef.BodyType.KinematicBody);

    } else {
        Gdx.app.log("WARNING", "Stone Barrier " + objectId + " must have an RectangleMapObject!");
        worldObjectManager.removeObject(this);
    }
}
 
开发者ID:Entwicklerpages,项目名称:school-game,代码行数:30,代码来源:StoneBarrier.java

示例14: init

import com.badlogic.gdx.graphics.g2d.TextureAtlas; //导入依赖的package包/类
private void init() {
	mSkillAtlas = MyGdxGame.assetManager.getTextureAtlas(Constant.FIREBALL_WIDGET);

	//升龙斩动画初始化
	mRJumpAtkRegions = new TextureAtlas.AtlasRegion[4];
	for (int i = 0; i < mRJumpAtkRegions.length - 1; i++) {
		mRJumpAtkRegions[i] = new TextureAtlas.AtlasRegion(mSkillAtlas.findRegion("jumpHit" + (i + 1)));
	}
	mRJumpAtkRegions[3] = new TextureAtlas.AtlasRegion(mSkillAtlas.findRegion("jumpHit3"));
	mLJumpAtkRegions = new TextureAtlas.AtlasRegion[4];
	for (int i = 0; i < mLJumpAtkRegions.length - 1; i++) {
		mLJumpAtkRegions[i] = new TextureAtlas.AtlasRegion(mSkillAtlas.findRegion("jumpHit" + (i + 1)));
		mLJumpAtkRegions[i].flip(true, false);
	}
	mLJumpAtkRegions[3] = mLJumpAtkRegions[2];
	mRJumpAtkAni = new Animation(1 / 12f, mRJumpAtkRegions);
	mLJumpAtkAni = new Animation(1 / 12f, mLJumpAtkRegions);
}
 
开发者ID:heyzqt,项目名称:libGdx-xiyou,代码行数:19,代码来源:JumpBall.java

示例15: create

import com.badlogic.gdx.graphics.g2d.TextureAtlas; //导入依赖的package包/类
@Override
public void create () {
    atlas = new TextureAtlas(Gdx.files.internal("LePendu.pack"));
    batch = new SpriteBatch();

    try {
        fileHandle  = Gdx.files.internal("dictionnaires/facile.txt");
        reader      = new BufferedReader(fileHandle.reader());
        while ((line = reader.readLine()) != null) easyWords.add(line);

        fileHandle  = Gdx.files.internal("dictionnaires/normal.txt");
        reader      = new BufferedReader(fileHandle.reader());
        while ((line = reader.readLine()) != null) normalWords.add(line);

        fileHandle  = Gdx.files.internal("dictionnaires/difficile.txt");
        reader      = new BufferedReader(fileHandle.reader());
        while ((line = reader.readLine()) != null) hardWords.add(line);
    } catch (IOException e) {
        System.out.println("Chargement des dictionnaires impossible !");
        System.out.println(e.getMessage());
        Gdx.app.exit();
    }

    setScreen(new MenuScreen(this));
}
 
开发者ID:Frappagames,项目名称:le-pendu,代码行数:26,代码来源:LePendu.java


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