DrawSpriteRange
DrawSpriteRange StartingSpriteIndex, EndingSpriteIndex
 
Parameters:

    StartingSpriteIndex = The identifier of the first sprite you wish to draw
    EndingSpriteIndex = The identifier of the last sprite in this range you wish to draw
Returns: NONE
 

      DrawSpriteRange lets you us manually render groups of sprites. The sprites will be rendered using their current properties. Typically though, you won't want to bother yourself with manually drawing sprites, so you'll either use DrawAllSprites, or DrawOrderedSprites. But it's here if you need it.




FACTS:


      * Unlike DrawSprite which will produce errors if you attempt to draw sprite that doesn't exist, DrawSpriteRange internally screens the validity of each sprite. So it won't produce errors if sprites don't exist within the provided range.

      * DrawSpriteRange renders all sprite images to current surface, except when CaptureToScene or CaptureToWorld are activated. In either situation the render request will be added to the scene or world que's respectively.

      * See SpriteDrawMode to the change the appearance of any sprite



 
Example Source: Download This Example
;-----------------------------------------
; DrawSpriteRange Example
;-----------------------------------------
  
; =========================================================
; First Create an Image, with a random circle pattern on it.
; =========================================================
  Size=95
  
  Circle_Image=CreateCircleImage(95)
  
  
; =============================================
; Create 20 sprites, between Index 1 and 20
; =============================================
  NumberOfSprites=20
  
  For ThisSprite=1 To NumberOfSprites
     
   ;Create this sprite
     CreateSprite ThisSprite
     
   ; Set this sprite auto center it's handles
     AutoCenterSpriteHandle ThisSprite,true
     
   ; Set each Sprite to use our circle image
   ; for it's artwork to display.
     SpriteImage ThisSprite,Circle_Image
     
   ; Randomly position this sprite within the screen
     Xpos=Rnd(GetScreenWidth())
     Ypos=Rnd(GetScreenHeight())
     PositionSprite ThisSprite,Xpos,Ypos
  Next
  
  
  
; Tell PB to limit speed of the program to 30 Frames (updates)
; per second or bellow
  SetFPS 30
  
  
  
; Start of Main DO/Loop
  Do
     
   ; Clear the Screen to back   0= rgb(0,0,0)
     Cls RGB(0,0,0)
     
     
   ;  Instruct PB to render all the sprites between index 1 and 100
     DrawSpriterange 1,100
     
     
     
   ; Display a message
     Ink $ff00
     Print "Manually Render a Range Of Sprites"
     Print "=================================="
     
     
   ; Display the screen and loop back to the DO statement
   ; to continue this loop
     Sync
  Loop
  
  
; =========================================================
; Create an Image with a shaded circle pattern on it.
; =========================================================
  
Function CreateCircleImage(Size)
  ThisImage=NewImage(size,size)
  Colour=RGB(128+Rnd(127),128+Rnd(127),128+Rnd(127))
  RenderPhongImage ThisIMage,size/2,size/2,Colour,200,255.0/(size/2)
EndFunction ThisImage
  
 
Related Info: DrawAllSprites | DrawOrderedSprites | DrawSprite | SpriteDrawMode :
 


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