abstract class Glint::GameObject

Overview

A generic game object class.

A game object is responsible for keeping track of it's own an child entities.

Direct Known Subclasses

Defined in:

glint/game_object/game_object.cr

Instance Method Summary

Instance Method Detail

def <<(other : GameObject) #

Add a game object to the game object's children for managing later.

class MyScene < Scene # Scene is a GameObject
  def initialize
    @spaceship = Spaceship.new
    self << @spaceship
  end
end

[View source]
def can_update? #

[View source]
def children : Array(GameObject) #

Returns the child entities.


[View source]
def delete(other : GameObject) #

Remove a game object from the game object's children, if it exists.

if health <= 0
  self.delete @spaceship
end

[View source]
def draw #

Draws the game object.

This performs any drawing specific for this game object. Any entities in @children will be drawn automatically (if applicable).


[View source]
def draw_above_children : Bool #

Whether to draw the game object above its child game objects.


[View source]
def draw_above_children=(draw_above_children : Bool) #

Whether to draw the game object above its child game objects.


[View source]
def draw_at(position) #

Draws a game object at a specific position.


[View source]
def draw_children : Bool #

Whether to draw the game object's child game objects.


[View source]
def draw_children=(draw_children : Bool) #

Whether to draw the game object's child game objects.


[View source]
def draw_position : DrawPosition #

The game object's position relative to its parent.


[View source]
def draw_position=(draw_position : DrawPosition) #

The game object's position relative to its parent.


[View source]
def extents : Dimension #

Returns game object's extents (maximum dimensions)


[View source]
def game : Game | Nil #

The Game object.

This is a reference to the current base Game to allow for changes, e.g. to pause the game or get the game's Window size.


[View source]
def game=(game : Game | Nil) #

The Game object.

This is a reference to the current base Game to allow for changes, e.g. to pause the game or get the game's Window size.


[View source]
def has?(other : GameObject) #

Returns whether the game object is in the children.


[View source]
def parent : GameObject | Game | Nil #

The game object's parent, if any.


[View source]
def parent=(parent : GameObject | Game | Nil) #

The game object's parent, if any.


[View source]
def pivot : Origin #

The game object's point of transformation.


[View source]
def pivot=(pivot : Origin) #

The game object's point of transformation.


[View source]
def position : Glint::Vector2 #

Returns the game object's current position.


[View source]
def position=(position : Glint::Vector2) #

Sets the game object's position.


[View source]
def rotation : Float64 #

Returns the game object's current rotation.


[View source]
def rotation=(rotation : Float64) #

Sets the game object's rotation.


[View source]
def update(delta) #

Updates the game object.

Updates are only applied if the #update_mode allows it.


[View source]
def update(delta, &) #

Updates the game object with a block.

Updates are only applied if the #update_mode allows it.


[View source]
def update_mode : UpdateMode #

How and when the game object (and its children) is updated.


[View source]
def update_mode=(update_mode : UpdateMode) #

How and when the game object (and its children) is updated.


[View source]
def visible : Bool #

Whether the game object is visible or not.


[View source]
def visible=(visible : Bool) #

Whether the game object is visible or not.


[View source]