SpriteLibrary
SpriteLibrary
SpriteLibrary
SpriteController Class
SpriteController Methods
ReplaceOriginalImage Method
ReplaceOriginalImage Method
ReplaceOriginalImage Method (Image)

# SpriteController ReplaceOriginalImage Method (Image)

Replace the image on which the sprites are drawn. Use this when you move to a new playing field, or want to have a different background
Examples
Replacing the background image is actually a lot more complex than you might imagine. Once you use the below code, it can be done without any problem. But you need to do it this way, or it just goofs up in a number of small ways. You need to tell the sprite controller that you are replacing the background image, and you need to change the image to that image as well.Because the Images are actually pointers to memory where the image sets, changes to one image will affect the other image.This goofs things up, so what we do is duplicate the image twice, and tell the sprite controller to use one of the copies and then set the background to be the other one of the two copies.Finally, we tell the picturebox to invalidate itself.That does everything that is needed.
C#
Copy

     void ReplaceBackground(Image NewBackground)
    {
        if (MyController == null) return;
        if (NewBackground == null) return;

        Image OneImage = new Bitmap(NewBackground);
        MyController.ReplaceOriginalImage(OneImage);

        Image TwoImage = new Bitmap(NewBackground);
        pb_map.BackgroundImage = TwoImage;
        pb_map.Invalidate();
    }

Namespace: SpriteLibrary
Assembly: SpriteLibrary (in SpriteLibrary.dll) Version: 1.0.0.6 (1.0.0.6)
Syntax
C#
Copy

    public void ReplaceOriginalImage(
    	Image tImage
    )

#### Parameters

tImage
  Type: System.Drawing
  Image
  The new image that all sprites will be drawn on

See Also

#### Reference

SpriteController Class
ReplaceOriginalImage Overload
SpriteLibrary Namespace