I am writing an app for the iPhone using cocos2d where I have 4 Sprites that are buttons. I want to allow and respond to the following (allowing the user 3 seconds to apply his input before timing out):
— Single button presses (I have this part working).
— Pressing of more than 1 button at at the same time (each combination would have a different response).
— Flicking/Swiping gestures that originate from within each of the button Sprites.
— Shaking the iPhone.
— Tilting the iphone up, down, left, right (from landscape mode).
Any insight into different approaches would be greatly appreciated. B)
Here is how I implemented this in case anyone else is trying to do this (I attempted to add the shakes/gestures/tilts part yet just the Simultaneous button presses and for now I have limited it to only 2-button combos — but I could easily extend the logic to handle 3 and 4-button combos as well).
spuButton.h (a CCSprite Subclass)
spuButton.m
HelloWorldScene.m (Just my tick: method to keep my other functions from confusing the example)