Esempio n. 1
0
        public void Start(ExEnAndroidActivity activity)
        {
            // The graphics device manager will hopefully have been created by the derived class's constructor
            // It must be a GraphicsDeviceManager because it holds an ExEnAndroidSurfaceView that also handles our Draw/Update loop
            if(graphicsDeviceManager == null)
                throw new InvalidOperationException("Game requires that a GraphicsDeviceManager is created before calling Start");

            // Add the activity as a service (used by ContentManager)
            this.services.AddService(typeof(ExEnAndroidActivity), activity);

            // Start the game
            graphicsDeviceManager.StartGame(activity);
        }
        public ExEnAndroidSurfaceView(Game game, GraphicsDeviceManager gdm, ExEnAndroidActivity activity)
            : base(activity)
        {
            this.game = game;
            this.gdm = gdm;
            this.activity = activity;

            inputScaler = new ExEnScaler(ExEnInterfaceOrientation.Portrait, new Point(1, 1), new Point(1, 1));

            Holder.AddCallback(this);
            Holder.SetType(SurfaceType.Gpu);

            updateGameTime = new GameTime();
            drawGameTime = new GameTime();
            GameLoop.Update = DoUpdate;
            GameLoop.Draw = DoDraw;
        }
Esempio n. 3
0
        internal void StartGame(ExEnAndroidActivity activity)
        {
            if(activity.surface != null)
                throw new InvalidOperationException("Game has already been started");

            this.activity = activity;

            // Note: If the handling of the graphics device gets more complicated,
            //       this may have to be split into functions around what needs to be done before,
            //       during and after graphics device creation:
            ApplyChanges();

            // Create the game's view:
            surfaceView = new ExEnAndroidSurfaceView(game, this, activity);
            activity.surface = surfaceView;

            // Start the game running in the rendering thread
            surfaceView.StartGame();

            // Now that Game has started, make the view visible:
            activity.SetContentView(surfaceView);

            // Return outwards to the activity's OnCreate method...
        }