Class hierarchy Compound list File list Compound Members

# Object2D Class Reference

2D World Object. More...

Inherits SpriteSelector.

Inherited by AnimatedSprite.

List of all members.

## Public Members

- Object2D ()
    Construct a 2D Object.

- ~Object2D ()
    Destruct the object.

- virtual long add (Object* O)
    this checks to make sure that any Object added to a Object2D is derived from Object2D.

- virtual long calcGlobalPosition (int AllTheWay=0)
    Calculate the object's global position.

- virtual long render (View& view)
    Render the sprite to the 2D view.

- long setPosition (fVector2D P)
    Set the local (relative to parent) position.

- Vector2D& getGlobalPosition ()
    Retrieve the object's global position.

- virtual Vector2D getSize ()
    Retrieve the object's dimensions.

- fVector2D& getPosition ()
    Retrieve the object's local position.

- fVector2D getMiddle ()
    Retrieve the mid point of the object.

- virtual Sprite* getSprite ()
    Retrieve the sprite associated with this object.

- virtual long collision (Collidable_Object* O)
    collision is called to indicate a collision between this and O.

- virtual int isCollision (Collidable_Object* O)
    called by CollisionDetection.

- virtual int isCollidable ()
    called to determine if the Object is to participate in collision detection.

## Detailed Description

2D World Object.

Connects the concepts of a 2D World and the bitmap. Provides movement and collision detection for sprites.

## Member Function Documentation

### Object2D::Object2D()

Construct a 2D Object.

### Object2D::~Object2D()

Destruct the object.

### virtual long Object2D::add(Object* O)`[virtual]`

this checks to make sure that any Object added to a Object2D is derived from Object2D.

Returns -1 if dynamic_cast fails.

### virtual long Object2D::calcGlobalPosition(int AllTheWay=0)`[virtual]`

Calculate the object's global position.

The global position is relative to the world, whereas the object's (local) position is relative to its parent. Non-zero AllTheWay means that the calculation will recursively go up the tree all the way to the root. Otherwise, the calculation will only go up one level.

### virtual long Object2D::render(View& view)`[virtual]`

Render the sprite to the 2D view.

### long Object2D::setPosition(fVector2D P)

Set the local (relative to parent) position.

### Vector2D& Object2D::getGlobalPosition()

Retrieve the object's global position.

The global position is relative to the world, whereas the object's (local) position is relative to its parent.

### virtual Vector2D Object2D::getSize()`[virtual]`

Retrieve the object's dimensions.

If a sprite is available, it will return its size, otherwize returns zero size.

### fVector2D& Object2D::getPosition()

Retrieve the object's local position.

### fVector2D Object2D::getMiddle()

Retrieve the mid point of the object.

This point is relative to the parent.

### virtual Sprite* Object2D::getSprite()`[virtual]`

Retrieve the sprite associated with this object.

Implements the abstract SpriteSelector class method.

Reimplemented from SpriteSelector.

### virtual long Object2D::collision(Collidable_Object* O)`[virtual]`

collision is called to indicate a collision between this and O.

It may return a RETCODE to indicate that it ('this' Object) should be removed/deleted.

### virtual int Object2D::isCollision(Collidable_Object* O)`[virtual]`

called by CollisionDetection.

Determines if a collision occurred bewteen this and O

### virtual int Object2D::isCollidable()`[virtual]`

called to determine if the Object is to participate in collision detection.

Default implementation returns non-zero if the sprite assigned to this is solid.

The documentation for this class was generated from the following file:

- 2D_Object2D.h