Game Development Community

Package

by Howard Dortch · in Torque Game Engine · 07/08/2004 (6:40 am) · 4 replies

I want to try to understand why I need to use packages. Package have some functions in it much like a class. Why can't the functions just be called? why wrap them in a package?

In the book( 3dgpaio ) "Packages can be used to dynamicly overload functions using the Parent::function()" I see in control/main.cs Parent::OnStart(); what onStart does it refer to as a parent? and why override the functionality why not just move it all in to one onStart() and just call it. Am I ramblinng out of control now? sorry.....

#1
07/08/2004 (6:57 am)
You want to use packages to "package" up a set of functionality. Think of packages in the sense of functions that get called for each mission. Things like "missionOnStart", "missionOnEnd", and "missionOnLoad" could be considered package-able functions. That way, when you load up a new mission, the controlling scripts don't have to know what to call, per mission. You just activate the correct package and the call is always the same.

Does that help any?

- Brett
#2
07/08/2004 (7:20 am)
Well it still has the look and feel of a class with no members just methods. Is that the gist of it?

How does a package know who it's parent is?
Like in root/main.cs there is an onStart()
In the common and control directories there are packages that have onStart() functions. I understand from the book that the main onStart() somehow automaticaly calls all other onStarts() but only if the Package has been loaded?
#3
07/08/2004 (7:37 am)
Quote:How does a package know who it's parent is?

DNA testing ;)
#4
07/08/2004 (7:42 am)
The namespaces are linked so that if you call Parent:: it will find the right thing.