SpriteTransparent
SpriteTransparent SpriteIndex, TransparentFlag
 
Parameters:

    SpriteIndex = The index of the sprite you wish to alter
    TransparentFlag = The transparent state (0= solid, 1= transparent)
Returns: NONE
 

      SpriteTransparent sets the transparent state of a sprite. Sprites can be drawn in two basic modes, Solid (0) or Transparent (1).

      When drawing a sprite in Solid mode, every pixel within the sprite images will be drawn. However, when transparent mode is enabled, only pixels that do not match the images Mask Colour are drawn.




FACTS:


      * Sprites drawn in transparent mode uses the mask color of their associated image (Video + Fx Images). To change an images mask colour see ImageMaskColour. However, when transparent mode is enabled and the sprite is using an AFX formatted image, the sprite rendering engine will use the images Alpha Channel for transparency rather than it's mask colour. Read Images Tutorial for do's and don't




Mini Tutorial:


      This example has is really three parts. Part #1 creates an image. Part #2 then creates 10 sprites, and assigns each sprite our previously created image from part #1. Then last part, renders the sprites to the screen.


  
; =========================
; Part #1 - Create an Image
; =========================
  
  Cls RGB(0,0,0)
  MyImage=GetFreeImage()
  CircleC 32,32,16,1,$ff40f0
  CircleC 32,32,8,1,$8080f0
  GetImage MyIMage,0,0,64,64
  
  
; =============================
; Part #2 - Create Some sprites
; =============================
  
  For lp=1 To 10
     
   ;  Calc a random position for this sprite
     X=Rnd(GetScreenWidth()-64)
     y=Rnd(GetScreenHeight()-64)
     
   ; Create a sprite
     ThisSprite=NewSprite(X,Y,MyImage)
     
   ; Randomly set the sprites transparent Flag
     SpriteTransparent ThisSprite,Rnd(1)
     
  Next
  
  
; =================================
; Part #3 - Draw the Sprites/Screen
; =================================
  
  
; Clear screen to a bright white-ish colour
  Cls RGB(240,255,240)
  
; Draw All the created sprites
  DrawAllSprites
  
; Display the screen and wait for a key press
  Sync
  WaitKey
  




This example would output.

  
  no Text output
  

 
Related Info: DrawSprite | GetSpriteTransparent | ImageMaskColour | Images | SpriteDrawMode | Sprites :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com