diff --git a/cocos2dx/base_nodes/CCNode.cpp b/cocos2dx/base_nodes/CCNode.cpp index b56675bdfb..651caa2268 100644 --- a/cocos2dx/base_nodes/CCNode.cpp +++ b/cocos2dx/base_nodes/CCNode.cpp @@ -62,40 +62,145 @@ CCNode::~CCNode() } + +/// zOrder getter +int CCNode::getZOrder() +{ + return m_iZOrder; +} + +/// ertexZ getter +float CCNode::getVertexZ() +{ + return m_fVertexZ; +} + + +/// vertexZ setter +void CCNode::setVertexZ(float var) +{ + m_fVertexZ = var; +} + + +/// rotation getter float CCNode::getRotation() { return m_fRotation; } +/// rotation setter +void CCNode::setRotation(float newRotation) +{ + m_fRotation = newRotation; + m_bIsTransformDirty = m_bIsInverseDirty = true; + #ifdef CCX_NODE_TRANSFORM_USING_AFFINE_MATRIX + m_bIsTransformGLDirty = true; + #endif +} + + +/// scale getter +float CCNode::getScale(void) +{ + ///@todo NSAssert( scaleX_ == scaleY_, @"CCNode#scale. ScaleX != ScaleY. Don't know which one to return"); + return m_fScale; +} + +/// scale setter +void CCNode::setScale(float scale) +{ + m_fScaleX = m_fScaleY = scale; + m_bIsTransformDirty = m_bIsInverseDirty = true; + #ifdef CCX_NODE_TRANSFORM_USING_AFFINE_MATRIX + m_bIsTransformGLDirty = true; + #endif +} + +/// scaleX getter +float CCNode::getScaleX() +{ + return m_fScaleX; +} + +/// scaleX setter +void CCNode::setScaleX(float newScaleX) +{ + m_fScaleX = newScaleX; + m_bIsTransformDirty = m_bIsInverseDirty = true; + #ifdef CCX_NODE_TRANSFORM_USING_AFFINE_MATRIX + m_bIsTransformGLDirty = true; + #endif +} + +/// scaleY getter +float CCNode::getScaleY() +{ + return m_fScaleY; +} + +/// scaleY setter +void CCNode::setScaleY(float newScaleY) +{ + m_fScaleY = newScaleY; + m_bIsTransformDirty = m_bIsInverseDirty = true; + #ifdef CCX_NODE_TRANSFORM_USING_AFFINE_MATRIX + m_bIsTransformGLDirty = true; + #endif +} + +/// position getter CGPoint CCNode::getPosition() { return m_tPosition; } -float CCNode::getScaleX() +/// position setter +void CCNode::setPosition(CGPoint newPosition) { - return m_fScaleX; + m_tPosition = newPosition; + m_bIsTransformDirty = m_bIsInverseDirty = true; + #ifdef CCX_NODE_TRANSFORM_USING_AFFINE_MATRIX + m_bIsTransformGLDirty = true; + #endif } -float CCNode::getScaleY() +/// children getter +NSMutableArray * CCNode::getChildren() { - return m_fScaleY; -} - -void CCNode::setVisibility(bool bIsVisible) -{ - m_bIsVisible = bIsVisible; + return m_pChildren; } -bool CCNode::getVisibility() +/// children getter +// camera: lazy alloc +CCCamera* getCamera() { - return m_bIsVisible; +/** @todo no declare in class +if( ! camera_ ) { +camera_ = [[CCCamera alloc] init]; + +// by default, center camera at the Sprite's anchor point +// [camera_ setCenterX:anchorPointInPixels_.x centerY:anchorPointInPixels_.y centerZ:0]; +// [camera_ setEyeX:anchorPointInPixels_.x eyeY:anchorPointInPixels_.y eyeZ:1]; + +// [camera_ setCenterX:0 centerY:0 centerZ:0]; +// [camera_ setEyeX:0 eyeY:0 eyeZ:1]; + } + +return camera_;*/ + return NULL; +} + + +/// grid getter /// @todo //CCGridBase* CCNode::getGrid() //{ // return m_pGrid; //} + +/// grid setter /// @todo //void CCNode::setGrid(CCGridBase* pGrid) //{ @@ -108,76 +213,53 @@ bool CCNode::getVisibility() // m_pGrid->retain(); //} - -// getters synthesized, setters explicit -void CCNode::setRotation(float newRotation) + +/// isVisible getter +bool CCNode::getIsVisible() { - m_fRotation = newRotation; - m_bIsTransformDirty = m_bIsInverseDirty = true; - #ifdef CCX_NODE_TRANSFORM_USING_AFFINE_MATRIX - m_bIsTransformGLDirty = true; - #endif + return m_bIsVisible; } -void CCNode::setScaleX(float newScaleX) +/// isVisible setter +void CCNode::setIsVisible(bool var) { - m_fScaleX = newScaleX; - m_bIsTransformDirty = m_bIsInverseDirty = true; - #ifdef CCX_NODE_TRANSFORM_USING_AFFINE_MATRIX - m_bIsTransformGLDirty = true; - #endif + m_bIsVisible = var; } -void CCNode::setScaleY(float newScaleY) -{ - m_fScaleY = newScaleY; - m_bIsTransformDirty = m_bIsInverseDirty = true; - #ifdef CCX_NODE_TRANSFORM_USING_AFFINE_MATRIX - m_bIsTransformGLDirty = true; - #endif -} -void CCNode::setPosition(CGPoint newPosition) +/// anchorPoint getter +CGPoint CCNode::getAnchorPoint() { - m_tPosition = newPosition; - m_bIsTransformDirty = m_bIsInverseDirty = true; - #ifdef CCX_NODE_TRANSFORM_USING_AFFINE_MATRIX - m_bIsTransformGLDirty = true; - #endif + return m_tAnchorPoint; } -void CCNode::setIsRelativeAnchorPoint(bool newValue) -{ - m_bIsRelativeAnchorPoint = newValue; - m_bIsTransformDirty = m_bIsInverseDirty = true; - #ifdef CCX_NODE_TRANSFORM_USING_AFFINE_MATRIX - m_bIsTransformGLDirty = true; - #endif -} - -bool CCNode::getIsRelativeAnchorPoint() -{ - return m_bIsRelativeAnchorPoint; -} -/// @todo +/// @todo anchorPoint setter void CCNode::setAnchorPoint(CGPoint point) { /*if( ! CGPointEqualToPoint(point, m_anchorPoint) ) { - m_anchorPoint = point; - this->m_anchorPointInPixels = ccp( m_contentSize.width * m_anchorPoint.x, m_contentSize.height * m_anchorPoint.y ); - m_isTransformDirty = m_isInverseDirty = true; - #ifdef CCX_NODE_TRANSFORM_USING_AFFINE_MATRIX - m_bIsTransformGLDirty = true; - #endif + m_anchorPoint = point; + this->m_anchorPointInPixels = ccp( m_contentSize.width * m_anchorPoint.x, m_contentSize.height * m_anchorPoint.y ); + m_isTransformDirty = m_isInverseDirty = true; + #ifdef CCX_NODE_TRANSFORM_USING_AFFINE_MATRIX + m_bIsTransformGLDirty = true; + #endif }*/ -} - -CGPoint CCNode::getAnchorPoint() -{ - return m_tAnchorPoint; } -/// @todo + +/// anchorPointInPixels getter +CGPoint CCNode::getAnchorPointInPixels() +{ + return m_tAnchorPointInPixels; +} + +/// contentSize getter +CGSize CCNode::getContentSize() +{ + return m_tContentSize; +} + +/// @todo contentSize setter void CCNode::setContentSize(CGSize size) { //if( ! CGSizeEqualToSize(size, m_contentSize) ) @@ -191,82 +273,76 @@ void CCNode::setContentSize(CGSize size) //} } -CGSize CCNode::getContentSize() + +/// isRunning getter +bool CCNode::getIsRunning() { - return m_tContentSize; + return m_bIsRunning; } + + +/// parent getter +CCNode * CCNode::getParent() +{ + return m_pParent; +} +/// parent setter +void CCNode::setParent(CCNode * var) +{ + m_pParent = var; +} + +/// isRelativeAnchorPoint getter +bool CCNode::getIsRelativeAnchorPoint() +{ + return m_bIsRelativeAnchorPoint; +} +/// isRelativeAnchorPoint setter +void CCNode::setIsRelativeAnchorPoint(bool newValue) +{ + m_bIsRelativeAnchorPoint = newValue; + m_bIsTransformDirty = m_bIsInverseDirty = true; + #ifdef CCX_NODE_TRANSFORM_USING_AFFINE_MATRIX + m_bIsTransformGLDirty = true; + #endif +} + +/// tag getter +int CCNode::getTag() +{ + return m_iTag; +} + +/// tag setter +void CCNode::setTag(int var) +{ + m_iTag = var; +} + +/// userData getter +void * CCNode::getUserData() +{ + return m_pUserData; +} + +/// userData setter +void CCNode::setUserData(void *var) +{ + m_pUserData = var; +} + + + + + /// @todo //CGRect CCNode::boundingBox() //{ // CGRect rect = CGRectMake(0, 0, m_contentSize.width, m_contentSize.height); // return CGRectApplyAffineTransform(rect, nodeToParentTransform()); //} -/// @todo -//float CCNode::scale() -//{ -// UXAssert( m_scaleX == m_scaleY, L"CocosNode#scale. ScaleX != ScaleY. Don't know which one to return"); -// return m_scaleX; -//} -void CCNode::setScale(float scale) -{ - m_fScaleX = m_fScaleY = scale; - m_bIsTransformDirty = m_bIsInverseDirty = true; - #ifdef CCX_NODE_TRANSFORM_USING_AFFINE_MATRIX - m_bIsTransformGLDirty = true; - #endif -} -/// @todo -//UxMutableArray* CCNode::children() -//{ -// return m_pChildrenArray; -//} - -void CCNode::setParent(CCNode* pParentNode) -{ - m_pParent = pParentNode; -} - -CCNode* CCNode::getParent() -{ - return m_pParent; -} - -int CCNode::getTag() -{ - return m_iTag; -} - -void CCNode::setTag(int tag) -{ - m_iTag = tag; -} - -int CCNode::getZOrder() -{ - return m_iZOrder; -} - -void CCNode::setVertexZ(float z) -{ - m_fVertexZ = z; -} - -float CCNode::getVertexZ() -{ - return m_fVertexZ; -} - -CGPoint CCNode::getAnchorPointInPixels() -{ - return m_tAnchorPointInPixels; -} - -bool CCNode::getIsRunning() -{ - return m_bIsRunning; -} /** @todo @@ -278,37 +354,13 @@ bool CCNode::getIsRunning() */ -/** @todo - -@synthesize children = children_; -@synthesize visible=visible_; -@synthesize parent=parent_; -@synthesize grid=grid_; -@synthesize zOrder=zOrder_; -@synthesize tag=tag_; -@synthesize vertexZ = vertexZ_; -@synthesize isRunning=isRunning_; - - -@synthesize rotation=rotation_, scaleX=scaleX_, scaleY=scaleY_, position=position_; -@synthesize anchorPointInPixels=anchorPointInPixels_, isRelativeAnchorPoint=isRelativeAnchorPoint_; -@synthesize userData; -*/ - - - - -float CCNode::getScale(void) -{ - ///@todo NSAssert( scaleX_ == scaleY_, @"CCNode#scale. ScaleX != ScaleY. Don't know which one to return"); - return m_fScale; -} - CCNode * CCNode::node(void) { /// @todo return [[[self alloc] init] autorelease]; - return NULL; + CCNode * pNode = new CCNode(); + pNode->autorelease(); + return pNode; } void CCNode::cleanup() @@ -356,25 +408,7 @@ void CCNode::childrenAlloc(void) { /// @todo children_ = [[CCArray alloc] initWithCapacity:4]; } -/** @todo no declare in class -// camera: lazy alloc -CCCamera* camera -{ - if( ! camera_ ) { - camera_ = [[CCCamera alloc] init]; - // by default, center camera at the Sprite's anchor point - // [camera_ setCenterX:anchorPointInPixels_.x centerY:anchorPointInPixels_.y centerZ:0]; - // [camera_ setEyeX:anchorPointInPixels_.x eyeY:anchorPointInPixels_.y eyeZ:1]; - - // [camera_ setCenterX:0 centerY:0 centerZ:0]; - // [camera_ setEyeX:0 eyeY:0 eyeZ:1]; - - } - - return camera_; -} -*/ CCNode* CCNode::getChildByTag(int aTag) { /** @todo @@ -804,7 +838,7 @@ void CCNode::pauseSchedulerAndActions() } /** @todo -- (CGAffineTransform)nodeToParentTransform +CGAffineTransform CCNode::nodeToParentTransform(void) { if ( isTransformDirty_ ) { @@ -827,8 +861,8 @@ void CCNode::pauseSchedulerAndActions() } return transform_; -} - +}*/ +/** @todo - (CGAffineTransform)parentToNodeTransform { if ( isInverseDirty_ ) { @@ -837,8 +871,8 @@ void CCNode::pauseSchedulerAndActions() } return inverse_; -} - +}*/ +/** @todo - (CGAffineTransform)nodeToWorldTransform { CGAffineTransform t = [self nodeToParentTransform]; @@ -847,50 +881,57 @@ void CCNode::pauseSchedulerAndActions() t = CGAffineTransformConcat(t, [p nodeToParentTransform]); return t; -} - +}*/ +/** @todo - (CGAffineTransform)worldToNodeTransform { return CGAffineTransformInvert([self nodeToWorldTransform]); +}*/ + +CGPoint CCNode::convertToNodeSpace(CGPoint worldPoint) +{ + /// @todo return CGPointApplyAffineTransform(worldPoint, [self worldToNodeTransform]); + return CGPoint(0,0); } -- (CGPoint)convertToNodeSpace:(CGPoint)worldPoint +CGPoint CCNode::convertToWorldSpace(CGPoint nodePoint) { - return CGPointApplyAffineTransform(worldPoint, [self worldToNodeTransform]); + /// @todo return CGPointApplyAffineTransform(nodePoint, [self nodeToWorldTransform]); + return CGPoint(0,0); } -- (CGPoint)convertToWorldSpace:(CGPoint)nodePoint -{ - return CGPointApplyAffineTransform(nodePoint, [self nodeToWorldTransform]); -} - -- (CGPoint)convertToNodeSpaceAR:(CGPoint)worldPoint +CGPoint CCNode::convertToNodeSpaceAR(CGPoint worldPoint) { + /** @todo CGPoint nodePoint = [self convertToNodeSpace:worldPoint]; - return ccpSub(nodePoint, anchorPointInPixels_); + return ccpSub(nodePoint, anchorPointInPixels_);*/ + return CGPoint(0,0); } -- (CGPoint)convertToWorldSpaceAR:(CGPoint)nodePoint +CGPoint CCNode::convertToWorldSpaceAR(CGPoint nodePoint) { + /** @todo nodePoint = ccpAdd(nodePoint, anchorPointInPixels_); - return [self convertToWorldSpace:nodePoint]; + return [self convertToWorldSpace:nodePoint];*/ + return CGPoint(0,0); } - -- (CGPoint)convertToWindowSpace:(CGPoint)nodePoint +/** @todo no declare in .h file +CGPoint CCNode::convertToWindowSpace(CGPoint nodePoint) { + CGPoint worldPoint = [self convertToWorldSpace:nodePoint]; return [[CCDirector sharedDirector] convertToUI:worldPoint]; -} +}*/ // convenience methods which take a UITouch instead of CGPoint - +/** @todo - (CGPoint)convertTouchToNodeSpace:(UITouch *)touch { CGPoint point = [touch locationInView: [touch view]]; point = [[CCDirector sharedDirector] convertToGL: point]; return [self convertToNodeSpace:point]; -} - +}*/ +/** @todo - (CGPoint)convertTouchToNodeSpaceAR:(UITouch *)touch { CGPoint point = [touch locationInView: [touch view]]; diff --git a/cocos2dx/include/CCLayer.h b/cocos2dx/include/CCLayer.h index 5b765a4b81..edcf7b8969 100644 --- a/cocos2dx/include/CCLayer.h +++ b/cocos2dx/include/CCLayer.h @@ -45,6 +45,10 @@ class CCLayer : public CCNode//, public UIAccelerometerDelegate, public CCStanda public: CCLayer(); virtual ~CCLayer(); + + virtual void onEnter(); + virtual void onExit(); + /** If isTouchEnabled, this method is called onEnter. Override it to change the way CCLayer receives touch events. ( Default: [[TouchDispatcher sharedDispatcher] addStandardDelegate:self priority:0] ) @@ -91,6 +95,9 @@ public: CCColorLayer(); virtual ~CCColorLayer(); + virtual void draw(); + virtual void setContentSize(CGSize var); + /** creates a CCLayer with color, width and height */ static CCColorLayer * layerWithColorWidthHeight(ccColor4B color, GLfloat width, GLfloat height); /** creates a CCLayer with color. Width and height are the window size. */ @@ -111,11 +118,14 @@ public: void changeWidthAndHeight(GLfloat w ,GLfloat h); /** Opacity: conforms to CCRGBAProtocol protocol */ - CCX_PROPERTY_READONLY(GLubyte, m_cOpacity, Opacity) + CCX_PROPERTY(GLubyte, m_cOpacity, Opacity) /** Opacity: conforms to CCRGBAProtocol protocol */ - CCX_PROPERTY_READONLY(ccColor3B, m_tColor, Color) + CCX_PROPERTY(ccColor3B, m_tColor, Color) /** BlendFunction. Conforms to CCBlendProtocol protocol */ CCX_PROPERTY(ccBlendFunc, m_tBlendFunc, BlendFunc) + +private : + void updateColor(); }; /** CCMultipleLayer is a CCLayer with the ability to multiplex it's children. @@ -127,7 +137,7 @@ class CCMultiplexLayer : public CCLayer { protected: unsigned int m_iEnabledLayer; - NSMutableArray * m_tLayers; + NSMutableArray * m_pLayers; public: CCMultiplexLayer(); diff --git a/cocos2dx/include/CCNode.h b/cocos2dx/include/CCNode.h index b25a9c639c..01f2677e40 100644 --- a/cocos2dx/include/CCNode.h +++ b/cocos2dx/include/CCNode.h @@ -92,8 +92,8 @@ Camera: - Each node has a camera. By default it points to the center of the CCNode. */ -class CCNode{ - +class CCNode : public NSObject +{ // variable property /** The z order of the node relative to it's "brothers": children of the same parent */ @@ -135,7 +135,7 @@ class CCNode{ CCX_PROPERTY(CCGridBase *, m_pGrid, Grid) /** Whether of not the node is visible. Default is true */ - CCX_PROPERTY(bool, m_bIsVisible, Visibility) + CCX_PROPERTY(bool, m_bIsVisible, IsVisible) /** anchorPoint is the point around which all transformations and positioning manipulations take place. It's like a pin in the node where it is "attached" to its parent. @@ -149,7 +149,7 @@ class CCNode{ /** The anchorPoint in absolute pixels. Since v0.8 you can only read it. If you wish to modify it, use anchorPoint instead */ - CCX_PROPERTY(CGPoint, m_tAnchorPointInPixels, AnchorPointInPixels) + CCX_PROPERTY_READONLY(CGPoint, m_tAnchorPointInPixels, AnchorPointInPixels) /** The untransformed size of the node. The contentSize remains the same no matter the node is scaled or rotated. @@ -221,7 +221,7 @@ public: If the CCNode enters the 'stage' with a transition, this callback is called when the transition starts. During onEnter you can't a "sister/brother" node. */ - void onEnter(); + virtual void onEnter(); /** callback that is called when the CCNode enters in the 'stage'. If the CCNode enters the 'stage' with a transition, this callback is called when the transition finishes. @since v0.8 @@ -231,7 +231,7 @@ public: If the CCNode leaves the 'stage' with a transition, this callback is called when the transition finishes. During onExit you can't a "sister/brother" node. */ - void onExit(); + virtual void onExit(); // composition: ADD @@ -291,8 +291,10 @@ public: /** Stops all running actions and schedulers @since v0.8 */ - void cleanup(void); + virtual void cleanup(void); + // @todo no declare in objc,but delcare in .m file + virtual void dealloc(void); // draw diff --git a/cocos2dx/include/CCScene.h b/cocos2dx/include/CCScene.h index 56f206ad47..7788f592fb 100644 --- a/cocos2dx/include/CCScene.h +++ b/cocos2dx/include/CCScene.h @@ -43,7 +43,6 @@ class CCScene : public CCNode public: CCScene(); virtual ~CCScene(); - }; #endif // __CCSCENE_H__ diff --git a/cocos2dx/include/CCTransition.h b/cocos2dx/include/CCTransition.h index 11e5041507..9833e5a6ba 100644 --- a/cocos2dx/include/CCTransition.h +++ b/cocos2dx/include/CCTransition.h @@ -38,6 +38,8 @@ class CCTransitionEaseScene : public NSObject @since v0.8.2 */ public: + CCTransitionEaseScene(); + virtual ~CCTransitionEaseScene(); virtual CCIntervalAction * easeActionWithAction(CCIntervalAction * action); }; @@ -60,13 +62,22 @@ class CCTransitionScene : public CCScene { protected: - CCScene * m_tInScene; - CCScene * m_tOutScene; + CCScene * m_pInScene; + CCScene * m_pOutScene; ccTime m_fDuration; - BOOL m_bIsInSceneOnTop; - BOOL m_bIsSendCleanupToScene; + bool m_bIsInSceneOnTop; + bool m_bIsSendCleanupToScene; public: + + CCTransitionScene(); + virtual ~CCTransitionScene(); + virtual void draw(); + virtual void onEnter(); + virtual void onExit(); + virtual void cleanup(); + virtual void dealloc(); + /** creates a base transition with duration and incoming scene */ static CCTransitionScene * transitionWithDurationAndScene(ccTime t, CCScene *scene); @@ -78,6 +89,11 @@ public: /** used by some transitions to hide the outter scene */ void hideOutShowIn(void); + +private: + void sceneOrder(); + void setNewScene(ccTime dt); + }; /** A CCTransition that supports orientation like. @@ -89,8 +105,11 @@ protected: tOrientation m_tOrientation; public: + CCOrientedTransitionScene(); + ~CCOrientedTransitionScene(); + /** creates a base transition with duration and incoming scene */ - virtual CCOrientedTransitionScene * transitionWithDurationAndScene(ccTime t,CCScene* scene, tOrientation orientation); + static CCOrientedTransitionScene * transitionWithDurationAndScene(ccTime t,CCScene* scene, tOrientation orientation); /** initializes a transition with duration and incoming scene */ virtual CCOrientedTransitionScene * initWithDurationAndScene(ccTime t,CCScene* scene,tOrientation orientation); }; @@ -103,6 +122,7 @@ class CCRotoZoomTransition : public CCTransitionScene public: CCRotoZoomTransition(); virtual ~CCRotoZoomTransition(); + virtual void onEnter(); }; /** CCJumpZoomTransition: @@ -113,6 +133,7 @@ class CCJumpZoomTransition : public CCTransitionScene public: CCJumpZoomTransition(); virtual ~CCJumpZoomTransition(); + virtual void onEnter(); }; /** CCMoveInLTransition: @@ -126,7 +147,11 @@ public: /** initializes the scenes */ virtual void initScenes(void); /** returns the action that will be performed */ - virtual CCIntervalAction* action(void); + CCIntervalAction* action(void); + + virtual CCIntervalAction* easeActionWithAction(CCIntervalAction * action); + + virtual void onEnter(); }; /** CCMoveInRTransition: @@ -137,6 +162,7 @@ class CCMoveInRTransition : public CCMoveInLTransition public: CCMoveInRTransition(); virtual ~CCMoveInRTransition(); + virtual void initScenes(); }; /** CCMoveInTTransition: @@ -147,6 +173,7 @@ class CCMoveInTTransition : public CCMoveInLTransition public: CCMoveInTTransition(); virtual ~CCMoveInTTransition(); + virtual void initScenes(); }; /** CCMoveInBTransition: @@ -157,6 +184,7 @@ class CCMoveInBTransition : public CCMoveInLTransition public: CCMoveInBTransition(); virtual ~CCMoveInBTransition(); + virtual void initScenes(); }; /** CCSlideInLTransition: @@ -172,6 +200,10 @@ public: virtual void initScenes(void); /** returns the action that will be performed by the incomming and outgoing scene */ virtual CCIntervalAction* action(void); + + virtual void onEnter(); + virtual void sceneOrder(); + virtual CCIntervalAction* easeActionWithAction(CCIntervalAction * action); }; /** CCSlideInRTransition: @@ -182,6 +214,13 @@ class CCSlideInRTransition : public CCSlideInLTransition public: CCSlideInRTransition(); virtual ~CCSlideInRTransition(); + + /** initializes the scenes */ + virtual void initScenes(void); + /** returns the action that will be performed by the incomming and outgoing scene */ + virtual CCIntervalAction* action(void); + + virtual void sceneOrder(); }; /** CCSlideInBTransition: @@ -192,6 +231,13 @@ class CCSlideInBTransition : public CCSlideInLTransition public: CCSlideInBTransition(); virtual ~CCSlideInBTransition(); + + /** initializes the scenes */ + virtual void initScenes(void); + /** returns the action that will be performed by the incomming and outgoing scene */ + virtual CCIntervalAction* action(void); + + virtual void sceneOrder(); }; /** CCSlideInTTransition: @@ -202,6 +248,13 @@ class CCSlideInTTransition : public CCSlideInLTransition public: CCSlideInTTransition(); virtual ~CCSlideInTTransition(); + + /** initializes the scenes */ + virtual void initScenes(void); + /** returns the action that will be performed by the incomming and outgoing scene */ + virtual CCIntervalAction* action(void); + + virtual void sceneOrder(); }; /** @@ -212,6 +265,9 @@ class CCShrinkGrowTransition : public CCTransitionScene , public CCTransitionEas public: CCShrinkGrowTransition(); virtual ~CCShrinkGrowTransition(); + + virtual void onEnter(); + virtual CCIntervalAction* easeActionWithAction(CCIntervalAction * action); }; /** CCFlipXTransition: @@ -223,6 +279,8 @@ class CCFlipXTransition : public CCOrientedTransitionScene public: CCFlipXTransition(); virtual ~CCFlipXTransition(); + + virtual void onEnter(); }; /** CCFlipYTransition: @@ -234,6 +292,8 @@ class CCFlipYTransition : public CCOrientedTransitionScene public: CCFlipYTransition(); virtual ~CCFlipYTransition(); + + virtual void onEnter(); }; /** CCFlipAngularTransition: @@ -245,6 +305,8 @@ class CCFlipAngularTransition : public CCOrientedTransitionScene public: CCFlipAngularTransition(); virtual ~CCFlipAngularTransition(); + + virtual void onEnter(); }; /** CCZoomFlipXTransition: @@ -256,6 +318,8 @@ class CCZoomFlipXTransition : public CCOrientedTransitionScene public: CCZoomFlipXTransition(); virtual ~CCZoomFlipXTransition(); + + virtual void onEnter(); }; /** CCZoomFlipYTransition: @@ -267,6 +331,8 @@ class CCZoomFlipYTransition : public CCOrientedTransitionScene public: CCZoomFlipYTransition(); virtual ~CCZoomFlipYTransition(); + + virtual void onEnter(); }; /** CCZoomFlipAngularTransition: @@ -278,6 +344,8 @@ class CCZoomFlipAngularTransition : public CCOrientedTransitionScene public: CCZoomFlipAngularTransition(); virtual ~CCZoomFlipAngularTransition(); + + virtual void onEnter(); }; /** CCFadeTransition: @@ -299,6 +367,10 @@ public: static CCFadeTransition* transitionWithDurationAndColor(ccTime duration,CCScene* scene, ccColor3B color); /** initializes the transition with a duration and with an RGB color */ CCFadeTransition* initWithDurationAndColor(ccTime duration, CCScene*scene ,ccColor3B color); + + virtual CCFadeTransition * initWithDurationAndScene(ccTime t,CCScene* scene); + virtual void onEnter(); + virtual void onExit(); }; /** @@ -311,6 +383,10 @@ class CCCrossFadeTransition : public CCTransitionScene public : CCCrossFadeTransition(); virtual ~CCCrossFadeTransition(); + + virtual void draw(); + virtual void onEnter(); + virtual void onExit(); }; /** CCTurnOffTilesTransition: @@ -321,6 +397,10 @@ class CCTurnOffTilesTransition : public CCTransitionScene ,public CCTransitionEa public : CCTurnOffTilesTransition(); virtual ~CCTurnOffTilesTransition(); + + virtual void sceneOrder(); + virtual void onEnter(); + CCIntervalAction * easeActionWithAction(CCIntervalAction * action); }; /** CCSplitColsTransition: @@ -333,6 +413,8 @@ public: virtual ~CCSplitColsTransition(); virtual CCIntervalAction* action(void); + virtual void onEnter(); + virtual CCIntervalAction * easeActionWithAction(CCIntervalAction * action); }; /** CCSplitRowsTransition: @@ -343,6 +425,8 @@ class CCSplitRowsTransition : public CCSplitColsTransition public: CCSplitRowsTransition(); virtual ~CCSplitRowsTransition(); + + virtual CCIntervalAction* action(void); }; /** CCFadeTRTransition: @@ -354,6 +438,10 @@ public: CCFadeTRTransition(); virtual ~CCFadeTRTransition(); virtual CCIntervalAction* actionWithSize(ccGridSize size); + + virtual void sceneOrder(); + virtual void onEnter(); + virtual CCIntervalAction* easeActionWithAction(CCIntervalAction * action); }; /** CCFadeBLTransition: @@ -364,6 +452,7 @@ class CCFadeBLTransition : public CCFadeTRTransition public: CCFadeBLTransition(); virtual ~CCFadeBLTransition(); + virtual CCIntervalAction* actionWithSize(ccGridSize size); }; /** CCFadeUpTransition: @@ -374,6 +463,7 @@ class CCFadeUpTransition : public CCFadeTRTransition public: CCFadeUpTransition(); virtual ~CCFadeUpTransition(); + virtual CCIntervalAction* actionWithSize(ccGridSize size); }; /** CCFadeDownTransition: @@ -384,6 +474,7 @@ class CCFadeDownTransition : public CCFadeTRTransition public: CCFadeDownTransition(); virtual ~CCFadeDownTransition(); + virtual CCIntervalAction* actionWithSize(ccGridSize size); }; #endif // __CCTRANSITION_H__ diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp index ecd6b6dc1e..7fa9457877 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp @@ -24,4 +24,354 @@ THE SOFTWARE. #include "CCLayer.h" -using namespace std; \ No newline at end of file +using namespace std; + +// CCLayer +CCLayer::CCLayer() +{ + /// @todo +} + +CCLayer::~CCLayer() +{ + /// @todo +} + + +/// Touch and Accelerometer related + +void CCLayer::registerWithTouchDispatcher() +{ + /// @todo [[CCTouchDispatcher sharedDispatcher] addStandardDelegate:self priority:0]; +} + + +/// isTouchEnabled getter +bool CCLayer::getIsTouchEnabled() +{ + return m_bIsTouchEnabled; +} +/// isTouchEnabled setter +void CCLayer::setIsTouchEnabled(bool enabled) +{ + /** @todo + if( isTouchEnabled != enabled ) { + isTouchEnabled = enabled; + if( isRunning_ ) { + if( enabled ) + [self registerWithTouchDispatcher]; + else + [[CCTouchDispatcher sharedDispatcher] removeDelegate:self]; + } + }*/ +} + +/// isAccelerometerEnabled getter +bool CCLayer::getIsAccelerometerEnabled() +{ + return m_bIsAccelerometerEnabled; +} +/// isAccelerometerEnabled setter +void CCLayer::setIsAccelerometerEnabled(bool enabled) +{ + /** @todo + if( enabled != isAccelerometerEnabled ) { + isAccelerometerEnabled = enabled; + if( isRunning_ ) { + if( enabled ) + [[UIAccelerometer sharedAccelerometer] setDelegate:self]; + else + [[UIAccelerometer sharedAccelerometer] setDelegate:nil]; + } + }*/ +} + + +/// Callbacks +void CCLayer::onEnter() +{ + /** @todo + // register 'parent' nodes first + // since events are propagated in reverse order + if (isTouchEnabled) + [self registerWithTouchDispatcher]; + + // then iterate over all the children + [super onEnter]; + + if( isAccelerometerEnabled ) + [[UIAccelerometer sharedAccelerometer] setDelegate:self];*/ +} + +void CCLayer::onExit() +{ + /** + if( isTouchEnabled ) + [[CCTouchDispatcher sharedDispatcher] removeDelegate:self]; + + if( isAccelerometerEnabled ) + [[UIAccelerometer sharedAccelerometer] setDelegate:nil]; + + [super onExit];*/ +} + +/** @todo +-(BOOL) ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event +{ + NSAssert(NO, @"Layer#ccTouchBegan override me"); + return YES; +}*/ + +/// ColorLayer + + +CCColorLayer::CCColorLayer() +{ +/// @todo +} +CCColorLayer::~CCColorLayer() +{ +/// @todo +} + +// Opacity and RGB color protocol +/// opacity getter +GLubyte CCColorLayer::getOpacity() +{ + return m_cOpacity; +} +/// opacity setter +void CCColorLayer::setOpacity(GLubyte var) +{ + m_cOpacity = var; + updateColor(); +} + +/// color getter +ccColor3B CCColorLayer::getColor() +{ + return m_tColor; +} + +/// color setter +void CCColorLayer::setColor(ccColor3B var) +{ + m_tColor = var; + updateColor(); +} + + +/// blendFunc getter +ccBlendFunc CCColorLayer::getBlendFunc() +{ + return m_tBlendFunc; +} +/// blendFunc setter +void CCColorLayer::setBlendFunc(ccBlendFunc var) +{ + m_tBlendFunc = var; +} + + +CCColorLayer * CCColorLayer::layerWithColorWidthHeight(ccColor4B color, GLfloat width, GLfloat height) +{ + /// @todo return [[[self alloc] initWithColor:color width:w height:h] autorelease]; + CCColorLayer * pLayer = new CCColorLayer(); + pLayer->initWithColorWidthHeight(color,width,height); + pLayer->autorelease(); + return pLayer; +} +CCColorLayer * CCColorLayer::layerWithColor(ccColor4B color) +{ + /// @todo return [[[self alloc] initWithColor:color] autorelease]; + CCColorLayer * pLayer = new CCColorLayer(); + pLayer->initWithColor(color); + pLayer->autorelease(); + return pLayer; +} + +CCColorLayer* CCColorLayer::initWithColorWidthHeight(ccColor4B color, GLfloat width, GLfloat height) +{ + /** @todo + if( (self=[super init]) ) { + + // default blend function + blendFunc_ = (ccBlendFunc) { CC_BLEND_SRC, CC_BLEND_DST }; + + color_.r = color.r; + color_.g = color.g; + color_.b = color.b; + opacity_ = color.a; + + for (NSUInteger i=0; iinitWithDurationAndScene(t,scene); + pScene->autorelease(); + return pScene; +} + +CCTransitionScene * CCTransitionScene::initWithDurationAndScene(ccTime t, CCScene *scene) +{ + /** @todo + NSAssert( s != nil, @"Argument scene must be non-nil"); + + if( (self=[super init]) ) { + + duration = t; + + // retain + inScene = [s retain]; + outScene = [[CCDirector sharedDirector] runningScene]; + [outScene retain]; + + NSAssert( inScene != outScene, @"Incoming scene must be different from the outgoing scene" ); + + // disable events while transitions + [[CCTouchDispatcher sharedDispatcher] setDispatchEvents: NO]; + + [self sceneOrder]; + } + return self;*/ + return NULL; +} + +void CCTransitionScene::sceneOrder() +{ + m_bIsInSceneOnTop = true; +} + +void CCTransitionScene::draw() +{ + /** @todo + if( inSceneOnTop ) { + [outScene visit]; + [inScene visit]; + } else { + [inScene visit]; + [outScene visit]; + }*/ +} + +void CCTransitionScene::finish() +{ + /** @todo + /* clean up + [inScene setVisible:YES]; + [inScene setPosition:ccp(0,0)]; + [inScene setScale:1.0f]; + [inScene setRotation:0.0f]; + [inScene.camera restore]; + + [outScene setVisible:NO]; + [outScene setPosition:ccp(0,0)]; + [outScene setScale:1.0f]; + [outScene setRotation:0.0f]; + [outScene.camera restore]; + + [self schedule:@selector(setNewScene:) interval:0];*/ +} + +void CCTransitionScene::setNewScene(ccTime dt) +{ + /** @todo + [self unschedule:_cmd]; + + CCDirector *director = [CCDirector sharedDirector]; + + // Before replacing, save the "send cleanup to scene" + sendCleanupToScene = [director sendCleanupToScene]; + + [director replaceScene: inScene]; + + // enable events while transitions + [[CCTouchDispatcher sharedDispatcher] setDispatchEvents: YES]; + + // issue #267 + [outScene setVisible:YES]; */ +} + +void CCTransitionScene::hideOutShowIn() +{ + m_pInScene->setIsVisible(true); + m_pOutScene->setIsVisible(false); +} + + +// custom onEnter +void CCTransitionScene::onEnter() +{ + /** @todo + [super onEnter]; + [inScene onEnter];*/ + // outScene should not receive the onEnter callback +} + +// custom onExit +void CCTransitionScene::onExit() +{ + /** @todo + [super onExit]; + [outScene onExit]; + + // inScene should not receive the onExit callback + // only the onEnterTransitionDidFinish + [inScene onEnterTransitionDidFinish];*/ +} + +// custom cleanup +void CCTransitionScene::cleanup() +{ + /** @todo + [super cleanup]; + + if( sendCleanupToScene ) + [outScene cleanup];*/ +} + +void CCTransitionScene::dealloc() +{ + /** @todo + [inScene release]; + [outScene release]; + [super dealloc];*/ +} + +// +// Oriented Transition +// +CCOrientedTransitionScene::CCOrientedTransitionScene() +{ +/// @todo +} +CCOrientedTransitionScene::~CCOrientedTransitionScene() +{ +/// @todo +} + +CCOrientedTransitionScene * CCOrientedTransitionScene::transitionWithDurationAndScene(ccTime t, CCScene *scene, tOrientation orientation) +{ +/// @todo return [[[self alloc] initWithDuration:t scene:s orientation:o] autorelease]; + CCOrientedTransitionScene * pScene = new CCOrientedTransitionScene(); + pScene->initWithDurationAndScene(t,scene,orientation); + pScene->autorelease(); + return pScene; +} + +CCOrientedTransitionScene * CCOrientedTransitionScene::initWithDurationAndScene(ccTime t, CCScene *scene, tOrientation orientation) +{ + /** @todo + if( (self=[super initWithDuration:t scene:s]) ) + orientation = o; + return self;*/ + return NULL; +} + +// +// RotoZoom +// +CCRotoZoomTransition::CCRotoZoomTransition() +{ + /// @todo +} +CCRotoZoomTransition::~CCRotoZoomTransition() +{ + /// @todo +} + +void CCRotoZoomTransition:: onEnter() +{ + /** @todo + [super onEnter]; + + [inScene setScale:0.001f]; + [outScene setScale:1.0f]; + + [inScene setAnchorPoint:ccp(0.5f, 0.5f)]; + [outScene setAnchorPoint:ccp(0.5f, 0.5f)]; + + CCIntervalAction *rotozoom = [CCSequence actions: [CCSpawn actions: + [CCScaleBy actionWithDuration:duration/2 scale:0.001f], + [CCRotateBy actionWithDuration:duration/2 angle:360 *2], + nil], + [CCDelayTime actionWithDuration:duration/2], + nil]; + + + [outScene runAction: rotozoom]; + [inScene runAction: [CCSequence actions: + [rotozoom reverse], + [CCCallFunc actionWithTarget:self selector:@selector(finish)], + nil]];*/ +} + + +// +// JumpZoom +// +CCJumpZoomTransition::CCJumpZoomTransition() +{ + /// @todo +} +CCJumpZoomTransition::~CCJumpZoomTransition() +{ + /// @todo +} + +void CCJumpZoomTransition::onEnter() +{ + /** @todo + [super onEnter]; + CGSize s = [[CCDirector sharedDirector] winSize]; + + [inScene setScale:0.5f]; + [inScene setPosition:ccp( s.width,0 )]; + + [inScene setAnchorPoint:ccp(0.5f, 0.5f)]; + [outScene setAnchorPoint:ccp(0.5f, 0.5f)]; + + CCIntervalAction *jump = [CCJumpBy actionWithDuration:duration/4 position:ccp(-s.width,0) height:s.width/4 jumps:2]; + CCIntervalAction *scaleIn = [CCScaleTo actionWithDuration:duration/4 scale:1.0f]; + CCIntervalAction *scaleOut = [CCScaleTo actionWithDuration:duration/4 scale:0.5f]; + + CCIntervalAction *jumpZoomOut = [CCSequence actions: scaleOut, jump, nil]; + CCIntervalAction *jumpZoomIn = [CCSequence actions: jump, scaleIn, nil]; + + CCIntervalAction *delay = [CCDelayTime actionWithDuration:duration/2]; + + [outScene runAction: jumpZoomOut]; + [inScene runAction: [CCSequence actions: delay, + jumpZoomIn, + [CCCallFunc actionWithTarget:self selector:@selector(finish)], + nil] ];*/ +} + + +// +// MoveInL +// +CCMoveInLTransition::CCMoveInLTransition() +{ + /// @todo +} +CCMoveInLTransition::~CCMoveInLTransition() +{ + /// @todo +} + +void CCMoveInLTransition::onEnter() +{ + /** @todo + [super onEnter]; + + [self initScenes]; + + CCIntervalAction *a = [self action]; + + [inScene runAction: [CCSequence actions: + [self easeActionWithAction:a], + [CCCallFunc actionWithTarget:self selector:@selector(finish)], + nil] + ];*/ + +} + +CCIntervalAction* CCMoveInLTransition::action() +{ + return NULL; + /// @todo return [CCMoveTo actionWithDuration:duration position:ccp(0,0)]; +} + +CCIntervalAction* CCMoveInLTransition::easeActionWithAction(CCIntervalAction* action) +{ + return NULL; + /// @todo return [CCEaseOut actionWithAction:action rate:2.0f]; + // return [EaseElasticOut actionWithAction:action period:0.4f]; +} + +void CCMoveInLTransition::initScenes() +{ + /** @todo + CGSize s = [[CCDirector sharedDirector] winSize]; + [inScene setPosition: ccp( -s.width,0) ];*/ +} + + + +// +// MoveInR +// +CCMoveInRTransition::CCMoveInRTransition() +{ + /// @todo +} +CCMoveInRTransition::~CCMoveInRTransition() +{ + /// @todo +} + +void CCMoveInRTransition::initScenes() +{ + /** @todo + CGSize s = [[CCDirector sharedDirector] winSize]; + [inScene setPosition: ccp( s.width,0) ];*/ +} + +// +// MoveInT +// +CCMoveInTTransition::CCMoveInTTransition() +{ + /// @todo +} +CCMoveInTTransition::~CCMoveInTTransition() +{ + /// @todo +} + +void CCMoveInTTransition::initScenes() +{ + /** @todo + CGSize s = [[CCDirector sharedDirector] winSize]; + [inScene setPosition: ccp( 0, s.height) ];*/ +} + + +// +// MoveInB +// +CCMoveInBTransition::CCMoveInBTransition() +{ + /// @todo +} +CCMoveInBTransition::~CCMoveInBTransition() +{ + /// @todo +} + +void CCMoveInBTransition::initScenes() +{ + /** @todo + CGSize s = [[CCDirector sharedDirector] winSize]; + [inScene setPosition: ccp( 0, -s.height) ];*/ +} + + +// +// SlideInL +// + +// The adjust factor is needed to prevent issue #442 +// One solution is to use DONT_RENDER_IN_SUBPIXELS images, but NO +// The other issue is that in some transitions (and I don't know why) +// the order should be reversed (In in top of Out or vice-versa). +#define ADJUST_FACTOR 0.5f +CCSlideInLTransition::CCSlideInLTransition() +{ + /// @todo +} +CCSlideInLTransition::~CCSlideInLTransition() +{ + /// @todo +} + +void CCSlideInLTransition::onEnter() +{ + /** @todo + [super onEnter]; + + [self initScenes]; + + CCIntervalAction *in = [self action]; + CCIntervalAction *out = [self action]; + + id inAction = [self easeActionWithAction:in]; + id outAction = [CCSequence actions: + [self easeActionWithAction:out], + [CCCallFunc actionWithTarget:self selector:@selector(finish)], + nil]; + + [inScene runAction: inAction]; + [outScene runAction: outAction];*/ +} + +void CCSlideInLTransition::sceneOrder() +{ + m_bIsInSceneOnTop = false; +} + +void CCSlideInLTransition:: initScenes() +{ + /** @todo + CGSize s = [[CCDirector sharedDirector] winSize]; + [inScene setPosition: ccp( -(s.width-ADJUST_FACTOR),0) ];*/ +} + +CCIntervalAction* CCSlideInLTransition::action() +{ + /** @todo + CGSize s = [[CCDirector sharedDirector] winSize]; + return [CCMoveBy actionWithDuration:duration position:ccp(s.width-ADJUST_FACTOR,0)];*/ + return NULL; +} + +CCIntervalAction* CCSlideInLTransition::easeActionWithAction(CCIntervalAction* action) +{ + /** @todo + return [CCEaseOut actionWithAction:action rate:2.0f];*/ + return NULL; + // return [EaseElasticOut actionWithAction:action period:0.4f]; +} + + +// +// SlideInR +// +CCSlideInRTransition::CCSlideInRTransition() +{ + /// @todo +} +CCSlideInRTransition::~CCSlideInRTransition() +{ + /// @todo +} + +void CCSlideInRTransition::sceneOrder() +{ + m_bIsInSceneOnTop = true; +} + +void CCSlideInRTransition::initScenes() +{ + /** @todo + CGSize s = [[CCDirector sharedDirector] winSize]; + [inScene setPosition: ccp( s.width-ADJUST_FACTOR,0) ];*/ +} + + +CCIntervalAction* CCSlideInRTransition:: action() +{ + /** @todo + CGSize s = [[CCDirector sharedDirector] winSize]; + return [CCMoveBy actionWithDuration:duration position:ccp(-(s.width-ADJUST_FACTOR),0)];*/ + return NULL; +} + + +// +// SlideInT +// +CCSlideInTTransition::CCSlideInTTransition() +{ + /// @todo +} +CCSlideInTTransition::~CCSlideInTTransition() +{ + /// @todo +} + +void CCSlideInTTransition::sceneOrder() +{ + m_bIsInSceneOnTop = false; +} + +void CCSlideInTTransition::initScenes() +{ + /** @todo + CGSize s = [[CCDirector sharedDirector] winSize]; + [inScene setPosition: ccp(0,s.height-ADJUST_FACTOR) ];*/ +} + + +CCIntervalAction* CCSlideInTTransition::action() +{ + /** @todo + CGSize s = [[CCDirector sharedDirector] winSize]; + return [CCMoveBy actionWithDuration:duration position:ccp(0,-(s.height-ADJUST_FACTOR))];*/ + return NULL; +} + + +// +// SlideInB +// +CCSlideInBTransition::CCSlideInBTransition() +{ + /// @todo +} +CCSlideInBTransition::~CCSlideInBTransition() +{ + /// @todo +} + +void CCSlideInBTransition::sceneOrder() +{ + m_bIsInSceneOnTop = true; +} + +void CCSlideInBTransition:: initScenes() +{ + /** @todo + CGSize s = [[CCDirector sharedDirector] winSize]; + [inScene setPosition: ccp(0,-(s.height-ADJUST_FACTOR)) ];*/ +} + + +CCIntervalAction* CCSlideInBTransition:: action() +{ + /** @todo + CGSize s = [[CCDirector sharedDirector] winSize]; + return [CCMoveBy actionWithDuration:duration position:ccp(0,s.height-ADJUST_FACTOR)];*/ + return NULL; +} + + + +// +// ShrinkGrow Transition +// +CCShrinkGrowTransition::CCShrinkGrowTransition() +{ + /// @todo +} +CCShrinkGrowTransition::~CCShrinkGrowTransition() +{ + /// @todo +} + +void CCShrinkGrowTransition::onEnter() +{ + /** @todo + [super onEnter]; + + [inScene setScale:0.001f]; + [outScene setScale:1.0f]; + + [inScene setAnchorPoint:ccp(2/3.0f,0.5f)]; + [outScene setAnchorPoint:ccp(1/3.0f,0.5f)]; + + CCIntervalAction *scaleOut = [CCScaleTo actionWithDuration:duration scale:0.01f]; + CCIntervalAction *scaleIn = [CCScaleTo actionWithDuration:duration scale:1.0f]; + + [inScene runAction: [self easeActionWithAction:scaleIn]]; + [outScene runAction: [CCSequence actions: + [self easeActionWithAction:scaleOut], + [CCCallFunc actionWithTarget:self selector:@selector(finish)], + nil] ];*/ +} +CCIntervalAction* CCShrinkGrowTransition:: easeActionWithAction(CCIntervalAction* action) +{ + return NULL; + /// @todo return [CCEaseOut actionWithAction:action rate:2.0f]; + // return [EaseElasticOut actionWithAction:action period:0.3f]; +} + + + +// +// FlipX Transition +// +CCFlipXTransition::CCFlipXTransition() +{ + /// @todo +} +CCFlipXTransition::~CCFlipXTransition() +{ + /// @todo +} + +void CCFlipXTransition::onEnter() +{ + /** @todo + [super onEnter]; + + CCIntervalAction *inA, *outA; + [inScene setVisible: NO]; + + float inDeltaZ, inAngleZ; + float outDeltaZ, outAngleZ; + + if( orientation == kOrientationRightOver ) { + inDeltaZ = 90; + inAngleZ = 270; + outDeltaZ = 90; + outAngleZ = 0; + } else { + inDeltaZ = -90; + inAngleZ = 90; + outDeltaZ = -90; + outAngleZ = 0; + } + + inA = [CCSequence actions: + [CCDelayTime actionWithDuration:duration/2], + [CCShow action], + [CCOrbitCamera actionWithDuration: duration/2 radius: 1 deltaRadius:0 angleZ:inAngleZ deltaAngleZ:inDeltaZ angleX:0 deltaAngleX:0], + [CCCallFunc actionWithTarget:self selector:@selector(finish)], + nil ]; + outA = [CCSequence actions: + [CCOrbitCamera actionWithDuration: duration/2 radius: 1 deltaRadius:0 angleZ:outAngleZ deltaAngleZ:outDeltaZ angleX:0 deltaAngleX:0], + [CCHide action], + [CCDelayTime actionWithDuration:duration/2], + nil ]; + + [inScene runAction: inA]; + [outScene runAction: outA]; +*/ +} + + +// +// FlipY Transition +// +CCFlipYTransition::CCFlipYTransition() +{ + /// @todo +} +CCFlipYTransition::~CCFlipYTransition() +{ + /// @todo +} + +void CCFlipYTransition::onEnter() +{ + /** @todo + [super onEnter]; + + CCIntervalAction *inA, *outA; + [inScene setVisible: NO]; + + float inDeltaZ, inAngleZ; + float outDeltaZ, outAngleZ; + + if( orientation == kOrientationUpOver ) { + inDeltaZ = 90; + inAngleZ = 270; + outDeltaZ = 90; + outAngleZ = 0; + } else { + inDeltaZ = -90; + inAngleZ = 90; + outDeltaZ = -90; + outAngleZ = 0; + } + inA = [CCSequence actions: + [CCDelayTime actionWithDuration:duration/2], + [CCShow action], + [CCOrbitCamera actionWithDuration: duration/2 radius: 1 deltaRadius:0 angleZ:inAngleZ deltaAngleZ:inDeltaZ angleX:90 deltaAngleX:0], + [CCCallFunc actionWithTarget:self selector:@selector(finish)], + nil ]; + outA = [CCSequence actions: + [CCOrbitCamera actionWithDuration: duration/2 radius: 1 deltaRadius:0 angleZ:outAngleZ deltaAngleZ:outDeltaZ angleX:90 deltaAngleX:0], + [CCHide action], + [CCDelayTime actionWithDuration:duration/2], + nil ]; + + [inScene runAction: inA]; + [outScene runAction: outA]; +*/ +} + + + +// +// FlipAngular Transition +// +CCFlipAngularTransition::CCFlipAngularTransition() +{ + /// @todo +} +CCFlipAngularTransition::~CCFlipAngularTransition() +{ + /// @todo +} + +void CCFlipAngularTransition::onEnter() +{ + /** @todo + [super onEnter]; + + CCIntervalAction *inA, *outA; + [inScene setVisible: NO]; + + float inDeltaZ, inAngleZ; + float outDeltaZ, outAngleZ; + + if( orientation == kOrientationRightOver ) { + inDeltaZ = 90; + inAngleZ = 270; + outDeltaZ = 90; + outAngleZ = 0; + } else { + inDeltaZ = -90; + inAngleZ = 90; + outDeltaZ = -90; + outAngleZ = 0; + } + inA = [CCSequence actions: + [CCDelayTime actionWithDuration:duration/2], + [CCShow action], + [CCOrbitCamera actionWithDuration: duration/2 radius: 1 deltaRadius:0 angleZ:inAngleZ deltaAngleZ:inDeltaZ angleX:-45 deltaAngleX:0], + [CCCallFunc actionWithTarget:self selector:@selector(finish)], + nil ]; + outA = [CCSequence actions: + [CCOrbitCamera actionWithDuration: duration/2 radius: 1 deltaRadius:0 angleZ:outAngleZ deltaAngleZ:outDeltaZ angleX:45 deltaAngleX:0], + [CCHide action], + [CCDelayTime actionWithDuration:duration/2], + nil ]; + + [inScene runAction: inA]; + [outScene runAction: outA];*/ +} + + +// +// ZoomFlipX Transition +// +CCZoomFlipXTransition::CCZoomFlipXTransition() +{ + /// @todo +} +CCZoomFlipXTransition::~CCZoomFlipXTransition() +{ + /// @todo +} + +void CCZoomFlipXTransition::onEnter() +{ + /** @todo + [super onEnter]; + + CCIntervalAction *inA, *outA; + [inScene setVisible: NO]; + + float inDeltaZ, inAngleZ; + float outDeltaZ, outAngleZ; + + if( orientation == kOrientationRightOver ) { + inDeltaZ = 90; + inAngleZ = 270; + outDeltaZ = 90; + outAngleZ = 0; + } else { + inDeltaZ = -90; + inAngleZ = 90; + outDeltaZ = -90; + outAngleZ = 0; + } + inA = [CCSequence actions: + [CCDelayTime actionWithDuration:duration/2], + [CCSpawn actions: + [CCOrbitCamera actionWithDuration: duration/2 radius: 1 deltaRadius:0 angleZ:inAngleZ deltaAngleZ:inDeltaZ angleX:0 deltaAngleX:0], + [CCScaleTo actionWithDuration:duration/2 scale:1], + [CCShow action], + nil], + [CCCallFunc actionWithTarget:self selector:@selector(finish)], + nil ]; + outA = [CCSequence actions: + [CCSpawn actions: + [CCOrbitCamera actionWithDuration: duration/2 radius: 1 deltaRadius:0 angleZ:outAngleZ deltaAngleZ:outDeltaZ angleX:0 deltaAngleX:0], + [CCScaleTo actionWithDuration:duration/2 scale:0.5f], + nil], + [CCHide action], + [CCDelayTime actionWithDuration:duration/2], + nil ]; + + inScene.scale = 0.5f; + [inScene runAction: inA]; + [outScene runAction: outA];*/ +} + + + +// +// ZoomFlipY Transition +// +CCZoomFlipYTransition::CCZoomFlipYTransition() +{ + /// @todo +} +CCZoomFlipYTransition::~CCZoomFlipYTransition() +{ + /// @todo +} + +void CCZoomFlipYTransition::onEnter() +{ + /** @todo + [super onEnter]; + + CCIntervalAction *inA, *outA; + [inScene setVisible: NO]; + + float inDeltaZ, inAngleZ; + float outDeltaZ, outAngleZ; + + if( orientation == kOrientationUpOver ) { + inDeltaZ = 90; + inAngleZ = 270; + outDeltaZ = 90; + outAngleZ = 0; + } else { + inDeltaZ = -90; + inAngleZ = 90; + outDeltaZ = -90; + outAngleZ = 0; + } + + inA = [CCSequence actions: + [CCDelayTime actionWithDuration:duration/2], + [CCSpawn actions: + [CCOrbitCamera actionWithDuration: duration/2 radius: 1 deltaRadius:0 angleZ:inAngleZ deltaAngleZ:inDeltaZ angleX:90 deltaAngleX:0], + [CCScaleTo actionWithDuration:duration/2 scale:1], + [CCShow action], + nil], + [CCCallFunc actionWithTarget:self selector:@selector(finish)], + nil ]; + outA = [CCSequence actions: + [CCSpawn actions: + [CCOrbitCamera actionWithDuration: duration/2 radius: 1 deltaRadius:0 angleZ:outAngleZ deltaAngleZ:outDeltaZ angleX:90 deltaAngleX:0], + [CCScaleTo actionWithDuration:duration/2 scale:0.5f], + nil], + [CCHide action], + [CCDelayTime actionWithDuration:duration/2], + nil ]; + + inScene.scale = 0.5f; + [inScene runAction: inA]; + [outScene runAction: outA];*/ +} + + + +// +// ZoomFlipAngular Transition +// +CCZoomFlipAngularTransition::CCZoomFlipAngularTransition() +{ + /// @todo +} +CCZoomFlipAngularTransition::~CCZoomFlipAngularTransition() +{ + /// @todo +} + + +void CCZoomFlipAngularTransition::onEnter() +{ + /** @todo + [super onEnter]; + + CCIntervalAction *inA, *outA; + [inScene setVisible: NO]; + + float inDeltaZ, inAngleZ; + float outDeltaZ, outAngleZ; + + if( orientation == kOrientationRightOver ) { + inDeltaZ = 90; + inAngleZ = 270; + outDeltaZ = 90; + outAngleZ = 0; + } else { + inDeltaZ = -90; + inAngleZ = 90; + outDeltaZ = -90; + outAngleZ = 0; + } + + inA = [CCSequence actions: + [CCDelayTime actionWithDuration:duration/2], + [CCSpawn actions: + [CCOrbitCamera actionWithDuration: duration/2 radius: 1 deltaRadius:0 angleZ:inAngleZ deltaAngleZ:inDeltaZ angleX:-45 deltaAngleX:0], + [CCScaleTo actionWithDuration:duration/2 scale:1], + [CCShow action], + nil], + [CCShow action], + [CCCallFunc actionWithTarget:self selector:@selector(finish)], + nil ]; + outA = [CCSequence actions: + [CCSpawn actions: + [CCOrbitCamera actionWithDuration: duration/2 radius: 1 deltaRadius:0 angleZ:outAngleZ deltaAngleZ:outDeltaZ angleX:45 deltaAngleX:0], + [CCScaleTo actionWithDuration:duration/2 scale:0.5f], + nil], + [CCHide action], + [CCDelayTime actionWithDuration:duration/2], + nil ]; + + inScene.scale = 0.5f; + [inScene runAction: inA]; + [outScene runAction: outA];*/ +} + + +// +// Fade Transition +// +CCFadeTransition::CCFadeTransition() +{ + /// @todo +} +CCFadeTransition::~CCFadeTransition() +{ + /// @todo +} + + +CCFadeTransition * CCFadeTransition::transitionWithDurationAndColor(ccTime duration, CCScene *scene, ccColor3B color) +{ + return NULL; +/// @todo return [[[self alloc] initWithDuration:d scene:s withColor:color] autorelease]; +} + +CCFadeTransition * CCFadeTransition::initWithDurationAndColor(ccTime duration, CCScene *scene, ccColor3B color) +{ + /** @todo + if( (self=[super initWithDuration:d scene:s]) ) { + color.r = aColor.r; + color.g = aColor.g; + color.b = aColor.b; + } + + return self;*/ + return NULL; +} + +CCFadeTransition * CCFadeTransition::initWithDurationAndScene(ccTime t, CCScene *scene) +{ + return NULL; + /// @todo return [self initWithDuration:d scene:s withColor:ccBLACK]; +} + +void CCFadeTransition :: onEnter() +{ + /** @todo + [super onEnter]; + + CCColorLayer *l = [CCColorLayer layerWithColor:color]; + [inScene setVisible: NO]; + + [self addChild: l z:2 tag:kSceneFade]; + + + CCNode *f = [self getChildByTag:kSceneFade]; + + CCIntervalAction *a = [CCSequence actions: + [CCFadeIn actionWithDuration:duration/2], + [CCCallFunc actionWithTarget:self selector:@selector(hideOutShowIn)], + [CCFadeOut actionWithDuration:duration/2], + [CCCallFunc actionWithTarget:self selector:@selector(finish)], + nil ]; + [f runAction: a];*/ +} + +void CCFadeTransition::onExit() +{ + /** @todo + [super onExit]; + [self removeChildByTag:kSceneFade cleanup:NO];*/ +} + + + +// +// Cross Fade Transition +// +CCCrossFadeTransition::CCCrossFadeTransition() +{ + /// @todo +} +CCCrossFadeTransition::~CCCrossFadeTransition() +{ + /// @todo +} + + +void CCCrossFadeTransition:: draw() +{ + /// @todo override draw since both scenes (textures) are rendered in 1 scene +} + +void CCCrossFadeTransition::onEnter() +{ + /** @todo + [super onEnter]; + + // create a transparent color layer + // in which we are going to add our rendertextures + ccColor4B color = {0,0,0,0}; + CGSize size = [[CCDirector sharedDirector] winSize]; + CCColorLayer * layer = [CCColorLayer layerWithColor:color]; + + // create the first render texture for inScene + CCRenderTexture *inTexture = [CCRenderTexture renderTextureWithWidth:size.width height:size.height]; + inTexture.sprite.anchorPoint= ccp(0.5f,0.5f); + inTexture.position = ccp(size.width/2, size.height/2); + inTexture.anchorPoint = ccp(0.5f,0.5f); + + // render inScene to its texturebuffer + [inTexture begin]; + [inScene visit]; + [inTexture end]; + + // create the second render texture for outScene + CCRenderTexture *outTexture = [CCRenderTexture renderTextureWithWidth:size.width height:size.height]; + outTexture.sprite.anchorPoint= ccp(0.5f,0.5f); + outTexture.position = ccp(size.width/2, size.height/2); + outTexture.anchorPoint = ccp(0.5f,0.5f); + + // render outScene to its texturebuffer + [outTexture begin]; + [outScene visit]; + [outTexture end]; + + // create blend functions + + ccBlendFunc blend1 = {GL_ONE, GL_ONE}; // inScene will lay on background and will not be used with alpha + ccBlendFunc blend2 = {GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA}; // we are going to blend outScene via alpha + + // set blendfunctions + [inTexture.sprite setBlendFunc:blend1]; + [outTexture.sprite setBlendFunc:blend2]; + + // add render textures to the layer + [layer addChild:inTexture]; + [layer addChild:outTexture]; + + // initial opacity: + [inTexture.sprite setOpacity:255]; + [outTexture.sprite setOpacity:255]; + + // create the blend action + CCIntervalAction * layerAction = [CCSequence actions: + [CCFadeTo actionWithDuration:duration opacity:0], + [CCCallFunc actionWithTarget:self selector:@selector(hideOutShowIn)], + [CCCallFunc actionWithTarget:self selector:@selector(finish)], + nil ]; + + + // run the blend action + [outTexture.sprite runAction: layerAction]; + + // add the layer (which contains our two rendertextures) to the scene + [self addChild: layer z:2 tag:kSceneFade];*/ +} + +// clean up on exit +void CCCrossFadeTransition::onExit() +{ + /** @todo + // remove our layer and release all containing objects + [self removeChildByTag:kSceneFade cleanup:NO]; + + [super onExit]; */ +} + + + +// +// TurnOffTilesTransition +// +CCTurnOffTilesTransition::CCTurnOffTilesTransition() +{ + /// @todo +} +CCTurnOffTilesTransition::~CCTurnOffTilesTransition() +{ + /// @todo +} + + +// override addScenes, and change the order +void CCTurnOffTilesTransition::sceneOrder() +{ + m_bIsInSceneOnTop = false; +} + +void CCTurnOffTilesTransition::onEnter() +{ + /** @todo + [super onEnter]; + CGSize s = [[CCDirector sharedDirector] winSize]; + float aspect = s.width / s.height; + int x = 12 * aspect; + int y = 12; + + id toff = [CCTurnOffTiles actionWithSize: ccg(x,y) duration:duration]; + id action = [self easeActionWithAction:toff]; + [outScene runAction: [CCSequence actions: action, + [CCCallFunc actionWithTarget:self selector:@selector(finish)], + [CCStopGrid action], + nil] + ];*/ + +} + + +CCIntervalAction* CCTurnOffTilesTransition:: easeActionWithAction(CCIntervalAction* action) +{ + return action; + // return [EaseIn actionWithAction:action rate:2.0f]; +} + + + + +// +// SplitCols Transition +// +CCSplitColsTransition::CCSplitColsTransition() +{ + /// @todo +} +CCSplitColsTransition::~CCSplitColsTransition() +{ + /// @todo +} + + +void CCSplitColsTransition::onEnter() +{ + /** @todo + [super onEnter]; + + inScene.visible = NO; + + id split = [self action]; + id seq = [CCSequence actions: + split, + [CCCallFunc actionWithTarget:self selector:@selector(hideOutShowIn)], + [split reverse], + nil + ]; + [self runAction: [CCSequence actions: + [self easeActionWithAction:seq], + [CCCallFunc actionWithTarget:self selector:@selector(finish)], + [CCStopGrid action], + nil] + ];*/ +} + + +CCIntervalAction* CCSplitColsTransition:: action() +{ + return NULL; + /// @todo return [CCSplitCols actionWithCols:3 duration:duration/2.0f]; +} + + +CCIntervalAction* easeActionWithAction(CCIntervalAction * action) +{ + return NULL; + /// @todo return [CCEaseInOut actionWithAction:action rate:3.0f]; +} + + +// +// SplitRows Transition +// +CCSplitRowsTransition::CCSplitRowsTransition() +{ + /// @todo +} +CCSplitRowsTransition::~CCSplitRowsTransition() +{ + /// @todo +} + + +CCIntervalAction* CCSplitRowsTransition::action() +{ + return NULL; + /// @todo return [CCSplitRows actionWithRows:3 duration:duration/2.0f]; +} + + + +// +// FadeTR Transition +// +CCFadeTRTransition::CCFadeTRTransition() +{ + /// @todo +} +CCFadeTRTransition::~CCFadeTRTransition() +{ + /// @todo +} + + +void CCFadeTRTransition::sceneOrder() +{ + m_bIsInSceneOnTop = false; +} + +void CCFadeTRTransition::onEnter() +{ + /** @todo + [super onEnter]; + + CGSize s = [[CCDirector sharedDirector] winSize]; + float aspect = s.width / s.height; + int x = 12 * aspect; + int y = 12; + + id action = [self actionWithSize:ccg(x,y)]; + + [outScene runAction: [CCSequence actions: + [self easeActionWithAction:action], + [CCCallFunc actionWithTarget:self selector:@selector(finish)], + [CCStopGrid action], + nil] + ];*/ +} + + +CCIntervalAction* CCFadeTRTransition::actionWithSize(ccGridSize size) +{ + return NULL; + /// @todo return [CCFadeOutTRTiles actionWithSize:v duration:duration]; +} + +CCIntervalAction* CCFadeTRTransition:: easeActionWithAction(CCIntervalAction* action) +{ + return action; + // return [EaseIn actionWithAction:action rate:2.0f]; +} + + +// +// FadeBL Transition +// + +CCFadeBLTransition::CCFadeBLTransition() +{ + /// @todo +} +CCFadeBLTransition::~CCFadeBLTransition() +{ + /// @todo +} + +CCIntervalAction* CCFadeBLTransition::actionWithSize(ccGridSize size) +{ + return NULL; + /// @todo return [CCFadeOutBLTiles actionWithSize:v duration:duration]; +} + + + +// +// FadeUp Transition +// +CCFadeUpTransition::CCFadeUpTransition() +{ + /// @todo +} +CCFadeUpTransition::~CCFadeUpTransition() +{ + /// @todo +} + + +CCIntervalAction* CCFadeUpTransition::actionWithSize(ccGridSize size) +{ + return NULL; + /// @todo return [CCFadeOutUpTiles actionWithSize:v duration:duration]; +} + + +// +// FadeDown Transition +// +CCFadeDownTransition::CCFadeDownTransition() +{ + /// @todo +} +CCFadeDownTransition::~CCFadeDownTransition() +{ + /// @todo +} + +CCIntervalAction* CCFadeDownTransition::actionWithSize(ccGridSize size) +{ + return NULL; + /// @todo return [CCFadeOutDownTiles actionWithSize:v duration:duration]; +}