• Main Page
  • Related Pages
  • Modules
  • Classes
  • Files
  • File List
  • File Members

/depot/cocosdocs/cocos2d-iphone-0.99.5/cocos2d/CCScheduler.h

00001 /*
00002  * cocos2d for iPhone: http://www.cocos2d-iphone.org
00003  *
00004  * Copyright (c) 2008-2010 Ricardo Quesada
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 
00027 #import "Support/uthash.h"
00028 #import "ccTypes.h"
00029 
00030 typedef void (*TICK_IMP)(id, SEL, ccTime);
00031 
00032 //
00033 // CCTimer
00034 //
00036 @interface CCTimer : NSObject
00037 {
00038          id target;
00039          TICK_IMP impMethod;
00040          
00041          ccTime elapsed;
00042 
00043 @public                                      // optimization
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 // CCScheduler
00076 //
00077 
00078 struct _listEntry;
00079 struct _hashSelectorEntry;
00080 struct _hashUpdateEntry;
00081 
00093 @interface CCScheduler : NSObject
00094 {        
00095          ccTime                              timeScale_;
00096          
00097          //
00098          // "updates with priority" stuff
00099          //
00100          struct _listEntry                   *updatesNeg;      // list of priority < 0
00101          struct _listEntry                   *updates0;                 // list priority == 0
00102          struct _listEntry                   *updatesPos;      // list priority > 0
00103          struct _hashUpdateEntry             *hashForUpdates;  // hash used to fetch quickly the list entries for pause,delete,etc.
00104                   
00105          // Used for "selectors with interval"
00106          struct _hashSelectorEntry  *hashForSelectors;
00107          struct _hashSelectorEntry  *currentTarget;
00108          BOOL                                                  currentTargetSalvaged;
00109          
00110          // Optimization
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

Generated on Tue Jan 25 2011 13:01:43 for Unofficial Cocos2D for iOS 0.99.5 API Reference by  doxygen 1.7.1