none
How to delete image from Graphic Window when new was created?

    Question

  • Hello

    When program has created a new image. How to delete old image? I'm going to delete old image which is called "Postac". There is some items like "Postac" "Mapa" beacause I wrote this program in Polish. Thank you for help!

    Postac = "D:\MSB GAME\Textury\Postac.png"
    mapa = "D:\MSB GAME\Textury\mapatest.png"
    x = 650
    y = 320
    GraphicsWindow.DrawResizedImage(mapa,1,1,1400,800)
    GraphicsWindow.DrawResizedImage(Postac,x,y,100,100)


    GraphicsWindow.KeyDown = keydown
    Sub keydown
      Postac = "D:\MSB GAME\Textury\Postac.png"
      mapa = "D:\MSB GAME\Textury\mapatest.png"
      lastkey = GraphicsWindow.LastKey
      If lastkey = "Right" Then
        x = x + 100
        GraphicsWindow.DrawResizedImage(Postac,x,y,100,100)
      EndIf
    EndSub

    Sunday, March 19, 2017 8:33 PM

All replies

  • JarekJaroslaw,

    All you have to do is issue: "GraphicsWindow.Clear()". I have taken your program and made it work as below. You need to do an imagelist.loadimage to bring the file in that you want to load. I changed the x values to what I needed to show on the screen. So it first shows the image to the left before hitting a key. Hit a key and that image disappears due to the graphicswindow.clear() function. Then it is redrawn to the right if you if the right key.

    Postac=ImageList.LoadImage("c:\temp\ms.png")
    'Postac = "D:\MSB GAME\Textury\Postac.png"
    mapa = "D:\MSB GAME\Textury\mapatest.png"
    'x = 650
    x=50
    y=50
    'y = 320
    GraphicsWindow.DrawResizedImage(mapa,1,1,1400,800)
    GraphicsWindow.DrawResizedImage(Postac,x,y,100,100)


    GraphicsWindow.KeyDown = keydown
    Sub keydown
      GraphicsWindow.Clear()
      'Postac = "D:\MSB GAME\Textury\Postac.png"
      mapa = "D:\MSB GAME\Textury\mapatest.png"
      lastkey = GraphicsWindow.LastKey
      If lastkey = "Right" Then
        x = x + 100
        GraphicsWindow.DrawResizedImage(Postac,x,y,100,100)
      EndIf
    EndSub


    JR

    Monday, March 20, 2017 12:28 AM