课程: Code Clinic: JavaScript

今天就学习课程吧!

今天就开通帐号,24,600 门业界名师课程任您挑!

Modifying notes on mouse position

Modifying notes on mouse position - JavaScript教程

课程: Code Clinic: JavaScript

Modifying notes on mouse position

- [Instructor] Now we want to modify the sound that we make when we click on different positions on the screen, so in order to do that I'm going to need a few other variables. I'll start off with original Y position as well as original X position. That would be obviously the position of the mouse and then we'll store the frequency or the note that we're playing in a variable called originalFrequency, and then we're gonna need a list of frequencies. So we'll put that in a list called scaleFrequencies and that's gonna be of course an array, and it's gonna have a bunch of notes. You notice that before we've been using this note of 110 and we need to put the frequencies for all the notes that we want to play depending on the mouse position. So, because there are a bunch of numbers, I've placed these in a Gist for you. The interesting thing to note is that if you look at the numbers you'll note that there's a 110 right here, and if you go seven places to the right, the number is 220, so…

内容