Triggering event on Movie ends
by Anna Tito · in iTorque 2D · 05/16/2011 (8:22 pm) · 7 replies
Hey ya!
I am using the iTorque playiPhoneMovie to trigger a movie cut scene I just wanted to know if there was a way to trigger an event such as loadlevel at the end of the movie. I could use a scheduled event but I wanted to see if there was a nicer way to do it.
Cheers
Anna
I am using the iTorque playiPhoneMovie to trigger a movie cut scene I just wanted to know if there was a way to trigger an event such as loadlevel at the end of the movie. I could use a scheduled event but I wanted to see if there was a nicer way to do it.
Cheers
Anna
About the author
Game Design and Programming Student at RMIT.
#2
05/17/2011 (5:37 am)
Briefly looking at that code, it looks like there is a moviePlaybackDidFinish in the source code. However, it doesn't look like there is any console callback in there unless it is another file.
#3
Add the following one line of code at the end of this function:
That should trigger this function you write in TorqueScript:
05/17/2011 (7:57 am)
Here is how you can expose it to TorqueScript. Find the moviePlaybackDidFinish function in iPhoneMoviePlayback.mm.Add the following one line of code at the end of this function:
- (void) moviePlaybackDidFinish:(NSNotification*)notification
{
//Remove our observer
[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
[movieViewController.view removeFromSuperview];
// Reactivate the current audio session
AudioSessionSetActive(YES);
//Audio::OpenALInit();
//We can dealloc this whole delegate once we are done as the playback was asynchronous, which releases the movieController
[self dealloc];
// ADD THIS CODE
Con::executef(1, "movieDidFinish");
}That should trigger this function you write in TorqueScript:
function movieDidFinish()
{
// Movie finished playing
}
#4
05/17/2011 (8:02 am)
Let me know if that works for you. I'm on a PC right now, so I can't test the code. If it works, I will add it to the engine for an official release.
#5
If you load a level and it has a lot of datablocks you can get a bit of a delay... but that I can sort out :)
Thank you again!
Anna
05/17/2011 (5:09 pm)
SUCCESSFUL!!! SQUEE!!!! Thank you so much!!! You have made me an extremely happy n00b TorqueScript/C++ programmer! *Does a little celebratory dance* If you load a level and it has a lot of datablocks you can get a bit of a delay... but that I can sort out :)
Thank you again!
Anna
#6
05/17/2011 (5:56 pm)
One thing to note is that if you replay a movie e.g. a 'death' video it is already considered as having been played and finished so it will load the movie finished script and play the movie in the background I am trying to find a way around it now. Will let you know how I go.
#7
05/19/2011 (11:54 pm)
Managed to fix it. It looks like it was a issue with my collision calls not the video end, I had to pause the game and tweak a couple of things so the call wasn't made while the movie was playing. :) Once again Thanks!
Torque Owner Anna Tito