timelinefx:timelinefx.tlGameObject
Class tlGameObject Virtual
The base class for all particle objects, can also be used for general game entities This is the main type for storing entity information such as coordinates, colour and other information. This type is designed to be a base type that you can use to extend and create other classes, for example Player or Bullet.

Entities can be parented to other entities and maintain and update a list of children. These children can be relative to their parents therefore minimising the work needed to calculate where entities should be drawn to the screen. If a parent rotates, then it's children will rotate with it and likewise, if the parent moves then its children will move with it as well. Children don't have to be relative however, set realative to false using Relative to make the children move independantly, however they will still be updated by their parent

If you have an entity with children, and those children in turn have children, in order to update all of those entities only one call to the parent Update method is required to see all of the children updated too. This also applies to rendering the entities on screen - by calling Render on the parent entityall children entities will also be rendered. See the code below for an example

Entities draw to the screen using tlShape, a class that allows you to easily draw single or animated images. To set the image use Image and LoadShape. You can adjust the appearence of the entity such as colour and scale using commands such as Red, Green, Blue, Alpha, SetScale and Angle.

When entities are rendered they can be tweened so that their animation and movement on the screen is smoothed out using fixed rate timing. You pass the tween value when you call Render but it's only optional.

tlGameObject os component based, meaning it uses tlComponents to add functionality. tlComponent is an abstract class you can extend and override the update method to add whatever functionality you need to the object, be it a control system or movement. You can create as many components as you need for an object and they can be re-used as much as you need. See tlComponent for more info.

Namespace myapp


Using std..
Using mojo..
Using timelinefx..

Class MyWindow Extends Window

	Field GameObject:tlGameObject
	Field ChildObject:tlGameObject

	Method New( title:String="tlGameObject example",width:Int=640,height:Int=480,flags:WindowFlags=Null )

		Super.New( title,width,height,flags )

		'Create a couple of new game objects
		GameObject = New tlGameObject
		ChildObject = New tlGameObject

		'Assign images using LoadShape
		GameObject.Image = LoadShape("asset::smoke.png")
		ChildObject.Image = LoadShape("asset::smoke.png")

		'Position the child object. This will be relative to the parent object.
		ChildObject.SetPosition(0, 200)
		'Scale it down a bit
		ChildObject.SetScale(0.5)

		'Add the child object to the parent object
		GameObject.AddChild(ChildObject)
		'Set the parent position
		GameObject.SetPosition(width/2, height/2)
		'Update the gameobject to make sure everything is initialised in the correct positions
		GameObject.Update()
	End

	Method OnRender( canvas:Canvas ) Override

		App.RequestRender()

		canvas.Clear( New Color(0,0,0,1) )

		'Rotate the parent object to show that the child stays relative
		GameObject.Rotate(0.05)
		'Update the game object
		GameObject.Update()
		'Render the game object
		GameObject.Render(canvas)
	End

End

Function Main()

	New AppInstance

	New MyWindow

	App.Run()
End

Public Properties
Alpha Get/Set the Alpha value of the object. Alpha is the opacity of the object when rendered
Angle Get/Set the local rotation of the object.
Animating Get/Set whether the object is animating or not.
AutoCenter Get/Set the whether the objects handle is set to auto center
BlendMode Get/Set the Blendmode of the object for rendering
Blue Get/Set the Blue value of the object
ChildCount Get the number of children in the object.
CollisionBox Get/Set the collisionbox of the object.
Components Get the components of the object.
ContainingBox Get/Set the containingbox of the object.
CurrentFrame Get/Set current animation frame of the object
Destroyed Get or set the destroyed flag
DoNotRender Set this to true if you don't want the object to be rendered.
FrameRate Get/Set the framerate of the image.
Frames Get/Set the number of animation frames.
Green Get/Set the Green value of the object
HandleVector Get/Set the handle of the object. Handle is the origin of the object.
Image Get/Set the tlShape of the object.
ImageBox Get/Set the imagebox of the object.
IsDestroyed Has Destory been called on the gameobject?
IsStatic Is the object a static object? See SetStatic
ListenLayers Get/Set the listen layers of the object.
LocalRotation Get/Set the local rotation of the object. See Angle
LocalVector Get/Set the local vector of the object
Name Get/Set the name of the object
Parent Get/Set the parent of the object.
Red Get/Set the Red value of the object
Relative Get/Set whether the object is relative to it's parent.
Removed This flag tells you if the child has been removed from the parent's child list.
RenderCollisionBox Set to true to render the collision box of the object for debugging and testing purposes
RootParent Get/Set the root parent at the top of the hierarchy
ScaleVector Get/Set the scale vector of the object reltive to the parent
UpdateContainerBox Set to true if you don't want the container box to be updated.
UpdateTime Get/Set the the updatetime of the object.
WorldRotation Get/Set the world rotation of the object.
WorldScaleVector Get/Set the scale vector of the object reltive to the world
WorldVector Get/Set the World Vector of the object.
Zoom Get/Set the Zoom level of the object. This helps with features where you can zoom in and out of the game world
Public Constructors
New New construct for creating a tlGameObject and setting defaults
Public Methods
AddChild Add a child object to this object.
AddComponent Add a tlComponent to the object
AttachChild Add a child object to this object but don't make it relative.
Capture Capture the transformation values of the object
CaptureAll Capture all including children
ClearChildren Remove all children from this object
Destroy Destroy the object.
Detatch Detatch a child object to this object. Same as RemoveChild
GetChildCount Get the number of children in this object
GetChildren Get the Stack of children for this object.
GetComponent Get a tlComponent from the object
GetWorldX Get the world x coordinate of the object
GetWorldY Get the world y coordinate of the object
KillChildren Set all children to "dead" so they are marked for removal.
ListenOnTheseLayers Set the layers you want this object to listen for collisions on
Move move the object relative to it's current position
MoveVector move the object relative to it's current position using a tlVector2
RemoveChild Remove a child object from this object.
Render Render the entity
Rotate Rotate the object relative to it's current rotation
SetCollisionBox Set the dimensions of the objects collision box
SetCollisionBoxtoImage Set the collision box of the object to the imagebox
SetCollisionCircle Set the dimensions of the objects collision circle
SetCollisionHandler The the function callback used for processing collisions on the tlQuadTree
SetCollisionPoly Set the dimensions of the objects collisionbox
SetCurrentFrame Set the current frame on the game object image
SetHandle Set the handle of the object. See HandleVector
SetImage Set the image of the object.
SetImageLayer Set the layer that the object's image box resides on.
SetPosition Set the position of the object
SetPositionVector Set the position of the object using a tlVector2
SetScale Set the scale of the object
SetStatic
SetStaticPosition Set the position of the #tlGameObject for static objects
SyncWithCollisionBox Use the collisionbox to prevent an overlap with another object.
TieToVector Tie the object to a vector so that whatever the position of the vector, will be the position of the object.
UnTie Untie the object from the vector that it's tied to.
Update Update the object
UpdateStaticCollisionBox