Otter
0.9.8.91
2d Game Development Framework based on SFML.Net
|
Movement Component that can be used by an Entity to provide simple top-down style movement. This class requires an Axis component be assigned to it, and that Axis must be also updated by another source. A simple way to do this is to just have the Entity have an Axis component as well as the movement component, and then pass a reference to the axis into the movement. More...
Inherits Otter.Movement.
Public Member Functions | |
BasicMovement (float xMax, float yMax, float accel) | |
Creates the basic movement. More... | |
override void | Update () |
Updates the Movement. More... | |
override void | MoveCollideX (Collider collider) |
A callback for when the horizontal sweep test hits a collision. More... | |
override void | MoveCollideY (Collider collider) |
A callback for when the vertical sweep test hits a collision. More... | |
Public Member Functions inherited from Otter.Movement | |
void | AddCollision (params int[] tags) |
Register a tag that the Collider should check for collisions with. More... | |
void | AddCollision (params Enum[] tags) |
Register a tag that the Collider should check for collisions with. More... | |
void | RemoveCollision (params int[] tags) |
Remove a tag from the collision checking. More... | |
virtual void | MoveX (int speed, Collider collider=null) |
Move the object in the X axis by the value of speed. Sweeping collision test. More... | |
virtual void | MoveY (int speed, Collider collider=null) |
Move the object in the Y axis by the value of speed. Sweeping collision test. More... | |
void | MoveXY (int speedX, int speedY, Collider collider=null) |
Shortcut to call both move x and move y. More... | |
Public Member Functions inherited from Otter.Component | |
T | GetEntity< T > () |
Get the Entity as a specific Type. More... | |
virtual void | Added () |
Called when the Component is added to the Entity. More... | |
virtual void | Removed () |
Called when the Component is removed from the Entity. More... | |
void | RemoveSelf () |
Removes the Component from its parent Entity. More... | |
virtual void | UpdateFirst () |
Called during the UpdateFirst on the parent Entity. More... | |
virtual void | Render () |
Called during the Render on the parent Entity. More... | |
virtual void | UpdateLast () |
Called during the UpdateLast on the parent Entity. More... | |
T | GetComponent< T > () |
Gets the first Component of type T from this Component's Entity. More... | |
List< T > | GetComponents< T > () |
Gets a list of Components of type T from this Component's Entity. More... | |
Public Attributes | |
Speed | Speed |
The Speed of the Movement. More... | |
Speed | TargetSpeed |
The movement will accelerate toward this Speed. More... | |
float | Accel |
The rate at which the Speed will approach the TargetSpeed. More... | |
bool | CircleClamp = true |
Determines if diagonal movement should be limited. This is to fix the problem where a vector of (1, 1) would have more length than a vector of (1, 0) or (0, 1). More... | |
Axis | Axis |
The axis used to move. This must be set to something and updated for the movement to work. More... | |
bool | Freeze |
If true the movement will not update. More... | |
Public Attributes inherited from Otter.Movement | |
Action | OnMove |
An action triggered after movement as been applied. Up to subclasses to implement. More... | |
int | SpeedScale = 100 |
Determines how many units represent 1 pixel. Default is 100. Example: A speed of 100 would move the object 1 pixel per update. More... | |
new Collider | Collider |
The main Collider to use for detecting collisions. If this is not set, no collisions will register at all! More... | |
Action | OnCollideX |
An action triggered when there is a collision in the X axis. More... | |
Action | OnCollideY |
An action triggered when there is a collision in the Y axis. More... | |
Public Attributes inherited from Otter.Component | |
Entity | Entity |
The parent Entity of the Component. More... | |
bool | RenderAfterEntity = true |
Determines if the Component should render after the Entity has rendered. More... | |
bool | Visible = true |
Determines if the Component will render. More... | |
float | Timer = 0 |
How long the Component has been alive (added to an Entity and updated.) More... | |
Additional Inherited Members | |
Protected Attributes inherited from Otter.Movement | |
int | MoveBufferX = 0 |
Properties inherited from Otter.Movement | |
List< int > | CollisionsSolid [get, set] |
The list of types that the Collider should check for collisions for when moving. More... | |
Properties inherited from Otter.Component | |
int | InstanceId [get, set] |
The Component's id for the Entity its attached to. More... | |
Scene | Scene [get] |
The Scene that the parent Entity is in. More... | |
Collider | Collider [get] |
The first Collider of the parent Entity. More... | |
Graphic | Graphic [get] |
The first Graphic of the parent Entity. More... | |
List< Graphic > | Graphics [get] |
The list of Graphics from the parent Entity. More... | |
List< Collider > | Colliders [get] |
The list of Colliders from the parent Entity. More... | |
Movement Component that can be used by an Entity to provide simple top-down style movement. This class requires an Axis component be assigned to it, and that Axis must be also updated by another source. A simple way to do this is to just have the Entity have an Axis component as well as the movement component, and then pass a reference to the axis into the movement.
The movement also requires a Collider if you want it to be able to collide with walls and other things!
Otter.BasicMovement.BasicMovement | ( | float | xMax, |
float | yMax, | ||
float | accel | ||
) |
Creates the basic movement.
xMax | The maximum speed allowed in the x axis. |
yMax | The maximum speed allowed in the y axis. |
accel | The acceleration. |
|
virtual |
A callback for when the horizontal sweep test hits a collision.
collider |
Reimplemented from Otter.Movement.
|
virtual |
A callback for when the vertical sweep test hits a collision.
collider |
Reimplemented from Otter.Movement.
|
virtual |
Updates the Movement.
Reimplemented from Otter.Component.
float Otter.BasicMovement.Accel |
The rate at which the Speed will approach the TargetSpeed.
Axis Otter.BasicMovement.Axis |
The axis used to move. This must be set to something and updated for the movement to work.
bool Otter.BasicMovement.CircleClamp = true |
Determines if diagonal movement should be limited. This is to fix the problem where a vector of (1, 1) would have more length than a vector of (1, 0) or (0, 1).
bool Otter.BasicMovement.Freeze |
If true the movement will not update.