Example #1
0
    /// <summary>
    /// Stack the sprites, but with a custom spacing between each layer.
    /// </summary>
    public void MakeStackFromPath(string path, int offsetSize)
    {
        int offset = 0;

        foreach (var image in GetSpritesFromPath(path))
        {
            // Loading Image
            var image_ = new Image();
            image_.Load(image);

            // Making ImageTexture from image.
            var texture = new ImageTexture();
            texture.CreateFromImage(image_);
            texture.SetData(image_);

            // Adding the layer
            var sprite = new Sprite();
            sprite.SetTexture(texture);
            sprite.Position -= new Vector2(0, offset * offsetSize);
            sprite.Name      = offset.ToString();

            Layers[Layers.Length] = sprite;
            AddChild(sprite);

            // Increasing the offset for next layer.
            offset += 1;
        }
    }
Example #2
0
    /// <summary>
    /// Stack the sprites
    /// </summary>
    public void MakeStackFromPath(string path)
    {
        // Set the name of the stack to the name of the loaded folder.
        string[] path_ = path.Split("\\");
        this.Name = path_[path_.Length - 1];

        int offset = 0;

        foreach (var image in GetSpritesFromPath(path))
        {
            // Loading Image
            var image_ = new Image();
            GD.Print(image);
            image_.Load(image);

            // Making ImageTexture from image.
            var texture = new ImageTexture();
            texture.CreateFromImage(image_);
            texture.SetData(image_);

            // Adding the layer
            var sprite = new Sprite();
            sprite.SetTexture(texture);
            sprite.Position -= new Vector2(0, offset);
            sprite.Name      = offset.ToString();

            Layers[Layers.Length - 1] = sprite;
            this.AddChild(sprite);

            // Increasing the offset for next layer.
            offset += 1;
        }
    }
Example #3
0
        public override void _Process(float delta)
        {
            if (_needUpdate)
            {
                _needUpdate = false;

                if (texture == null)
                {
                    texture = new ImageTexture();
                    texture.CreateFromImage(image);
                }
                else
                {
                    if (image.GetFormat() == texture.GetFormat())
                    {
                        texture.SetData(image);
                    }
                }
                Update();// for call _Draw
            }
        }