Transfering script behavior to engine: scheduling?
by Christopher Evans · in iTorque 2D · 02/09/2010 (1:53 pm) · 4 replies
I am in the last stage of testing for my new game, YEAH! But I have some optimization that I want to squeeze out so it runs better on my 1st generation itouch. I have a spawning script that I want to port over, but I am having issues with moving script "schedule" to engine.
I was hoping to do something like:
But no luck. I know I could add onUpdate to my behavior and check if the current time is the right time to spawn, but this feels like it more work then I need. Also I don't know if the improvement would be more then I get in script.
So I am wondering has anyone figured out how to do a schedule event in a behavior, and what am I not understanding about engine scheduling?
Thanks.
I was hoping to do something like:
const char *func = "spawn()"; Sim::schedule(spawnTime, this, 0, &func, true);
But no luck. I know I could add onUpdate to my behavior and check if the current time is the right time to spawn, but this feels like it more work then I need. Also I don't know if the improvement would be more then I get in script.
So I am wondering has anyone figured out how to do a schedule event in a behavior, and what am I not understanding about engine scheduling?
Thanks.
#2
02/09/2010 (4:28 pm)
Sorry if I wasn't clear. What I wanted to do is to schedule an event in (in c++) and have it call my behavior methods (also in C++). The above code was what I was hoping I could do.
#3
I never tried to call exposed functions directly again through schedule, only real script functions that then call one or more functions ...
I assume that this is an instance of BehaviorInstance and that spawnTime is in the future?
02/09/2010 (5:42 pm)
I see ...I never tried to call exposed functions directly again through schedule, only real script functions that then call one or more functions ...
I assume that this is an instance of BehaviorInstance and that spawnTime is in the future?
#4
My script right now doesn't get called much but have a lot of stuff that it does when fired, so I figure I could see some improvement if I convert it to engine.
So I see two things that I can do.
Method A:
I can keep the scheduling code in script and just have it call my C++ code, when I need to spawn my guys. This I think will be the easiest to do, and most likely what I will do.
Method B:
The other option is to use the onUpdate method in C++, and firer the event when the time is ready.
I wonder would I see any real improvement with method B over method A?
Does anyone have an idea oh how much speed is taken for a method call?
02/09/2010 (6:40 pm)
Yeah it is an instance and spawnTime is the time to call. I was hoping this was easy to do. My script right now doesn't get called much but have a lot of stuff that it does when fired, so I figure I could see some improvement if I convert it to engine.
So I see two things that I can do.
Method A:
I can keep the scheduling code in script and just have it call my C++ code, when I need to spawn my guys. This I think will be the easiest to do, and most likely what I will do.
Method B:
The other option is to use the onUpdate method in C++, and firer the event when the time is ready.
I wonder would I see any real improvement with method B over method A?
Does anyone have an idea oh how much speed is taken for a method call?
Torque 3D Owner Marc Dreamora Schaerer
Gayasoft