Beispiel #1
0
        public AndroidTextInput(AndroidGameView view)
        {
            this.view = view;
            activity  = (AndroidGameActivity)view.Context;

            inputMethodManager = view.Context.GetSystemService(Context.InputMethodService) as InputMethodManager;
        }
        protected override void OnElementChanged(ElementChangedEventArgs <Controls.MonoGameView> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null || Element == null)
            {
                return;
            }

            if (e.OldElement != null)
            {
                // remove handlers
            }

            if (e.NewElement != null)
            {
                if (Control == null)
                {
                    var activity = Context as Activity;
                    Game.Activity = activity;

                    _game     = new TestGame();
                    _gameView = (Android.Views.View)_game.Services.GetService(typeof(Android.Views.View));
                    SetNativeControl(_gameView);
                    _game.Run();
                    AndroidGameActivity.ExternalActivityResumed(this);
                }

                // add handlers
            }
        }
Beispiel #3
0
        public HostGame(ICoreGame preloadedCoreGame)
#endif
        {
#if !PLATFORM_ANDROID
            _coreGame = preloadedCoreGame;
#endif

            _graphicsDeviceManager = new GraphicsDeviceManager(this);

            if (_coreGame != null)
            {
                _coreGame.AssignHost(this);
                _shouldHandleResize = true;
                _windowWidth        = Window.ClientBounds.Width;
                _windowHeight       = Window.ClientBounds.Height;
                _coreGame.PrepareGraphicsDeviceManager(_graphicsDeviceManager);
                _graphicsDeviceManager.PreparingDeviceSettings +=
                    (sender, e) =>
                {
                    _coreGame.PrepareDeviceSettings(e.GraphicsDeviceInformation);
                };
            }
            else
            {
                _shouldLoadContentOnDelayedGame = false;
                _backgroundColor = Color.Black;
#if PLATFORM_ANDROID
                _graphicsDeviceManager.IsFullScreen = true;
                _gameActivity = gameActivity;
                try
                {
                    var layout       = _gameActivity.Window.DecorView.FindViewById(Android.Resource.Id.Content);
                    var colorId      = _gameActivity.Resources.GetIdentifier("splash_background", "color", Android.App.Application.Context.PackageName);
                    var androidColor = _gameActivity.Resources.GetColor(colorId);
                    _backgroundColor = new Color(androidColor.R, androidColor.G, androidColor.B, (byte)255);
                }
                catch
                {
                    // Setting background is optional.
                }
#endif
            }
        }
Beispiel #4
0
 public GestureListener(AndroidGameActivity activity)
     : base()
 {
     this.activity = activity;
 }
Beispiel #5
0
 public GestureListener(AndroidGameActivity activity) : base()
 {
     this.activity = activity;
 }
Beispiel #6
0
 public HostGame(AndroidGameActivity gameActivity)
        public Skeleton ReadSkeletonJsonFile(AndroidGameActivity activity, string jsonFile, float scale = 1)
        {
            string jsonText = null;

            using (var inputStram = activity.Assets.Open(jsonFile))
            {
                jsonText = new StreamReader(inputStram).ReadToEnd();
            }

            var skeletonData = CreateSkeletonData(jsonFile, scale, jsonText);

            return new Skeleton (skeletonData);
        }
 void ActivityResumed(AndroidGameActivity activity)
 {
     _sensorManager.RegisterListener(_listener, _sensor, SensorDelay.Game);
 }
 void ActivityPaused(AndroidGameActivity activity)
 {
     _sensorManager.UnregisterListener(_listener, _sensor);
 }
Beispiel #10
0
 public AndroidPlatform(AndroidGameActivity mainActivity)
 {
     this.activity = mainActivity;
 }