示例#1
0
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            uiContext = new UIContext(new InputManager(), this);
            // view from slightly above and to the right, but far away TODO: for some reason we aren't looking at 0, 0, 0??
            uiContext.Camera = new FPSCamera(new Vector3(-2, 2, -10), new Vector3(0, 0, 0));
            var renderSubject = TemplateManager.Load("zdata.txt", "Spaceship1", GraphicsDevice);

            mainGameObject = new MainGameObject(uiContext, renderSubject);
            mainGameObject.Focus();
            int radii = 5;

            cursorTexture = new Texture2D(GraphicsDevice, radii * 2 + 1, radii * 2 + 1);
            Color[] data = new Color[(radii * 2 + 1) * (radii * 2 + 1)];
            for (int i = 0; i < radii * 2 + 1; i++)
            {
                data[i + (radii * 2 + 1) * radii] = Color.White; // horizontal
                data[i * (radii * 2 + 1) + radii] = Color.White; // vertical
            }
            cursorTexture.SetData(data);

            GlobalContent.Init(this.Content);

            int w = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width - 40;
            int h = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height - 40 - 45;

            _graphics.PreferredBackBufferWidth  = w;
            _graphics.PreferredBackBufferHeight = h;
            Window.Position = new Point(20, 20);
            //_graphics.IsFullScreen = true;
            _graphics.ApplyChanges();

            base.Initialize();
        }
 /// <summary>
 /// LoadContent will be called once per game and is the place to load
 /// all of your content.
 /// </summary>
 protected override void LoadContent()
 {
     // Create a new SpriteBatch, which can be used to draw textures.
     spriteBatch = new SpriteBatch(GraphicsDevice);
     Primitives2D.CreateThePixel(GraphicsDevice);
     drawContext = new DrawContext(spriteBatch);
     if (ScreenInfo.Default.HasMouse)
     {
         mouseTexture = Content.Load <Texture2D>("cross");
     }
     GlobalContent.Init(initContext);
     master.InitContent(initContext);
 }