Skip to content

Components

AlienTina edited this page Oct 15, 2023 · 4 revisions

Creation:

Component component = new Component(parent);

Usage:

  • Component.Active(bool): Component's update and draw functions are sometimes made to stop when this variable isn't true.

  • Component.Start()(function): Gets called right before being added to a GameObject.

  • Component.Update(GameTime)(function): Gets called every frame.

  • Component.Draw()(function): Handles rendering.

Transform

This component doesn't usually have to get added to a GameObject, as every GameObject has one built-in.

Creation:

Transform transform = new Transform(GameObject parent, Vector2 position, float rotation, float scale);

Usage:

  • Transform.position(Vector2): GameObject's position.

  • Transform.localPosition(Vector2): The local position of the object, used to move the object when it's a child of another object.

  • Transform.rotation(double): GameObject's rotation.

  • Transform.scale(float): GameObject's size. 1 being 1x size, 2 being 2x size and so on.

Renderer:

Creation:

Renderer render = new Renderer(GameObject parent);
Renderer render = new Renderer(GameObject parent, Texture2D sprite);
Renderer render = new Renderer(GameObject parent, string spritePath);

Usage:

  • Renderer.sprite(Texture2D): The sprite that is rendered.

  • Renderer.color(Color): The color that the sprite will be rendered in.

  • Renderer.origin(Vector2): The origin point of the sprite. When the sprite gets rendered, the origin point will be exactly where the GameObject is located.

  • Renderer.CalculateOrigin(Vector2 point)(function): Calculates the origin point automatically, accepts inputs from 0.0 to 1.0 to signify the position on the sprite.

Collider:

Creation:

Collider collider = new Collider(GameObject parent);

Usage:

  • Collider.Position(Vector2D): The position used to convert the Collider into a Rectangle.

  • Collider.Size(Vector2D): The size of the Collider used to convert the Collider into a Rectangle.

  • Collider.CheckForCollision(Collider)(bool): Checks if the Collider is touching the passed Collider.

CharacterController:

Creation:

CharacterController controller = new CharacterController(GameObject parent);

Usage:

  • CharacterController.velocity(Vector2): the direction and speed of movement.

Clone this wiki locally