Jump to content

Tween library


Rick
 Share

Recommended Posts

Yeah. To explain the below on how it's used. You have some lua table (music in this case) that can have whatever you want in it. You then create the tween object (which you need to hang onto because you need to call it's update function each frame) passing in how long you want the entire tween to take (10 in this case(note this isn't seconds but it's a value that will always be the same depending on what you pass into the update function for timing)), then pass in the lua table that it's going to modify (music in this case), and then pass in a table that has the same property name as the table has that you want modified (volume in this case) and the end value (5 in this case).

 

-- increase the volume of music from 0 to 5 in 10 seconds

local music = { volume = 0, path = "path/to/file.mp3" }

local musicTween = tween.new(10, music, {volume = 5})

...

musicTween:update(dt)

 

 

So it knows to adjust the volume setting in the music table to a max value of 5 over time 10 duration.

  • Upvote 2
Link to comment
Share on other sites

Posts like this I think should have a special section on the forum. Anything that offers helpful information, tips, tricks, etc. There is a lot of this kind of stuff strewn across multiple sections between all the questions that are nice for those that regularly keep up on the forums, but that newcomers may never stumble across, or that even those that saw them may lose once they get buried under dozens of other topics.

 

Or if not a dedicated section, perhaps a stickied thread that is actively updated serving the only purpose of indexing and linking to threads such as this.

  • Upvote 3
Link to comment
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.

 Share

×
×
  • Create New...