gpt4 book ai didi

java - 游戏打不开,黑屏

转载 作者:行者123 更新时间:2023-11-30 04:13:57 28 4
gpt4 key购买 nike

BlackScreenPicture 我正在尝试 MrSnakey 游戏。当我运行它时,它没有给我任何错误。但是,模拟器在启动时显示黑屏。你们不知道如何解决吗?解决此问题所需的有关我的项目的任何信息,请告诉我,我会在此处发布。

首先是 list 文件

   <?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>

其次是 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);
}
}

第三个是从 MrSnakeyActivity 链接的 AndroidGame Activity

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;
}
}

我不知道需要什么更多信息,因为我不知道是什么导致我的应用程序显示为黑屏。哦,是的,控制台日志:

[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 }

没有错误。我认为该应用程序运行良好,只是它无法让我进入游戏。请帮我解决黑屏问题。如果你们需要更多信息,请告诉我,我会在这里发布。谢谢

最佳答案

您没有在任何地方加载布局文件。你需要调用AndroidGame 中的setContentView(R.layout.main)。假设您的布局文件名为 main.xml

关于java - 游戏打不开,黑屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10370217/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com