ScaleSprite
ScaleSprite SpriteIndex, Scale#
 
Parameters:

    SpriteIndex = The number of the sprite you wish to scale
    Scale# = The scaler to apply this sprites combined width & height
Returns: NONE
 

      The ScaleSprite command lets the user set both the width / height scaling factors of the a sprite.

Scale Values
      0.00 = Sprite is scaled by zero.
      0.25 = Sprite is 25% of it's normal size
      0.50 = Sprite is 50% of it's normal size
      0.75 = Sprite is 75% of it's normal size
      1.00 = Sprite is 100% of it's normal size.
      2.00 = Sprite is 200% of it's normal size.
      3.00 = Sprite is 300% of it's normal size.



      Here's an example animation of sprite scaling from 0.0 to 2.0. So it starts out at basically a point, then zooms into twice it's actual size, and zooms out again.






FACTS:


      * Using a negative scaling value will Flip / Mirror a sprite

      * In order to see the effect of sprite scaling, the sprite needs to set to Rotation Mode using the SpriteDrawMode command.

      * Note: For the best performance!, it's highly recommended that a scaled sprites image be previously prepared in FX image format (see PrepareFXimage, LoadFxImage)




Mini Tutorial:


     This example is really 3 parts. Part #1 creates a image out of a triangle shape and a circle. Part #2 creates the sprite, the sprite is then set to render the previously created image as it's graphic to rotate. Part #3 is the programs main do/loop. Which allows the user to rotates the sprites with the left/right arrows key controls and then renders it

  
  
  
; ========================
; Part 1 - Create an image (so we have something to look at)
; ========================
  
  Cls RGB(0,0,0)
  
; Create a LIttle triangle image
  Size=50
  CreateConvexShape 1,Size*0.50,3
  RotateShape 1,30,1
  DrawShape 1,Size/2,size/2,2
  CircleC size/2,size/2,size/5,1,RndRGB()
  MyImage=GetFreeImage()
  GetImage MyImage,0,0,size,size
  PrepareFXImage MyImage
  
  
; ========================
; Part 2 - Create our sprite
; ========================
  
; Create Sprite1 at 100X,100Y using MyImage
  Sprite1=NewSprite(100,100,MyImage)
  
  
  
  
; Create a second sprite  at position 200,200 using MyImage
  Sprite2=NewSprite(200,200,myimage)
  
; set sprite 2, to be 5 times (500%) larger than sprite 1
  ScaleSprite Sprite2,5.00
  
; set sprite 2's drawing mode to ROTATION/Scaling mode (mode 2)
  SpriteDrawMode Sprite2,2
  
  
  
; ========================
; Part 3 - The main Loop
; ========================
  
; Start a do/loop
  Do
   ; clear the screen
     Cls RGB(0,0,0)
     
   ; Draw all the created sprites
     DrawAllSprites
     
   ; Draw the screen
     Sync
     
   ; Loop back to the DO statement
  Loop
  
  
  
  



This example would output.

  
  no Text output
  


 
Related Info: PrepareFXimage | RotateSprite | ScaleSpriteX | ScaleSpriteXY | ScaleSpriteY | SpriteDrawMode | TurnSprite :
 


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