cocos2d for iPhone 1.0.0
2D engine for iOS and OS X
/Users/rquesada/progs/cocos2d-iphone/cocos2d/CCScheduler.h
00001 /*
00002  * cocos2d for iPhone: http://www.cocos2d-iphone.org
00003  *
00004  * Copyright (c) 2008-2010 Ricardo Quesada
00005  * Copyright (c) 2011 Zynga Inc.
00006  * 
00007  * Permission is hereby granted, free of charge, to any person obtaining a copy
00008  * of this software and associated documentation files (the "Software"), to deal
00009  * in the Software without restriction, including without limitation the rights
00010  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00011  * copies of the Software, and to permit persons to whom the Software is
00012  * furnished to do so, subject to the following conditions:
00013  * 
00014  * The above copyright notice and this permission notice shall be included in
00015  * all copies or substantial portions of the Software.
00016  * 
00017  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00018  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00019  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00020  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00021  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00022  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00023  * THE SOFTWARE.
00024  */
00025 
00026 
00027 
00028 #import "Support/uthash.h"
00029 #import "ccTypes.h"
00030 
00031 typedef void (*TICK_IMP)(id, SEL, ccTime);
00032 
00033 //
00034 // CCTimer
00035 //
00037 @interface CCTimer : NSObject
00038 {
00039         id target;
00040         TICK_IMP impMethod;
00041         
00042         ccTime elapsed;
00043 
00044 @public                                 // optimization
00045         ccTime interval;
00046         SEL selector;
00047 }
00048 
00050 @property (nonatomic,readwrite,assign) ccTime interval;
00051 
00054 +(id) timerWithTarget:(id) t selector:(SEL)s;
00055 
00058 +(id) timerWithTarget:(id) t selector:(SEL)s interval:(ccTime)seconds;
00059 
00062  -(id) initWithTarget:(id) t selector:(SEL)s;
00063 
00066 -(id) initWithTarget:(id) t selector:(SEL)s interval:(ccTime)seconds;
00067 
00068 
00070 -(void) update: (ccTime) dt;
00071 @end
00072 
00073 
00074 
00075 //
00076 // CCScheduler
00077 //
00090 struct _listEntry;
00091 struct _hashSelectorEntry;
00092 struct _hashUpdateEntry;
00093 
00094 @interface CCScheduler : NSObject
00095 {       
00096         ccTime                          timeScale_;
00097         
00098         //
00099         // "updates with priority" stuff
00100         //
00101         struct _listEntry                       *updatesNeg;    // list of priority < 0
00102         struct _listEntry                       *updates0;              // list priority == 0
00103         struct _listEntry                       *updatesPos;    // list priority > 0
00104         struct _hashUpdateEntry         *hashForUpdates;        // hash used to fetch quickly the list entries for pause,delete,etc.
00105                 
00106         // Used for "selectors with interval"
00107         struct _hashSelectorEntry       *hashForSelectors;
00108         struct _hashSelectorEntry       *currentTarget;
00109         BOOL                                            currentTargetSalvaged;
00110         
00111         // Optimization
00112         TICK_IMP                        impMethod;
00113         SEL                                     updateSelector;
00114     
00115     BOOL updateHashLocked; // If true unschedule will not remove anything from a hash. Elements will only be marked for deletion.
00116 }
00117 
00125 @property (nonatomic,readwrite) ccTime  timeScale;
00126 
00128 +(CCScheduler *)sharedScheduler;
00129 
00133 +(void)purgeSharedScheduler;
00134 
00138 -(void) tick:(ccTime)dt;
00139 
00147 -(void) scheduleSelector:(SEL)selector forTarget:(id)target interval:(ccTime)interval paused:(BOOL)paused;
00148 
00154 -(void) scheduleUpdateForTarget:(id)target priority:(NSInteger)priority paused:(BOOL)paused;
00155 
00160 -(void) unscheduleSelector:(SEL)selector forTarget:(id)target;
00161 
00165 -(void) unscheduleUpdateForTarget:(id)target;
00166 
00171 -(void) unscheduleAllSelectorsForTarget:(id)target;
00172 
00178 -(void) unscheduleAllSelectors;
00179 
00185 -(void) pauseTarget:(id)target;
00186 
00192 -(void) resumeTarget:(id)target;
00193 
00197 -(BOOL) isTargetPaused:(id)target;
00198 
00199 @end
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Defines

cocos2d for iPhone API Reference - Generated using Doxygen 1.7.4