diff options
Diffstat (limited to 'libs/cocos2d/Platforms/iOS/CCTouchDelegateProtocol.h')
| -rwxr-xr-x | libs/cocos2d/Platforms/iOS/CCTouchDelegateProtocol.h | 75 |
1 files changed, 75 insertions, 0 deletions
| diff --git a/libs/cocos2d/Platforms/iOS/CCTouchDelegateProtocol.h b/libs/cocos2d/Platforms/iOS/CCTouchDelegateProtocol.h new file mode 100755 index 0000000..20ba036 --- /dev/null +++ b/libs/cocos2d/Platforms/iOS/CCTouchDelegateProtocol.h | |||
| @@ -0,0 +1,75 @@ | |||
| 1 | /* | ||
| 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org | ||
| 3 | * | ||
| 4 | * Copyright (c) 2009 Valentin Milea | ||
| 5 | * | ||
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 7 | * of this software and associated documentation files (the "Software"), to deal | ||
| 8 | * in the Software without restriction, including without limitation the rights | ||
| 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 10 | * copies of the Software, and to permit persons to whom the Software is | ||
| 11 | * furnished to do so, subject to the following conditions: | ||
| 12 | * | ||
| 13 | * The above copyright notice and this permission notice shall be included in | ||
| 14 | * all copies or substantial portions of the Software. | ||
| 15 | * | ||
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| 22 | * THE SOFTWARE. | ||
| 23 | * | ||
| 24 | */ | ||
| 25 | |||
| 26 | // Only compile this code on iOS. These files should NOT be included on your Mac project. | ||
| 27 | // But in case they are included, it won't be compiled. | ||
| 28 | #import <Availability.h> | ||
| 29 | #ifdef __IPHONE_OS_VERSION_MAX_ALLOWED | ||
| 30 | |||
| 31 | #import <UIKit/UIKit.h> | ||
| 32 | |||
| 33 | /** | ||
| 34 | CCTargetedTouchDelegate. | ||
| 35 | |||
| 36 | Using this type of delegate results in two benefits: | ||
| 37 | 1. You don't need to deal with NSSets, the dispatcher does the job of splitting | ||
| 38 | them. You get exactly one UITouch per call. | ||
| 39 | 2. You can *claim* a UITouch by returning YES in ccTouchBegan. Updates of claimed | ||
| 40 | touches are sent only to the delegate(s) that claimed them. So if you get a move/ | ||
| 41 | ended/cancelled update you're sure it's your touch. This frees you from doing a | ||
| 42 | lot of checks when doing multi-touch. | ||
| 43 | |||
| 44 | (The name TargetedTouchDelegate relates to updates "targeting" their specific | ||
| 45 | handler, without bothering the other handlers.) | ||
| 46 | @since v0.8 | ||
| 47 | */ | ||
| 48 | @protocol CCTargetedTouchDelegate <NSObject> | ||
| 49 | |||
| 50 | /** Return YES to claim the touch. | ||
| 51 | @since v0.8 | ||
| 52 | */ | ||
| 53 | - (BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event; | ||
| 54 | @optional | ||
| 55 | // touch updates: | ||
| 56 | - (void)ccTouchMoved:(UITouch *)touch withEvent:(UIEvent *)event; | ||
| 57 | - (void)ccTouchEnded:(UITouch *)touch withEvent:(UIEvent *)event; | ||
| 58 | - (void)ccTouchCancelled:(UITouch *)touch withEvent:(UIEvent *)event; | ||
| 59 | @end | ||
| 60 | |||
| 61 | /** | ||
| 62 | CCStandardTouchDelegate. | ||
| 63 | |||
| 64 | This type of delegate is the same one used by CocoaTouch. You will receive all the events (Began,Moved,Ended,Cancelled). | ||
| 65 | @since v0.8 | ||
| 66 | */ | ||
| 67 | @protocol CCStandardTouchDelegate <NSObject> | ||
| 68 | @optional | ||
| 69 | - (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event; | ||
| 70 | - (void)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event; | ||
| 71 | - (void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event; | ||
| 72 | - (void)ccTouchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event; | ||
| 73 | @end | ||
| 74 | |||
| 75 | #endif // __IPHONE_OS_VERSION_MAX_ALLOWED | ||
