ADDSPRITE
Jump to navigation
Jump to search
Description
- This command adds a Sprite to a GRAPHICBOX or a Graphics Window, assigning to it a name, and one bitmap name or a list of several bitmaps names.
- The bitmap must be loaded first with the LOADBMP command, or created at runtime.
- A sprite bitmap must include a mask above and a sprite below, like this:
- To delete a Sprite, read REMOVESPRITE.
- The Background and Sprites will not show up until a DRAWSPRITES command is issued.
Syntax
GraphicBox Control
- Print #Handle.Extension, "addsprite spritename bmpname"
- Print #Handle.Extension, "addsprite spritename bmpname1 bmpname2 bmpname3"
- #Handle.Extension "addsprite spritename bmpname"
- #Handle.Extension "addsprite spritename bmpname1 bmpname2 bmpname 3"
Graphics Type Window
- Print #Handle, "addsprite spritename bmpname"
- Print #Handle, "addsprite spritename bmpname1 bmpname2 bmpname3"
- #Handle "addsprite spritename bmpname"
- #Handle "addsprite spritename bmpname1 bmpname2 bmpname3"
Hints
- The sprites could be several images of a character walking.
- Only one graphic-box or graphics window in a program may use sprites.
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] #main "Drawsprites" Wait [quit] Timer 0 Close #main UNLOADBMP "BMP" End
Useful Procedures
' Place a useful function using this keyword here