xna resizing question

Started by
2 comments, last by gameXcore 15 years, 3 months ago
Would anyone know how to go about making an image resize using keyboard input such as shrinking and growing ?
Advertisement
Well, depending on what you mean this could be a way to go about doing it. Have to variables like:

int imageHeight = 800;
int imageWidth = 600;

Then for the keypress:

if(Up Arrow Pressed){
imageHeight--;
}else if(Down Arrow Pressed){
imageHeight++;
}

And so on. Then to draw it you'd do:

spriteBatch.Draw(image, new Rectangle(x,y, imageWidth, imageHeight), Color.White);

I think that is what you mean. If not just let me know. Or if you need the keyboard input in XNA explained.
oh forgot to mention the grow / shrink is for the entire image. I was trying to make a image slowly shrink when the up arrow is pressed and slowly grow when the down arrow is pressed to give the illusion of my character walking off in the distance or moving up close to the screen.
Use the sprite batch overload which accepts a scale, then use a variable to scale it, pretty much like above
Game development blog and portfolio: http://gamexcore.co.uk

This topic is closed to new replies.

Advertisement