Accelerometer :S - MacRumors Forums
Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Oct 19, 2009, 05:14 PM   #1
JavaWizKid
macrumors 6502a
 
Join Date: Sep 2008
Send a message via MSN to JavaWizKid Send a message via Skype™ to JavaWizKid
Accelerometer :S

I've coded this:
Code:
- (void)accelerometer:(UIAccelerometer *)acel didAccelerate:(UIAcceleration *)aceler {
	
	if (fabsf(aceler.x) > 0.5)
	{
		spaceshipVelocity = CGPointMake(kSpaceshipMovingrX,kSpaceshipY);
	}
	if (fabsf(aceler.x) <= 0.5 && fabsf(aceler.x) >= 0)
	{
		spaceshipVelocity = CGPointMake(kSpaceshipX,kSpaceshipY);
	}
	if (fabsf(aceler.x) < -0.5)
	{
		spaceshipVelocity = CGPointMake(kSpaceshipMovinglX,kSpaceshipY);
	}
	if (fabsf(aceler.x) >= -0.5 && fabsf(aceler.x) <= 0)
	{
		spaceshipVelocity = CGPointMake(kSpaceshipX,kSpaceshipY);
	}
}
and for some reason it doesn't execute the negative commands? Any suggestions as to what is wrong?
JavaWizKid is offline   0 Reply With Quote
Old Oct 19, 2009, 05:19 PM   #2
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
fabsf() returns an absolute value. Thus, there are no negatives.
__________________
dejo is online now   0 Reply With Quote
Old Oct 19, 2009, 05:25 PM   #3
JavaWizKid
Thread Starter
macrumors 6502a
 
Join Date: Sep 2008
Send a message via MSN to JavaWizKid Send a message via Skype™ to JavaWizKid
Any workaround?
JavaWizKid is offline   0 Reply With Quote
Old Oct 19, 2009, 05:35 PM   #4
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by JavaWizKid View Post
Any workaround?
Workaround? I'm not sure you're approaching this correctly if you think a workaround is the solution. Maybe do a bit more research into UIAcceleration, UIAccelerationValue and how those work.
__________________
dejo is online now   0 Reply With Quote
Old Oct 19, 2009, 05:41 PM   #5
JavaWizKid
Thread Starter
macrumors 6502a
 
Join Date: Sep 2008
Send a message via MSN to JavaWizKid Send a message via Skype™ to JavaWizKid
I meant a way to get negative values because tilting one way and only one way seems a bit pointless
JavaWizKid is offline   0 Reply With Quote
Old Oct 19, 2009, 05:47 PM   #6
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by JavaWizKid View Post
I meant a way to get negative values because tilting one way and only one way seems a bit pointless
UIAccelerationValue can already contain a negative.
__________________
dejo is online now   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Need help with accelerometer in objective c xcode MozzaCheese iPhone/iPad Programming 1 May 19, 2014 01:39 PM
iPad: Accelerometer/gyro off on my ipad air. richard371 iPad 1 Nov 2, 2013 11:29 PM
Accelerometer Question. Rory Manton iPhone Tips, Help and Troubleshooting 4 Oct 31, 2013 12:37 AM
iMac accelerometer query thomas223 iMac 7 Nov 17, 2012 09:51 PM
rMBP doesn't have an accelerometer? mgmusicman94 MacBook Pro 2 Jun 29, 2012 11:46 AM

Forum Jump

All times are GMT -5. The time now is 02:38 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC