Browse Source

Some changes to platformer and vector rumble for android and touch support

dellis1972 13 years ago
parent
commit
f0beba42cf

+ 1 - 0
StarterKits/Android/Platformer/Platformer.csproj

@@ -16,6 +16,7 @@
     <AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
     <AssemblyName>Platformer</AssemblyName>
     <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
+    <TargetFrameworkVersion>v2.3</TargetFrameworkVersion>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DebugSymbols>true</DebugSymbols>

+ 3 - 4
StarterKits/Android/Platformer/Properties/AndroidManifest.xml

@@ -1,6 +1,5 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="platformer.platformer">
-	<application android:label="Platformer" android:debuggable="true">
-	</application>
-	<uses-sdk />
+	<application android:label="Platformer" android:debuggable="true"></application>
+	<uses-sdk android:minSdkVersion="8" />
 </manifest>

+ 4 - 0
StarterKits/MacOS/VectorRumble/Game.cs

@@ -21,6 +21,9 @@ using Microsoft.Xna.Framework.Content;
 using Microsoft.Xna.Framework.Graphics;
 using Microsoft.Xna.Framework.Input;
 using Microsoft.Xna.Framework.Storage;
+#if WINDOWS_PHONE || IOS || ANDROID // WP7, iPad or Tablets only
+using Microsoft.Xna.Framework.Input.Touch;
+#endif
 #endregion
 
 namespace VectorRumble
@@ -46,6 +49,7 @@ namespace VectorRumble
             graphics.PreferredBackBufferHeight = 480;
 			graphics.IsFullScreen = true;
 			graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft;
+			TouchPanel.EnabledGestures = GestureType.Tap;
 #else
 			graphics.PreferredBackBufferWidth = 1280;
             graphics.PreferredBackBufferHeight = 720;

+ 10 - 0
StarterKits/MacOS/VectorRumble/ScreenManager/InputState.cs

@@ -12,6 +12,7 @@ using Microsoft.Xna.Framework;
 using Microsoft.Xna.Framework.Input;
 #if ANDROID
 using Microsoft.Xna.Framework.Input.Touch;
+using System.Collections.Generic;
 #endif
 #endregion
 
@@ -38,6 +39,7 @@ namespace VectorRumble
 		
 #if ANDROID
 		public TouchCollection CurrentTouchState;
+		public List<GestureSample> Gestures = new List<GestureSample>();
 #endif		
 
         #endregion
@@ -55,6 +57,9 @@ namespace VectorRumble
 
             LastKeyboardStates = new KeyboardState[MaxInputs];
             LastGamePadStates = new GamePadState[MaxInputs];
+#if ANDROID
+			
+#endif			
         }
 
 
@@ -159,6 +164,11 @@ namespace VectorRumble
             }
 #if ANDROID			
 			CurrentTouchState = TouchPanel.GetState();
+			Gestures.Clear();
+			while(TouchPanel.IsGestureAvailable)
+			{
+				Gestures.Add(TouchPanel.ReadGesture());
+			}
 #endif			
         }
 

+ 4 - 1
StarterKits/MacOS/VectorRumble/Screens/MenuScreen.cs

@@ -12,6 +12,9 @@ using System;
 using System.Collections.Generic;
 using Microsoft.Xna.Framework;
 using Microsoft.Xna.Framework.Graphics;
+#if ANDROID
+using Microsoft.Xna.Framework.Input.Touch;
+#endif
 #endregion
 
 namespace VectorRumble
@@ -113,7 +116,7 @@ namespace VectorRumble
 						}
 					}					
                  }				 
-			}
+			}					
 #endif			
             // Move to the previous menu entry?
             if (input.MenuUp)

+ 12 - 0
StarterKits/MacOS/VectorRumble/Screens/MessageBoxScreen.cs

@@ -11,6 +11,9 @@
 using System;
 using Microsoft.Xna.Framework;
 using Microsoft.Xna.Framework.Graphics;
+#if ANDROID
+using Microsoft.Xna.Framework.Input.Touch;
+#endif
 #endregion
 
 namespace VectorRumble
@@ -96,6 +99,15 @@ namespace VectorRumble
 
                 ExitScreen();
             }
+			foreach (var g in input.Gestures)
+			{
+				if (g.GestureType == GestureType.Tap)
+				{
+					if (Accepted != null)
+                       Accepted(this, EventArgs.Empty);
+					ExitScreen();
+				}
+			}
         }
 
 

+ 2 - 0
StarterKits/iOS/Platformer/Accelerometer.cs

@@ -13,6 +13,7 @@ using Microsoft.Xna.Framework;
 using Microsoft.Xna.Framework.Input;
 #endregion
 
+#if !ANDROID
 namespace Platformer
 {
     /// <summary>
@@ -178,3 +179,4 @@ namespace Platformer
         }
     }
 }
+#endif

+ 3 - 1
StarterKits/iOS/Platformer/PlatformerGame.cs

@@ -75,8 +75,10 @@ namespace Platformer
 #else
 			graphics.IsFullScreen = true;
 			graphics.SupportedOrientations =  DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight;
-#endif			
+#endif		
+#if WINDOWS_PHONE			
             Accelerometer.Initialize();
+#endif			
 
         }