April 18, 2024, 06:34:57 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


SpriteScaleFactor Doesn't seem to work.

Started by J B Wood (Zumwalt), December 05, 2006, 09:37:50 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

J B Wood (Zumwalt)

SpriteScaleFactor backgroundsprite, 0.50
This should scale my sprite by 50%, but the sprite doesn't change size.

Ionic Wind Support Team

You have to set the sprite mode to one of the scaled modes.  @TRANSSCALED for example.  Users guide for 2D->Sprites.  And before you ask they are software rendered so you can't combine modes, you can only use the ones from that chart.

Ionic Wind Support Team

J B Wood (Zumwalt)

This shifts the sprite, I even tried @Scaled, but as I reduce the sprite in size, it shifts id down on the screen.
Here is my code:



backgroundsprite = LoadSprite(GETSTARTPATH + "img\background.bmp")
if backgroundsprite <> NULL
SpriteDrawMode backgroundsprite, @SCALED
SpriteScaleFactor backgroundsprite, 0.95

Frame = 0
int mElapsed,mTimer
mTimer = timeGetTime()
exit_game=FALSE
/* Our beautiful Game Loop */
DO
FILLSCREEN 0
'ESC to exit at any time
IF KEYDOWN(1) then exit_game = TRUE
SpriteFrame backgroundsprite, 0
    DrawSpriteXY backgroundsprite,0,0

'target 75 frames per second for movement.
mElapsed = timeGetTime() - mTimer
mTimer = timeGetTime()
mAdjust = mElapsed / 13.3333
fps = FLIP 1

UNTIL exit_game
FREESPRITE backgroundsprite
ENDIF
CLOSESCREEN

Ionic Wind Support Team

Scaling is based on the center of the sprite.  Any more questions?
Ionic Wind Support Team

J B Wood (Zumwalt)

Yea how do I move the scaled sprite if DrawSpriteXY doesn't move it? I want the scaled version to be placed with upper left at 0,0

Ionic Wind Support Team

DrawSpriteXY sprite, -w/2 * scale, -h/2 * scale

Would be my guess.  Either that or just create a bitmap of the correct size in the first place ;)

Ionic Wind Support Team

J B Wood (Zumwalt)

Takes out half the fun of messing with the methods to see what I can dork up.
I'll let you sleep now :) going to work on this more tomorrow night :) Thanks