Warning: Cannot modify header information - headers already sent by (output started at C:\HostingSpaces\slamdunk\slamdunksoftware.com\wwwroot\index.php:1) in C:\HostingSpaces\slamdunk\slamdunksoftware.com\wwwroot\wp-includes\feed-rss2.php on line 8
Slamdunk Software http://www.slamdunksoftware.com "It's showtime!" Sat, 26 Nov 2011 21:23:19 +0000 en hourly 1 http://wordpress.org/?v=3.1 How to get iPhone/iPad angle from accelerometer using MonoTouch http://www.slamdunksoftware.com/how-to-get-iphoneipad-angle-from-accelerometer-using-monotouch/ http://www.slamdunksoftware.com/how-to-get-iphoneipad-angle-from-accelerometer-using-monotouch/#comments Wed, 16 Mar 2011 01:53:37 +0000 slamdunk http://www.slamdunksoftware.com/?p=73 Continue reading ]]> For a new game that we’re working on at Slamdunk Software, I needed to be able to work out the angle that the iPhone/iPad was on.

It was quite simple to get it working in MonoTouch. I created a new view controller with xib and in the Initialize() method I put the following code…

void Initialize ()
{
     UIAccelerometer.SharedAccelerometer.UpdateInterval = 0.05;

     UIAccelerometer.SharedAccelerometer.Acceleration +=
                delegate(object sender, UIAccelerometerEventArgs e)
     {
          double accelerationX = e.Acceleration.X;
          double accelerationY = - e.Acceleration.Y;
          double currentRawReading = Math.Atan2(accelerationY, accelerationX);

          angle = RadiansToDegrees(currentRawReading);

          // Display Angle
          lblAngle.Text = angle.ToString();
      };
}

private double RadiansToDegrees(double radians)
{
	return radians * 180/Math.PI;
}

So there you have it! Enjoy

]]>
http://www.slamdunksoftware.com/how-to-get-iphoneipad-angle-from-accelerometer-using-monotouch/feed/ 0
Development Blog! http://www.slamdunksoftware.com/hello-world/ http://www.slamdunksoftware.com/hello-world/#comments Sun, 13 Mar 2011 23:34:52 +0000 slamdunk http://www.slamdunksoftware.com/?p=1 Continue reading ]]> Welcome to my development blog! My name is Andrew, the developer at Slamdunk Software. I’ll be posting tips and code samples for iPhone, iPad and Android development.

I’ve had a lot of help along the way from the development community whilst developing our first few apps Techitot Pets for iPhone and Android and Landlubbers for iPhone and Android,  so here’s my chance to give something back.

I’ve developed for iOS with Objective-C and X-Code and also C# .Net with MonoTouch. For Android I used Java and Eclipse.

Thanks for checking out my Development Blog :)

Andrew.

 

]]>
http://www.slamdunksoftware.com/hello-world/feed/ 0