ゲームエンジンのすべてのコンポーネントをAsyncTaskで初期化したいと思います。誰かがこれがどのように行われるかを私に教えてもらえますか?
次のようなものが欲しいです:1。コードを実行する前に、スプラッシュ画面(.xml)を設定します2.初期化コードを実行します3.すべて完了したら、ゲームのロード画面を実行します
これが私の現在のコードです:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Display splash screen
if(this.splashScreen != null) {
// .xml
setContentView(this.splashScreen);
}
// Do all the initialization
// 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);
networkSocket = new NetworkSocket(this);
this.gameEngineLog.d(classTAG, "Completed initialization");
setContentView(renderView);
// 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!");
}
this.getNetworkSocket().useAnalytics(this.analyticsAppAPIKey);
this.getNetworkSocket().useServerCommunication(this.serverCommunicationAppID, this.serverCommunicationClientKey);
this.getNetworkSocket().useFacebookCommunicaiton(this.facebookCommunicationAppID);
// Check if server communication should be initialized
if(this.networkSocket.getUseOfServerCommunication() == true) {
this.networkSocket.getServerCommunication().initialize(this, this.networkSocket.getServerCommunicationAppID(), this.networkSocket.getServerCommunicationClientKey());
}
// Check if facebook communication should be initialized
if(this.networkSocket.getUseFacebookCommunication() == true) {
this.networkSocket.getFacebookCommunication().initialize(this.networkSocket.getFacebookCommunicationAppID(), true);
}
// Start the Load screen
// Once all of this code has been executed, the class that extends this class calls "setScreen(new LoadScreen(this));" to set the LoadScreen, which
// loads all the assets of the game
}