abstract class Glint::GameObject
- Glint::GameObject
- Reference
- Object
Overview
A generic game object class.
A game object is responsible for keeping track of it's own an child entities.
Direct Known Subclasses
- Glint::Control
- Glint::Physics::PhysicsObject
- Glint::Pixel
- Glint::Scene
- Glint::Shape::Shape
- Glint::Sprite
Defined in:
glint/game_object/game_object.crInstance Method Summary
-
#<<(other : GameObject)
Add a game object to the game object's children for managing later.
- #can_update?
-
#children : Array(GameObject)
Returns the child entities.
-
#delete(other : GameObject)
Remove a game object from the game object's children, if it exists.
-
#draw
Draws the game object.
-
#draw_above_children : Bool
Whether to draw the game object above its child game objects.
-
#draw_above_children=(draw_above_children : Bool)
Whether to draw the game object above its child game objects.
-
#draw_at(position)
Draws a game object at a specific position.
-
#draw_children : Bool
Whether to draw the game object's child game objects.
-
#draw_children=(draw_children : Bool)
Whether to draw the game object's child game objects.
-
#draw_position : DrawPosition
The game object's position relative to its parent.
-
#draw_position=(draw_position : DrawPosition)
The game object's position relative to its parent.
-
#extents : Dimension
Returns game object's extents (maximum dimensions)
-
#game : Game | Nil
The
Game
object. -
#game=(game : Game | Nil)
The
Game
object. -
#has?(other : GameObject)
Returns whether the game object is in the children.
-
#parent : GameObject | Game | Nil
The game object's parent, if any.
-
#parent=(parent : GameObject | Game | Nil)
The game object's parent, if any.
-
#pivot : Origin
The game object's point of transformation.
-
#pivot=(pivot : Origin)
The game object's point of transformation.
-
#position : Glint::Vector2
Returns the game object's current position.
-
#position=(position : Glint::Vector2)
Sets the game object's position.
-
#rotation : Float64
Returns the game object's current rotation.
-
#rotation=(rotation : Float64)
Sets the game object's rotation.
-
#update(delta)
Updates the game object.
-
#update(delta, &)
Updates the game object with a block.
-
#update_mode : UpdateMode
How and when the game object (and its children) is updated.
-
#update_mode=(update_mode : UpdateMode)
How and when the game object (and its children) is updated.
-
#visible : Bool
Whether the game object is visible or not.
-
#visible=(visible : Bool)
Whether the game object is visible or not.
Instance Method Detail
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
Remove a game object from the game object's children, if it exists.
if health <= 0
self.delete @spaceship
end
Draws the game object.
This performs any drawing specific for this game object. Any entities in
@children
will be drawn automatically (if applicable).
Whether to draw the game object above its child game objects.
The game object's position relative to its parent.
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.
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.
Updates the game object.
Updates are only applied if the #update_mode
allows it.
Updates the game object with a block.
Updates are only applied if the #update_mode
allows it.
How and when the game object (and its children) is updated.