Component

A component is a base game object class that all game objects inherit from. Most components are stored in ComponentCollections inside of GameScreens, (except for 2D GUI Components, which are stored inside of GUIManagers inside of GameScreens) and are updated and drawn from there. A Component must be in a ComponentCollection inside of a GameScreen to be used or displayed properly. When a component is created with a new statement, it will automatically be added to the DefaultScreen if no other Parent GameScreen is specified. Generally, you will not use just the straight Component class or object by itself, but instead will use a Component that inherits the Component class, such as PhysicsActor, Player, Pickup and more. The Component class serves as a generic object to make handling the variety of objects in the game engine easier for OmegaEngine.

Members


  • public GameScreen Parent - The GameScreen that this component belongs to.
  • public bool Initialized - A simple true or false to tell if this Component has been initialized or not.
  • public bool Visible - A simple true or false to tell OmegaEngine whether or not to draw this Component.
  • public int drawOrder - An integer value used to determine when to draw this component. OmegaEngine will always draw Components with lower drawOrders first.
  • public string Name - A string value that represents the component's name. Useful for labeling Components as needed, but does not serve any functionality yet.

Methods


  • public Component() - Default constructor. Defaults the components GameScreen Parent to DefaultScreen
  • public Component(GameScreen Parent) - Overloaded constructor that allows you to specify a specific GameScreen for this Components Parent
  • public int DrawOrder() - Getter/Setter for drawOrder, which will re-sort the draw order list for the Parent GameScreen when changed
  • protected virtual void InitializeComponent(GameScreen Parent) - Attempts to initialize the component. This is automatically called in the constructor
  • public virtual void Update() - Dummy function, this is called everytime the engine updates. Put logic code here in inherited classes
  • public virtual void Draw() - Dummy function, this is called everytime the engine draws. Put drawing code here in inherited classes
  • public virtual void DisableComponent() - Disabled and deletes the component
  • public class ComponentDrawOrderChangedEventArgs - Helper class to reorganize the components by draw order when one is changed
  • public delegate void ComponentDrawOrderChangedEventHandler() - Delegate function to reorganize the components by draw order when one is changed

Examples


Last edited Mar 7, 2011 at 1:04 AM by shmeeps, version 11

Comments

No comments yet.