+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (c) 2008-2010 Ricardo Quesada
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-
-#include <sys/time.h>
-#import <Foundation/Foundation.h>
-
-#import "ccTypes.h"
-
-enum {
- //! Default tag
- kCCActionTagInvalid = -1,
-};
-
-/** Base class for CCAction objects.
- */
-@interface CCAction : NSObject <NSCopying>
-{
- id originalTarget_;
- id target_;
- NSInteger tag_;
-}
-
-/** The "target". The action will modify the target properties.
- The target will be set with the 'startWithTarget' method.
- When the 'stop' method is called, target will be set to nil.
- The target is 'assigned', it is not 'retained'.
- */
-@property (nonatomic,readonly,assign) id target;
-
-/** The original target, since target can be nil.
- Is the target that were used to run the action. Unless you are doing something complex, like ActionManager, you should NOT call this method.
- @since v0.8.2
-*/
-@property (nonatomic,readonly,assign) id originalTarget;
-
-
-/** The action tag. An identifier of the action */
-@property (nonatomic,readwrite,assign) NSInteger tag;
-
-/** Allocates and initializes the action */
-+(id) action;
-
-/** Initializes the action */
--(id) init;
-
--(id) copyWithZone: (NSZone*) zone;
-
-//! return YES if the action has finished
--(BOOL) isDone;
-//! called before the action start. It will also set the target.
--(void) startWithTarget:(id)target;
-//! called after the action has finished. It will set the 'target' to nil.
-//! IMPORTANT: You should never call "[action stop]" manually. Instead, use: "[target stopAction:action];"
--(void) stop;
-//! called every frame with it's delta time. DON'T override unless you know what you are doing.
--(void) step: (ccTime) dt;
-//! called once per frame. time a value between 0 and 1
-//! For example:
-//! * 0 means that the action just started
-//! * 0.5 means that the action is in the middle
-//! * 1 means that the action is over
--(void) update: (ccTime) time;
-
-@end
-
-/** Base class actions that do have a finite time duration.
- Possible actions:
- - An action with a duration of 0 seconds
- - An action with a duration of 35.5 seconds
- Infitite time actions are valid
- */
-@interface CCFiniteTimeAction : CCAction <NSCopying>
-{
- //! duration in seconds
- ccTime duration_;
-}
-//! duration in seconds of the action
-@property (nonatomic,readwrite) ccTime duration;
-
-/** returns a reversed action */
-- (CCFiniteTimeAction*) reverse;
-@end
-
-
-@class CCActionInterval;
-/** Repeats an action for ever.
- To repeat the an action for a limited number of times use the Repeat action.
- @warning This action can't be Sequenceable because it is not an IntervalAction
- */
-@interface CCRepeatForever : CCAction <NSCopying>
-{
- CCActionInterval *other;
-}
-/** creates the action */
-+(id) actionWithAction: (CCActionInterval*) action;
-/** initializes the action */
--(id) initWithAction: (CCActionInterval*) action;
-@end
-
-/** Changes the speed of an action, making it take longer (speed>1)
- or less (speed<1) time.
- Useful to simulate 'slow motion' or 'fast forward' effect.
- @warning This action can't be Sequenceable because it is not an IntervalAction
- */
-@interface CCSpeed : CCAction <NSCopying>
-{
- CCActionInterval *other;
- float speed;
-}
-/** alter the speed of the inner function in runtime */
-@property (nonatomic,readwrite) float speed;
-/** creates the action */
-+(id) actionWithAction: (CCActionInterval*) action speed:(float)rate;
-/** initializes the action */
--(id) initWithAction: (CCActionInterval*) action speed:(float)rate;
-@end
-
-@class CCNode;
-/** CCFollow is an action that "follows" a node.
-
- Eg:
- [layer runAction: [CCFollow actionWithTarget:hero]];
-
- Instead of using CCCamera as a "follower", use this action instead.
- @since v0.99.2
- */
-@interface CCFollow : CCAction <NSCopying>
-{
- /* node to follow */
- CCNode *followedNode_;
-
- /* whether camera should be limited to certain area */
- BOOL boundarySet;
-
- /* if screensize is bigger than the boundary - update not needed */
- BOOL boundaryFullyCovered;
-
- /* fast access to the screen dimensions */
- CGPoint halfScreenSize;
- CGPoint fullScreenSize;
-
- /* world boundaries */
- float leftBoundary;
- float rightBoundary;
- float topBoundary;
- float bottomBoundary;
-}
-
-/** alter behavior - turn on/off boundary */
-@property (nonatomic,readwrite) BOOL boundarySet;
-
-/** creates the action with no boundary set */
-+(id) actionWithTarget:(CCNode *)followedNode;
-
-/** creates the action with a set boundary */
-+(id) actionWithTarget:(CCNode *)followedNode worldBoundary:(CGRect)rect;
-
-/** initializes the action */
--(id) initWithTarget:(CCNode *)followedNode;
-
-/** initializes the action with a set boundary */
--(id) initWithTarget:(CCNode *)followedNode worldBoundary:(CGRect)rect;
-
-@end
-
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (c) 2008-2010 Ricardo Quesada
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-
-
-#import <Availability.h>
-#import "CCDirector.h"
-#import "ccMacros.h"
-#import "CCAction.h"
-#import "CCActionInterval.h"
-#import "Support/CGPointExtension.h"
-
-//
-// Action Base Class
-//
-#pragma mark -
-#pragma mark Action
-@implementation CCAction
-
-@synthesize tag = tag_, target = target_, originalTarget = originalTarget_;
-
-+(id) action
-{
- return [[[self alloc] init] autorelease];
-}
-
--(id) init
-{
- if( (self=[super init]) ) {
- originalTarget_ = target_ = nil;
- tag_ = kCCActionTagInvalid;
- }
- return self;
-}
-
--(void) dealloc
-{
- CCLOGINFO(@"cocos2d: deallocing %@", self);
- [super dealloc];
-}
-
--(NSString*) description
-{
- return [NSString stringWithFormat:@"<%@ = %08X | Tag = %i>", [self class], self, tag_];
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCAction *copy = [[[self class] allocWithZone: zone] init];
- copy.tag = tag_;
- return copy;
-}
-
--(void) startWithTarget:(id)aTarget
-{
- originalTarget_ = target_ = aTarget;
-}
-
--(void) stop
-{
- target_ = nil;
-}
-
--(BOOL) isDone
-{
- return YES;
-}
-
--(void) step: (ccTime) dt
-{
- NSLog(@"[Action step]. override me");
-}
-
--(void) update: (ccTime) time
-{
- NSLog(@"[Action update]. override me");
-}
-@end
-
-//
-// FiniteTimeAction
-//
-#pragma mark -
-#pragma mark FiniteTimeAction
-@implementation CCFiniteTimeAction
-@synthesize duration = duration_;
-
-- (CCFiniteTimeAction*) reverse
-{
- CCLOG(@"cocos2d: FiniteTimeAction#reverse: Implement me");
- return nil;
-}
-@end
-
-
-//
-// RepeatForever
-//
-#pragma mark -
-#pragma mark RepeatForever
-@implementation CCRepeatForever
-+(id) actionWithAction: (CCActionInterval*) action
-{
- return [[[self alloc] initWithAction: action] autorelease];
-}
-
--(id) initWithAction: (CCActionInterval*) action
-{
- if( (self=[super init]) )
- other = [action retain];
-
- return self;
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCAction *copy = [[[self class] allocWithZone: zone] initWithAction:[[other copy] autorelease] ];
- return copy;
-}
-
--(void) dealloc
-{
- [other release];
- [super dealloc];
-}
-
--(void) startWithTarget:(id)aTarget
-{
- [super startWithTarget:aTarget];
- [other startWithTarget:target_];
-}
-
--(void) step:(ccTime) dt
-{
- [other step: dt];
- if( [other isDone] ) {
- ccTime diff = dt + other.duration - other.elapsed;
- [other startWithTarget:target_];
-
- // to prevent jerk. issue #390
- [other step: diff];
- }
-}
-
-
--(BOOL) isDone
-{
- return NO;
-}
-
-- (CCActionInterval *) reverse
-{
- return [CCRepeatForever actionWithAction:[other reverse]];
-}
-
-@end
-
-//
-// Speed
-//
-#pragma mark -
-#pragma mark Speed
-@implementation CCSpeed
-@synthesize speed;
-
-+(id) actionWithAction: (CCActionInterval*) action speed:(float)r
-{
- return [[[self alloc] initWithAction: action speed:r] autorelease];
-}
-
--(id) initWithAction: (CCActionInterval*) action speed:(float)r
-{
- if( (self=[super init]) ) {
- other = [action retain];
- speed = r;
- }
- return self;
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCAction *copy = [[[self class] allocWithZone: zone] initWithAction:[[other copy] autorelease] speed:speed];
- return copy;
-}
-
--(void) dealloc
-{
- [other release];
- [super dealloc];
-}
-
--(void) startWithTarget:(id)aTarget
-{
- [super startWithTarget:aTarget];
- [other startWithTarget:target_];
-}
-
--(void) stop
-{
- [other stop];
- [super stop];
-}
-
--(void) step:(ccTime) dt
-{
- [other step: dt * speed];
-}
-
--(BOOL) isDone
-{
- return [other isDone];
-}
-
-- (CCActionInterval *) reverse
-{
- return [CCSpeed actionWithAction:[other reverse] speed:speed];
-}
-@end
-
-//
-// Follow
-//
-#pragma mark -
-#pragma mark Follow
-@implementation CCFollow
-
-@synthesize boundarySet;
-
-+(id) actionWithTarget:(CCNode *) fNode
-{
- return [[[self alloc] initWithTarget:fNode] autorelease];
-}
-
-+(id) actionWithTarget:(CCNode *) fNode worldBoundary:(CGRect)rect
-{
- return [[[self alloc] initWithTarget:fNode worldBoundary:rect] autorelease];
-}
-
--(id) initWithTarget:(CCNode *)fNode
-{
- if( (self=[super init]) ) {
-
- followedNode_ = [fNode retain];
- boundarySet = FALSE;
- boundaryFullyCovered = FALSE;
-
- CGSize s = [[CCDirector sharedDirector] winSize];
- fullScreenSize = CGPointMake(s.width, s.height);
- halfScreenSize = ccpMult(fullScreenSize, .5f);
- }
-
- return self;
-}
-
--(id) initWithTarget:(CCNode *)fNode worldBoundary:(CGRect)rect
-{
- if( (self=[super init]) ) {
-
- followedNode_ = [fNode retain];
- boundarySet = TRUE;
- boundaryFullyCovered = FALSE;
-
- CGSize winSize = [[CCDirector sharedDirector] winSize];
- fullScreenSize = CGPointMake(winSize.width, winSize.height);
- halfScreenSize = ccpMult(fullScreenSize, .5f);
-
- leftBoundary = -((rect.origin.x+rect.size.width) - fullScreenSize.x);
- rightBoundary = -rect.origin.x ;
- topBoundary = -rect.origin.y;
- bottomBoundary = -((rect.origin.y+rect.size.height) - fullScreenSize.y);
-
- if(rightBoundary < leftBoundary)
- {
- // screen width is larger than world's boundary width
- //set both in the middle of the world
- rightBoundary = leftBoundary = (leftBoundary + rightBoundary) / 2;
- }
- if(topBoundary < bottomBoundary)
- {
- // screen width is larger than world's boundary width
- //set both in the middle of the world
- topBoundary = bottomBoundary = (topBoundary + bottomBoundary) / 2;
- }
-
- if( (topBoundary == bottomBoundary) && (leftBoundary == rightBoundary) )
- boundaryFullyCovered = TRUE;
- }
-
- return self;
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCAction *copy = [[[self class] allocWithZone: zone] init];
- copy.tag = tag_;
- return copy;
-}
-
--(void) step:(ccTime) dt
-{
-#define CLAMP(x,y,z) MIN(MAX(x,y),z)
-
- if(boundarySet)
- {
- // whole map fits inside a single screen, no need to modify the position - unless map boundaries are increased
- if(boundaryFullyCovered)
- return;
-
- CGPoint tempPos = ccpSub( halfScreenSize, followedNode_.position);
- [target_ setPosition:ccp(CLAMP(tempPos.x,leftBoundary,rightBoundary), CLAMP(tempPos.y,bottomBoundary,topBoundary))];
- }
- else
- [target_ setPosition:ccpSub( halfScreenSize, followedNode_.position )];
-
-#undef CLAMP
-}
-
-
--(BOOL) isDone
-{
- return !followedNode_.isRunning;
-}
-
--(void) stop
-{
- target_ = nil;
- [super stop];
-}
-
--(void) dealloc
-{
- [followedNode_ release];
- [super dealloc];
-}
-
-@end
-
-
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (c) 2008-2010 Ricardo Quesada
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-#import "CCActionInterval.h"
-
-@class CCCamera;
-
-/** Base class for CCCamera actions
- */
-@interface CCActionCamera : CCActionInterval <NSCopying>
-{
- float centerXOrig_;
- float centerYOrig_;
- float centerZOrig_;
-
- float eyeXOrig_;
- float eyeYOrig_;
- float eyeZOrig_;
-
- float upXOrig_;
- float upYOrig_;
- float upZOrig_;
-}
-@end
-
-/** CCOrbitCamera action
- Orbits the camera around the center of the screen using spherical coordinates
- */
-@interface CCOrbitCamera : CCActionCamera <NSCopying>
-{
- float radius_;
- float deltaRadius_;
- float angleZ_;
- float deltaAngleZ_;
- float angleX_;
- float deltaAngleX_;
-
- float radZ_;
- float radDeltaZ_;
- float radX_;
- float radDeltaX_;
-
-}
-/** creates a CCOrbitCamera action with radius, delta-radius, z, deltaZ, x, deltaX */
-+(id) actionWithDuration:(float) t radius:(float)r deltaRadius:(float) dr angleZ:(float)z deltaAngleZ:(float)dz angleX:(float)x deltaAngleX:(float)dx;
-/** initializes a CCOrbitCamera action with radius, delta-radius, z, deltaZ, x, deltaX */
--(id) initWithDuration:(float) t radius:(float)r deltaRadius:(float) dr angleZ:(float)z deltaAngleZ:(float)dz angleX:(float)x deltaAngleX:(float)dx;
-/** positions the camera according to spherical coordinates */
--(void) sphericalRadius:(float*) r zenith:(float*) zenith azimuth:(float*) azimuth;
-@end
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (c) 2008-2010 Ricardo Quesada
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-
-
-#import "CCActionCamera.h"
-#import "CCNode.h"
-#import "CCCamera.h"
-#import "ccMacros.h"
-
-//
-// CameraAction
-//
-@implementation CCActionCamera
--(void) startWithTarget:(id)aTarget
-{
- [super startWithTarget:aTarget];
- CCCamera *camera = [target_ camera];
- [camera centerX:¢erXOrig_ centerY:¢erYOrig_ centerZ:¢erZOrig_];
- [camera eyeX:&eyeXOrig_ eyeY:&eyeYOrig_ eyeZ:&eyeZOrig_];
- [camera upX:&upXOrig_ upY:&upYOrig_ upZ: &upZOrig_];
-}
-
--(id) reverse
-{
- return [CCReverseTime actionWithAction:self];
-}
-@end
-
-@implementation CCOrbitCamera
-+(id) actionWithDuration:(float)t radius:(float)r deltaRadius:(float) dr angleZ:(float)z deltaAngleZ:(float)dz angleX:(float)x deltaAngleX:(float)dx
-{
- return [[[self alloc] initWithDuration:t radius:r deltaRadius:dr angleZ:z deltaAngleZ:dz angleX:x deltaAngleX:dx] autorelease];
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- return [[[self class] allocWithZone: zone] initWithDuration:duration_ radius:radius_ deltaRadius:deltaRadius_ angleZ:angleZ_ deltaAngleZ:deltaAngleZ_ angleX:angleX_ deltaAngleX:deltaAngleX_];
-}
-
-
--(id) initWithDuration:(float)t radius:(float)r deltaRadius:(float) dr angleZ:(float)z deltaAngleZ:(float)dz angleX:(float)x deltaAngleX:(float)dx
-{
- if((self=[super initWithDuration:t]) ) {
-
- radius_ = r;
- deltaRadius_ = dr;
- angleZ_ = z;
- deltaAngleZ_ = dz;
- angleX_ = x;
- deltaAngleX_ = dx;
-
- radDeltaZ_ = (CGFloat)CC_DEGREES_TO_RADIANS(dz);
- radDeltaX_ = (CGFloat)CC_DEGREES_TO_RADIANS(dx);
- }
-
- return self;
-}
-
--(void) startWithTarget:(id)aTarget
-{
- [super startWithTarget:aTarget];
- float r, zenith, azimuth;
-
- [self sphericalRadius: &r zenith:&zenith azimuth:&azimuth];
-
-#if 0 // isnan() is not supported on the simulator, and isnan() always returns false.
- if( isnan(radius_) )
- radius_ = r;
-
- if( isnan( angleZ_) )
- angleZ_ = (CGFloat)CC_RADIANS_TO_DEGREES(zenith);
-
- if( isnan( angleX_ ) )
- angleX_ = (CGFloat)CC_RADIANS_TO_DEGREES(azimuth);
-#endif
-
- radZ_ = (CGFloat)CC_DEGREES_TO_RADIANS(angleZ_);
- radX_ = (CGFloat)CC_DEGREES_TO_RADIANS(angleX_);
-}
-
--(void) update: (ccTime) dt
-{
- float r = (radius_ + deltaRadius_ * dt) *[CCCamera getZEye];
- float za = radZ_ + radDeltaZ_ * dt;
- float xa = radX_ + radDeltaX_ * dt;
-
- float i = sinf(za) * cosf(xa) * r + centerXOrig_;
- float j = sinf(za) * sinf(xa) * r + centerYOrig_;
- float k = cosf(za) * r + centerZOrig_;
-
- [[target_ camera] setEyeX:i eyeY:j eyeZ:k];
-}
-
--(void) sphericalRadius:(float*) newRadius zenith:(float*) zenith azimuth:(float*) azimuth
-{
- float ex, ey, ez, cx, cy, cz, x, y, z;
- float r; // radius
- float s;
-
- CCCamera *camera = [target_ camera];
- [camera eyeX:&ex eyeY:&ey eyeZ:&ez];
- [camera centerX:&cx centerY:&cy centerZ:&cz];
-
- x = ex-cx;
- y = ey-cy;
- z = ez-cz;
-
- r = sqrtf( x*x + y*y + z*z);
- s = sqrtf( x*x + y*y);
- if(s==0.0f)
- s = FLT_EPSILON;
- if(r==0.0f)
- r = FLT_EPSILON;
-
- *zenith = acosf( z/r);
- if( x < 0 )
- *azimuth = (float)M_PI - asinf(y/s);
- else
- *azimuth = asinf(y/s);
-
- *newRadius = r / [CCCamera getZEye];
-}
-@end
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (c) 2008-2009 Jason Booth
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-
-#import "CCActionInterval.h"
-
-/** Base class for Easing actions
- */
-@interface CCActionEase : CCActionInterval <NSCopying>
-{
- CCActionInterval * other;
-}
-/** creates the action */
-+(id) actionWithAction: (CCActionInterval*) action;
-/** initializes the action */
--(id) initWithAction: (CCActionInterval*) action;
-@end
-
-/** Base class for Easing actions with rate parameters
- */
-@interface CCEaseRateAction : CCActionEase <NSCopying>
-{
- float rate;
-}
-/** rate value for the actions */
-@property (nonatomic,readwrite,assign) float rate;
-/** Creates the action with the inner action and the rate parameter */
-+(id) actionWithAction: (CCActionInterval*) action rate:(float)rate;
-/** Initializes the action with the inner action and the rate parameter */
--(id) initWithAction: (CCActionInterval*) action rate:(float)rate;
-@end
-
-/** CCEaseIn action with a rate
- */
-@interface CCEaseIn : CCEaseRateAction <NSCopying> {} @end
-
-/** CCEaseOut action with a rate
- */
-@interface CCEaseOut : CCEaseRateAction <NSCopying> {} @end
-
-/** CCEaseInOut action with a rate
- */
-@interface CCEaseInOut : CCEaseRateAction <NSCopying> {} @end
-
-/** CCEase Exponential In
- */
-@interface CCEaseExponentialIn : CCActionEase <NSCopying> {} @end
-/** Ease Exponential Out
- */
-@interface CCEaseExponentialOut : CCActionEase <NSCopying> {} @end
-/** Ease Exponential InOut
- */
-@interface CCEaseExponentialInOut : CCActionEase <NSCopying> {} @end
-/** Ease Sine In
- */
-@interface CCEaseSineIn : CCActionEase <NSCopying> {} @end
-/** Ease Sine Out
- */
-@interface CCEaseSineOut : CCActionEase <NSCopying> {} @end
-/** Ease Sine InOut
- */
-@interface CCEaseSineInOut : CCActionEase <NSCopying> {} @end
-
-/** Ease Elastic abstract class
- @since v0.8.2
- */
-@interface CCEaseElastic : CCActionEase <NSCopying>
-{
- float period_;
-}
-
-/** period of the wave in radians. default is 0.3 */
-@property (nonatomic,readwrite) float period;
-
-/** Creates the action with the inner action and the period in radians (default is 0.3) */
-+(id) actionWithAction: (CCActionInterval*) action period:(float)period;
-/** Initializes the action with the inner action and the period in radians (default is 0.3) */
--(id) initWithAction: (CCActionInterval*) action period:(float)period;
-@end
-
-/** Ease Elastic In action.
- @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action.
- @since v0.8.2
- */
-@interface CCEaseElasticIn : CCEaseElastic <NSCopying> {} @end
-/** Ease Elastic Out action.
- @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action.
- @since v0.8.2
- */
-@interface CCEaseElasticOut : CCEaseElastic <NSCopying> {} @end
-/** Ease Elastic InOut action.
- @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action.
- @since v0.8.2
- */
-@interface CCEaseElasticInOut : CCEaseElastic <NSCopying> {} @end
-
-/** CCEaseBounce abstract class.
- @since v0.8.2
-*/
-@interface CCEaseBounce : CCActionEase <NSCopying> {} @end
-
-/** CCEaseBounceIn action.
- @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action.
- @since v0.8.2
-*/
-@interface CCEaseBounceIn : CCEaseBounce <NSCopying> {} @end
-
-/** EaseBounceOut action.
- @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action.
- @since v0.8.2
- */
-@interface CCEaseBounceOut : CCEaseBounce <NSCopying> {} @end
-
-/** CCEaseBounceInOut action.
- @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action.
- @since v0.8.2
- */
-@interface CCEaseBounceInOut : CCEaseBounce <NSCopying> {} @end
-
-/** CCEaseBackIn action.
- @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action.
- @since v0.8.2
- */
-@interface CCEaseBackIn : CCActionEase <NSCopying> {} @end
-
-/** CCEaseBackOut action.
- @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action.
- @since v0.8.2
- */
-@interface CCEaseBackOut : CCActionEase <NSCopying> {} @end
-
-/** CCEaseBackInOut action.
- @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action.
- @since v0.8.2
- */
-@interface CCEaseBackInOut : CCActionEase <NSCopying> {} @end
-
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (c) 2008-2009 Jason Booth
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-
-/*
- * Elastic, Back and Bounce actions based on code from:
- * http://github.com/NikhilK/silverlightfx/
- *
- * by http://github.com/NikhilK
- */
-
-#import "CCActionEase.h"
-
-#ifndef M_PI_X_2
-#define M_PI_X_2 (float)M_PI * 2.0f
-#endif
-
-#pragma mark EaseAction
-
-//
-// EaseAction
-//
-@implementation CCActionEase
-
-+(id) actionWithAction: (CCActionInterval*) action
-{
- return [[[self alloc] initWithAction: action] autorelease ];
-}
-
--(id) initWithAction: (CCActionInterval*) action
-{
- NSAssert( action!=nil, @"Ease: arguments must be non-nil");
-
- if( (self=[super initWithDuration: action.duration]) )
- other = [action retain];
-
- return self;
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCAction *copy = [[[self class] allocWithZone:zone] initWithAction:[[other copy] autorelease]];
- return copy;
-}
-
--(void) dealloc
-{
- [other release];
- [super dealloc];
-}
-
--(void) startWithTarget:(id)aTarget
-{
- [super startWithTarget:aTarget];
- [other startWithTarget:target_];
-}
-
--(void) stop
-{
- [other stop];
- [super stop];
-}
-
--(void) update: (ccTime) t
-{
- [other update: t];
-}
-
--(CCActionInterval*) reverse
-{
- return [[self class] actionWithAction: [other reverse]];
-}
-@end
-
-
-#pragma mark -
-#pragma mark EaseRate
-
-//
-// EaseRateAction
-//
-@implementation CCEaseRateAction
-@synthesize rate;
-+(id) actionWithAction: (CCActionInterval*) action rate:(float)aRate
-{
- return [[[self alloc] initWithAction: action rate:aRate] autorelease ];
-}
-
--(id) initWithAction: (CCActionInterval*) action rate:(float)aRate
-{
- if( (self=[super initWithAction:action ]) )
- self.rate = aRate;
-
- return self;
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCAction *copy = [[[self class] allocWithZone:zone] initWithAction:[[other copy] autorelease] rate:rate];
- return copy;
-}
-
--(void) dealloc
-{
- [super dealloc];
-}
-
--(CCActionInterval*) reverse
-{
- return [[self class] actionWithAction: [other reverse] rate:1/rate];
-}
-@end
-
-//
-// EeseIn
-//
-@implementation CCEaseIn
--(void) update: (ccTime) t
-{
- [other update: powf(t,rate)];
-}
-@end
-
-//
-// EaseOut
-//
-@implementation CCEaseOut
--(void) update: (ccTime) t
-{
- [other update: powf(t,1/rate)];
-}
-@end
-
-//
-// EaseInOut
-//
-@implementation CCEaseInOut
--(void) update: (ccTime) t
-{
- int sign =1;
- int r = (int) rate;
- if (r % 2 == 0)
- sign = -1;
- t *= 2;
- if (t < 1)
- [other update: 0.5f * powf (t, rate)];
- else
- [other update: sign*0.5f * (powf (t-2, rate) + sign*2)];
-}
-
-// InOut and OutIn are symmetrical
--(CCActionInterval*) reverse
-{
- return [[self class] actionWithAction: [other reverse] rate:rate];
-}
-
-@end
-
-#pragma mark -
-#pragma mark EaseExponential
-
-//
-// EaseExponentialIn
-//
-@implementation CCEaseExponentialIn
--(void) update: (ccTime) t
-{
- [other update: (t==0) ? 0 : powf(2, 10 * (t/1 - 1)) - 1 * 0.001f];
-}
-
-- (CCActionInterval*) reverse
-{
- return [CCEaseExponentialOut actionWithAction: [other reverse]];
-}
-@end
-
-//
-// EaseExponentialOut
-//
-@implementation CCEaseExponentialOut
--(void) update: (ccTime) t
-{
- [other update: (t==1) ? 1 : (-powf(2, -10 * t/1) + 1)];
-}
-
-- (CCActionInterval*) reverse
-{
- return [CCEaseExponentialIn actionWithAction: [other reverse]];
-}
-@end
-
-//
-// EaseExponentialInOut
-//
-@implementation CCEaseExponentialInOut
--(void) update: (ccTime) t
-{
- t /= 0.5f;
- if (t < 1)
- t = 0.5f * powf(2, 10 * (t - 1));
- else
- t = 0.5f * (-powf(2, -10 * (t -1) ) + 2);
-
- [other update:t];
-}
-@end
-
-
-#pragma mark -
-#pragma mark EaseSin actions
-
-//
-// EaseSineIn
-//
-@implementation CCEaseSineIn
--(void) update: (ccTime) t
-{
- [other update:-1*cosf(t * (float)M_PI_2) +1];
-}
-
-- (CCActionInterval*) reverse
-{
- return [CCEaseSineOut actionWithAction: [other reverse]];
-}
-@end
-
-//
-// EaseSineOut
-//
-@implementation CCEaseSineOut
--(void) update: (ccTime) t
-{
- [other update:sinf(t * (float)M_PI_2)];
-}
-
-- (CCActionInterval*) reverse
-{
- return [CCEaseSineIn actionWithAction: [other reverse]];
-}
-@end
-
-//
-// EaseSineInOut
-//
-@implementation CCEaseSineInOut
--(void) update: (ccTime) t
-{
- [other update:-0.5f*(cosf( (float)M_PI*t) - 1)];
-}
-@end
-
-#pragma mark -
-#pragma mark EaseElastic actions
-
-//
-// EaseElastic
-//
-@implementation CCEaseElastic
-
-@synthesize period = period_;
-
-+(id) actionWithAction: (CCActionInterval*) action
-{
- return [[[self alloc] initWithAction:action period:0.3f] autorelease];
-}
-
-+(id) actionWithAction: (CCActionInterval*) action period:(float)period
-{
- return [[[self alloc] initWithAction:action period:period] autorelease];
-}
-
--(id) initWithAction: (CCActionInterval*) action
-{
- return [self initWithAction:action period:0.3f];
-}
-
--(id) initWithAction: (CCActionInterval*) action period:(float)period
-{
- if( (self=[super initWithAction:action]) )
- period_ = period;
-
- return self;
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCAction *copy = [[[self class] allocWithZone:zone] initWithAction:[[other copy] autorelease] period:period_];
- return copy;
-}
-
--(CCActionInterval*) reverse
-{
- NSAssert(NO,@"Override me");
- return nil;
-}
-
-@end
-
-//
-// EaseElasticIn
-//
-
-@implementation CCEaseElasticIn
--(void) update: (ccTime) t
-{
- ccTime newT = 0;
- if (t == 0 || t == 1)
- newT = t;
-
- else {
- float s = period_ / 4;
- t = t - 1;
- newT = -powf(2, 10 * t) * sinf( (t-s) *M_PI_X_2 / period_);
- }
- [other update:newT];
-}
-
-- (CCActionInterval*) reverse
-{
- return [CCEaseElasticOut actionWithAction: [other reverse] period:period_];
-}
-
-@end
-
-//
-// EaseElasticOut
-//
-@implementation CCEaseElasticOut
-
--(void) update: (ccTime) t
-{
- ccTime newT = 0;
- if (t == 0 || t == 1) {
- newT = t;
-
- } else {
- float s = period_ / 4;
- newT = powf(2, -10 * t) * sinf( (t-s) *M_PI_X_2 / period_) + 1;
- }
- [other update:newT];
-}
-
-- (CCActionInterval*) reverse
-{
- return [CCEaseElasticIn actionWithAction: [other reverse] period:period_];
-}
-
-@end
-
-//
-// EaseElasticInOut
-//
-@implementation CCEaseElasticInOut
--(void) update: (ccTime) t
-{
- ccTime newT = 0;
-
- if( t == 0 || t == 1 )
- newT = t;
- else {
- t = t * 2;
- if(! period_ )
- period_ = 0.3f * 1.5f;
- ccTime s = period_ / 4;
-
- t = t -1;
- if( t < 0 )
- newT = -0.5f * powf(2, 10 * t) * sinf((t - s) * M_PI_X_2 / period_);
- else
- newT = powf(2, -10 * t) * sinf((t - s) * M_PI_X_2 / period_) * 0.5f + 1;
- }
- [other update:newT];
-}
-
-- (CCActionInterval*) reverse
-{
- return [CCEaseElasticInOut actionWithAction: [other reverse] period:period_];
-}
-
-@end
-
-#pragma mark -
-#pragma mark EaseBounce actions
-
-//
-// EaseBounce
-//
-@implementation CCEaseBounce
--(ccTime) bounceTime:(ccTime) t
-{
- if (t < 1 / 2.75) {
- return 7.5625f * t * t;
- }
- else if (t < 2 / 2.75) {
- t -= 1.5f / 2.75f;
- return 7.5625f * t * t + 0.75f;
- }
- else if (t < 2.5 / 2.75) {
- t -= 2.25f / 2.75f;
- return 7.5625f * t * t + 0.9375f;
- }
-
- t -= 2.625f / 2.75f;
- return 7.5625f * t * t + 0.984375f;
-}
-@end
-
-//
-// EaseBounceIn
-//
-
-@implementation CCEaseBounceIn
-
--(void) update: (ccTime) t
-{
- ccTime newT = 1 - [self bounceTime:1-t];
- [other update:newT];
-}
-
-- (CCActionInterval*) reverse
-{
- return [CCEaseBounceOut actionWithAction: [other reverse]];
-}
-
-@end
-
-@implementation CCEaseBounceOut
-
--(void) update: (ccTime) t
-{
- ccTime newT = [self bounceTime:t];
- [other update:newT];
-}
-
-- (CCActionInterval*) reverse
-{
- return [CCEaseBounceIn actionWithAction: [other reverse]];
-}
-
-@end
-
-@implementation CCEaseBounceInOut
-
--(void) update: (ccTime) t
-{
- ccTime newT = 0;
- if (t < 0.5) {
- t = t * 2;
- newT = (1 - [self bounceTime:1-t] ) * 0.5f;
- } else
- newT = [self bounceTime:t * 2 - 1] * 0.5f + 0.5f;
-
- [other update:newT];
-}
-@end
-
-#pragma mark -
-#pragma mark Ease Back actions
-
-//
-// EaseBackIn
-//
-@implementation CCEaseBackIn
-
--(void) update: (ccTime) t
-{
- ccTime overshoot = 1.70158f;
- [other update: t * t * ((overshoot + 1) * t - overshoot)];
-}
-
-- (CCActionInterval*) reverse
-{
- return [CCEaseBackOut actionWithAction: [other reverse]];
-}
-@end
-
-//
-// EaseBackOut
-//
-@implementation CCEaseBackOut
--(void) update: (ccTime) t
-{
- ccTime overshoot = 1.70158f;
-
- t = t - 1;
- [other update: t * t * ((overshoot + 1) * t + overshoot) + 1];
-}
-
-- (CCActionInterval*) reverse
-{
- return [CCEaseBackIn actionWithAction: [other reverse]];
-}
-@end
-
-//
-// EaseBackInOut
-//
-@implementation CCEaseBackInOut
-
--(void) update: (ccTime) t
-{
- ccTime overshoot = 1.70158f * 1.525f;
-
- t = t * 2;
- if (t < 1)
- [other update: (t * t * ((overshoot + 1) * t - overshoot)) / 2];
- else {
- t = t - 2;
- [other update: (t * t * ((overshoot + 1) * t + overshoot)) / 2 + 1];
- }
-}
-@end
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (c) 2009 On-Core
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-
-#import "CCActionInterval.h"
-#import "CCActionInstant.h"
-#import "CCGrid.h"
-
-@class CCGridBase;
-
-/** Base class for Grid actions */
-@interface CCGridAction : CCActionInterval
-{
- ccGridSize gridSize_;
-}
-
-/** size of the grid */
-@property (nonatomic,readwrite) ccGridSize gridSize;
-
-/** creates the action with size and duration */
-+(id) actionWithSize:(ccGridSize)size duration:(ccTime)d;
-/** initializes the action with size and duration */
--(id) initWithSize:(ccGridSize)gridSize duration:(ccTime)d;
-/** returns the grid */
--(CCGridBase *)grid;
-
-@end
-
-////////////////////////////////////////////////////////////
-
-/** Base class for CCGrid3D actions.
- Grid3D actions can modify a non-tiled grid.
- */
-@interface CCGrid3DAction : CCGridAction
-{
-}
-
-/** returns the vertex than belongs to certain position in the grid */
--(ccVertex3F)vertex:(ccGridSize)pos;
-/** returns the non-transformed vertex than belongs to certain position in the grid */
--(ccVertex3F)originalVertex:(ccGridSize)pos;
-/** sets a new vertex to a certain position of the grid */
--(void)setVertex:(ccGridSize)pos vertex:(ccVertex3F)vertex;
-
-@end
-
-////////////////////////////////////////////////////////////
-
-/** Base class for CCTiledGrid3D actions */
-@interface CCTiledGrid3DAction : CCGridAction
-{
-}
-
-/** returns the tile that belongs to a certain position of the grid */
--(ccQuad3)tile:(ccGridSize)pos;
-/** returns the non-transformed tile that belongs to a certain position of the grid */
--(ccQuad3)originalTile:(ccGridSize)pos;
-/** sets a new tile to a certain position of the grid */
--(void)setTile:(ccGridSize)pos coords:(ccQuad3)coords;
-
-@end
-
-////////////////////////////////////////////////////////////
-
-/** CCAccelDeccelAmplitude action */
-@interface CCAccelDeccelAmplitude : CCActionInterval
-{
- float rate;
- CCActionInterval *other;
-}
-
-/** amplitude rate */
-@property (nonatomic,readwrite) float rate;
-
-/** creates the action with an inner action that has the amplitude property, and a duration time */
-+(id)actionWithAction:(CCAction*)action duration:(ccTime)d;
-/** initializes the action with an inner action that has the amplitude property, and a duration time */
--(id)initWithAction:(CCAction*)action duration:(ccTime)d;
-
-@end
-
-////////////////////////////////////////////////////////////
-
-/** CCAccelAmplitude action */
-@interface CCAccelAmplitude : CCActionInterval
-{
- float rate;
- CCActionInterval *other;
-}
-
-/** amplitude rate */
-@property (nonatomic,readwrite) float rate;
-
-/** creates the action with an inner action that has the amplitude property, and a duration time */
-+(id)actionWithAction:(CCAction*)action duration:(ccTime)d;
-/** initializes the action with an inner action that has the amplitude property, and a duration time */
--(id)initWithAction:(CCAction*)action duration:(ccTime)d;
-
-@end
-
-////////////////////////////////////////////////////////////
-
-/** CCDeccelAmplitude action */
-@interface CCDeccelAmplitude : CCActionInterval
-{
- float rate;
- CCActionInterval *other;
-}
-
-/** amplitude rate */
-@property (nonatomic,readwrite) float rate;
-
-/** creates the action with an inner action that has the amplitude property, and a duration time */
-+(id)actionWithAction:(CCAction*)action duration:(ccTime)d;
-/** initializes the action with an inner action that has the amplitude property, and a duration time */
--(id)initWithAction:(CCAction*)action duration:(ccTime)d;
-
-@end
-
-////////////////////////////////////////////////////////////
-
-/** CCStopGrid action.
- Don't call this action if another grid action is active.
- Call if you want to remove the the grid effect. Example:
- [Sequence actions:[Lens ...], [StopGrid action], nil];
- */
-@interface CCStopGrid : CCActionInstant
-{
-}
-@end
-
-////////////////////////////////////////////////////////////
-
-/** CCReuseGrid action */
-@interface CCReuseGrid : CCActionInstant
-{
- int t;
-}
-/** creates an action with the number of times that the current grid will be reused */
-+(id) actionWithTimes: (int) times;
-/** initializes an action with the number of times that the current grid will be reused */
--(id) initWithTimes: (int) times;
-@end
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (c) 2009 On-Core
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-
-#import "CCActionGrid.h"
-#import "CCDirector.h"
-
-#pragma mark -
-#pragma mark GridAction
-
-@implementation CCGridAction
-
-@synthesize gridSize = gridSize_;
-
-+(id) actionWithSize:(ccGridSize)size duration:(ccTime)d
-{
- return [[[self alloc] initWithSize:size duration:d ] autorelease];
-}
-
--(id) initWithSize:(ccGridSize)gSize duration:(ccTime)d
-{
- if ( (self = [super initWithDuration:d]) )
- {
- gridSize_ = gSize;
- }
-
- return self;
-}
-
--(void)startWithTarget:(id)aTarget
-{
- [super startWithTarget:aTarget];
-
- CCGridBase *newgrid = [self grid];
-
- CCNode *t = (CCNode*) target_;
- CCGridBase *targetGrid = [t grid];
-
- if ( targetGrid && targetGrid.reuseGrid > 0 )
- {
- if ( targetGrid.active && targetGrid.gridSize.x == gridSize_.x && targetGrid.gridSize.y == gridSize_.y && [targetGrid isKindOfClass:[newgrid class]] )
- [targetGrid reuse];
- else
- [NSException raise:@"GridBase" format:@"Cannot reuse grid"];
- }
- else
- {
- if ( targetGrid && targetGrid.active )
- targetGrid.active = NO;
-
- t.grid = newgrid;
- t.grid.active = YES;
- }
-}
-
--(CCGridBase *)grid
-{
- [NSException raise:@"GridBase" format:@"Abstract class needs implementation"];
- return nil;
-}
-
-- (CCActionInterval*) reverse
-{
- return [CCReverseTime actionWithAction:self];
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCGridAction *copy = [[[self class] allocWithZone:zone] initWithSize:gridSize_ duration:duration_];
- return copy;
-}
-@end
-
-////////////////////////////////////////////////////////////
-
-#pragma mark -
-#pragma mark Grid3DAction
-
-@implementation CCGrid3DAction
-
--(CCGridBase *)grid
-{
- return [CCGrid3D gridWithSize:gridSize_];
-}
-
--(ccVertex3F)vertex:(ccGridSize)pos
-{
- CCGrid3D *g = (CCGrid3D *)[target_ grid];
- return [g vertex:pos];
-}
-
--(ccVertex3F)originalVertex:(ccGridSize)pos
-{
- CCGrid3D *g = (CCGrid3D *)[target_ grid];
- return [g originalVertex:pos];
-}
-
--(void)setVertex:(ccGridSize)pos vertex:(ccVertex3F)vertex
-{
- CCGrid3D *g = (CCGrid3D *)[target_ grid];
- return [g setVertex:pos vertex:vertex];
-}
-@end
-
-////////////////////////////////////////////////////////////
-
-#pragma mark -
-#pragma mark TiledGrid3DAction
-
-@implementation CCTiledGrid3DAction
-
--(CCGridBase *)grid
-{
- return [CCTiledGrid3D gridWithSize:gridSize_];
-}
-
--(ccQuad3)tile:(ccGridSize)pos
-{
- CCTiledGrid3D *g = (CCTiledGrid3D *)[target_ grid];
- return [g tile:pos];
-}
-
--(ccQuad3)originalTile:(ccGridSize)pos
-{
- CCTiledGrid3D *g = (CCTiledGrid3D *)[target_ grid];
- return [g originalTile:pos];
-}
-
--(void)setTile:(ccGridSize)pos coords:(ccQuad3)coords
-{
- CCTiledGrid3D *g = (CCTiledGrid3D *)[target_ grid];
- [g setTile:pos coords:coords];
-}
-
-@end
-
-////////////////////////////////////////////////////////////
-
-@interface CCActionInterval (Amplitude)
--(void)setAmplitudeRate:(CGFloat)amp;
--(CGFloat)getAmplitudeRate;
-@end
-
-@implementation CCActionInterval (Amplitude)
--(void)setAmplitudeRate:(CGFloat)amp
-{
- [NSException raise:@"IntervalAction (Amplitude)" format:@"Abstract class needs implementation"];
-}
-
--(CGFloat)getAmplitudeRate
-{
- [NSException raise:@"IntervalAction (Amplitude)" format:@"Abstract class needs implementation"];
- return 0;
-}
-@end
-
-////////////////////////////////////////////////////////////
-
-#pragma mark -
-#pragma mark AccelDeccelAmplitude
-
-@implementation CCAccelDeccelAmplitude
-
-@synthesize rate;
-
-+(id)actionWithAction:(CCAction*)action duration:(ccTime)d
-{
- return [[[self alloc] initWithAction:action duration:d ] autorelease];
-}
-
--(id)initWithAction:(CCAction *)action duration:(ccTime)d
-{
- if ( (self = [super initWithDuration:d]) )
- {
- rate = 1.0f;
- other = [action retain];
- }
-
- return self;
-}
-
--(void)dealloc
-{
- [other release];
- [super dealloc];
-}
-
--(void)startWithTarget:(id)aTarget
-{
- [super startWithTarget:aTarget];
- [other startWithTarget:target_];
-}
-
--(void) update: (ccTime) time
-{
- float f = time*2;
-
- if (f > 1)
- {
- f -= 1;
- f = 1 - f;
- }
-
- [other setAmplitudeRate:powf(f, rate)];
- [other update:time];
-}
-
-- (CCActionInterval*) reverse
-{
- return [CCAccelDeccelAmplitude actionWithAction:[other reverse] duration:duration_];
-}
-
-@end
-
-////////////////////////////////////////////////////////////
-
-#pragma mark -
-#pragma mark AccelAmplitude
-
-@implementation CCAccelAmplitude
-
-@synthesize rate;
-
-+(id)actionWithAction:(CCAction*)action duration:(ccTime)d
-{
- return [[[self alloc] initWithAction:action duration:d ] autorelease];
-}
-
--(id)initWithAction:(CCAction *)action duration:(ccTime)d
-{
- if ( (self = [super initWithDuration:d]) )
- {
- rate = 1.0f;
- other = [action retain];
- }
-
- return self;
-}
-
--(void)dealloc
-{
- [other release];
- [super dealloc];
-}
-
--(void)startWithTarget:(id)aTarget
-{
- [super startWithTarget:aTarget];
- [other startWithTarget:target_];
-}
-
--(void) update: (ccTime) time
-{
- [other setAmplitudeRate:powf(time, rate)];
- [other update:time];
-}
-
-- (CCActionInterval*) reverse
-{
- return [CCAccelAmplitude actionWithAction:[other reverse] duration:self.duration];
-}
-
-@end
-
-////////////////////////////////////////////////////////////
-
-#pragma mark -
-#pragma mark DeccelAmplitude
-
-@implementation CCDeccelAmplitude
-
-@synthesize rate;
-
-+(id)actionWithAction:(CCAction*)action duration:(ccTime)d
-{
- return [[[self alloc] initWithAction:action duration:d ] autorelease];
-}
-
--(id)initWithAction:(CCAction *)action duration:(ccTime)d
-{
- if ( (self = [super initWithDuration:d]) )
- {
- rate = 1.0f;
- other = [action retain];
- }
-
- return self;
-}
-
--(void)dealloc
-{
- [other release];
- [super dealloc];
-}
-
--(void)startWithTarget:(id)aTarget
-{
- [super startWithTarget:aTarget];
- [other startWithTarget:target_];
-}
-
--(void) update: (ccTime) time
-{
- [other setAmplitudeRate:powf((1-time), rate)];
- [other update:time];
-}
-
-- (CCActionInterval*) reverse
-{
- return [CCDeccelAmplitude actionWithAction:[other reverse] duration:self.duration];
-}
-
-@end
-
-////////////////////////////////////////////////////////////
-
-#pragma mark -
-#pragma mark StopGrid
-
-@implementation CCStopGrid
-
--(void)startWithTarget:(id)aTarget
-{
- [super startWithTarget:aTarget];
-
- if ( [[self target] grid] && [[[self target] grid] active] ) {
- [[[self target] grid] setActive: NO];
-
-// [[self target] setGrid: nil];
- }
-}
-
-@end
-
-////////////////////////////////////////////////////////////
-
-#pragma mark -
-#pragma mark ReuseGrid
-
-@implementation CCReuseGrid
-
-+(id)actionWithTimes:(int)times
-{
- return [[[self alloc] initWithTimes:times ] autorelease];
-}
-
--(id)initWithTimes:(int)times
-{
- if ( (self = [super init]) )
- t = times;
-
- return self;
-}
-
--(void)startWithTarget:(id)aTarget
-{
- [super startWithTarget:aTarget];
-
- CCNode *myTarget = (CCNode*) [self target];
- if ( myTarget.grid && myTarget.grid.active )
- myTarget.grid.reuseGrid += t;
-}
-
-@end
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (c) 2009 On-Core
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-
-#import "CCActionGrid.h"
-
-/** CCWaves3D action */
-@interface CCWaves3D : CCGrid3DAction
-{
- int waves;
- float amplitude;
- float amplitudeRate;
-}
-
-/** amplitude of the wave */
-@property (nonatomic,readwrite) float amplitude;
-/** amplitude rate of the wave */
-@property (nonatomic,readwrite) float amplitudeRate;
-
-+(id)actionWithWaves:(int)wav amplitude:(float)amp grid:(ccGridSize)gridSize duration:(ccTime)d;
--(id)initWithWaves:(int)wav amplitude:(float)amp grid:(ccGridSize)gridSize duration:(ccTime)d;
-
-@end
-
-////////////////////////////////////////////////////////////
-
-/** CCFlipX3D action */
-@interface CCFlipX3D : CCGrid3DAction
-{
-}
-
-/** creates the action with duration */
-+(id) actionWithDuration:(ccTime)d;
-/** initizlies the action with duration */
--(id) initWithDuration:(ccTime)d;
-
-@end
-
-////////////////////////////////////////////////////////////
-
-/** CCFlipY3D action */
-@interface CCFlipY3D : CCFlipX3D
-{
-}
-
-@end
-
-////////////////////////////////////////////////////////////
-
-/** CCLens3D action */
-@interface CCLens3D : CCGrid3DAction
-{
- CGPoint position_;
- CGPoint positionInPixels_;
- float radius_;
- float lensEffect_;
- BOOL dirty_;
-}
-
-/** lens effect. Defaults to 0.7 - 0 means no effect, 1 is very strong effect */
-@property (nonatomic,readwrite) float lensEffect;
-/** lens center position in Points */
-@property (nonatomic,readwrite) CGPoint position;
-
-/** creates the action with center position in Points, radius, a grid size and duration */
-+(id)actionWithPosition:(CGPoint)pos radius:(float)r grid:(ccGridSize)gridSize duration:(ccTime)d;
-/** initializes the action with center position in Points, radius, a grid size and duration */
--(id)initWithPosition:(CGPoint)pos radius:(float)r grid:(ccGridSize)gridSize duration:(ccTime)d;
-
-@end
-
-////////////////////////////////////////////////////////////
-
-/** CCRipple3D action */
-@interface CCRipple3D : CCGrid3DAction
-{
- CGPoint position_;
- CGPoint positionInPixels_;
- float radius_;
- int waves_;
- float amplitude_;
- float amplitudeRate_;
-}
-
-/** center position in Points */
-@property (nonatomic,readwrite) CGPoint position;
-/** amplitude */
-@property (nonatomic,readwrite) float amplitude;
-/** amplitude rate */
-@property (nonatomic,readwrite) float amplitudeRate;
-
-/** creates the action with a position in points, radius, number of waves, amplitude, a grid size and duration */
-+(id)actionWithPosition:(CGPoint)pos radius:(float)r waves:(int)wav amplitude:(float)amp grid:(ccGridSize)gridSize duration:(ccTime)d;
-/** initializes the action with a position in points, radius, number of waves, amplitude, a grid size and duration */
--(id)initWithPosition:(CGPoint)pos radius:(float)r waves:(int)wav amplitude:(float)amp grid:(ccGridSize)gridSize duration:(ccTime)d;
-
-@end
-
-////////////////////////////////////////////////////////////
-
-/** CCShaky3D action */
-@interface CCShaky3D : CCGrid3DAction
-{
- int randrange;
- BOOL shakeZ;
-}
-
-/** creates the action with a range, shake Z vertices, a grid and duration */
-+(id)actionWithRange:(int)range shakeZ:(BOOL)shakeZ grid:(ccGridSize)gridSize duration:(ccTime)d;
-/** initializes the action with a range, shake Z vertices, a grid and duration */
--(id)initWithRange:(int)range shakeZ:(BOOL)shakeZ grid:(ccGridSize)gridSize duration:(ccTime)d;
-
-@end
-
-////////////////////////////////////////////////////////////
-
-/** CCLiquid action */
-@interface CCLiquid : CCGrid3DAction
-{
- int waves;
- float amplitude;
- float amplitudeRate;
-
-}
-
-/** amplitude */
-@property (nonatomic,readwrite) float amplitude;
-/** amplitude rate */
-@property (nonatomic,readwrite) float amplitudeRate;
-
-/** creates the action with amplitude, a grid and duration */
-+(id)actionWithWaves:(int)wav amplitude:(float)amp grid:(ccGridSize)gridSize duration:(ccTime)d;
-/** initializes the action with amplitude, a grid and duration */
--(id)initWithWaves:(int)wav amplitude:(float)amp grid:(ccGridSize)gridSize duration:(ccTime)d;
-
-@end
-
-////////////////////////////////////////////////////////////
-
-/** CCWaves action */
-@interface CCWaves : CCGrid3DAction
-{
- int waves;
- float amplitude;
- float amplitudeRate;
- BOOL vertical;
- BOOL horizontal;
-}
-
-/** amplitude */
-@property (nonatomic,readwrite) float amplitude;
-/** amplitude rate */
-@property (nonatomic,readwrite) float amplitudeRate;
-
-/** initializes the action with amplitude, horizontal sin, vertical sin, a grid and duration */
-+(id)actionWithWaves:(int)wav amplitude:(float)amp horizontal:(BOOL)h vertical:(BOOL)v grid:(ccGridSize)gridSize duration:(ccTime)d;
-/** creates the action with amplitude, horizontal sin, vertical sin, a grid and duration */
--(id)initWithWaves:(int)wav amplitude:(float)amp horizontal:(BOOL)h vertical:(BOOL)v grid:(ccGridSize)gridSize duration:(ccTime)d;
-
-@end
-
-////////////////////////////////////////////////////////////
-
-/** CCTwirl action */
-@interface CCTwirl : CCGrid3DAction
-{
- CGPoint position_;
- CGPoint positionInPixels_;
- int twirls_;
- float amplitude_;
- float amplitudeRate_;
-}
-
-/** twirl center */
-@property (nonatomic,readwrite) CGPoint position;
-/** amplitude */
-@property (nonatomic,readwrite) float amplitude;
-/** amplitude rate */
-@property (nonatomic,readwrite) float amplitudeRate;
-
-/** creates the action with center position, number of twirls, amplitude, a grid size and duration */
-+(id)actionWithPosition:(CGPoint)pos twirls:(int)t amplitude:(float)amp grid:(ccGridSize)gridSize duration:(ccTime)d;
-/** initializes the action with center position, number of twirls, amplitude, a grid size and duration */
--(id)initWithPosition:(CGPoint)pos twirls:(int)t amplitude:(float)amp grid:(ccGridSize)gridSize duration:(ccTime)d;
-
-@end
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (c) 2009 On-Core
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-
-#import "CCActionGrid3D.h"
-#import "ccMacros.h"
-#import "Support/CGPointExtension.h"
-
-#pragma mark -
-#pragma mark Waves3D
-
-@implementation CCWaves3D
-
-@synthesize amplitude;
-@synthesize amplitudeRate;
-
-+(id)actionWithWaves:(int)wav amplitude:(float)amp grid:(ccGridSize)gridSize duration:(ccTime)d
-{
- return [[[self alloc] initWithWaves:wav amplitude:amp grid:gridSize duration:d] autorelease];
-}
-
--(id)initWithWaves:(int)wav amplitude:(float)amp grid:(ccGridSize)gSize duration:(ccTime)d
-{
- if ( (self = [super initWithSize:gSize duration:d]) )
- {
- waves = wav;
- amplitude = amp;
- amplitudeRate = 1.0f;
- }
-
- return self;
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCGridAction *copy = [[[self class] allocWithZone:zone] initWithWaves:waves amplitude:amplitude grid:gridSize_ duration:duration_];
- return copy;
-}
-
-
--(void)update:(ccTime)time
-{
- int i, j;
-
- for( i = 0; i < (gridSize_.x+1); i++ )
- {
- for( j = 0; j < (gridSize_.y+1); j++ )
- {
- ccVertex3F v = [self originalVertex:ccg(i,j)];
- v.z += (sinf((CGFloat)M_PI*time*waves*2 + (v.y+v.x) * .01f) * amplitude * amplitudeRate);
- [self setVertex:ccg(i,j) vertex:v];
- }
- }
-}
-@end
-
-////////////////////////////////////////////////////////////
-
-#pragma mark -
-#pragma mark FlipX3D
-
-@implementation CCFlipX3D
-
-+(id) actionWithDuration:(ccTime)d
-{
- return [[[self alloc] initWithSize:ccg(1,1) duration:d] autorelease];
-}
-
--(id) initWithDuration:(ccTime)d
-{
- return [super initWithSize:ccg(1,1) duration:d];
-}
-
--(id)initWithSize:(ccGridSize)gSize duration:(ccTime)d
-{
- if ( gSize.x != 1 || gSize.y != 1 )
- {
- [NSException raise:@"FlipX3D" format:@"Grid size must be (1,1)"];
- }
-
- return [super initWithSize:gSize duration:d];
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCGridAction *copy = [[[self class] allocWithZone:zone] initWithSize:gridSize_ duration:duration_];
- return copy;
-}
-
-
--(void)update:(ccTime)time
-{
- CGFloat angle = (CGFloat)M_PI * time; // 180 degrees
- CGFloat mz = sinf( angle );
- angle = angle / 2.0f; // x calculates degrees from 0 to 90
- CGFloat mx = cosf( angle );
-
- ccVertex3F v0, v1, v, diff;
-
- v0 = [self originalVertex:ccg(1,1)];
- v1 = [self originalVertex:ccg(0,0)];
-
- CGFloat x0 = v0.x;
- CGFloat x1 = v1.x;
- CGFloat x;
- ccGridSize a, b, c, d;
-
- if ( x0 > x1 )
- {
- // Normal Grid
- a = ccg(0,0);
- b = ccg(0,1);
- c = ccg(1,0);
- d = ccg(1,1);
- x = x0;
- }
- else
- {
- // Reversed Grid
- c = ccg(0,0);
- d = ccg(0,1);
- a = ccg(1,0);
- b = ccg(1,1);
- x = x1;
- }
-
- diff.x = ( x - x * mx );
- diff.z = fabsf( floorf( (x * mz) / 4.0f ) );
-
-// bottom-left
- v = [self originalVertex:a];
- v.x = diff.x;
- v.z += diff.z;
- [self setVertex:a vertex:v];
-
-// upper-left
- v = [self originalVertex:b];
- v.x = diff.x;
- v.z += diff.z;
- [self setVertex:b vertex:v];
-
-// bottom-right
- v = [self originalVertex:c];
- v.x -= diff.x;
- v.z -= diff.z;
- [self setVertex:c vertex:v];
-
-// upper-right
- v = [self originalVertex:d];
- v.x -= diff.x;
- v.z -= diff.z;
- [self setVertex:d vertex:v];
-}
-
-@end
-
-////////////////////////////////////////////////////////////
-
-#pragma mark -
-#pragma mark FlipY3D
-
-@implementation CCFlipY3D
-
--(void)update:(ccTime)time
-{
- CGFloat angle = (CGFloat)M_PI * time; // 180 degrees
- CGFloat mz = sinf( angle );
- angle = angle / 2.0f; // x calculates degrees from 0 to 90
- CGFloat my = cosf( angle );
-
- ccVertex3F v0, v1, v, diff;
-
- v0 = [self originalVertex:ccg(1,1)];
- v1 = [self originalVertex:ccg(0,0)];
-
- CGFloat y0 = v0.y;
- CGFloat y1 = v1.y;
- CGFloat y;
- ccGridSize a, b, c, d;
-
- if ( y0 > y1 )
- {
- // Normal Grid
- a = ccg(0,0);
- b = ccg(0,1);
- c = ccg(1,0);
- d = ccg(1,1);
- y = y0;
- }
- else
- {
- // Reversed Grid
- b = ccg(0,0);
- a = ccg(0,1);
- d = ccg(1,0);
- c = ccg(1,1);
- y = y1;
- }
-
- diff.y = y - y * my;
- diff.z = fabsf( floorf( (y * mz) / 4.0f ) );
-
- // bottom-left
- v = [self originalVertex:a];
- v.y = diff.y;
- v.z += diff.z;
- [self setVertex:a vertex:v];
-
- // upper-left
- v = [self originalVertex:b];
- v.y -= diff.y;
- v.z -= diff.z;
- [self setVertex:b vertex:v];
-
- // bottom-right
- v = [self originalVertex:c];
- v.y = diff.y;
- v.z += diff.z;
- [self setVertex:c vertex:v];
-
- // upper-right
- v = [self originalVertex:d];
- v.y -= diff.y;
- v.z -= diff.z;
- [self setVertex:d vertex:v];
-}
-
-@end
-
-////////////////////////////////////////////////////////////
-
-#pragma mark -
-#pragma mark Lens3D
-
-@implementation CCLens3D
-
-@synthesize lensEffect=lensEffect_;
-
-+(id)actionWithPosition:(CGPoint)pos radius:(float)r grid:(ccGridSize)gridSize duration:(ccTime)d
-{
- return [[[self alloc] initWithPosition:pos radius:r grid:gridSize duration:d] autorelease];
-}
-
--(id)initWithPosition:(CGPoint)pos radius:(float)r grid:(ccGridSize)gSize duration:(ccTime)d
-{
- if ( (self = [super initWithSize:gSize duration:d]) )
- {
- position_ = ccp(-1,-1);
- self.position = pos;
- radius_ = r;
- lensEffect_ = 0.7f;
- dirty_ = YES;
- }
-
- return self;
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCGridAction *copy = [[[self class] allocWithZone:zone] initWithPosition:position_ radius:radius_ grid:gridSize_ duration:duration_];
- return copy;
-}
-
--(void) setPosition:(CGPoint)pos
-{
- if( ! CGPointEqualToPoint(pos, position_) ) {
- position_ = pos;
- positionInPixels_.x = pos.x * CC_CONTENT_SCALE_FACTOR();
- positionInPixels_.y = pos.y * CC_CONTENT_SCALE_FACTOR();
-
- dirty_ = YES;
- }
-}
-
--(CGPoint) position
-{
- return position_;
-}
-
--(void)update:(ccTime)time
-{
- if ( dirty_ )
- {
- int i, j;
-
- for( i = 0; i < gridSize_.x+1; i++ )
- {
- for( j = 0; j < gridSize_.y+1; j++ )
- {
- ccVertex3F v = [self originalVertex:ccg(i,j)];
- CGPoint vect = ccpSub(positionInPixels_, ccp(v.x,v.y));
- CGFloat r = ccpLength(vect);
-
- if ( r < radius_ )
- {
- r = radius_ - r;
- CGFloat pre_log = r / radius_;
- if ( pre_log == 0 ) pre_log = 0.001f;
- float l = logf(pre_log) * lensEffect_;
- float new_r = expf( l ) * radius_;
-
- if ( ccpLength(vect) > 0 )
- {
- vect = ccpNormalize(vect);
- CGPoint new_vect = ccpMult(vect, new_r);
- v.z += ccpLength(new_vect) * lensEffect_;
- }
- }
-
- [self setVertex:ccg(i,j) vertex:v];
- }
- }
-
- dirty_ = NO;
- }
-}
-
-@end
-
-////////////////////////////////////////////////////////////
-
-#pragma mark -
-#pragma mark Ripple3D
-
-@implementation CCRipple3D
-
-@synthesize amplitude = amplitude_;
-@synthesize amplitudeRate = amplitudeRate_;
-
-+(id)actionWithPosition:(CGPoint)pos radius:(float)r waves:(int)wav amplitude:(float)amp grid:(ccGridSize)gridSize duration:(ccTime)d
-{
- return [[[self alloc] initWithPosition:pos radius:r waves:wav amplitude:amp grid:gridSize duration:d] autorelease];
-}
-
--(id)initWithPosition:(CGPoint)pos radius:(float)r waves:(int)wav amplitude:(float)amp grid:(ccGridSize)gSize duration:(ccTime)d
-{
- if ( (self = [super initWithSize:gSize duration:d]) )
- {
- self.position = pos;
- radius_ = r;
- waves_ = wav;
- amplitude_ = amp;
- amplitudeRate_ = 1.0f;
- }
-
- return self;
-}
-
--(CGPoint) position
-{
- return position_;
-}
-
--(void) setPosition:(CGPoint)pos
-{
- position_ = pos;
- positionInPixels_.x = pos.x * CC_CONTENT_SCALE_FACTOR();
- positionInPixels_.y = pos.y * CC_CONTENT_SCALE_FACTOR();
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCGridAction *copy = [[[self class] allocWithZone:zone] initWithPosition:position_ radius:radius_ waves:waves_ amplitude:amplitude_ grid:gridSize_ duration:duration_];
- return copy;
-}
-
-
--(void)update:(ccTime)time
-{
- int i, j;
-
- for( i = 0; i < (gridSize_.x+1); i++ )
- {
- for( j = 0; j < (gridSize_.y+1); j++ )
- {
- ccVertex3F v = [self originalVertex:ccg(i,j)];
- CGPoint vect = ccpSub(positionInPixels_, ccp(v.x,v.y));
- CGFloat r = ccpLength(vect);
-
- if ( r < radius_ )
- {
- r = radius_ - r;
- CGFloat rate = powf( r / radius_, 2);
- v.z += (sinf( time*(CGFloat)M_PI*waves_*2 + r * 0.1f) * amplitude_ * amplitudeRate_ * rate );
- }
-
- [self setVertex:ccg(i,j) vertex:v];
- }
- }
-}
-
-@end
-
-////////////////////////////////////////////////////////////
-
-#pragma mark -
-#pragma mark Shaky3D
-
-@implementation CCShaky3D
-
-+(id)actionWithRange:(int)range shakeZ:(BOOL)sz grid:(ccGridSize)gridSize duration:(ccTime)d
-{
- return [[[self alloc] initWithRange:range shakeZ:sz grid:gridSize duration:d] autorelease];
-}
-
--(id)initWithRange:(int)range shakeZ:(BOOL)sz grid:(ccGridSize)gSize duration:(ccTime)d
-{
- if ( (self = [super initWithSize:gSize duration:d]) )
- {
- randrange = range;
- shakeZ = sz;
- }
-
- return self;
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCGridAction *copy = [[[self class] allocWithZone:zone] initWithRange:randrange shakeZ:shakeZ grid:gridSize_ duration:duration_];
- return copy;
-}
-
--(void)update:(ccTime)time
-{
- int i, j;
-
- for( i = 0; i < (gridSize_.x+1); i++ )
- {
- for( j = 0; j < (gridSize_.y+1); j++ )
- {
- ccVertex3F v = [self originalVertex:ccg(i,j)];
- v.x += ( rand() % (randrange*2) ) - randrange;
- v.y += ( rand() % (randrange*2) ) - randrange;
- if( shakeZ )
- v.z += ( rand() % (randrange*2) ) - randrange;
-
- [self setVertex:ccg(i,j) vertex:v];
- }
- }
-}
-
-@end
-
-////////////////////////////////////////////////////////////
-
-#pragma mark -
-#pragma mark Liquid
-
-@implementation CCLiquid
-
-@synthesize amplitude;
-@synthesize amplitudeRate;
-
-+(id)actionWithWaves:(int)wav amplitude:(float)amp grid:(ccGridSize)gridSize duration:(ccTime)d
-{
- return [[[self alloc] initWithWaves:wav amplitude:amp grid:gridSize duration:d] autorelease];
-}
-
--(id)initWithWaves:(int)wav amplitude:(float)amp grid:(ccGridSize)gSize duration:(ccTime)d
-{
- if ( (self = [super initWithSize:gSize duration:d]) )
- {
- waves = wav;
- amplitude = amp;
- amplitudeRate = 1.0f;
- }
-
- return self;
-}
-
--(void)update:(ccTime)time
-{
- int i, j;
-
- for( i = 1; i < gridSize_.x; i++ )
- {
- for( j = 1; j < gridSize_.y; j++ )
- {
- ccVertex3F v = [self originalVertex:ccg(i,j)];
- v.x = (v.x + (sinf(time*(CGFloat)M_PI*waves*2 + v.x * .01f) * amplitude * amplitudeRate));
- v.y = (v.y + (sinf(time*(CGFloat)M_PI*waves*2 + v.y * .01f) * amplitude * amplitudeRate));
- [self setVertex:ccg(i,j) vertex:v];
- }
- }
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCGridAction *copy = [[[self class] allocWithZone:zone] initWithWaves:waves amplitude:amplitude grid:gridSize_ duration:duration_];
- return copy;
-}
-
-@end
-
-////////////////////////////////////////////////////////////
-
-#pragma mark -
-#pragma mark Waves
-
-@implementation CCWaves
-
-@synthesize amplitude;
-@synthesize amplitudeRate;
-
-+(id)actionWithWaves:(int)wav amplitude:(float)amp horizontal:(BOOL)h vertical:(BOOL)v grid:(ccGridSize)gridSize duration:(ccTime)d
-{
- return [[[self alloc] initWithWaves:wav amplitude:amp horizontal:h vertical:v grid:gridSize duration:d] autorelease];
-}
-
--(id)initWithWaves:(int)wav amplitude:(float)amp horizontal:(BOOL)h vertical:(BOOL)v grid:(ccGridSize)gSize duration:(ccTime)d
-{
- if ( (self = [super initWithSize:gSize duration:d]) )
- {
- waves = wav;
- amplitude = amp;
- amplitudeRate = 1.0f;
- horizontal = h;
- vertical = v;
- }
-
- return self;
-}
-
--(void)update:(ccTime)time
-{
- int i, j;
-
- for( i = 0; i < (gridSize_.x+1); i++ )
- {
- for( j = 0; j < (gridSize_.y+1); j++ )
- {
- ccVertex3F v = [self originalVertex:ccg(i,j)];
-
- if ( vertical )
- v.x = (v.x + (sinf(time*(CGFloat)M_PI*waves*2 + v.y * .01f) * amplitude * amplitudeRate));
-
- if ( horizontal )
- v.y = (v.y + (sinf(time*(CGFloat)M_PI*waves*2 + v.x * .01f) * amplitude * amplitudeRate));
-
- [self setVertex:ccg(i,j) vertex:v];
- }
- }
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCGridAction *copy = [[[self class] allocWithZone:zone] initWithWaves:waves amplitude:amplitude horizontal:horizontal vertical:vertical grid:gridSize_ duration:duration_];
- return copy;
-}
-
-@end
-
-////////////////////////////////////////////////////////////
-
-#pragma mark -
-#pragma mark Twirl
-
-@implementation CCTwirl
-
-@synthesize amplitude = amplitude_;
-@synthesize amplitudeRate = amplitudeRate_;
-
-+(id)actionWithPosition:(CGPoint)pos twirls:(int)t amplitude:(float)amp grid:(ccGridSize)gridSize duration:(ccTime)d
-{
- return [[[self alloc] initWithPosition:pos twirls:t amplitude:amp grid:gridSize duration:d] autorelease];
-}
-
--(id)initWithPosition:(CGPoint)pos twirls:(int)t amplitude:(float)amp grid:(ccGridSize)gSize duration:(ccTime)d
-{
- if ( (self = [super initWithSize:gSize duration:d]) )
- {
- self.position = pos;
- twirls_ = t;
- amplitude_ = amp;
- amplitudeRate_ = 1.0f;
- }
-
- return self;
-}
-
--(void) setPosition:(CGPoint)pos
-{
- position_ = pos;
- positionInPixels_.x = pos.x * CC_CONTENT_SCALE_FACTOR();
- positionInPixels_.y = pos.y * CC_CONTENT_SCALE_FACTOR();
-}
-
--(CGPoint) position
-{
- return position_;
-}
-
--(void)update:(ccTime)time
-{
- int i, j;
- CGPoint c = positionInPixels_;
-
- for( i = 0; i < (gridSize_.x+1); i++ )
- {
- for( j = 0; j < (gridSize_.y+1); j++ )
- {
- ccVertex3F v = [self originalVertex:ccg(i,j)];
-
- CGPoint avg = ccp(i-(gridSize_.x/2.0f), j-(gridSize_.y/2.0f));
- CGFloat r = ccpLength( avg );
-
- CGFloat amp = 0.1f * amplitude_ * amplitudeRate_;
- CGFloat a = r * cosf( (CGFloat)M_PI/2.0f + time * (CGFloat)M_PI * twirls_ * 2 ) * amp;
-
- float cosA = cosf(a);
- float sinA = sinf(a);
-
- CGPoint d = {
- sinA * (v.y-c.y) + cosA * (v.x-c.x),
- cosA * (v.y-c.y) - sinA * (v.x-c.x)
- };
-
- v.x = c.x + d.x;
- v.y = c.y + d.y;
-
- [self setVertex:ccg(i,j) vertex:v];
- }
- }
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCGridAction *copy = [[[self class] allocWithZone:zone] initWithPosition:position_
- twirls:twirls_
- amplitude:amplitude_
- grid:gridSize_
- duration:duration_];
- return copy;
-}
-
-
-@end
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (c) 2008-2010 Ricardo Quesada
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-
-#import "CCAction.h"
-
-/** Instant actions are immediate actions. They don't have a duration like
- the CCIntervalAction actions.
-*/
-@interface CCActionInstant : CCFiniteTimeAction <NSCopying>
-{
-}
-@end
-
-/** Show the node
- */
- @interface CCShow : CCActionInstant
-{
-}
-@end
-
-/** Hide the node
- */
-@interface CCHide : CCActionInstant
-{
-}
-@end
-
-/** Toggles the visibility of a node
- */
-@interface CCToggleVisibility : CCActionInstant
-{
-}
-@end
-
-/** Flips the sprite horizontally
- @since v0.99.0
- */
-@interface CCFlipX : CCActionInstant
-{
- BOOL flipX;
-}
-+(id) actionWithFlipX:(BOOL)x;
--(id) initWithFlipX:(BOOL)x;
-@end
-
-/** Flips the sprite vertically
- @since v0.99.0
- */
-@interface CCFlipY : CCActionInstant
-{
- BOOL flipY;
-}
-+(id) actionWithFlipY:(BOOL)y;
--(id) initWithFlipY:(BOOL)y;
-@end
-
-/** Places the node in a certain position
- */
-@interface CCPlace : CCActionInstant <NSCopying>
-{
- CGPoint position;
-}
-/** creates a Place action with a position */
-+(id) actionWithPosition: (CGPoint) pos;
-/** Initializes a Place action with a position */
--(id) initWithPosition: (CGPoint) pos;
-@end
-
-/** Calls a 'callback'
- */
-@interface CCCallFunc : CCActionInstant <NSCopying>
-{
- id targetCallback_;
- SEL selector_;
-}
-/** creates the action with the callback */
-+(id) actionWithTarget: (id) t selector:(SEL) s;
-/** initializes the action with the callback */
--(id) initWithTarget: (id) t selector:(SEL) s;
-/** exeuctes the callback */
--(void) execute;
-@end
-
-/** Calls a 'callback' with the node as the first argument.
- N means Node
- */
-@interface CCCallFuncN : CCCallFunc
-{
-}
-@end
-
-typedef void (*CC_CALLBACK_ND)(id, SEL, id, void *);
-/** Calls a 'callback' with the node as the first argument and the 2nd argument is data.
- * ND means: Node and Data. Data is void *, so it could be anything.
- */
-@interface CCCallFuncND : CCCallFuncN
-{
- void *data_;
- CC_CALLBACK_ND callbackMethod_;
-}
-
-/** Invocation object that has the target#selector and the parameters */
-@property (nonatomic,readwrite) CC_CALLBACK_ND callbackMethod;
-
-/** creates the action with the callback and the data to pass as an argument */
-+(id) actionWithTarget: (id) t selector:(SEL) s data:(void*)d;
-/** initializes the action with the callback and the data to pass as an argument */
--(id) initWithTarget:(id) t selector:(SEL) s data:(void*) d;
-@end
-
-/** Calls a 'callback' with an object as the first argument.
- O means Object.
- @since v0.99.5
- */
-@interface CCCallFuncO : CCCallFunc
-{
- id object_;
-}
-/** creates the action with the callback and the object to pass as an argument */
-+(id) actionWithTarget: (id) t selector:(SEL) s object:(id)object;
-/** initializes the action with the callback and the object to pass as an argument */
--(id) initWithTarget:(id) t selector:(SEL) s object:(id)object;
-
-@end
-
-#pragma mark Blocks Support
-
-#if NS_BLOCKS_AVAILABLE
-
-/** Executes a callback using a block.
- */
-@interface CCCallBlock : CCActionInstant<NSCopying>
-{
- void (^block_)();
-}
-
-/** creates the action with the specified block, to be used as a callback.
- The block will be "copied".
- */
-+(id) actionWithBlock:(void(^)())block;
-
-/** initialized the action with the specified block, to be used as a callback.
- The block will be "copied".
- */
--(id) initWithBlock:(void(^)())block;
-
-/** executes the callback */
--(void) execute;
-@end
-
-@class CCNode;
-
-/** Executes a callback using a block with a single CCNode parameter.
- */
-@interface CCCallBlockN : CCActionInstant<NSCopying>
-{
- void (^block_)(CCNode *);
-}
-
-/** creates the action with the specified block, to be used as a callback.
- The block will be "copied".
- */
-+(id) actionWithBlock:(void(^)(CCNode *node))block;
-
-/** initialized the action with the specified block, to be used as a callback.
- The block will be "copied".
- */
--(id) initWithBlock:(void(^)(CCNode *node))block;
-
-/** executes the callback */
--(void) execute;
-@end
-
-#endif
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (c) 2008-2010 Ricardo Quesada
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-
-#import "CCBlockSupport.h"
-#import "CCActionInstant.h"
-#import "CCNode.h"
-#import "CCSprite.h"
-
-
-//
-// InstantAction
-//
-#pragma mark CCActionInstant
-
-@implementation CCActionInstant
-
--(id) init
-{
- if( (self=[super init]) )
- duration_ = 0;
-
- return self;
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCActionInstant *copy = [[[self class] allocWithZone: zone] init];
- return copy;
-}
-
-- (BOOL) isDone
-{
- return YES;
-}
-
--(void) step: (ccTime) dt
-{
- [self update: 1];
-}
-
--(void) update: (ccTime) t
-{
- // ignore
-}
-
--(CCFiniteTimeAction*) reverse
-{
- return [[self copy] autorelease];
-}
-@end
-
-//
-// Show
-//
-#pragma mark CCShow
-
-@implementation CCShow
--(void) startWithTarget:(id)aTarget
-{
- [super startWithTarget:aTarget];
- ((CCNode *)target_).visible = YES;
-}
-
--(CCFiniteTimeAction*) reverse
-{
- return [CCHide action];
-}
-@end
-
-//
-// Hide
-//
-#pragma mark CCHide
-
-@implementation CCHide
--(void) startWithTarget:(id)aTarget
-{
- [super startWithTarget:aTarget];
- ((CCNode *)target_).visible = NO;
-}
-
--(CCFiniteTimeAction*) reverse
-{
- return [CCShow action];
-}
-@end
-
-//
-// ToggleVisibility
-//
-#pragma mark CCToggleVisibility
-
-@implementation CCToggleVisibility
--(void) startWithTarget:(id)aTarget
-{
- [super startWithTarget:aTarget];
- ((CCNode *)target_).visible = !((CCNode *)target_).visible;
-}
-@end
-
-//
-// FlipX
-//
-#pragma mark CCFlipX
-
-@implementation CCFlipX
-+(id) actionWithFlipX:(BOOL)x
-{
- return [[[self alloc] initWithFlipX:x] autorelease];
-}
-
--(id) initWithFlipX:(BOOL)x
-{
- if(( self=[super init]))
- flipX = x;
-
- return self;
-}
-
--(void) startWithTarget:(id)aTarget
-{
- [super startWithTarget:aTarget];
- [(CCSprite*)aTarget setFlipX:flipX];
-}
-
--(CCFiniteTimeAction*) reverse
-{
- return [CCFlipX actionWithFlipX:!flipX];
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCActionInstant *copy = [[[self class] allocWithZone: zone] initWithFlipX:flipX];
- return copy;
-}
-@end
-
-//
-// FlipY
-//
-#pragma mark CCFlipY
-
-@implementation CCFlipY
-+(id) actionWithFlipY:(BOOL)y
-{
- return [[[self alloc] initWithFlipY:y] autorelease];
-}
-
--(id) initWithFlipY:(BOOL)y
-{
- if(( self=[super init]))
- flipY = y;
-
- return self;
-}
-
--(void) startWithTarget:(id)aTarget
-{
- [super startWithTarget:aTarget];
- [(CCSprite*)aTarget setFlipY:flipY];
-}
-
--(CCFiniteTimeAction*) reverse
-{
- return [CCFlipY actionWithFlipY:!flipY];
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCActionInstant *copy = [[[self class] allocWithZone: zone] initWithFlipY:flipY];
- return copy;
-}
-@end
-
-
-//
-// Place
-//
-#pragma mark CCPlace
-
-@implementation CCPlace
-+(id) actionWithPosition: (CGPoint) pos
-{
- return [[[self alloc]initWithPosition:pos]autorelease];
-}
-
--(id) initWithPosition: (CGPoint) pos
-{
- if( (self=[super init]) )
- position = pos;
-
- return self;
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCActionInstant *copy = [[[self class] allocWithZone: zone] initWithPosition: position];
- return copy;
-}
-
--(void) startWithTarget:(id)aTarget
-{
- [super startWithTarget:aTarget];
- ((CCNode *)target_).position = position;
-}
-
-@end
-
-//
-// CallFunc
-//
-#pragma mark CCCallFunc
-
-@implementation CCCallFunc
-+(id) actionWithTarget: (id) t selector:(SEL) s
-{
- return [[[self alloc] initWithTarget: t selector: s] autorelease];
-}
-
--(id) initWithTarget: (id) t selector:(SEL) s
-{
- if( (self=[super init]) ) {
- targetCallback_ = [t retain];
- selector_ = s;
- }
- return self;
-}
-
--(NSString*) description
-{
- return [NSString stringWithFormat:@"<%@ = %08X | Tag = %i | target = %@ | selector = %@>",
- [self class],
- self,
- tag_,
- [targetCallback_ class],
- NSStringFromSelector(selector_)
- ];
-}
-
--(void) dealloc
-{
- [targetCallback_ release];
- [super dealloc];
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCActionInstant *copy = [[[self class] allocWithZone: zone] initWithTarget:targetCallback_ selector:selector_];
- return copy;
-}
-
--(void) startWithTarget:(id)aTarget
-{
- [super startWithTarget:aTarget];
- [self execute];
-}
-
--(void) execute
-{
- [targetCallback_ performSelector:selector_];
-}
-@end
-
-//
-// CallFuncN
-//
-#pragma mark CCCallFuncN
-
-@implementation CCCallFuncN
-
--(void) execute
-{
- [targetCallback_ performSelector:selector_ withObject:target_];
-}
-@end
-
-//
-// CallFuncND
-//
-#pragma mark CCCallFuncND
-
-@implementation CCCallFuncND
-
-@synthesize callbackMethod = callbackMethod_;
-
-+(id) actionWithTarget:(id)t selector:(SEL)s data:(void*)d
-{
- return [[[self alloc] initWithTarget:t selector:s data:d] autorelease];
-}
-
--(id) initWithTarget:(id)t selector:(SEL)s data:(void*)d
-{
- if( (self=[super initWithTarget:t selector:s]) ) {
- data_ = d;
-
-#if COCOS2D_DEBUG
- NSMethodSignature * sig = [t methodSignatureForSelector:s]; // added
- NSAssert(sig !=0 , @"Signature not found for selector - does it have the following form? -(void)name:(id)sender data:(void*)data");
-#endif
- callbackMethod_ = (CC_CALLBACK_ND) [t methodForSelector:s];
- }
- return self;
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCActionInstant *copy = [[[self class] allocWithZone: zone] initWithTarget:targetCallback_ selector:selector_ data:data_];
- return copy;
-}
-
--(void) dealloc
-{
- // nothing to dealloc really. Everything is dealloc on super (CCCallFuncN)
- [super dealloc];
-}
-
--(void) execute
-{
- callbackMethod_(targetCallback_,selector_,target_, data_);
-}
-@end
-
-@implementation CCCallFuncO
-
-+(id) actionWithTarget: (id) t selector:(SEL) s object:(id)object
-{
- return [[[self alloc] initWithTarget:t selector:s object:object] autorelease];
-}
-
--(id) initWithTarget:(id) t selector:(SEL) s object:(id)object
-{
- if( (self=[super initWithTarget:t selector:s] ) )
- object_ = [object retain];
-
- return self;
-}
-
-- (void) dealloc
-{
- [object_ release];
- [super dealloc];
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCActionInstant *copy = [[[self class] allocWithZone: zone] initWithTarget:targetCallback_ selector:selector_ object:object_];
- return copy;
-}
-
-
--(void) execute
-{
- [targetCallback_ performSelector:selector_ withObject:object_];
-}
-
-@end
-
-
-#pragma mark -
-#pragma mark Blocks
-
-#if NS_BLOCKS_AVAILABLE
-
-#pragma mark CCCallBlock
-
-@implementation CCCallBlock
-
-+(id) actionWithBlock:(void(^)())block
-{
- return [[[self alloc] initWithBlock:block] autorelease];
-}
-
--(id) initWithBlock:(void(^)())block
-{
- if ((self = [super init]))
- block_ = [block copy];
-
- return self;
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCActionInstant *copy = [[[self class] allocWithZone: zone] initWithBlock:block_];
- return copy;
-}
-
--(void) startWithTarget:(id)aTarget
-{
- [super startWithTarget:aTarget];
- [self execute];
-}
-
--(void) execute
-{
- block_();
-}
-
--(void) dealloc
-{
- [block_ release];
- [super dealloc];
-}
-
-@end
-
-#pragma mark CCCallBlockN
-
-@implementation CCCallBlockN
-
-+(id) actionWithBlock:(void(^)(CCNode *node))block
-{
- return [[[self alloc] initWithBlock:block] autorelease];
-}
-
--(id) initWithBlock:(void(^)(CCNode *node))block
-{
- if ((self = [super init]))
- block_ = [block copy];
-
- return self;
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCActionInstant *copy = [[[self class] allocWithZone: zone] initWithBlock:block_];
- return copy;
-}
-
--(void) startWithTarget:(id)aTarget
-{
- [super startWithTarget:aTarget];
- [self execute];
-}
-
--(void) execute
-{
- block_(target_);
-}
-
--(void) dealloc
-{
- [block_ release];
- [super dealloc];
-}
-
-@end
-
-
-#endif // NS_BLOCKS_AVAILABLE
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (c) 2008-2010 Ricardo Quesada
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-
-#import "CCNode.h"
-#import "CCAction.h"
-#import "CCProtocols.h"
-
-#include <sys/time.h>
-
-/** An interval action is an action that takes place within a certain period of time.
-It has an start time, and a finish time. The finish time is the parameter
-duration plus the start time.
-
-These CCActionInterval actions have some interesting properties, like:
- - They can run normally (default)
- - They can run reversed with the reverse method
- - They can run with the time altered with the Accelerate, AccelDeccel and Speed actions.
-
-For example, you can simulate a Ping Pong effect running the action normally and
-then running it again in Reverse mode.
-
-Example:
-
- CCAction * pingPongAction = [CCSequence actions: action, [action reverse], nil];
-*/
-@interface CCActionInterval: CCFiniteTimeAction <NSCopying>
-{
- ccTime elapsed_;
- BOOL firstTick_;
-}
-
-/** how many seconds had elapsed since the actions started to run. */
-@property (nonatomic,readonly) ccTime elapsed;
-
-/** creates the action */
-+(id) actionWithDuration: (ccTime) d;
-/** initializes the action */
--(id) initWithDuration: (ccTime) d;
-/** returns YES if the action has finished */
--(BOOL) isDone;
-/** returns a reversed action */
-- (CCActionInterval*) reverse;
-@end
-
-/** Runs actions sequentially, one after another
- */
-@interface CCSequence : CCActionInterval <NSCopying>
-{
- CCFiniteTimeAction *actions[2];
- ccTime split;
- int last;
-}
-/** helper contructor to create an array of sequenceable actions */
-+(id) actions: (CCFiniteTimeAction*) action1, ... NS_REQUIRES_NIL_TERMINATION;
-/** creates the action */
-+(id) actionOne:(CCFiniteTimeAction*)actionOne two:(CCFiniteTimeAction*)actionTwo;
-/** initializes the action */
--(id) initOne:(CCFiniteTimeAction*)actionOne two:(CCFiniteTimeAction*)actionTwo;
-@end
-
-
-/** Repeats an action a number of times.
- * To repeat an action forever use the CCRepeatForever action.
- */
-@interface CCRepeat : CCActionInterval <NSCopying>
-{
- unsigned int times_;
- unsigned int total_;
- CCFiniteTimeAction *other_;
-}
-/** creates a CCRepeat action. Times is an unsigned integer between 1 and pow(2,30) */
-+(id) actionWithAction:(CCFiniteTimeAction*)action times: (unsigned int)times;
-/** initializes a CCRepeat action. Times is an unsigned integer between 1 and pow(2,30) */
--(id) initWithAction:(CCFiniteTimeAction*)action times: (unsigned int)times;
-@end
-
-/** Spawn a new action immediately
- */
-@interface CCSpawn : CCActionInterval <NSCopying>
-{
- CCFiniteTimeAction *one;
- CCFiniteTimeAction *two;
-}
-/** helper constructor to create an array of spawned actions */
-+(id) actions: (CCFiniteTimeAction*) action1, ... NS_REQUIRES_NIL_TERMINATION;
-/** creates the Spawn action */
-+(id) actionOne: (CCFiniteTimeAction*) one two:(CCFiniteTimeAction*) two;
-/** initializes the Spawn action with the 2 actions to spawn */
--(id) initOne: (CCFiniteTimeAction*) one two:(CCFiniteTimeAction*) two;
-@end
-
-/** Rotates a CCNode object to a certain angle by modifying it's
- rotation attribute.
- The direction will be decided by the shortest angle.
-*/
-@interface CCRotateTo : CCActionInterval <NSCopying>
-{
- float dstAngle;
- float startAngle;
- float diffAngle;
-}
-/** creates the action */
-+(id) actionWithDuration:(ccTime)duration angle:(float)angle;
-/** initializes the action */
--(id) initWithDuration:(ccTime)duration angle:(float)angle;
-@end
-
-/** Rotates a CCNode object clockwise a number of degrees by modiying it's rotation attribute.
-*/
-@interface CCRotateBy : CCActionInterval <NSCopying>
-{
- float angle;
- float startAngle;
-}
-/** creates the action */
-+(id) actionWithDuration:(ccTime)duration angle:(float)deltaAngle;
-/** initializes the action */
--(id) initWithDuration:(ccTime)duration angle:(float)deltaAngle;
-@end
-
-/** Moves a CCNode object to the position x,y. x and y are absolute coordinates by modifying it's position attribute.
-*/
-@interface CCMoveTo : CCActionInterval <NSCopying>
-{
- CGPoint endPosition;
- CGPoint startPosition;
- CGPoint delta;
-}
-/** creates the action */
-+(id) actionWithDuration:(ccTime)duration position:(CGPoint)position;
-/** initializes the action */
--(id) initWithDuration:(ccTime)duration position:(CGPoint)position;
-@end
-
-/** Moves a CCNode object x,y pixels by modifying it's position attribute.
- x and y are relative to the position of the object.
- Duration is is seconds.
-*/
-@interface CCMoveBy : CCMoveTo <NSCopying>
-{
-}
-/** creates the action */
-+(id) actionWithDuration: (ccTime)duration position:(CGPoint)deltaPosition;
-/** initializes the action */
--(id) initWithDuration: (ccTime)duration position:(CGPoint)deltaPosition;
-@end
-
-/** Moves a CCNode object simulating a parabolic jump movement by modifying it's position attribute.
-*/
- @interface CCJumpBy : CCActionInterval <NSCopying>
-{
- CGPoint startPosition;
- CGPoint delta;
- ccTime height;
- int jumps;
-}
-/** creates the action */
-+(id) actionWithDuration: (ccTime)duration position:(CGPoint)position height:(ccTime)height jumps:(int)jumps;
-/** initializes the action */
--(id) initWithDuration: (ccTime)duration position:(CGPoint)position height:(ccTime)height jumps:(int)jumps;
-@end
-
-/** Moves a CCNode object to a parabolic position simulating a jump movement by modifying it's position attribute.
-*/
- @interface CCJumpTo : CCJumpBy <NSCopying>
-{
-}
-@end
-
-/** bezier configuration structure
- */
-typedef struct _ccBezierConfig {
- //! end position of the bezier
- CGPoint endPosition;
- //! Bezier control point 1
- CGPoint controlPoint_1;
- //! Bezier control point 2
- CGPoint controlPoint_2;
-} ccBezierConfig;
-
-/** An action that moves the target with a cubic Bezier curve by a certain distance.
- */
-@interface CCBezierBy : CCActionInterval <NSCopying>
-{
- ccBezierConfig config;
- CGPoint startPosition;
-}
-
-/** creates the action with a duration and a bezier configuration */
-+(id) actionWithDuration: (ccTime) t bezier:(ccBezierConfig) c;
-
-/** initializes the action with a duration and a bezier configuration */
--(id) initWithDuration: (ccTime) t bezier:(ccBezierConfig) c;
-@end
-
-/** An action that moves the target with a cubic Bezier curve to a destination point.
- @since v0.8.2
- */
-@interface CCBezierTo : CCBezierBy
-{
-}
-@end
-
-/** Scales a CCNode object to a zoom factor by modifying it's scale attribute.
- @warning This action doesn't support "reverse"
- */
-@interface CCScaleTo : CCActionInterval <NSCopying>
-{
- float scaleX;
- float scaleY;
- float startScaleX;
- float startScaleY;
- float endScaleX;
- float endScaleY;
- float deltaX;
- float deltaY;
-}
-/** creates the action with the same scale factor for X and Y */
-+(id) actionWithDuration: (ccTime)duration scale:(float) s;
-/** initializes the action with the same scale factor for X and Y */
--(id) initWithDuration: (ccTime)duration scale:(float) s;
-/** creates the action with and X factor and a Y factor */
-+(id) actionWithDuration: (ccTime)duration scaleX:(float) sx scaleY:(float)sy;
-/** initializes the action with and X factor and a Y factor */
--(id) initWithDuration: (ccTime)duration scaleX:(float) sx scaleY:(float)sy;
-@end
-
-/** Scales a CCNode object a zoom factor by modifying it's scale attribute.
-*/
-@interface CCScaleBy : CCScaleTo <NSCopying>
-{
-}
-@end
-
-/** Blinks a CCNode object by modifying it's visible attribute
-*/
-@interface CCBlink : CCActionInterval <NSCopying>
-{
- int times;
-}
-/** creates the action */
-+(id) actionWithDuration: (ccTime)duration blinks:(unsigned int)blinks;
-/** initilizes the action */
--(id) initWithDuration: (ccTime)duration blinks:(unsigned int)blinks;
-@end
-
-/** Fades In an object that implements the CCRGBAProtocol protocol. It modifies the opacity from 0 to 255.
- The "reverse" of this action is FadeOut
- */
-@interface CCFadeIn : CCActionInterval <NSCopying>
-{
-}
-@end
-
-/** Fades Out an object that implements the CCRGBAProtocol protocol. It modifies the opacity from 255 to 0.
- The "reverse" of this action is FadeIn
-*/
-@interface CCFadeOut : CCActionInterval <NSCopying>
-{
-}
-@end
-
-/** Fades an object that implements the CCRGBAProtocol protocol. It modifies the opacity from the current value to a custom one.
- @warning This action doesn't support "reverse"
- */
-@interface CCFadeTo : CCActionInterval <NSCopying>
-{
- GLubyte toOpacity;
- GLubyte fromOpacity;
-}
-/** creates an action with duration and opactiy */
-+(id) actionWithDuration:(ccTime)duration opacity:(GLubyte)opactiy;
-/** initializes the action with duration and opacity */
--(id) initWithDuration:(ccTime)duration opacity:(GLubyte)opacity;
-@end
-
-/** Tints a CCNode that implements the CCNodeRGB protocol from current tint to a custom one.
- @warning This action doesn't support "reverse"
- @since v0.7.2
-*/
-@interface CCTintTo : CCActionInterval <NSCopying>
-{
- ccColor3B to;
- ccColor3B from;
-}
-/** creates an action with duration and color */
-+(id) actionWithDuration:(ccTime)duration red:(GLubyte)red green:(GLubyte)green blue:(GLubyte)blue;
-/** initializes the action with duration and color */
--(id) initWithDuration:(ccTime)duration red:(GLubyte)red green:(GLubyte)green blue:(GLubyte)blue;
-@end
-
-/** Tints a CCNode that implements the CCNodeRGB protocol from current tint to a custom one.
- @since v0.7.2
- */
-@interface CCTintBy : CCActionInterval <NSCopying>
-{
- GLshort deltaR, deltaG, deltaB;
- GLshort fromR, fromG, fromB;
-}
-/** creates an action with duration and color */
-+(id) actionWithDuration:(ccTime)duration red:(GLshort)deltaRed green:(GLshort)deltaGreen blue:(GLshort)deltaBlue;
-/** initializes the action with duration and color */
--(id) initWithDuration:(ccTime)duration red:(GLshort)deltaRed green:(GLshort)deltaGreen blue:(GLshort)deltaBlue;
-@end
-
-/** Delays the action a certain amount of seconds
-*/
-@interface CCDelayTime : CCActionInterval <NSCopying>
-{
-}
-@end
-
-/** Executes an action in reverse order, from time=duration to time=0
-
- @warning Use this action carefully. This action is not
- sequenceable. Use it as the default "reversed" method
- of your own actions, but using it outside the "reversed"
- scope is not recommended.
-*/
-@interface CCReverseTime : CCActionInterval <NSCopying>
-{
- CCFiniteTimeAction * other;
-}
-/** creates the action */
-+(id) actionWithAction: (CCFiniteTimeAction*) action;
-/** initializes the action */
--(id) initWithAction: (CCFiniteTimeAction*) action;
-@end
-
-
-@class CCAnimation;
-@class CCTexture2D;
-/** Animates a sprite given the name of an Animation */
-@interface CCAnimate : CCActionInterval <NSCopying>
-{
- CCAnimation *animation_;
- id origFrame;
- BOOL restoreOriginalFrame;
-}
-/** animation used for the animage */
-@property (readwrite,nonatomic,retain) CCAnimation * animation;
-
-/** creates the action with an Animation and will restore the original frame when the animation is over */
-+(id) actionWithAnimation:(CCAnimation*) a;
-/** initializes the action with an Animation and will restore the original frame when the animtion is over */
--(id) initWithAnimation:(CCAnimation*) a;
-/** creates the action with an Animation */
-+(id) actionWithAnimation:(CCAnimation*) a restoreOriginalFrame:(BOOL)b;
-/** initializes the action with an Animation */
--(id) initWithAnimation:(CCAnimation*) a restoreOriginalFrame:(BOOL)b;
-/** creates an action with a duration, animation and depending of the restoreOriginalFrame, it will restore the original frame or not.
- The 'delay' parameter of the animation will be overrided by the duration parameter.
- @since v0.99.0
- */
-+(id) actionWithDuration:(ccTime)duration animation:(CCAnimation*)animation restoreOriginalFrame:(BOOL)b;
-/** initializes an action with a duration, animation and depending of the restoreOriginalFrame, it will restore the original frame or not.
- The 'delay' parameter of the animation will be overrided by the duration parameter.
- @since v0.99.0
- */
--(id) initWithDuration:(ccTime)duration animation:(CCAnimation*)animation restoreOriginalFrame:(BOOL)b;
-@end
\ No newline at end of file
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (c) 2008-2010 Ricardo Quesada
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-
-
-#import "CCActionInterval.h"
-#import "CCSprite.h"
-#import "CCSpriteFrame.h"
-#import "CCAnimation.h"
-#import "CCNode.h"
-#import "Support/CGPointExtension.h"
-
-//
-// IntervalAction
-//
-#pragma mark -
-#pragma mark IntervalAction
-@implementation CCActionInterval
-
-@synthesize elapsed = elapsed_;
-
--(id) init
-{
- NSAssert(NO, @"IntervalActionInit: Init not supported. Use InitWithDuration");
- [self release];
- return nil;
-}
-
-+(id) actionWithDuration: (ccTime) d
-{
- return [[[self alloc] initWithDuration:d ] autorelease];
-}
-
--(id) initWithDuration: (ccTime) d
-{
- if( (self=[super init]) ) {
- duration_ = d;
-
- // prevent division by 0
- // This comparison could be in step:, but it might decrease the performance
- // by 3% in heavy based action games.
- if( duration_ == 0 )
- duration_ = FLT_EPSILON;
- elapsed_ = 0;
- firstTick_ = YES;
- }
- return self;
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCAction *copy = [[[self class] allocWithZone: zone] initWithDuration: [self duration] ];
- return copy;
-}
-
-- (BOOL) isDone
-{
- return (elapsed_ >= duration_);
-}
-
--(void) step: (ccTime) dt
-{
- if( firstTick_ ) {
- firstTick_ = NO;
- elapsed_ = 0;
- } else
- elapsed_ += dt;
-
- [self update: MIN(1, elapsed_/duration_)];
-}
-
--(void) startWithTarget:(id)aTarget
-{
- [super startWithTarget:aTarget];
- elapsed_ = 0.0f;
- firstTick_ = YES;
-}
-
-- (CCActionInterval*) reverse
-{
- NSAssert(NO, @"CCIntervalAction: reverse not implemented.");
- return nil;
-}
-@end
-
-//
-// Sequence
-//
-#pragma mark -
-#pragma mark Sequence
-@implementation CCSequence
-+(id) actionOne: (CCFiniteTimeAction*) one two: (CCFiniteTimeAction*) two
-{
- return [[[self alloc] initOne:one two:two ] autorelease];
-}
-
-+(id) actions: (CCFiniteTimeAction*) action1, ...
-{
- va_list params;
- va_start(params,action1);
-
- CCFiniteTimeAction *now;
- CCFiniteTimeAction *prev = action1;
-
- while( action1 ) {
- now = va_arg(params,CCFiniteTimeAction*);
- if ( now )
- prev = [self actionOne: prev two: now];
- else
- break;
- }
- va_end(params);
- return prev;
-}
-
--(id) initOne: (CCFiniteTimeAction*) one_ two: (CCFiniteTimeAction*) two_
-{
- NSAssert( one_!=nil, @"Sequence: argument one must be non-nil");
- NSAssert( two_!=nil, @"Sequence: argument two must be non-nil");
-
- CCFiniteTimeAction *one = one_;
- CCFiniteTimeAction *two = two_;
-
- ccTime d = [one duration] + [two duration];
- [super initWithDuration: d];
-
- actions[0] = [one retain];
- actions[1] = [two retain];
-
- return self;
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCAction *copy = [[[self class] allocWithZone:zone] initOne:[[actions[0] copy] autorelease] two:[[actions[1] copy] autorelease] ];
- return copy;
-}
-
--(void) dealloc
-{
- [actions[0] release];
- [actions[1] release];
- [super dealloc];
-}
-
--(void) startWithTarget:(id)aTarget
-{
- [super startWithTarget:aTarget];
- split = [actions[0] duration] / duration_;
- last = -1;
-}
-
--(void) stop
-{
- [actions[0] stop];
- [actions[1] stop];
- [super stop];
-}
-
--(void) update: (ccTime) t
-{
- int found = 0;
- ccTime new_t = 0.0f;
-
- if( t >= split ) {
- found = 1;
- if ( split == 1 )
- new_t = 1;
- else
- new_t = (t-split) / (1 - split );
- } else {
- found = 0;
- if( split != 0 )
- new_t = t / split;
- else
- new_t = 1;
- }
-
- if (last == -1 && found==1) {
- [actions[0] startWithTarget:target_];
- [actions[0] update:1.0f];
- [actions[0] stop];
- }
-
- if (last != found ) {
- if( last != -1 ) {
- [actions[last] update: 1.0f];
- [actions[last] stop];
- }
- [actions[found] startWithTarget:target_];
- }
- [actions[found] update: new_t];
- last = found;
-}
-
-- (CCActionInterval *) reverse
-{
- return [[self class] actionOne: [actions[1] reverse] two: [actions[0] reverse ] ];
-}
-@end
-
-//
-// Repeat
-//
-#pragma mark -
-#pragma mark CCRepeat
-@implementation CCRepeat
-+(id) actionWithAction:(CCFiniteTimeAction*)action times:(unsigned int)times
-{
- return [[[self alloc] initWithAction:action times:times] autorelease];
-}
-
--(id) initWithAction:(CCFiniteTimeAction*)action times:(unsigned int)times
-{
- ccTime d = [action duration] * times;
-
- if( (self=[super initWithDuration: d ]) ) {
- times_ = times;
- other_ = [action retain];
-
- total_ = 0;
- }
- return self;
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCAction *copy = [[[self class] allocWithZone:zone] initWithAction:[[other_ copy] autorelease] times:times_];
- return copy;
-}
-
--(void) dealloc
-{
- [other_ release];
- [super dealloc];
-}
-
--(void) startWithTarget:(id)aTarget
-{
- total_ = 0;
- [super startWithTarget:aTarget];
- [other_ startWithTarget:aTarget];
-}
-
--(void) stop
-{
- [other_ stop];
- [super stop];
-}
-
-
-// issue #80. Instead of hooking step:, hook update: since it can be called by any
-// container action like Repeat, Sequence, AccelDeccel, etc..
--(void) update:(ccTime) dt
-{
- ccTime t = dt * times_;
- if( t > total_+1 ) {
- [other_ update:1.0f];
- total_++;
- [other_ stop];
- [other_ startWithTarget:target_];
-
- // repeat is over ?
- if( total_== times_ )
- // so, set it in the original position
- [other_ update:0];
- else {
- // no ? start next repeat with the right update
- // to prevent jerk (issue #390)
- [other_ update: t-total_];
- }
-
- } else {
-
- float r = fmodf(t, 1.0f);
-
- // fix last repeat position
- // else it could be 0.
- if( dt== 1.0f) {
- r = 1.0f;
- total_++; // this is the added line
- }
- [other_ update: MIN(r,1)];
- }
-}
-
--(BOOL) isDone
-{
- return ( total_ == times_ );
-}
-
-- (CCActionInterval *) reverse
-{
- return [[self class] actionWithAction:[other_ reverse] times:times_];
-}
-@end
-
-//
-// Spawn
-//
-#pragma mark -
-#pragma mark Spawn
-
-@implementation CCSpawn
-+(id) actions: (CCFiniteTimeAction*) action1, ...
-{
- va_list params;
- va_start(params,action1);
-
- CCFiniteTimeAction *now;
- CCFiniteTimeAction *prev = action1;
-
- while( action1 ) {
- now = va_arg(params,CCFiniteTimeAction*);
- if ( now )
- prev = [self actionOne: prev two: now];
- else
- break;
- }
- va_end(params);
- return prev;
-}
-
-+(id) actionOne: (CCFiniteTimeAction*) one two: (CCFiniteTimeAction*) two
-{
- return [[[self alloc] initOne:one two:two ] autorelease];
-}
-
--(id) initOne: (CCFiniteTimeAction*) one_ two: (CCFiniteTimeAction*) two_
-{
- NSAssert( one_!=nil, @"Spawn: argument one must be non-nil");
- NSAssert( two_!=nil, @"Spawn: argument two must be non-nil");
-
- ccTime d1 = [one_ duration];
- ccTime d2 = [two_ duration];
-
- [super initWithDuration: fmaxf(d1,d2)];
-
- one = one_;
- two = two_;
-
- if( d1 > d2 )
- two = [CCSequence actionOne: two_ two:[CCDelayTime actionWithDuration: (d1-d2)] ];
- else if( d1 < d2)
- one = [CCSequence actionOne: one_ two: [CCDelayTime actionWithDuration: (d2-d1)] ];
-
- [one retain];
- [two retain];
- return self;
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCAction *copy = [[[self class] allocWithZone: zone] initOne: [[one copy] autorelease] two: [[two copy] autorelease] ];
- return copy;
-}
-
--(void) dealloc
-{
- [one release];
- [two release];
- [super dealloc];
-}
-
--(void) startWithTarget:(id)aTarget
-{
- [super startWithTarget:aTarget];
- [one startWithTarget:target_];
- [two startWithTarget:target_];
-}
-
--(void) stop
-{
- [one stop];
- [two stop];
- [super stop];
-}
-
--(void) update: (ccTime) t
-{
- [one update:t];
- [two update:t];
-}
-
-- (CCActionInterval *) reverse
-{
- return [[self class] actionOne: [one reverse] two: [two reverse ] ];
-}
-@end
-
-//
-// RotateTo
-//
-#pragma mark -
-#pragma mark RotateTo
-
-@implementation CCRotateTo
-+(id) actionWithDuration: (ccTime) t angle:(float) a
-{
- return [[[self alloc] initWithDuration:t angle:a ] autorelease];
-}
-
--(id) initWithDuration: (ccTime) t angle:(float) a
-{
- if( (self=[super initWithDuration: t]) )
- dstAngle = a;
-
- return self;
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCAction *copy = [[[self class] allocWithZone: zone] initWithDuration:[self duration] angle: dstAngle];
- return copy;
-}
-
--(void) startWithTarget:(CCNode *)aTarget
-{
- [super startWithTarget:aTarget];
-
- startAngle = [target_ rotation];
- if (startAngle > 0)
- startAngle = fmodf(startAngle, 360.0f);
- else
- startAngle = fmodf(startAngle, -360.0f);
-
- diffAngle = dstAngle - startAngle;
- if (diffAngle > 180)
- diffAngle -= 360;
- if (diffAngle < -180)
- diffAngle += 360;
-}
--(void) update: (ccTime) t
-{
- [target_ setRotation: startAngle + diffAngle * t];
-}
-@end
-
-
-//
-// RotateBy
-//
-#pragma mark -
-#pragma mark RotateBy
-
-@implementation CCRotateBy
-+(id) actionWithDuration: (ccTime) t angle:(float) a
-{
- return [[[self alloc] initWithDuration:t angle:a ] autorelease];
-}
-
--(id) initWithDuration: (ccTime) t angle:(float) a
-{
- if( (self=[super initWithDuration: t]) )
- angle = a;
-
- return self;
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCAction *copy = [[[self class] allocWithZone: zone] initWithDuration: [self duration] angle: angle];
- return copy;
-}
-
--(void) startWithTarget:(id)aTarget
-{
- [super startWithTarget:aTarget];
- startAngle = [target_ rotation];
-}
-
--(void) update: (ccTime) t
-{
- // XXX: shall I add % 360
- [target_ setRotation: (startAngle + angle * t )];
-}
-
--(CCActionInterval*) reverse
-{
- return [[self class] actionWithDuration:duration_ angle:-angle];
-}
-
-@end
-
-//
-// MoveTo
-//
-#pragma mark -
-#pragma mark MoveTo
-
-@implementation CCMoveTo
-+(id) actionWithDuration: (ccTime) t position: (CGPoint) p
-{
- return [[[self alloc] initWithDuration:t position:p ] autorelease];
-}
-
--(id) initWithDuration: (ccTime) t position: (CGPoint) p
-{
- if( (self=[super initWithDuration: t]) )
- endPosition = p;
-
- return self;
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCAction *copy = [[[self class] allocWithZone: zone] initWithDuration: [self duration] position: endPosition];
- return copy;
-}
-
--(void) startWithTarget:(CCNode *)aTarget
-{
- [super startWithTarget:aTarget];
- startPosition = [(CCNode*)target_ position];
- delta = ccpSub( endPosition, startPosition );
-}
-
--(void) update: (ccTime) t
-{
- [target_ setPosition: ccp( (startPosition.x + delta.x * t ), (startPosition.y + delta.y * t ) )];
-}
-@end
-
-//
-// MoveBy
-//
-#pragma mark -
-#pragma mark MoveBy
-
-@implementation CCMoveBy
-+(id) actionWithDuration: (ccTime) t position: (CGPoint) p
-{
- return [[[self alloc] initWithDuration:t position:p ] autorelease];
-}
-
--(id) initWithDuration: (ccTime) t position: (CGPoint) p
-{
- if( (self=[super initWithDuration: t]) )
- delta = p;
-
- return self;
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCAction *copy = [[[self class] allocWithZone: zone] initWithDuration: [self duration] position: delta];
- return copy;
-}
-
--(void) startWithTarget:(CCNode *)aTarget
-{
- CGPoint dTmp = delta;
- [super startWithTarget:aTarget];
- delta = dTmp;
-}
-
--(CCActionInterval*) reverse
-{
- return [[self class] actionWithDuration:duration_ position:ccp( -delta.x, -delta.y)];
-}
-@end
-
-//
-// JumpBy
-//
-#pragma mark -
-#pragma mark JumpBy
-
-@implementation CCJumpBy
-+(id) actionWithDuration: (ccTime) t position: (CGPoint) pos height: (ccTime) h jumps:(int)j
-{
- return [[[self alloc] initWithDuration: t position: pos height: h jumps:j] autorelease];
-}
-
--(id) initWithDuration: (ccTime) t position: (CGPoint) pos height: (ccTime) h jumps:(int)j
-{
- if( (self=[super initWithDuration:t]) ) {
- delta = pos;
- height = h;
- jumps = j;
- }
- return self;
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCAction *copy = [[[self class] allocWithZone: zone] initWithDuration: [self duration] position: delta height:height jumps:jumps];
- return copy;
-}
-
--(void) startWithTarget:(id)aTarget
-{
- [super startWithTarget:aTarget];
- startPosition = [(CCNode*)target_ position];
-}
-
--(void) update: (ccTime) t
-{
- // Sin jump. Less realistic
-// ccTime y = height * fabsf( sinf(t * (CGFloat)M_PI * jumps ) );
-// y += delta.y * t;
-// ccTime x = delta.x * t;
-// [target setPosition: ccp( startPosition.x + x, startPosition.y + y )];
-
- // parabolic jump (since v0.8.2)
- ccTime frac = fmodf( t * jumps, 1.0f );
- ccTime y = height * 4 * frac * (1 - frac);
- y += delta.y * t;
- ccTime x = delta.x * t;
- [target_ setPosition: ccp( startPosition.x + x, startPosition.y + y )];
-
-}
-
--(CCActionInterval*) reverse
-{
- return [[self class] actionWithDuration:duration_ position: ccp(-delta.x,-delta.y) height: height jumps:jumps];
-}
-@end
-
-//
-// JumpTo
-//
-#pragma mark -
-#pragma mark JumpTo
-
-@implementation CCJumpTo
--(void) startWithTarget:(CCNode *)aTarget
-{
- [super startWithTarget:aTarget];
- delta = ccp( delta.x - startPosition.x, delta.y - startPosition.y );
-}
-@end
-
-
-#pragma mark -
-#pragma mark BezierBy
-
-// Bezier cubic formula:
-// ((1 - t) + t)3 = 1
-// Expands to…
-// (1 - t)3 + 3t(1-t)2 + 3t2(1 - t) + t3 = 1
-static inline float bezierat( float a, float b, float c, float d, ccTime t )
-{
- return (powf(1-t,3) * a +
- 3*t*(powf(1-t,2))*b +
- 3*powf(t,2)*(1-t)*c +
- powf(t,3)*d );
-}
-
-//
-// BezierBy
-//
-@implementation CCBezierBy
-+(id) actionWithDuration: (ccTime) t bezier:(ccBezierConfig) c
-{
- return [[[self alloc] initWithDuration:t bezier:c ] autorelease];
-}
-
--(id) initWithDuration: (ccTime) t bezier:(ccBezierConfig) c
-{
- if( (self=[super initWithDuration: t]) ) {
- config = c;
- }
- return self;
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCAction *copy = [[[self class] allocWithZone: zone] initWithDuration: [self duration] bezier: config];
- return copy;
-}
-
--(void) startWithTarget:(id)aTarget
-{
- [super startWithTarget:aTarget];
- startPosition = [(CCNode*)target_ position];
-}
-
--(void) update: (ccTime) t
-{
- float xa = 0;
- float xb = config.controlPoint_1.x;
- float xc = config.controlPoint_2.x;
- float xd = config.endPosition.x;
-
- float ya = 0;
- float yb = config.controlPoint_1.y;
- float yc = config.controlPoint_2.y;
- float yd = config.endPosition.y;
-
- float x = bezierat(xa, xb, xc, xd, t);
- float y = bezierat(ya, yb, yc, yd, t);
- [target_ setPosition: ccpAdd( startPosition, ccp(x,y))];
-}
-
-- (CCActionInterval*) reverse
-{
- ccBezierConfig r;
-
- r.endPosition = ccpNeg(config.endPosition);
- r.controlPoint_1 = ccpAdd(config.controlPoint_2, ccpNeg(config.endPosition));
- r.controlPoint_2 = ccpAdd(config.controlPoint_1, ccpNeg(config.endPosition));
-
- CCBezierBy *action = [[self class] actionWithDuration:[self duration] bezier:r];
- return action;
-}
-@end
-
-//
-// BezierTo
-//
-#pragma mark -
-#pragma mark BezierTo
-@implementation CCBezierTo
--(void) startWithTarget:(id)aTarget
-{
- [super startWithTarget:aTarget];
- config.controlPoint_1 = ccpSub(config.controlPoint_1, startPosition);
- config.controlPoint_2 = ccpSub(config.controlPoint_2, startPosition);
- config.endPosition = ccpSub(config.endPosition, startPosition);
-}
-@end
-
-
-//
-// ScaleTo
-//
-#pragma mark -
-#pragma mark ScaleTo
-@implementation CCScaleTo
-+(id) actionWithDuration: (ccTime) t scale:(float) s
-{
- return [[[self alloc] initWithDuration: t scale:s] autorelease];
-}
-
--(id) initWithDuration: (ccTime) t scale:(float) s
-{
- if( (self=[super initWithDuration: t]) ) {
- endScaleX = s;
- endScaleY = s;
- }
- return self;
-}
-
-+(id) actionWithDuration: (ccTime) t scaleX:(float)sx scaleY:(float)sy
-{
- return [[[self alloc] initWithDuration: t scaleX:sx scaleY:sy] autorelease];
-}
-
--(id) initWithDuration: (ccTime) t scaleX:(float)sx scaleY:(float)sy
-{
- if( (self=[super initWithDuration: t]) ) {
- endScaleX = sx;
- endScaleY = sy;
- }
- return self;
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCAction *copy = [[[self class] allocWithZone: zone] initWithDuration: [self duration] scaleX:endScaleX scaleY:endScaleY];
- return copy;
-}
-
--(void) startWithTarget:(CCNode *)aTarget
-{
- [super startWithTarget:aTarget];
- startScaleX = [target_ scaleX];
- startScaleY = [target_ scaleY];
- deltaX = endScaleX - startScaleX;
- deltaY = endScaleY - startScaleY;
-}
-
--(void) update: (ccTime) t
-{
- [target_ setScaleX: (startScaleX + deltaX * t ) ];
- [target_ setScaleY: (startScaleY + deltaY * t ) ];
-}
-@end
-
-//
-// ScaleBy
-//
-#pragma mark -
-#pragma mark ScaleBy
-@implementation CCScaleBy
--(void) startWithTarget:(CCNode *)aTarget
-{
- [super startWithTarget:aTarget];
- deltaX = startScaleX * endScaleX - startScaleX;
- deltaY = startScaleY * endScaleY - startScaleY;
-}
-
--(CCActionInterval*) reverse
-{
- return [[self class] actionWithDuration:duration_ scaleX: 1/endScaleX scaleY:1/endScaleY];
-}
-@end
-
-//
-// Blink
-//
-#pragma mark -
-#pragma mark Blink
-@implementation CCBlink
-+(id) actionWithDuration: (ccTime) t blinks: (unsigned int) b
-{
- return [[[ self alloc] initWithDuration: t blinks: b] autorelease];
-}
-
--(id) initWithDuration: (ccTime) t blinks: (unsigned int) b
-{
- if( (self=[super initWithDuration: t] ) )
- times = b;
-
- return self;
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCAction *copy = [[[self class] allocWithZone: zone] initWithDuration: [self duration] blinks: times];
- return copy;
-}
-
--(void) update: (ccTime) t
-{
- if( ! [self isDone] ) {
- ccTime slice = 1.0f / times;
- ccTime m = fmodf(t, slice);
- [target_ setVisible: (m > slice/2) ? YES : NO];
- }
-}
-
--(CCActionInterval*) reverse
-{
- // return 'self'
- return [[self class] actionWithDuration:duration_ blinks: times];
-}
-@end
-
-//
-// FadeIn
-//
-#pragma mark -
-#pragma mark FadeIn
-@implementation CCFadeIn
--(void) update: (ccTime) t
-{
- [(id<CCRGBAProtocol>) target_ setOpacity: 255 *t];
-}
-
--(CCActionInterval*) reverse
-{
- return [CCFadeOut actionWithDuration:duration_];
-}
-@end
-
-//
-// FadeOut
-//
-#pragma mark -
-#pragma mark FadeOut
-@implementation CCFadeOut
--(void) update: (ccTime) t
-{
- [(id<CCRGBAProtocol>) target_ setOpacity: 255 *(1-t)];
-}
-
--(CCActionInterval*) reverse
-{
- return [CCFadeIn actionWithDuration:duration_];
-}
-@end
-
-//
-// FadeTo
-//
-#pragma mark -
-#pragma mark FadeTo
-@implementation CCFadeTo
-+(id) actionWithDuration: (ccTime) t opacity: (GLubyte) o
-{
- return [[[ self alloc] initWithDuration: t opacity: o] autorelease];
-}
-
--(id) initWithDuration: (ccTime) t opacity: (GLubyte) o
-{
- if( (self=[super initWithDuration: t] ) )
- toOpacity = o;
-
- return self;
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCAction *copy = [[[self class] allocWithZone: zone] initWithDuration: [self duration] opacity: toOpacity];
- return copy;
-}
-
--(void) startWithTarget:(CCNode *)aTarget
-{
- [super startWithTarget:aTarget];
- fromOpacity = [(id<CCRGBAProtocol>)target_ opacity];
-}
-
--(void) update: (ccTime) t
-{
- [(id<CCRGBAProtocol>)target_ setOpacity: fromOpacity + ( toOpacity - fromOpacity ) * t];
-}
-@end
-
-//
-// TintTo
-//
-#pragma mark -
-#pragma mark TintTo
-@implementation CCTintTo
-+(id) actionWithDuration:(ccTime)t red:(GLubyte)r green:(GLubyte)g blue:(GLubyte)b
-{
- return [[(CCTintTo*)[ self alloc] initWithDuration:t red:r green:g blue:b] autorelease];
-}
-
--(id) initWithDuration: (ccTime) t red:(GLubyte)r green:(GLubyte)g blue:(GLubyte)b
-{
- if( (self=[super initWithDuration: t] ) )
- to = ccc3(r,g,b);
-
- return self;
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCAction *copy = [(CCTintTo*)[[self class] allocWithZone: zone] initWithDuration: [self duration] red:to.r green:to.g blue:to.b];
- return copy;
-}
-
--(void) startWithTarget:(id)aTarget
-{
- [super startWithTarget:aTarget];
-
- id<CCRGBAProtocol> tn = (id<CCRGBAProtocol>) target_;
- from = [tn color];
-}
-
--(void) update: (ccTime) t
-{
- id<CCRGBAProtocol> tn = (id<CCRGBAProtocol>) target_;
- [tn setColor:ccc3(from.r + (to.r - from.r) * t, from.g + (to.g - from.g) * t, from.b + (to.b - from.b) * t)];
-}
-@end
-
-//
-// TintBy
-//
-#pragma mark -
-#pragma mark TintBy
-@implementation CCTintBy
-+(id) actionWithDuration:(ccTime)t red:(GLshort)r green:(GLshort)g blue:(GLshort)b
-{
- return [[(CCTintBy*)[ self alloc] initWithDuration:t red:r green:g blue:b] autorelease];
-}
-
--(id) initWithDuration:(ccTime)t red:(GLshort)r green:(GLshort)g blue:(GLshort)b
-{
- if( (self=[super initWithDuration: t] ) ) {
- deltaR = r;
- deltaG = g;
- deltaB = b;
- }
- return self;
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- return[(CCTintBy*)[[self class] allocWithZone: zone] initWithDuration: [self duration] red:deltaR green:deltaG blue:deltaB];
-}
-
--(void) startWithTarget:(id)aTarget
-{
- [super startWithTarget:aTarget];
-
- id<CCRGBAProtocol> tn = (id<CCRGBAProtocol>) target_;
- ccColor3B color = [tn color];
- fromR = color.r;
- fromG = color.g;
- fromB = color.b;
-}
-
--(void) update: (ccTime) t
-{
- id<CCRGBAProtocol> tn = (id<CCRGBAProtocol>) target_;
- [tn setColor:ccc3( fromR + deltaR * t, fromG + deltaG * t, fromB + deltaB * t)];
-}
-
-- (CCActionInterval*) reverse
-{
- return [CCTintBy actionWithDuration:duration_ red:-deltaR green:-deltaG blue:-deltaB];
-}
-@end
-
-//
-// DelayTime
-//
-#pragma mark -
-#pragma mark DelayTime
-@implementation CCDelayTime
--(void) update: (ccTime) t
-{
- return;
-}
-
--(id)reverse
-{
- return [[self class] actionWithDuration:duration_];
-}
-@end
-
-//
-// ReverseTime
-//
-#pragma mark -
-#pragma mark ReverseTime
-@implementation CCReverseTime
-+(id) actionWithAction: (CCFiniteTimeAction*) action
-{
- // casting to prevent warnings
- CCReverseTime *a = [super alloc];
- return [[a initWithAction:action] autorelease];
-}
-
--(id) initWithAction: (CCFiniteTimeAction*) action
-{
- if( (self=[super initWithDuration: [action duration]]) )
- other = [action retain];
-
- return self;
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- return [[[self class] allocWithZone: zone] initWithAction:[[other copy] autorelease] ];
-}
-
--(void) dealloc
-{
- [other release];
- [super dealloc];
-}
-
--(void) startWithTarget:(id)aTarget
-{
- [super startWithTarget:aTarget];
- [other startWithTarget:target_];
-}
-
--(void) stop
-{
- [other stop];
- [super stop];
-}
-
--(void) update:(ccTime)t
-{
- [other update:1-t];
-}
-
--(CCActionInterval*) reverse
-{
- return [[other copy] autorelease];
-}
-@end
-
-//
-// Animate
-//
-
-#pragma mark -
-#pragma mark Animate
-@implementation CCAnimate
-
-@synthesize animation = animation_;
-
-+(id) actionWithAnimation: (CCAnimation*)anim
-{
- return [[[self alloc] initWithAnimation:anim restoreOriginalFrame:YES] autorelease];
-}
-
-+(id) actionWithAnimation: (CCAnimation*)anim restoreOriginalFrame:(BOOL)b
-{
- return [[[self alloc] initWithAnimation:anim restoreOriginalFrame:b] autorelease];
-}
-
-+(id) actionWithDuration:(ccTime)duration animation: (CCAnimation*)anim restoreOriginalFrame:(BOOL)b
-{
- return [[[self alloc] initWithDuration:duration animation:anim restoreOriginalFrame:b] autorelease];
-}
-
--(id) initWithAnimation: (CCAnimation*)anim
-{
- NSAssert( anim!=nil, @"Animate: argument Animation must be non-nil");
- return [self initWithAnimation:anim restoreOriginalFrame:YES];
-}
-
--(id) initWithAnimation: (CCAnimation*)anim restoreOriginalFrame:(BOOL) b
-{
- NSAssert( anim!=nil, @"Animate: argument Animation must be non-nil");
-
- if( (self=[super initWithDuration: [[anim frames] count] * [anim delay]]) ) {
-
- restoreOriginalFrame = b;
- self.animation = anim;
- origFrame = nil;
- }
- return self;
-}
-
--(id) initWithDuration:(ccTime)aDuration animation: (CCAnimation*)anim restoreOriginalFrame:(BOOL) b
-{
- NSAssert( anim!=nil, @"Animate: argument Animation must be non-nil");
-
- if( (self=[super initWithDuration:aDuration] ) ) {
-
- restoreOriginalFrame = b;
- self.animation = anim;
- origFrame = nil;
- }
- return self;
-}
-
-
--(id) copyWithZone: (NSZone*) zone
-{
- return [[[self class] allocWithZone: zone] initWithDuration:duration_ animation:animation_ restoreOriginalFrame:restoreOriginalFrame];
-}
-
--(void) dealloc
-{
- [animation_ release];
- [origFrame release];
- [super dealloc];
-}
-
--(void) startWithTarget:(id)aTarget
-{
- [super startWithTarget:aTarget];
- CCSprite *sprite = target_;
-
- [origFrame release];
-
- if( restoreOriginalFrame )
- origFrame = [[sprite displayedFrame] retain];
-}
-
--(void) stop
-{
- if( restoreOriginalFrame ) {
- CCSprite *sprite = target_;
- [sprite setDisplayFrame:origFrame];
- }
-
- [super stop];
-}
-
--(void) update: (ccTime) t
-{
- NSArray *frames = [animation_ frames];
- NSUInteger numberOfFrames = [frames count];
-
- NSUInteger idx = t * numberOfFrames;
-
- if( idx >= numberOfFrames )
- idx = numberOfFrames -1;
-
- CCSprite *sprite = target_;
- if (! [sprite isFrameDisplayed: [frames objectAtIndex: idx]] )
- [sprite setDisplayFrame: [frames objectAtIndex:idx]];
-}
-
-- (CCActionInterval *) reverse
-{
- NSArray *oldArray = [animation_ frames];
- NSMutableArray *newArray = [NSMutableArray arrayWithCapacity:[oldArray count]];
- NSEnumerator *enumerator = [oldArray reverseObjectEnumerator];
- for (id element in enumerator)
- [newArray addObject:[[element copy] autorelease]];
-
- CCAnimation *newAnim = [CCAnimation animationWithFrames:newArray delay:animation_.delay];
- return [[self class] actionWithDuration:duration_ animation:newAnim restoreOriginalFrame:restoreOriginalFrame];
-}
-
-@end
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (c) 2008-2010 Ricardo Quesada
- * Copyright (c) 2009 Valentin Milea
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-
-#import "CCAction.h"
-#import "Support/ccCArray.h"
-#import "Support/uthash.h"
-
-typedef struct _hashElement
-{
- struct ccArray *actions;
- id target;
- unsigned int actionIndex;
- CCAction *currentAction;
- BOOL currentActionSalvaged;
- BOOL paused;
- UT_hash_handle hh;
-} tHashElement;
-
-
-/** CCActionManager is a singleton that manages all the actions.
- Normally you won't need to use this singleton directly. 99% of the cases you will use the CCNode interface,
- which uses this singleton.
- But there are some cases where you might need to use this singleton.
- Examples:
- - When you want to run an action where the target is different from a CCNode.
- - When you want to pause / resume the actions
-
- @since v0.8
- */
-@interface CCActionManager : NSObject
-{
- tHashElement *targets;
- tHashElement *currentTarget;
- BOOL currentTargetSalvaged;
-}
-
-/** returns a shared instance of the CCActionManager */
-+ (CCActionManager *)sharedManager;
-
-/** purges the shared action manager. It releases the retained instance.
- @since v0.99.0
- */
-+(void)purgeSharedManager;
-
-// actions
-
-/** Adds an action with a target.
- If the target is already present, then the action will be added to the existing target.
- If the target is not present, a new instance of this target will be created either paused or paused, and the action will be added to the newly created target.
- When the target is paused, the queued actions won't be 'ticked'.
- */
--(void) addAction: (CCAction*) action target:(id)target paused:(BOOL)paused;
-/** Removes all actions from all the targers.
- */
--(void) removeAllActions;
-
-/** Removes all actions from a certain target.
- All the actions that belongs to the target will be removed.
- */
--(void) removeAllActionsFromTarget:(id)target;
-/** Removes an action given an action reference.
- */
--(void) removeAction: (CCAction*) action;
-/** Removes an action given its tag and the target */
--(void) removeActionByTag:(int)tag target:(id)target;
-/** Gets an action given its tag an a target
- @return the Action the with the given tag
- */
--(CCAction*) getActionByTag:(int) tag target:(id)target;
-/** Returns the numbers of actions that are running in a certain target
- * Composable actions are counted as 1 action. Example:
- * If you are running 1 Sequence of 7 actions, it will return 1.
- * If you are running 7 Sequences of 2 actions, it will return 7.
- */
--(int) numberOfRunningActionsInTarget:(id)target;
-
-/** Pauses the target: all running actions and newly added actions will be paused.
- */
--(void) pauseTarget:(id)target;
-/** Resumes the target. All queued actions will be resumed.
- */
--(void) resumeTarget:(id)target;
-
-/** Resumes the target. All queued actions will be resumed.
- @deprecated Use resumeTarget: instead. Will be removed in v1.0.
- */
--(void) resumeAllActionsForTarget:(id)target DEPRECATED_ATTRIBUTE;
-/** Pauses the target: all running actions and newly added actions will be paused.
- */
--(void) pauseAllActionsForTarget:(id)target DEPRECATED_ATTRIBUTE;
-
-
-@end
-
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (c) 2008-2010 Ricardo Quesada
- * Copyright (c) 2009 Valentin Milea
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-
-#import "CCActionManager.h"
-#import "CCScheduler.h"
-#import "ccMacros.h"
-
-
-//
-// singleton stuff
-//
-static CCActionManager *sharedManager_ = nil;
-
-@interface CCActionManager (Private)
--(void) removeActionAtIndex:(NSUInteger)index hashElement:(tHashElement*)element;
--(void) deleteHashElement:(tHashElement*)element;
--(void) actionAllocWithHashElement:(tHashElement*)element;
-@end
-
-
-@implementation CCActionManager
-
-#pragma mark ActionManager - init
-+ (CCActionManager *)sharedManager
-{
- if (!sharedManager_)
- sharedManager_ = [[self alloc] init];
-
- return sharedManager_;
-}
-
-+(id)alloc
-{
- NSAssert(sharedManager_ == nil, @"Attempted to allocate a second instance of a singleton.");
- return [super alloc];
-}
-
-+(void)purgeSharedManager
-{
- [[CCScheduler sharedScheduler] unscheduleUpdateForTarget:self];
- [sharedManager_ release];
- sharedManager_ = nil;
-}
-
--(id) init
-{
- if ((self=[super init]) ) {
- [[CCScheduler sharedScheduler] scheduleUpdateForTarget:self priority:0 paused:NO];
- targets = NULL;
- }
-
- return self;
-}
-
-- (void) dealloc
-{
- CCLOGINFO( @"cocos2d: deallocing %@", self);
-
- [self removeAllActions];
-
- sharedManager_ = nil;
-
- [super dealloc];
-}
-
-#pragma mark ActionManager - Private
-
--(void) deleteHashElement:(tHashElement*)element
-{
- ccArrayFree(element->actions);
- HASH_DEL(targets, element);
-// CCLOG(@"cocos2d: ---- buckets: %d/%d - %@", targets->entries, targets->size, element->target);
- [element->target release];
- free(element);
-}
-
--(void) actionAllocWithHashElement:(tHashElement*)element
-{
- // 4 actions per Node by default
- if( element->actions == nil )
- element->actions = ccArrayNew(4);
- else if( element->actions->num == element->actions->max )
- ccArrayDoubleCapacity(element->actions);
-}
-
--(void) removeActionAtIndex:(NSUInteger)index hashElement:(tHashElement*)element
-{
- id action = element->actions->arr[index];
-
- if( action == element->currentAction && !element->currentActionSalvaged ) {
- [element->currentAction retain];
- element->currentActionSalvaged = YES;
- }
-
- ccArrayRemoveObjectAtIndex(element->actions, index);
-
- // update actionIndex in case we are in tick:, looping over the actions
- if( element->actionIndex >= index )
- element->actionIndex--;
-
- if( element->actions->num == 0 ) {
- if( currentTarget == element )
- currentTargetSalvaged = YES;
- else
- [self deleteHashElement: element];
- }
-}
-
-#pragma mark ActionManager - Pause / Resume
-
-// XXX DEPRECATED. REMOVE IN 1.0
--(void) pauseAllActionsForTarget:(id)target
-{
- [self pauseTarget:target];
-}
-
--(void) pauseTarget:(id)target
-{
- tHashElement *element = NULL;
- HASH_FIND_INT(targets, &target, element);
- if( element )
- element->paused = YES;
-// else
-// CCLOG(@"cocos2d: pauseAllActions: Target not found");
-}
-
-// XXX DEPRECATED. REMOVE IN 1.0
--(void) resumeAllActionsForTarget:(id)target
-{
- [self resumeTarget:target];
-}
-
--(void) resumeTarget:(id)target
-{
- tHashElement *element = NULL;
- HASH_FIND_INT(targets, &target, element);
- if( element )
- element->paused = NO;
-// else
-// CCLOG(@"cocos2d: resumeAllActions: Target not found");
-}
-
-#pragma mark ActionManager - run
-
--(void) addAction:(CCAction*)action target:(id)target paused:(BOOL)paused
-{
- NSAssert( action != nil, @"Argument action must be non-nil");
- NSAssert( target != nil, @"Argument target must be non-nil");
-
- tHashElement *element = NULL;
- HASH_FIND_INT(targets, &target, element);
- if( ! element ) {
- element = calloc( sizeof( *element ), 1 );
- element->paused = paused;
- element->target = [target retain];
- HASH_ADD_INT(targets, target, element);
-// CCLOG(@"cocos2d: ---- buckets: %d/%d - %@", targets->entries, targets->size, element->target);
-
- }
-
- [self actionAllocWithHashElement:element];
-
- NSAssert( !ccArrayContainsObject(element->actions, action), @"runAction: Action already running");
- ccArrayAppendObject(element->actions, action);
-
- [action startWithTarget:target];
-}
-
-#pragma mark ActionManager - remove
-
--(void) removeAllActions
-{
- for(tHashElement *element=targets; element != NULL; ) {
- id target = element->target;
- element = element->hh.next;
- [self removeAllActionsFromTarget:target];
- }
-}
--(void) removeAllActionsFromTarget:(id)target
-{
- // explicit nil handling
- if( target == nil )
- return;
-
- tHashElement *element = NULL;
- HASH_FIND_INT(targets, &target, element);
- if( element ) {
- if( ccArrayContainsObject(element->actions, element->currentAction) && !element->currentActionSalvaged ) {
- [element->currentAction retain];
- element->currentActionSalvaged = YES;
- }
- ccArrayRemoveAllObjects(element->actions);
- if( currentTarget == element )
- currentTargetSalvaged = YES;
- else
- [self deleteHashElement:element];
- }
-// else {
-// CCLOG(@"cocos2d: removeAllActionsFromTarget: Target not found");
-// }
-}
-
--(void) removeAction: (CCAction*) action
-{
- // explicit nil handling
- if (action == nil)
- return;
-
- tHashElement *element = NULL;
- id target = [action originalTarget];
- HASH_FIND_INT(targets, &target, element );
- if( element ) {
- NSUInteger i = ccArrayGetIndexOfObject(element->actions, action);
- if( i != NSNotFound )
- [self removeActionAtIndex:i hashElement:element];
- }
-// else {
-// CCLOG(@"cocos2d: removeAction: Target not found");
-// }
-}
-
--(void) removeActionByTag:(int) aTag target:(id)target
-{
- NSAssert( aTag != kCCActionTagInvalid, @"Invalid tag");
- NSAssert( target != nil, @"Target should be ! nil");
-
- tHashElement *element = NULL;
- HASH_FIND_INT(targets, &target, element);
-
- if( element ) {
- NSUInteger limit = element->actions->num;
- for( NSUInteger i = 0; i < limit; i++) {
- CCAction *a = element->actions->arr[i];
-
- if( a.tag == aTag && [a originalTarget]==target)
- return [self removeActionAtIndex:i hashElement:element];
- }
-// CCLOG(@"cocos2d: removeActionByTag: Action not found!");
- }
-// else {
-// CCLOG(@"cocos2d: removeActionByTag: Target not found!");
-// }
-}
-
-#pragma mark ActionManager - get
-
--(CCAction*) getActionByTag:(int)aTag target:(id)target
-{
- NSAssert( aTag != kCCActionTagInvalid, @"Invalid tag");
-
- tHashElement *element = NULL;
- HASH_FIND_INT(targets, &target, element);
-
- if( element ) {
- if( element->actions != nil ) {
- NSUInteger limit = element->actions->num;
- for( NSUInteger i = 0; i < limit; i++) {
- CCAction *a = element->actions->arr[i];
-
- if( a.tag == aTag )
- return a;
- }
- }
-// CCLOG(@"cocos2d: getActionByTag: Action not found");
- }
-// else {
-// CCLOG(@"cocos2d: getActionByTag: Target not found");
-// }
- return nil;
-}
-
--(int) numberOfRunningActionsInTarget:(id) target
-{
- tHashElement *element = NULL;
- HASH_FIND_INT(targets, &target, element);
- if( element )
- return element->actions ? element->actions->num : 0;
-
-// CCLOG(@"cocos2d: numberOfRunningActionsInTarget: Target not found");
- return 0;
-}
-
-#pragma mark ActionManager - main loop
-
--(void) update: (ccTime) dt
-{
- for(tHashElement *elt = targets; elt != NULL; ) {
-
- currentTarget = elt;
- currentTargetSalvaged = NO;
-
- if( ! currentTarget->paused ) {
-
- // The 'actions' ccArray may change while inside this loop.
- for( currentTarget->actionIndex = 0; currentTarget->actionIndex < currentTarget->actions->num; currentTarget->actionIndex++) {
- currentTarget->currentAction = currentTarget->actions->arr[currentTarget->actionIndex];
- currentTarget->currentActionSalvaged = NO;
-
- [currentTarget->currentAction step: dt];
-
- if( currentTarget->currentActionSalvaged ) {
- // The currentAction told the node to remove it. To prevent the action from
- // accidentally deallocating itself before finishing its step, we retained
- // it. Now that step is done, it's safe to release it.
- [currentTarget->currentAction release];
-
- } else if( [currentTarget->currentAction isDone] ) {
- [currentTarget->currentAction stop];
-
- CCAction *a = currentTarget->currentAction;
- // Make currentAction nil to prevent removeAction from salvaging it.
- currentTarget->currentAction = nil;
- [self removeAction:a];
- }
-
- currentTarget->currentAction = nil;
- }
- }
-
- // elt, at this moment, is still valid
- // so it is safe to ask this here (issue #490)
- elt = elt->hh.next;
-
- // only delete currentTarget if no actions were scheduled during the cycle (issue #481)
- if( currentTargetSalvaged && currentTarget->actions->num == 0 )
- [self deleteHashElement:currentTarget];
- }
-
- // issue #635
- currentTarget = nil;
-}
-@end
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (c) 2009 Sindesso Pty Ltd http://www.sindesso.com/
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-
-#import "CCActionGrid3D.h"
-
-/**
- * This action simulates a page turn from the bottom right hand corner of the screen
- * It's not much use by itself but is used by the PageTurnTransition.
- *
- * Based on an original paper by L Hong et al.
- * http://www.parc.com/publication/1638/turning-pages-of-3d-electronic-books.html
- *
- * @since v0.8.2
- */
-@interface CCPageTurn3D : CCGrid3DAction
-{
-}
-
-@end
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (c) 2009 Sindesso Pty Ltd http://www.sindesso.com/
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-#import "CCActionPageTurn3D.h"
-
-@implementation CCPageTurn3D
-
-/*
- * Update each tick
- * Time is the percentage of the way through the duration
- */
--(void)update:(ccTime)time
-{
- float tt = MAX( 0, time - 0.25f );
- float deltaAy = ( tt * tt * 500);
- float ay = -100 - deltaAy;
-
- float deltaTheta = - (float) M_PI_2 * sqrtf( time) ;
- float theta = /*0.01f*/ + (float) M_PI_2 +deltaTheta;
-
- float sinTheta = sinf(theta);
- float cosTheta = cosf(theta);
-
- for( int i = 0; i <=gridSize_.x; i++ )
- {
- for( int j = 0; j <= gridSize_.y; j++ )
- {
- // Get original vertex
- ccVertex3F p = [self originalVertex:ccg(i,j)];
-
- float R = sqrtf(p.x*p.x + (p.y - ay) * (p.y - ay));
- float r = R * sinTheta;
- float alpha = asinf( p.x / R );
- float beta = alpha / sinTheta;
- float cosBeta = cosf( beta );
-
- // If beta > PI then we've wrapped around the cone
- // Reduce the radius to stop these points interfering with others
- if( beta <= M_PI)
- p.x = ( r * sinf(beta));
- else
- {
- // Force X = 0 to stop wrapped
- // points
- p.x = 0;
- }
-
- p.y = ( R + ay - ( r*(1 - cosBeta)*sinTheta));
-
- // We scale z here to avoid the animation being
- // too much bigger than the screen due to perspectve transform
- p.z = (r * ( 1 - cosBeta ) * cosTheta) / 7; // "100" didn't work for
-
- // Stop z coord from dropping beneath underlying page in a transition
- // issue #751
- if( p.z<0.5f )
- p.z = 0.5f;
-
- // Set new coords
- [self setVertex:ccg(i,j) vertex:p];
- }
- }
-}
-@end
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (C) 2010 Lam Pham
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-
-#import <Foundation/Foundation.h>
-#import "CCProgressTimer.h"
-#import "CCActionInterval.h"
-
-/**
- Progress to percentage
-@since v0.99.1
-*/
-@interface CCProgressTo : CCActionInterval <NSCopying>
-{
- float to_;
- float from_;
-}
-/** Creates and initializes with a duration and a percent */
-+(id) actionWithDuration:(ccTime)duration percent:(float)percent;
-/** Initializes with a duration and a percent */
--(id) initWithDuration:(ccTime)duration percent:(float)percent;
-@end
-
-/**
- Progress from a percentage to another percentage
- @since v0.99.1
- */
-@interface CCProgressFromTo : CCActionInterval <NSCopying>
-{
- float to_;
- float from_;
-}
-/** Creates and initializes the action with a duration, a "from" percentage and a "to" percentage */
-+(id) actionWithDuration:(ccTime)duration from:(float)fromPercentage to:(float) toPercentage;
-/** Initializes the action with a duration, a "from" percentage and a "to" percentage */
--(id) initWithDuration:(ccTime)duration from:(float)fromPercentage to:(float) toPercentage;
-@end
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (C) 2010 Lam Pham
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-
-#import "CCActionProgressTimer.h"
-
-#define kProgressTimerCast CCProgressTimer*
-
-@implementation CCProgressTo
-+(id) actionWithDuration: (ccTime) t percent: (float) v
-{
- return [[[ self alloc] initWithDuration: t percent: v] autorelease];
-}
-
--(id) initWithDuration: (ccTime) t percent: (float) v
-{
- if( (self=[super initWithDuration: t] ) )
- to_ = v;
-
- return self;
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCAction *copy = [[[self class] allocWithZone: zone] initWithDuration:duration_ percent:to_];
- return copy;
-}
-
--(void) startWithTarget:(id) aTarget;
-{
- [super startWithTarget:aTarget];
- from_ = [(kProgressTimerCast)target_ percentage];
-
- // XXX: Is this correct ?
- // Adding it to support CCRepeat
- if( from_ == 100)
- from_ = 0;
-}
-
--(void) update: (ccTime) t
-{
- [(kProgressTimerCast)target_ setPercentage: from_ + ( to_ - from_ ) * t];
-}
-@end
-
-@implementation CCProgressFromTo
-+(id) actionWithDuration: (ccTime) t from:(float)fromPercentage to:(float) toPercentage
-{
- return [[[self alloc] initWithDuration: t from: fromPercentage to: toPercentage] autorelease];
-}
-
--(id) initWithDuration: (ccTime) t from:(float)fromPercentage to:(float) toPercentage
-{
- if( (self=[super initWithDuration: t] ) ){
- to_ = toPercentage;
- from_ = fromPercentage;
- }
- return self;
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCAction *copy = [[[self class] allocWithZone: zone] initWithDuration:duration_ from:from_ to:to_];
- return copy;
-}
-
-- (CCActionInterval *) reverse
-{
- return [[self class] actionWithDuration:duration_ from:to_ to:from_];
-}
-
--(void) startWithTarget:(id) aTarget;
-{
- [super startWithTarget:aTarget];
-}
-
--(void) update: (ccTime) t
-{
- [(kProgressTimerCast)target_ setPercentage: from_ + ( to_ - from_ ) * t];
-}
-@end
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (c) 2009 On-Core
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-#import "CCActionGrid.h"
-
-/** CCShakyTiles3D action */
-@interface CCShakyTiles3D : CCTiledGrid3DAction
-{
- int randrange;
- BOOL shakeZ;
-}
-
-/** creates the action with a range, whether or not to shake Z vertices, a grid size, and duration */
-+(id)actionWithRange:(int)range shakeZ:(BOOL)shakeZ grid:(ccGridSize)gridSize duration:(ccTime)d;
-/** initializes the action with a range, whether or not to shake Z vertices, a grid size, and duration */
--(id)initWithRange:(int)range shakeZ:(BOOL)shakeZ grid:(ccGridSize)gridSize duration:(ccTime)d;
-
-@end
-
-////////////////////////////////////////////////////////////
-
-/** CCShatteredTiles3D action */
-@interface CCShatteredTiles3D : CCTiledGrid3DAction
-{
- int randrange;
- BOOL once;
- BOOL shatterZ;
-}
-
-/** creates the action with a range, whether of not to shatter Z vertices, a grid size and duration */
-+(id)actionWithRange:(int)range shatterZ:(BOOL)shatterZ grid:(ccGridSize)gridSize duration:(ccTime)d;
-/** initializes the action with a range, whether or not to shatter Z vertices, a grid size and duration */
--(id)initWithRange:(int)range shatterZ:(BOOL)shatterZ grid:(ccGridSize)gridSize duration:(ccTime)d;
-
-@end
-
-////////////////////////////////////////////////////////////
-
-/** CCShuffleTiles action
- Shuffle the tiles in random order
- */
-@interface CCShuffleTiles : CCTiledGrid3DAction
-{
- int seed;
- int tilesCount;
- int *tilesOrder;
- void *tiles;
-}
-
-/** creates the action with a random seed, the grid size and the duration */
-+(id)actionWithSeed:(int)s grid:(ccGridSize)gridSize duration:(ccTime)d;
-/** initializes the action with a random seed, the grid size and the duration */
--(id)initWithSeed:(int)s grid:(ccGridSize)gridSize duration:(ccTime)d;
-
-@end
-
-////////////////////////////////////////////////////////////
-
-/** CCFadeOutTRTiles action
- Fades out the tiles in a Top-Right direction
- */
-@interface CCFadeOutTRTiles : CCTiledGrid3DAction
-{
-}
-@end
-
-////////////////////////////////////////////////////////////
-
-/** CCFadeOutBLTiles action.
- Fades out the tiles in a Bottom-Left direction
- */
-@interface CCFadeOutBLTiles : CCFadeOutTRTiles
-{
-}
-@end
-
-////////////////////////////////////////////////////////////
-
-/** CCFadeOutUpTiles action.
- Fades out the tiles in upwards direction
- */
-@interface CCFadeOutUpTiles : CCFadeOutTRTiles
-{
-}
-@end
-
-////////////////////////////////////////////////////////////
-
-/** CCFadeOutDownTiles action.
- Fades out the tiles in downwards direction
- */
-@interface CCFadeOutDownTiles : CCFadeOutUpTiles
-{
-}
-@end
-
-////////////////////////////////////////////////////////////
-
-/** CCTurnOffTiles action.
- Turn off the files in random order
- */
-@interface CCTurnOffTiles : CCTiledGrid3DAction
-{
- int seed;
- int tilesCount;
- int *tilesOrder;
-}
-
-/** creates the action with a random seed, the grid size and the duration */
-+(id)actionWithSeed:(int)s grid:(ccGridSize)gridSize duration:(ccTime)d;
-/** initializes the action with a random seed, the grid size and the duration */
--(id)initWithSeed:(int)s grid:(ccGridSize)gridSize duration:(ccTime)d;
-@end
-
-////////////////////////////////////////////////////////////
-
-/** CCWavesTiles3D action. */
-@interface CCWavesTiles3D : CCTiledGrid3DAction
-{
- int waves;
- float amplitude;
- float amplitudeRate;
-}
-
-/** waves amplitude */
-@property (nonatomic,readwrite) float amplitude;
-/** waves amplitude rate */
-@property (nonatomic,readwrite) float amplitudeRate;
-
-/** creates the action with a number of waves, the waves amplitude, the grid size and the duration */
-+(id)actionWithWaves:(int)wav amplitude:(float)amp grid:(ccGridSize)gridSize duration:(ccTime)d;
-/** initializes the action with a number of waves, the waves amplitude, the grid size and the duration */
--(id)initWithWaves:(int)wav amplitude:(float)amp grid:(ccGridSize)gridSize duration:(ccTime)d;
-
-@end
-
-////////////////////////////////////////////////////////////
-
-/** CCJumpTiles3D action.
- A sin function is executed to move the tiles across the Z axis
- */
-@interface CCJumpTiles3D : CCTiledGrid3DAction
-{
- int jumps;
- float amplitude;
- float amplitudeRate;
-}
-
-/** amplitude of the sin*/
-@property (nonatomic,readwrite) float amplitude;
-/** amplitude rate */
-@property (nonatomic,readwrite) float amplitudeRate;
-
-/** creates the action with the number of jumps, the sin amplitude, the grid size and the duration */
-+(id)actionWithJumps:(int)j amplitude:(float)amp grid:(ccGridSize)gridSize duration:(ccTime)d;
-/** initializes the action with the number of jumps, the sin amplitude, the grid size and the duration */
--(id)initWithJumps:(int)j amplitude:(float)amp grid:(ccGridSize)gridSize duration:(ccTime)d;
-
-@end
-
-////////////////////////////////////////////////////////////
-
-/** CCSplitRows action */
-@interface CCSplitRows : CCTiledGrid3DAction
-{
- int rows;
- CGSize winSize;
-}
-/** creates the action with the number of rows to split and the duration */
-+(id)actionWithRows:(int)rows duration:(ccTime)duration;
-/** initializes the action with the number of rows to split and the duration */
--(id)initWithRows:(int)rows duration:(ccTime)duration;
-
-@end
-
-////////////////////////////////////////////////////////////
-
-/** CCSplitCols action */
-@interface CCSplitCols : CCTiledGrid3DAction
-{
- int cols;
- CGSize winSize;
-}
-/** creates the action with the number of columns to split and the duration */
-+(id)actionWithCols:(int)cols duration:(ccTime)duration;
-/** initializes the action with the number of columns to split and the duration */
--(id)initWithCols:(int)cols duration:(ccTime)duration;
-
-@end
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (c) 2009 On-Core
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-
-#import "CCActionTiledGrid.h"
-#import "CCDirector.h"
-#import "ccMacros.h"
-#import "Support/CGPointExtension.h"
-
-typedef struct
-{
- CGPoint position;
- CGPoint startPosition;
- ccGridSize delta;
-} Tile;
-
-#pragma mark -
-#pragma mark ShakyTiles3D
-
-@implementation CCShakyTiles3D
-
-+(id)actionWithRange:(int)range shakeZ:(BOOL)shakeZ grid:(ccGridSize)gridSize duration:(ccTime)d
-{
- return [[[self alloc] initWithRange:range shakeZ:shakeZ grid:gridSize duration:d] autorelease];
-}
-
--(id)initWithRange:(int)range shakeZ:(BOOL)sz grid:(ccGridSize)gSize duration:(ccTime)d
-{
- if ( (self = [super initWithSize:gSize duration:d]) )
- {
- randrange = range;
- shakeZ = sz;
- }
-
- return self;
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCGridAction *copy = [[[self class] allocWithZone:zone] initWithRange:randrange shakeZ:shakeZ grid:gridSize_ duration:duration_];
- return copy;
-}
-
-
--(void)update:(ccTime)time
-{
- int i, j;
-
- for( i = 0; i < gridSize_.x; i++ )
- {
- for( j = 0; j < gridSize_.y; j++ )
- {
- ccQuad3 coords = [self originalTile:ccg(i,j)];
-
- // X
- coords.bl.x += ( rand() % (randrange*2) ) - randrange;
- coords.br.x += ( rand() % (randrange*2) ) - randrange;
- coords.tl.x += ( rand() % (randrange*2) ) - randrange;
- coords.tr.x += ( rand() % (randrange*2) ) - randrange;
-
- // Y
- coords.bl.y += ( rand() % (randrange*2) ) - randrange;
- coords.br.y += ( rand() % (randrange*2) ) - randrange;
- coords.tl.y += ( rand() % (randrange*2) ) - randrange;
- coords.tr.y += ( rand() % (randrange*2) ) - randrange;
-
- if( shakeZ ) {
- coords.bl.z += ( rand() % (randrange*2) ) - randrange;
- coords.br.z += ( rand() % (randrange*2) ) - randrange;
- coords.tl.z += ( rand() % (randrange*2) ) - randrange;
- coords.tr.z += ( rand() % (randrange*2) ) - randrange;
- }
-
- [self setTile:ccg(i,j) coords:coords];
- }
- }
-}
-
-@end
-
-////////////////////////////////////////////////////////////
-
-#pragma mark -
-#pragma mark CCShatteredTiles3D
-
-@implementation CCShatteredTiles3D
-
-+(id)actionWithRange:(int)range shatterZ:(BOOL)sz grid:(ccGridSize)gridSize duration:(ccTime)d
-{
- return [[[self alloc] initWithRange:range shatterZ:sz grid:gridSize duration:d] autorelease];
-}
-
--(id)initWithRange:(int)range shatterZ:(BOOL)sz grid:(ccGridSize)gSize duration:(ccTime)d
-{
- if ( (self = [super initWithSize:gSize duration:d]) )
- {
- once = NO;
- randrange = range;
- shatterZ = sz;
- }
-
- return self;
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCGridAction *copy = [[[self class] allocWithZone:zone] initWithRange:randrange shatterZ:shatterZ grid:gridSize_ duration:duration_];
- return copy;
-}
-
-
--(void)update:(ccTime)time
-{
- int i, j;
-
- if ( once == NO )
- {
- for( i = 0; i < gridSize_.x; i++ )
- {
- for( j = 0; j < gridSize_.y; j++ )
- {
- ccQuad3 coords = [self originalTile:ccg(i,j)];
-
- // X
- coords.bl.x += ( rand() % (randrange*2) ) - randrange;
- coords.br.x += ( rand() % (randrange*2) ) - randrange;
- coords.tl.x += ( rand() % (randrange*2) ) - randrange;
- coords.tr.x += ( rand() % (randrange*2) ) - randrange;
-
- // Y
- coords.bl.y += ( rand() % (randrange*2) ) - randrange;
- coords.br.y += ( rand() % (randrange*2) ) - randrange;
- coords.tl.y += ( rand() % (randrange*2) ) - randrange;
- coords.tr.y += ( rand() % (randrange*2) ) - randrange;
-
- if( shatterZ ) {
- coords.bl.z += ( rand() % (randrange*2) ) - randrange;
- coords.br.z += ( rand() % (randrange*2) ) - randrange;
- coords.tl.z += ( rand() % (randrange*2) ) - randrange;
- coords.tr.z += ( rand() % (randrange*2) ) - randrange;
- }
-
- [self setTile:ccg(i,j) coords:coords];
- }
- }
-
- once = YES;
- }
-}
-
-@end
-
-////////////////////////////////////////////////////////////
-
-#pragma mark -
-#pragma mark CCShuffleTiles
-
-@implementation CCShuffleTiles
-
-+(id)actionWithSeed:(int)s grid:(ccGridSize)gridSize duration:(ccTime)d
-{
- return [[[self alloc] initWithSeed:s grid:gridSize duration:d] autorelease];
-}
-
--(id)initWithSeed:(int)s grid:(ccGridSize)gSize duration:(ccTime)d
-{
- if ( (self = [super initWithSize:gSize duration:d]) )
- {
- seed = s;
- tilesOrder = nil;
- tiles = nil;
- }
-
- return self;
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCGridAction *copy = [[[self class] allocWithZone:zone] initWithSeed:seed grid:gridSize_ duration:duration_];
- return copy;
-}
-
-
--(void)dealloc
-{
- if ( tilesOrder ) free(tilesOrder);
- if ( tiles ) free(tiles);
- [super dealloc];
-}
-
--(void)shuffle:(int*)array count:(int)len
-{
- int i;
- for( i = len - 1; i >= 0; i-- )
- {
- int j = rand() % (i+1);
- int v = array[i];
- array[i] = array[j];
- array[j] = v;
- }
-}
-
--(ccGridSize)getDelta:(ccGridSize)pos
-{
- CGPoint pos2;
-
- int idx = pos.x * gridSize_.y + pos.y;
-
- pos2.x = tilesOrder[idx] / (int)gridSize_.y;
- pos2.y = tilesOrder[idx] % (int)gridSize_.y;
-
- return ccg(pos2.x - pos.x, pos2.y - pos.y);
-}
-
--(void)placeTile:(ccGridSize)pos tile:(Tile)t
-{
- ccQuad3 coords = [self originalTile:pos];
-
- CGPoint step = [[target_ grid] step];
- coords.bl.x += (int)(t.position.x * step.x);
- coords.bl.y += (int)(t.position.y * step.y);
-
- coords.br.x += (int)(t.position.x * step.x);
- coords.br.y += (int)(t.position.y * step.y);
-
- coords.tl.x += (int)(t.position.x * step.x);
- coords.tl.y += (int)(t.position.y * step.y);
-
- coords.tr.x += (int)(t.position.x * step.x);
- coords.tr.y += (int)(t.position.y * step.y);
-
- [self setTile:pos coords:coords];
-}
-
--(void)startWithTarget:(id)aTarget
-{
- [super startWithTarget:aTarget];
-
- if ( seed != -1 )
- srand(seed);
-
- tilesCount = gridSize_.x * gridSize_.y;
- tilesOrder = (int*)malloc(tilesCount*sizeof(int));
- int i, j;
-
- for( i = 0; i < tilesCount; i++ )
- tilesOrder[i] = i;
-
- [self shuffle:tilesOrder count:tilesCount];
-
- tiles = malloc(tilesCount*sizeof(Tile));
- Tile *tileArray = (Tile*)tiles;
-
- for( i = 0; i < gridSize_.x; i++ )
- {
- for( j = 0; j < gridSize_.y; j++ )
- {
- tileArray->position = ccp(i,j);
- tileArray->startPosition = ccp(i,j);
- tileArray->delta = [self getDelta:ccg(i,j)];
- tileArray++;
- }
- }
-}
-
--(void)update:(ccTime)time
-{
- int i, j;
-
- Tile *tileArray = (Tile*)tiles;
-
- for( i = 0; i < gridSize_.x; i++ )
- {
- for( j = 0; j < gridSize_.y; j++ )
- {
- tileArray->position = ccpMult( ccp(tileArray->delta.x, tileArray->delta.y), time);
- [self placeTile:ccg(i,j) tile:*tileArray];
- tileArray++;
- }
- }
-}
-
-@end
-
-////////////////////////////////////////////////////////////
-
-#pragma mark -
-#pragma mark CCFadeOutTRTiles
-
-@implementation CCFadeOutTRTiles
-
--(float)testFunc:(ccGridSize)pos time:(ccTime)time
-{
- CGPoint n = ccpMult( ccp(gridSize_.x,gridSize_.y), time);
- if ( (n.x+n.y) == 0.0f )
- return 1.0f;
-
- return powf( (pos.x+pos.y) / (n.x+n.y), 6 );
-}
-
--(void)turnOnTile:(ccGridSize)pos
-{
- [self setTile:pos coords:[self originalTile:pos]];
-}
-
--(void)turnOffTile:(ccGridSize)pos
-{
- ccQuad3 coords;
- bzero(&coords, sizeof(ccQuad3));
- [self setTile:pos coords:coords];
-}
-
--(void)transformTile:(ccGridSize)pos distance:(float)distance
-{
- ccQuad3 coords = [self originalTile:pos];
- CGPoint step = [[target_ grid] step];
-
- coords.bl.x += (step.x / 2) * (1.0f - distance);
- coords.bl.y += (step.y / 2) * (1.0f - distance);
-
- coords.br.x -= (step.x / 2) * (1.0f - distance);
- coords.br.y += (step.y / 2) * (1.0f - distance);
-
- coords.tl.x += (step.x / 2) * (1.0f - distance);
- coords.tl.y -= (step.y / 2) * (1.0f - distance);
-
- coords.tr.x -= (step.x / 2) * (1.0f - distance);
- coords.tr.y -= (step.y / 2) * (1.0f - distance);
-
- [self setTile:pos coords:coords];
-}
-
--(void)update:(ccTime)time
-{
- int i, j;
-
- for( i = 0; i < gridSize_.x; i++ )
- {
- for( j = 0; j < gridSize_.y; j++ )
- {
- float distance = [self testFunc:ccg(i,j) time:time];
- if ( distance == 0 )
- [self turnOffTile:ccg(i,j)];
- else if ( distance < 1 )
- [self transformTile:ccg(i,j) distance:distance];
- else
- [self turnOnTile:ccg(i,j)];
- }
- }
-}
-
-@end
-
-////////////////////////////////////////////////////////////
-
-#pragma mark -
-#pragma mark CCFadeOutBLTiles
-
-@implementation CCFadeOutBLTiles
-
--(float)testFunc:(ccGridSize)pos time:(ccTime)time
-{
- CGPoint n = ccpMult(ccp(gridSize_.x, gridSize_.y), (1.0f-time));
- if ( (pos.x+pos.y) == 0 )
- return 1.0f;
-
- return powf( (n.x+n.y) / (pos.x+pos.y), 6 );
-}
-
-@end
-
-////////////////////////////////////////////////////////////
-
-#pragma mark -
-#pragma mark CCFadeOutUpTiles
-
-@implementation CCFadeOutUpTiles
-
--(float)testFunc:(ccGridSize)pos time:(ccTime)time
-{
- CGPoint n = ccpMult(ccp(gridSize_.x, gridSize_.y), time);
- if ( n.y == 0 )
- return 1.0f;
-
- return powf( pos.y / n.y, 6 );
-}
-
--(void)transformTile:(ccGridSize)pos distance:(float)distance
-{
- ccQuad3 coords = [self originalTile:pos];
- CGPoint step = [[target_ grid] step];
-
- coords.bl.y += (step.y / 2) * (1.0f - distance);
- coords.br.y += (step.y / 2) * (1.0f - distance);
- coords.tl.y -= (step.y / 2) * (1.0f - distance);
- coords.tr.y -= (step.y / 2) * (1.0f - distance);
-
- [self setTile:pos coords:coords];
-}
-
-@end
-
-////////////////////////////////////////////////////////////
-
-#pragma mark -
-#pragma mark CCFadeOutDownTiles
-
-@implementation CCFadeOutDownTiles
-
--(float)testFunc:(ccGridSize)pos time:(ccTime)time
-{
- CGPoint n = ccpMult(ccp(gridSize_.x,gridSize_.y), (1.0f - time));
- if ( pos.y == 0 )
- return 1.0f;
-
- return powf( n.y / pos.y, 6 );
-}
-
-@end
-
-////////////////////////////////////////////////////////////
-
-#pragma mark -
-#pragma mark TurnOffTiles
-
-@implementation CCTurnOffTiles
-
-+(id)actionWithSeed:(int)s grid:(ccGridSize)gridSize duration:(ccTime)d
-{
- return [[[self alloc] initWithSeed:s grid:gridSize duration:d] autorelease];
-}
-
--(id)initWithSeed:(int)s grid:(ccGridSize)gSize duration:(ccTime)d
-{
- if ( (self = [super initWithSize:gSize duration:d]) )
- {
- seed = s;
- tilesOrder = nil;
- }
-
- return self;
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCGridAction *copy = [[[self class] allocWithZone:zone] initWithSeed:seed grid:gridSize_ duration:duration_];
- return copy;
-}
-
--(void)dealloc
-{
- if ( tilesOrder ) free(tilesOrder);
- [super dealloc];
-}
-
--(void)shuffle:(int*)array count:(int)len
-{
- int i;
- for( i = len - 1; i >= 0; i-- )
- {
- int j = rand() % (i+1);
- int v = array[i];
- array[i] = array[j];
- array[j] = v;
- }
-}
-
--(void)turnOnTile:(ccGridSize)pos
-{
- [self setTile:pos coords:[self originalTile:pos]];
-}
-
--(void)turnOffTile:(ccGridSize)pos
-{
- ccQuad3 coords;
-
- bzero(&coords, sizeof(ccQuad3));
- [self setTile:pos coords:coords];
-}
-
--(void)startWithTarget:(id)aTarget
-{
- int i;
-
- [super startWithTarget:aTarget];
-
- if ( seed != -1 )
- srand(seed);
-
- tilesCount = gridSize_.x * gridSize_.y;
- tilesOrder = (int*)malloc(tilesCount*sizeof(int));
-
- for( i = 0; i < tilesCount; i++ )
- tilesOrder[i] = i;
-
- [self shuffle:tilesOrder count:tilesCount];
-}
-
--(void)update:(ccTime)time
-{
- int i, l, t;
-
- l = (int)(time * (float)tilesCount);
-
- for( i = 0; i < tilesCount; i++ )
- {
- t = tilesOrder[i];
- ccGridSize tilePos = ccg( t / gridSize_.y, t % gridSize_.y );
-
- if ( i < l )
- [self turnOffTile:tilePos];
- else
- [self turnOnTile:tilePos];
- }
-}
-
-@end
-
-////////////////////////////////////////////////////////////
-
-#pragma mark -
-#pragma mark CCWavesTiles3D
-
-@implementation CCWavesTiles3D
-
-@synthesize amplitude;
-@synthesize amplitudeRate;
-
-+(id)actionWithWaves:(int)wav amplitude:(float)amp grid:(ccGridSize)gridSize duration:(ccTime)d
-{
- return [[[self alloc] initWithWaves:wav amplitude:amp grid:gridSize duration:d] autorelease];
-}
-
--(id)initWithWaves:(int)wav amplitude:(float)amp grid:(ccGridSize)gSize duration:(ccTime)d
-{
- if ( (self = [super initWithSize:gSize duration:d]) )
- {
- waves = wav;
- amplitude = amp;
- amplitudeRate = 1.0f;
- }
-
- return self;
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCGridAction *copy = [[[self class] allocWithZone:zone] initWithWaves:waves amplitude:amplitude grid:gridSize_ duration:duration_];
- return copy;
-}
-
-
--(void)update:(ccTime)time
-{
- int i, j;
-
- for( i = 0; i < gridSize_.x; i++ )
- {
- for( j = 0; j < gridSize_.y; j++ )
- {
- ccQuad3 coords = [self originalTile:ccg(i,j)];
-
- coords.bl.z = (sinf(time*(CGFloat)M_PI*waves*2 + (coords.bl.y+coords.bl.x) * .01f) * amplitude * amplitudeRate );
- coords.br.z = coords.bl.z;
- coords.tl.z = coords.bl.z;
- coords.tr.z = coords.bl.z;
-
- [self setTile:ccg(i,j) coords:coords];
- }
- }
-}
-@end
-
-////////////////////////////////////////////////////////////
-
-#pragma mark -
-#pragma mark CCJumpTiles3D
-
-@implementation CCJumpTiles3D
-
-@synthesize amplitude;
-@synthesize amplitudeRate;
-
-+(id)actionWithJumps:(int)j amplitude:(float)amp grid:(ccGridSize)gridSize duration:(ccTime)d
-{
- return [[[self alloc] initWithJumps:j amplitude:amp grid:gridSize duration:d] autorelease];
-}
-
--(id)initWithJumps:(int)j amplitude:(float)amp grid:(ccGridSize)gSize duration:(ccTime)d
-{
- if ( (self = [super initWithSize:gSize duration:d]) )
- {
- jumps = j;
- amplitude = amp;
- amplitudeRate = 1.0f;
- }
-
- return self;
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCGridAction *copy = [[[self class] allocWithZone:zone] initWithJumps:jumps amplitude:amplitude grid:gridSize_ duration:duration_];
- return copy;
-}
-
-
--(void)update:(ccTime)time
-{
- int i, j;
-
- float sinz = (sinf((CGFloat)M_PI*time*jumps*2) * amplitude * amplitudeRate );
- float sinz2 = (sinf((CGFloat)M_PI*(time*jumps*2 + 1)) * amplitude * amplitudeRate );
-
- for( i = 0; i < gridSize_.x; i++ )
- {
- for( j = 0; j < gridSize_.y; j++ )
- {
- ccQuad3 coords = [self originalTile:ccg(i,j)];
-
- if ( ((i+j) % 2) == 0 )
- {
- coords.bl.z += sinz;
- coords.br.z += sinz;
- coords.tl.z += sinz;
- coords.tr.z += sinz;
- }
- else
- {
- coords.bl.z += sinz2;
- coords.br.z += sinz2;
- coords.tl.z += sinz2;
- coords.tr.z += sinz2;
- }
-
- [self setTile:ccg(i,j) coords:coords];
- }
- }
-}
-@end
-
-////////////////////////////////////////////////////////////
-
-#pragma mark -
-#pragma mark SplitRows
-
-@implementation CCSplitRows
-
-+(id)actionWithRows:(int)r duration:(ccTime)d
-{
- return [[[self alloc] initWithRows:r duration:d] autorelease];
-}
-
--(id)initWithRows:(int)r duration:(ccTime)d
-{
- rows = r;
- return [super initWithSize:ccg(1,r) duration:d];
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCGridAction *copy = [[[self class] allocWithZone:zone] initWithRows:rows duration:duration_];
- return copy;
-}
-
--(void)startWithTarget:(id)aTarget
-{
- [super startWithTarget:aTarget];
- winSize = [[CCDirector sharedDirector] winSizeInPixels];
-}
-
--(void)update:(ccTime)time
-{
- int j;
-
- for( j = 0; j < gridSize_.y; j++ )
- {
- ccQuad3 coords = [self originalTile:ccg(0,j)];
- float direction = 1;
-
- if ( (j % 2 ) == 0 )
- direction = -1;
-
- coords.bl.x += direction * winSize.width * time;
- coords.br.x += direction * winSize.width * time;
- coords.tl.x += direction * winSize.width * time;
- coords.tr.x += direction * winSize.width * time;
-
- [self setTile:ccg(0,j) coords:coords];
- }
-}
-
-@end
-
-////////////////////////////////////////////////////////////
-
-#pragma mark -
-#pragma mark CCSplitCols
-
-@implementation CCSplitCols
-
-+(id)actionWithCols:(int)c duration:(ccTime)d
-{
- return [[[self alloc] initWithCols:c duration:d] autorelease];
-}
-
--(id)initWithCols:(int)c duration:(ccTime)d
-{
- cols = c;
- return [super initWithSize:ccg(c,1) duration:d];
-}
-
--(id) copyWithZone: (NSZone*) zone
-{
- CCGridAction *copy = [[[self class] allocWithZone:zone] initWithCols:cols duration:duration_];
- return copy;
-}
-
--(void)startWithTarget:(id)aTarget
-{
- [super startWithTarget:aTarget];
- winSize = [[CCDirector sharedDirector] winSizeInPixels];
-}
-
--(void)update:(ccTime)time
-{
- int i;
-
- for( i = 0; i < gridSize_.x; i++ )
- {
- ccQuad3 coords = [self originalTile:ccg(i,0)];
- float direction = 1;
-
- if ( (i % 2 ) == 0 )
- direction = -1;
-
- coords.bl.y += direction * winSize.height * time;
- coords.br.y += direction * winSize.height * time;
- coords.tl.y += direction * winSize.height * time;
- coords.tr.y += direction * winSize.height * time;
-
- [self setTile:ccg(i,0) coords:coords];
- }
-}
-
-@end
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright 2009 lhunath (Maarten Billemont)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-
-#import <Foundation/Foundation.h>
-#import "CCActionInterval.h"
-
-/** CCActionTween
-
- CCActionTween is an action that lets you update any property of an object.
- For example, if you want to modify the "width" property of a target from 200 to 300 in 2 senconds, then:
-
- id modifyWidth = [CCActionTween actionWithDuration:2 key:@"width" from:200 to:300];
- [target runAction:modifyWidth];
-
-
- Another example: CCScaleTo action could be rewriten using CCPropertyAction:
-
- // scaleA and scaleB are equivalents
- id scaleA = [CCScaleTo actionWithDuration:2 scale:3];
- id scaleB = [CCActionTween actionWithDuration:2 key:@"scale" from:1 to:3];
-
-
- @since v0.99.2
- */
-@interface CCActionTween : CCActionInterval
-{
- NSString *key_;
-
- float from_, to_;
- float delta_;
-}
-
-/** creates an initializes the action with the property name (key), and the from and to parameters. */
-+ (id)actionWithDuration:(ccTime)aDuration key:(NSString *)key from:(float)from to:(float)to;
-
-/** initializes the action with the property name (key), and the from and to parameters. */
-- (id)initWithDuration:(ccTime)aDuration key:(NSString *)key from:(float)from to:(float)to;
-
-@end
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright 2009 lhunath (Maarten Billemont)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-#import "CCActionTween.h"
-
-
-@implementation CCActionTween
-
-+ (id)actionWithDuration:(ccTime)aDuration key:(NSString *)aKey from:(float)aFrom to:(float)aTo {
-
- return [[[[self class] alloc] initWithDuration:aDuration key:aKey from:aFrom to:aTo] autorelease];
-}
-
-- (id)initWithDuration:(ccTime)aDuration key:(NSString *)key from:(float)from to:(float)to {
-
- if ((self = [super initWithDuration:aDuration])) {
-
- key_ = [key copy];
- to_ = to;
- from_ = from;
-
- }
-
- return self;
-}
-
-- (void) dealloc
-{
- [key_ release];
- [super dealloc];
-}
-
-- (void)startWithTarget:aTarget
-{
- [super startWithTarget:aTarget];
- delta_ = to_ - from_;
-}
-
-- (void) update:(ccTime) dt
-{
- [target_ setValue:[NSNumber numberWithFloat:to_ - delta_ * (1 - dt)] forKey:key_];
-}
-
-- (CCActionInterval *) reverse
-{
- return [[self class] actionWithDuration:duration_ key:key_ from:to_ to:from_];
-}
-
-
-@end
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (c) 2008-2010 Ricardo Quesada
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-#import <Foundation/Foundation.h>
-
-@class CCSpriteFrame;
-@class CCTexture2D;
-
-/** A CCAnimation object is used to perform animations on the CCSprite objects.
-
- The CCAnimation object contains CCSpriteFrame objects, and a possible delay between the frames.
- You can animate a CCAnimation object by using the CCAnimate action. Example:
-
- [sprite runAction:[CCAnimate actionWithAnimation:animation]];
-
- */
-@interface CCAnimation : NSObject
-{
- NSString *name_;
- float delay_;
- NSMutableArray *frames_;
-}
-
-/** name of the animation */
-@property (nonatomic,readwrite,retain) NSString *name;
-/** delay between frames in seconds. */
-@property (nonatomic,readwrite,assign) float delay;
-/** array of frames */
-@property (nonatomic,readwrite,retain) NSMutableArray *frames;
-
-/** Creates an animation
- @since v0.99.5
- */
-+(id) animation;
-
-/** Creates an animation with frames.
- @since v0.99.5
- */
-+(id) animationWithFrames:(NSArray*)frames;
-
-/* Creates an animation with frames and a delay between frames.
- @since v0.99.5
- */
-+(id) animationWithFrames:(NSArray*)frames delay:(float)delay;
-
-/** Creates a CCAnimation with a name
- @since v0.99.3
- @deprecated Will be removed in 1.0.1. Use "animation" instead.
- */
-+(id) animationWithName:(NSString*)name DEPRECATED_ATTRIBUTE;
-
-/** Creates a CCAnimation with a name and frames
- @since v0.99.3
- @deprecated Will be removed in 1.0.1. Use "animationWithFrames" instead.
- */
-+(id) animationWithName:(NSString*)name frames:(NSArray*)frames DEPRECATED_ATTRIBUTE;
-
-/** Creates a CCAnimation with a name and delay between frames. */
-+(id) animationWithName:(NSString*)name delay:(float)delay DEPRECATED_ATTRIBUTE;
-
-/** Creates a CCAnimation with a name, delay and an array of CCSpriteFrames. */
-+(id) animationWithName:(NSString*)name delay:(float)delay frames:(NSArray*)frames DEPRECATED_ATTRIBUTE;
-
-
-/** Initializes a CCAnimation with frames.
- @since v0.99.5
-*/
--(id) initWithFrames:(NSArray*)frames;
-
-/** Initializes a CCAnimation with frames and a delay between frames
- @since v0.99.5
- */
--(id) initWithFrames:(NSArray *)frames delay:(float)delay;
-
-/** Initializes a CCAnimation with a name
- @since v0.99.3
- @deprecated Will be removed in 1.0.1. Use "init" instead.
- */
--(id) initWithName:(NSString*)name DEPRECATED_ATTRIBUTE;
-
-/** Initializes a CCAnimation with a name and frames
- @since v0.99.3
- @deprecated Will be removed in 1.0.1. Use "initWithFrames" instead.
- */
--(id) initWithName:(NSString*)name frames:(NSArray*)frames DEPRECATED_ATTRIBUTE;
-
-/** Initializes a CCAnimation with a name and delay between frames.
- @deprecated Will be removed in 1.0.1. Use "initWithFrames:nil delay:delay" instead.
-*/
--(id) initWithName:(NSString*)name delay:(float)delay DEPRECATED_ATTRIBUTE;
-
-/** Initializes a CCAnimation with a name, delay and an array of CCSpriteFrames.
- @deprecated Will be removed in 1.0.1. Use "initWithFrames:frames delay:delay" instead.
-*/
--(id) initWithName:(NSString*)name delay:(float)delay frames:(NSArray*)frames DEPRECATED_ATTRIBUTE;
-
-/** Adds a frame to a CCAnimation. */
--(void) addFrame:(CCSpriteFrame*)frame;
-
-/** Adds a frame with an image filename. Internally it will create a CCSpriteFrame and it will add it.
- Added to facilitate the migration from v0.8 to v0.9.
- */
--(void) addFrameWithFilename:(NSString*)filename;
-
-/** Adds a frame with a texture and a rect. Internally it will create a CCSpriteFrame and it will add it.
- Added to facilitate the migration from v0.8 to v0.9.
- */
--(void) addFrameWithTexture:(CCTexture2D*)texture rect:(CGRect)rect;
-
-@end
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (c) 2008-2010 Ricardo Quesada
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-#import "ccMacros.h"
-#import "CCAnimation.h"
-#import "CCSpriteFrame.h"
-#import "CCTexture2D.h"
-#import "CCTextureCache.h"
-
-@implementation CCAnimation
-@synthesize name = name_, delay = delay_, frames = frames_;
-
-+(id) animation
-{
- return [[[self alloc] init] autorelease];
-}
-
-+(id) animationWithFrames:(NSArray*)frames
-{
- return [[[self alloc] initWithFrames:frames] autorelease];
-}
-
-+(id) animationWithFrames:(NSArray*)frames delay:(float)delay
-{
- return [[[self alloc] initWithFrames:frames delay:delay] autorelease];
-}
-
-+(id) animationWithName:(NSString*)name
-{
- return [[[self alloc] initWithName:name] autorelease];
-}
-
-+(id) animationWithName:(NSString*)name frames:(NSArray*)frames
-{
- return [[[self alloc] initWithName:name frames:frames] autorelease];
-}
-
-+(id) animationWithName:(NSString*)aname delay:(float)d frames:(NSArray*)array
-{
- return [[[self alloc] initWithName:aname delay:d frames:array] autorelease];
-}
-
-+(id) animationWithName:(NSString*)aname delay:(float)d
-{
- return [[[self alloc] initWithName:aname delay:d] autorelease];
-}
-
--(id) init
-{
- return [self initWithFrames:nil delay:0];
-}
-
--(id) initWithFrames:(NSArray*)frames
-{
- return [self initWithFrames:frames delay:0];
-}
-
--(id) initWithFrames:(NSArray*)array delay:(float)delay
-{
- if( (self=[super init]) ) {
-
- delay_ = delay;
- self.frames = [NSMutableArray arrayWithArray:array];
- }
- return self;
-}
-
--(id) initWithName:(NSString*)name
-{
- return [self initWithName:name delay:0 frames:nil];
-}
-
--(id) initWithName:(NSString*)name frames:(NSArray*)frames
-{
- return [self initWithName:name delay:0 frames:frames];
-}
-
--(id) initWithName:(NSString*)t delay:(float)d
-{
- return [self initWithName:t delay:d frames:nil];
-}
-
--(id) initWithName:(NSString*)name delay:(float)delay frames:(NSArray*)array
-{
- if( (self=[super init]) ) {
-
- delay_ = delay;
- self.name = name;
- self.frames = [NSMutableArray arrayWithArray:array];
- }
- return self;
-}
-
-- (NSString*) description
-{
- return [NSString stringWithFormat:@"<%@ = %08X | frames=%d, delay:%f>", [self class], self,
- [frames_ count],
- delay_
- ];
-}
-
--(void) dealloc
-{
- CCLOGINFO( @"cocos2d: deallocing %@",self);
- [name_ release];
- [frames_ release];
- [super dealloc];
-}
-
--(void) addFrame:(CCSpriteFrame*)frame
-{
- [frames_ addObject:frame];
-}
-
--(void) addFrameWithFilename:(NSString*)filename
-{
- CCTexture2D *texture = [[CCTextureCache sharedTextureCache] addImage:filename];
- CGRect rect = CGRectZero;
- rect.size = texture.contentSize;
- CCSpriteFrame *frame = [CCSpriteFrame frameWithTexture:texture rect:rect];
- [frames_ addObject:frame];
-}
-
--(void) addFrameWithTexture:(CCTexture2D*)texture rect:(CGRect)rect
-{
- CCSpriteFrame *frame = [CCSpriteFrame frameWithTexture:texture rect:rect];
- [frames_ addObject:frame];
-}
-
-@end
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (c) 2010 Ricardo Quesada
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-#import <Foundation/Foundation.h>
-
-@class CCAnimation;
-
-/** Singleton that manages the Animations.
- It saves in a cache the animations. You should use this class if you want to save your animations in a cache.
-
- Before v0.99.5, the recommend way was to save them on the CCSprite. Since v0.99.5, you should use this class instead.
-
- @since v0.99.5
- */
-@interface CCAnimationCache : NSObject
-{
- NSMutableDictionary *animations_;
-}
-
-/** Retruns ths shared instance of the Animation cache */
-+ (CCAnimationCache *) sharedAnimationCache;
-
-/** Purges the cache. It releases all the CCAnimation objects and the shared instance.
- */
-+(void)purgeSharedAnimationCache;
-
-/** Adds a CCAnimation with a name.
- */
--(void) addAnimation:(CCAnimation*)animation name:(NSString*)name;
-
-/** Deletes a CCAnimation from the cache.
- */
--(void) removeAnimationByName:(NSString*)name;
-
-/** Returns a CCAnimation that was previously added.
- If the name is not found it will return nil.
- You should retain the returned copy if you are going to use it.
- */
--(CCAnimation*) animationByName:(NSString*)name;
-
-@end
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (c) 2010 Ricardo Quesada
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-#import "ccMacros.h"
-#import "CCAnimationCache.h"
-#import "CCAnimation.h"
-#import "CCSprite.h"
-
-
-@implementation CCAnimationCache
-
-#pragma mark CCAnimationCache - Alloc, Init & Dealloc
-
-static CCAnimationCache *sharedAnimationCache_=nil;
-
-+ (CCAnimationCache *)sharedAnimationCache
-{
- if (!sharedAnimationCache_)
- sharedAnimationCache_ = [[CCAnimationCache alloc] init];
-
- return sharedAnimationCache_;
-}
-
-+(id)alloc
-{
- NSAssert(sharedAnimationCache_ == nil, @"Attempted to allocate a second instance of a singleton.");
- return [super alloc];
-}
-
-+(void)purgeSharedAnimationCache
-{
- [sharedAnimationCache_ release];
- sharedAnimationCache_ = nil;
-}
-
--(id) init
-{
- if( (self=[super init]) ) {
- animations_ = [[NSMutableDictionary alloc] initWithCapacity: 20];
- }
-
- return self;
-}
-
-- (NSString*) description
-{
- return [NSString stringWithFormat:@"<%@ = %08X | num of animations = %i>", [self class], self, [animations_ count]];
-}
-
--(void) dealloc
-{
- CCLOGINFO(@"cocos2d: deallocing %@", self);
-
- [animations_ release];
- [super dealloc];
-}
-
-#pragma mark CCAnimationCache - load/get/del
-
--(void) addAnimation:(CCAnimation*)animation name:(NSString*)name
-{
- [animations_ setObject:animation forKey:name];
-}
-
--(void) removeAnimationByName:(NSString*)name
-{
- if( ! name )
- return;
-
- [animations_ removeObjectForKey:name];
-}
-
--(CCAnimation*) animationByName:(NSString*)name
-{
- return [animations_ objectForKey:name];
-}
-
-@end
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (c) 2008-2010 Ricardo Quesada
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-
-#import "CCTextureAtlas.h"
-#import "CCNode.h"
-#import "CCProtocols.h"
-
-/** CCAtlasNode is a subclass of CCNode that implements the CCRGBAProtocol and
- CCTextureProtocol protocol
-
- It knows how to render a TextureAtlas object.
- If you are going to render a TextureAtlas consider subclassing CCAtlasNode (or a subclass of CCAtlasNode)
-
- All features from CCNode are valid, plus the following features:
- - opacity and RGB colors
- */
-@interface CCAtlasNode : CCNode <CCRGBAProtocol, CCTextureProtocol>
-{
- // texture atlas
- CCTextureAtlas *textureAtlas_;
-
- // chars per row
- int itemsPerRow_;
- // chars per column
- int itemsPerColumn_;
-
- // width of each char
- int itemWidth_;
- // height of each char
- int itemHeight_;
-
- // blend function
- ccBlendFunc blendFunc_;
-
- // texture RGBA.
- GLubyte opacity_;
- ccColor3B color_;
- ccColor3B colorUnmodified_;
- BOOL opacityModifyRGB_;
-}
-
-/** conforms to CCTextureProtocol protocol */
-@property (nonatomic,readwrite,retain) CCTextureAtlas *textureAtlas;
-
-/** conforms to CCTextureProtocol protocol */
-@property (nonatomic,readwrite) ccBlendFunc blendFunc;
-
-/** conforms to CCRGBAProtocol protocol */
-@property (nonatomic,readwrite) GLubyte opacity;
-/** conforms to CCRGBAProtocol protocol */
-@property (nonatomic,readwrite) ccColor3B color;
-
-
-/** creates a CCAtlasNode with an Atlas file the width and height of each item measured in points and the quantity of items to render*/
-+(id) atlasWithTileFile:(NSString*)tile tileWidth:(int)w tileHeight:(int)h itemsToRender: (int) c;
-
-/** initializes an CCAtlasNode with an Atlas file the width and height of each item measured in points and the quantity of items to render*/
--(id) initWithTileFile:(NSString*)tile tileWidth:(int)w tileHeight:(int)h itemsToRender: (int) c;
-
-/** updates the Atlas (indexed vertex array).
- * Shall be overriden in subclasses
- */
--(void) updateAtlasValues;
-@end
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (c) 2008-2010 Ricardo Quesada
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-
-#import "CCAtlasNode.h"
-#import "ccMacros.h"
-
-
-@interface CCAtlasNode ()
--(void) calculateMaxItems;
--(void) updateBlendFunc;
--(void) updateOpacityModifyRGB;
-@end
-
-@implementation CCAtlasNode
-
-@synthesize textureAtlas = textureAtlas_;
-@synthesize blendFunc = blendFunc_;
-
-#pragma mark CCAtlasNode - Creation & Init
-+(id) atlasWithTileFile:(NSString*)tile tileWidth:(int)w tileHeight:(int)h itemsToRender: (int) c
-{
- return [[[self alloc] initWithTileFile:tile tileWidth:w tileHeight:h itemsToRender:c] autorelease];
-}
-
--(id) initWithTileFile:(NSString*)tile tileWidth:(int)w tileHeight:(int)h itemsToRender: (int) c
-{
- if( (self=[super init]) ) {
-
- itemWidth_ = w * CC_CONTENT_SCALE_FACTOR();
- itemHeight_ = h * CC_CONTENT_SCALE_FACTOR();
-
- opacity_ = 255;
- color_ = colorUnmodified_ = ccWHITE;
- opacityModifyRGB_ = YES;
-
- blendFunc_.src = CC_BLEND_SRC;
- blendFunc_.dst = CC_BLEND_DST;
-
- // double retain to avoid the autorelease pool
- // also, using: self.textureAtlas supports re-initialization without leaking
- self.textureAtlas = [[CCTextureAtlas alloc] initWithFile:tile capacity:c];
- [textureAtlas_ release];
-
- if( ! textureAtlas_ ) {
- CCLOG(@"cocos2d: Could not initialize CCAtlasNode. Invalid Texture");
- [self release];
- return nil;
- }
-
- [self updateBlendFunc];
- [self updateOpacityModifyRGB];
-
- [self calculateMaxItems];
-
- }
- return self;
-}
-
--(void) dealloc
-{
- [textureAtlas_ release];
-
- [super dealloc];
-}
-
-#pragma mark CCAtlasNode - Atlas generation
-
--(void) calculateMaxItems
-{
- CGSize s = [[textureAtlas_ texture] contentSizeInPixels];
- itemsPerColumn_ = s.height / itemHeight_;
- itemsPerRow_ = s.width / itemWidth_;
-}
-
--(void) updateAtlasValues
-{
- [NSException raise:@"CCAtlasNode:Abstract" format:@"updateAtlasValue not overriden"];
-}
-
-#pragma mark CCAtlasNode - draw
-- (void) draw
-{
- // Default GL states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
- // Needed states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_TEXTURE_COORD_ARRAY
- // Unneeded states: GL_COLOR_ARRAY
- glDisableClientState(GL_COLOR_ARRAY);
-
- glColor4ub( color_.r, color_.g, color_.b, opacity_);
-
- BOOL newBlend = blendFunc_.src != CC_BLEND_SRC || blendFunc_.dst != CC_BLEND_DST;
- if( newBlend )
- glBlendFunc( blendFunc_.src, blendFunc_.dst );
-
- [textureAtlas_ drawQuads];
-
- if( newBlend )
- glBlendFunc(CC_BLEND_SRC, CC_BLEND_DST);
-
- // is this chepear than saving/restoring color state ?
- // XXX: There is no need to restore the color to (255,255,255,255). Objects should use the color
- // XXX: that they need
-// glColor4ub( 255, 255, 255, 255);
-
- // restore default GL state
- glEnableClientState(GL_COLOR_ARRAY);
-
-}
-
-#pragma mark CCAtlasNode - RGBA protocol
-
-- (ccColor3B) color
-{
- if(opacityModifyRGB_)
- return colorUnmodified_;
-
- return color_;
-}
-
--(void) setColor:(ccColor3B)color3
-{
- color_ = colorUnmodified_ = color3;
-
- if( opacityModifyRGB_ ){
- color_.r = color3.r * opacity_/255;
- color_.g = color3.g * opacity_/255;
- color_.b = color3.b * opacity_/255;
- }
-}
-
--(GLubyte) opacity
-{
- return opacity_;
-}
-
--(void) setOpacity:(GLubyte) anOpacity
-{
- opacity_ = anOpacity;
-
- // special opacity for premultiplied textures
- if( opacityModifyRGB_ )
- [self setColor: colorUnmodified_];
-}
-
--(void) setOpacityModifyRGB:(BOOL)modify
-{
- ccColor3B oldColor = self.color;
- opacityModifyRGB_ = modify;
- self.color = oldColor;
-}
-
--(BOOL) doesOpacityModifyRGB
-{
- return opacityModifyRGB_;
-}
-
--(void) updateOpacityModifyRGB
-{
- opacityModifyRGB_ = [textureAtlas_.texture hasPremultipliedAlpha];
-}
-
-#pragma mark CCAtlasNode - CocosNodeTexture protocol
-
--(void) updateBlendFunc
-{
- if( ! [textureAtlas_.texture hasPremultipliedAlpha] ) {
- blendFunc_.src = GL_SRC_ALPHA;
- blendFunc_.dst = GL_ONE_MINUS_SRC_ALPHA;
- }
-}
-
--(void) setTexture:(CCTexture2D*)texture
-{
- textureAtlas_.texture = texture;
- [self updateBlendFunc];
- [self updateOpacityModifyRGB];
-}
-
--(CCTexture2D*) texture
-{
- return textureAtlas_.texture;
-}
-
-@end
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (c) 2010 Stuart Carnie
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-
-#import <Foundation/Foundation.h>
-
-/** @file
- cocos2d blocks support
- */
-
-// To comply with Apple Objective C runtime (this is defined in NSObjCRuntime.h)
-#if !defined(NS_BLOCKS_AVAILABLE)
- #if __BLOCKS__
- #define NS_BLOCKS_AVAILABLE 1
- #else
- #define NS_BLOCKS_AVAILABLE 0
- #endif
-#endif
-
-#if NS_BLOCKS_AVAILABLE
-
-@interface NSObject(CCBlocksAdditions)
-
-- (void)ccCallbackBlock;
-- (void)ccCallbackBlockWithSender:(id)sender;
-
-@end
-
-#endif // NS_BLOCKS_AVAILABLE
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (c) 2010 Stuart Carnie
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-
-#import "CCBlockSupport.h"
-
-#if NS_BLOCKS_AVAILABLE
-
-@implementation NSObject(CCBlocksAdditions)
-
-- (void)ccCallbackBlock {
- void (^block)(void) = (id)self;
- block();
-}
-
-- (void)ccCallbackBlockWithSender:(id)sender {
- void (^block)(id) = (id)self;
- block(sender);
-}
-
-
-@end
-
-#endif
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (c) 2008-2010 Ricardo Quesada
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-
-
-#import "CCNode.h"
-
-/**
- A CCCamera is used in every CCNode.
- Useful to look at the object from different views.
- The OpenGL gluLookAt() function is used to locate the
- camera.
-
- If the object is transformed by any of the scale, rotation or
- position attributes, then they will override the camera.
-
- IMPORTANT: Either your use the camera or the rotation/scale/position properties. You can't use both.
- World coordinates won't work if you use the camera.
-
- Limitations:
-
- - Some nodes, like CCParallaxNode, CCParticle uses world node coordinates, and they won't work properly if you move them (or any of their ancestors)
- using the camera.
-
- - It doesn't work on batched nodes like CCSprite objects when they are parented to a CCSpriteBatchNode object.
-
- - It is recommended to use it ONLY if you are going to create 3D effects. For 2D effecs, use the action CCFollow or position/scale/rotate.
-
-*/
-
-@interface CCCamera : NSObject
-{
- float eyeX_;
- float eyeY_;
- float eyeZ_;
-
- float centerX_;
- float centerY_;
- float centerZ_;
-
- float upX_;
- float upY_;
- float upZ_;
-
- BOOL dirty_;
-}
-
-/** whether of not the camera is dirty */
-@property (nonatomic,readwrite) BOOL dirty;
-
-/** returns the Z eye */
-+(float) getZEye;
-
-/** sets the camera in the defaul position */
--(void) restore;
-/** Sets the camera using gluLookAt using its eye, center and up_vector */
--(void) locate;
-/** sets the eye values in points */
--(void) setEyeX: (float)x eyeY:(float)y eyeZ:(float)z;
-/** sets the center values in points */
--(void) setCenterX: (float)x centerY:(float)y centerZ:(float)z;
-/** sets the up values */
--(void) setUpX: (float)x upY:(float)y upZ:(float)z;
-
-/** get the eye vector values in points */
--(void) eyeX:(float*)x eyeY:(float*)y eyeZ:(float*)z;
-/** get the center vector values in points */
--(void) centerX:(float*)x centerY:(float*)y centerZ:(float*)z;
-/** get the up vector values */
--(void) upX:(float*)x upY:(float*)y upZ:(float*)z;
-
-
-@end
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (c) 2008-2010 Ricardo Quesada
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-
-#import "Platforms/CCGL.h"
-#import "CCCamera.h"
-#import "ccMacros.h"
-#import "CCDrawingPrimitives.h"
-
-@implementation CCCamera
-
-@synthesize dirty = dirty_;
-
--(id) init
-{
- if( (self=[super init]) )
- [self restore];
-
- return self;
-}
-
-- (NSString*) description
-{
- return [NSString stringWithFormat:@"<%@ = %08X | center = (%.2f,%.2f,%.2f)>", [self class], self, centerX_, centerY_, centerZ_];
-}
-
-
-- (void) dealloc
-{
- CCLOGINFO(@"cocos2d: deallocing %@", self);
- [super dealloc];
-}
-
--(void) restore
-{
- eyeX_ = eyeY_ = 0;
- eyeZ_ = [CCCamera getZEye];
-
- centerX_ = centerY_ = centerZ_ = 0;
-
- upX_ = 0.0f;
- upY_ = 1.0f;
- upZ_ = 0.0f;
-
- dirty_ = NO;
-}
-
--(void) locate
-{
- if( dirty_ )
- gluLookAt( eyeX_, eyeY_, eyeZ_,
- centerX_, centerY_, centerZ_,
- upX_, upY_, upZ_
- );
-}
-
-+(float) getZEye
-{
- return FLT_EPSILON;
-// CGSize s = [[CCDirector sharedDirector] displaySize];
-// return ( s.height / 1.1566f );
-}
-
--(void) setEyeX: (float)x eyeY:(float)y eyeZ:(float)z
-{
- eyeX_ = x * CC_CONTENT_SCALE_FACTOR();
- eyeY_ = y * CC_CONTENT_SCALE_FACTOR();
- eyeZ_ = z * CC_CONTENT_SCALE_FACTOR();
- dirty_ = YES;
-}
-
--(void) setCenterX: (float)x centerY:(float)y centerZ:(float)z
-{
- centerX_ = x * CC_CONTENT_SCALE_FACTOR();
- centerY_ = y * CC_CONTENT_SCALE_FACTOR();
- centerZ_ = z * CC_CONTENT_SCALE_FACTOR();
- dirty_ = YES;
-}
-
--(void) setUpX: (float)x upY:(float)y upZ:(float)z
-{
- upX_ = x;
- upY_ = y;
- upZ_ = z;
- dirty_ = YES;
-}
-
--(void) eyeX: (float*)x eyeY:(float*)y eyeZ:(float*)z
-{
- *x = eyeX_ / CC_CONTENT_SCALE_FACTOR();
- *y = eyeY_ / CC_CONTENT_SCALE_FACTOR();
- *z = eyeZ_ / CC_CONTENT_SCALE_FACTOR();
-}
-
--(void) centerX: (float*)x centerY:(float*)y centerZ:(float*)z
-{
- *x = centerX_ / CC_CONTENT_SCALE_FACTOR();
- *y = centerY_ / CC_CONTENT_SCALE_FACTOR();
- *z = centerZ_ / CC_CONTENT_SCALE_FACTOR();
-}
-
--(void) upX: (float*)x upY:(float*)y upZ:(float*)z
-{
- *x = upX_;
- *y = upY_;
- *z = upZ_;
-}
-
-@end
+++ /dev/null
-
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (c) 2008-2010 Ricardo Quesada
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-// AUTOMATICALLY GENERATED. DO NOT EDIT
-
-
-#import <Foundation/Foundation.h>
-#import "cocos2d.h"
-
-#if CC_COMPATIBILITY_WITH_0_8
-
-DEPRECATED_ATTRIBUTE @interface AccelAmplitude : CCAccelAmplitude {} @end
-DEPRECATED_ATTRIBUTE @interface AccelDeccelAmplitude : CCAccelDeccelAmplitude {} @end
-DEPRECATED_ATTRIBUTE @interface Action : CCAction {} @end
-DEPRECATED_ATTRIBUTE @interface ActionManager : CCActionManager {} @end
-DEPRECATED_ATTRIBUTE @interface Animate : CCAnimate {} @end
-DEPRECATED_ATTRIBUTE @interface Animation : CCAnimation {} @end
-DEPRECATED_ATTRIBUTE @interface AtlasAnimation : CCAnimation {} @end
-DEPRECATED_ATTRIBUTE @interface AtlasNode : CCAtlasNode {} @end
-DEPRECATED_ATTRIBUTE @interface AtlasSprite : CCSprite {} @end
-DEPRECATED_ATTRIBUTE @interface AtlasSpriteFrame : CCSpriteFrame {} @end
-DEPRECATED_ATTRIBUTE @interface AtlasSpriteManager : CCSpriteSheet {} @end
-DEPRECATED_ATTRIBUTE @interface BezierBy : CCBezierBy {} @end
-DEPRECATED_ATTRIBUTE @interface BezierTo : CCBezierTo {} @end
-DEPRECATED_ATTRIBUTE @interface BitmapFontAtlas : CCBitmapFontAtlas {} @end
-DEPRECATED_ATTRIBUTE @interface BitmapFontConfiguration : CCBitmapFontConfiguration {} @end
-DEPRECATED_ATTRIBUTE @interface Blink : CCBlink {} @end
-DEPRECATED_ATTRIBUTE @interface CallFunc : CCCallFunc {} @end
-DEPRECATED_ATTRIBUTE @interface CallFuncN : CCCallFuncN {} @end
-DEPRECATED_ATTRIBUTE @interface CallFuncND : CCCallFuncND {} @end
-DEPRECATED_ATTRIBUTE @interface Camera : CCCamera {} @end
-DEPRECATED_ATTRIBUTE @interface CameraAction : CCCameraAction {} @end
-DEPRECATED_ATTRIBUTE @interface CocosNode : CCNode {} @end
-DEPRECATED_ATTRIBUTE @interface ColorLayer : CCColorLayer {} @end
-DEPRECATED_ATTRIBUTE @interface DeccelAmplitude : CCDeccelAmplitude {} @end
-DEPRECATED_ATTRIBUTE @interface DelayTime : CCDelayTime {} @end
-DEPRECATED_ATTRIBUTE @interface Director : CCDirector {} @end
-DEPRECATED_ATTRIBUTE @interface DisplayLinkDirector : CCDisplayLinkDirector {} @end
-DEPRECATED_ATTRIBUTE @interface EaseAction : CCEaseAction {} @end
-DEPRECATED_ATTRIBUTE @interface EaseBackIn : CCEaseBackIn {} @end
-DEPRECATED_ATTRIBUTE @interface EaseBackInOut : CCEaseBackInOut {} @end
-DEPRECATED_ATTRIBUTE @interface EaseBackOut : CCEaseBackOut {} @end
-DEPRECATED_ATTRIBUTE @interface EaseBounce : CCEaseBounce {} @end
-DEPRECATED_ATTRIBUTE @interface EaseBounceIn : CCEaseBounceIn {} @end
-DEPRECATED_ATTRIBUTE @interface EaseBounceInOut : CCEaseBounceInOut {} @end
-DEPRECATED_ATTRIBUTE @interface EaseBounceOut : CCEaseBounceOut {} @end
-DEPRECATED_ATTRIBUTE @interface EaseElastic : CCEaseElastic {} @end
-DEPRECATED_ATTRIBUTE @interface EaseElasticIn : CCEaseElasticIn {} @end
-DEPRECATED_ATTRIBUTE @interface EaseElasticInOut : CCEaseElasticInOut {} @end
-DEPRECATED_ATTRIBUTE @interface EaseElasticOut : CCEaseElasticOut {} @end
-DEPRECATED_ATTRIBUTE @interface EaseExponentialIn : CCEaseExponentialIn {} @end
-DEPRECATED_ATTRIBUTE @interface EaseExponentialInOut : CCEaseExponentialInOut {} @end
-DEPRECATED_ATTRIBUTE @interface EaseExponentialOut : CCEaseExponentialOut {} @end
-DEPRECATED_ATTRIBUTE @interface EaseIn : CCEaseIn {} @end
-DEPRECATED_ATTRIBUTE @interface EaseInOut : CCEaseInOut {} @end
-DEPRECATED_ATTRIBUTE @interface EaseOut : CCEaseOut {} @end
-DEPRECATED_ATTRIBUTE @interface EaseRateAction : CCEaseRateAction {} @end
-DEPRECATED_ATTRIBUTE @interface EaseSineIn : CCEaseSineIn {} @end
-DEPRECATED_ATTRIBUTE @interface EaseSineInOut : CCEaseSineInOut {} @end
-DEPRECATED_ATTRIBUTE @interface EaseSineOut : CCEaseSineOut {} @end
-DEPRECATED_ATTRIBUTE @interface FadeBLTransition : CCTransitionFadeBL {} @end
-DEPRECATED_ATTRIBUTE @interface FadeDownTransition : CCTransitionFadeDown {} @end
-DEPRECATED_ATTRIBUTE @interface FadeIn : CCFadeIn {} @end
-DEPRECATED_ATTRIBUTE @interface FadeOut : CCFadeOut {} @end
-DEPRECATED_ATTRIBUTE @interface FadeOutBLTiles : CCFadeOutBLTiles {} @end
-DEPRECATED_ATTRIBUTE @interface FadeOutDownTiles : CCFadeOutDownTiles {} @end
-DEPRECATED_ATTRIBUTE @interface FadeOutTRTiles : CCFadeOutTRTiles {} @end
-DEPRECATED_ATTRIBUTE @interface FadeOutUpTiles : CCFadeOutUpTiles {} @end
-DEPRECATED_ATTRIBUTE @interface FadeTRTransition : CCTransitionFadeTR {} @end
-DEPRECATED_ATTRIBUTE @interface FadeTo : CCFadeTo {} @end
-DEPRECATED_ATTRIBUTE @interface FadeTransition : CCTransitionFade {} @end
-DEPRECATED_ATTRIBUTE @interface FadeUpTransition : CCTransitionFadeUp {} @end
-DEPRECATED_ATTRIBUTE @interface FastDirector : CCFastDirector {} @end
-DEPRECATED_ATTRIBUTE @interface FiniteTimeAction : CCFiniteTimeAction {} @end
-DEPRECATED_ATTRIBUTE @interface FlipAngularTransition : CCTransitionFlipAngular {} @end
-DEPRECATED_ATTRIBUTE @interface FlipX3D : CCFlipX3D {} @end
-DEPRECATED_ATTRIBUTE @interface FlipXTransition : CCTransitionFlipX {} @end
-DEPRECATED_ATTRIBUTE @interface FlipY3D : CCFlipY3D {} @end
-DEPRECATED_ATTRIBUTE @interface FlipYTransition : CCTransitionFlipY {} @end
-DEPRECATED_ATTRIBUTE @interface Grabber : CCGrabber {} @end
-DEPRECATED_ATTRIBUTE @interface Grid3D : CCGrid3D {} @end
-DEPRECATED_ATTRIBUTE @interface Grid3DAction : CCGrid3DAction {} @end
-DEPRECATED_ATTRIBUTE @interface GridAction : CCGridAction {} @end
-DEPRECATED_ATTRIBUTE @interface GridBase : CCGridBase {} @end
-DEPRECATED_ATTRIBUTE @interface Hide : CCHide {} @end
-DEPRECATED_ATTRIBUTE @interface InstantAction : CCInstantAction {} @end
-DEPRECATED_ATTRIBUTE @interface IntervalAction : CCIntervalAction {} @end
-DEPRECATED_ATTRIBUTE @interface JumpBy : CCJumpBy {} @end
-DEPRECATED_ATTRIBUTE @interface JumpTiles3D : CCJumpTiles3D {} @end
-DEPRECATED_ATTRIBUTE @interface JumpTo : CCJumpTo {} @end
-DEPRECATED_ATTRIBUTE @interface JumpZoomTransition : CCTransitionJumpZoom {} @end
-DEPRECATED_ATTRIBUTE @interface Label : CCLabel {} @end
-DEPRECATED_ATTRIBUTE @interface LabelAtlas : CCLabelAtlas {} @end
-DEPRECATED_ATTRIBUTE @interface Layer : CCLayer {} @end
-DEPRECATED_ATTRIBUTE @interface Lens3D : CCLens3D {} @end
-DEPRECATED_ATTRIBUTE @interface Liquid : CCLiquid {} @end
-DEPRECATED_ATTRIBUTE @interface Menu : CCMenu {} @end
-DEPRECATED_ATTRIBUTE @interface MenuItem : CCMenuItem {} @end
-DEPRECATED_ATTRIBUTE @interface MenuItemAtlasFont : CCMenuItemAtlasFont {} @end
-DEPRECATED_ATTRIBUTE @interface MenuItemFont : CCMenuItemFont {} @end
-DEPRECATED_ATTRIBUTE @interface MenuItemImage : CCMenuItemImage {} @end
-DEPRECATED_ATTRIBUTE @interface MenuItemLabel : CCMenuItemLabel {} @end
-DEPRECATED_ATTRIBUTE @interface MenuItemSprite : CCMenuItemSprite {} @end
-DEPRECATED_ATTRIBUTE @interface MenuItemToggle : CCMenuItemToggle {} @end
-DEPRECATED_ATTRIBUTE @interface MotionStreak : CCMotionStreak {} @end
-DEPRECATED_ATTRIBUTE @interface MoveBy : CCMoveBy {} @end
-DEPRECATED_ATTRIBUTE @interface MoveInBTransition : CCTransitionMoveInB {} @end
-DEPRECATED_ATTRIBUTE @interface MoveInLTransition : CCTransitionMoveInL {} @end
-DEPRECATED_ATTRIBUTE @interface MoveInRTransition : CCTransitionMoveInR {} @end
-DEPRECATED_ATTRIBUTE @interface MoveInTTransition : CCTransitionMoveInT {} @end
-DEPRECATED_ATTRIBUTE @interface MoveTo : CCMoveTo {} @end
-DEPRECATED_ATTRIBUTE @interface MultiplexLayer : CCMultiplexLayer {} @end
-DEPRECATED_ATTRIBUTE @interface OrbitCamera : CCOrbitCamera {} @end
-DEPRECATED_ATTRIBUTE @interface OrientedTransitionScene : CCTransitionSceneOriented {} @end
-DEPRECATED_ATTRIBUTE @interface PVRTexture : CCPVRTexture {} @end
-DEPRECATED_ATTRIBUTE @interface PageTurn3D : CCPageTurn3D {} @end
-DEPRECATED_ATTRIBUTE @interface PageTurnTransition : CCPageTurnTransition {} @end
-DEPRECATED_ATTRIBUTE @interface ParallaxNode : CCParallaxNode {} @end
-DEPRECATED_ATTRIBUTE @interface ParticleExplosion : CCParticleExplosion {} @end
-DEPRECATED_ATTRIBUTE @interface ParticleFire : CCParticleFire {} @end
-DEPRECATED_ATTRIBUTE @interface ParticleFireworks : CCParticleFireworks {} @end
-DEPRECATED_ATTRIBUTE @interface ParticleFlower : CCParticleFlower {} @end
-DEPRECATED_ATTRIBUTE @interface ParticleGalaxy : CCParticleGalaxy {} @end
-DEPRECATED_ATTRIBUTE @interface ParticleMeteor : CCParticleMeteor {} @end
-DEPRECATED_ATTRIBUTE @interface ParticleRain : CCParticleRain {} @end
-DEPRECATED_ATTRIBUTE @interface ParticleSmoke : CCParticleSmoke {} @end
-DEPRECATED_ATTRIBUTE @interface ParticleSnow : CCParticleSnow {} @end
-DEPRECATED_ATTRIBUTE @interface ParticleSpiral : CCParticleSpiral {} @end
-DEPRECATED_ATTRIBUTE @interface ParticleSun : CCParticleSun {} @end
-DEPRECATED_ATTRIBUTE @interface ParticleSystem : CCParticleSystem {} @end
-DEPRECATED_ATTRIBUTE @interface Place : CCPlace {} @end
-DEPRECATED_ATTRIBUTE @interface PointParticleSystem : CCPointParticleSystem {} @end
-DEPRECATED_ATTRIBUTE @interface QuadParticleSystem : CCQuadParticleSystem {} @end
-DEPRECATED_ATTRIBUTE @interface RenderTexture : CCRenderTexture {} @end
-DEPRECATED_ATTRIBUTE @interface Repeat : CCRepeat {} @end
-DEPRECATED_ATTRIBUTE @interface RepeatForever : CCRepeatForever {} @end
-DEPRECATED_ATTRIBUTE @interface ReuseGrid : CCReuseGrid {} @end
-DEPRECATED_ATTRIBUTE @interface ReverseTime : CCReverseTime {} @end
-DEPRECATED_ATTRIBUTE @interface Ribbon : CCRibbon {} @end
-DEPRECATED_ATTRIBUTE @interface RibbonSegment : CCRibbonSegment {} @end
-DEPRECATED_ATTRIBUTE @interface Ripple3D : CCRipple3D {} @end
-DEPRECATED_ATTRIBUTE @interface RotateBy : CCRotateBy {} @end
-DEPRECATED_ATTRIBUTE @interface RotateTo : CCRotateTo {} @end
-DEPRECATED_ATTRIBUTE @interface RotoZoomTransition : CCTransitionRotoZoom {} @end
-DEPRECATED_ATTRIBUTE @interface ScaleBy : CCScaleBy {} @end
-DEPRECATED_ATTRIBUTE @interface ScaleTo : CCScaleTo {} @end
-DEPRECATED_ATTRIBUTE @interface Scene : CCScene {} @end
-DEPRECATED_ATTRIBUTE @interface Scheduler : CCScheduler {} @end
-DEPRECATED_ATTRIBUTE @interface Sequence : CCSequence {} @end
-DEPRECATED_ATTRIBUTE @interface Shaky3D : CCShaky3D {} @end
-DEPRECATED_ATTRIBUTE @interface ShakyTiles3D : CCShakyTiles3D {} @end
-DEPRECATED_ATTRIBUTE @interface ShatteredTiles3D : CCShatteredTiles3D {} @end
-DEPRECATED_ATTRIBUTE @interface Show : CCShow {} @end
-DEPRECATED_ATTRIBUTE @interface ShrinkGrowTransition : CCTransitionShrinkGrow {} @end
-DEPRECATED_ATTRIBUTE @interface ShuffleTiles : CCShuffleTiles {} @end
-DEPRECATED_ATTRIBUTE @interface SlideInBTransition : CCTransitionSlideInB {} @end
-DEPRECATED_ATTRIBUTE @interface SlideInLTransition : CCTransitionSlideInL {} @end
-DEPRECATED_ATTRIBUTE @interface SlideInRTransition : CCTransitionSlideInR {} @end
-DEPRECATED_ATTRIBUTE @interface SlideInTTransition : CCTransitionSlideInT {} @end
-DEPRECATED_ATTRIBUTE @interface Spawn : CCSpawn {} @end
-DEPRECATED_ATTRIBUTE @interface Speed : CCSpeed {} @end
-DEPRECATED_ATTRIBUTE @interface SplitCols : CCSplitCols {} @end
-DEPRECATED_ATTRIBUTE @interface SplitColsTransition : CCTransitionSplitCols {} @end
-DEPRECATED_ATTRIBUTE @interface SplitRows : CCSplitRows {} @end
-DEPRECATED_ATTRIBUTE @interface SplitRowsTransition : CCTransitionSplitRows {} @end
-DEPRECATED_ATTRIBUTE @interface Sprite : CCSprite {} @end
-DEPRECATED_ATTRIBUTE @interface StandardTouchHandler : CCStandardTouchHandler {} @end
-DEPRECATED_ATTRIBUTE @interface StopGrid : CCStopGrid {} @end
-DEPRECATED_ATTRIBUTE @interface TMXLayer : CCTMXLayer {} @end
-DEPRECATED_ATTRIBUTE @interface TMXLayerInfo : CCTMXLayerInfo {} @end
-DEPRECATED_ATTRIBUTE @interface TMXMapInfo : CCTMXMapInfo {} @end
-DEPRECATED_ATTRIBUTE @interface TMXTiledMap : CCTMXTiledMap {} @end
-DEPRECATED_ATTRIBUTE @interface TMXTilesetInfo : CCTMXTilesetInfo {} @end
-DEPRECATED_ATTRIBUTE @interface TargetedTouchHandler : CCTargetedTouchHandler {} @end
-DEPRECATED_ATTRIBUTE @interface Texture2D : CCTexture2D {} @end
-DEPRECATED_ATTRIBUTE @interface TextureAtlas : CCTextureAtlas {} @end
-DEPRECATED_ATTRIBUTE @interface TextureMgr : CCTextureCache {} @end
-DEPRECATED_ATTRIBUTE @interface TextureNode : CCSprite {} @end
-DEPRECATED_ATTRIBUTE @interface ThreadedFastDirector : CCThreadedFastDirector {} @end
-DEPRECATED_ATTRIBUTE @interface TileMapAtlas : CCTileMapAtlas {} @end
-DEPRECATED_ATTRIBUTE @interface TiledGrid3D : CCTiledGrid3D {} @end
-DEPRECATED_ATTRIBUTE @interface TiledGrid3DAction : CCTiledGrid3DAction {} @end
-DEPRECATED_ATTRIBUTE @interface Timer : CCTimer {} @end
-DEPRECATED_ATTRIBUTE @interface TimerDirector : CCTimerDirector {} @end
-DEPRECATED_ATTRIBUTE @interface TintBy : CCTintBy {} @end
-DEPRECATED_ATTRIBUTE @interface TintTo : CCTintTo {} @end
-DEPRECATED_ATTRIBUTE @interface ToggleVisibility : CCToggleVisibility {} @end
-DEPRECATED_ATTRIBUTE @interface TouchDispatcher : CCTouchDispatcher {} @end
-DEPRECATED_ATTRIBUTE @interface TouchHandler : CCTouchHandler {} @end
-DEPRECATED_ATTRIBUTE @interface TransitionScene : CCTransitionScene {} @end
-DEPRECATED_ATTRIBUTE @interface TurnOffTiles : CCTurnOffTiles {} @end
-DEPRECATED_ATTRIBUTE @interface TurnOffTilesTransition : CCTransitionTurnOffTiles {} @end
-DEPRECATED_ATTRIBUTE @interface Twirl : CCTwirl {} @end
-DEPRECATED_ATTRIBUTE @interface Waves : CCWaves {} @end
-DEPRECATED_ATTRIBUTE @interface Waves3D : CCWaves3D {} @end
-DEPRECATED_ATTRIBUTE @interface WavesTiles3D : CCWavesTiles3D {} @end
-DEPRECATED_ATTRIBUTE @interface ZoomFlipAngularTransition : CCTransitionZoomFlipAngular {} @end
-DEPRECATED_ATTRIBUTE @interface ZoomFlipXTransition : CCTransitionZoomFlipX {} @end
-DEPRECATED_ATTRIBUTE @interface ZoomFlipYTransition : CCTransitionZoomFlipY {} @end
-
-#endif // CC_COMPATIBILITY_WITH_0_8
+++ /dev/null
-
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (c) 2008-2010 Ricardo Quesada
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-// AUTOMATICALLY GENERATED. DO NOT EDIT
-
-#include "CCCompatibility.h"
-#if CC_COMPATIBILITY_WITH_0_8
-@implementation AccelAmplitude
-@end
-
-@implementation AccelDeccelAmplitude
-@end
-
-@implementation Action
-@end
-
-@implementation ActionManager
-@end
-
-@implementation Animate
-@end
-
-@implementation Animation
-@end
-
-@implementation AtlasAnimation
-@end
-
-@implementation AtlasNode
-@end
-
-@implementation AtlasSprite
-@end
-
-@implementation AtlasSpriteFrame
-@end
-
-@implementation AtlasSpriteManager
-@end
-
-@implementation BezierBy
-@end
-
-@implementation BezierTo
-@end
-
-@implementation BitmapFontAtlas
-@end
-
-@implementation BitmapFontConfiguration
-@end
-
-@implementation Blink
-@end
-
-@implementation CallFunc
-@end
-
-@implementation CallFuncN
-@end
-
-@implementation CallFuncND
-@end
-
-@implementation Camera
-@end
-
-@implementation CameraAction
-@end
-
-@implementation CocosNode
-@end
-
-@implementation ColorLayer
-@end
-
-@implementation DeccelAmplitude
-@end
-
-@implementation DelayTime
-@end
-
-@implementation Director
-@end
-
-@implementation DisplayLinkDirector
-@end
-
-@implementation EaseAction
-@end
-
-@implementation EaseBackIn
-@end
-
-@implementation EaseBackInOut
-@end
-
-@implementation EaseBackOut
-@end
-
-@implementation EaseBounce
-@end
-
-@implementation EaseBounceIn
-@end
-
-@implementation EaseBounceInOut
-@end
-
-@implementation EaseBounceOut
-@end
-
-@implementation EaseElastic
-@end
-
-@implementation EaseElasticIn
-@end
-
-@implementation EaseElasticInOut
-@end
-
-@implementation EaseElasticOut
-@end
-
-@implementation EaseExponentialIn
-@end
-
-@implementation EaseExponentialInOut
-@end
-
-@implementation EaseExponentialOut
-@end
-
-@implementation EaseIn
-@end
-
-@implementation EaseInOut
-@end
-
-@implementation EaseOut
-@end
-
-@implementation EaseRateAction
-@end
-
-@implementation EaseSineIn
-@end
-
-@implementation EaseSineInOut
-@end
-
-@implementation EaseSineOut
-@end
-
-@implementation FadeBLTransition
-@end
-
-@implementation FadeDownTransition
-@end
-
-@implementation FadeIn
-@end
-
-@implementation FadeOut
-@end
-
-@implementation FadeOutBLTiles
-@end
-
-@implementation FadeOutDownTiles
-@end
-
-@implementation FadeOutTRTiles
-@end
-
-@implementation FadeOutUpTiles
-@end
-
-@implementation FadeTRTransition
-@end
-
-@implementation FadeTo
-@end
-
-@implementation FadeTransition
-@end
-
-@implementation FadeUpTransition
-@end
-
-@implementation FastDirector
-@end
-
-@implementation FiniteTimeAction
-@end
-
-@implementation FlipAngularTransition
-@end
-
-@implementation FlipX3D
-@end
-
-@implementation FlipXTransition
-@end
-
-@implementation FlipY3D
-@end
-
-@implementation FlipYTransition
-@end
-
-@implementation Grabber
-@end
-
-@implementation Grid3D
-@end
-
-@implementation Grid3DAction
-@end
-
-@implementation GridAction
-@end
-
-@implementation GridBase
-@end
-
-@implementation Hide
-@end
-
-@implementation InstantAction
-@end
-
-@implementation IntervalAction
-@end
-
-@implementation JumpBy
-@end
-
-@implementation JumpTiles3D
-@end
-
-@implementation JumpTo
-@end
-
-@implementation JumpZoomTransition
-@end
-
-@implementation Label
-@end
-
-@implementation LabelAtlas
-@end
-
-@implementation Layer
-@end
-
-@implementation Lens3D
-@end
-
-@implementation Liquid
-@end
-
-@implementation Menu
-@end
-
-@implementation MenuItem
-@end
-
-@implementation MenuItemAtlasFont
-@end
-
-@implementation MenuItemFont
-@end
-
-@implementation MenuItemImage
-@end
-
-@implementation MenuItemLabel
-@end
-
-@implementation MenuItemSprite
-@end
-
-@implementation MenuItemToggle
-@end
-
-@implementation MotionStreak
-@end
-
-@implementation MoveBy
-@end
-
-@implementation MoveInBTransition
-@end
-
-@implementation MoveInLTransition
-@end
-
-@implementation MoveInRTransition
-@end
-
-@implementation MoveInTTransition
-@end
-
-@implementation MoveTo
-@end
-
-@implementation MultiplexLayer
-@end
-
-@implementation OrbitCamera
-@end
-
-@implementation OrientedTransitionScene
-@end
-
-@implementation PVRTexture
-@end
-
-@implementation PageTurn3D
-@end
-
-@implementation PageTurnTransition
-@end
-
-@implementation ParallaxNode
-@end
-
-@implementation ParticleExplosion
-@end
-
-@implementation ParticleFire
-@end
-
-@implementation ParticleFireworks
-@end
-
-@implementation ParticleFlower
-@end
-
-@implementation ParticleGalaxy
-@end
-
-@implementation ParticleMeteor
-@end
-
-@implementation ParticleRain
-@end
-
-@implementation ParticleSmoke
-@end
-
-@implementation ParticleSnow
-@end
-
-@implementation ParticleSpiral
-@end
-
-@implementation ParticleSun
-@end
-
-@implementation ParticleSystem
-@end
-
-@implementation Place
-@end
-
-@implementation PointParticleSystem
-@end
-
-@implementation QuadParticleSystem
-@end
-
-@implementation RenderTexture
-@end
-
-@implementation Repeat
-@end
-
-@implementation RepeatForever
-@end
-
-@implementation ReuseGrid
-@end
-
-@implementation ReverseTime
-@end
-
-@implementation Ribbon
-@end
-
-@implementation RibbonSegment
-@end
-
-@implementation Ripple3D
-@end
-
-@implementation RotateBy
-@end
-
-@implementation RotateTo
-@end
-
-@implementation RotoZoomTransition
-@end
-
-@implementation ScaleBy
-@end
-
-@implementation ScaleTo
-@end
-
-@implementation Scene
-@end
-
-@implementation Scheduler
-@end
-
-@implementation Sequence
-@end
-
-@implementation Shaky3D
-@end
-
-@implementation ShakyTiles3D
-@end
-
-@implementation ShatteredTiles3D
-@end
-
-@implementation Show
-@end
-
-@implementation ShrinkGrowTransition
-@end
-
-@implementation ShuffleTiles
-@end
-
-@implementation SlideInBTransition
-@end
-
-@implementation SlideInLTransition
-@end
-
-@implementation SlideInRTransition
-@end
-
-@implementation SlideInTTransition
-@end
-
-@implementation Spawn
-@end
-
-@implementation Speed
-@end
-
-@implementation SplitCols
-@end
-
-@implementation SplitColsTransition
-@end
-
-@implementation SplitRows
-@end
-
-@implementation SplitRowsTransition
-@end
-
-@implementation Sprite
-@end
-
-@implementation StandardTouchHandler
-@end
-
-@implementation StopGrid
-@end
-
-@implementation TMXLayer
-@end
-
-@implementation TMXLayerInfo
-@end
-
-@implementation TMXMapInfo
-@end
-
-@implementation TMXTiledMap
-@end
-
-@implementation TMXTilesetInfo
-@end
-
-@implementation TargetedTouchHandler
-@end
-
-@implementation Texture2D
-@end
-
-@implementation TextureAtlas
-@end
-
-@implementation TextureMgr
-@end
-
-@implementation TextureNode
-@end
-
-@implementation ThreadedFastDirector
-@end
-
-@implementation TileMapAtlas
-@end
-
-@implementation TiledGrid3D
-@end
-
-@implementation TiledGrid3DAction
-@end
-
-@implementation Timer
-@end
-
-@implementation TimerDirector
-@end
-
-@implementation TintBy
-@end
-
-@implementation TintTo
-@end
-
-@implementation ToggleVisibility
-@end
-
-@implementation TouchDispatcher
-@end
-
-@implementation TouchHandler
-@end
-
-@implementation TransitionScene
-@end
-
-@implementation TurnOffTiles
-@end
-
-@implementation TurnOffTilesTransition
-@end
-
-@implementation Twirl
-@end
-
-@implementation Waves
-@end
-
-@implementation Waves3D
-@end
-
-@implementation WavesTiles3D
-@end
-
-@implementation ZoomFlipAngularTransition
-@end
-
-@implementation ZoomFlipXTransition
-@end
-
-@implementation ZoomFlipYTransition
-@end
-
-
-#endif // CC_COMPATIBILITY_WITH_0_8
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (c) 2010 Ricardo Quesada
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-#import <Foundation/Foundation.h>
-
-#import "Platforms/CCGL.h"
-
-/** OS version definitions. Includes both iOS and Mac OS versions
- */
-enum {
- kCCiOSVersion_3_0 = 0x03000000,
- kCCiOSVersion_3_1 = 0x03010000,
- kCCiOSVersion_3_1_1 = 0x03010100,
- kCCiOSVersion_3_1_2 = 0x03010200,
- kCCiOSVersion_3_1_3 = 0x03010300,
- kCCiOSVersion_3_2 = 0x03020000,
- kCCiOSVersion_3_2_1 = 0x03020100,
- kCCiOSVersion_4_0 = 0x04000000,
- kCCiOSVersion_4_0_1 = 0x04000100,
- kCCiOSVersion_4_1 = 0x04010000,
-
- kCCMacVersion_10_5 = 0x0a050000,
- kCCMacVersion_10_6 = 0x0a060000,
- kCCMacVersion_10_7 = 0x0a070000,
-};
-
-/**
- CCConfiguration contains some openGL variables
- @since v0.99.0
- */
-@interface CCConfiguration : NSObject {
-
- GLint maxTextureSize_;
- GLint maxModelviewStackDepth_;
- BOOL supportsPVRTC_;
- BOOL supportsNPOT_;
- BOOL supportsBGRA8888_;
- BOOL supportsDiscardFramebuffer_;
- unsigned int OSVersion_;
- GLint maxSamplesAllowed_;
-}
-
-/** OpenGL Max texture size. */
-@property (nonatomic, readonly) GLint maxTextureSize;
-
-/** OpenGL Max Modelview Stack Depth. */
-@property (nonatomic, readonly) GLint maxModelviewStackDepth;
-
-/** Whether or not the GPU supports NPOT (Non Power Of Two) textures.
- NPOT textures have the following limitations:
- - They can't have mipmaps
- - They only accept GL_CLAMP_TO_EDGE in GL_TEXTURE_WRAP_{S,T}
-
- @since v0.99.2
- */
-@property (nonatomic, readonly) BOOL supportsNPOT;
-
-/** Whether or not PVR Texture Compressed is supported */
-@property (nonatomic, readonly) BOOL supportsPVRTC;
-
-/** Whether or not BGRA8888 textures are supported.
-
- @since v0.99.2
- */
-@property (nonatomic, readonly) BOOL supportsBGRA8888;
-
-/** Whether or not glDiscardFramebufferEXT is supported
-
- @since v0.99.2
- */
-@property (nonatomic, readonly) BOOL supportsDiscardFramebuffer;
-
-/** returns the OS version.
- - On iOS devices it returns the firmware version.
- - On Mac returns the OS version
-
- @since v0.99.5
- */
-@property (nonatomic, readonly) unsigned int OSVersion;
-
-/** returns a shared instance of the CCConfiguration */
-+(CCConfiguration *) sharedConfiguration;
-
-/** returns whether or not an OpenGL is supported */
-- (BOOL) checkForGLExtension:(NSString *)searchName;
-
-
-
-@end
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (c) 2010 Ricardo Quesada
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-#import <Availability.h>
-
-#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
-#import <UIKit/UIKit.h> // Needed for UIDevice
-#endif
-
-#import "Platforms/CCGL.h"
-#import "CCBlockSupport.h"
-#import "CCConfiguration.h"
-#import "ccMacros.h"
-#import "ccConfig.h"
-#import "Support/OpenGL_Internal.h"
-
-@implementation CCConfiguration
-
-@synthesize maxTextureSize = maxTextureSize_;
-@synthesize supportsPVRTC = supportsPVRTC_;
-@synthesize maxModelviewStackDepth = maxModelviewStackDepth_;
-@synthesize supportsNPOT = supportsNPOT_;
-@synthesize supportsBGRA8888 = supportsBGRA8888_;
-@synthesize supportsDiscardFramebuffer = supportsDiscardFramebuffer_;
-@synthesize OSVersion = OSVersion_;
-
-//
-// singleton stuff
-//
-static CCConfiguration *_sharedConfiguration = nil;
-
-static char * glExtensions;
-
-+ (CCConfiguration *)sharedConfiguration
-{
- if (!_sharedConfiguration)
- _sharedConfiguration = [[self alloc] init];
-
- return _sharedConfiguration;
-}
-
-+(id)alloc
-{
- NSAssert(_sharedConfiguration == nil, @"Attempted to allocate a second instance of a singleton.");
- return [super alloc];
-}
-
-
-#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
-#elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED)
-- (NSString*)getMacVersion
-{
- SInt32 versionMajor, versionMinor, versionBugFix;
- Gestalt(gestaltSystemVersionMajor, &versionMajor);
- Gestalt(gestaltSystemVersionMinor, &versionMinor);
- Gestalt(gestaltSystemVersionBugFix, &versionBugFix);
-
- return [NSString stringWithFormat:@"%d.%d.%d", versionMajor, versionMinor, versionBugFix];
-}
-#endif // __MAC_OS_X_VERSION_MAX_ALLOWED
-
--(id) init
-{
- if( (self=[super init])) {
-
- // Obtain iOS version
- OSVersion_ = 0;
-#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
- NSString *OSVer = [[UIDevice currentDevice] systemVersion];
-#elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED)
- NSString *OSVer = [self getMacVersion];
-#endif
- NSArray *arr = [OSVer componentsSeparatedByString:@"."];
- int idx=0x01000000;
- for( NSString *str in arr ) {
- int value = [str intValue];
- OSVersion_ += value * idx;
- idx = idx >> 8;
- }
- CCLOG(@"cocos2d: OS version: %@ (0x%08x)", OSVer, OSVersion_);
-
- CCLOG(@"cocos2d: GL_VENDOR: %s", glGetString(GL_VENDOR) );
- CCLOG(@"cocos2d: GL_RENDERER: %s", glGetString ( GL_RENDERER ) );
- CCLOG(@"cocos2d: GL_VERSION: %s", glGetString ( GL_VERSION ) );
-
- glExtensions = (char*) glGetString(GL_EXTENSIONS);
-
- glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize_);
- glGetIntegerv(GL_MAX_MODELVIEW_STACK_DEPTH, &maxModelviewStackDepth_);
-#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
- if( OSVersion_ >= kCCiOSVersion_4_0 )
- glGetIntegerv(GL_MAX_SAMPLES_APPLE, &maxSamplesAllowed_);
- else
- maxSamplesAllowed_ = 0;
-#elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED)
- glGetIntegerv(GL_MAX_SAMPLES, &maxSamplesAllowed_);
-#endif
-
- supportsPVRTC_ = [self checkForGLExtension:@"GL_IMG_texture_compression_pvrtc"];
-#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
- supportsNPOT_ = [self checkForGLExtension:@"GL_APPLE_texture_2D_limited_npot"];
-#elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED)
- supportsNPOT_ = [self checkForGLExtension:@"GL_ARB_texture_non_power_of_two"];
-#endif
- // It seems that somewhere between firmware iOS 3.0 and 4.2 Apple renamed
- // GL_IMG_... to GL_APPLE.... So we should check both names
-
-#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
- BOOL bgra8a = [self checkForGLExtension:@"GL_IMG_texture_format_BGRA8888"];
- BOOL bgra8b = [self checkForGLExtension:@"GL_APPLE_texture_format_BGRA8888"];
- supportsBGRA8888_ = bgra8a | bgra8b;
-#elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED)
- supportsBGRA8888_ = [self checkForGLExtension:@"GL_EXT_bgra"];
-#endif
-
- supportsDiscardFramebuffer_ = [self checkForGLExtension:@"GL_EXT_discard_framebuffer"];
-
- CCLOG(@"cocos2d: GL_MAX_TEXTURE_SIZE: %d", maxTextureSize_);
- CCLOG(@"cocos2d: GL_MAX_MODELVIEW_STACK_DEPTH: %d",maxModelviewStackDepth_);
- CCLOG(@"cocos2d: GL_MAX_SAMPLES: %d", maxSamplesAllowed_);
- CCLOG(@"cocos2d: GL supports PVRTC: %s", (supportsPVRTC_ ? "YES" : "NO") );
- CCLOG(@"cocos2d: GL supports BGRA8888 textures: %s", (supportsBGRA8888_ ? "YES" : "NO") );
- CCLOG(@"cocos2d: GL supports NPOT textures: %s", (supportsNPOT_ ? "YES" : "NO") );
- CCLOG(@"cocos2d: GL supports discard_framebuffer: %s", (supportsDiscardFramebuffer_ ? "YES" : "NO") );
- CCLOG(@"cocos2d: compiled with NPOT support: %s",
-#if CC_TEXTURE_NPOT_SUPPORT
- "YES"
-#else
- "NO"
-#endif
- );
- CCLOG(@"cocos2d: compiled with VBO support in TextureAtlas : %s",
-#if CC_USES_VBO
- "YES"
-#else
- "NO"
-#endif
- );
-
- CCLOG(@"cocos2d: compiled with Affine Matrix transformation in CCNode : %s",
-#if CC_NODE_TRANSFORM_USING_AFFINE_MATRIX
- "YES"
-#else
- "NO"
-#endif
- );
-
- CCLOG(@"cocos2d: compiled with Profiling Support: %s",
-#if CC_ENABLE_PROFILERS
-
- "YES - *** Disable it when you finish profiling ***"
-#else
- "NO"
-#endif
- );
-
- CHECK_GL_ERROR();
- }
-
- return self;
-}
-
-- (BOOL) checkForGLExtension:(NSString *)searchName
-{
- // For best results, extensionsNames should be stored in your renderer so that it does not
- // need to be recreated on each invocation.
- NSString *extensionsString = [NSString stringWithCString:glExtensions encoding: NSASCIIStringEncoding];
- NSArray *extensionsNames = [extensionsString componentsSeparatedByString:@" "];
- return [extensionsNames containsObject: searchName];
-}
-@end
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (c) 2008-2010 Ricardo Quesada
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-
-#import "ccConfig.h"
-#import "ccTypes.h"
-
-// OpenGL related
-#import "Platforms/CCGL.h"
-#import "CCProtocols.h"
-
-/** @typedef ccDirectorProjection
- Possible OpenGL projections used by director
- */
-typedef enum {
- /// sets a 2D projection (orthogonal projection).
- kCCDirectorProjection2D,
-
- /// sets a 3D projection with a fovy=60, znear=0.5f and zfar=1500.
- kCCDirectorProjection3D,
-
- /// it calls "updateProjection" on the projection delegate.
- kCCDirectorProjectionCustom,
-
- /// Detault projection is 3D projection
- kCCDirectorProjectionDefault = kCCDirectorProjection3D,
-
- // backward compatibility stuff
- CCDirectorProjection2D = kCCDirectorProjection2D,
- CCDirectorProjection3D = kCCDirectorProjection3D,
- CCDirectorProjectionCustom = kCCDirectorProjectionCustom,
-
-} ccDirectorProjection;
-
-
-@class CCLabelAtlas;
-@class CCScene;
-
-/**Class that creates and handle the main Window and manages how
-and when to execute the Scenes.
-
- The CCDirector is also resposible for:
- - initializing the OpenGL ES context
- - setting the OpenGL pixel format (default on is RGB565)
- - setting the OpenGL buffer depth (default one is 0-bit)
- - setting the projection (default one is 3D)
- - setting the orientation (default one is Protrait)
-
- Since the CCDirector is a singleton, the standard way to use it is by calling:
- - [[CCDirector sharedDirector] methodName];
-
- The CCDirector also sets the default OpenGL context:
- - GL_TEXTURE_2D is enabled
- - GL_VERTEX_ARRAY is enabled
- - GL_COLOR_ARRAY is enabled
- - GL_TEXTURE_COORD_ARRAY is enabled
-*/
-@interface CCDirector : NSObject
-{
- CC_GLVIEW *openGLView_;
-
- // internal timer
- NSTimeInterval animationInterval_;
- NSTimeInterval oldAnimationInterval_;
-
- /* display FPS ? */
- BOOL displayFPS_;
-
- NSUInteger frames_;
- ccTime accumDt_;
- ccTime frameRate_;
-#if CC_DIRECTOR_FAST_FPS
- CCLabelAtlas *FPSLabel_;
-#endif
-
- /* is the running scene paused */
- BOOL isPaused_;
-
- /* The running scene */
- CCScene *runningScene_;
-
- /* This object will be visited after the scene. Useful to hook a notification node */
- id notificationNode_;
-
- /* will be the next 'runningScene' in the next frame
- nextScene is a weak reference. */
- CCScene *nextScene_;
-
- /* If YES, then "old" scene will receive the cleanup message */
- BOOL sendCleanupToScene_;
-
- /* scheduled scenes */
- NSMutableArray *scenesStack_;
-
- /* last time the main loop was updated */
- struct timeval lastUpdate_;
- /* delta time since last tick to main loop */
- ccTime dt;
- /* whether or not the next delta time will be zero */
- BOOL nextDeltaTimeZero_;
-
- /* projection used */
- ccDirectorProjection projection_;
-
- /* Projection protocol delegate */
- id<CCProjectionProtocol> projectionDelegate_;
-
- /* window size in points */
- CGSize winSizeInPoints_;
-
- /* window size in pixels */
- CGSize winSizeInPixels_;
-
- /* the cocos2d running thread */
- NSThread *runningThread_;
-
- // profiler
-#if CC_ENABLE_PROFILERS
- ccTime accumDtForProfiler_;
-#endif
-}
-
-/** returns the cocos2d thread.
- If you want to run any cocos2d task, run it in this thread.
- On iOS usually it is the main thread.
- @since v0.99.5
- */
-@property (readonly, nonatomic ) NSThread *runningThread;
-/** The current running Scene. Director can only run one Scene at the time */
-@property (nonatomic,readonly) CCScene* runningScene;
-/** The FPS value */
-@property (nonatomic,readwrite, assign) NSTimeInterval animationInterval;
-/** Whether or not to display the FPS on the bottom-left corner */
-@property (nonatomic,readwrite, assign) BOOL displayFPS;
-/** The OpenGLView, where everything is rendered */
-@property (nonatomic,readwrite,retain) CC_GLVIEW *openGLView;
-/** whether or not the next delta time will be zero */
-@property (nonatomic,readwrite,assign) BOOL nextDeltaTimeZero;
-/** Whether or not the Director is paused */
-@property (nonatomic,readonly) BOOL isPaused;
-/** Sets an OpenGL projection
- @since v0.8.2
- */
-@property (nonatomic,readwrite) ccDirectorProjection projection;
-
-/** Whether or not the replaced scene will receive the cleanup message.
- If the new scene is pushed, then the old scene won't receive the "cleanup" message.
- If the new scene replaces the old one, the it will receive the "cleanup" message.
- @since v0.99.0
- */
-@property (nonatomic, readonly) BOOL sendCleanupToScene;
-
-/** This object will be visited after the main scene is visited.
- This object MUST implement the "visit" selector.
- Useful to hook a notification object, like CCNotifications (http://github.com/manucorporat/CCNotifications)
- @since v0.99.5
- */
-@property (nonatomic, readwrite, retain) id notificationNode;
-
-/** This object will be called when the OpenGL projection is udpated and only when the kCCDirectorProjectionCustom projection is used.
- @since v0.99.5
- */
-@property (nonatomic, readwrite, retain) id<CCProjectionProtocol> projectionDelegate;
-
-/** returns a shared instance of the director */
-+(CCDirector *)sharedDirector;
-
-
-
-// Window size
-
-/** returns the size of the OpenGL view in points.
- It takes into account any possible rotation (device orientation) of the window
- */
-- (CGSize) winSize;
-
-/** returns the size of the OpenGL view in pixels.
- It takes into account any possible rotation (device orientation) of the window.
- On Mac winSize and winSizeInPixels return the same value.
- */
-- (CGSize) winSizeInPixels;
-/** returns the display size of the OpenGL view in pixels.
- It doesn't take into account any possible rotation of the window.
- */
--(CGSize) displaySizeInPixels;
-/** changes the projection size */
--(void) reshapeProjection:(CGSize)newWindowSize;
-
-/** converts a UIKit coordinate to an OpenGL coordinate
- Useful to convert (multi) touchs coordinates to the current layout (portrait or landscape)
- */
--(CGPoint) convertToGL: (CGPoint) p;
-/** converts an OpenGL coordinate to a UIKit coordinate
- Useful to convert node points to window points for calls such as glScissor
- */
--(CGPoint) convertToUI:(CGPoint)p;
-
-/// XXX: missing description
--(float) getZEye;
-
-// Scene Management
-
-/**Enters the Director's main loop with the given Scene.
- * Call it to run only your FIRST scene.
- * Don't call it if there is already a running scene.
- */
-- (void) runWithScene:(CCScene*) scene;
-
-/**Suspends the execution of the running scene, pushing it on the stack of suspended scenes.
- * The new scene will be executed.
- * Try to avoid big stacks of pushed scenes to reduce memory allocation.
- * ONLY call it if there is a running scene.
- */
-- (void) pushScene:(CCScene*) scene;
-
-/**Pops out a scene from the queue.
- * This scene will replace the running one.
- * The running scene will be deleted. If there are no more scenes in the stack the execution is terminated.
- * ONLY call it if there is a running scene.
- */
-- (void) popScene;
-
-/** Replaces the running scene with a new one. The running scene is terminated.
- * ONLY call it if there is a running scene.
- */
--(void) replaceScene: (CCScene*) scene;
-
-/** Ends the execution, releases the running scene.
- It doesn't remove the OpenGL view from its parent. You have to do it manually.
- */
--(void) end;
-
-/** Pauses the running scene.
- The running scene will be _drawed_ but all scheduled timers will be paused
- While paused, the draw rate will be 4 FPS to reduce CPU consuption
- */
--(void) pause;
-
-/** Resumes the paused scene
- The scheduled timers will be activated again.
- The "delta time" will be 0 (as if the game wasn't paused)
- */
--(void) resume;
-
-/** Stops the animation. Nothing will be drawn. The main loop won't be triggered anymore.
- If you wan't to pause your animation call [pause] instead.
- */
--(void) stopAnimation;
-
-/** The main loop is triggered again.
- Call this function only if [stopAnimation] was called earlier
- @warning Dont' call this function to start the main loop. To run the main loop call runWithScene
- */
--(void) startAnimation;
-
-/** Draw the scene.
- This method is called every frame. Don't call it manually.
- */
--(void) drawScene;
-
-// Memory Helper
-
-/** Removes all the cocos2d data that was cached automatically.
- It will purge the CCTextureCache, CCBitmapFont cache.
- IMPORTANT: The CCSpriteFrameCache won't be purged. If you want to purge it, you have to purge it manually.
- @since v0.99.3
- */
--(void) purgeCachedData;
-
-// OpenGL Helper
-
-/** sets the OpenGL default values */
--(void) setGLDefaultValues;
-
-/** enables/disables OpenGL alpha blending */
-- (void) setAlphaBlending: (BOOL) on;
-/** enables/disables OpenGL depth test */
-- (void) setDepthTest: (BOOL) on;
-
-// Profiler
--(void) showProfilers;
-
-@end
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (c) 2008-2010 Ricardo Quesada
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-
-/* Idea of decoupling Window from Director taken from OC3D project: http://code.google.com/p/oc3d/
- */
-
-#import <unistd.h>
-#import <Availability.h>
-
-// cocos2d imports
-#import "CCDirector.h"
-#import "CCScheduler.h"
-#import "CCActionManager.h"
-#import "CCTextureCache.h"
-#import "CCAnimationCache.h"
-#import "CCLabelAtlas.h"
-#import "ccMacros.h"
-#import "CCTransition.h"
-#import "CCScene.h"
-#import "CCSpriteFrameCache.h"
-#import "CCTexture2D.h"
-#import "CCLabelBMFont.h"
-#import "CCLayer.h"
-
-// support imports
-#import "Platforms/CCGL.h"
-#import "Platforms/CCNS.h"
-
-#import "Support/OpenGL_Internal.h"
-#import "Support/CGPointExtension.h"
-
-#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
-#import "Platforms/iOS/CCDirectorIOS.h"
-#define CC_DIRECTOR_DEFAULT CCDirectorTimer
-#elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED)
-#import "Platforms/Mac/CCDirectorMac.h"
-#define CC_DIRECTOR_DEFAULT CCDirectorDisplayLink
-#endif
-
-#import "Support/CCProfiling.h"
-
-#define kDefaultFPS 60.0 // 60 frames per second
-
-extern NSString * cocos2dVersion(void);
-
-
-@interface CCDirector (Private)
--(void) setNextScene;
-// shows the FPS in the screen
--(void) showFPS;
-// calculates delta time since last time it was called
--(void) calculateDeltaTime;
-@end
-
-@implementation CCDirector
-
-@synthesize animationInterval = animationInterval_;
-@synthesize runningScene = runningScene_;
-@synthesize displayFPS = displayFPS_;
-@synthesize nextDeltaTimeZero = nextDeltaTimeZero_;
-@synthesize isPaused = isPaused_;
-@synthesize sendCleanupToScene = sendCleanupToScene_;
-@synthesize runningThread = runningThread_;
-@synthesize notificationNode = notificationNode_;
-@synthesize projectionDelegate = projectionDelegate_;
-//
-// singleton stuff
-//
-static CCDirector *_sharedDirector = nil;
-
-+ (CCDirector *)sharedDirector
-{
- if (!_sharedDirector) {
-
- //
- // Default Director is TimerDirector
- //
- if( [ [CCDirector class] isEqual:[self class]] )
- _sharedDirector = [[CC_DIRECTOR_DEFAULT alloc] init];
- else
- _sharedDirector = [[self alloc] init];
- }
-
- return _sharedDirector;
-}
-
-+(id)alloc
-{
- NSAssert(_sharedDirector == nil, @"Attempted to allocate a second instance of a singleton.");
- return [super alloc];
-}
-
-- (id) init
-{
- CCLOG(@"cocos2d: %@", cocos2dVersion() );
-
- if( (self=[super init]) ) {
-
- CCLOG(@"cocos2d: Using Director Type:%@", [self class]);
-
- // scenes
- runningScene_ = nil;
- nextScene_ = nil;
-
- notificationNode_ = nil;
-
- oldAnimationInterval_ = animationInterval_ = 1.0 / kDefaultFPS;
- scenesStack_ = [[NSMutableArray alloc] initWithCapacity:10];
-
- // Set default projection (3D)
- projection_ = kCCDirectorProjectionDefault;
-
- // projection delegate if "Custom" projection is used
- projectionDelegate_ = nil;
-
- // FPS
- displayFPS_ = NO;
- frames_ = 0;
-
- // paused ?
- isPaused_ = NO;
-
- // running thread
- runningThread_ = nil;
-
- winSizeInPixels_ = winSizeInPoints_ = CGSizeZero;
- }
-
- return self;
-}
-
-- (void) dealloc
-{
- CCLOGINFO(@"cocos2d: deallocing %@", self);
-
-#if CC_DIRECTOR_FAST_FPS
- [FPSLabel_ release];
-#endif
- [runningScene_ release];
- [notificationNode_ release];
- [scenesStack_ release];
-
- [projectionDelegate_ release];
-
- _sharedDirector = nil;
-
- [super dealloc];
-}
-
--(void) setGLDefaultValues
-{
- // This method SHOULD be called only after openGLView_ was initialized
- NSAssert( openGLView_, @"openGLView_ must be initialized");
-
- [self setAlphaBlending: YES];
- [self setDepthTest: YES];
- [self setProjection: projection_];
-
- // set other opengl default values
- glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
-
-#if CC_DIRECTOR_FAST_FPS
- if (!FPSLabel_) {
- CCTexture2DPixelFormat currentFormat = [CCTexture2D defaultAlphaPixelFormat];
- [CCTexture2D setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGBA4444];
- FPSLabel_ = [[CCLabelAtlas labelWithString:@"00.0" charMapFile:@"fps_images.png" itemWidth:16 itemHeight:24 startCharMap:'.'] retain];
- [CCTexture2D setDefaultAlphaPixelFormat:currentFormat];
- }
-#endif // CC_DIRECTOR_FAST_FPS
-}
-
-//
-// Draw the Scene
-//
-- (void) drawScene
-{
- // Override me
-}
-
--(void) calculateDeltaTime
-{
- struct timeval now;
-
- if( gettimeofday( &now, NULL) != 0 ) {
- CCLOG(@"cocos2d: error in gettimeofday");
- dt = 0;
- return;
- }
-
- // new delta time
- if( nextDeltaTimeZero_ ) {
- dt = 0;
- nextDeltaTimeZero_ = NO;
- } else {
- dt = (now.tv_sec - lastUpdate_.tv_sec) + (now.tv_usec - lastUpdate_.tv_usec) / 1000000.0f;
- dt = MAX(0,dt);
- }
-
- lastUpdate_ = now;
-}
-
-#pragma mark Director - Memory Helper
-
--(void) purgeCachedData
-{
- [CCLabelBMFont purgeCachedData];
- [CCTextureCache purgeSharedTextureCache];
-}
-
-#pragma mark Director - Scene OpenGL Helper
-
--(ccDirectorProjection) projection
-{
- return projection_;
-}
-
--(float) getZEye
-{
- return ( winSizeInPixels_.height / 1.1566f );
-}
-
--(void) setProjection:(ccDirectorProjection)projection
-{
- CCLOG(@"cocos2d: override me");
-}
-
-- (void) setAlphaBlending: (BOOL) on
-{
- if (on) {
- glEnable(GL_BLEND);
- glBlendFunc(CC_BLEND_SRC, CC_BLEND_DST);
-
- } else
- glDisable(GL_BLEND);
-}
-
-- (void) setDepthTest: (BOOL) on
-{
- if (on) {
- ccglClearDepth(1.0f);
- glEnable(GL_DEPTH_TEST);
- glDepthFunc(GL_LEQUAL);
- glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
- } else
- glDisable( GL_DEPTH_TEST );
-}
-
-#pragma mark Director Integration with a UIKit view
-
--(CC_GLVIEW*) openGLView
-{
- return openGLView_;
-}
-
--(void) setOpenGLView:(CC_GLVIEW *)view
-{
- NSAssert( view, @"OpenGLView must be non-nil");
-
- if( view != openGLView_ ) {
- [openGLView_ release];
- openGLView_ = [view retain];
-
- // set size
- winSizeInPixels_ = winSizeInPoints_ = CCNSSizeToCGSize( [view bounds].size );
-
- [self setGLDefaultValues];
- }
-}
-
-#pragma mark Director Scene Landscape
-
--(CGPoint)convertToGL:(CGPoint)uiPoint
-{
- CCLOG(@"CCDirector#convertToGL: OVERRIDE ME.");
- return CGPointZero;
-}
-
--(CGPoint)convertToUI:(CGPoint)glPoint
-{
- CCLOG(@"CCDirector#convertToUI: OVERRIDE ME.");
- return CGPointZero;
-}
-
--(CGSize)winSize
-{
- return winSizeInPoints_;
-}
-
--(CGSize)winSizeInPixels
-{
- return winSizeInPixels_;
-}
-
--(CGSize)displaySizeInPixels
-{
- return winSizeInPixels_;
-}
-
--(void) reshapeProjection:(CGSize)newWindowSize
-{
- winSizeInPixels_ = winSizeInPoints_ = newWindowSize;
- [self setProjection:projection_];
-}
-
-#pragma mark Director Scene Management
-
-- (void)runWithScene:(CCScene*) scene
-{
- NSAssert( scene != nil, @"Argument must be non-nil");
- NSAssert( runningScene_ == nil, @"You can't run an scene if another Scene is running. Use replaceScene or pushScene instead");
-
- [self pushScene:scene];
- [self startAnimation];
-}
-
--(void) replaceScene: (CCScene*) scene
-{
- NSAssert( scene != nil, @"Argument must be non-nil");
-
- NSUInteger index = [scenesStack_ count];
-
- sendCleanupToScene_ = YES;
- [scenesStack_ replaceObjectAtIndex:index-1 withObject:scene];
- nextScene_ = scene; // nextScene_ is a weak ref
-}
-
-- (void) pushScene: (CCScene*) scene
-{
- NSAssert( scene != nil, @"Argument must be non-nil");
-
- sendCleanupToScene_ = NO;
-
- [scenesStack_ addObject: scene];
- nextScene_ = scene; // nextScene_ is a weak ref
-}
-
--(void) popScene
-{
- NSAssert( runningScene_ != nil, @"A running Scene is needed");
-
- [scenesStack_ removeLastObject];
- NSUInteger c = [scenesStack_ count];
-
- if( c == 0 )
- [self end];
- else {
- sendCleanupToScene_ = YES;
- nextScene_ = [scenesStack_ objectAtIndex:c-1];
- }
-}
-
--(void) end
-{
- [runningScene_ onExit];
- [runningScene_ cleanup];
- [runningScene_ release];
-
- runningScene_ = nil;
- nextScene_ = nil;
-
- // remove all objects, but don't release it.
- // runWithScene might be executed after 'end'.
- [scenesStack_ removeAllObjects];
-
- [self stopAnimation];
-
-#if CC_DIRECTOR_FAST_FPS
- [FPSLabel_ release];
- FPSLabel_ = nil;
-#endif
-
- [projectionDelegate_ release];
- projectionDelegate_ = nil;
-
- // Purge bitmap cache
- [CCLabelBMFont purgeCachedData];
-
- // Purge all managers
- [CCAnimationCache purgeSharedAnimationCache];
- [CCSpriteFrameCache purgeSharedSpriteFrameCache];
- [CCScheduler purgeSharedScheduler];
- [CCActionManager purgeSharedManager];
- [CCTextureCache purgeSharedTextureCache];
-
-
- // OpenGL view
-
- // Since the director doesn't attach the openglview to the window
- // it shouldn't remove it from the window too.
-// [openGLView_ removeFromSuperview];
-
- [openGLView_ release];
- openGLView_ = nil;
-}
-
--(void) setNextScene
-{
- Class transClass = [CCTransitionScene class];
- BOOL runningIsTransition = [runningScene_ isKindOfClass:transClass];
- BOOL newIsTransition = [nextScene_ isKindOfClass:transClass];
-
- // If it is not a transition, call onExit/cleanup
- if( ! newIsTransition ) {
- [runningScene_ onExit];
-
- // issue #709. the root node (scene) should receive the cleanup message too
- // otherwise it might be leaked.
- if( sendCleanupToScene_)
- [runningScene_ cleanup];
- }
-
- [runningScene_ release];
-
- runningScene_ = [nextScene_ retain];
- nextScene_ = nil;
-
- if( ! runningIsTransition ) {
- [runningScene_ onEnter];
- [runningScene_ onEnterTransitionDidFinish];
- }
-}
-
--(void) pause
-{
- if( isPaused_ )
- return;
-
- oldAnimationInterval_ = animationInterval_;
-
- // when paused, don't consume CPU
- [self setAnimationInterval:1/4.0];
- isPaused_ = YES;
-}
-
--(void) resume
-{
- if( ! isPaused_ )
- return;
-
- [self setAnimationInterval: oldAnimationInterval_];
-
- if( gettimeofday( &lastUpdate_, NULL) != 0 ) {
- CCLOG(@"cocos2d: Director: Error in gettimeofday");
- }
-
- isPaused_ = NO;
- dt = 0;
-}
-
-- (void)startAnimation
-{
- CCLOG(@"cocos2d: Director#startAnimation. Override me");
-}
-
-- (void)stopAnimation
-{
- CCLOG(@"cocos2d: Director#stopAnimation. Override me");
-}
-
-- (void)setAnimationInterval:(NSTimeInterval)interval
-{
- CCLOG(@"cocos2d: Director#setAnimationInterval. Override me");
-}
-
-#if CC_DIRECTOR_FAST_FPS
-
-// display the FPS using a LabelAtlas
-// updates the FPS every frame
--(void) showFPS
-{
- frames_++;
- accumDt_ += dt;
-
- if ( accumDt_ > CC_DIRECTOR_FPS_INTERVAL) {
- frameRate_ = frames_/accumDt_;
- frames_ = 0;
- accumDt_ = 0;
-
-// sprintf(format,"%.1f",frameRate);
-// [FPSLabel setCString:format];
-
- NSString *str = [[NSString alloc] initWithFormat:@"%.1f", frameRate_];
- [FPSLabel_ setString:str];
- [str release];
- }
-
- [FPSLabel_ draw];
-}
-#else
-// display the FPS using a manually generated Texture (very slow)
-// updates the FPS 3 times per second aprox.
--(void) showFPS
-{
- frames_++;
- accumDt_ += dt;
-
- if ( accumDt_ > CC_DIRECTOR_FPS_INTERVAL) {
- frameRate_ = frames_/accumDt_;
- frames_ = 0;
- accumDt_ = 0;
- }
-
- NSString *str = [NSString stringWithFormat:@"%.2f",frameRate_];
- CCTexture2D *texture = [[CCTexture2D alloc] initWithString:str dimensions:CGSizeMake(100,30) alignment:UITextAlignmentLeft fontName:@"Arial" fontSize:24];
-
- // Default GL states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
- // Needed states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_TEXTURE_COORD_ARRAY
- // Unneeded states: GL_COLOR_ARRAY
- glDisableClientState(GL_COLOR_ARRAY);
-
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
- glColor4ub(224,224,244,200);
- [texture drawAtPoint: ccp(5,2)];
- [texture release];
-
- glBlendFunc(CC_BLEND_SRC, CC_BLEND_DST);
-
- // restore default GL state
- glEnableClientState(GL_COLOR_ARRAY);
-}
-#endif
-
-- (void) showProfilers {
-#if CC_ENABLE_PROFILERS
- accumDtForProfiler_ += dt;
- if (accumDtForProfiler_ > 1.0f) {
- accumDtForProfiler_ = 0;
- [[CCProfiler sharedProfiler] displayTimers];
- }
-#endif // CC_ENABLE_PROFILERS
-}
-
-@end
-
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (c) 2008-2010 Ricardo Quesada
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-
-#ifndef __CC_DRAWING_PRIMITIVES_H
-#define __CC_DRAWING_PRIMITIVES_H
-
-#import <Availability.h>
-#import <Foundation/Foundation.h>
-
-#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
-#import <CoreGraphics/CGGeometry.h> // for CGPoint
-#endif
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- @file
- Drawing OpenGL ES primitives.
- - ccDrawPoint
- - ccDrawLine
- - ccDrawPoly
- - ccDrawCircle
- - ccDrawQuadBezier
- - ccDrawCubicBezier
-
- You can change the color, width and other property by calling the
- glColor4ub(), glLineWitdh(), glPointSize().
-
- @warning These functions draws the Line, Point, Polygon, immediately. They aren't batched. If you are going to make a game that depends on these primitives, I suggest creating a batch.
- */
-
-
-/** draws a point given x and y coordinate measured in points. */
-void ccDrawPoint( CGPoint point );
-
-/** draws an array of points.
- @since v0.7.2
- */
-void ccDrawPoints( const CGPoint *points, NSUInteger numberOfPoints );
-
-/** draws a line given the origin and destination point measured in points. */
-void ccDrawLine( CGPoint origin, CGPoint destination );
-
-/** draws a poligon given a pointer to CGPoint coordiantes and the number of vertices measured in points.
- The polygon can be closed or open
- */
-void ccDrawPoly( const CGPoint *vertices, NSUInteger numOfVertices, BOOL closePolygon );
-
-/** draws a circle given the center, radius and number of segments measured in points */
-void ccDrawCircle( CGPoint center, float radius, float angle, NSUInteger segments, BOOL drawLineToCenter);
-
-/** draws a quad bezier path measured in points.
- @since v0.8
- */
-void ccDrawQuadBezier(CGPoint origin, CGPoint control, CGPoint destination, NSUInteger segments);
-
-/** draws a cubic bezier path measured in points.
- @since v0.8
- */
-void ccDrawCubicBezier(CGPoint origin, CGPoint control1, CGPoint control2, CGPoint destination, NSUInteger segments);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // __CC_DRAWING_PRIMITIVES_H
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (c) 2008-2010 Ricardo Quesada
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-#import <math.h>
-#import <stdlib.h>
-#import <string.h>
-
-#import "CCDrawingPrimitives.h"
-#import "ccTypes.h"
-#import "ccMacros.h"
-#import "Platforms/CCGL.h"
-
-void ccDrawPoint( CGPoint point )
-{
- ccVertex2F p = (ccVertex2F) {point.x * CC_CONTENT_SCALE_FACTOR(), point.y * CC_CONTENT_SCALE_FACTOR() };
-
- // Default GL states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
- // Needed states: GL_VERTEX_ARRAY,
- // Unneeded states: GL_TEXTURE_2D, GL_TEXTURE_COORD_ARRAY, GL_COLOR_ARRAY
- glDisable(GL_TEXTURE_2D);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- glDisableClientState(GL_COLOR_ARRAY);
-
- glVertexPointer(2, GL_FLOAT, 0, &p);
- glDrawArrays(GL_POINTS, 0, 1);
-
- // restore default state
- glEnableClientState(GL_COLOR_ARRAY);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glEnable(GL_TEXTURE_2D);
-}
-
-void ccDrawPoints( const CGPoint *points, NSUInteger numberOfPoints )
-{
- // Default GL states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
- // Needed states: GL_VERTEX_ARRAY,
- // Unneeded states: GL_TEXTURE_2D, GL_TEXTURE_COORD_ARRAY, GL_COLOR_ARRAY
- glDisable(GL_TEXTURE_2D);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- glDisableClientState(GL_COLOR_ARRAY);
-
- ccVertex2F newPoints[numberOfPoints];
-
- // iPhone and 32-bit machines optimization
- if( sizeof(CGPoint) == sizeof(ccVertex2F) ) {
-
- // points ?
- if( CC_CONTENT_SCALE_FACTOR() != 1 ) {
- for( NSUInteger i=0; i<numberOfPoints;i++)
- newPoints[i] = (ccVertex2F){ points[i].x * CC_CONTENT_SCALE_FACTOR(), points[i].y * CC_CONTENT_SCALE_FACTOR() };
-
- glVertexPointer(2, GL_FLOAT, 0, newPoints);
-
- } else
- glVertexPointer(2, GL_FLOAT, 0, points);
-
- glDrawArrays(GL_POINTS, 0, numberOfPoints);
-
- } else {
-
- // Mac on 64-bit
- for( NSUInteger i=0; i<numberOfPoints;i++)
- newPoints[i] = (ccVertex2F) { points[i].x, points[i].y };
-
- glVertexPointer(2, GL_FLOAT, 0, newPoints);
- glDrawArrays(GL_POINTS, 0, numberOfPoints);
-
- }
-
-
- // restore default state
- glEnableClientState(GL_COLOR_ARRAY);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glEnable(GL_TEXTURE_2D);
-}
-
-
-void ccDrawLine( CGPoint origin, CGPoint destination )
-{
- ccVertex2F vertices[2] = {
- {origin.x * CC_CONTENT_SCALE_FACTOR(), origin.y * CC_CONTENT_SCALE_FACTOR() },
- {destination.x * CC_CONTENT_SCALE_FACTOR(), destination.y * CC_CONTENT_SCALE_FACTOR() }
- };
-
- // Default GL states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
- // Needed states: GL_VERTEX_ARRAY,
- // Unneeded states: GL_TEXTURE_2D, GL_TEXTURE_COORD_ARRAY, GL_COLOR_ARRAY
- glDisable(GL_TEXTURE_2D);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- glDisableClientState(GL_COLOR_ARRAY);
-
- glVertexPointer(2, GL_FLOAT, 0, vertices);
- glDrawArrays(GL_LINES, 0, 2);
-
- // restore default state
- glEnableClientState(GL_COLOR_ARRAY);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glEnable(GL_TEXTURE_2D);
-}
-
-
-void ccDrawPoly( const CGPoint *poli, NSUInteger numberOfPoints, BOOL closePolygon )
-{
- ccVertex2F newPoint[numberOfPoints];
-
- // Default GL states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
- // Needed states: GL_VERTEX_ARRAY,
- // Unneeded states: GL_TEXTURE_2D, GL_TEXTURE_COORD_ARRAY, GL_COLOR_ARRAY
- glDisable(GL_TEXTURE_2D);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- glDisableClientState(GL_COLOR_ARRAY);
-
-
- // iPhone and 32-bit machines
- if( sizeof(CGPoint) == sizeof(ccVertex2F) ) {
-
- // convert to pixels ?
- if( CC_CONTENT_SCALE_FACTOR() != 1 ) {
- memcpy( newPoint, poli, numberOfPoints * sizeof(ccVertex2F) );
- for( NSUInteger i=0; i<numberOfPoints;i++)
- newPoint[i] = (ccVertex2F) { poli[i].x * CC_CONTENT_SCALE_FACTOR(), poli[i].y * CC_CONTENT_SCALE_FACTOR() };
-
- glVertexPointer(2, GL_FLOAT, 0, newPoint);
-
- } else
- glVertexPointer(2, GL_FLOAT, 0, poli);
-
-
- } else {
- // 64-bit machines (Mac)
-
- for( NSUInteger i=0; i<numberOfPoints;i++)
- newPoint[i] = (ccVertex2F) { poli[i].x, poli[i].y };
-
- glVertexPointer(2, GL_FLOAT, 0, newPoint );
-
- }
-
- if( closePolygon )
- glDrawArrays(GL_LINE_LOOP, 0, numberOfPoints);
- else
- glDrawArrays(GL_LINE_STRIP, 0, numberOfPoints);
-
- // restore default state
- glEnableClientState(GL_COLOR_ARRAY);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glEnable(GL_TEXTURE_2D);
-}
-
-void ccDrawCircle( CGPoint center, float r, float a, NSUInteger segs, BOOL drawLineToCenter)
-{
- int additionalSegment = 1;
- if (drawLineToCenter)
- additionalSegment++;
-
- const float coef = 2.0f * (float)M_PI/segs;
-
- GLfloat *vertices = calloc( sizeof(GLfloat)*2*(segs+2), 1);
- if( ! vertices )
- return;
-
- for(NSUInteger i=0;i<=segs;i++)
- {
- float rads = i*coef;
- GLfloat j = r * cosf(rads + a) + center.x;
- GLfloat k = r * sinf(rads + a) + center.y;
-
- vertices[i*2] = j * CC_CONTENT_SCALE_FACTOR();
- vertices[i*2+1] =k * CC_CONTENT_SCALE_FACTOR();
- }
- vertices[(segs+1)*2] = center.x * CC_CONTENT_SCALE_FACTOR();
- vertices[(segs+1)*2+1] = center.y * CC_CONTENT_SCALE_FACTOR();
-
- // Default GL states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
- // Needed states: GL_VERTEX_ARRAY,
- // Unneeded states: GL_TEXTURE_2D, GL_TEXTURE_COORD_ARRAY, GL_COLOR_ARRAY
- glDisable(GL_TEXTURE_2D);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- glDisableClientState(GL_COLOR_ARRAY);
-
- glVertexPointer(2, GL_FLOAT, 0, vertices);
- glDrawArrays(GL_LINE_STRIP, 0, segs+additionalSegment);
-
- // restore default state
- glEnableClientState(GL_COLOR_ARRAY);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glEnable(GL_TEXTURE_2D);
-
- free( vertices );
-}
-
-void ccDrawQuadBezier(CGPoint origin, CGPoint control, CGPoint destination, NSUInteger segments)
-{
- ccVertex2F vertices[segments + 1];
-
- float t = 0.0f;
- for(NSUInteger i = 0; i < segments; i++)
- {
- GLfloat x = powf(1 - t, 2) * origin.x + 2.0f * (1 - t) * t * control.x + t * t * destination.x;
- GLfloat y = powf(1 - t, 2) * origin.y + 2.0f * (1 - t) * t * control.y + t * t * destination.y;
- vertices[i] = (ccVertex2F) {x * CC_CONTENT_SCALE_FACTOR(), y * CC_CONTENT_SCALE_FACTOR() };
- t += 1.0f / segments;
- }
- vertices[segments] = (ccVertex2F) {destination.x * CC_CONTENT_SCALE_FACTOR(), destination.y * CC_CONTENT_SCALE_FACTOR() };
-
- // Default GL states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
- // Needed states: GL_VERTEX_ARRAY,
- // Unneeded states: GL_TEXTURE_2D, GL_TEXTURE_COORD_ARRAY, GL_COLOR_ARRAY
- glDisable(GL_TEXTURE_2D);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- glDisableClientState(GL_COLOR_ARRAY);
-
- glVertexPointer(2, GL_FLOAT, 0, vertices);
- glDrawArrays(GL_LINE_STRIP, 0, segments + 1);
-
- // restore default state
- glEnableClientState(GL_COLOR_ARRAY);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glEnable(GL_TEXTURE_2D);
-}
-
-void ccDrawCubicBezier(CGPoint origin, CGPoint control1, CGPoint control2, CGPoint destination, NSUInteger segments)
-{
- ccVertex2F vertices[segments + 1];
-
- float t = 0;
- for(NSUInteger i = 0; i < segments; i++)
- {
- GLfloat x = powf(1 - t, 3) * origin.x + 3.0f * powf(1 - t, 2) * t * control1.x + 3.0f * (1 - t) * t * t * control2.x + t * t * t * destination.x;
- GLfloat y = powf(1 - t, 3) * origin.y + 3.0f * powf(1 - t, 2) * t * control1.y + 3.0f * (1 - t) * t * t * control2.y + t * t * t * destination.y;
- vertices[i] = (ccVertex2F) {x * CC_CONTENT_SCALE_FACTOR(), y * CC_CONTENT_SCALE_FACTOR() };
- t += 1.0f / segments;
- }
- vertices[segments] = (ccVertex2F) {destination.x * CC_CONTENT_SCALE_FACTOR(), destination.y * CC_CONTENT_SCALE_FACTOR() };
-
- // Default GL states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
- // Needed states: GL_VERTEX_ARRAY,
- // Unneeded states: GL_TEXTURE_2D, GL_TEXTURE_COORD_ARRAY, GL_COLOR_ARRAY
- glDisable(GL_TEXTURE_2D);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- glDisableClientState(GL_COLOR_ARRAY);
-
- glVertexPointer(2, GL_FLOAT, 0, vertices);
- glDrawArrays(GL_LINE_STRIP, 0, segments + 1);
-
- // restore default state
- glEnableClientState(GL_COLOR_ARRAY);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glEnable(GL_TEXTURE_2D);
-}
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (c) 2009 On-Core
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-
-#import "Platforms/CCGL.h"
-#import <Foundation/Foundation.h>
-
-@class CCTexture2D;
-
-/** FBO class that grabs the the contents of the screen */
-@interface CCGrabber : NSObject
-{
- GLuint fbo;
- GLint oldFBO;
-}
-
--(void)grab:(CCTexture2D*)texture;
--(void)beforeRender:(CCTexture2D*)texture;
--(void)afterRender:(CCTexture2D*)texture;
-
-@end
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (c) 2009 On-Core
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-
-#import "Platforms/CCGL.h"
-#import "CCGrabber.h"
-#import "ccMacros.h"
-#import "CCTexture2D.h"
-#import "Support/OpenGL_Internal.h"
-
-@implementation CCGrabber
-
--(id) init
-{
- if(( self = [super init] )) {
- // generate FBO
- ccglGenFramebuffers(1, &fbo);
- }
- return self;
-}
-
--(void)grab:(CCTexture2D*)texture
-{
- glGetIntegerv(CC_GL_FRAMEBUFFER_BINDING, &oldFBO);
-
- // bind
- ccglBindFramebuffer(CC_GL_FRAMEBUFFER, fbo);
-
- // associate texture with FBO
- ccglFramebufferTexture2D(CC_GL_FRAMEBUFFER, CC_GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture.name, 0);
-
- // check if it worked (probably worth doing :) )
- GLuint status = ccglCheckFramebufferStatus(CC_GL_FRAMEBUFFER);
- if (status != CC_GL_FRAMEBUFFER_COMPLETE)
- [NSException raise:@"Frame Grabber" format:@"Could not attach texture to framebuffer"];
-
- ccglBindFramebuffer(CC_GL_FRAMEBUFFER, oldFBO);
-}
-
--(void)beforeRender:(CCTexture2D*)texture
-{
- glGetIntegerv(CC_GL_FRAMEBUFFER_BINDING, &oldFBO);
- ccglBindFramebuffer(CC_GL_FRAMEBUFFER, fbo);
-
- // BUG XXX: doesn't work with RGB565.
-
-
- glClearColor(0,0,0,0);
-
- // BUG #631: To fix #631, uncomment the lines with #631
- // Warning: But it CCGrabber won't work with 2 effects at the same time
-// glClearColor(0.0f,0.0f,0.0f,1.0f); // #631
-
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
-// glColorMask(TRUE, TRUE, TRUE, FALSE); // #631
-
-}
-
--(void)afterRender:(CCTexture2D*)texture
-{
- ccglBindFramebuffer(CC_GL_FRAMEBUFFER, oldFBO);
-// glColorMask(TRUE, TRUE, TRUE, TRUE); // #631
-}
-
-- (void) dealloc
-{
- CCLOGINFO(@"cocos2d: deallocing %@", self);
- ccglDeleteFramebuffers(1, &fbo);
- [super dealloc];
-}
-
-@end
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (c) 2009 On-Core
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-
-#import <Foundation/Foundation.h>
-
-#import "CCNode.h"
-#import "CCCamera.h"
-#import "ccTypes.h"
-
-@class CCTexture2D;
-@class CCGrabber;
-
-/** Base class for other
- */
-@interface CCGridBase : NSObject
-{
- BOOL active_;
- int reuseGrid_;
- ccGridSize gridSize_;
- CCTexture2D *texture_;
- CGPoint step_;
- CCGrabber *grabber_;
- BOOL isTextureFlipped_;
-}
-
-/** wheter or not the grid is active */
-@property (nonatomic,readwrite) BOOL active;
-/** number of times that the grid will be reused */
-@property (nonatomic,readwrite) int reuseGrid;
-/** size of the grid */
-@property (nonatomic,readonly) ccGridSize gridSize;
-/** pixels between the grids */
-@property (nonatomic,readwrite) CGPoint step;
-/** texture used */
-@property (nonatomic, retain) CCTexture2D *texture;
-/** grabber used */
-@property (nonatomic, retain) CCGrabber *grabber;
-/** is texture flipped */
-@property (nonatomic, readwrite) BOOL isTextureFlipped;
-
-+(id) gridWithSize:(ccGridSize)gridSize texture:(CCTexture2D*)texture flippedTexture:(BOOL)flipped;
-+(id) gridWithSize:(ccGridSize)gridSize;
-
--(id) initWithSize:(ccGridSize)gridSize texture:(CCTexture2D*)texture flippedTexture:(BOOL)flipped;
--(id)initWithSize:(ccGridSize)gridSize;
--(void)beforeDraw;
--(void)afterDraw:(CCNode*)target;
--(void)blit;
--(void)reuse;
-
--(void)calculateVertexPoints;
-
-@end
-
-////////////////////////////////////////////////////////////
-
-/**
- CCGrid3D is a 3D grid implementation. Each vertex has 3 dimensions: x,y,z
- */
-@interface CCGrid3D : CCGridBase
-{
- GLvoid *texCoordinates;
- GLvoid *vertices;
- GLvoid *originalVertices;
- GLushort *indices;
-}
-
-/** returns the vertex at a given position */
--(ccVertex3F)vertex:(ccGridSize)pos;
-/** returns the original (non-transformed) vertex at a given position */
--(ccVertex3F)originalVertex:(ccGridSize)pos;
-/** sets a new vertex at a given position */
--(void)setVertex:(ccGridSize)pos vertex:(ccVertex3F)vertex;
-
-@end
-
-////////////////////////////////////////////////////////////
-
-/**
- CCTiledGrid3D is a 3D grid implementation. It differs from Grid3D in that
- the tiles can be separated from the grid.
-*/
-@interface CCTiledGrid3D : CCGridBase
-{
- GLvoid *texCoordinates;
- GLvoid *vertices;
- GLvoid *originalVertices;
- GLushort *indices;
-}
-
-/** returns the tile at the given position */
--(ccQuad3)tile:(ccGridSize)pos;
-/** returns the original tile (untransformed) at the given position */
--(ccQuad3)originalTile:(ccGridSize)pos;
-/** sets a new tile */
--(void)setTile:(ccGridSize)pos coords:(ccQuad3)coords;
-
-@end
+++ /dev/null
-/*
- * cocos2d for iPhone: http://www.cocos2d-iphone.org
- *
- * Copyright (c) 2009 On-Core
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-
-#import <Availability.h>
-
-#import "ccMacros.h"
-#import "CCGrid.h"
-#import "CCTexture2D.h"
-#import "CCDirector.h"
-#import "CCGrabber.h"
-
-#import "Platforms/CCGL.h"
-#import "Support/CGPointExtension.h"
-#import "Support/ccUtils.h"
-
-#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
-#import "Platforms/iOS/CCDirectorIOS.h"
-#endif // __IPHONE_OS_VERSION_MAX_ALLOWED
-
-#pragma mark -
-#pragma mark CCGridBase
-
-@implementation CCGridBase
-
-@synthesize reuseGrid = reuseGrid_;
-@synthesize texture = texture_;
-@synthesize grabber = grabber_;
-@synthesize gridSize = gridSize_;
-@synthesize step = step_;
-
-+(id) gridWithSize:(ccGridSize)gridSize texture:(CCTexture2D*)texture flippedTexture:(BOOL)flipped
-{
- return [[[self alloc] initWithSize:gridSize texture:texture flippedTexture:flipped] autorelease];
-}
-
-+(id) gridWithSize:(ccGridSize)gridSize
-{
- return [[(CCGridBase*)[self alloc] initWithSize:gridSize] autorelease];
-}
-
--(id) initWithSize:(ccGridSize)gridSize texture:(CCTexture2D*)texture flippedTexture:(BOOL)flipped
-{
- if( (self=[super init]) ) {
-
- active_ = NO;
- reuseGrid_ = 0;
- gridSize_ = gridSize;
-
- self.texture = texture;
- isTextureFlipped_ = flipped;
-
- CGSize texSize = [texture_ contentSizeInPixels];
- step_.x = texSize.width / gridSize_.x;
- step_.y = texSize.height / gridSize_.y;
-
- grabber_ = [[CCGrabber alloc] init];
- [grabber_ grab:texture_];
-
- [self calculateVertexPoints];
- }
- return self;
-}
-
--(id)initWithSize:(ccGridSize)gSize
-{
- CCDirector *director = [CCDirector sharedDirector];
- CGSize s = [director winSizeInPixels];
-
- unsigned int POTWide = ccNextPOT(s.width);
- unsigned int POTHigh = ccNextPOT(s.height);
-
-#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
- EAGLView *glview = [[CCDirector sharedDirector] openGLView];
- NSString *pixelFormat = [glview pixelFormat];
-
- CCTexture2DPixelFormat format = [pixelFormat isEqualToString: kEAGLColorFormatRGB565] ? kCCTexture2DPixelFormat_RGB565 : kCCTexture2DPixelFormat_RGBA8888;
-#else
- CCTexture2DPixelFormat format = kCCTexture2DPixelFormat_RGBA8888;
-#endif
-
- void *data = calloc((int)(POTWide * POTHigh * 4), 1);
- if( ! data ) {
- CCLOG(@"cocos2d: CCGrid: not enough memory");
- [self release];
- return nil;
- }
-
- CCTexture2D *texture = [[CCTexture2D alloc] initWithData:data pixelFormat:format pixelsWide:POTWide pixelsHigh:POTHigh contentSize:s];
- free( data );
-
- if( ! texture ) {
- CCLOG(@"cocos2d: CCGrid: error creating texture");
- [self release];
- return nil;
- }
-
- self = [self initWithSize:gSize texture:texture flippedTexture:NO];
-
- [texture release];
-
- return self;
-}
-- (NSString*) description
-{
- return [NSString stringWithFormat:@"<%@ = %08X | Dimensions = %ix%i>", [self class], self, gridSize_.x, gridSize_.y];
-}
-
-- (void) dealloc
-{
- CCLOGINFO(@"cocos2d: deallocing %@", self);
-
- [self setActive: NO];
-
- [texture_ release];
- [grabber_ release];
- [super dealloc];
-}
-
-// properties
--(BOOL) active
-{
- return active_;
-}
-
--(void) setActive:(BOOL)active
-{
- active_ = active;
- if( ! active ) {
- CCDirector *director = [CCDirector sharedDirector];
- ccDirectorProjection proj = [director projection];
- [director setProjection:proj];
- }
-}
-
--(BOOL) isTextureFlipped
-{
- return isTextureFlipped_;
-}
-
--(void) setIsTextureFlipped:(BOOL)flipped
-{
- if( isTextureFlipped_ != flipped ) {
- isTextureFlipped_ = flipped;
- [self calculateVertexPoints];
- }
-}
-
-// This routine can be merged with Director
-#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
--(void)applyLandscape
-{
- CCDirector *director = [CCDirector sharedDirector];
-
- CGSize winSize = [director displaySizeInPixels];
- float w = winSize.width / 2;
- float h = winSize.height / 2;
-
- ccDeviceOrientation orientation = [director deviceOrientation];
-
- switch (orientation) {
- case CCDeviceOrientationLandscapeLeft:
- glTranslatef(w,h,0);
- glRotatef(-90,0,0,1);
- glTranslatef(-h,-w,0);
- break;
- case CCDeviceOrientationLandscapeRight:
- glTranslatef(w,h,0);
- glRotatef(90,0,0,1);
- glTranslatef(-h,-w,0);
- break;
- case CCDeviceOrientationPortraitUpsideDown:
- glTranslatef(w,h,0);
- glRotatef(180,0,0,1);
- glTranslatef(-w,-h,0);
- break;
- default:
- break;
- }
-}
-#endif
-
--(void)set2DProjection
-{
- CGSize winSize = [[CCDirector sharedDirector] winSizeInPixels];
-
- glLoadIdentity();
- glViewport(0, 0, winSize.width, winSize.height);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- ccglOrtho(0, winSize.width, 0, winSize.height, -1024, 1024);
- glMatrixMode(GL_MODELVIEW);
-}
-
-// This routine can be merged with Director
--(void)set3DProjection
-{
- CCDirector *director = [CCDirector sharedDirector];
-
- CGSize winSize = [director displaySizeInPixels];
-
- glViewport(0, 0, winSize.width, winSize.height);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- gluPerspective(60, (GLfloat)winSize.width/winSize.height, 0.5f, 1500.0f);
-
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- gluLookAt( winSize.width/2, winSize.height/2, [director getZEye],
- winSize.width/2, winSize.height/2, 0,
- 0.0f, 1.0f, 0.0f
- );
-}
-
--(void)beforeDraw
-{
- [self set2DProjection];
- [grabber_ beforeRender:texture_];
-}
-
--(void)afterDraw:(CCNode *)target
-{
- [grabber_ afterRender:texture_];
-
- [self set3DProjection];
-#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
- [self applyLandscape];
-#endif
-
- if( target.camera.dirty ) {
-
- CGPoint offset = [target anchorPointInPixels];
-
- //
- // XXX: Camera should be applied in the AnchorPoint
- //
- ccglTranslate(offset.x, offset.y, 0);
- [target.camera locate];
- ccglTranslate(-offset.x, -offset.y, 0);
- }
-
- glBindTexture(GL_TEXTURE_2D, texture_.name);
-
- [self blit];
-}
-
--(void)blit
-{
- [NSException raise:@"GridBase" format:@"Abstract class needs implementation"];
-}
-
--(void)reuse
-{
- [NSException raise:@"GridBase" format:@"Abstract class needs implementation"];
-}
-
--(void)calculateVertexPoints
-{
- [NSException raise:@"GridBase" format:@"Abstract class needs implementation"];
-}
-
-@end
-
-////////////////////////////////////////////////////////////
-
-#pragma mark -
-#pragma mark CCGrid3D
-@implementation CCGrid3D
-
--(void)dealloc
-{
- free(texCoordinates);
- free(vertices);
- free(indices);
- free(originalVertices);
- [super dealloc];
-}
-
--(void)blit
-{
- int n = gridSize_.x * gridSize_.y;
-
- // Default GL states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
- // Needed states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_TEXTURE_COORD_ARRAY
- // Unneeded states: GL_COLOR_ARRAY
- glDisableClientState(GL_COLOR_ARRAY);
-
- glVertexPointer(3, GL_FLOAT, 0, vertices);
- glTexCoordPointer(2, GL_FLOAT, 0, texCoordinates);
- glDrawElements(GL_TRIANGLES, n*6, GL_UNSIGNED_SHORT, indices);
-
- // restore GL default state
- glEnableClientState(GL_COLOR_ARRAY);
-}
-
--(void)calculateVertexPoints
-{
- float width = (float)texture_.pixelsWide;
- float height = (float)texture_.pixelsHigh;
- float imageH = texture_.contentSizeInPixels.height;
-
- int x, y, i;
-
- vertices = malloc((gridSize_.x+1)*(gridSize_.y+1)*sizeof(ccVertex3F));
- originalVertices = malloc((gridSize_.x+1)*(gridSize_.y+1)*sizeof(ccVertex3F));
- texCoordinates = malloc((gridSize_.x+1)*(gridSize_.y+1)*sizeof(CGPoint));
- indices = malloc(gridSize_.x*gridSize_.y*sizeof(GLushort)*6);
-
- float *vertArray = (float*)vertices;
- float *texArray = (float*)texCoordinates;
- GLushort *idxArray = (GLushort *)indices;
-
- for( x = 0; x < gridSize_.x; x++ )
- {
- for( y = 0; y < gridSize_.y; y++ )
- {
- int idx = (y * gridSize_.x) + x;
-
- float x1 = x * step_.x;
- float x2 = x1 + step_.x;
- float y1 = y * step_.y;
- float y2 = y1 + step_.y;
-
- GLushort a = x * (gridSize_.y+1) + y;
- GLushort b = (x+1) * (gridSize_.y+1) + y;
- GLushort c = (x+1) * (gridSize_.y+1) + (y+1);
- GLushort d = x * (gridSize_.y+1) + (y+1);
-
- GLushort tempidx[6] = { a, b, d, b, c, d };
-
- memcpy(&idxArray[6*idx], tempidx, 6*sizeof(GLushort));
-
- int l1[4] = { a*3, b*3, c*3, d*3 };
- ccVertex3F e = {x1,y1,0};
- ccVertex3F f = {x2,y1,0};
- ccVertex3F g = {x2,y2,0};
- ccVertex3F h = {x1,y2,0};
-
- ccVertex3F l2[4] = { e, f, g, h };
-
- int tex1[4] = { a*2, b*2, c*2, d*2 };
- CGPoint tex2[4] = { ccp(x1, y1), ccp(x2, y1), ccp(x2, y2), ccp(x1, y2) };
-
- for( i = 0; i < 4; i++ )
- {
- vertArray[ l1[i] ] = l2[i].x;
- vertArray[ l1[i] + 1 ] = l2[i].y;
- vertArray[ l1[i] + 2 ] = l2[i].z;
-
- texArray[ tex1[i] ] = tex2[i].x / width;
- if( isTextureFlipped_ )
- texArray[ tex1[i] + 1 ] = (imageH - tex2[i].y) / height;
- else
- texArray[ tex1[i] + 1 ] = tex2[i].y / height;
- }
- }
- }
-
- memcpy(originalVertices, vertices, (gridSize_.x+1)*(gridSize_.y+1)*sizeof(ccVertex3F));
-}
-
--(ccVertex3F)vertex:(ccGridSize)pos
-{
- int index = (pos.x * (gridSize_.y+1) + pos.y) * 3;
- float *vertArray = (float *)vertices;
-
- ccVertex3F vert = { vertArray[index], vertArray[index+1], vertArray[index+2] };
-
- return vert;
-}
-
--(ccVertex3F)originalVertex:(ccGridSize)pos
-{
- int index = (pos.x * (gridSize_.y+1) + pos.y) * 3;
- float *vertArray = (float *)originalVertices;
-
- ccVertex3F vert = { vertArray[index], vertArray[index+1], vertArray[index+2] };
-
- return vert;
-}
-
--(void)setVertex:(ccGridSize)pos vertex:(ccVertex3F)vertex
-{
- int index = (pos.x * (gridSize_.y+1) + pos.y) * 3;
- float *vertArray = (float *)vertices;
- vertArray[index] = vertex.x;
- vertArray[index+1] = vertex.y;
- &n