2 Replies - 321 Views - Last Post: 05 February 2012 - 04:38 AM Rate Topic: -----

#1 DanielLeone  Icon User is offline

  • D.I.C Head

Reputation: 22
  • View blog
  • Posts: 177
  • Joined: 04-February 12

Referring to specific instances within a class. question

Posted 04 February 2012 - 06:42 PM

Hello there,

I am currently trying to create muliple instances of a MenuEntry class in a ScreenManager program and only draw specific instances. I create these instances like so:

private MenuEntry menuEntry = new MenuEntry("text", new Vector2(200,200), Color.Black);


Then I add all of these to a static list of menu entries called 'entries'.

MenuEntry.entries.Add(menuEntry);


These instances are in many different classes like a MainMenu class, OptionsMenu class and so forth. So instead of calling Draw() foreach of these instances and want to use a foreach loop so something similar like so:

            
      foreach (MenuEntry entry in MenuEntry.entries)
            {
                entry.Draw(spriteBatch);
            }



However, I only want to draw the instances in one class at a time.

So, my question is can I draw specific instances on MenuEntries without reffering to each and every instances.

Sorry if that was a bit confusing but it was my first time positin here.

I have thought about making a scope class or method or something, but I don't know where to start.

Any help appreciated,
Daniel

Is This A Good Question/Topic? 0
  • +

Replies To: Referring to specific instances within a class. question

#2 DanielLeone  Icon User is offline

  • D.I.C Head

Reputation: 22
  • View blog
  • Posts: 177
  • Joined: 04-February 12

Re: Referring to specific instances within a class. question

Posted 05 February 2012 - 02:41 AM

FIXED. I just put a Screen in the MenuEntry constructor and if the screen was active I would draw the entry. Thanks anyway.

Does anyone know how to remove or end a topic?
Was This Post Helpful? 1
  • +
  • -

#3 RexGrammer  Icon User is offline

  • Coding Dynamo
  • member icon

Reputation: 181
  • View blog
  • Posts: 777
  • Joined: 27-October 11

Re: Referring to specific instances within a class. question

Posted 05 February 2012 - 04:38 AM

No need to remove it, so that others can see the problem and the solution to it.

Oh, and keep up the good work. It's always nice to see someone that returns and posts the solution to the problem if he finds it.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1