Exemple #1
0
// returns true if any of the buttons are pressed.
boolean touchAnyPressed() {
  return (
           touchPressed(I_RED) ||
           touchPressed(I_GRN) ||
           touchPressed(I_BLU) ||
           touchPressed(I_YEL)
         );
}
const bool CCSceneAppUI::handleTouches(const CCScreenTouches &touch1, const CCScreenTouches &touch2, const CCTime &time)
{
    bool usingControls = false;
    
    // Handles two touches pressed
	if( touch1.usingTouch != NULL && touch2.usingTouch != NULL )
	{
        if( touchAllowed( touch1 ) )
        {
            if( controlsUITouch == touch1.usingTouch )
            {
                touchReleased( touch1, touch_lost );
            }
            
            if( controlsUITouch != touch2.usingTouch )
            {
                twoTouchRegistered( touch1, touch2 );
            }
            
            usingControls = handleTwoTouches( touch1, touch2 );
        }
	}
	else
	{
		// Handles one touch pressed
		if( touch2.lastTimeReleased > 0.0f &&
            touchAllowed( touch1 ) )
		{
			if( controlsUITouch != touch1.usingTouch )
			{
                touchRegistered( touch1 );
			}
			
            CCPoint touchDelta = touch1.delta;
            if( controlsMoving == false )
            {
                if( touchMovementAllowed( touch1, touchDelta ) )
                {
                }
                else
                {
                    usingControls = touchPressed( touch1 );
                }
            }
            
            if( controlsMoving )
            {   
                usingControls = touchMoving( touch1, touchDelta );
            }
		}
		
		// On touch release
		else 
        {
            if( controlsUITouch != NULL )
            {
                if( controlsUITouch == touch1.lastTouch )
                {	
                    usingControls = touchReleased( touch1, touch_released );
                }
                else
                {
                    touchReleased( touch1, touch_lost );
                }
                
                lockCameraView();
                
                // Reset state
                if( controlsMoving )
                {
                    controlsMoving = false;
                }
				controlsUITouch = NULL;
			}
		}
	}
    
    return usingControls;
}