Simple Piano The script is not complicated, and it requires the blessing of music theory to be able to play
This script is relatively simple, and the characters are relatively simple. The difficulty lies in the principle of programming, and even more difficult in the music theory. Once the script is running, you can use the keyboard to play the piano, and the keys you press will change the appearance.
Let's set one key first, and then set the rest later, and modify the script parameters. First we define the keys and notes, and then we set up a little bit of variation in the size of the character. It looks simple, but the programming principle is really simple.
So how are the keys positioned? That's with the help of CodeCat's note editor. Once you've decided on the notes, click OK.
For specific settings, please refer to the following settings. The A key is set to 40, the B key is set to 42, the S key is set to 44, the D key is set to 45, the J key is set to 47, the K key is set to 49, and the L key is set to 51. Copy the script of the A key and copy it to other roles to modify the parameters.
It stands to reason that the script editor can be played with the keyboard at this point. After all, it's the easy version. So, it's inevitable that the notes aren't all right. If you are proficient in piano theory, you can also try to play a piece yourself. Of course, we can also use programming to let the script play itself according to the score. However, the process is more cumbersome.
In order to simplify the script, you can set the 7 notes as a definition function, so that when editing the score, the procedure will be simplified a lot, and you don't have to think about which key the note corresponds to on the keyboard.