Multi-Touch Setup
rainwaterstudios
Member Posts: 198
I'm trying to find the best way to make a digital instrument using multi-touch in GameSalad.
I need a tone to be played whenever the user is touching any of 6 buttons, but the pitch of the tone must depend on which buttons are pressed, i.e. if all 6 fingers are touching the tone would be D, if 5 fingers are down E, 4 fingers F#, 3 fingers G, 2 fingers A, 1 finger B....
@Socks any suggestions?
Comments
You can monitor the touch count using the touch attributes. You'll have to build out logic that accounts for when a touch is pressed and how many touches are on the screen. I have a few videos on multitouch.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Like @The_Gamesalad_Guru says, you can use the touches.count attribute.
When game.touches.count = 1
Play B
Otherwise
--When game.touches.count = 2
--Play A
--Otherwise
----When game.touches.count = 3
----Play G
----Otherwise
------When game.touches.count = 4
-------Play F#
------Otherwise
--------When game.touches.count = 5
--------Play E
--------Otherwise
----------When game.touches.count = 6
----------Play D
Another approach . . . . you could also load in just a D (as your root sound file) and pitch it according to the touch count, each semi tone is 105.94631% higher in pitch value than the previously lower pitch, so D is 1, D# is 1.0594631, E is 1.12246206026161 (1.0594631
*
1.0594631), F is 1.18920713399715 (1.12246206026161*
1.0594631) . . . etc etc.This might seem a little convoluted, but the advantage is that if you can be bothered to calculate the equation then you can put the entirety of your touch based pitching into a single equation that lives in the pitch expression field, and the number of touches will pitch the root D up accordingly.