Question

What I want to build;

App ALWAYS is in landscape mode (top of phone to the left!).

When the user flips the phone (over Y-axis, so user is looking at it's back, screen is in front of person sitting on the other end of the table) the orentation should change to Reversed Landscape. In that scenario, the TextView that is showing, will be right-side-up for the person looking at the screen.

Then, when the user flips back the phone, the orientation should change back to landscape.

But... (and here's the catch..) when the user turns the phone over the X-Axis (so looking at the screen, turns it (couter)clockwise, nothing should happen. (in the game, this would be cheating)

I tried using the onSensorChanged, but it doesn't behave like I described. Any thoughts? Thnx

public void onSensorChanged(SensorEvent event) {  

                TextView tv = (TextView) findViewById(R.id.TextView01);
                tv.setText("0 : " + event.values[0] + "1 : " + event.values[1] + " -- 2 : " + event.values[2]);

                if (event.values[1] < -6 || event.values[1] > 6) {
                    playfair();
                    return;
                } else {if (event.values[1] > -6 || event.values[1] < 6){cheat = false;}}
                if (event.values[0] < -8.5) {
                    if (state == PRE_ROUND)
                    startround();                                               
                } else {
                    if (state == SHOWING_OBJECT){
                        flipper.setInAnimation(inFromBottomAnimation(1));
                        flipper.setOutAnimation(outToTopAnimation(1));
                        flipper.setDisplayedChild(1);

                        state = PRE_ROUND;  
                    }

                }                   
            }

Pas de solution correcte

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top