andengine load texture
来源:互联网 发布:小区信息发布查询软件 编辑:程序博客网 时间:2024/06/16 04:25
记录一下texture的几种加载方式
1 BitmapTextureAtlas
BitmapTextureAtlas mBitmapTextureAtlas = new BitmapTextureAtlas(this.getTextureManager(), 1024, 1024, TextureOptions.BILINEAR);ITextureRegion textureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(mBitmapTextureAtlas, this, "main_menu.jpg", 0, 0);mBitmapTextureAtlas.load();float srx = CAMERA_WIDTH/2 - textureRegion .getWidth()/2;float sry = CAMERA_HEIGHT - textureRegion .getHeight();Sprite first = new Sprite(srx, sry, textureRegion , this.mEngine.getVertexBufferObjectManager());this.scene.attachChild(first);
最基本的, 这里就不解释了
2 BuildableBitmapTextureAtlas
BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");BuildableBitmapTextureAtlas mBitmapTextureAtlas = new BuildableBitmapTextureAtlas(this.getTextureManager(), 1024, 512, TextureOptions.NEAREST);ITextureRegion firstTexureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.mBitmapTextureAtlas, this, "load_logo.png");ITextureRegion secondTexureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.mBitmapTextureAtlas, this, "load_flash.png");ITextureRegion thirdTexureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.mBitmapTextureAtlas, this, "load_flash_c.png");mBitmapTextureAtlas.build(new BlackPawnTextureAtlasBuilder<IBitmapTextureAtlasSource, BitmapTextureAtlas>(0, 0, 0));mBitmapTextureAtlas.load();float srx = CAMERA_WIDTH/2 - firstTexureRegion.getWidth()/2;float sry = CAMERA_HEIGHT/2 - firstTexureRegion.getHeight()/2;Sprite first = new Sprite(srx, sry, firstTexureRegion, this.mEngine.getVertexBufferObjectManager());this.scene.attachChild(first);
BuildableBitmapTextureAtlas 的意义在于,将多个图片加载在一texture中,而你不需要去安排每张图的位置
如果想用第一种方式将几张图片加载到同一个texture中,BitmapTextureAtlasTextureRegionFactory.createFromAsset的最后两个参数则需要你自己填写,这个需要按照加载的图片的大小你自己安排
3
内部
AssetBitmapTextureAtlasSource abtas = AssetBitmapTextureAtlasSource.create(this.getAssets(), "gfx/background_grass.png")ITextureRegion tr = BitmapTextureAtlasTextureRegionFactory.createFromSource(pBitmapTextureAtlas, abtas , pTextureX, pTextureY);srx = CAMERA_WIDTH - tr.getWidth();sry = CAMERA_HEIGHT - tr.getHeight();Sprite second = new Sprite(srx, sry, tr, this.mEngine.getVertexBufferObjectManager());this.scene.attachChild(second);
4
将多个单张图加载到一个tiledtextureregion中
BitmapTextureAtlas bitmapTextureAtlas = new BitmapTextureAtlas (this.getTextureManager(), 256, 128, TextureOptions.BILINEAR_PREMULTIPLYALPHA);ITextureRegion[] childTextureRegions = new TextureRegion[2];childTextureRegions[0] = BitmapTextureAtlasTextureRegionFactory.createFromAsset(bitmapTextureAtlas, this, "start_default.png", 0, 0);childTextureRegions[1] = BitmapTextureAtlasTextureRegionFactory.createFromAsset(bitmapTextureAtlas, this, "start_default.png", 65, 0);TiledTextureRegion tiledTextureRegion = TiledTextureRegion.create(bitmapTextureAtlas , 0, 0 , 250 , 128 , 1, 2);
0 0
- andengine load texture
- AndEngine开发中的纹理,即texture
- AndEngine:关于Texture质量问题 和 Gradient背景
- AndEngine:关于Texture的质量(2)
- Andengine
- andengine
- Texture
- texture
- unable to load texture at BitmapTexture.cpp:270
- DXUT 加载纹理Load the texture for the screen quad
- AndEngine----初识AndEngine
- andengine 画圆
- AndEngine编译
- andengine学习
- AndEngine Examples
- AndEngine配置
- andengine线程
- andengine背景
- C简单加密程序 字母循环加5,数字不变!
- Coupons / 取样问题
- NYOJ 73 比大小
- C: 局部变量、全局变量初始化问题
- C:四舍五入
- andengine load texture
- 在VisualStudio中使用GIT
- 常用C/C++ 字符串处理总结
- Android-/dev/hidraw0 设备文件创建
- 大数据平台搭建笔记
- 互联网公司做智能硬件的十大坑
- linux进程间通信--信号
- EditText讲解
- C++ STL--stack/queue 的使用方法