This repository has been archived by the owner on Jan 14, 2025. It is now read-only.
forked from joekallen/cocos2d-GestureRecognizers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcocos2d.patch
710 lines (688 loc) · 22 KB
/
cocos2d.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
diff -rupN old/CCLayer.h new/CCLayer.h
--- old/CCLayer.h 2011-09-09 07:23:19.000000000 +0200
+++ new/CCLayer.h 2011-09-06 21:04:36.000000000 +0200
@@ -49,7 +49,6 @@
#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
@interface CCLayer : CCNode <UIAccelerometerDelegate, CCStandardTouchDelegate, CCTargetedTouchDelegate>
{
- BOOL isTouchEnabled_;
BOOL isAccelerometerEnabled_;
}
/** If isTouchEnabled, this method is called onEnter. Override it to change the
@@ -67,15 +66,6 @@
*/
-(void) registerWithTouchDispatcher;
-/** whether or not it will receive Touch events.
- You can enable / disable touch events with this property.
- Only the touches of this node will be affected. This "method" is not propagated to it's children.
-
- Valid on iOS and Mac OS X v10.6 and later.
-
- @since v0.8.1
- */
-@property(nonatomic,assign) BOOL isTouchEnabled;
/** whether or not it will receive Accelerometer events
You can enable / disable accelerometer events with this property.
diff -rupN old/CCLayer.m new/CCLayer.m
--- old/CCLayer.m 2011-09-09 07:23:19.000000000 +0200
+++ new/CCLayer.m 2011-09-06 21:05:54.000000000 +0200
@@ -56,8 +56,6 @@
[self setContentSize:s];
self.isRelativeAnchorPoint = NO;
- isTouchEnabled_ = NO;
-
#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
isAccelerometerEnabled_ = NO;
#elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED)
@@ -95,15 +93,11 @@
}
}
--(BOOL) isTouchEnabled
-{
- return isTouchEnabled_;
-}
-
-(void) setIsTouchEnabled:(BOOL)enabled
{
if( isTouchEnabled_ != enabled ) {
- isTouchEnabled_ = enabled;
+ // CCNode needs to remove any gesture recognizers
+ [super setIsTouchEnabled:enabled];
if( isRunning_ ) {
if( enabled )
[self registerWithTouchDispatcher];
diff -rupN old/CCNode.h new/CCNode.h
--- old/CCNode.h 2011-09-09 07:23:19.000000000 +0200
+++ new/CCNode.h 2011-09-06 21:08:52.000000000 +0200
@@ -35,6 +35,10 @@
#import "ccConfig.h"
#import "Support/CCArray.h"
+#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
+@class CCGestureRecognizer;
+#endif
+
enum {
kCCNodeTagInvalid = -1,
};
@@ -166,6 +170,12 @@ enum {
#if CC_NODE_TRANSFORM_USING_AFFINE_MATRIX
BOOL isTransformGLDirty_:1;
#endif
+
+#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
+ CCArray* gestureRecognizers_;
+ CGSize touchableArea_;
+ BOOL isTouchEnabled_;
+#endif
}
/** The z order of the node relative to it's "brothers": children of the same parent */
@@ -475,6 +485,29 @@ enum {
*/
-(void) pauseSchedulerAndActions;
+#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
+-(void) addGestureRecognizer:(CCGestureRecognizer*)gestureRecognizer;
+-(void) removeGestureRecognizer:(CCGestureRecognizer*)gestureRecognizer;
+-(void) stopAllGestureRecognizers;
+-(void) startAllGestureRecognizers;
+
+/* used to see if a touch is in a nodes touchAble area, if the area isn't set
+ the content size is used */
+-(BOOL) isPointInArea:(CGPoint)pt;
+-(BOOL) isNodeInTreeTouched:(CGPoint)pt;
+
+/* property for getting/setting touchable area */
+@property(nonatomic,assign) CGSize touchableArea;
+@property(nonatomic,readonly) CCArray *gestureRecognizers;
+
+/** whether or not it will receive Touch events.
+ You can enable / disable touch events with this property.
+ Only the touches of this node will be affected. This "method" is not propagated to it's children.
+ @since v0.8.1
+ */
+@property(nonatomic,assign) BOOL isTouchEnabled;
+#endif
+
// transformation methods
diff -rupN old/CCNode.m new/CCNode.m
--- old/CCNode.m 2011-09-09 07:23:19.000000000 +0200
+++ new/CCNode.m 2011-09-06 21:36:59.000000000 +0200
@@ -41,6 +41,7 @@
#import <Availability.h>
#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
#import "Platforms/iOS/CCDirectorIOS.h"
+#import "Platforms/iOS/CCGestureRecognizer.h"
#endif
@@ -72,6 +73,10 @@
@synthesize isRunning = isRunning_;
@synthesize userData = userData_;
+#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
+@synthesize gestureRecognizers = gestureRecognizers_;
+#endif
+
#pragma mark CCNode - Transform related properties
@synthesize rotation = rotation_, scaleX = scaleX_, scaleY = scaleY_;
@@ -298,6 +303,12 @@
// userData is always inited as nil
userData_ = nil;
+
+#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
+ // lazy allocation
+ gestureRecognizers_ = nil;
+ isTouchEnabled_ = NO;
+#endif
//initialize parent to nil
parent_ = nil;
@@ -672,6 +683,11 @@
-(void) onEnter
{
+#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
+ if( isTouchEnabled_ )
+ [self startAllGestureRecognizers];
+#endif
+
[children_ makeObjectsPerformSelector:@selector(onEnter)];
[self resumeSchedulerAndActions];
@@ -685,6 +701,9 @@
-(void) onExit
{
+#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
+ [self stopAllGestureRecognizers];
+#endif
[self pauseSchedulerAndActions];
isRunning_ = NO;
@@ -783,6 +802,143 @@
[[CCActionManager sharedManager] pauseTarget:self];
}
+#pragma mark Gesture Recognition
+
+#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
+-(BOOL) isRunning
+{
+ return isRunning_;
+}
+
+-(void) setIsRunning:(BOOL)running
+{
+ if( isRunning_ != running )
+ {
+ isRunning_ = running;
+ if( isRunning_ && isTouchEnabled_ )
+ [self startAllGestureRecognizers];
+ else
+ [self stopAllGestureRecognizers];
+ }
+}
+
+- (void)addGestureRecognizer:(CCGestureRecognizer*)gestureRecognizer
+{
+ if( ! gestureRecognizers_ )
+ gestureRecognizers_ = [[CCArray alloc] initWithCapacity:4];
+ [gestureRecognizers_ addObject:gestureRecognizer];
+ gestureRecognizer.node = self;
+
+ // if we are running we add the recognizer to the view right now
+ // if not we let the one enter take care of it since we don't
+ // want recognizers going off when the node isn't active
+ if( isRunning_ && isTouchEnabled_ )
+ [[CCDirector sharedDirector].openGLView addGestureRecognizer:gestureRecognizer.gestureRecognizer];
+}
+
+- (void)removeGestureRecognizer:(CCGestureRecognizer*)gestureRecognizer
+{
+ [gestureRecognizers_ removeObject:gestureRecognizer];
+ // this is a sanity check to make sure that someone didn't add the
+ // same gestureRecognizer to different nodes
+ if( gestureRecognizer.node == self )
+ [[CCDirector sharedDirector].openGLView removeGestureRecognizer:gestureRecognizer.gestureRecognizer];
+}
+
+- (void)stopAllGestureRecognizers
+{
+ CCGestureRecognizer* recognizer;
+ CCARRAY_FOREACH(gestureRecognizers_, recognizer)
+ {
+ if( recognizer.node == self )
+ [[CCDirector sharedDirector].openGLView removeGestureRecognizer:recognizer.gestureRecognizer];
+ }
+}
+
+-(void) startAllGestureRecognizers
+{
+ CCGestureRecognizer* recognizer;
+ CCARRAY_FOREACH(gestureRecognizers_, recognizer)
+ {
+ if( recognizer.node == self )
+ [[CCDirector sharedDirector].openGLView addGestureRecognizer:recognizer.gestureRecognizer];
+ }
+}
+
+-(BOOL) isPointInArea:(CGPoint)pt
+{
+ if( visible_ == NO )
+ return NO;
+
+ /* convert the point to the nodes local coordinate system to make it
+ easier to compare against the area the node occupies*/
+ pt = [self convertToNodeSpace:pt];
+
+ // we have to take the anchor point into account for checking
+ CGRect rect;
+ /* we should be able to use touchableArea here, even if a node doesn't set
+ this, it will return the contentArea. */
+ rect.size = self.touchableArea;
+ rect.origin = CGPointZero;;
+
+ if( CGRectContainsPoint(rect,pt) )
+ return YES;
+ return NO;
+}
+
+-(BOOL) isNodeInTreeTouched:(CGPoint)pt
+{
+ if( [self isPointInArea:pt] )
+ return YES;
+
+ BOOL rslt = NO;
+ CCNode* child;
+ CCARRAY_FOREACH(children_, child )
+ {
+ if( [child isNodeInTreeTouched:pt] )
+ {
+ rslt = YES;
+ break;
+ }
+ }
+ return rslt;
+}
+
+-(CGSize) touchableArea
+{
+ // we use content size if touchable area is 0
+ if( touchableArea_.width != 0.0f || touchableArea_.height != 0.0f )
+ return touchableArea_;
+ else
+ return contentSize_;
+}
+
+-(void) setTouchableArea:(CGSize)area
+{
+ touchableArea_ = area;
+}
+
+-(BOOL) isTouchEnabled
+{
+ return isTouchEnabled_;
+}
+
+-(void) setIsTouchEnabled:(BOOL)enabled
+{
+ if( isTouchEnabled_ != enabled )
+ {
+ isTouchEnabled_ = enabled;
+ CCGestureRecognizer* recognizer;
+ CCARRAY_FOREACH(gestureRecognizers_, recognizer)
+ {
+ // just an extra check
+ if( recognizer.node == self )
+ recognizer.gestureRecognizer.enabled = isTouchEnabled_;
+ }
+ }
+}
+#endif
+
#pragma mark CCNode Transform
- (CGAffineTransform)nodeToParentTransform
diff -rupN old/Platforms/iOS/CCGestureRecognizer.h new/Platforms/iOS/CCGestureRecognizer.h
--- old/Platforms/iOS/CCGestureRecognizer.h 1970-01-01 01:00:00.000000000 +0100
+++ new/Platforms/iOS/CCGestureRecognizer.h 2011-09-06 21:25:22.000000000 +0200
@@ -0,0 +1,46 @@
+//
+// CCGestureRecognizer.h
+// cocos
+//
+// Created by Joe Allen on 7/11/10.
+// Copyright 2010 Glaiveware LLC. All rights reserved.
+//
+
+#import "ccTypes.h"
+#import "CCNode.h"
+#import <UIKit/UIKit.h>
+
+#ifndef __CCGestureRecognizer_H__
+#define __CCGestureRecognizer_H__
+
+@class CCNode;
+
+@interface CCGestureRecognizer : NSObject <UIGestureRecognizerDelegate,NSCoding>
+{
+ UIGestureRecognizer* gestureRecognizer_;
+ CCNode* node_;
+
+ id<UIGestureRecognizerDelegate> delegate_;
+
+ id target_;
+ SEL callback_;
+ }
+
+@property(nonatomic,readonly) UIGestureRecognizer* gestureRecognizer;
+@property(nonatomic,assign) CCNode* node;
+@property(nonatomic,assign) id<UIGestureRecognizerDelegate> delegate;
+@property(nonatomic,assign) id target;
+@property(nonatomic,assign) SEL callback;
+
+- (id) initWithRecognizerTargetAction:(UIGestureRecognizer*)gestureRecognizer target:(id)target action:(SEL)action;
++ (id) CCRecognizerWithRecognizerTargetAction:(UIGestureRecognizer*)gestureRecognizer target:(id)target action:(SEL)action;
+
+- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch;
+- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer;
+- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer;
+
+// this is the function the gesture recognizer will callback and we will add our info onto it
+- (void) callback:(UIGestureRecognizer*)recognizer;
+@end
+
+#endif // end of __CCGestureRecognizer_H__
\ No newline at end of file
diff -rupN old/Platforms/iOS/CCGestureRecognizer.m new/Platforms/iOS/CCGestureRecognizer.m
--- old/Platforms/iOS/CCGestureRecognizer.m 1970-01-01 01:00:00.000000000 +0100
+++ new/Platforms/iOS/CCGestureRecognizer.m 2011-09-07 15:48:20.000000000 +0200
@@ -0,0 +1,328 @@
+//
+// CCGestureRecognizer.m
+// cocos
+//
+// Created by Joe Allen on 7/11/10.
+// Copyright 2010 Glaiveware LLC. All rights reserved.
+//
+
+#import "CCGestureRecognizer.h"
+#import "CCDirector.h"
+#import "ccMacros.h"
+#import "CGPointExtension.h"
+
+@implementation CCGestureRecognizer
+
+-(void)dealloc
+{
+ CCLOGINFO( @"cocos2d: deallocing %@", self);
+ [gestureRecognizer_ release];
+ [super dealloc];
+ }
+
+- (UIGestureRecognizer*)gestureRecognizer
+{
+ return gestureRecognizer_;
+ }
+
+- (CCNode*)node
+{
+ return node_;
+ }
+
+- (void)setNode:(CCNode*)node
+{
+ node_ = node;
+ }
+
+- (id<UIGestureRecognizerDelegate>)delegate
+{
+ return delegate_;
+ }
+
+- (void) setDelegate:(id<UIGestureRecognizerDelegate>)delegate
+{
+ delegate_ = delegate;
+ }
+
+- (id)target
+{
+ return target_;
+ }
+
+- (void)setTarget:(id)target
+{
+ target_ = target;
+ }
+
+- (SEL)callback
+{
+ return callback_;
+ }
+
+- (void)setCallback:(SEL)callback
+{
+ callback_ = callback;
+ }
+
+- (id)initWithRecognizerTargetAction:(UIGestureRecognizer*)gestureRecognizer target:(id)target action:(SEL)action
+{
+ if( (self=[super init]) )
+ {
+ assert(gestureRecognizer != NULL && "gesture recognizer must not be null");
+ gestureRecognizer_ = gestureRecognizer;
+ [gestureRecognizer_ retain];
+ [gestureRecognizer_ addTarget:self action:@selector(callback:)];
+
+ // setup our new delegate
+ delegate_ = gestureRecognizer_.delegate;
+ gestureRecognizer_.delegate = self;
+
+ target_ = target; // weak ref
+ callback_ = action;
+ }
+ return self;
+ }
+
++ (id)CCRecognizerWithRecognizerTargetAction:(UIGestureRecognizer*)gestureRecognizer target:(id)target action:(SEL)action
+{
+ return [[[self alloc] initWithRecognizerTargetAction:gestureRecognizer target:target action:action] autorelease];
+ }
+
+- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
+{
+ assert( node_ != NULL && "gesture recognizer must have a node" );
+
+ CGPoint pt = [[CCDirector sharedDirector] convertToGL:[touch locationInView: [touch view]]];
+ /* do a rotation opposite of the node to see if the point is in it
+ it should make it easier to check against an aligned object */
+
+ BOOL rslt = [node_ isPointInArea:pt];
+ // TODO: we might want to think about adding this first check back in.
+
+ // leaving this out lets a node and its children share a touch if the
+ // touch are overlaps. two nodes overlapping on a scene though would
+ // not both get the touch.
+
+
+ if( rslt )
+ {
+ /* ok we know this node was touched, but now we need to make sure
+ no other node above this one was touched -- this check only includes
+ nodes that receive touches */
+
+ // first is to check children
+ CCNode* n;
+ /*CCARRAY_FOREACH(node_.children, node)
+ {
+ if( [node isNodeInTreeTouched:pt] )
+ {
+ rslt = NO;
+ break;
+ }
+ }*/
+
+ // ok, still ok, now check children of parents after this node
+ n = node_;
+ CCNode* parent = node_.parent;
+ while( n != nil && rslt)
+ {
+ CCNode* child;
+ BOOL nodeFound = NO;
+ CCARRAY_FOREACH(parent.children, child)
+ {
+ if( !nodeFound )
+ {
+ if( !nodeFound && n == child )
+ nodeFound = YES; // we need to keep track of until we hit our node, any past it have a higher z value
+ continue;
+ }
+
+ if( [child isNodeInTreeTouched:pt] )
+ {
+ rslt = NO;
+ break;
+ }
+ }
+
+ n = parent;
+ parent = n.parent;
+ }
+ }
+
+ if( rslt && delegate_ && [delegate_ respondsToSelector:@selector(gestureRecognizer:shouldReceiveTouch:)] )
+ rslt = [delegate_ gestureRecognizer:gestureRecognizer shouldReceiveTouch:touch];
+
+ return rslt;
+ }
+
+- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
+{
+ if( delegate_ && [delegate_ respondsToSelector:@selector(gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:)] )
+ return [delegate_ gestureRecognizer:gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:otherGestureRecognizer];
+ return YES;
+ }
+
+- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
+{
+ if( delegate_ && [delegate_ respondsToSelector:@selector(gestureRecognizerShouldBegin:)] )
+ return [delegate_ gestureRecognizerShouldBegin:gestureRecognizer];
+ return YES;
+ }
+
+- (void)callback:(UIGestureRecognizer*)recognizer
+{
+ if( target_ )
+ [target_ performSelector:callback_ withObject:recognizer withObject:node_];
+ }
+
+- (void)encodeWithCoder:(NSCoder *)coder
+{
+ [coder encodeObject:gestureRecognizer_ forKey:@"gestureRecognizer"];
+ [coder encodeObject:node_ forKey:@"node"];
+ [coder encodeObject:delegate_ forKey:@"delegate"];
+ [coder encodeObject:target_ forKey:@"target"];
+ // TODO: callback_
+ [coder encodeBytes:(uint8_t*)&callback_ length:sizeof(callback_) forKey:@"callback"];
+ }
+
+- (id)initWithCoder:(NSCoder *)decoder
+{
+ self=[self init];
+ if (self)
+ {
+ // don't retain node, it will retain this
+ node_ = [decoder decodeObjectForKey:@"node"]; // weak ref
+ delegate_ = [decoder decodeObjectForKey:@"delegate"]; // weak ref
+ target_ = [decoder decodeObjectForKey:@"target"]; // weak ref
+ // TODO: callback_
+ NSUInteger len;
+ const uint8_t * buffer = [decoder decodeBytesForKey:@"callback" returnedLength:&len];
+ // sanity check to make sure our length is correct
+ if( len == sizeof(callback_) )
+ memcpy(&callback_, buffer, len);
+
+ gestureRecognizer_ = [decoder decodeObjectForKey:@"gestureRecognizer"];
+ [gestureRecognizer_ addTarget:self action:@selector(callback:)];
+
+ gestureRecognizer_.delegate = self;
+ [gestureRecognizer_ retain];
+ }
+ return self;
+ }
+
+- (NSString*) description
+{
+ return [NSString stringWithFormat:@"<%@ = %08X | %@ | Node = %@ >", [self class], self, [gestureRecognizer_ class], node_];
+ }
+
+@end
+#pragma mark NSCoding of built in recognizers
+
+@implementation UIRotationGestureRecognizer(NSCoder)
+- (void)encodeWithCoder:(NSCoder *)coder
+{}
+
+- (id)initWithCoder:(NSCoder *)decoder
+{
+ self=[self init];
+ if (self)
+ {}
+ return self;
+ }
+@end
+
+@implementation UITapGestureRecognizer(NSCoder)
+- (void)encodeWithCoder:(NSCoder *)coder
+{
+ [coder encodeInt:self.numberOfTapsRequired forKey:@"numberofTapsRequired"];
+ [coder encodeInt:self.numberOfTouchesRequired forKey:@"numberOfTouchesRequired"];
+ }
+
+- (id)initWithCoder:(NSCoder *)decoder
+{
+ self=[self init];
+ if (self)
+ {
+ self.numberOfTapsRequired = [decoder decodeIntForKey:@"numberOfTapsRequired"];
+ self.numberOfTouchesRequired = [decoder decodeIntForKey:@"numberOfTouchesRequired"];
+ }
+ return self;
+ }
+@end
+
+@implementation UIPanGestureRecognizer(NSCoder)
+- (void)encodeWithCoder:(NSCoder *)coder
+{
+ [coder encodeInt:self.minimumNumberOfTouches forKey:@"minimumNumberOfTouches"];
+ [coder encodeInt:self.maximumNumberOfTouches forKey:@"maximumNumberOfTouches"];
+ }
+
+- (id)initWithCoder:(NSCoder *)decoder
+{
+ self=[self init];
+ if (self)
+ {
+ self.minimumNumberOfTouches = [decoder decodeIntForKey:@"minimumNumberOfTouches"];
+ self.maximumNumberOfTouches = [decoder decodeIntForKey:@"maximumNumberOfTouches"];
+ }
+ return self;
+ }
+@end
+
+@implementation UILongPressGestureRecognizer(NSCoder)
+- (void)encodeWithCoder:(NSCoder *)coder
+{
+ [coder encodeInt:self.numberOfTapsRequired forKey:@"numberOfTapsRequired"];
+ [coder encodeInt:self.numberOfTouchesRequired forKey:@"numberOfTouchesRequired"];
+ [coder encodeDouble:self.minimumPressDuration forKey:@"minimumPressDuration"];
+ [coder encodeFloat:self.allowableMovement forKey:@"allowableMovement"];
+ }
+
+- (id)initWithCoder:(NSCoder *)decoder
+{
+ self=[self init];
+ if (self)
+ {
+ self.numberOfTapsRequired = [decoder decodeIntForKey:@"numberOfTapsRequired"];
+ self.numberOfTouchesRequired = [decoder decodeIntForKey:@"numberOfTouchesRequired"];
+ self.minimumPressDuration = [decoder decodeDoubleForKey:@"minimumPressDuration"];
+ self.allowableMovement = [decoder decodeFloatForKey:@"allowableMovement"];
+ }
+ return self;
+ }
+@end
+
+@implementation UISwipeGestureRecognizer(NSCoder)
+- (void)encodeWithCoder:(NSCoder *)coder
+{
+ [coder encodeInt:self.numberOfTouchesRequired forKey:@"numberOfTouchesRequired"];
+ [coder encodeInt:self.direction forKey:@"direction"];
+ }
+
+- (id)initWithCoder:(NSCoder *)decoder
+{
+ self=[self init];
+ if (self)
+ {
+ self.numberOfTouchesRequired = [decoder decodeIntForKey:@"numberOfTouchesRequired"];
+ self.direction = (UISwipeGestureRecognizerDirection)[decoder decodeIntForKey:@"direction"];
+ }
+ return self;
+ }
+@end
+
+@implementation UIPinchGestureRecognizer(NSCoder)
+- (void)encodeWithCoder:(NSCoder *)coder
+{
+ }
+
+- (id)initWithCoder:(NSCoder *)decoder
+{
+ self=[self init];
+ if (self)
+ {
+ }
+ return self;
+ }
+@end
\ No newline at end of file
diff -rupN old/cocos2d.h new/cocos2d.h
--- old/cocos2d.h 2011-09-09 07:23:21.000000000 +0200
+++ new/cocos2d.h 2011-09-06 21:31:53.000000000 +0200
@@ -130,6 +130,7 @@
#import "Platforms/iOS/CCTouchHandler.h"
#import "Platforms/iOS/EAGLView.h"
#import "Platforms/iOS/CCDirectorIOS.h"
+#import "Platforms/iOS/CCGestureRecognizer.h"
#elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED)
#import "Platforms/Mac/MacGLView.h"