Pausing animations
by Richard Skala · in iTorque 2D · 07/23/2010 (1:33 am) · 6 replies
I am at the point in development where I need to implement Pausing the game. Is there a way to pause animations on t2dAnimatedSprites?
About the author
Founded in 2009, Pixel Vandals Inc. is focused on bringing fun, fresh, and new ideas to the iPhone. www.pixelvandals.com www.pixelvandals.com/vineking
#2
I don't really use scripts at all, but I used the equivalent C++ calls, and it appears to work (aside from some issues I will need to resolve on my end).
Example:
07/23/2010 (3:43 am)
Awesome! Thank you for guiding me to the correct place!I don't really use scripts at all, but I used the equivalent C++ calls, and it appears to work (aside from some issues I will need to resolve on my end).
Example:
t2dSceneGraph* pSceneGraph = m_pOwner->getSceneGraph();
if( pSceneGraph )
{
if( pSceneGraph->getScenePause() )
{
printf( "UNPAUSING SCENE!\n" );
pSceneGraph->setScenePause( false );
}
else
{
printf( "PAUSING SCENE!\n" );
pSceneGraph->setScenePause( true );
}
}
#3
07/23/2010 (3:54 am)
Cool, I'm glad to see it was helpful. Don't forget about $timescale = 0/1. If you have any timers or scheduled events, those will continue to run if you don't set $timescale = 0. I'm not sure where that variable is defined though.
#4
Like I mentioned, there is a fix, but the original version was written for TGB (not iTGB). I modified it a bit and got it to work in the editor, but I haven't yet been able to get it working on the device. If you're interested, the original fix can be found here:
http://www.torquepowered.com/community/resources/view/9385
I'll post again if I manage to get mine to work on the actual iPhone.
07/23/2010 (4:10 am)
Also, if you have any audio playing you can use alxStop() to stop an audio channel, and then alxPlay() to re-enable it. However, I found that this only works for looping audio. If you have any non-looping audio playing (sound effects etc) at the time you hit the pause button the non-looping audio will continue until it reaches the end of the file. Looping audio files, such as background music loops do pause correctly though, even without the fix.Like I mentioned, there is a fix, but the original version was written for TGB (not iTGB). I modified it a bit and got it to work in the editor, but I haven't yet been able to get it working on the device. If you're interested, the original fix can be found here:
http://www.torquepowered.com/community/resources/view/9385
I'll post again if I manage to get mine to work on the actual iPhone.
#5
and
07/23/2010 (4:28 am)
Thanks. For the C++ people, since gTimeScale is static in main.cc, you have to set it like this:Con::setVariable( "$timeScale", "0" );
and
Con::setVariable( "$timeScale", "1" );
#6
07/23/2010 (3:09 pm)
Not at my main machine at the moment (so I can't confirm this), but I have a sneaking thought in the back of my head that schedules won't be paused by using $timescale.
Torque Owner Mark Davies
Pause:
$thescenegraph.setScenePause(true);
$timescale = 0;
Unpause:
$thescenegraph.setScenePause(false);
$timescale = 1;