Game Development Community

Quick Way to Lock Rendering Frames to "Scene Ticks"?

by Charlie Patterson · in Torque Game Builder · 11/04/2011 (12:05 am) · 7 replies

I'm pretty sure I'm not imagining things. If I clone something and then rotate it, all during one function, I can *see* the item appear on screen non-rotated first, THEN rotated. Aaarrgghhh! I was trying to do my work between frames. I see similar issues other times (like while mounting things).

I was reading the code once and I believe it was true that it would render as fast as possible but only provide a "tick" every 1/30th of a second. But it's been a while.

Is there an easy way to "sync" the rendering to be once per game tick?

Thanks.

#1
11/04/2011 (8:10 am)
I once had problems with cloning, so instead I wrote a function that directly made the object and provided the rotation angle right inside the creation of the object.

I can't remember the code exactly, but it was something like this:
function cloneBear( %c )
{
  %b = new t2dStaticSprite()
  {
    sceneGraph = <YOUR SCENE GRAPH>
    rotation = 30;
    position = %c.getPosition();
    size = %c.getSize();
    class = Bear;
    ... etc ...
  };
  return %b;
}
#2
11/04/2011 (9:55 am)
Thanks William. My current problem is mounting an object that is already created. Say, for some reason, there is a cleaver flying through the air and it hits an alien in the chest. I would like to stop the cleaver at that point and mount it to the alien's chest. This works... but

I can see the cleaver first in the center of the alien for just a flash. Then it pops to the location, on the edge of the alien, where I am trying to mount it.

Does anyone else have issues like this because it messes with my faith that I'll ever finish!
#3
11/04/2011 (12:47 pm)
My only advice is to delete the original cleaver and construct a new cleaver with the position set in the construction block. When you construct the object with the position (instead of calling the setPosition function), it will initially exist at the constructed location.
#4
11/04/2011 (1:05 pm)
OK. I'll try it. Thanks.

Still seems something is wrong if I *don't* want the engine to redraw inbetween ticks and even during a particular function. It's kind of sacred that I can set up something while the screen is "locked" and then show it when I'm ready.
#5
11/04/2011 (1:10 pm)
Maybe you can immediatly after cloning do a 'removeFromScene()' and then do your transforms and then Add it to the scenegraph?
#6
11/07/2011 (3:36 pm)
Perhaps this thread, specifically Michael's post, could help you:

http://www.garagegames.com/community/forums/viewthread/44589

I haven't played around with that yet in my game, but I imagine this is the area where you will want to make some changes.
#7
11/07/2011 (3:52 pm)
Thanks @Justin.

I actually do have "$pref::timeManagerProcessInterval = 34;" in my code. Your post reminded me to turn it *off* to see what would happen, just to be safe. But I still get to see unwanted images between the good ones.

My focus right now is that when I first mount a moving cleaver onto an alien head, you can see the cleaver snap to the middle of the alien then snap back to the head. After the first clever per alien, the rest of the cleavers are OK. Weird.

But like I said I've seen other weird things and I'm pretty sure it has to do with rendering in between frames. The code line above seems to limit the physics only, which is posted as "FPS" in the debug banner.