Skip to content

Commit c5a9fd7

Browse files
committed
Merge branch 'v3.2' into develop
Conflicts: external/ObjectAL
2 parents 49b401b + 426c593 commit c5a9fd7

File tree

5 files changed

+48
-6
lines changed

5 files changed

+48
-6
lines changed

cocos2d-ui-tests/tests/CCBMFontTest.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
static NSString *TEST_STRINGS[] = {
1313
@"ABCDEFGHIJKLM\nNOPQRSTUVWXYZ",
1414
@"abcdefghijklm\nnopqrstuvwxyz",
15+
@"first line\u2028second line",
1516
@",.?!;:'\"",
1617
@"()[]{}<>\\|/\n",
1718
@"@#$%^&*+-=_",

cocos2d/CCLabelBMFont.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ -(void) createFontChars
762762
// since the Y position needs to be calcualted before hand
763763
for(NSUInteger i=0; i < stringLen-1;i++) {
764764
unichar c = [_string characterAtIndex:i];
765-
if( c=='\n')
765+
if([[NSCharacterSet newlineCharacterSet] characterIsMember:c])
766766
quantityOfLines++;
767767
}
768768

@@ -776,7 +776,7 @@ -(void) createFontChars
776776
for(NSUInteger i = 0; i<stringLen; i++) {
777777
unichar c = [_string characterAtIndex:i];
778778

779-
if (c == '\n') {
779+
if ([[NSCharacterSet newlineCharacterSet] characterIsMember:c]) {
780780
nextFontPositionX = 0;
781781
nextFontPositionY -= _configuration->_commonHeight;
782782
continue;

cocos2d/CCNode.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,17 @@ A common user pattern in building a Cocos2d game is to subclass CCNode, add it t
531531
*
532532
* @return A newly initialized CCTimer object.
533533
*/
534+
535+
/**
536+
* Schedules a custom selector with an interval time in seconds.
537+
* If the custom selector you pass in is not already scheduled, this method simply schedules it for the first time.
538+
* The difference between this method and the schedule:interval: method is that if the selector passed in this method is already scheduled, calling this method will only adjust the interval on the already scheduled method. In contrast, when you call schedule:interval: on an already scheduled selector, your custom selector will be unscheduled and then rescheduled.
539+
* @param selector Selector to execute.
540+
* @param interval Interval between execution in seconds.
541+
*/
542+
-(CCTimer*)reschedule:(SEL)selector interval:(CCTime)interval;
543+
544+
534545
- (CCTimer *) scheduleOnce:(SEL) selector delay:(CCTime) delay;
535546

536547
/**

cocos2d/CCNode.m

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,6 +1184,32 @@ -(CCTimer *) schedule:(SEL)selector interval:(CCTime)interval
11841184
return [self schedule:selector interval:interval repeat:CCTimerRepeatForever delay:interval];
11851185
}
11861186

1187+
-(CCTimer*)reschedule:(SEL)selector interval:(CCTime)interval
1188+
{
1189+
NSString *selectorName = NSStringFromSelector(selector);
1190+
1191+
CCTimer *currentTimerForSelector = nil;
1192+
1193+
for (CCTimer *timer in [_scheduler timersForTarget:self])
1194+
{
1195+
if([selectorName isEqual:timer.userData])
1196+
{
1197+
CCLOG(@"%@ was already scheduled on %@. Updating interval from %f to %f",NSStringFromSelector(selector),self,timer.repeatInterval,interval);
1198+
timer.repeatInterval = interval;
1199+
currentTimerForSelector = timer;
1200+
break;
1201+
}
1202+
}
1203+
1204+
if (currentTimerForSelector == nil)
1205+
{
1206+
CCLOG(@"%@ was never scheduled. Scheduling for the first time.",selectorName);
1207+
currentTimerForSelector = [self schedule:selector interval:interval];
1208+
}
1209+
1210+
return currentTimerForSelector;
1211+
}
1212+
11871213
-(BOOL)unschedule_private:(SEL)selector
11881214
{
11891215
NSString *selectorName = NSStringFromSelector(selector);

cocos2d/Platforms/iOS/CCAppDelegate.m

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,28 +266,32 @@ - (void) setupCocos2dWithOptions:(NSDictionary*)config
266266
// getting a call, pause the game
267267
-(void) applicationWillResignActive:(UIApplication *)application
268268
{
269-
if( [navController_ visibleViewController] == [CCDirector sharedDirector] )
269+
if([CCDirector sharedDirector].paused == NO) {
270270
[[CCDirector sharedDirector] pause];
271+
}
271272
}
272273

273274
// call got rejected
274275
-(void) applicationDidBecomeActive:(UIApplication *)application
275276
{
276277
[[CCDirector sharedDirector] setNextDeltaTimeZero:YES];
277-
if( [navController_ visibleViewController] == [CCDirector sharedDirector] )
278+
if([CCDirector sharedDirector].paused) {
278279
[[CCDirector sharedDirector] resume];
280+
}
279281
}
280282

281283
-(void) applicationDidEnterBackground:(UIApplication*)application
282284
{
283-
if( [navController_ visibleViewController] == [CCDirector sharedDirector] )
285+
if([CCDirector sharedDirector].animating) {
284286
[[CCDirector sharedDirector] stopAnimation];
287+
}
285288
}
286289

287290
-(void) applicationWillEnterForeground:(UIApplication*)application
288291
{
289-
if( [navController_ visibleViewController] == [CCDirector sharedDirector] )
292+
if([CCDirector sharedDirector].animating == NO) {
290293
[[CCDirector sharedDirector] startAnimation];
294+
}
291295
}
292296

293297
// application will be killed

0 commit comments

Comments
 (0)