REMOVESPRITE

From Liberty BASIC Family
Jump to navigation Jump to search
Supported in Just BASIC Supported in Liberty BASIC Not supported in Liberty BASIC 5 Not supported in Run BASIC

Description

This command removes a Sprite from a GRAPHICBOX or a Graphics Window.
To add a sprite please read ADDSPRITE.

Syntax

GraphicBox Control

  1. Print #Handle.Extension, "removesprite spritename"
  2. #Handle.Extension "removesprite spritename"

Graphics Type Window

  1. Print #Handle, "removesprite spritename"
  2. #Handle "removesprite spritename"

Hints

Remember to avoid checking collisions, position and other properties for removed sprites. A way to know which sprites were removed is to create a string variable to hold a list.

Example

This example uses the image from this article. Save it to a folder of your choice and run this code from the same folder.

NOMAINWIN
LOADBMP "BMP","sprite_jb_guy_1.bmp"
Open "Just BASIC - Sprite Demo - Addsprite" For Graphics_nsb_nf as #main
    #main "Trapclose [quit]"
    #main "AddSprite player BMP"
    Timer 56,[redraw]
    Wait

    [redraw]
    counter = counter + 1
    ' when the counter reaches 40 we will remove the sprite
    if counter = 20 then
        #main "RemoveSprite player"
        ' set the timer to zero stop the timed loop
        timer 0

    end if

    #main "Drawsprites"

    Wait

[quit]
    Timer 0
    Close #main
    UNLOADBMP "BMP"
End

Useful Procedures

' Place a useful function or sub using this keyword here