Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/touchableBlocks' into develop
- Loading branch information
Showing
14 changed files
with
364 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// | ||
// BlockCircle.h | ||
// TotemBalance | ||
// | ||
// Created by Raúl Uranga on 7/6/11. | ||
// Copyright 2011 GrupoW. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "cocos2d.h" | ||
#import "chipmunk.h" | ||
#import "TouchableBlock.h" | ||
|
||
@class TouchableBlock; | ||
|
||
|
||
@interface BlockCircle : TouchableBlock { | ||
|
||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// | ||
// BlockCircle.m | ||
// TotemBalance | ||
// | ||
// Created by Raúl Uranga on 7/6/11. | ||
// Copyright 2011 GrupoW. All rights reserved. | ||
// | ||
|
||
#import "BlockCircle.h" | ||
#import "GameScene.h" | ||
|
||
@implementation BlockCircle | ||
|
||
-(void) dealloc | ||
{ | ||
[super dealloc]; | ||
} | ||
|
||
-(id) initWithPosition: (CGPoint)pos theGame:(GameLayer *) game | ||
{ | ||
if ((self = [super init])) { | ||
self.theGame = game; | ||
[game addChild:self z:1]; | ||
|
||
mySprite = [CCSprite spriteWithFile:@"block_circ.png"]; | ||
[mySprite setPosition:pos]; | ||
|
||
[game addChild:mySprite z:1]; | ||
|
||
myBody = cpBodyNew(1.0f,cpMomentForCircle(1, 16, 16, CGPointZero)); | ||
myBody->p = pos; | ||
myBody->data = self; | ||
|
||
cpSpaceAddBody(game.space, myBody); | ||
|
||
myShape = cpCircleShapeNew(myBody, 16, CGPointZero); | ||
myShape->e = 0.5; | ||
myShape->u = 0.5; | ||
myShape->data = mySprite; | ||
myShape->collision_type = 3; | ||
|
||
cpSpaceAddShape(game.space, myShape); | ||
|
||
} | ||
|
||
return self; | ||
} | ||
|
||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// | ||
// BlockRectangle.h | ||
// TotemBalance | ||
// | ||
// Created by Raúl Uranga on 7/6/11. | ||
// Copyright 2011 GrupoW. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "cocos2d.h" | ||
#import "chipmunk.h" | ||
#import "TouchableBlock.h" | ||
|
||
@class TouchableBlock; | ||
|
||
@interface BlockRectangle : TouchableBlock { | ||
|
||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// | ||
// BlockRectangle.m | ||
// TotemBalance | ||
// | ||
// Created by Raúl Uranga on 7/6/11. | ||
// Copyright 2011 GrupoW. All rights reserved. | ||
// | ||
|
||
#import "BlockRectangle.h" | ||
#import "GameScene.h" | ||
|
||
@implementation BlockRectangle | ||
|
||
-(void) dealloc | ||
{ | ||
[super dealloc]; | ||
} | ||
|
||
-(id) initWithPosition: (CGPoint)pos theGame:(GameLayer *) game | ||
{ | ||
if ((self = [super init])) { | ||
self.theGame = game; | ||
[game addChild:self z:1]; | ||
|
||
mySprite = [CCSprite spriteWithFile:@"block_rect.png"]; | ||
[mySprite setPosition:pos]; | ||
|
||
[game addChild:mySprite z:1]; | ||
|
||
int num = 4; | ||
CGPoint verts[] = | ||
{ | ||
ccp(-33,-12), | ||
ccp(-33,12), | ||
ccp(33,12), | ||
ccp(33,-12), | ||
}; | ||
|
||
myBody = cpBodyNew(1.0f,cpMomentForPoly(1.0f, num, verts, CGPointZero)); | ||
myBody->p = pos; | ||
myBody->data = self; | ||
|
||
cpSpaceAddBody(game.space, myBody); | ||
|
||
myShape = cpPolyShapeNew(myBody, num, verts, CGPointZero); | ||
myShape->e = 0.5; | ||
myShape->u = 0.5; | ||
myShape->data = mySprite; | ||
myShape->collision_type = 3; | ||
|
||
cpSpaceAddShape(game.space, myShape); | ||
|
||
} | ||
|
||
return self; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// | ||
// BlockTriangle.h | ||
// TotemBalance | ||
// | ||
// Created by Raúl Uranga on 7/6/11. | ||
// Copyright 2011 GrupoW. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "cocos2d.h" | ||
#import "chipmunk.h" | ||
#import "TouchableBlock.h" | ||
|
||
@class TouchableBlock; | ||
|
||
|
||
@interface BlockTriangle : TouchableBlock { | ||
|
||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// | ||
// BlockTriangle.m | ||
// TotemBalance | ||
// | ||
// Created by Raúl Uranga on 7/6/11. | ||
// Copyright 2011 GrupoW. All rights reserved. | ||
// | ||
|
||
#import "BlockTriangle.h" | ||
#import "GameScene.h" | ||
|
||
@implementation BlockTriangle | ||
|
||
-(void) dealloc | ||
{ | ||
[super dealloc]; | ||
} | ||
|
||
-(id) initWithPosition: (CGPoint)pos theGame:(GameLayer *) game | ||
{ | ||
if ((self = [super init])) { | ||
self.theGame = game; | ||
[game addChild:self z:1]; | ||
|
||
mySprite = [CCSprite spriteWithFile:@"block_tri.png"]; | ||
[mySprite setPosition:pos]; | ||
|
||
[game addChild:mySprite z:1]; | ||
|
||
int num = 3; | ||
CGPoint verts[] = | ||
{ | ||
ccp(0,15), | ||
ccp(16,-15), | ||
ccp(-16,-15), | ||
}; | ||
|
||
myBody = cpBodyNew(1.0f,cpMomentForPoly(1.0f, num, verts, CGPointZero)); | ||
myBody->p = pos; | ||
myBody->data = self; | ||
|
||
cpSpaceAddBody(game.space, myBody); | ||
|
||
myShape = cpPolyShapeNew(myBody, num, verts, CGPointZero); | ||
myShape->e = 0.5; | ||
myShape->u = 0.5; | ||
myShape->data = mySprite; | ||
myShape->collision_type = 3; | ||
|
||
cpSpaceAddShape(game.space, myShape); | ||
|
||
} | ||
|
||
return self; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// TouchableBlock.h | ||
// TotemBalance | ||
// | ||
// Created by Raúl Uranga on 7/6/11. | ||
// Copyright 2011 GrupoW. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "cocos2d.h" | ||
#import "chipmunk.h" | ||
|
||
typedef enum tagState | ||
{ | ||
kStateGrabbed, | ||
kStateUngrabbed | ||
} touchState; | ||
|
||
@class GameLayer; | ||
|
||
@interface TouchableBlock : CCNode <CCTargetedTouchDelegate> { | ||
CCSprite *mySprite; | ||
cpBody *myBody; | ||
cpShape *myShape; | ||
GameLayer *theGame; | ||
touchState state; | ||
|
||
} | ||
|
||
@property (nonatomic, retain) CCSprite *mySprite; | ||
@property (nonatomic, retain) GameLayer *theGame; | ||
@property (nonatomic, readwrite) cpBody *myBody; | ||
@property (nonatomic, readwrite) cpShape *myShape; | ||
@property (nonatomic, readwrite) touchState state;; | ||
|
||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// TouchableBlock.m | ||
// TotemBalance | ||
// | ||
// Created by Raúl Uranga on 7/6/11. | ||
// Copyright 2011 GrupoW. All rights reserved. | ||
// | ||
|
||
#import "TouchableBlock.h" | ||
#import "GameScene.h" | ||
|
||
|
||
@implementation TouchableBlock | ||
|
||
@synthesize mySprite; | ||
@synthesize theGame; | ||
@synthesize myBody; | ||
@synthesize myShape; | ||
@synthesize state; | ||
|
||
-(void) dealloc | ||
{ | ||
[super dealloc]; | ||
} | ||
|
||
-(id) init | ||
{ | ||
if ((self=[super init])) { | ||
self.state = kStateUngrabbed; | ||
} | ||
return self; | ||
} | ||
|
||
@end |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.