Game not starting: Black screen

Topics: Windows Phone 8
Oct 2, 2013 at 3:59 PM
Hello,

I have an existing Cocos2D-XNA game for windows phone that works fine with the latest version of the master branch (I updated the branch today). However, on Windows Phone 8 it doesn't start. I only see a black screen.

As a project template I used this template because it supports XAML:
http://visualstudiogallery.msdn.microsoft.com/3fb72ac5-2068-4908-a7b1-4e7130892f16

I do require XAML for a couple of things.

Currently I am at the stage that all compiles. The first problem is the following exception:

NotSupportedException
method: private static EffectParameterCollection ReadParameters(BinaryReader reader)
class: Microsoft.Xna.Framework.Graphics.Effect

reason: type is Texture2D

I do not know if this causes problems down the line. The exception is catched and initialisation of the aplication continues.

Second problem is in CCDirector.SetOpenGL()

The projection is set as 3D and this causes the Matrix.CreatePerspectiveFieldOfView to throw an exception.

I have managed to eliminate this exception by calling

pDirector.Projection = CCDirectorProjection.Projection2D;

before calling SetOpenGL()

Unfortunately this is not the last of the problems. The application freezes when I have loaded my scene and added it to the Director. There is one more exception (NotSupportedException in ReadParameters method of Effect class). The screen stays black, but the loading animation stops (i.e. the dots do not move)

I have looked at the test example for Windows Phone 8, but this one alos shows only a black screen. However, the exceptions seems to be different.

Any help welcome.

Cheers
Tom
Oct 3, 2013 at 5:35 PM
Hello,

I have further debugged the problems today and I have found a solution.

1) Need to change the order of some calls in the method AppDelegate.ApplicationDidFinishLaunching()

the test and my code calls in this order
CCDirector pDirector = CCDirector.SharedDirector;
pDirector.SetOpenGlView();
CCDrawManager.SetDesignResolutionSize(480, 800, CCResolutionPolicy.ShowAll);
This causes problems when pDirector.SetOpenGlView() is called as the size is 0 in Matrix.CreatePerspectiveFieldOfView()

if you change the order it works fine:
CCDirector pDirector = CCDirector.SharedDirector;
CCDrawManager.SetDesignResolutionSize(480, 800, CCResolutionPolicy.ShowAll);
pDirector.SetOpenGlView();
2) There is a problem with the version of Monogame used on the master branch. I have compared this with a previous version and there is a difference in the Effect class that causes problems. The switch statement in the Effect.ReadParameters() method has a default case that throws an exception. This causes the application to block and results in a black screen. The default case is not present in earlier versions so I commented it out.

What's the best way to report these kind of things?

Cheers
Tom
Coordinator
Oct 15, 2013 at 5:46 AM
hi Tom, the effect class was fixed shortly after it was broken. Please make sure that you update the submodule in your fork, if you are using a fork. There is a sample script file in the cocos2d-xna master branch that demonstrates the commands used to update the submodule's head.

The other finding about ordering of calls to setup the OpenGL view and setting the design resolution are interesting. We'll take a look at why that is.