Closed Zambiorix closed 10 years ago
when building the android test solution "cocos2d-xna.Tests.Android", I get the same errors ..
Yes, MonoGame has recently changed the manner in which we get the activity context. Now we do it via a more elegant API that uses the Activity assigned to the game. You will see some commits from me that addressed that in our source tree on GitHub here.
From CCLabel-Android:
if (_paint == null) { var display = Game.Activity.WindowManager.DefaultDisplay; var metrics = new DisplayMetrics(); display.GetMetrics(metrics);
Closing - non-issue for us. Just a refactoring change in MonoGame.
Make sure you update the submodule (MonoGame) so you get the latest code from there.
I don't understand how this can be closed?
I made a complete new clone from the cocos2d-xna project including all submodules. Then I try to to build the cocos2d-xna test example. That fails for the android example...
See the included image above.
How must I set the content view in the android game activity ? Your examples are not adapted ..
Can you please run your Android test example in cocos2d-xna? (cocos2d-xna.Tests.Android) A fresh clone with all submodules updated does not work, the test example is broken. The problem is in the OnCreate of the main activity ..
Game1.Activity = this;
var game = new Game1();
var frameLayout = new FrameLayout(this);
frameLayout.AddView(game.Window);
this.SetContentView(frameLayout);
How must I setup the Game + activity correctly with the new changes in MonoGame? (MonoGame does have tests for iOS & Windows etc, but I cannot find any for Android ??)
Your answer above with code: I fail to see how that solves my problem ?
From CCLabel-Android:
if (_paint == null) { var display = Game.Activity.WindowManager.DefaultDisplay; var metrics = new DisplayMetrics(); display.GetMetrics(metrics);
Here is what you need:
var game = new Game1();
var frameLayout = new FrameLayout(this);
frameLayout.AddView((View)game.Services.GetService(typeof(View)));
this.SetContentView(frameLayout);
//SetContentView(game.Window);
game.Run(GameRunBehavior.Asynchronous);
Forgot to push up my changes to the tests .... probably was waiting for my Android license to finally allow me to actually USE it.
https://github.com/Cocos2DXNA/cocos2d-xna/commit/e1b087f4a105678313f97e61a8885c51585d66ec
Templates and test code has been updated. Sorry for all of the confusion.
Thank you!
On Android, has the initialisation of the AndroidGameActivity changed? In alle examples I see the code below:
But I get 2 exceptions when trying to build.
Sources.Android/Activity.cs(68,11): error CS1502: The best overloaded method match for
Android.Views.ViewGroup.AddView(Android.Views.View)' has some invalid arguments Sources.Android/Activity.cs(68,31): error CS1503: Argument
#1' cannot convertMicrosoft.Xna.Framework.GameWindow' expression to type
Android.Views.View'The code below used to work on cocos2d xna clone a few months old