Monogame Android - 如何将表面格式更改为游戏视图的 Rgba8888
Monogame Android - how to change surface format to Rgba8888 of game view
我想在 xamarin android 中更改游戏视图的表面格式以获得 Android 布局中单游戏背景的透明影响,但在投射到 AndroidGameView 时出现异常:
这是我的 Activity 代码:
public class Activity1 : Microsoft.Xna.Framework.AndroidGameActivity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
this.SetContentView(TestFBX.Resource.Layout.layout1);
var gameWindowLayout = FindViewById<RelativeLayout>(TestFBX.Resource.Id.gameWindow);
var game1 = new Game1();
var game1View = game1.Services.GetService<View>();
//Exception thrown here:
game1View.JavaCast<OpenTK.Platform.Android.AndroidGameView>().SurfaceFormat = Android.Graphics.Format.Rgba8888;
gameWindowLayout.AddView(game1View);
game1.Run(GameRunBehavior.Asynchronous);
}
}
例外情况:
System.InvalidCastException: Unable to convert instance of type 'Microsoft.Xna.Framework.MonoGameAndroidGameView' to type 'OpenTK.Platform.Android.AndroidGameView'.
我正在使用 Monogame 3.5。
有什么想法吗?
原来我要参考OpenTK-1.0 dll
而不是OpenTK
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v7.0\OpenTK-1.0.dll
我想在 xamarin android 中更改游戏视图的表面格式以获得 Android 布局中单游戏背景的透明影响,但在投射到 AndroidGameView 时出现异常:
这是我的 Activity 代码:
public class Activity1 : Microsoft.Xna.Framework.AndroidGameActivity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
this.SetContentView(TestFBX.Resource.Layout.layout1);
var gameWindowLayout = FindViewById<RelativeLayout>(TestFBX.Resource.Id.gameWindow);
var game1 = new Game1();
var game1View = game1.Services.GetService<View>();
//Exception thrown here:
game1View.JavaCast<OpenTK.Platform.Android.AndroidGameView>().SurfaceFormat = Android.Graphics.Format.Rgba8888;
gameWindowLayout.AddView(game1View);
game1.Run(GameRunBehavior.Asynchronous);
}
}
例外情况:
System.InvalidCastException: Unable to convert instance of type 'Microsoft.Xna.Framework.MonoGameAndroidGameView' to type 'OpenTK.Platform.Android.AndroidGameView'.
我正在使用 Monogame 3.5。
有什么想法吗?
原来我要参考OpenTK-1.0 dll
而不是OpenTK
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v7.0\OpenTK-1.0.dll