ScaleSpriteX
ScaleSpriteX SpriteIndex, Scaler#
 
Parameters:

    SpriteIndex = The number of the sprite you wish to scale
    Scaler# = The scaler to apply to sprites width
Returns: NONE
 

      The ScaleSpriteX command lets the user scale the sprite width without any changing the height scaling.

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.



FACTS:


      * Using a negative scaling value will Flip / Mirror this 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 main do/loop. Which allows the user to rotates the sprites with the left/right arrows key controls and then renders it

  
  
  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()
  CircleC size/4,size/4,size/6,1,RndRGB()
  
  MyImage=GetFreeImage()
  GetImage MyImage,0,0,size,size
  PrepareFXImage MyImage
  
  
; ===========================
; Part 2 - Create our sprites
; ===========================
  
; Create the Sprite
  CreateSprite 1
; Set sprite Center it's handle on any image
  AutoCenterSpriteHandle 1,true
; set this sprite to use the previously created image
  SpriteImage 1,MyImage
; set the sprites drawing mode to ROTATION (mode 2)
  SpriteDrawMode 1,2
; Position the sprite at 100,100
  PositionSprite 1,100,100
  
; Create a second sprite
  CreateSprite 2
; copy the settings from sprite 1, into sprite 2
  CopySprite 1,2
; Position the sprite at 350,250
  PositionSprite 2,350,250
  
  
; Create a sprite
  CreateSprite 3
; copy the settings from sprite 1, into sprite 3
  CopySprite 1,3
; Use a Negate Scale to MIRROR this sprite.
  ScaleSpriteX 3,-1
; Position the sprite at 300,100
  PositionSprite 3,300,100
  
  
; Create a sprite
  CreateSprite 4
; copy the settings from sprite 1, into sprite 4
  CopySprite 1,4
; Use a Negate Scale to FLIP this sprite.
  ScaleSpriteY 4,-1
; Position the sprite at 400,100
  PositionSprite 4,400,100
; ========================
; Part 3 - The main Loop
; ========================
  
; Start a do/loop
  Do
   ; clear the screen
     Cls RGB(0,0,0)
     
   ; bump the scaler angle
     Angle#=WrapAngle(angle#,1)
     
   ; Set Sprites 2's X scaling factor
     ScaleSpriteX 2,2+CosRadius(angle#,0.5)
     
   ; Set Sprites 2's Y scaling factor
     ScaleSpriteY 2,2+SinRadius(angle#,0.5)
     
   ; Display the current scaling of this sprite
     Print "Sprite Scaling Stuff"
     Print "Sprites Scale X:"+Str$(GetSpriteScaleX(2))
     Print "Sprites Scale Y:"+Str$(GetSpriteScaleY(2))
     
   ; Draw all the created sprites
     DrawAllSprites
     
   ; Draw the screen
     Sync
     
   ; Loop back to the DO statement
  Loop
  
  
  



This example would output the following text.

  
  Sprite Scaling Stuff
  Sprites Scale X:0.4545
  Sprites Scale Y:8.5433
  


 
Related Info: ScaleSprite | ScaleSpriteXY | ScaleSpriteY | SpriteDrawMode :
 


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