|
1 | 1 | #import "TestBase.h"
|
| 2 | +#import "CCTextureCache.h" |
2 | 3 |
|
3 | 4 | @interface CCRendererTest : TestBase @end
|
4 | 5 | @implementation CCRendererTest
|
5 | 6 |
|
| 7 | +- (void)setupMotionStreakNodeTest |
| 8 | +{ |
| 9 | + self.subTitle = @"Testing CCMotionStreak"; |
| 10 | + |
| 11 | + CCNode *stage = [CCNode node]; |
| 12 | + stage.anchorPoint = ccp(0.5, 0.5); |
| 13 | + stage.positionType = CCPositionTypeNormalized; |
| 14 | + stage.position = ccp(0.5, 0.5); |
| 15 | + stage.contentSizeType = CCSizeTypeNormalized; |
| 16 | + stage.contentSize = CGSizeMake(0.75, 0.75); |
| 17 | + [self.contentNode addChild:stage]; |
| 18 | + |
| 19 | + // Maybe want to find a better texture than a random tile graphic? |
| 20 | + { |
| 21 | + CCMotionStreak *streak = [CCMotionStreak streakWithFade:15.0 minSeg:5 width:3 color:[CCColor whiteColor] textureFilename:@"Tiles/05.png"]; |
| 22 | + [stage addChild:streak]; |
| 23 | + |
| 24 | + [streak scheduleBlock:^(CCTimer *timer) { |
| 25 | + CCTime t = timer.invokeTime; |
| 26 | + CGSize size = stage.contentSizeInPoints; |
| 27 | + |
| 28 | + streak.position = ccp(size.width*(0.5 + 0.5*sin(3.1*t)), size.height*(0.5 + 0.5*cos(4.3*t))); |
| 29 | + |
| 30 | + [timer repeatOnceWithInterval:0.01]; |
| 31 | + } delay:0.0]; |
| 32 | + }{ |
| 33 | + CCMotionStreak *streak = [CCMotionStreak streakWithFade:0.5 minSeg:5 width:3 color:[CCColor redColor] textureFilename:@"Tiles/05.png"]; |
| 34 | + [stage addChild:streak]; |
| 35 | + |
| 36 | + [streak scheduleBlock:^(CCTimer *timer) { |
| 37 | + CCTime t = timer.invokeTime; |
| 38 | + CGSize size = stage.contentSizeInPoints; |
| 39 | + |
| 40 | + streak.position = ccp(size.width*(0.5 + 0.5*sin(1.6*t)), size.height*(0.5 + 0.5*cos(5.1*t))); |
| 41 | + |
| 42 | + [timer repeatOnceWithInterval:0.01]; |
| 43 | + } delay:0.0]; |
| 44 | + } |
| 45 | +} |
| 46 | + |
6 | 47 | - (void)setupProgressNodeTest
|
7 | 48 | {
|
| 49 | + self.subTitle = @"Testing various CCProgressNode setups."; |
| 50 | + |
8 | 51 | // Radial timer
|
9 | 52 | {
|
10 | 53 | NSString *image = @"Tiles/05.png";
|
@@ -158,10 +201,64 @@ - (void)setupProgressNodeTest
|
158 | 201 | [timer repeatOnceWithInterval:interval];
|
159 | 202 | } delay:interval];
|
160 | 203 | }
|
| 204 | + |
| 205 | + { |
| 206 | + NSString *image = @"Tiles/05.png"; |
| 207 | + CGPoint position = ccp(0.4, 0.25); |
| 208 | + CCTime interval = 1.0/60.0; |
| 209 | + |
| 210 | + CCSprite *sprite = [CCSprite spriteWithImageNamed:image]; |
| 211 | + sprite.positionType = CCPositionTypeNormalized; |
| 212 | + sprite.position = position; |
| 213 | + sprite.color = [CCColor grayColor]; |
| 214 | + [self.contentNode addChild:sprite]; |
| 215 | + |
| 216 | + CCProgressNode *progress = [CCProgressNode progressWithSprite:[CCSprite spriteWithImageNamed:image]]; |
| 217 | + progress.type = CCProgressNodeTypeBar; |
| 218 | + progress.midpoint = ccp(0.5, 0.5); |
| 219 | + progress.barChangeRate = ccp(1, 1); |
| 220 | + progress.positionType = CCPositionTypeNormalized; |
| 221 | + progress.position = position; |
| 222 | + [self.contentNode addChild:progress]; |
| 223 | + |
| 224 | + [self scheduleBlock:^(CCTimer *timer) { |
| 225 | + progress.percentage = 100.0*(0.5 + 0.5*sin(timer.invokeTime*M_PI)); |
| 226 | + |
| 227 | + [timer repeatOnceWithInterval:interval]; |
| 228 | + } delay:interval]; |
| 229 | + } |
| 230 | + |
| 231 | + { |
| 232 | + NSString *image = @"Tiles/05.png"; |
| 233 | + CGPoint position = ccp(0.4, 0.5); |
| 234 | + CCTime interval = 1.0/60.0; |
| 235 | + |
| 236 | + CCSprite *sprite = [CCSprite spriteWithImageNamed:image]; |
| 237 | + sprite.positionType = CCPositionTypeNormalized; |
| 238 | + sprite.position = position; |
| 239 | + sprite.color = [CCColor grayColor]; |
| 240 | + [self.contentNode addChild:sprite]; |
| 241 | + |
| 242 | + CCProgressNode *progress = [CCProgressNode progressWithSprite:[CCSprite spriteWithImageNamed:image]]; |
| 243 | + progress.type = CCProgressNodeTypeBar; |
| 244 | + progress.midpoint = ccp(0.5, 0.5); |
| 245 | + progress.barChangeRate = ccp(0, 0); |
| 246 | + progress.positionType = CCPositionTypeNormalized; |
| 247 | + progress.position = position; |
| 248 | + [self.contentNode addChild:progress]; |
| 249 | + |
| 250 | + [self scheduleBlock:^(CCTimer *timer) { |
| 251 | + progress.percentage = 100.0*(0.5 + 0.5*sin(timer.invokeTime*M_PI)); |
| 252 | + |
| 253 | + [timer repeatOnceWithInterval:interval]; |
| 254 | + } delay:interval]; |
| 255 | + } |
161 | 256 | }
|
162 | 257 |
|
163 | 258 | - (void)setupDrawNodeTest
|
164 | 259 | {
|
| 260 | + self.subTitle = @"Testing CCDrawNode"; |
| 261 | + |
165 | 262 | CCDrawNode *draw = [CCDrawNode node];
|
166 | 263 |
|
167 | 264 | [draw drawDot:ccp(100, 100) radius:50 color:[CCColor redColor]];
|
|
0 commit comments