android - Orientation Issue in Andengine Live Wallpaper -
i have live wallpaper in market runs potrait mode, in landscape.. looks stretched , bad. have developed wallpaper in andengine. looked through web figure out need implement onconfigurationchanged() method take care of orientation changes. used solution proposed here :-
following onconfigurationchanged() method
@override public void onconfigurationchanged(configuration newconfig) { if (mode == 0) { if (newconfig.orientation == configuration.orientation_portrait) { mmainscene.setscale(1); mmainscene.setposition(0, 0); } else if (newconfig.orientation == configuration.orientation_landscape) { mmainscene.setscaley(1.5f); mmainscene.setscalex(0.5f); mmainscene.setposition(260, -500); } } else if (mode == 1) { if (newconfig.orientation == configuration.orientation_portrait) { mmainscene.setscaley(0.5f); mmainscene.setscalex(1.5f); mmainscene.setposition(-500, 250); } else if (newconfig.orientation == configuration.orientation_landscape) { mmainscene.setscale(1); mmainscene.setposition(0, 0); } } }
the problem when see wallpaper in preview mode, mmainscene gets shifted right 260 pixels have specified in onconfigurationchanged() method. think problem can solved if can detect when wallpaper in preview mode can't seem find out how to? did try basewallpaperglengine.ispreview() method gives me nullpointer exception. can me?
you can handle orientation change more properly, , avoid problems in preview mode. @ answer: andengine portrait distortion rotationmodifier
Comments
Post a Comment