Engine.Objects.Layer.CreateNew C# (CSharp) Method

CreateNew() public method

Creates a blank layer.
public CreateNew ( short width, short height ) : void
width short Width in tiles to use.
height short Height in tiles to use.
return void
        public void CreateNew(short width, short height)
        {
            Width = width;
            Height = height;
            Name = "Untitled";
            ParallaxX = 1.0f;
            ParallaxY = 1.0f;

            _tiles = new TwoArray<short>(width, height);
        }

Usage Example

Example #1
0
        /// <summary>
        /// Creates a new map with values.
        /// </summary>
        /// <param name="width">The width in tiles.</param>
        /// <param name="height">The height in tiles.</param>
        /// <param name="tileWidth">The tilewidth in pixels.</param>
        /// <param name="tileHeight">The tileheight in pixels.</param>
        /// <param name="tilesetPath">The path to the tileset.</param>
        public void CreateNew(short width, short height, short tileWidth, short tileHeight, string tilesetPath)
        {
            for (int i = 0; i < 9; ++i) Scripts.Add("");

            // create a base layer:
            Layer layer = new Layer();
            layer.CreateNew(width, height);
            Layers.Add(layer);

            // create a starting tile:
            Tileset = new Tileset();

            if (string.IsNullOrEmpty(tilesetPath))
                Tileset.CreateNew(tileWidth, tileHeight);
            else
            {
                Tileset = Tileset.FromFile(tilesetPath);
                Scripts[0] = Path.GetFileName(tilesetPath);
            }
        }