Android AndEngine动画精灵未显示
我刚开始用动画精灵,并添加了一个,但它似乎不起作用,任何帮助将不胜感激 它只是将精灵显示为一个黑匣子。不过背景会显示出来。我发现如果我没有使用Android AndEngine动画精灵未显示,android,andengine,Android,Andengine,我刚开始用动画精灵,并添加了一个,但它似乎不起作用,任何帮助将不胜感激 它只是将精灵显示为一个黑匣子。不过背景会显示出来。我发现如果我没有使用(bi~).load()它将显示为一个黑框,但它有一个load() 原木猫 我的班级 专用摄像机mCamera; 私有内部c_宽度=640; 私人室内c_高度=480; 私有可构建BitmapTextureAtlas mBitmapTextureAtlas; 私有平铺纹理区域pi; 私密场景; @凌驾 public EngineOptions onCrea
(bi~).load()代码>它将显示为一个黑框,但它有一个load()代码>
原木猫
我的班级
专用摄像机mCamera;
私有内部c_宽度=640;
私人室内c_高度=480;
私有可构建BitmapTextureAtlas mBitmapTextureAtlas;
私有平铺纹理区域pi;
私密场景;
@凌驾
public EngineOptions onCreateEngineOptions(){
mCamera=新相机(0,0,c_宽度,c_高度);
EngineOptions=new EngineOptions(真,
ScreenOrientation.scape\u固定、新比率解决方案策略(
c_宽度,c_高度),mCamera);
返回选项;
}
@凌驾
公共资源(
OnCreateResourcesCallback pOnCreateResourcesCallback)
抛出异常{
BitmapTextureLastTextureRegionFactory.setAssetBasePath(“gfx/”);
this.mBitmapTextureAtlas=新的可构建位图纹理atlas(
this.getTextureManager(),32,32,TextureOptions.NEAREST);
this.pi=BitMapTextureAtlastTextureRegionFactory.createTiledFromAsset(
this.mbitmaptexturetalas,this,“face_box_tiled.png”,2,1);
试一试{
此文件为.mBitmapTextureAtlas
.build(新的BlackPawnTextureAtlasBuilder)(
0, 0, 1));
这个.mBitmapTextureAtlas.load();
}捕获(例外e){
e(e);
}
ponCreateResourcesScallback.onCreateResourcesFinished();
}
@凌驾
public void OnCreateSceneCallback(OnCreateSceneCallback-pOnCreateSceneCallback)
抛出异常{
this.mScene=新场景();
这是一个新的背景(0.82f,0.91f,0.7121f);
pOnCreateSceneCallback.onCreateSceneFinished(this.mScene);
}
@凌驾
在PopulateScene(场景pScene,
OnPopulateSceneCallback PopulateSceneCallback)引发异常{
最终动画精灵piA=新动画精灵(32,32,pi,
这是.getVertexBufferObjectManager());
制作动画(100);
this.mScene.attachChild(piA);
pOnPopulateSceneCallback.onPopulateSceneFinished();
}
}
看起来atlas上没有足够的空间放置您的雪碧纹理。尝试增加atlas大小,使其大于或等于sprite大小+填充。听起来像是大小问题-您的.png文件的尺寸是多少。仅用于踢腿-将TextureAtlas的大小设置为128x128,看看是否有效谢谢。我想我永远不会从错误描述中得到正确的答案。。。
01-07 10:47:48.049: W/System.err(2879): org.andengine.opengl.texture.atlas.buildable.builder.ITextureAtlasBuilder$TextureAtlasBuilderException: Could not build: 'AssetBitmapTextureAtlasSource(gfx/face_hexagon_tiled.png)' into: 'BitmapTextureAtlas'.
01-07 10:47:48.049: W/System.err(2879): at org.andengine.opengl.texture.atlas.buildable.builder.BlackPawnTextureAtlasBuilder.build(BlackPawnTextureAtlasBuilder.java:87)
01-07 10:47:48.049: W/System.err(2879): at org.andengine.opengl.texture.atlas.buildable.BuildableTextureAtlas.build(BuildableTextureAtlas.java:236)
01-07 10:47:48.059: W/System.err(2879): at com.example.pilet.Game.onCreateResources(Game.java:48)
01-07 10:47:48.059: W/System.err(2879): at org.andengine.ui.activity.BaseGameActivity.onCreateGame(BaseGameActivity.java:181)
01-07 10:47:48.059: W/System.err(2879): at org.andengine.ui.activity.BaseGameActivity.onSurfaceCreated(BaseGameActivity.java:110)
01-07 10:47:48.059: W/System.err(2879): at org.andengine.opengl.view.EngineRenderer.onSurfaceCreated(EngineRenderer.java:80)
01-07 10:47:48.059: W/System.err(2879): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1494)
01-07 10:47:48.059: W/System.err(2879): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
private Camera mCamera;
private int c_width = 640;
private int c_height = 480;
private BuildableBitmapTextureAtlas mBitmapTextureAtlas;
private TiledTextureRegion pi;
private Scene mScene;
@Override
public EngineOptions onCreateEngineOptions() {
mCamera = new Camera(0, 0, c_width, c_height);
EngineOptions options = new EngineOptions(true,
ScreenOrientation.LANDSCAPE_FIXED, new RatioResolutionPolicy(
c_width, c_height), mCamera);
return options;
}
@Override
public void onCreateResources(
OnCreateResourcesCallback pOnCreateResourcesCallback)
throws Exception {
BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
this.mBitmapTextureAtlas = new BuildableBitmapTextureAtlas(
this.getTextureManager(), 32, 32, TextureOptions.NEAREST);
this.pi = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(
this.mBitmapTextureAtlas, this, "face_box_tiled.png", 2, 1);
try {
this.mBitmapTextureAtlas
.build(new BlackPawnTextureAtlasBuilder<IBitmapTextureAtlasSource, BitmapTextureAtlas>(
0, 0, 1));
this.mBitmapTextureAtlas.load();
} catch (Exception e) {
Debug.e(e);
}
pOnCreateResourcesCallback.onCreateResourcesFinished();
}
@Override
public void onCreateScene(OnCreateSceneCallback pOnCreateSceneCallback)
throws Exception {
this.mScene = new Scene();
this.mScene.setBackground(new Background(0.82f, 0.91f, 0.7121f));
pOnCreateSceneCallback.onCreateSceneFinished(this.mScene);
}
@Override
public void onPopulateScene(Scene pScene,
OnPopulateSceneCallback pOnPopulateSceneCallback) throws Exception {
final AnimatedSprite piA = new AnimatedSprite(32, 32, pi,
this.getVertexBufferObjectManager());
piA.animate(100);
this.mScene.attachChild(piA);
pOnPopulateSceneCallback.onPopulateSceneFinished();
}
}