Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stage.getOrientation() Always returns 0 #651

Open
PaulGene opened this issue Sep 26, 2019 · 2 comments
Open

Stage.getOrientation() Always returns 0 #651

PaulGene opened this issue Sep 26, 2019 · 2 comments
Labels

Comments

@PaulGene
Copy link
Contributor

No description provided.

@PaulGene
Copy link
Contributor Author

PaulGene commented Sep 26, 2019

Uncommenting this line fixes it https://github.com/haxenme/nme/blob/master/templates/android/java/org/haxe/nme/GameActivity.java#L1039

I know it says it shouldn't be done in the GUI thread but surely it's better than breaking functionality ?

@codeservice
Copy link
Contributor

I am using:

@OverRide public void onSensorChanged(SensorEvent event)
{
if(mView == null)
return;
loadNewSensorData(event);
// this should not be done on the gui thread
//NME.onDeviceOrientationUpdate(prepareDeviceOrientation());
final int _orientation = prepareDeviceOrientation();
if(orientation != _orientation){
orientation = _orientation;
mView.queueEvent(new Runnable(){
public void run(){
if(mView != null)
mView.HandleResult(NME.onDeviceOrientationUpdate(_orientation));
}
});
}
}

Works well for me. Would be great implement related event:
https://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/StageOrientationEvent.html
This could help with preventing stage orientation changing when we need:
"The orientationChanging (StageOrientationEvent.ORIENTATION_CHANGING), is dispatched before the screen changes to a new orientation. Calling the preventDefault() method of the event object dispatched for orientationChanging prevents the stage from changing orientation."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants