shabbar Posted January 29, 2015 Share Posted January 29, 2015 I want to sync animation with sound , for example i have a character and i want to animate his mouth only when narration is palying , and mouth should be shut when there is gapes in the narrations what i am doing is i am using currentTime sound property to check if sound reaches certain position in the update function but it is not working for me as update function called with certain interval and when this function called sound time is less or more then what i am testing in the if condition , that is why this condition never full fill , and if i set if condition as >= then the commands keep executing again and again as condition remain full fill for the rest of the sound time please let me know how i can synch animation with sound update: function () { if (this.narration.currentTime == 1380) { this.mouth.animations.stop(); } if (this.narration.currentTime == 11879) { this.mouth.animations.play('talking', 25, true, false); } } shabbar 1 Link to comment Share on other sites More sharing options...
shabbar Posted February 3, 2015 Author Share Posted February 3, 2015 Any one can help me please shabbar 1 Link to comment Share on other sites More sharing options...
mxmlb Posted February 3, 2015 Share Posted February 3, 2015 Hello, It depends of the precision & complexity of what you want to achieve. The simplest solution would be to use a timer instead of the update function. Example : var timer = game.time.create(false);var durationBeforeBlank = 1380;timer.add(durationBeforeBlank, this.onNarrationComplete, this);timer.start();Then you can stop the mouth animation in this.onNarrationComplete. As an advice, I would create a specific manager to handle this lip sync behaviour, which for example may load a json containing durations and delays between animations. shabbar 1 Link to comment Share on other sites More sharing options...
gingerbeardman Posted February 3, 2015 Share Posted February 3, 2015 Try >= Test&& this.mouth.animations.currentAnim != 'talking'Then you can flip flop animation statehttp://docs.phaser.io/Phaser.AnimationManager.html gingerbeardman 1 Link to comment Share on other sites More sharing options...
Recommended Posts