c# - How to center an image in a rectangle? -


how center image inside rectangle with:

batch.draw(imagename, new rectangle(x, y, imagename.width, imagename.height), color.white); 

you can use origin overload spritebatch

batch.draw(imagename, new rectangle(x, y, imagename.width, imagename.height), color.white,0f,new vector2(imagename.width /2, imagename.height /2) ,spriteeffects.null, 0); 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -