Game Development Community

Beta 2: Edit > Scripting > Persist, name, class, superclass

by Alex Rice · in Torque Game Builder · 04/15/2006 (2:12 pm) · 2 replies

The new persist-across levels feature is pretty useful. Has anyone come up with interesting uses for the Class and Superclass fields on the Edit > Scripting panel? Seems like it could be real useful I just don't grok it yet what the benefits are.

#1
04/16/2006 (6:39 am)
It's for defining the namespace for your scripting of the objects. For example:

Enemy 1:

Superclass = Enemy;
Class = LowbieEnemy;

Enemy 2:

Superclass = Enemy;
Class = BossEnemy;

These two objects give you the following namespaces to work with (as well as the default ones):

Enemy::
LowbieEnemy::
BossEnemy::

So you can have a function such as:


Enemy::moveRandomly()
{
// do random movement when no detection of player has occured
}

LowbieEnemy::onDetectPlayer()
{
// do something specific for this enemy type when you are told you detect the player
// maybe fire weak weapon
}

BossEnemy::onDetectPlayer()
{
// do something superbly awesome when you detect the enemy
// maybe spawn into 20 LowbieEnemy--up to you!
}

Does that help?
BossEnemy::onDetectPlayer()
#2
04/16/2006 (7:59 am)
Ah I get it- thanks for that. Alex