Skip to content

Commit b2d9054

Browse files
committed
Added files to template demo
1 parent 3da0dbf commit b2d9054

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1052
-100
lines changed

cocos2d.xcodeproj/project.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

templates/cocos2d iOS demo.xctemplate/Classes/GameObject.h

Lines changed: 0 additions & 31 deletions
This file was deleted.

templates/cocos2d iOS demo.xctemplate/Classes/GameObject.m

Lines changed: 0 additions & 42 deletions
This file was deleted.

templates/cocos2d iOS demo.xctemplate/Classes/Paddle.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#import <Foundation/Foundation.h>
1414
#import "cocos2d.h"
1515
#import "GameTypes.h"
16-
#import "GameObject.h"
1716

1817
// -----------------------------------------------------------------
1918

@@ -26,7 +25,7 @@ typedef NS_ENUM(NSUInteger, PaddleSide)
2625

2726
// -----------------------------------------------------------------
2827

29-
@interface Paddle : GameObject
28+
@interface Paddle : CCSprite
3029

3130
// -----------------------------------------------------------------
3231

templates/cocos2d iOS demo.xctemplate/Classes/gameScene.m

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,14 @@
1414
#import "cocos2d-ui.h"
1515

1616
#import "Paddle.h"
17-
#import "GameObject.h"
1817

1918
// -----------------------------------------------------------------
2019

2120
@implementation GameScene
2221
{
2322
Paddle *_paddleA;
2423
Paddle *_paddleB;
25-
GameObject *_ball;
24+
CCSprite *_ball;
2625
CGSize _gameSize;
2726
CGPoint _ballVector;
2827
}
@@ -42,7 +41,7 @@ - (instancetype)init
4241
_paddleB = [Paddle paddleWithSide:PaddleSideRight];
4342
[self addChild:_paddleB];
4443

45-
_ball = [GameObject gameObjectWithImageNamed:@"ball.png"];
44+
_ball = [CCSprite spriteWithImageNamed:@"ball.png"];
4645
[self addChild:_ball];
4746

4847
// create a way out of this ...
@@ -178,7 +177,7 @@ - (void)update:(CCTime)delta
178177
_ball.position = ccpAdd(_ball.position, ccpMult(_ballVector, delta));
179178

180179
// check for paddle-ball collisions
181-
if (CGRectIntersectsRect(_paddleA.rect, _ball.rect))
180+
if (CGRectIntersectsRect(_paddleA.boundingBox, _ball.boundingBox))
182181
{
183182
// da beep
184183
[[OALSimpleAudio sharedInstance] playEffect:@"beep.wav"];
@@ -195,7 +194,7 @@ - (void)update:(CCTime)delta
195194
// adjust vector
196195
_ballVector = ccpRotateByAngle(_ballVector, CGPointZero, spin * M_PI / 180);
197196
}
198-
else if (CGRectIntersectsRect(_paddleB.rect, _ball.rect))
197+
else if (CGRectIntersectsRect(_paddleB.boundingBox, _ball.boundingBox))
199198
{
200199
// da beep
201200
[[OALSimpleAudio sharedInstance] playEffect:@"beep.wav"];

0 commit comments

Comments
 (0)