![]() |
Source Code |
4 | vbMedia |   |
NOTE:
this code has been superceded by the version at the new site.
|
  |
Transparent Sprite Library
This sample requires the SSubTmr.DLL component because it includes an implementation of the COMCTL32.DLL Slider control. Make sure you have loaded and registered this before trying the BlobSaver project.
This VB library aims to make it simple to add fast, animated graphics using transparent sprites,
something which is either missing or dismally slow using VB's standard methods. To get quicker
or smoother than this, you'll need to use Direct X (article coming soon!)
Creating Sprite and Mask from the Bitmap: |
  |
  |
|
|
|
|
  |
  |
ORing the Mask onto the Background: |
  |
  |
|
|
|
|
  |
  |
ANDing the Sprite to Get the Transparent Effect: |
  |
  |
|
|
|
|
  |
  |
Initial position: |
  |
  |
|
|
  |
  |
Restore the background behind the sprite into the stage (repeating for all other sprites in the scene): |
  |
  |
|
|
  |
  |
Move the sprite to its new position in the stage, and store the area behind the sprite so we can restore it next time around the loop (repeating for all sprites in the scene). Note that at this stage we could change the background if we wanted, provided you remember which rectangles have been updated so they can be copied in the last part of the loop: |
  |
  |
|
|
  |
  |
Draw the sprite transparently in the new position (repeating for all sprites in the scene): |
  |
  |
|
|
  |
  |
Finally, copy the changes from the stage to the screen, minimising the number of drawing steps (here both the background and the sprite are copied as one rectangle): |
  |
  |
|
|
  |
  |
|
  |
  |
Back to top |
  |
![]() |
|
About Contribute Send Feedback Privacy
|