iPhone reverse device orientation in cocos2d - iphone

here's a weird question,
Is there a way to inverse the device orientation of the iPhone in cocos2d?
ex:
if the device is held in a landscape left position, i want the screen to show the landscape right and vice-versa.
so basically to let the device work in the opposite way of its intended use.
Thank you.

If you're creating a game where you want to invert the gravity of the world, I'd suggest you doing this without tweaking device orientation, but by changing gravity vector direction instead.

Related

Device roll compensation on augmented reality

I'm working on an app that performs geolocalization over the camera stream of the iPhone. I use the compass to figure out where to put the icons and information onto the the camera layer. If I rotate the device around yaw axis everything works fine.
However, when I roll the iPhone all the information on screen goes away. That's because when you roll the device the compass orientation also changes. However, there are apps like Layar or Wikitude that allow roll rotation without losing focus on the visual items you have onto the camera layer. That way, these apps allow smooth transition between portrait orientation to landscape orientation.
How they achieve that? How can I compensate the roll rotation of the device to keep information on screen?
By the way, the ARKit framework has the same problem as me.
Thanks.
If you are in 2D maybe it is enough to take the point you are calculating from camera field view and offset heading, calculate the distance to the center of the screen, and use that distance as a radius for a circle to do x += r*cos, y += r*sin with -roll as the angle, so the object moves in a circle against the roll. Then you just have to counter rotate the image itself with a transform (CGAffineTransformMakeRotation) to keep it vertical.

iOS 4 core motion attitude in landscape orientation

I've been trying to rotate my view based on the CMAttitude returned from CMMotionManager specifically the pitch=x and roll=y. I'm using a reference attitude to set my horizon.
This works great for portrait mode but the minute i try to do it for a landscape view it goes wrong.
As the phone is now rotated 90 ccw I was hoping that coremotion would know landscape was in place and keep the pitch and roll useful. Instead I still have the axis pointing their original way.
To try and compensate I simply changed the sign on roll=x and switched pitch=y.
This appeared to work till I held the device in front of me and the turned around 180 degrees. The view spun upside down and inverted.
My spidy sense is telling me I need to apply a proper transformation on the pitch roll and yaw to reorientate the attitude
I'm hoping some geniuses or genii can help me. Maths is obviously not a strong point of mine.
Your are right, changing pitch and roll will lead into serious trouble. The simplest way seems to work with a new reference attitude like in CoreMotionTeapot sample. Just when the orientation change is detected, you have to grab the current attitude before multiplying it with your former reference attitude and set it as new reference attitude.

Is it possible to detect the rotation of a single finger on the iPhone?

Is it possible to detect the rotation of a single finger in an iPhone application? I'm looking for rotation about a point, not rotation by moving the finger horizontally or vertically.
Assuming that the case you have in mind is when you set down a single finger and rotate it in place, then the answer is pretty much no. The only data you receive from the OS is (x,y) coordinates for each touch. (The OS has a little more to work off of -- in the private CoreScreen framework, you can I believe get some more detailed contact information, but it is not entirely clear how that would help.)
A rotating finger is likely to exhibit a little bit of wobble as it rotates, so you could perhaps attempt to find some pattern of wobbling that corresponds to rotation, but it is likely not to be very accurate.

Landscape mode in chipmunk/cocos2D

I'm trying to create a chipmunk space with a bouncing ball.(Example seen here)
Currently my device is running in Landscape mode. So according to cocos2D everything is all right. When adding Sprites they orient to landscape mode.
[director setDeviceOrientation:kCCDeviceOrientationLandscapeLeft];
The only problem is that the device orientation is screwed up when using chipmunk right now. When tilting the ipad towards the upper-left corner, my 'bouncing ball' moves towards the upper-right corner.
Is there a way to rotate a chipmunk space manually?
Or is there some other way to set rotation within a chipmunk space?
It sounds like a simple sign issue. I assume the balls are moved by applying a force to them. So instead of applying a positive force like (10, 0) apply a negative force (-10, 0) when moving the balls in one direction, and do the reverse in the other (eg multiply x coordinate forces by -1). Chipmunk doesn't care or know about device orientation, it just moves objects according to forces and gravity.

While playing sound acceleration occurs

I am developing one game where I want to move UIImageView based on accelerometer. When I rotate iphone device left to right or right to left the UIImageView have to rotate in particular angle. It's moving also but the problem occurs when I play background sound because of that sound, it sends some acceleration point even if my iphone is idle.
So my UIImageView is also moving. It should not happen. When I decrease the iphone sound volume it works very well. What I have to do for that.
And also if anyone knows how to get acceleration point only when iphone is moving from left to right or right to left. It should not detect when iphone is xz or yz plane.
If anybody knows the solution please reply.
Have you got any filtering on the input from the accelertometer? I would expect the noise from the speaker the accelerometer is picking up is vastly different in amplitude and frequency than the game control.
There is a simple low pass filter in the Apple accelerometer graph sample code.