Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/gles20' into gles20
Browse files Browse the repository at this point in the history
  • Loading branch information
Lam Pham committed Feb 10, 2012
2 parents 2ab735a + c3c802a commit 794e913
Show file tree
Hide file tree
Showing 9 changed files with 230 additions and 4 deletions.
3 changes: 3 additions & 0 deletions AUTHORS
Expand Up @@ -44,6 +44,9 @@ People/companies who were/are contributing code to cocos2d for iPhone (alphabeti
CCGLProgram: fixes in fragmentShaderLog
CCShaderCache: Added addProgram:forKey: method
CCArray: Fixed copyWithZone

* Karl Stenerud (http://www.mindsnacks.com/):
Author of ActionTargeted

* manucorporat (manu.valladolid) (http://forzefield.com/):
Author of new Retina Display code:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG
Expand Up @@ -5,6 +5,7 @@ version 2.0-rc0 XX-Feb-2012
Sprite: fixed possible setColor and opacity
TileMap: Flipped tiles can be changed during runtime (issue #1264)
TileMap: Fixed a problem with multiple layers and multiple tile sets that could cause TMX maps to not load if rotation is used (issue #1302)
. [NEW] Actions: Added ActionTargeted action. Useful to target other nodes from a sequence.
. [NEW] Animation: Added new animation format that supports delays per frame and notifications per frame
. [NEW] Director: When the stats are on, the number of GL draw calls per frame are displayed
Added support for main-thread director (Mac only. Needed for some editors)
Expand Down
112 changes: 112 additions & 0 deletions cocos2d-ios.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions cocos2d/CCActionInterval.h
Expand Up @@ -423,3 +423,22 @@ typedef struct _ccBezierConfig {
*/
-(id) initWithDuration:(ccTime)duration animation:(CCAnimation*)animation restoreOriginalFrame:(BOOL)restoreOriginalFrame;
@end

/** Overrides the target of an action so that it always runs on the target
* specified at action creation rather than the one specified by runAction.
*/
@interface CCTargetedAction : CCActionInterval <NSCopying>
{
id forcedTarget_;
CCFiniteTimeAction* action_;
}
/** This is the target that the action will be forced to run with */
@property(readwrite,nonatomic,retain) id forcedTarget;

/** Create an action with the specified action and forced target */
+ (id) actionWithTarget:(id) target action:(CCFiniteTimeAction*) action;

/** Init an action with the specified action and forced target */
- (id) initWithTarget:(id) target action:(CCFiniteTimeAction*) action;

@end
56 changes: 56 additions & 0 deletions cocos2d/CCActionInterval.m
Expand Up @@ -1364,5 +1364,61 @@ - (CCActionInterval *) reverse
CCAnimation *newAnim = [CCAnimation animationWithFrames:newArray delayPerUnit:animation_.delayPerUnit];
return [[self class] actionWithDuration:duration_ animation:newAnim restoreOriginalFrame:restoreOriginalFrame_];
}
@end


@implementation CCTargetedAction

@synthesize forcedTarget = forcedTarget_;

+ (id) actionWithTarget:(id) target action:(CCFiniteTimeAction*) action
{
return [[ (CCTargetedAction*)[self alloc] initWithTarget:target action:action] autorelease];
}

- (id) initWithTarget:(id) targetIn action:(CCFiniteTimeAction*) actionIn
{
if((self = [super initWithDuration:actionIn.duration]))
{
forcedTarget_ = [targetIn retain];
action_ = [actionIn retain];
}
return self;
}

-(id) copyWithZone: (NSZone*) zone
{
CCAction *copy = [ (CCTargetedAction*) [[self class] allocWithZone: zone] initWithTarget:target_ action:[[action_ copy] autorelease]];
return copy;
}

- (void) dealloc
{
[forcedTarget_ release];
[action_ release];
[super dealloc];
}

//- (void) updateDuration:(id)aTarget
//{
// [action updateDuration:forcedTarget];
// duration_ = action.duration;
//}

- (void) startWithTarget:(id)aTarget
{
[super startWithTarget:forcedTarget_];
[action_ startWithTarget:forcedTarget_];
}

- (void) stop
{
[action_ stop];
}

- (void) update:(ccTime) time
{
[action_ update:time];
}

@end
2 changes: 1 addition & 1 deletion cocos2d/CCTextureAtlas.m
Expand Up @@ -542,4 +542,4 @@ -(void) drawNumberOfQuads: (NSUInteger) n fromIndex: (NSUInteger) start

CHECK_GL_ERROR_DEBUG();
}
@end
@end
2 changes: 1 addition & 1 deletion cocos2d/ccMacros.h
Expand Up @@ -339,4 +339,4 @@ extern NSUInteger __ccNumberOfDraws;
/** @def CCAnimationFrameDisplayedNotification
Notification name when a CCSpriteFrame is displayed
*/
#define CCAnimationFrameDisplayedNotification @"CCAnimationFrameDisplayedNotification"
#define CCAnimationFrameDisplayedNotification @"CCAnimationFrameDisplayedNotification"
4 changes: 4 additions & 0 deletions tests/ActionsTest.h
Expand Up @@ -138,4 +138,8 @@
{}
@end

@interface ActionTargeted : ActionDemo
{}
@end


35 changes: 33 additions & 2 deletions tests/ActionsTest.m
Expand Up @@ -19,8 +19,6 @@
static int sceneIdx=-1;
static NSString *transitions[] = {

@"ActionAnimate",

@"ActionManual",
@"ActionMove",
@"ActionRotate",
Expand Down Expand Up @@ -50,6 +48,7 @@
@"ActionOrbit",
@"ActionFollow",
@"ActionProperty",
@"ActionTargeted",
};

Class nextAction()
Expand Down Expand Up @@ -1138,6 +1137,38 @@ -(NSString*) subtitle

@end

@implementation ActionTargeted
-(void) onEnter
{
[super onEnter];

[self centerSprites:2];

CCJumpBy *jump1 = [CCJumpBy actionWithDuration:2 position:CGPointZero height:100 jumps:3];
CCJumpBy *jump2 = [[jump1 copy] autorelease];
CCRotateBy *rot1 = [CCRotateBy actionWithDuration:1 angle:360];
CCRotateBy *rot2 = [[rot1 copy] autorelease];

CCTargetedAction *t1 = [CCTargetedAction actionWithTarget:kathia action:jump2];
CCTargetedAction *t2 = [CCTargetedAction actionWithTarget:kathia action:rot2];


CCSequence *seq = [CCSequence actions:jump1, t1, rot1, t2, nil];
CCRepeatForever *always = [CCRepeatForever actionWithAction:seq];

[tamara runAction:always];
}

-(NSString *) title
{
return @"ActionTargeted";
}

-(NSString*) subtitle
{
return @"Action that runs on another target. Useful for sequences";
}
@end


// CLASS IMPLEMENTATIONS
Expand Down

0 comments on commit 794e913

Please sign in to comment.