Windows Phone 7 Flashlight

Now that the developer tools for Windows Phone 7 are out in the wild, I wondered how long before we see the ubiquitous “flashlight” app. I decided to grab the bull by the horns and put it out there myself. So find below the steps required to make your own flashlight app

  1. Create a new XNA Game Project for the phone
  2. Add this line of code to the Draw method:
graphics.GraphicsDevice.Clear(Color.White);

And BAM! that’s it!

4 Comments »

  1. Zachary Snow Said,

    March 16, 2010 @ 2:36 am

    Isn’t the XNA Framework amazing? The flashlight app in one line of code.

  2. Leaf Said,

    March 16, 2010 @ 2:41 am

    Pah, my real flashlight can send out “SOS” in morse code. Let’s see that in one line :)

  3. GoGo-Robot Said,

    March 19, 2010 @ 6:53 am

    Couldn’t resist :)

    graphics.GraphicsDevice.Clear(
    /* Check for touch panel being pressed */
    TouchPanel.GetState().Count == 0 ?
    /* Touch panel released, so reset the timer. This is stored in the target elapsed time, so we don’t have to create any variables :) We also turn off IsFixedTimeStep, so that TargetElapsedTime isn’t used. */
    ((((this.IsFixedTimeStep = false) == false) && ((this.TargetElapsedTime = TimeSpan.FromMilliseconds(Math.Max(1.0f, gameTime.TotalGameTime.TotalMilliseconds))) == TimeSpan.Zero)) ? Color.Gray : Color.Gray) :
    /* Touch panel pressed, so do SOS */
    (gameTime.TotalGameTime – this.TargetElapsedTime).Seconds = 2) && ((gameTime.TotalGameTime – this.TargetElapsedTime).Seconds = 4) && ((gameTime.TotalGameTime – this.TargetElapsedTime).Seconds = 7) && ((gameTime.TotalGameTime – this.TargetElapsedTime).Seconds = 10) && ((gameTime.TotalGameTime – this.TargetElapsedTime).Seconds = 13) && ((gameTime.TotalGameTime – this.TargetElapsedTime).Seconds = 17) && ((gameTime.TotalGameTime – this.TargetElapsedTime).Seconds = 19) && ((gameTime.TotalGameTime – this.TargetElapsedTime).Seconds = 21) && ((gameTime.TotalGameTime – this.TargetElapsedTime).Seconds < 22)) ? Color.White :
    Color.Black);

  4. GoGo-Robot Said,

    March 19, 2010 @ 7:03 am

    Bah! Comments mangled the code :( I’ve posted it here: http://www.gogo-robot.com/2010/03/19/windows-phone-7-flashlight-with-sos/

RSS feed for comments on this post

Leave a Comment