The ScaleSpriteXY command lets the user scale the sprites width and height independently.
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 then renders the created sprites.
; ======================== ; Part 1 - Create an image ; ======================== 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 & Y scaling factors x#=2+CosRadius(angle#,0.5) y#=2+SinRadius(angle#,0.5) ScaleSpriteXY 2,x#,y# ; 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. Sprites Scale X: Sprites Scale Y: |
|