Rick Rickk
Rick Rickk

Reputation: 23

Game cant start , black screen seen

BlackScreenPicturei am trying out the game MrSnakey. It doesn't give me any errors when i run it . however, the emulator shows a black screen when it is launched . Do u guys noe how to solve it? Anymore information on my project that is needed to solve this problem , just tell me i will post it here.

Firstly the manifest file

   <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.zardtechnologies.androidgames.mrsnakey"
    android:versionCode="1"
    android:versionName="1.0" >

    <application
        androidicon="@drawable/icon"
        android:debuggable="true"
        android:label="Mr. Snakey" >
        <activity
            android:name=".MrSnakeyActivity"
            android:configChanges="keyboard|keyboardHidden|orientation"
            android:label="Mr. Snakey"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <uses-sdk
        android:minSdkVersion="3"
        android:targetSdkVersion="12" />

</manifest>

Secondly the MrSnakeyActivity

    package com.zardtechnologies.androidgames.mrsnakey;

import com.zardtechnologies.framework.Screen;
import com.zardtechnologies.framework.impl.AndroidGame;

public class MrSnakeyActivity extends AndroidGame {
    public Screen getStartScreen() {
        return new LoadingScreen(this);
    }
}

Thirdly the AndroidGame activity that is linked from MrSnakeyActivity

package com.zardtechnologies.androidgames.mrsnakey;  
import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.os.Bundle;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.view.Window;
import android.view.WindowManager;

import com.zardtechnologies.framework.Audio;
import com.zardtechnologies.framework.FileIO;
import com.zardtechnologies.framework.Game;
import com.zardtechnologies.framework.Graphics;
import com.zardtechnologies.framework.Input;
import com.zardtechnologies.framework.Screen;

public abstract class AndroidGame extends Activity implements Game {
    AndroidFastRenderView renderView;
    Graphics graphics;
    Audio audio;
    Input input;
    FileIO fileIO;
    Screen screen;
    WakeLock wakeLock;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);

        boolean isLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
        int frameBufferWidth = isLandscape ? 480 : 320;
        int frameBufferHeight = isLandscape ? 320 : 480;
        Bitmap frameBuffer = Bitmap.createBitmap(frameBufferWidth,
                frameBufferHeight, Config.RGB_565);

        float scaleX = (float) frameBufferWidth
                / getWindowManager().getDefaultDisplay().getWidth();
        float scaleY = (float) frameBufferHeight
                / getWindowManager().getDefaultDisplay().getHeight();

        renderView = new AndroidFastRenderView(this, frameBuffer);
        graphics = new AndroidGraphics(getAssets(), frameBuffer);
        fileIO = new AndroidFileIO(getAssets());
        audio = new AndroidAudio(this);
        input = new AndroidInput(this, renderView, scaleX, scaleY);
        screen = getStartScreen();
        setContentView(renderView);

        PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
        wakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, "GLGame");
    }

    @Override
    public void onResume() {
        super.onResume();
        wakeLock.acquire();
        screen.resume();
        renderView.resume();
    }

    @Override
    public void onPause() {
        super.onPause();
        wakeLock.release();
        renderView.pause();
        screen.pause();

        if (isFinishing())
            screen.dispose();
    }

    public Input getInput() {
        return input;
    }

    public FileIO getFileIO() {
        return fileIO;
    }

    public Graphics getGraphics() {
        return graphics;
    }

    public Audio getAudio() {
        return audio;
    }

    public void setScreen(Screen screen) {
        if (screen == null)
            throw new IllegalArgumentException("Screen must not be null");

        this.screen.pause();
        this.screen.dispose();
        screen.resume();
        screen.update(0);
        this.screen = screen;
    }

    public Screen getCurrentScreen() {
        return screen;
    }
}

I do not know what more information is needed as i dont know what is causing my app to be appearing as a black screen. Oh ya, the Console log:

[2012-04-29 14:24:54 - MrSnakey] Android Launch!
[2012-04-29 14:24:54 - MrSnakey] adb is running normally.
[2012-04-29 14:24:54 - MrSnakey] Performing com.zardtechnologies.androidgames.mrsnakey.MrSnakeyActivity activity launch
[2012-04-29 14:24:54 - MrSnakey] Automatic Target Mode: using existing emulator 'emulator-5554' running compatible AVD 'Test.Phone'
[2012-04-29 14:24:54 - MrSnakey] Uploading MrSnakey.apk onto device 'emulator-5554'
[2012-04-29 14:24:55 - MrSnakey] Installing MrSnakey.apk...
[2012-04-29 14:25:20 - MrSnakey] Success!
[2012-04-29 14:25:20 - MrSnakey] Project dependency found, installing: AndroidGamesFramework
[2012-04-29 14:25:22 - AndroidGamesFramework] Application already deployed. No need to reinstall.
[2012-04-29 14:25:22 - MrSnakey] Project dependency found, installing: AndroidGamesFrameworkImplementation
[2012-04-29 14:25:24 - AndroidGamesFrameworkImplementation] Application already deployed. No need to reinstall.
[2012-04-29 14:25:24 - AndroidGamesFrameworkImplementation] Project dependency found, installing: AndroidGamesFramework
[2012-04-29 14:25:26 - AndroidGamesFramework] Application already deployed. No need to reinstall.
[2012-04-29 14:25:26 - MrSnakey] Starting activity com.zardtechnologies.androidgames.mrsnakey.MrSnakeyActivity on device emulator-5554
[2012-04-29 14:25:28 - MrSnakey] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.zardtechnologies.androidgames.mrsnakey/.MrSnakeyActivity }

There are no errors . I think the app works perfectly fine just that it just doesn't get me to the game. Please help me solve the black screen issue .If you guys need anymore info, just tell me and i will post it here . Thanks

Upvotes: 1

Views: 591

Answers (1)

ACC
ACC

Reputation: 2570

You are not loading the layout file anywhere. You need a call to setContentView(R.layout.main) in AndroidGame. Assuming your layout file is called main.xml

Upvotes: 1

Related Questions