【发布时间】:2012-06-10 09:09:34
【问题描述】:
我想在 onCreate() 方法中初始化所有内容时显示启动画面,但我需要将内容绘制到屏幕上的组件也在初始化,因此当我启动应用程序时和之后出现黑屏onCreate() 方法已经完成,然后只绘制第一个屏幕。我想要一个启动画面,而不是黑屏。
这是我在 onCreate 方法中的代码:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Acquire a wakeLock to prevent the phone from sleeping
PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
wakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, "GLGame");
// Setup all the Game Engine components
gameEngineLog = new WSLog("WSGameEngine");
gameEngineLog.setLogType(this.gameEngineLogType);
gameLog = new WSLog(this.gameLogTAG);
gameLog.setLogType(this.gameLogType);
io = new FileIO(this, getAssets());
audio = new Audio(this);
wsScreen = new WSScreen(this, this.screenResizeType, this.customTopYGap, this.customLeftXGap, this.gameScreenWidth, this.gameScreenHeight);
graphics = new Graphics(this, wsScreen.getGameScreen(), wsScreen.getGameScreenextended());
renderView = new RenderView(this, wsScreen.getGameScreen(), wsScreen.getGameScreenextended(), FPS, maxFrameskippes);
input = new Input(this, renderView, logGameEngineInputLog);
setContentView(renderView);
if(useOfAnalytics == true) {
getGameEngineLog().w(classTAG, "Analytics has been enabled");
analytics = new Analytics(this);
}
// Check that the developer has initialized the assets
if(this.assets == null) {
this.gameEngineLog.w(classTAG, "The assets for the game haven't been defined!");
}
}
如何实现闪屏,避免一开始就黑屏?
【问题讨论】:
标签: java android splash-screen