Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8123805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:17:07+00:00 2026-06-06T06:17:07+00:00

I would like to initialize all the components of the game engine with the

  • 0

I would like to initialize all the components of the game engine with the AsyncTask. Could somebody guide me how this would be done?

I’d like something like this:
1. Before the code runs, set a splash screen (.xml)
2. run the initialization code
3. once all done, run the load screen of the game

Here’s my current code:

@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

    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T06:17:09+00:00Added an answer on June 6, 2026 at 6:17 am

    According to the asynctask documentation the class exposes four methods that you can use to implement your application loading logic:

    onPreExecute(), invoked on the UI thread immediately after the task is
    executed. This step is normally used to setup the task, for instance
    by showing a progress bar in the user interface.

    doInBackground(Params…), invoked on the background thread
    immediately after onPreExecute() finishes executing. This step is
    used to perform background computation that can take a long time.

    onProgressUpdate(Progress…), invoked on the UI thread after a call
    to publishProgress(Progress…). This method is used to display any
    form of progress in the user interface while the background
    computation is still executing.

    onPostExecute(Result), invoked on the UI thread after the background
    computation finishes. The result of the background computation is
    passed to this step as a parameter.

    Following the documentation, you can start your async task in your main Activity. In the onPreExecute method you can display your splash screen.

    In the doInBackGround method insert the code that does all the loading stuff. If you want to provide the user with some information about the loading state you can use inside this method publishProgress to publish one or more units of progress. These values are published on the UI thread, in the onProgressUpdate(Progress…) step.

    Finally in onPostExecute method you can remove the splashscreen and run the load screen of the game.

    have a look also at this example.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to initialize boost::random::discrete_distribution with a double[] like this: boost::random::discrete_distribution<>* distribution(double* _distr)
I would like my default constructor to create & initialize all the objects shown
I have a Visual Studio 2008 C++03 application where I would like to initialize
Here is part of my code. I would like to initialize only the arraylist[0]
I would like to define and initialize some variables in web.xml and the access
I would like to know: how can i initialize class object with parameters? I've
Which is the best practice in this situation? I would like an un-initialized array
Would like to get a list of all packages available on CRAN to the
I have a Sinatra::Base object that I would like to include in all of
I would like to catch all exceptions in a Rails 3 application. I tried

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.