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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - laserbeams

Pages: [1]
1
General / [SOLVED] Inherit Drawable or implement Draw() in SFML.net 2?
« on: November 18, 2011, 09:32:47 pm »
Edit for future readers:  I was initially unclear, and should have mentioned that I was using SFML.net 2.  Inheriting from Drawable is not possible in SFML.net 2.  This thread explains why. -end edit-

I've seen people ask how to do this one way or another, but I'm not experienced enough to know if there are any big problems with doing it either way (I'm a SFML neophyte).

I want to be able to render a list of simple and compound objects easily, which seems to mean choosing one of these two options.  Ignore bad syntax:

Code: [Select]
for each (object in objectlist) {
    window.Draw(object);
}

for each (object in objectlist) {
    object.Draw(window);
}

So either I build all of my compound objects (e.g. a button consisting of a background shape and a text label) as inheriting drawable, and throw those objects into a list with other basic drawable objects like sprites... or I implement my compound objects with a Draw(window) method, along with giving simpler objects like sprites a wrapper, so I can use sprite.Draw(window) as well.

I suppose different lists could be kept for simple and compound objects, depending on what was being drawn (and I will no doubt have multiple lists anyway), but switching between drawing methods depending on the object type seems kludgy.

Does anyone have any suggestions on why one method might be better?

Pages: [1]
anything