Skip to content

Commit 3e9dc2c

Browse files
committed
Merge branch 'develop-v3' of https://github.com/apportable/cocos2d-iphone into develop-v3
Former-commit-id: 2a8226f
2 parents a38af81 + 6b6a4ba commit 3e9dc2c

File tree

10 files changed

+328
-36
lines changed

10 files changed

+328
-36
lines changed

AUTHORS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ People and companies, who have contributed, in alphabetical order.
3939
Apportable integration
4040

4141
* Scott Lembcke
42-
Co-author of chipmunk (http://howlingmoonsoftware.com/index.php)
42+
Co-author of Chipmunk2D (http://chipmunk2d.net)
4343
CCPhysics
4444
Being the unstopable force
4545
An incredible number of contributions and suggestions
@@ -51,7 +51,7 @@ People and companies, who have contributed, in alphabetical order.
5151
Countless other contributions
5252

5353
Thanks to Wangsheng, Shintaro Kaneko, frranck and Yannick Loriot, for various minor contributions.
54-
Also thanks to those who contributed on git, and took part in the discussions (Ben-G mentioned, but no-one forgotten) even if their suggestions didnt make it to release.
54+
Also thanks to those who contributed on git, and took part in the discussions (Ben-G mentioned, but no-one forgotten) even if their suggestions didn't make it to release.
5555

5656
cocos2d for iPhone 2.1 authors
5757
------------------------------
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
40af2ecdcbc1edb7178d4fff03c6c62e439fee8a
1+
11bc1d4cdb4f251665a23432b31a4395f2e92a41

cocos2d-ui/CCTextField.m

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,13 @@
2424

2525
#import "CCTextField.h"
2626
#import "CCControlSubclass.h"
27+
#import "CCDirector_Private.h"
2728

28-
@implementation CCTextField
29+
@implementation CCTextField {
30+
#if defined(APPORTABLE)
31+
BOOL _textFieldIsEditing;
32+
#endif
33+
}
2934

3035
+ (id) textFieldWithSpriteFrame:(CCSpriteFrame *)frame
3136
{
@@ -189,6 +194,10 @@ - (void) layout
189194
#ifdef __CC_PLATFORM_IOS
190195
- (void)textFieldDidBeginEditing:(UITextField *)textField
191196
{
197+
#if defined(APPORTABLE)
198+
_textFieldIsEditing = YES;
199+
#endif
200+
192201
if (_keyboardIsShown)
193202
{
194203
[self focusOnTextField];
@@ -197,6 +206,9 @@ - (void)textFieldDidBeginEditing:(UITextField *)textField
197206

198207
- (void)textFieldDidEndEditing:(UITextField *)textField
199208
{
209+
#if defined(APPORTABLE)
210+
_textFieldIsEditing = NO;
211+
#endif
200212
[self endFocusingOnTextField];
201213
}
202214

@@ -256,7 +268,13 @@ - (void)keyboardWasShown:(NSNotification*)notification
256268

257269
_keyboardHeight = kbSize.height;
258270

259-
if (_textField.isEditing)
271+
BOOL focusOnTextField = _textField.isEditing;
272+
273+
#if defined(APPORTABLE)
274+
focusOnTextField = _textFieldIsEditing;
275+
#endif
276+
277+
if (focusOnTextField)
260278
{
261279
[self focusOnTextField];
262280
}
@@ -275,11 +293,18 @@ - (void) keyboardWillBeHidden:(NSNotification*) notification
275293

276294
- (void) focusOnTextField
277295
{
296+
#if defined(APPORTABLE)
297+
// Ensure that all textfields have actually been positioned before checkings textField.frame property,
298+
// it's possible for the apportable keyboard notification to be fired before the mainloop has had a chance to kick of a scheduler update
299+
CCDirector *director = [CCDirector sharedDirector];
300+
[director.scheduler update:0.0];
301+
#endif
302+
278303
CGSize windowSize = [[CCDirector sharedDirector] viewSize];
279304

280305
// Find the location of the textField
281306
float fieldCenterY = _textField.frame.origin.y - (_textField.frame.size.height/2);
282-
307+
283308
// Upper third part of the screen
284309
float upperThirdHeight = windowSize.height / 3;
285310

@@ -290,8 +315,16 @@ - (void) focusOnTextField
290315
// Calculate offset
291316
float dstYLocation = windowSize.height / 4;
292317
float offset = -(fieldCenterY - dstYLocation);
318+
293319
if (offset < -_keyboardHeight) offset = -_keyboardHeight;
294320

321+
#if defined(APPORTABLE)
322+
// Apportable does not support changing the openglview position, so we will just change the current scenes position instead
323+
CCScene *runningScene = [[CCDirector sharedDirector] runningScene];
324+
CGPoint newPosition = runningScene.position;
325+
newPosition.y = (offset * -1);
326+
runningScene.position = newPosition;
327+
#else
295328
// Calcualte target frame
296329
UIView* view = [[CCDirector sharedDirector] view];
297330
CGRect frame = view.frame;
@@ -303,16 +336,23 @@ - (void) focusOnTextField
303336
[UIView setAnimationDuration: 0.2f];
304337

305338
view.frame = frame;
306-
307339
[UIView commitAnimations];
340+
#endif
308341
}
309342
}
310343

311344
- (void) endFocusingOnTextField
312345
{
313-
UIView* view = [[CCDirector sharedDirector] view];
314-
315346
// Slide the main view back down
347+
348+
#if defined(APPORTABLE)
349+
// Apportable does not support changing the openglview position, so we will just change the current scenes position instead
350+
CCScene *runningScene = [[CCDirector sharedDirector] runningScene];
351+
CGPoint newPosition = CGPointZero;
352+
newPosition.y = 0.0f;
353+
runningScene.position = newPosition;
354+
#else
355+
UIView* view = [[CCDirector sharedDirector] view];
316356
[UIView beginAnimations: @"textFieldAnim" context: nil];
317357
[UIView setAnimationBeginsFromCurrentState: YES];
318358
[UIView setAnimationDuration: 0.2f];
@@ -322,6 +362,8 @@ - (void) endFocusingOnTextField
322362
view.frame = frame;
323363

324364
[UIView commitAnimations];
365+
#endif
366+
325367
}
326368

327369
#endif

cocos2d.xcworkspace/xcshareddata/cocos2d.xccheckout

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,46 +5,46 @@
55
<key>IDESourceControlProjectFavoriteDictionaryKey</key>
66
<false/>
77
<key>IDESourceControlProjectIdentifier</key>
8-
<string>BAB2EF7E-733F-4AA6-AF6F-DC4E801C55EE</string>
8+
<string>A65B7BE5-B206-48B3-B33B-3563050F370A</string>
99
<key>IDESourceControlProjectName</key>
1010
<string>cocos2d</string>
1111
<key>IDESourceControlProjectOriginsDictionary</key>
1212
<dict>
13-
<key>DFBFA92A-FF14-4180-9A6E-807312C9A80A</key>
14-
<string>https://github.com/slembcke/Chipmunk2D.git</string>
15-
<key>FE1DDE1C-A6E5-4F8B-B7BE-96022811DCBE</key>
16-
<string>https://github.com/cocos2d/cocos2d-iphone.git</string>
13+
<key>625E0235-0E1B-4490-9002-129C7865DDEE</key>
14+
<string>github:cocos2d/cocos2d-iphone.git</string>
15+
<key>E2E4EF31-484E-410D-BA9A-5DA0CD3BD5CD</key>
16+
<string>ssh://github.com/slembcke/Chipmunk2D.git</string>
1717
</dict>
1818
<key>IDESourceControlProjectPath</key>
1919
<string>cocos2d.xcworkspace</string>
2020
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
2121
<dict>
22-
<key>DFBFA92A-FF14-4180-9A6E-807312C9A80A</key>
23-
<string>../external/Chipmunk</string>
24-
<key>FE1DDE1C-A6E5-4F8B-B7BE-96022811DCBE</key>
22+
<key>625E0235-0E1B-4490-9002-129C7865DDEE</key>
2523
<string>..</string>
24+
<key>E2E4EF31-484E-410D-BA9A-5DA0CD3BD5CD</key>
25+
<string>../external/Chipmunk</string>
2626
</dict>
2727
<key>IDESourceControlProjectURL</key>
28-
<string>https://github.com/cocos2d/cocos2d-iphone.git</string>
28+
<string>github:cocos2d/cocos2d-iphone.git</string>
2929
<key>IDESourceControlProjectVersion</key>
3030
<integer>110</integer>
3131
<key>IDESourceControlProjectWCCIdentifier</key>
32-
<string>FE1DDE1C-A6E5-4F8B-B7BE-96022811DCBE</string>
32+
<string>625E0235-0E1B-4490-9002-129C7865DDEE</string>
3333
<key>IDESourceControlProjectWCConfigurations</key>
3434
<array>
3535
<dict>
3636
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
3737
<string>public.vcs.git</string>
3838
<key>IDESourceControlWCCIdentifierKey</key>
39-
<string>DFBFA92A-FF14-4180-9A6E-807312C9A80A</string>
39+
<string>E2E4EF31-484E-410D-BA9A-5DA0CD3BD5CD</string>
4040
<key>IDESourceControlWCCName</key>
4141
<string>Chipmunk</string>
4242
</dict>
4343
<dict>
4444
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
4545
<string>public.vcs.git</string>
4646
<key>IDESourceControlWCCIdentifierKey</key>
47-
<string>FE1DDE1C-A6E5-4F8B-B7BE-96022811DCBE</string>
47+
<string>625E0235-0E1B-4490-9002-129C7865DDEE</string>
4848
<key>IDESourceControlWCCName</key>
4949
<string>cocos2d-iphone</string>
5050
</dict>

cocos2d/CCNode.m

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,12 @@ -(float) rotation
242242
}
243243

244244
-(float)rotationalSkewX {
245-
return _rotationalSkewX;
245+
CCPhysicsBody *body = GetBodyIfRunning(self);
246+
if(body){
247+
return -CC_RADIANS_TO_DEGREES(body.absoluteRadians) + NodeToPhysicsRotation(self.parent);
248+
} else {
249+
return _rotationalSkewX;
250+
}
246251
}
247252

248253
-(void) setRotationalSkewX: (float)newX
@@ -255,7 +260,12 @@ -(void) setRotationalSkewX: (float)newX
255260

256261
-(float)rotationalSkewY
257262
{
258-
return _rotationalSkewY;
263+
CCPhysicsBody *body = GetBodyIfRunning(self);
264+
if(body){
265+
return -CC_RADIANS_TO_DEGREES(body.absoluteRadians) + NodeToPhysicsRotation(self.parent);
266+
} else {
267+
return _rotationalSkewY;
268+
}
259269
}
260270

261271
-(void) setRotationalSkewY: (float)newY

cocos2d/Platforms/iOS/CCAppDelegate.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
#import "kazmath/kazmath.h"
3636
#import "kazmath/GL/matrix.h"
3737

38+
#import "OALSimpleAudio.h"
39+
3840
NSString* const CCSetupPixelFormat = @"CCSetupPixelFormat";
3941
NSString* const CCSetupScreenMode = @"CCSetupScreenMode";
4042
NSString* const CCSetupScreenOrientation = @"CCSetupScreenOrientation";
@@ -242,6 +244,9 @@ - (void) setupCocos2dWithOptions:(NSDictionary*)config
242244
// It can be RGBA8888, RGBA4444, RGB5_A1, RGB565
243245
// You can change this setting at any time.
244246
[CCTexture setDefaultAlphaPixelFormat:CCTexturePixelFormat_RGBA8888];
247+
248+
// Initialise OpenAL
249+
[OALSimpleAudio sharedInstance];
245250

246251
// Create a Navigation Controller with the Director
247252
navController_ = [[CCNavigationController alloc] initWithRootViewController:director];

0 commit comments

Comments
 (0)