00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #import "Support/uthash.h"
00028 #import "ccTypes.h"
00029
00030 typedef void (*TICK_IMP)(id, SEL, ccTime);
00031
00032
00033
00034
00036 @interface CCTimer : NSObject
00037 {
00038 id target;
00039 TICK_IMP impMethod;
00040
00041 ccTime elapsed;
00042
00043 @public
00044 ccTime interval;
00045 SEL selector;
00046 }
00047
00049 @property (nonatomic,readwrite,assign) ccTime interval;
00050
00053 +(id) timerWithTarget:(id) t selector:(SEL)s;
00054
00057 +(id) timerWithTarget:(id) t selector:(SEL)s interval:(ccTime)seconds;
00058
00061 -(id) initWithTarget:(id) t selector:(SEL)s;
00062
00065 -(id) initWithTarget:(id) t selector:(SEL)s interval:(ccTime)seconds;
00066
00067
00069 -(void) update: (ccTime) dt;
00070 @end
00071
00072
00073
00074
00075
00076
00077
00078 struct _listEntry;
00079 struct _hashSelectorEntry;
00080 struct _hashUpdateEntry;
00081
00093 @interface CCScheduler : NSObject
00094 {
00095 ccTime timeScale_;
00096
00097
00098
00099
00100 struct _listEntry *updatesNeg;
00101 struct _listEntry *updates0;
00102 struct _listEntry *updatesPos;
00103 struct _hashUpdateEntry *hashForUpdates;
00104
00105
00106 struct _hashSelectorEntry *hashForSelectors;
00107 struct _hashSelectorEntry *currentTarget;
00108 BOOL currentTargetSalvaged;
00109
00110
00111 TICK_IMP impMethod;
00112 SEL updateSelector;
00113 }
00114
00122 @property (nonatomic,readwrite) ccTime timeScale;
00123
00125 +(CCScheduler *)sharedScheduler;
00126
00130 +(void)purgeSharedScheduler;
00131
00135 -(void) tick:(ccTime)dt;
00136
00144 -(void) scheduleSelector:(SEL)selector forTarget:(id)target interval:(ccTime)interval paused:(BOOL)paused;
00145
00151 -(void) scheduleUpdateForTarget:(id)target priority:(int)priority paused:(BOOL)paused;
00152
00157 -(void) unscheduleSelector:(SEL)selector forTarget:(id)target;
00158
00162 -(void) unscheduleUpdateForTarget:(id)target;
00163
00168 -(void) unscheduleAllSelectorsForTarget:(id)target;
00169
00175 -(void) unscheduleAllSelectors;
00176
00182 -(void) pauseTarget:(id)target;
00183
00189 -(void) resumeTarget:(id)target;
00190
00191
00197 -(void) scheduleTimer: (CCTimer*) timer DEPRECATED_ATTRIBUTE;
00198
00203 -(void) unscheduleTimer: (CCTimer*) timer DEPRECATED_ATTRIBUTE;
00204
00211 -(void) unscheduleAllTimers DEPRECATED_ATTRIBUTE;
00212 @end