简体   繁体   中英

Movie Clips Position Changes when user Backs out of Android AIR Game

Hey guys so I am having this strange issue with my Android AIR Game.

So everything on the game is aligned perfect but the problem that I am having is when say the user backs out of the app and then goes back into the app to continue playing the movie clips completely reposition themselves to the bottom right of the screen. They dont scale out of proportion or anything but just reposition. I dont understand why this is happening? This is currently what I use to scale everything for Android devices:

//Screen size for all devices
        stage.align = StageAlign.TOP_LEFT;
        stage.scaleMode = StageScaleMode.EXACT_FIT;
        stage.displayState = StageDisplayState.FULL_SCREEN;
        trace(stage.fullScreenWidth, stage.fullScreenHeight);

This code has always worked for me but say the user leaves the app and when they come back this Movie Clip or current movie clips:

        loadingScreen = new mcLoadingScreen();
        stage.addChild(loadingScreen);
        loadingScreen.x = (stage.stageWidth / 2);
        loadingScreen.y = (stage.stageHeight / 2);

will be repositioned to the bottom Right hand side of the screen. Any ideas? Thanks for any help I appreciate it!

Also I seemed to narrow it down. This only happens when the user presses the Home button and the screen orientation goes from Landscape which I have it set as, to Portrait. So when I go back into the app after that, all the Movie clips are re positioned

Try changing these configurations (I'm not telling that will fix the problem, just suggesting something that worked for me with an iOS device):

stage.scaleMode = StageScaleMode.NO_SCALE;
// stage.displayState = StageDisplayState.FULL_SCREEN;

in your Application Descriptor (XML file)

<aspectRatio>portrait</aspectRatio>
<autoOrients>false</autoOrients>
<fullScreen>true</fullScreen>

If doesn't work, probably what @Aaron suggested will the the start to solve this issue:

NativeApplication.nativeApplication.addEventListener(Event.ACTIVATE, function(event:Event):void
{
      // the application is reactivated 
});

NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE, function(event:Event):void
{
      // the application is deactivate to receive a phone call or when the user presses the Home button, etc
});

Add some traces and verify what changes. If you have events listeners like ENTER_FRAME, Event.RESIZE, be aware and remove these event listeners when the application is deactivate.

Hope will be possible to help you somehow.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM