Question

I'm working an iPhone app called RealBaseball. If you're familiar with RealSoccer, it's pretty similar. It will allow you to play baseball with your iPhone with friends around the world.

When you hit the iPhone screen with your conductive bat, it should first detect the touch event then detect the acceleration so it knows exactly when you hit it, and how hard and how fast.

This is where I'm running into some technical difficulties. I have the standard touchesBegan and didAccelerate listeners. The problem is that didAccelerate is firing before touchesBegan. Clearly, something is wrong since it shouldn't start accelerating before the bat touches it. Could I be missing setup code?

I need to fix this, because if the timing is wrong, the batting machine on the other end will be laggy, and it won't be any fun.

Any advice you can provide would be appreciated.

EDIT: I added some NSLog calls with formatted [[NSDate date] timeIntervalSince1970]; Here's the output:

didAccelerate: 1364850400.03221
touchesBegan: 1364850400.21486

So you can see it's a small but clear difference.

Was it helpful?

Solution

How are you ensuring the bat is closing the conductive circuit from the phone to your hand? I'd suggest copious use of the material used to make gloves touchscreen friendly. Silver-threaded nylon is recommended here: http://www.howtogeek.com/130477/diy-touch-screen-mod-makes-regular-gloves-smartphone-friendly/

UPDATE: Oh, you might need to amplify the very tiny current that the bat will experience so it can travel all the way to your hand. I'm not an electrician but a portable car battery attached to the bat via the same thread should do the trick.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top