Package de.coreengine.system
Class GameObject
- java.lang.Object
-
- de.coreengine.system.GameObject
-
- Direct Known Subclasses:
Animated
,Button
,DayNightCycle
,FPCamera
,List
,MovingParticle
,NumericUpDown
,ParticleSystem
,PlayerGameObject
,ShadowBox
,Simple
,TextField
,TPCamera
public abstract class GameObject extends Object
Class that represents an object in the game- Author:
- Darius Dinger
-
-
Field Summary
Fields Modifier and Type Field Description protected GameObject
parent
-
Constructor Summary
Constructors Constructor Description GameObject()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addActionToPhysicWorld(com.bulletphysics.dynamics.ActionInterface ai)
Adding action interface object to the physics world of the scenevoid
addChild(GameObject child)
Adding a new child game object to the childs and setting this as parentprotected void
addRigidBodyToWorld(com.bulletphysics.dynamics.RigidBody rb)
Adding rigidbody to the physics world of the game objects sceneScene
getScene()
Getting scene of this game object, by getting scene of the root game object of the treeprotected void
onAdd()
This method gets called once, when the GameObject is added to a scene, or to another GameObject as child.void
onInit()
This method gets called once in the GameObject life cycle.void
onLoad(byte[] state)
This method gets called asynchronous, when the game wants to GameObject to recreate its state from saved data.void
onPauseUpdate()
This method gets called every frame when the game is paused before the render method.protected void
onRemove()
This method gets called once, when the GameObject gets removed from a scene or its parent GameObject (if it had one).void
onRender()
In this method the GameObject gets rendered onto the screen (if it has an graphical representation).byte[]
onSave()
This method gets called asynchronous, when the game wants the GameObject to save its current state.void
onSyncronize()
This method gets called, every time a network update occurs.void
onUpdate()
This method gets called every frame before the render method.void
removeChild(GameObject child)
Removing child game object from childsvoid
setShouldRender(boolean shouldRender)
Should the gameobject and all childrens get renderedvoid
setShouldSyncronize(boolean shouldSyncronize)
Should the gameobject and all childrens get syncronizedvoid
setShouldUpdate(boolean shouldUpdate)
Should the gameobject and all childrens get updated
-
-
-
Field Detail
-
parent
protected GameObject parent
-
-
Method Detail
-
onInit
public void onInit()
This method gets called once in the GameObject life cycle. Even if the GameObject gets removed and readded, this method dont gets called again. Its like an additional constructor, except that its not gets called when the GameObject gets created, but when its first has to action.
-
onSyncronize
public void onSyncronize()
This method gets called, every time a network update occurs. Here the GameObject has to syncronize all used network variables, like SyncFloats, SimpleEvents, ChatEvents, SyncMatrices, ...
-
onUpdate
public void onUpdate()
This method gets called every frame before the render method. Here is place for the GameObject logic updates, e.g. input handling, physics, actions, ...
-
onPauseUpdate
public void onPauseUpdate()
This method gets called every frame when the game is paused before the render method.
-
onRender
public void onRender()
In this method the GameObject gets rendered onto the screen (if it has an graphical representation). Its primary used for MasterRenderer calls.
-
onAdd
protected void onAdd()
This method gets called once, when the GameObject is added to a scene, or to another GameObject as child. If the GameObject gets removed and readded, the method will be called again.
-
onRemove
protected void onRemove()
This method gets called once, when the GameObject gets removed from a scene or its parent GameObject (if it had one). If the GameObject gets added and removed again, the method will be called again.
-
onSave
public byte[] onSave()
This method gets called asynchronous, when the game wants the GameObject to save its current state. If you have to save your current state, convert the relevant data into bytes and return them in this method.- Returns:
- Current state in bytes
-
onLoad
public void onLoad(byte[] state)
This method gets called asynchronous, when the game wants to GameObject to recreate its state from saved data. This method passing a byte array, which contains the data, the GameObject saved/returned with the onSave method.- Parameters:
state
- Loaded state in bytes
-
addChild
public final void addChild(GameObject child)
Adding a new child game object to the childs and setting this as parent- Parameters:
child
- Child to add
-
removeChild
public final void removeChild(GameObject child)
Removing child game object from childs- Parameters:
child
- Game object to remove
-
getScene
public Scene getScene()
Getting scene of this game object, by getting scene of the root game object of the tree- Returns:
- Scene of the game object
-
addRigidBodyToWorld
protected void addRigidBodyToWorld(com.bulletphysics.dynamics.RigidBody rb)
Adding rigidbody to the physics world of the game objects scene- Parameters:
rb
- Rigidbody to add to physics world
-
addActionToPhysicWorld
protected void addActionToPhysicWorld(com.bulletphysics.dynamics.ActionInterface ai)
Adding action interface object to the physics world of the scene- Parameters:
ai
- Action interface object to add
-
setShouldRender
public void setShouldRender(boolean shouldRender)
Should the gameobject and all childrens get rendered- Parameters:
shouldRender
- New value of should render
-
setShouldUpdate
public void setShouldUpdate(boolean shouldUpdate)
Should the gameobject and all childrens get updated- Parameters:
shouldUpdate
- New value of should update
-
setShouldSyncronize
public void setShouldSyncronize(boolean shouldSyncronize)
Should the gameobject and all childrens get syncronized- Parameters:
shouldSyncronize
- New value of should syncronize
-
-