Itween Basic Audio (volume and pitch changes)

Source: Internet
Author: User

First, basic introduction; second, basic attributes

Original address: http://blog.csdn.net/dingkun520wy/article/details/50826033

First, the basic introduction

Audioto: Changes the volume and pitch of the sound to the specified value.

Audiofrom: Changes the volume and pitch of the sound from the given value to the original value;

Audioupdate: Similar to Audioto, called in the Update () method or in a looping environment. Provides an environment for changing attribute values per frame. Not dependent on Easrtype

Stab: Play AudioClip once, you can not manually load Audiosource components

Second, the basic attributes

Basic attributes are simpler and directly on the code

First of all, Audioto.

[CSharp]View PlainCopy  
  1. void Start () {
  2. //Play the Sound object
  3. Audiosource Tempsource = gameobject.addcomponent<audiosource> ();
  4. Tempsource.loop = true;
  5. Tempsource.clip = Soundend;
  6. Tempsource.volume = 1;
  7. Tempsource.play ();
  8. //Key-value pairs the parameters used to save the Itween
  9. Hashtable args = new Hashtable ();
  10. //Sound
  11. Args.  ADD ("Audiosource", Tempsource);
  12. //Volume
  13. Args.  ADD ("volume", 0);
  14. //Tone
  15. Args.  ADD ("pitch", 0);
  16. //Time of Change
  17. Args.  ADD ("Time", 10f);
  18. //Delay Execution Time
  19. Args.  ADD ("delay", 0.1f);
  20. //Here is the set type, Itween type and many kinds, in the source of enumeration Easetype
  21. Args.  ADD ("Easetype", ITween.EaseType.easeInOutExpo);
  22. //Three loop type none Loop Pingpong (General loop back and forth)
  23. //args.  ADD ("Looptype", "none");
  24. //args.    ADD ("Looptype", "loop");
  25. Args.  ADD ("Looptype", ITween.LoopType.pingPong);
  26. //Handles events during playback.
  27. the Animationstart method is called when playback starts, and 5.0 indicates its arguments
  28. Args.  ADD ("OnStart", "Animationstart");
  29. Args.  ADD ("Onstartparams", 5.0f);
  30. //Set the object to accept the method, the default is self-acceptance, here can also be changed to another object to accept,
  31. //Then you have to implement the Animationstart method in the script that receives the object.
  32. Args.  ADD ("Onstarttarget", gameobject);
  33. //Play at the end of the call, parameters and similar above
  34. Args.  ADD ("OnComplete", "Animationend");
  35. Args.  ADD ("Oncompleteparams", "End");
  36. Args.  ADD ("Oncompletetarget", gameobject);
  37. //play in call, parameters and similar above
  38. Args.  ADD ("OnUpdate", "animationupdate");
  39. Args.  ADD ("Onupdatetarget", gameobject);
  40. Args.  ADD ("Onupdateparams", true);
  41. Itween.audioto (Btnbegin, args);
  42. }
  43. //The animation is called at the start
  44. void Animationstart (float f)
  45. {
  46. Debug.Log ("Start:" + f);
  47. }
  48. //At the end of the animation call
  49. void Animationend (string f)
  50. {
  51. Debug.Log ("End:" + f);
  52. }
  53. //Call in animation
  54. void Animationupdate (bool f)
  55. {
  56. Debug.Log ("UPDATE:" + f);
  57. }

And then the stab code.

[CSharp]View PlainCopy  
  1. void Start () {
  2. //Key-value pairs the parameters used to save the Itween
  3. Hashtable Stabargs = new Hashtable ();
  4. //audio source to play
  5. Stabargs.add ("AudioClip", soundtanover);
  6. //Play the volume
  7. Stabargs.add ("Volume", 1);
  8. //Play to the specified Audiosource (can default)
  9. //audiosource Tempsource = gameobject.addcomponent<audiosource> ();
  10. //stabargs.add ("Audiosource", Tempsource);
  11. //Set the tone of the sound
  12. Stabargs.add ("pitch", 1);
  13. //Delay play
  14. Stabargs.add ("delay", 0);
  15. //Handles events during playback.
  16. the Animationstart method is called when playback starts, and 5.0 indicates its arguments
  17. Stabargs.add ("OnStart", "Animationstart");
  18. Stabargs.add ("Onstartparams", 5.0f);
  19. //Set the object to accept the method, the default is self-acceptance, here can also be changed to another object to accept,
  20. //Then you have to implement the Animationstart method in the script that receives the object.
  21. Stabargs.add ("Onstarttarget", gameobject);
  22. //Play at the end of the call, parameters and similar above
  23. Stabargs.add ("OnComplete", "Animationend");
  24. Stabargs.add ("Oncompleteparams", "End");
  25. Stabargs.add ("Oncompletetarget", gameobject);
  26. //play in call, parameters and similar above
  27. Stabargs.add ("OnUpdate", "animationupdate");
  28. Stabargs.add ("Onupdateparams", true);
  29. Stabargs.add ("Onupdatetarget", gameobject);
  30. Itween.stab (Gameobject, Stabargs);
  31. }
  32. //The animation is called at the start
  33. void Animationstart (float f)
  34. {
  35. Debug.Log ("Start:" + f);
  36. }
  37. //At the end of the animation call
  38. void Animationend (string f)
  39. {
  40. Debug.Log ("End:" + f);
  41. }
  42. //Call in animation
  43. void Animationupdate (bool f)
  44. {
  45. Debug.Log ("UPDATE:" + f);
  46. }


Itween Basic Audio (volume and pitch changes)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.