コード例 #1
0
ファイル: Camera.cs プロジェクト: pablobaxter/XNA_Base
        /// <summary>
        /// Update method to focus camera on player that is passed.
        /// Point of focus is center of sprite image.
        /// </summary>
        /// <param name="map">Used to keep camera from going off the map.</param>
        /// <param name="player">Player to focus camera on.</param>
        public void Update(TileMap map, Player player)
        {
            position.X = player.Position.X + (player.Width / 2 - screenWidth / 2);
            position.Y = player.Position.Y + (player.Height / 2 - screenHeight / 2);

            position.X = MathHelper.Clamp(position.X, 0.0f, map.Width - screenWidth);
            position.Y = MathHelper.Clamp(position.Y, 0.0f, map.Height - screenHeight);
        }
コード例 #2
0
ファイル: Game1.cs プロジェクト: pablobaxter/XNA_Base
        /// <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);

            //Loads all tile textures to a list for easy map creation.
            textures.Add(Content.Load<Texture2D>("Test_Sprites/checker"));

            //Loads sprite.
            sprite = new Player(
                Content.Load<Texture2D>("Test_Sprites/sprite1"),
                Vector2.Zero,
                4);
        }