Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: window.draw() to draw multiple sprites?  (Read 3425 times)

0 Members and 1 Guest are viewing this topic.

eyeliner

  • Newbie
  • *
  • Posts: 19
    • View Profile
window.draw() to draw multiple sprites?
« on: July 19, 2013, 01:09:25 pm »
First and foremost, I am quite dumb, but I'm still learning, and love every second of it. :)
I hope you don't find this question too dumb. :p

Is this possible?
I have the following code on Main():
            string newImage1 = "textures\\1.png";
            Sprite sTexture1 = createSprite(newImage1, window, new Vector2f(95, 95), new Vector2f(50, 50));

            string newImage2 = "textures\\2.png";
            Sprite sTexture2 = createSprite(newImage2, window, new Vector2f(95, 95), new Vector2f(500, 400));
And the method called:
        private static Sprite createSprite(string image, RenderTarget window, Vector2f origin, Vector2f position)
        {
            Sprite sTexture1;

            //Load a texture and make a sprite
            Texture texture = new Texture(image);
            sTexture1 = new Sprite(texture);

            //Set the origin to it's center
            sTexture1.Origin = origin;

            //Set the position to the center of the screen
            sTexture1.Position = position;
            return sTexture1;
        }

Then, in the game loop, I have to call window.draw to each sprite (makes sense), but is there a way to make only one window.draw to draw all the sprites?

I just remembered arrays/lists, but I'd have to make a for loop, and I don't know how that would be performance wise...

eyeliner

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: window.draw() to draw multiple sprites?
« Reply #1 on: July 19, 2013, 01:18:01 pm »
Made it with a List...

 

anything