I’m on cocos2d and I have a sprite that I would like to rotate with the accelerometer.
I’ve heard about CMMotionManager. I would like to know if it is possible to use it just for 2D rotation, and, if yes, how?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
put this in
onEnter:you need to conform to
UIAccelerometerDelegatelike so:and implement this in
MyClass.m:edit: almost forgot…put
accelerometer.delegate = nil;inonExitnote that the method is called every time the accelerometer changes value..in all 3 vectors
cards on the table..i didnt use accelerometer …ever..but it should look something like this…check the rotation property in the documentation and play a little with it
hope it helps
PS: loved the “sorry for my english i’m french” part…hilarious
edit: here is my test of that code..and made a few modifications..it works fairly smooth..if you dont like it play around with the values.