Sign in to follow this  
jung34

sync audio to start of tween

Recommended Posts

Hi, 

 

I'm trying to sync audio to the start of a tween.

 

this.myTween = this.add.tween(...)

this.myTween.onStart.add(this.playSound, this)

 

Instead, the audio plays first and then a few moments later the tween starts.

 

I read the onStart should wait until the tween starts, but this doesn't seem to be happening.

 

Please help!

 

Share this post


Link to post
Share on other sites

Hi, the tween moves the sprite.  The sound needs to play at the start of this movement.  I'm not sure how to set the delay to zero.

 

tween1: function() {

  this.tweenMini1 = this.add.tween(this.spriteMini).to({ y: this.world.centerY}, 2000, Phaser.Easing.Back.In, true, 0);
  this.tweenMini1.onStart.add(this.playSwoosh, this);

},

 

playSwoosh: function() {
  this.swoosh.play();
  this.swoosh.volume = 0.3;
},

Share this post


Link to post
Share on other sites

your delay is 0 already

 

I believe it's your easing.. look here:

http://easings.net/#easeInBack

 

see how it goes down and then up... (i've marked it in green).. I think you're not seeing it until the up part of the graph there. if it's an opacity alpha then of course you're not going to see any negative alpha... so yes it's going to look delayed

[edit: sorry you're tweening Y.. i'm not sure about that then.. it depends where your sprite is starting. you should see it moving if it's on screen)

 

I'm don't know what easings Phaser includes but use this to compare with what you need

http://easings.net/

post-16536-0-93529800-1443839566.jpg

post-16536-0-87797900-1443839700.jpg

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.