|
cocos2d for iPhone 1.0.0
2D engine for iOS and OS X
|
00001 /* 00002 * cocos2d for iPhone: http://www.cocos2d-iphone.org 00003 * 00004 * Copyright (c) 2009 Valentin Milea 00005 * 00006 * Permission is hereby granted, free of charge, to any person obtaining a copy 00007 * of this software and associated documentation files (the "Software"), to deal 00008 * in the Software without restriction, including without limitation the rights 00009 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00010 * copies of the Software, and to permit persons to whom the Software is 00011 * furnished to do so, subject to the following conditions: 00012 * 00013 * The above copyright notice and this permission notice shall be included in 00014 * all copies or substantial portions of the Software. 00015 * 00016 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00017 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00018 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00019 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00020 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00021 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00022 * THE SOFTWARE. 00023 * 00024 */ 00025 00026 // Only compile this code on iOS. These files should NOT be included on your Mac project. 00027 // But in case they are included, it won't be compiled. 00028 #import <Availability.h> 00029 #ifdef __IPHONE_OS_VERSION_MAX_ALLOWED 00030 00031 #import "CCTouchDelegateProtocol.h" 00032 #import "EAGLView.h" 00033 00034 00035 typedef enum 00036 { 00037 kCCTouchSelectorBeganBit = 1 << 0, 00038 kCCTouchSelectorMovedBit = 1 << 1, 00039 kCCTouchSelectorEndedBit = 1 << 2, 00040 kCCTouchSelectorCancelledBit = 1 << 3, 00041 kCCTouchSelectorAllBits = ( kCCTouchSelectorBeganBit | kCCTouchSelectorMovedBit | kCCTouchSelectorEndedBit | kCCTouchSelectorCancelledBit), 00042 } ccTouchSelectorFlag; 00043 00044 00045 enum { 00046 kCCTouchBegan, 00047 kCCTouchMoved, 00048 kCCTouchEnded, 00049 kCCTouchCancelled, 00050 00051 kCCTouchMax, 00052 }; 00053 00054 struct ccTouchHandlerHelperData { 00055 SEL touchesSel; 00056 SEL touchSel; 00057 ccTouchSelectorFlag type; 00058 }; 00059 00076 @interface CCTouchDispatcher : NSObject <EAGLTouchDelegate> 00077 { 00078 NSMutableArray *targetedHandlers; 00079 NSMutableArray *standardHandlers; 00080 00081 BOOL locked; 00082 BOOL toAdd; 00083 BOOL toRemove; 00084 NSMutableArray *handlersToAdd; 00085 NSMutableArray *handlersToRemove; 00086 BOOL toQuit; 00087 00088 BOOL dispatchEvents; 00089 00090 // 4, 1 for each type of event 00091 struct ccTouchHandlerHelperData handlerHelperData[kCCTouchMax]; 00092 } 00093 00095 + (CCTouchDispatcher*)sharedDispatcher; 00096 00098 @property (nonatomic,readwrite, assign) BOOL dispatchEvents; 00099 00104 -(void) addStandardDelegate:(id<CCStandardTouchDelegate>) delegate priority:(int)priority; 00109 -(void) addTargetedDelegate:(id<CCTargetedTouchDelegate>) delegate priority:(int)priority swallowsTouches:(BOOL)swallowsTouches; 00113 -(void) removeDelegate:(id) delegate; 00115 -(void) removeAllDelegates; 00118 -(void) setPriority:(int) priority forDelegate:(id) delegate; 00119 00120 NSComparisonResult sortByPriority(id first, id second, void *context); 00121 @end 00122 00123 #endif // __IPHONE_OS_VERSION_MAX_ALLOWED