简体   繁体   English

用户退出Android AIR游戏时影片剪辑的位置发生变化

[英]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. 大家好,我的Android AIR游戏遇到了这个奇怪的问题。

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: 目前,这是我用来扩展Android设备所有内容的方式:

//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): 尝试更改这些配置(我并不是说这可以解决问题,只是建议适用于iOS设备的某些功能):

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

in your Application Descriptor (XML file) 在您的应用程序描述符(XML文件)中

<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: 如果不起作用,@ Aaron可能会建议您开始解决此问题:

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. 如果您具有事件监听器,例如ENTER_FRAME,Event.RESIZE,请注意并在停用应用程序时删除这些事件监听器。

Hope will be possible to help you somehow. 希望有可能以某种方式帮助您。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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