We are wanting the keys to be horizontally centered in the world. The center of the world is at half the width of the world. Half the keyboard is to be on the left of world center and the other half on the right. The whole keyboard width is the number of keys times the width of the image of one key; half of that is the number of keys times the width of the image of one key divided by two. Subtracting half the width of the keyboard from the center of the world gives the location of the left edge of the first key of the keyboard. Adding half the width of one key to that will give the x-location at which to place the first key. The remaining keys can then be placed by adding the width of one key to the x-location of the last key placed.
A new version of this scenario was uploaded on Sun Jan 20 14:58:29 UTC 2013
A very simple piano project I have done with the help of book.
2013/1/19