GameObject

RareEngine2 Core Game Object Class

Overview

GameObject represents a scene entity in RareEngine2. It handles its own transform (position, scale, rotation), input states, and can hold multiple Component instances for modular behaviors.

Field Summary

boolean isEnabled
Controls whether the object is active in the scene.
boolean isVisible
Determines if the object should be rendered.
Vector2 position, scale
Local position and scale of the object.
Vector2 globalposition, globalscale
World position and scale including parent hierarchy.
float rotation, globalrotation
Local and global rotation in degrees.
GameObject parent
Parent object used for calculating globals.
String name, layer
Name of the object and the layer it belongs to.
boolean isDown, isUp, isClick, isDrag
Touch-related states for interaction tracking.
Vector2 touchPosition, dragValue
Stores touch and drag-related vectors.

Method Summary

void addComponent(Component c, GameView gv)
Adds a component and calls its start() method.
void removeComponent(Component c, GameView gv)
Removes a component and calls its destroy() method.
Component getComponentAt(int index)
Returns the component at the specified index.
ArrayList<Component> getComponents()
Returns a list of all components attached to this object.
void calculateGlobals()
Updates global position, scale, and rotation based on the parent.
void setName(String name)
Sets the object's name.
String getName()
Gets the object's name.
void setLayer(String layer)
Sets the object's layer.
String getLayer()
Gets the object's layer.
void setPosition(float x, float y)
Sets local position using float values.
void setScale(float x, float y)
Sets local scale using float values.
void setRotation(float rotation)
Sets local rotation in degrees.