These are chat archives for Zhouzi/TheaterJS

16th
May 2016
Felipe Becerra
@polloNoEnd_twitter
May 16 2016 04:20
hi! , i need run a function after end scene , any solution?
Gabin Aureche
@Zhouzi
May 16 2016 07:23

Hey @polloNoEnd_twitter! There are a few ways to do that and it all depends on what you are looking for.

If you want to call a function after a scene ends:

theater
  .addScene('vader:I am your father!')
  .addScene(function (done) {
    alert('wow, such a revelation!');

    // you can do whatever you want, the only thing that matter
    // is that you call "done()" to play the next scene
    done();
  })

If you want to call a function every time a scenes ends, you can listen to the relevant events, e.g:

theater
  .on('type:start, erase:start', function () {
    var actor = theater.getCurrentActor()
    actor.$element.classList.add('blinking-caret')
  })

And here's the documentation regarding event listeners: https://github.com/Zhouzi/TheaterJS#on