0
我在AndEngine中玩耍并在制作闪屏时学习这些未记录文档。我知道有一个SplashScene类,但是当我在学习时,我正在尝试各种方法。为什么ScaleModifier会使精灵闪烁?
但是,我似乎无法得到这一个权利。屏幕是240x320(宽x高)和闪屏纹理是480x640,所以我缩小它适合屏幕。纹理加载等工作正常,但是当精灵显示时,我首先看到0.1secs的大纹理,然后它被缩小。我希望它在显示之前缩小。尝试了一切,将调用attachChild()调用到onLoadComplete(),使用setVisible(false)等,但我看到纹理每次缩小。
为什么?
这里是我的代码:
@Override
public Scene onLoadScene() {
this.scene = new Scene();
// Texture sizes
final int sX = mSplashTextureRegion.getWidth();
final int sY = mSplashTextureRegion.getHeight();
// Center on camera
final int cX = (CAMERA_WIDTH - sX)/2;
final int cY = (CAMERA_HEIGHT - sY)/2;
// Scale factor according to camera
final float scaleFactor = Math.min((float) CAMERA_WIDTH/sX, (float) CAMERA_HEIGHT/sY);
// Init sprite
splashScreen = new Sprite(cX, cY, mSplashTextureRegion);
splashScreen.setVisible(false);
// Rescale the splash-screen to fit the display, move it to (0, 0) and show it.
splashScreen.registerEntityModifier(new ScaleModifier(0.1f, 1.0f, scaleFactor));
//splashScreen.registerEntityModifier(new ScaleAtModifier(0.001f, 1.0f, scaleFactor, 0, 0));
// splashScreen.registerEntityModifier(new SequenceEntityModifier(
// new ScaleModifier(0.1f, 1.0f, scaleFactor),
// new DelayModifier(0.2f)
//));
return scene;
}
@Override
public void onLoadComplete() {
scene.attachChild(splashScreen);
splashScreen.setVisible(true);
}
如果我在这个改写onLoadComplete()
:
@Override
public void onLoadComplete() {
scene.attachChild(splashScreen);
mHandler.postDelayed(korv, 1000);
}
private Runnable korv = new Runnable() {
@Override
public void run() {
splashScreen.setVisible(true);
}
};
闪烁消失了,但这并不觉得自己是一个很好的解决方案。
完美。谢谢! – bos 2012-03-08 19:32:24