java - Playing sound while tweening -
i've run issue while trying implement idea have.
i have image tween alpha layer of, fading in , second later fading out. here wish play mario coin @ point of total fade in.
i've tried implementing different callbacks either way sound plays either before tweening or after tweening.
code snippet:
tween.set(splash, spriteaccessor.alpha).target(0).start(tweenmanager); tween.to(splash, spriteaccessor.alpha, 2).target(1).repeatyoyo(1, 0.5f).setcallback(new tweencallback() { @override public void onevent(int type, basetween<?> source) { ((game) gdx.app.getapplicationlistener()).setscreen(new mainmenu()); } }).start(tweenmanager);
doing:
tween.set(splash, spriteaccessor.alpha).target(0).start(tweenmanager); tween.to(splash, spriteaccessor.alpha, 2).target(1).repeatyoyo(1, 0.5f).setcallback(new tweencallback() { @override public void onevent(int type, basetween<?> source) { soundmanager.playintro(); ((game) gdx.app.getapplicationlistener()).setscreen(new mainmenu()); } }).start(tweenmanager);
plays sound after tweening.
and:
tween.set(splash, spriteaccessor.alpha).target(0).start(tweenmanager) .setcallback(new tweencallback() { @override public void onevent(int type, basetween<?> source) { soundmanager.playintro(); } }); tween.to(splash, spriteaccessor.alpha, 2).target(1).repeatyoyo(1, 0.5f).setcallback(new tweencallback() { @override public void onevent(int type, basetween<?> source) { ((game) gdx.app.getapplicationlistener()).setscreen(new mainmenu()); } }).start(tweenmanager);
plays before. how implement want?
you can achieve using timeline tween engine , creating sequence, it's use these cases.
this should work you:
timeline.createsequence().beginsequence() .push(tween.to(splash, spriteaccessor.alpha, 0).target(0)) .push(tween.to(splash, spriteaccessor.alpha, 2).target(1).setcallback(new tweencallback() { @override public void onevent(int arg0, basetween<?> arg1) { soundmanager.playintro(); } })) .pushpause(0.5f) .push(tween.to(splash, spriteaccessor.alpha, 2f).target(0)).setcallback(new tweencallback() { @override public void onevent(int arg0, basetween<?> arg1) { ((game) gdx.app.getapplicationlistener()).setscreen(new mainmenu()); } }) .start(tweenmanager);
Comments
Post a Comment