Showing posts with label XNA. Show all posts
Showing posts with label XNA. Show all posts

Tuesday, December 7, 2010

Windows Phone 7 Quick Tip #24 – Hide the Status Bar in your XNA Application

To hide the status bar:

image

Simply set the property IsFullScreen on the GraphicsDeviceManager instance to true:

public Game1()
{
    graphics = new GraphicsDeviceManager(this);
    graphics.IsFullScreen = true;

Not only will this let your application take advantage of the full height of the device and not display the status bar it also will fill the width of your device to maintain the proper aspect ratio.  Let me explain.  If you specify your PreferredBackBuffer Width and Height to be 480x800 and not hide the status bar, there will be a margin on both the right and left of your screen.  Your screen will maintain your aspect ratio of 3/5.  This means since the height of your screen is not actually 800 pixels (because the status bar takes up a portion of the top of the screen), to maintain the aspect ratio, your width won’t be 480. 

This is especially obvious when you use Snippet in Windows Mode to capture a screen shot of your application, you will see a black border across the top and sides of your screen.  Setting graphics.IsFullScreen = true will allow your applications height to be 800 and thus the width will be 480 maintaining the correct aspect ratio and making the full use of the real-estate on the device.

-twb

Sunday, November 28, 2010

Windows Phone 7 Quick Tip #22 – Force Orientation in an XNA Game

While creating a Windows Phone 7 XNA game that uses the accelerometer, I noticed that as I tilted and rotated my phone, the screen orientation would switch from Landscape Left to Landscape Right, this obviously made the game a little difficult to play.

To resolve this, I simply changed the SupportedOrientations property on the graphics instance.  By default this is set to a landscape where the orientation changed based upon accelerometer input.  Adding the following line of code to my constructor resolved the issue.

graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft;

-twb

Windows Phone 7 Quick Tip #21 – Good Vibrations

Not an earth shattering tip this time, but I just spent the last 30 minutes “binging” how to make my phone vibrate and didn’t come up with anything.

As with most stuff in programming, it’s easy once you know how:

  1. Add a reference to Microsoft.Phone (if you are working in XNA and don’t already have one)
  2. Then call Start on Microsoft.Devices.VibrateController.Default with the number of milliseconds you want the phone to vibrate.

-twb

Tuesday, August 17, 2010

SW Florida .NET Developers Group

Tonight (August 17, 2010) I’ll be doing a little talk about about a hot technology you might have heard of called Windows Phone 7.

The first part of the talk will be dedicated to a quick overview of development for Windows Phone 7.  We won’t dwell on C# or Silverlight but will build three little applications that should give an overview of the development environment for Windows Phone:

  • W.O.P.R. – Slightly more exciting than “Hello World”
  • KLIK2WIN – Very simple silverlight game
  • John’s Game – Well you’ll have to attend to see what this one is about

The file for my presentation include both a step-by-step lab and the completed working applications.  You can download the files from here.

The second part of the talk should be a lot of fun, John asked that the user group members come up with Windows Phone 7 applications.  The group will then vote on the best app and we’ll talk about what it would take to implement it and start building the application frameworks.  We certainly won’t have time to finish the application but should be able to get an idea of what would be involved.

Hope to see you all there!

-twb

Monday, September 14, 2009

Crazy Coins Approved for Distribution on the Xbox 360

The XNA game Crazy Coins that I built for the Xbox 360 has been approved for distribution on the Indie Games area of XBox LIVE Marketplace.  Look for it available for purchase on your Xbox market place this Wednesday.

CrazyCoinsImage

Wednesday, April 15, 2009

Improving the rendering of your models with MultiSampling in XNA

When you first compile, build and render your models in XNA, they can look pretty bad.  By default MultiSampling isn’t enabled for your game.  If you enable MultiSampling, the appearance of your models will be greatly enhanced. 

MultiSampling will antialias the edges of the triangles for your model. According the XNA Developer Center

Antialiasing is the process of smoothing the edges of triangles by averaging neighboring pixels in a render target. Because this process samples multiple pixels, it is also known as multisampling.

The first screen capture is from the Windows version of my game that does not have MultiSampling enabled.

NoMultiSampling

 

The second screen capture show how this looks with MultiSampling enabled.

MultiSampling

 

As you can see the grid lines look much better as well as the guns and the edges of the ships.

 

Enabling MultiSampling is easy, in the constructor of your game you will need to set a property and hookup an event.

The instructions can be found at:

http://msdn.microsoft.com/en-us/library/bb975403.aspx

 

It’s important to note that you MUST setup your graphics device in the constructor.  I had done this in the Initialize function, at that point the Graphics Device has already been setup and resetting it causes very bad things to happen once you deploy your game to the XBOX 360 (this cost me about 4 hours that I’ll never get back).

Enjoy!

-ec