예제 #1
0
        public static TileGrid Create(Rectangle viewport, Texture2D texture, int numTilesX, int numTilesY, float heightScale, Vector2? worldOffset, Vector2 cameraOffset)
        {
            var tileWidth = texture.Width;
            var tileHeight = texture.Height;

            var spriteSheet = new SpriteSheet(texture);
            spriteSheet.AddSourceSprite(1, new Rectangle(0, 0, tileWidth, tileHeight));

            if (worldOffset == null)
            {
                var worldOffsetX = -viewport.Width / 2;
                var worldOffsetY = -viewport.Height / 2;
                worldOffset = new Vector2(worldOffsetX, worldOffsetY);
            }

            var tileGrid = new TileGrid(tileWidth, tileHeight, numTilesX, numTilesY, worldOffset.Value, cameraOffset, spriteSheet, viewport) { TileScale = heightScale };
            for (int i = 0; i < numTilesX; i++)
            {
                for (int j = 0; j < numTilesY; j++)
                {
                    tileGrid.SetTile(i, j, 1);
                }
            }

            return tileGrid;
        }
		public Vector2 Speed;            //Speed of movement of our parallax effect

		public ParallaxTileGridBackground(TileGrid tilegrid, Vector2 speed)
		{
			_tilegrid = tilegrid;
			Speed = speed;
		}