Game Development Community

onUpdate position in script

by rennie moffat · in Torque Game Builder · 08/10/2009 (1:10 pm) · 4 replies

For a general playerClass.cs which requires an onUpdate callback, I have a question regaruding this code.

function playerClass::onUpdate(%this)
{
   %this.updateHorizontal();
   %this.updateVertical();
   %this.setCurrentAnimation();
}


A. should this be positioned in a specific position with in the playerClass.cs file? ie, top, bottom middle, right after... and if so why?

About the author

My thanks to Garage Games and the Garage Games Community combined with owned determination I got one game up, Temple Racer and I am looking to build more interesting, fun games for the mass market of the iOS app store.


#1
08/10/2009 (1:13 pm)
Doesn't matter. Defining a method can happen anywhere. You could even split the playerclass into several files if it gets too large.
#2
08/10/2009 (1:30 pm)
What do you mean by that?

How big can a file get.. or perhaps, what is too big?
#3
08/10/2009 (3:05 pm)
Too big is a machine-dependent thing. I don't think there is any limit, except the practical.

Where you define a function does not matter. As long as the object has already been defined, all its methods can be defined in any order. Just make sure they are defined and its sourcefile is exec'd before you call them.
#4
08/10/2009 (3:12 pm)
Ok,
I had read earlier tho, in one tutorial I was following along with and I remember it saying that where you placed this Xcode in the XX.cs file, was very important. This is not true tho?


Also, when placing a datablock in the main.cs, as some tuts do, would I place a datablock in the onStart Function?