c# - XNA - Repeat texture x amount of times -


i have basic brick texture want repeat across x axis number of times. instead of drawing (possibly) hundreds of same texture using spritebatch.draw(...) on , over, there easier way spritebatch.draw(brick,vector_array[],color) brick texture , vector_array[] of vector points texture painted on , over?

unrelated idea, next best idea like:

for (int = 0; <= 16; += 1)             {                 spritebatch.draw(brick, brickxy, color.white);                 brickxy.x += 32;             } 

which draw 16 brick textures repeatedly right. (each texture 32x32) does stays on screen 1 frame. how fix this?

thanks help! :d

try setting brickxy somewhere else. setting brickxy alone array needs brickxy[int] try like:

    protected override void loadcontent()     {         spritebatch = new spritebatch(graphicsdevice);         brick = content.load<texture2d>("whatever texture want here");         (int = 0; < brickxy.length - 1; a++)         {             brickxy[a].x += (32 * a);         }     } 

after of values set draw them or else bricks start move.

    protected override void draw(gametime gametime)     {         graphicsdevice.clear(color.cornflowerblue);         spritebatch.begin();         (int = 0; <= brickxy.length - 1; i++)         {             spritebatch.draw(brick, brickxy[i], color.white);         }         spritebatch.end();         base.draw(gametime);     } 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -