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


Java TextureRegionFactory类代码示例

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


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

示例1: SplashScene

import org.andengine.opengl.texture.region.TextureRegionFactory; //导入依赖的package包/类
public SplashScene(TextureManager textureManager, AssetManager assetManager, VertexBufferObjectManager vbo, Camera camera) {
    super();
    this.setBackground(new Background(new Color(100, 100, 100)));
    try {
        splashTexture = new AssetBitmapTexture(textureManager, assetManager, "textures/splash.png", TextureOptions.BILINEAR);
        splashTextureRegion = TextureRegionFactory.extractFromTexture(splashTexture);
        splashTexture.load();
        splash = new Sprite(0, 0, splashTextureRegion, vbo);

        final float scale_factor = GameActivity.CAMERA_HEIGHT / splashTextureRegion.getHeight();
        splash.setScale(scale_factor+0.1f);
        splash.setPosition((camera.getWidth()) * 0.5f, (camera.getHeight()) * 0.5f);
        this.attachChild(splash);
    } catch (final IOException e) {
        System.err.println("Error loading splash!");
        e.printStackTrace(System.err);
    }
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:19,代码来源:SplashScene.java

示例2: loadLocaleGames

import org.andengine.opengl.texture.region.TextureRegionFactory; //导入依赖的package包/类
private void loadLocaleGames() throws IOException {
    List<Game> blockGames = locale.games;
    try {
        // Load game assets
        for (int i = 0; i < blockGames.size(); i++) {
            Game game = blockGames.get(i);
            Debug.d("Loading game sprite texture from " + game.sprite_texture);
            final AssetBitmapTexture gameSpriteTexture = new AssetBitmapTexture(PhoeniciaContext.textureManager, PhoeniciaContext.assetManager, game.sprite_texture);
            gameSpriteTexture.load();
            this.gameTextures.put(game, gameSpriteTexture);
            this.gameSprites.put(game, TextureRegionFactory.extractTiledFromTexture(gameSpriteTexture, 0, 0, GAME_SPRITE_WIDTH * GAME_SPRITE_COLS, GAME_SPRITE_HEIGHT * GAME_SPRITE_ROWS, GAME_SPRITE_COLS, GAME_SPRITE_ROWS));

            Debug.d("Loading game block texture from " + game.block_texture);
            final AssetBitmapTexture gameTexture = new AssetBitmapTexture(PhoeniciaContext.textureManager, PhoeniciaContext.assetManager, game.block_texture);
            gameTexture.load();
            int[] gameTileSize = GameTextures.calculateTileSize(game.columns, game.rows, game.height);
            Debug.d("Word "+game.name+" has size "+game.columns+"x"+game.rows+" and sprite size "+gameTileSize[0]+"x"+gameTileSize[1]);
            this.gameBlocks.put(game, TextureRegionFactory.extractTiledFromTexture(gameTexture, 0, 0, gameTileSize[0] * GAME_TEXTURE_COLS, gameTileSize[1] * GAME_TEXTURE_ROWS, GAME_TEXTURE_COLS, GAME_TEXTURE_ROWS));
        }

    } catch (final IOException e)
    {
        e.printStackTrace();
        throw e;
    }
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:27,代码来源:PhoeniciaGame.java

示例3: loadLocaleDecorations

import org.andengine.opengl.texture.region.TextureRegionFactory; //导入依赖的package包/类
private void loadLocaleDecorations() throws IOException {
    List<Decoration> blockDecorations = locale.decorations;
    try {
        // Load game assets
        for (int i = 0; i < blockDecorations.size(); i++) {
            Decoration decoration = blockDecorations.get(i);
            Debug.d("Loading decoration sprite texture from " + decoration.sprite_texture);
            final AssetBitmapTexture decorationSpriteTexture = new AssetBitmapTexture(PhoeniciaContext.textureManager, PhoeniciaContext.assetManager, decoration.sprite_texture);
            decorationSpriteTexture.load();
            this.decorationTextures.put(decoration, decorationSpriteTexture);
            this.decorationSprites.put(decoration, TextureRegionFactory.extractTiledFromTexture(decorationSpriteTexture, 0, 0, DECORATION_SPRITE_WIDTH * DECORATION_SPRITE_COLS, DECORATION_SPRITE_HEIGHT * DECORATION_SPRITE_ROWS, DECORATION_SPRITE_COLS, DECORATION_SPRITE_ROWS));

            Debug.d("Loading decoration block texture from " + decoration.block_texture);
            final AssetBitmapTexture decorationTexture = new AssetBitmapTexture(PhoeniciaContext.textureManager, PhoeniciaContext.assetManager, decoration.block_texture);
            decorationTexture.load();
            int[] decorationTileSize = GameTextures.calculateTileSize(decoration.columns, decoration.rows, decoration.height);
            Debug.d("Word "+decoration.name+" has size "+decoration.columns+"x"+decoration.rows+" and sprite size "+decorationTileSize[0]+"x"+decorationTileSize[1]);
            this.decorationBlocks.put(decoration, TextureRegionFactory.extractTiledFromTexture(decorationTexture, 0, 0, decorationTileSize[0] * DECORATION_TEXTURE_COLS, decorationTileSize[1] * DECORATION_TEXTURE_ROWS, DECORATION_TEXTURE_COLS, DECORATION_TEXTURE_ROWS));
        }

    } catch (final IOException e)
    {
        e.printStackTrace();
        throw e;
    }
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:27,代码来源:PhoeniciaGame.java

示例4: getTextureFromAsset

import org.andengine.opengl.texture.region.TextureRegionFactory; //导入依赖的package包/类
private TextureRegion getTextureFromAsset(final String path) {
    try {
        texture = new BitmapTexture(engine.getTextureManager(), new IInputStreamOpener() {
            @Override
            public InputStream open() throws IOException {
                return context.getAssets().open("gfx/" + path); // path of the image
            }
        }, TextureOptions.BILINEAR);
        texture.load();
        return TextureRegionFactory.extractFromTexture(texture);
    } catch (IOException e) {
        e.printStackTrace();
        Log.e(ASSETS_ERROR_TAG, e.toString());
    }
    return null;
}
 
开发者ID:viniciusDSL,项目名称:One-Cachito,代码行数:17,代码来源:ResourceManager.java

示例5: getTiledTextureFromAsset

import org.andengine.opengl.texture.region.TextureRegionFactory; //导入依赖的package包/类
private TiledTextureRegion getTiledTextureFromAsset(final String path, int rows, int columns) {
    try {
        texture = new BitmapTexture(engine.getTextureManager(), new IInputStreamOpener() {
            @Override
            public InputStream open() throws IOException {
                return context.getAssets().open("gfx/" + path); // path of the image
            }
        }, TextureOptions.BILINEAR);
        texture.load();
        return TextureRegionFactory.extractTiledFromTexture(texture, rows, columns);
    } catch (IOException e) {
        e.printStackTrace();
        Log.e(ASSETS_ERROR_TAG, e.toString());
    }
    return null;
}
 
开发者ID:viniciusDSL,项目名称:One-Cachito,代码行数:17,代码来源:ResourceManager.java

示例6: populateScene

import org.andengine.opengl.texture.region.TextureRegionFactory; //导入依赖的package包/类
@Override
public void populateScene() {
    AbstractGameActivity activity = getActivity();
    if (activity == null) {
        return;
    }
    ResourcesManager resourcesManager = activity.getResourcesManager();
    try {
        resourcesManager.uploadTexture("gfx/splash.jpg");
    } catch (IOException e) {
        return;
    }
    TextureRegion splashRegion = TextureRegionFactory.extractFromTexture(
            resourcesManager.getTexture("gfx/splash.jpg"));
    mSplash = new Sprite(0, 0, splashRegion, resourcesManager.getVertexBufferObjectManager()) {
        @Override
        protected void preDraw(GLState pGLState, Camera pCamera) {
            super.preDraw(pGLState, pCamera);
            pGLState.enableDither();
        }
    };

    mSplash.setPosition(activity.getCameraWidth() / 2, activity.getCameraHeight() / 2);
    attachChild(mSplash);
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:26,代码来源:SplashScene.java

示例7: createBackground

import org.andengine.opengl.texture.region.TextureRegionFactory; //导入依赖的package包/类
private void createBackground() {
    Logger.log(TAG, "creating menu background");
    AbstractGameActivity activity = getActivity();
    if (activity == null) {
        return;
    }
    ResourcesManager manager = activity.getResourcesManager();
    TextureRegion region = TextureRegionFactory.extractFromTexture(manager.getTexture("gfx/menu_background.jpg"));
    attachChild(new Sprite(activity.getCameraWidth() / 2, activity.getCameraHeight() / 2,
            region, manager.getVertexBufferObjectManager()) {
        @Override
        protected void preDraw(GLState pGLState, Camera pCamera) {
            super.preDraw(pGLState, pCamera);
            pGLState.enableDither();
        }
    });
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:18,代码来源:GameMenuScene.java

示例8: onCreateScene

import org.andengine.opengl.texture.region.TextureRegionFactory; //导入依赖的package包/类
@Override
protected Scene onCreateScene() {
    Logger.log(TAG, "onCreateScene");
    Scene scene = new Scene();
    ITexture background = mResources.getTexture("background.jpg");
    ITextureRegion region = TextureRegionFactory.extractFromTexture(background);
    Logger.log(TAG, "region: x - " + region.getTextureX() + "; y - " + region.getTextureY() +
            "; width - " + region.getWidth() + "; height - " + region.getHeight());
    Sprite backgroundSprite = new Sprite(CAMERA_WIDTH / 2, CAMERA_HEIGHT / 2, region, getVertexBufferObjectManager());
    scene.attachChild(backgroundSprite);

    ITexture fish = mResources.getTexture("fish.png");
    ITextureRegion fishRegion = TextureRegionFactory.extractFromTexture(fish);
    Sprite fishSprite = new Sprite(CAMERA_WIDTH / 2, CAMERA_HEIGHT / 2, fishRegion, getVertexBufferObjectManager());
    scene.attachChild(fishSprite);

    return scene;
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:19,代码来源:GameActivity.java

示例9: getTexture

import org.andengine.opengl.texture.region.TextureRegionFactory; //导入依赖的package包/类
TextureRegion getTexture(final String path) {

        try {
            ITexture texture = new BitmapTexture(textureManager, new IInputStreamOpener() {

                        @Override
                        public InputStream open() throws IOException {

                            return assetManager.open(path);
                        }
                    }, TextureOptions.BILINEAR);

            return TextureRegionFactory.extractFromTexture(texture);
        } catch (IOException e) {
            e.printStackTrace();
        }

        return null;
    }
 
开发者ID:djschilling,项目名称:sopa,代码行数:20,代码来源:ResourceLoader.java

示例10: drawActiveBar

import org.andengine.opengl.texture.region.TextureRegionFactory; //导入依赖的package包/类
/**
 * Draws the volume bar (only thr active colored part).
 */
public void drawActiveBar() {
    int xPartShown;
    
    // Clean memory if the texture is loaded:
    if(shownBarTR!=null) {
        if(shownBarTR.getTexture().isLoadedToHardware()) {
            //shownBarTR.getTexture().unload();
            shownBarTR = null;
            shownBar.detachSelf();
        }
    }
    // Calculates the pixels that must be shown:
    xPartShown = Math.round(value * texture_width / VALUE_MAX);
    // Load texture showing only the part on the left of value:
    shownBarTR = TextureRegionFactory.extractFromTexture(
            ResourceManager.getInstance().mainOptionsSoundBarsActive.getTexture(),
            0, 0, xPartShown, texture_height, false);
    shownBar = new Sprite(
            x - texture_width/2 + shownBarTR.getWidth()/2, y,
            shownBarTR,
            ResourceManager.getInstance().engine.getVertexBufferObjectManager());
    attachChild(shownBar);
}
 
开发者ID:jjhaggar,项目名称:ninja-trials,代码行数:27,代码来源:VolumeBar.java

示例11: loadRecordsResources

import org.andengine.opengl.texture.region.TextureRegionFactory; //导入依赖的package包/类
public synchronized void loadRecordsResources() {
    BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/results/");

    BitmapTextureAtlas recordHeadsT = new BitmapTextureAtlas(this.textureManager, 100, 100,
            mTransparentTextureOption);
    BitmapTextureAtlasTextureRegionFactory.createFromAsset(
            recordHeadsT, this.activity, "results_records_winner_faces.png", 0, 0);
    recordHeadsT.load();

    menuRecordsRyokoHead = TextureRegionFactory.
            extractFromTexture(recordHeadsT, 0, 0, 50, 50, false);

    menuRecordsRyokoHeadGold = TextureRegionFactory.
            extractFromTexture(recordHeadsT, 0, 50, 50, 50, false);

    menuRecordsShoHead = TextureRegionFactory.
            extractFromTexture(recordHeadsT, 50, 0, 50, 50, false);

    menuRecordsShoHeadGold = TextureRegionFactory.
            extractFromTexture(recordHeadsT, 50, 50, 50, 50, false);
}
 
开发者ID:jjhaggar,项目名称:ninja-trials,代码行数:22,代码来源:ResourceManager.java

示例12: setSpotlight

import org.andengine.opengl.texture.region.TextureRegionFactory; //导入依赖的package包/类
public void setSpotlight(String texture) {
    try {
        final AssetBitmapTexture spotlight_texture = new AssetBitmapTexture(PhoeniciaContext.textureManager, PhoeniciaContext.assetManager, texture);
        spotlight_texture.load();
        TextureRegion spotlight_region = TextureRegionFactory.extractFromTexture(spotlight_texture);
        this.clearSpotlight();
        this.spotlight = new Sprite(this.getWidth()/2, this.getHeight()/2, spotlight_region, PhoeniciaContext.vboManager);
        this.spotlight.setZIndex(this.guideSprite.getZIndex()-1);
        this.attachChild(this.spotlight);
        this.sortChildren();
    } catch (IOException e) {
        Debug.e("Failed to load spotlight texture: "+texture);
    }
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:15,代码来源:TourOverlay.java

示例13: LoadingScene

import org.andengine.opengl.texture.region.TextureRegionFactory; //导入依赖的package包/类
public LoadingScene(PhoeniciaGame game) {
    super();
    this.game = game;
    this.setBackground(new Background(new Color(100, 100, 100)));
    try {
        AssetBitmapTexture splashTexture = new AssetBitmapTexture(PhoeniciaContext.textureManager, PhoeniciaContext.assetManager, "textures/loading.png", TextureOptions.BILINEAR);
        splashTextureRegion = TextureRegionFactory.extractFromTexture(splashTexture);
        splashTexture.load();
        splash = new Sprite(0, 0, splashTextureRegion, PhoeniciaContext.vboManager);

        final float scale_factor = (GameActivity.CAMERA_HEIGHT / splashTextureRegion.getHeight()) + 0.1f;
        splash.setScale(scale_factor);
        splash.setPosition((GameActivity.CAMERA_WIDTH) * 0.5f, (GameActivity.CAMERA_HEIGHT) * 0.5f);
        this.attachChild(splash);

        AssetBitmapTexture progressbarTexture = new AssetBitmapTexture(PhoeniciaContext.textureManager, PhoeniciaContext.assetManager, "textures/progressbar.png", TextureOptions.BILINEAR);
        progressbarTexture.load();
        progressbarTextureRegion = TextureRegionFactory.extractFromTexture(progressbarTexture);
        progress = new ProgressBar((GameActivity.CAMERA_WIDTH + 5) * 0.5f, (125 * scale_factor), progressbarTextureRegion, PhoeniciaContext.vboManager);
        progress.setScale(scale_factor);
        this.attachChild(progress);

    } catch (final IOException e) {
        System.err.println("Error loading splash!");
        e.printStackTrace(System.err);
    }
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:28,代码来源:LoadingScene.java

示例14: loadLocaleDefaults

import org.andengine.opengl.texture.region.TextureRegionFactory; //导入依赖的package包/类
private void loadLocaleDefaults() throws IOException {
    try {

        inventoryTexture = new AssetBitmapTexture(PhoeniciaContext.textureManager, PhoeniciaContext.assetManager, this.locale.inventoryBlock.block_texture);
        inventoryTexture.load();
        int[] inventoryTileSize = GameTextures.calculateTileSize(locale.inventoryBlock.columns, locale.inventoryBlock.rows, locale.inventoryBlock.height);
        inventoryTiles = TextureRegionFactory.extractTiledFromTexture(inventoryTexture, 0, 0, inventoryTileSize[0] * 4, inventoryTileSize[1] * 2, 4, 2);
        this.spriteMasks.put(inventoryTiles, AssetBitmapTextureAtlasSource.create(PhoeniciaContext.assetManager, this.locale.inventoryBlock.block_texture).onLoadBitmap(Bitmap.Config.ALPHA_8));

        marketTexture = new AssetBitmapTexture(PhoeniciaContext.textureManager, PhoeniciaContext.assetManager, this.locale.marketBlock.block_texture);
        marketTexture.load();
        int[] marketTileSize = GameTextures.calculateTileSize(locale.marketBlock.columns, locale.marketBlock.rows, locale.marketBlock.height);
        marketTiles = TextureRegionFactory.extractTiledFromTexture(marketTexture, 0, 0, marketTileSize[0] * 4, marketTileSize[1] * 2, 4, 2);
        this.spriteMasks.put(marketTiles, AssetBitmapTextureAtlasSource.create(PhoeniciaContext.assetManager, this.locale.marketBlock.block_texture).onLoadBitmap(Bitmap.Config.ALPHA_8));

        workshopTexture = new AssetBitmapTexture(PhoeniciaContext.textureManager, PhoeniciaContext.assetManager, this.locale.workshopBlock.block_texture);
        workshopTexture.load();
        int[] workshopTileSize = GameTextures.calculateTileSize(locale.workshopBlock.columns, locale.workshopBlock.rows, locale.workshopBlock.height);
        workshopTiles = TextureRegionFactory.extractTiledFromTexture(workshopTexture, 0, 0, workshopTileSize[0] * 4, workshopTileSize[1] * 2, 4, 2);
        this.spriteMasks.put(workshopTiles, AssetBitmapTextureAtlasSource.create(PhoeniciaContext.assetManager, this.locale.workshopBlock.block_texture).onLoadBitmap(Bitmap.Config.ALPHA_8));

    } catch (final IOException e) {
        e.printStackTrace();
        throw e;
    }

}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:28,代码来源:PhoeniciaGame.java

示例15: loadLocalePeople

import org.andengine.opengl.texture.region.TextureRegionFactory; //导入依赖的package包/类
private void loadLocalePeople() throws IOException {
    for (Person person : this.locale.people) {
        try {
            AssetBitmapTexture texture = new AssetBitmapTexture(PhoeniciaContext.textureManager, PhoeniciaContext.assetManager, person.texture_src);
            texture.load();
            this.personTextures.put(person, texture);
            this.personTiles.put(person, TextureRegionFactory.extractFromTexture(texture, 0, 0, PERSON_TILE_WIDTH, PERSON_TILE_HEIGHT));
        } catch (final IOException e) {
            e.printStackTrace();
            throw e;
        }
    }
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:14,代码来源:PhoeniciaGame.java


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