少年辛苦终身事,莫向光阴惰寸功。这篇文章主要讲述在AndroidGameActivity中运行LoadContent时启动/加载屏幕相关的知识,希望能为你提供帮助。
首先,我想说一般来说我对C#和Monogame都很陌生。
【在AndroidGameActivity中运行LoadContent时启动/加载屏幕】我的问题是显示屏幕。我有一个名为loadingsplash.xml的布局资源,并希望在Game活动运行时显示它LoadContent();
流程图是:Main.xml:按下按钮>
在LoadContent>
GameActivity期间的ProgressDialog
我想要的流程图:Main.xml:按下按钮>
在LoadContent>
GameActivity期间显示loadingsplash.xml
MainMenu.cs
[Activity( Label = "theApp", Theme = "@android:style/Theme.NoTitleBar.Fullscreen", MainLauncher=true, ScreenOrientation=Android.Content.PM.ScreenOrientation.Landscape)]public class MainMenu : Activity, IDialogInterfaceOnClickListener
{
......
void GoButton_Click(object sender, EventArgs e)
{
Intent theActivity = new Intent(this, typeof(GameActivity));
StartActivity(theActivity);
}
theActivity.cs
namespace theApp
{
[Activity(Theme = "@android:style/Theme.NoTitleBar.Fullscreen", Label = "theApp", Icon = "@drawable/icon", ScreenOrientation = Android.Content.PM.ScreenOrientation.Landscape, ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.Keyboard | ConfigChanges.KeyboardHidden)]public class GameActivity : Microsoft.Xna.Framework.AndroidGameActivity, IDialogInterfaceOnClickListener
{
myGame game = null;
static GameBundle gameBundle = null;
ProgressDialog dialog;
const int WindowID = 10001;
protected override void OnCreate(Bundle bundle)
{
loadedOnce = true;
//this works
//
//dialog = new ProgressDialog(this);
//dialog.SetMessage("Loading...");
//dialog.Show();
////Loading Splash screen invocation code goes here?if (game == null)
{
myGame.Activity = this;
base.OnCreate (bundle);
game = new myGame();
game.NativeCommand = ProcessCommand;
game.Window.GraphicsMode = new AndroidGraphicsMode(0, 4, 0, 0, 0, false);
game.Window.Id = WindowID;
if (gameBundle == null)
{
game.Run();
}
else
{
if (gameBundle != null)
{
resumeGame.Show();
}
}
}
SetContentView(game.Window);
}
myGame.cs
public class myGame : Microsoft.Xna.Framework.Game
{public myGame()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Resources/Drawable";
unloading = false;
graphics.PreferMultiSampling = true;
graphics.IsFullScreen = true;
graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft;
}protected override void Initialize()
{
graphics.SynchronizeWithVerticalRetrace = true;
graphics.PreferredBackBufferWidth =800;
graphics.PreferredBackBufferHeight = 480;
screenManager = new ScreenManager(this, 800, 480);
base.Initialize();
}bool loaded = false;
protected override void LoadContent()
{
spriteBatch = new SpriteBatch(this.GraphicsDevice);
font = Content.Load<
SpriteFont>
("Arial");
GraphicsDevice.Clear(Color.Black);
ThreadPool.QueueUserWorkItem(state =>
{
...
loaded = true;
});
如果我用setContentView(Resource.Layout.LoadingSplash)调用LoadingSplash; 在base.OnCreate(bundle)之前我得到一个异常,必须调用requestFeature。
答案对于仍在寻找这个问题答案的人,我建议您不要使用不同的xml文件来使用单独的屏幕,只需在Monogame中操作它。
请在这篇文章中查看我的答案:https://stackoverflow.com/a/55667101/8594783
推荐阅读
- 启动Android模拟器时,“设备上没有足够的存储空间来存储包”
- 用户'IIS APPPOOLASP.NET v4.0'登录失败
- 如果我在RabbitTemplate上直接设置它们,为什么Spring需要在Converter和ClassMapper上使用@Bean()
- 将Cocoapods与App Extension一起使用
- 应用程序名称在模拟器中具有.app作为后缀
- 如何启动App Store应用程序并导航到开发人员页面
- 你能获得Apple Watch的大概电池百分比吗()
- djangocms与apphook对象集成filer_image
- Apple标签,Apple脚本和Evernote