diff options
author | Ian C <ianc@noddybox.co.uk> | 2012-05-28 22:46:59 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2012-05-28 22:46:59 +0000 |
commit | 643c13f3ebd3240aa58f83a35a66909fdd9545d9 (patch) | |
tree | f342069f0a639d55e20f5913e758336932cdcf2d /WindowsPhone | |
parent | 60b52b009c2f74cea7d5ffb0ad62cbbc55c41729 (diff) |
Added test code to handle buttons to make sure drawing is OK.
Diffstat (limited to 'WindowsPhone')
-rw-r--r-- | WindowsPhone/JoystickTest/JoystickTest/Game1.cs | 41 | ||||
-rw-r--r-- | WindowsPhone/JoystickTest/JoystickTestContent/JoystickTestContent.contentproj | 17 | ||||
-rw-r--r-- | WindowsPhone/JoystickTest/JoystickTestContent/button.png | bin | 0 -> 6594 bytes | |||
-rw-r--r-- | WindowsPhone/JoystickTest/JoystickTestContent/joystick.png | bin | 0 -> 16006 bytes | |||
-rw-r--r-- | WindowsPhone/JoystickTest/JoystickTestContent/joystick_background.png | bin | 0 -> 109311 bytes |
5 files changed, 46 insertions, 12 deletions
diff --git a/WindowsPhone/JoystickTest/JoystickTest/Game1.cs b/WindowsPhone/JoystickTest/JoystickTest/Game1.cs index a5f8be3..53560a7 100644 --- a/WindowsPhone/JoystickTest/JoystickTest/Game1.cs +++ b/WindowsPhone/JoystickTest/JoystickTest/Game1.cs @@ -9,6 +9,8 @@ using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Input.Touch;
using Microsoft.Xna.Framework.Media;
+using Noddybox.Emulation.Xna.Input;
+using Noddybox.Emulation.Xna.Input.Joystick;
namespace JoystickTest
{
@@ -19,6 +21,12 @@ namespace JoystickTest {
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
+ InputManager manager;
+ JoystickDriver digital;
+ JoystickDriver analogue;
+ Texture2D background;
+ Texture2D button;
+ Texture2D joystick;
public Game1()
{
@@ -45,8 +53,6 @@ namespace JoystickTest /// </summary>
protected override void Initialize()
{
- // TODO: Add your initialization logic here
-
base.Initialize();
}
@@ -56,10 +62,21 @@ namespace JoystickTest /// </summary>
protected override void LoadContent()
{
- // Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
- // TODO: use this.Content to load your game content here
+ background = Content.Load<Texture2D>("joystick_background");
+ joystick = Content.Load<Texture2D>("joystick");
+ button = Content.Load<Texture2D>("button");
+
+ manager = new InputManager();
+
+ digital = new JoystickDriver(manager, GraphicsDevice, JoystickType.Digital, background, joystick, button,
+ Vector2.Zero, new Vector2(100), new Vector2[2] {new Vector2(300, 50), new Vector2(300, 150)},
+ 10, 100);
+
+ analogue = new JoystickDriver(manager, GraphicsDevice, JoystickType.Analogue, background, joystick, button,
+ new Vector2(0, 300), new Vector2(100), new Vector2[1] {new Vector2(300, 150)},
+ 10, 100);
}
/// <summary>
@@ -78,12 +95,7 @@ namespace JoystickTest /// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Update(GameTime gameTime)
{
- // Allows the game to exit
- if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
- this.Exit();
-
- // TODO: Add your update logic here
-
+ manager.Update();
base.Update(gameTime);
}
@@ -93,9 +105,14 @@ namespace JoystickTest /// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Draw(GameTime gameTime)
{
- GraphicsDevice.Clear(Color.CornflowerBlue);
+ GraphicsDevice.Clear(Color.White);
+
+ spriteBatch.Begin();
+
+ digital.Draw(spriteBatch);
+ analogue.Draw(spriteBatch);
- // TODO: Add your drawing code here
+ spriteBatch.End();
base.Draw(gameTime);
}
diff --git a/WindowsPhone/JoystickTest/JoystickTestContent/JoystickTestContent.contentproj b/WindowsPhone/JoystickTest/JoystickTestContent/JoystickTestContent.contentproj index 4ae643c..abe9430 100644 --- a/WindowsPhone/JoystickTest/JoystickTestContent/JoystickTestContent.contentproj +++ b/WindowsPhone/JoystickTest/JoystickTestContent/JoystickTestContent.contentproj @@ -29,6 +29,23 @@ <Reference Include="Microsoft.Xna.Framework.Content.Pipeline.AudioImporters, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=MSIL" />
<Reference Include="Microsoft.Xna.Framework.Content.Pipeline.VideoImporters, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=MSIL" />
</ItemGroup>
+ <ItemGroup>
+ <Compile Include="button.png">
+ <Name>button</Name>
+ <Importer>TextureImporter</Importer>
+ <Processor>TextureProcessor</Processor>
+ </Compile>
+ <Compile Include="joystick.png">
+ <Name>joystick</Name>
+ <Importer>TextureImporter</Importer>
+ <Processor>TextureProcessor</Processor>
+ </Compile>
+ <Compile Include="joystick_background.png">
+ <Name>joystick_background</Name>
+ <Importer>TextureImporter</Importer>
+ <Processor>TextureProcessor</Processor>
+ </Compile>
+ </ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
diff --git a/WindowsPhone/JoystickTest/JoystickTestContent/button.png b/WindowsPhone/JoystickTest/JoystickTestContent/button.png Binary files differnew file mode 100644 index 0000000..b2e483c --- /dev/null +++ b/WindowsPhone/JoystickTest/JoystickTestContent/button.png diff --git a/WindowsPhone/JoystickTest/JoystickTestContent/joystick.png b/WindowsPhone/JoystickTest/JoystickTestContent/joystick.png Binary files differnew file mode 100644 index 0000000..cb24378 --- /dev/null +++ b/WindowsPhone/JoystickTest/JoystickTestContent/joystick.png diff --git a/WindowsPhone/JoystickTest/JoystickTestContent/joystick_background.png b/WindowsPhone/JoystickTest/JoystickTestContent/joystick_background.png Binary files differnew file mode 100644 index 0000000..c7ac0d3 --- /dev/null +++ b/WindowsPhone/JoystickTest/JoystickTestContent/joystick_background.png |