浏览代码

Updated Android samples to use the new Game.Activity property

dellis1972 13 年之前
父节点
当前提交
505c7b0f6f

+ 2 - 2
Samples/Android/ChaseAndEvade/Activity1.cs

@@ -11,8 +11,8 @@ namespace MonoGame.Samples.ChaseAndEvade.Droid
         protected override void OnCreate(Bundle bundle)
         protected override void OnCreate(Bundle bundle)
         {
         {
             base.OnCreate(bundle);
             base.OnCreate(bundle);
-
-            ChaseAndEvadeGame g = new ChaseAndEvadeGame(this);
+            ChaseAndEvadeGame.Activity = this;
+            ChaseAndEvadeGame g = new ChaseAndEvadeGame();
             SetContentView(g.Window);
             SetContentView(g.Window);
             g.Run();
             g.Run();
         }
         }

+ 2 - 2
Samples/Android/Draw2D/Activity1.cs

@@ -9,8 +9,8 @@ namespace Microsoft.Xna.Samples.Draw2D
         protected override void OnCreate(Bundle bundle)
         protected override void OnCreate(Bundle bundle)
         {
         {
             base.OnCreate(bundle);
             base.OnCreate(bundle);
-
-            var g = new Game1(this);
+            Game1.Activity = this;
+            var g = new Game1();
             SetContentView(g.Window);
             SetContentView(g.Window);
             g.Run();
             g.Run();
         }
         }

+ 2 - 2
Samples/Android/Peer2Peer/Activity1.cs

@@ -15,8 +15,8 @@ namespace MonoGame.Samples.PeerToPeerGame.Droid
         protected override void OnCreate(Bundle bundle)
         protected override void OnCreate(Bundle bundle)
         {
         {
             base.OnCreate(bundle);
             base.OnCreate(bundle);
-
-            var g = new PeerToPeer.PeerToPeerGame(this);
+            PeerToPeer.PeerToPeerGame.Activity = this;
+            var g = new PeerToPeer.PeerToPeerGame();
             SetContentView(g.Window);
             SetContentView(g.Window);
             g.Run();
             g.Run();
         }
         }

+ 2 - 2
Samples/Android/RenderTarget2D/Activity1.cs

@@ -16,8 +16,8 @@ namespace RenderTarget2DSample
 		protected override void OnCreate (Bundle bundle)
 		protected override void OnCreate (Bundle bundle)
 		{
 		{
 			base.OnCreate (bundle);
 			base.OnCreate (bundle);
-
-			var g = new Game1(this);
+            Game1.Activity = this;
+			var g = new Game1();
             SetContentView(g.Window);
             SetContentView(g.Window);
             g.Run();
             g.Run();
 		}
 		}

+ 2 - 2
Samples/Android/Sound/Activity1.cs

@@ -17,8 +17,8 @@ namespace Microsoft.Xna.Samples.Sound
         protected override void OnCreate(Bundle bundle)
         protected override void OnCreate(Bundle bundle)
         {
         {
             base.OnCreate(bundle);
             base.OnCreate(bundle);
-
-            var g = new Game1(this);
+            Game1.Activity = this;
+            var g = new Game1();
             SetContentView(g.Window);
             SetContentView(g.Window);
             g.Run();
             g.Run();
                
                

+ 1 - 1
Samples/Android/Sound/Resources/Resource.Designer.cs

@@ -1,7 +1,7 @@
 //------------------------------------------------------------------------------
 //------------------------------------------------------------------------------
 // <auto-generated>
 // <auto-generated>
 //     This code was generated by a tool.
 //     This code was generated by a tool.
-//     Runtime Version:4.0.30319.237
+//     Runtime Version:4.0.30319.239
 //
 //
 //     Changes to this file may cause incorrect behavior and will be lost if
 //     Changes to this file may cause incorrect behavior and will be lost if
 //     the code is regenerated.
 //     the code is regenerated.

+ 0 - 4
Samples/Linux/Sound/Game1.cs

@@ -26,11 +26,7 @@ namespace Microsoft.Xna.Samples.Sound
 		SoundEffectInstance soundInst;
 		SoundEffectInstance soundInst;
 		SpriteFont font;
 		SpriteFont font;
 		
 		
-#if ANDROID 
-		public Game1 (AndroidGameActivity activity) : base (activity)
-#else 
         public Game1 ()  
         public Game1 ()  
-#endif
 		{
 		{
 			graphics = new GraphicsDeviceManager (this);
 			graphics = new GraphicsDeviceManager (this);
 			
 			

+ 0 - 5
Samples/MacOS/Peer2PeerSample/PeerToPeerGame.cs

@@ -54,12 +54,7 @@ namespace PeerToPeer
 	#region Initialization
 	#region Initialization
 
 
 
 
-#if ANDROID 
-        public PeerToPeerGame(AndroidGameActivity activity)
-            : base(activity)
-#else 
         public PeerToPeerGame ()  
         public PeerToPeerGame ()  
-#endif
 		{
 		{
 			graphics = new GraphicsDeviceManager (this);
 			graphics = new GraphicsDeviceManager (this);
 			
 			

+ 0 - 5
Samples/MacOS/RenderTarget2DSample/Game1.cs

@@ -50,12 +50,7 @@ namespace RenderTarget2DSample
 		/// <summary>
 		/// <summary>
 		/// The constructor for our Game1 class.
 		/// The constructor for our Game1 class.
 		/// </summary>
 		/// </summary>
-#if ANDROID
-        public Game1(AndroidGameActivity activity)
-            : base(activity)
-#else 
         public Game1 ()  
         public Game1 ()  
-#endif
 		{
 		{
 			// Create the GraphicsDeviceManager for our game.
 			// Create the GraphicsDeviceManager for our game.
 			graphics = new GraphicsDeviceManager (this);
 			graphics = new GraphicsDeviceManager (this);

+ 0 - 5
Samples/iOS/ChaseAndEvade/ChaseAndEvadeGame.cs

@@ -131,12 +131,7 @@ namespace ChaseAndEvade
 
 
 	#region Initialization
 	#region Initialization
 
 
-#if ANDROID 
-        public ChaseAndEvadeGame(AndroidGameActivity activity)
-            : base(activity)
-#else 
         public ChaseAndEvadeGame ()  
         public ChaseAndEvadeGame ()  
-#endif
         {
         {
 
 
 			graphics = new GraphicsDeviceManager (this);
 			graphics = new GraphicsDeviceManager (this);

+ 0 - 4
Samples/iOS/Draw2D/Game1.cs

@@ -27,11 +27,7 @@ namespace Microsoft.Xna.Samples.Draw2D
 		Color alphaColor = Color.White;
 		Color alphaColor = Color.White;
 		FPSCounterComponent fps;
 		FPSCounterComponent fps;
 		
 		
-#if ANDROID 
-		public Game1 (AndroidGameActivity activity) : base (activity)
-#else 
         public Game1 ()  
         public Game1 ()  
-#endif
 		{
 		{
 			graphics = new GraphicsDeviceManager (this);
 			graphics = new GraphicsDeviceManager (this);
 			
 			

+ 3 - 3
StarterKits/Android/Cards/Activity1.cs

@@ -10,13 +10,13 @@ using Android.OS;
 namespace Blackjack
 namespace Blackjack
 {
 {
 	[Activity (Label = "Blackjack.Android", MainLauncher = true)]
 	[Activity (Label = "Blackjack.Android", MainLauncher = true)]
-	public class Activity1 : Activity
+	public class Activity1 : Microsoft.Xna.Framework.AndroidGameActivity
 	{
 	{
 		protected override void OnCreate(Bundle bundle)
 		protected override void OnCreate(Bundle bundle)
         {
         {
             base.OnCreate(bundle);
             base.OnCreate(bundle);
-
-            var g = new BlackjackGame(this);
+            BlackjackGame.Activity = this;
+            var g = new BlackjackGame();
             SetContentView(g.Window);
             SetContentView(g.Window);
             g.Run();
             g.Run();
         }
         }

+ 6 - 4
StarterKits/Android/Cards/Blackjack.Android.csproj

@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
 <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <PropertyGroup>
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -410,9 +410,7 @@
     </AndroidAsset>
     </AndroidAsset>
   </ItemGroup>
   </ItemGroup>
   <Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
   <Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
-  <ItemGroup>
-    <Folder Include="Assets\" />
-  </ItemGroup>
+  <ItemGroup />
   <ItemGroup>
   <ItemGroup>
     <AndroidAsset Include="..\..\MacOS\Cards\BlackjackLoDefContent\Fonts\Bold.xnb">
     <AndroidAsset Include="..\..\MacOS\Cards\BlackjackLoDefContent\Fonts\Bold.xnb">
       <Link>Assets\Content\Fonts\Bold.xnb</Link>
       <Link>Assets\Content\Fonts\Bold.xnb</Link>
@@ -446,6 +444,10 @@
     </AndroidAsset>
     </AndroidAsset>
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
+    <ProjectReference Include="..\..\..\..\MonoGame\MonoGame.Framework\MonoGame.Framework.Android.csproj">
+      <Project>{BA9476CF-99BA-4D03-92F2-73D2C5E58883}</Project>
+      <Name>MonoGame.Framework.Android</Name>
+    </ProjectReference>
     <ProjectReference Include="CardsFramework.Android.csproj">
     <ProjectReference Include="CardsFramework.Android.csproj">
       <Project>{25465464-21B2-4C14-8E3C-3B9F8C131484}</Project>
       <Project>{25465464-21B2-4C14-8E3C-3B9F8C131484}</Project>
       <Name>CardsFramework.Android</Name>
       <Name>CardsFramework.Android</Name>

+ 1 - 1
StarterKits/Android/Cards/Resources/Resource.designer.cs

@@ -1,7 +1,7 @@
 //------------------------------------------------------------------------------
 //------------------------------------------------------------------------------
 // <auto-generated>
 // <auto-generated>
 //     This code was generated by a tool.
 //     This code was generated by a tool.
-//     Runtime Version:4.0.30319.235
+//     Runtime Version:4.0.30319.239
 //
 //
 //     Changes to this file may cause incorrect behavior and will be lost if
 //     Changes to this file may cause incorrect behavior and will be lost if
 //     the code is regenerated.
 //     the code is regenerated.

+ 2 - 2
StarterKits/Android/Marblets/Marblets.csproj

@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
 <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <PropertyGroup>
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -115,7 +115,7 @@
   </ItemGroup>
   </ItemGroup>
   <Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
   <Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
   <ItemGroup>
   <ItemGroup>
-    <ProjectReference Include="..\..\..\MonoGame\MonoGame.Framework\MonoGame.Framework.Android.csproj">
+    <ProjectReference Include="..\..\..\..\MonoGame\MonoGame.Framework\MonoGame.Framework.Android.csproj">
       <Project>{BA9476CF-99BA-4D03-92F2-73D2C5E58883}</Project>
       <Project>{BA9476CF-99BA-4D03-92F2-73D2C5E58883}</Project>
       <Name>MonoGame.Framework.Android</Name>
       <Name>MonoGame.Framework.Android</Name>
     </ProjectReference>
     </ProjectReference>

+ 3 - 3
StarterKits/Android/Platformer/Activity1.cs

@@ -4,13 +4,13 @@ using Android.OS;
 namespace Platformer
 namespace Platformer
 {
 {
     [Activity(Label = "Platformer", MainLauncher = true, Icon = "@drawable/icon")]
     [Activity(Label = "Platformer", MainLauncher = true, Icon = "@drawable/icon")]
-    public class Activity1 : Activity
+    public class Activity1 : Microsoft.Xna.Framework.AndroidGameActivity
     {
     {
         protected override void OnCreate(Bundle bundle)
         protected override void OnCreate(Bundle bundle)
         {
         {
             base.OnCreate(bundle);
             base.OnCreate(bundle);
-
-            PlatformerGame g = new PlatformerGame(this);
+            PlatformerGame.Activity = this;
+            PlatformerGame g = new PlatformerGame();
             SetContentView(g.Window);
             SetContentView(g.Window);
             g.Run();
             g.Run();
         }
         }

+ 0 - 4
StarterKits/MacOS/Cards/CardsGame/BlackjackGame.cs

@@ -45,11 +45,7 @@ namespace Blackjack
         /// <summary>
         /// <summary>
         /// Initializes a new instance of the game.
         /// Initializes a new instance of the game.
         /// </summary>
         /// </summary>
-#if ANDROID 
-		public BlackjackGame (Activity activity) : base (activity)
-#else 
         public BlackjackGame ()  
         public BlackjackGame ()  
-#endif
         {
         {
             graphics = new GraphicsDeviceManager(this);
             graphics = new GraphicsDeviceManager(this);
 
 

+ 0 - 4
StarterKits/iOS/Platformer/PlatformerGame.cs

@@ -60,11 +60,7 @@ namespace Platformer
         // or handle exceptions, both of which can add unnecessary time to level loading.
         // or handle exceptions, both of which can add unnecessary time to level loading.
         private const int numberOfLevels = 3;
         private const int numberOfLevels = 3;
 
 
-#if ANDROID 
-		public PlatformerGame (Activity activity) : base (activity)
-#else
         public PlatformerGame()
         public PlatformerGame()
-#endif
         {
         {
             graphics = new GraphicsDeviceManager(this);
             graphics = new GraphicsDeviceManager(this);
             Content.RootDirectory = "Content";
             Content.RootDirectory = "Content";