ResolutionPolicy FixedHeight not working

GillesVogelesangGillesVogelesang NLMember
edited January 2016 in CocosSharp


I am using CocosSharp in my game (CocosSharp Game template). In the ViewController.cs file of the iOS project, I am setting the ResolutionPolicy of the gameView to CCViewResolutionPolicy.FixedHeight in the LoadGame method.

void LoadGame (object sender, EventArgs e)
            CCGameView gameView = sender as CCGameView;

            if (gameView != null) {
                var contentSearchPaths = new List<string> () { "Fonts", "Sounds" };
                CCSizeI viewSize = gameView.ViewSize;

                int width = 500;
                int height = 500;

                // Set world dimensions
                gameView.DesignResolution = new CCSizeI (width, height);
                gameView.ResolutionPolicy = CCViewResolutionPolicy.FixedHeight; // <--

                // Determine whether to use the high or low def versions of our images
                // Make sure the default texel to content size ratio is set correctly
                // Of course you're free to have a finer set of image resolutions e.g (ld, hd, super-hd)
                if (width < viewSize.Width) {
                    contentSearchPaths.Add ("Images/Hd");
                    CCSprite.DefaultTexelToContentSizeRatio = 2.0f;
                } else {
                    contentSearchPaths.Add ("Images/Ld");
                    CCSprite.DefaultTexelToContentSizeRatio = 1.0f;

                gameView.ContentManager.SearchPaths = contentSearchPaths;

                CCScene gameScene = new CCScene (gameView);
                gameScene.AddLayer (new GameLayer ());
                gameView.RunWithScene (gameScene);

The problem is that game starts with a distorted view (it looks like the ExactFit Policy). After a replace of the scene with the same GameLayer, the view will be shown correctly conform the FixedHeight Policy.

Does anybody know how I can solve this, so the game will start with the correct ResolutionPolicy (FixedHeight)?


Sign In or Register to comment.