0
我想改變xamarin的Android遊戲視圖的表面形式以獲取在Android的佈局monogame背景透明的影響,但有例外鑄造AndroidGameView時:Monogame Android的 - 如何改變表面格式RGBA8888遊戲視圖
這裏是我的活動代碼:
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。
有什麼想法?