Execute every frame
by Erwin Bell · in Torque Game Engine · 06/03/2008 (7:43 am) · 6 replies
Hi All,
I am just starting in the Torque Game Builder and still playing around in the tutorials. I want to customize some of the tutorial results to my own taste.
I want to execute some things every frame.
I have searched the forums but couldn't find anything useful.
Now I am doubting if it is even possible.
So my questions are:
Is it possible to execute a few things every frame (in torquescript), and if so, how?
EDIT: By The Way, I am working in Torque Game Builder 2D
I am just starting in the Torque Game Builder and still playing around in the tutorials. I want to customize some of the tutorial results to my own taste.
I want to execute some things every frame.
I have searched the forums but couldn't find anything useful.
Now I am doubting if it is even possible.
So my questions are:
Is it possible to execute a few things every frame (in torquescript), and if so, how?
EDIT: By The Way, I am working in Torque Game Builder 2D
#2
So for example I can every frame change the speed of the fish in the fishdemo tutorial.
Isn't there something like that in torquescript? It would be very usefull
06/03/2008 (4:19 pm)
Hmm, I was hoping for some event that would happen every frame that is drawn with which I could work.So for example I can every frame change the speed of the fish in the fishdemo tutorial.
Isn't there something like that in torquescript? It would be very usefull
#3
06/03/2008 (5:29 pm)
"t2dscenegraph::onupdatescene()" is the script function you need, it will execute every frame.
#4
Unfortunately I was under the impression that it would be simple to implement, but I think I am too noob.
I have tried a large variety of ways to use it, but it doesn't work.
I am still trying in the fishdemo tutorial and try to change the speed of the fish every frame, but it doesn't swim at all.
In game.cs I put the following, which I thought was correct:
I also tried, but I'm almost certain that is wrong:
The knowledge I'm missing, is how to use the scenegraph class I guess, I searched for it but can't find anything which explains the correct use.
This is probably related to my small experience with OO programming in general.
06/04/2008 (9:13 am)
Thank you very much for your answer, now at least I know it is possible.Unfortunately I was under the impression that it would be simple to implement, but I think I am too noob.
I have tried a large variety of ways to use it, but it doesn't work.
I am still trying in the fishdemo tutorial and try to change the speed of the fish every frame, but it doesn't swim at all.
In game.cs I put the following, which I thought was correct:
function t2dSceneGraph::onUpdateScene(%this)
{
FishClass.setSpeed();
FishClass.setLinearVelocityX(FishClass.speed);
}But it doesn't workI also tried, but I'm almost certain that is wrong:
function FishClass::onUpdateScene(%scenegraph)
{
%this.setSpeed();
%this.setLinearVelocityX(%this.speed);
}The knowledge I'm missing, is how to use the scenegraph class I guess, I searched for it but can't find anything which explains the correct use.
This is probably related to my small experience with OO programming in general.
#5
My great OO-noobism got me to not give my fish a name as an object.
Just now, I named it Fish and got it working with the following:
Ofcourse it doesn't do yet exactly what I want but it is a start.
06/05/2008 (1:05 am)
Eureka!!! Got it working.My great OO-noobism got me to not give my fish a name as an object.
Just now, I named it Fish and got it working with the following:
function t2dSceneGraph::onUpdateScene(%this)
{
Fish.setSpeed();
Fish.setLinearVelocityX(Fish.speed);
}Ofcourse it doesn't do yet exactly what I want but it is a start.
#6
My great OO-noobism got me to not give my fish a name as an object.
Just now, I named it Fish and got it working with the following:
Ofcourse it doesn't do yet exactly what I want but it is a start.
06/05/2008 (1:29 am)
Eureka!!! Got it working.My great OO-noobism got me to not give my fish a name as an object.
Just now, I named it Fish and got it working with the following:
function t2dSceneGraph::onUpdateScene(%this)
{
Fish.setSpeed();
Fish.setLinearVelocityX(Fish.speed);
}Ofcourse it doesn't do yet exactly what I want but it is a start.
Associate Ross Pawley
Then just implement your onAdvanceTime function for your object in script.