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