Page 1 of 1
How to draw all instantiations of a class?
Posted: Sun Mar 14, 2010 11:57 am
by Bullet Pulse
I'm trying to write a function in my image class that will draw every instantiation of an image object to the screen, so that I won't have to put
Code: Select all
image1.DrawToScreen( surface );
image2.DrawToScreen( surface );
...etc
I'm using SDL by the way.
How would I go about doing this?
Re: How to draw all instantiations of a class?
Posted: Sun Mar 14, 2010 12:03 pm
by Moosader
Hey theres--
Usually in my ImageManager class I'll store all the images as an array, then when I go to draw everything I call imageManager.Draw(); in main (or wherever), and it does a for loop through every index of the array, drawing each.
Re: How to draw all instantiations of a class?
Posted: Sun Mar 14, 2010 12:07 pm
by Bullet Pulse
Alright thanks :D
Re: How to draw all instantiations of a class?
Posted: Sun Mar 14, 2010 2:02 pm
by Bakkon
Look into the STL containers such as list and vector.