issue #18, complete the implementation left.

This commit is contained in:
Walzer 2010-09-01 04:02:36 +00:00
parent 05259df015
commit 820676ea28
7 changed files with 93 additions and 91 deletions

View File

@ -590,6 +590,19 @@ namespace cocos2d
} }
// implementation of TurnOffTiles // implementation of TurnOffTiles
CCTurnOffTiles* CCTurnOffTiles::actionWithSize(ccGridSize size, ccTime d)
{
CCTurnOffTiles* pAction = new CCTurnOffTiles();
if (pAction->initWithSize(size, d))
{
pAction->autorelease();
}
else
{
CCX_SAFE_DELETE(pAction);
}
return pAction;
}
CCTurnOffTiles* CCTurnOffTiles::actionWithSeed(int s, cocos2d::ccGridSize gridSize, cocos2d::ccTime duration) CCTurnOffTiles* CCTurnOffTiles::actionWithSeed(int s, cocos2d::ccGridSize gridSize, cocos2d::ccTime duration)
{ {

View File

@ -27,8 +27,6 @@ THE SOFTWARE.
#include <string> #include <string>
#include "NSObject.h" #include "NSObject.h"
/// @todo #import <Foundation/Foundation.h>
/// @todo #import <CoreGraphics/CGImage.h>
#include "NSMutableDictionary.h" #include "NSMutableDictionary.h"
namespace cocos2d { namespace cocos2d {

View File

@ -164,7 +164,8 @@ namespace cocos2d
virtual void update(ccTime time); virtual void update(ccTime time);
public: public:
static CCTurnOffTiles* actionWithSeed(int s, ccGridSize gridSize, ccTime duration); static CCTurnOffTiles* actionWithSize(ccGridSize size, ccTime d);
static CCTurnOffTiles* actionWithSeed(int s, ccGridSize gridSize, ccTime duration);
protected: protected:
int m_nSeed; int m_nSeed;

View File

@ -27,6 +27,7 @@ THE SOFTWARE.
#include "CCIntervalAction.h" #include "CCIntervalAction.h"
#include "CCInstantAction.h" #include "CCInstantAction.h"
#include "CCGridAction.h" #include "CCGridAction.h"
#include "CCPageTurn3DAction.h"
namespace cocos2d { namespace cocos2d {
@ -113,19 +114,19 @@ void CCPageTurnTransition::onEnter()
CCIntervalAction* CCPageTurnTransition:: actionWithSize(ccGridSize vector) CCIntervalAction* CCPageTurnTransition:: actionWithSize(ccGridSize vector)
{ {
/** @todo CCPageTurn3D if( m_bBack )
if( back_ )
{ {
// Get hold of the PageTurn3DAction // Get hold of the PageTurn3DAction
return [CCReverseTime actionWithAction: return CCReverseTime::actionWithAction
[CCPageTurn3D actionWithSize:v duration:duration]]; (
CCPageTurn3D::actionWithSize(vector, m_fDuration)
);
} }
else else
{ {
// Get hold of the PageTurn3DAction // Get hold of the PageTurn3DAction
return [CCPageTurn3D actionWithSize:v duration:duration]; return CCPageTurn3D::actionWithSize(vector, m_fDuration);
}*/ }
return NULL;
} }
}//namespace cocos2d }//namespace cocos2d

View File

@ -24,6 +24,10 @@ THE SOFTWARE.
#include "CCRadialTransition.h" #include "CCRadialTransition.h"
#include "CCDirector.h" #include "CCDirector.h"
#include "CCRenderTexture.h"
#include "CCInstantAction.h"
#include "CCProgressTimerActions.h"
#include "CGPointExtension.h"
namespace cocos2d { namespace cocos2d {
@ -61,43 +65,44 @@ void CCRadialCCWTransition::onEnter()
// create a transparent color layer // create a transparent color layer
// in which we are going to add our rendertextures // in which we are going to add our rendertextures
CGSize size = CCDirector::getSharedDirector()->getWinSize(); CGSize size = CCDirector::getSharedDirector()->getWinSize();
/** @todo CCProgressTimer, CCRenderTexture
// create the second render texture for outScene // create the second render texture for outScene
CCRenderTexture *outTexture = CCRenderTexture::renderTextureWithWidth:size.width height:size.height]; CCRenderTexture *outTexture = CCRenderTexture::renderTextureWithWidthAndHeight((int)size.width, (int)size.height);
outTexture.sprite.anchorPoint= ccp(0.5f,0.5f); outTexture->getSprite()->setAnchorPoint(ccp(0.5f,0.5f));
outTexture.position = ccp(size.width/2, size.height/2); outTexture->setPosition(ccp(size.width/2, size.height/2));
outTexture.anchorPoint = ccp(0.5f,0.5f); outTexture->setAnchorPoint(ccp(0.5f,0.5f));
// render outScene to its texturebuffer // render outScene to its texturebuffer
[outTexture clear:0 g:0 b:0 a:1]; outTexture->clear(0,0,0,1);
[outTexture begin]; outTexture->begin();
[outScene visit]; m_pOutScene->visit();
[outTexture end]; outTexture->end();
// Since we've passed the outScene to the texture we don't need it. // Since we've passed the outScene to the texture we don't need it.
[self hideOutShowIn]; this->hideOutShowIn();
// We need the texture in RenderTexture. // We need the texture in RenderTexture.
CCProgressTimer *outNode = [CCProgressTimer progressWithTexture:outTexture.sprite.texture]; CCProgressTimer *outNode = CCProgressTimer::progressWithTexture(outTexture->getSprite()->getTexture());
// but it's flipped upside down so we flip the sprite // but it's flipped upside down so we flip the sprite
outNode.sprite.flipY = YES; outNode->getSprite()->setFlipY(true);
// Return the radial type that we want to use // Return the radial type that we want to use
outNode.type = [self radialType]; outNode->setType(radialType());
outNode.percentage = 100.f; outNode->setPercentage(100.f);
outNode.position = ccp(size.width/2, size.height/2); outNode->setPosition(ccp(size.width/2, size.height/2));
outNode.anchorPoint = ccp(0.5f,0.5f); outNode->setAnchorPoint(ccp(0.5f,0.5f));
// create the blend action // create the blend action
CCIntervalAction * layerAction = [CCSequence actions: CCAction * layerAction = CCSequence::actions
[CCProgressFromTo actionWithDuration:duration from:100.f to:0.f], (
[CCCallFunc actionWithTarget:self selector:@selector(finish)], CCProgressFromTo::actionWithDuration(m_fDuration, 100.0f, 0.0f),
nil ]; CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)),
NULL
);
// run the blend action // run the blend action
[outNode runAction: layerAction]; outNode->runAction(layerAction);
// add the layer (which contains our two rendertextures) to the scene // add the layer (which contains our two rendertextures) to the scene
[self addChild: outNode z:2 tag:kSceneRadial];*/ this->addChild(outNode, 2, kSceneRadial);
} }

View File

@ -33,6 +33,8 @@ THE SOFTWARE.
#include "CCCameraAction.h" #include "CCCameraAction.h"
#include "CCLayer.h" #include "CCLayer.h"
#include "CCGridAction.h" #include "CCGridAction.h"
#include "CCRenderTexture.h"
#include "CCTiledGridAction.h"
namespace cocos2d { namespace cocos2d {
enum { enum {
@ -1094,7 +1096,6 @@ void CCCrossFadeTransition:: draw()
void CCCrossFadeTransition::onEnter() void CCCrossFadeTransition::onEnter()
{ {
/** @todo ccrendertexture
__super::onEnter(); __super::onEnter();
// create a transparent color layer // create a transparent color layer
@ -1104,7 +1105,7 @@ void CCCrossFadeTransition::onEnter()
CCColorLayer* layer = CCColorLayer::layerWithColor(color); CCColorLayer* layer = CCColorLayer::layerWithColor(color);
// create the first render texture for inScene // create the first render texture for inScene
CCRenderTexture* inTexture = CCRenderTexture::renderTextureWithWidth((int)size.width, (int)size.height); CCRenderTexture* inTexture = CCRenderTexture::renderTextureWithWidthAndHeight((int)size.width, (int)size.height);
inTexture->getSprite()->setAnchorPoint( ccp(0.5f,0.5f) ); inTexture->getSprite()->setAnchorPoint( ccp(0.5f,0.5f) );
inTexture->setPosition( ccp(size.width/2, size.height/2) ); inTexture->setPosition( ccp(size.width/2, size.height/2) );
inTexture->setAnchorPoint( ccp(0.5f,0.5f) ); inTexture->setAnchorPoint( ccp(0.5f,0.5f) );
@ -1115,7 +1116,7 @@ void CCCrossFadeTransition::onEnter()
inTexture->end(); inTexture->end();
// create the second render texture for outScene // create the second render texture for outScene
CCRenderTexture* outTexture = CCRenderTexture::renderTextureWithWidth((int)size.width, (int)size.height); CCRenderTexture* outTexture = CCRenderTexture::renderTextureWithWidthAndHeight((int)size.width, (int)size.height);
outTexture->getSprite()->setAnchorPoint( ccp(0.5f,0.5f) ); outTexture->getSprite()->setAnchorPoint( ccp(0.5f,0.5f) );
outTexture->setPosition( ccp(size.width/2, size.height/2) ); outTexture->setPosition( ccp(size.width/2, size.height/2) );
outTexture->setAnchorPoint( ccp(0.5f,0.5f) ); outTexture->setAnchorPoint( ccp(0.5f,0.5f) );
@ -1144,19 +1145,19 @@ void CCCrossFadeTransition::onEnter()
// create the blend action // create the blend action
CCAction* layerAction = CCSequence::actions CCAction* layerAction = CCSequence::actions
( (
CCFadeTo::actionWithDuration(m_fDuration, 0), CCFadeTo::actionWithDuration(m_fDuration, 0),
CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::hideOutShowIn)), CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::hideOutShowIn)),
CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)), CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)),
NULL NULL
); );
// run the blend action // run the blend action
outTexture->getSprite()->runAction( layerAction ); outTexture->getSprite()->runAction( layerAction );
// add the layer (which contains our two rendertextures) to the scene // add the layer (which contains our two rendertextures) to the scene
addChild(layer, 2, kSceneFade);*/ addChild(layer, 2, kSceneFade);
} }
// clean up on exit // clean up on exit
@ -1195,37 +1196,24 @@ void CCTurnOffTilesTransition::sceneOrder()
void CCTurnOffTilesTransition::onEnter() void CCTurnOffTilesTransition::onEnter()
{ {
/** @todo ccturnofftiles
__super::onEnter(); __super::onEnter();
CGSize s = CCDirector::getSharedDirector()->getWinSize(); CGSize s = CCDirector::getSharedDirector()->getWinSize();
float aspect = s.width / s.height; float aspect = s.width / s.height;
int x = (int)(12 * aspect); int x = (int)(12 * aspect);
int y = 12; int y = 12;
CCTurnOffTiles* toff = CCTurnOffTiles::actionWithSize( ccg(x,y), m_duration); CCTurnOffTiles* toff = CCTurnOffTiles::actionWithSize( ccg(x,y), m_fDuration);
CCIntervalAction* action = easeActionWithAction(toff); CCIntervalAction* action = easeActionWithAction(toff);
m_outScene->runAction( m_pOutScene->runAction
CCSequence::actions( (
action, CCSequence::actions
CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)), (
CCStopGrid::action(), action,
NULL) CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)),
);*/ CCStopGrid::action(),
/** @todo NULL
[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]
];*/
} }
@ -1254,12 +1242,12 @@ void CCSplitColsTransition::onEnter()
CCIntervalAction* split = action(); CCIntervalAction* split = action();
CCIntervalAction* seq = (CCIntervalAction*)CCSequence::actions CCIntervalAction* seq = (CCIntervalAction*)CCSequence::actions
( (
split, split,
CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::hideOutShowIn)), CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::hideOutShowIn)),
split->reverse(), split->reverse(),
NULL NULL
); );
this->runAction this->runAction
( (
@ -1276,8 +1264,7 @@ void CCSplitColsTransition::onEnter()
CCIntervalAction* CCSplitColsTransition:: action() CCIntervalAction* CCSplitColsTransition:: action()
{ {
return NULL; return CCSplitCols::actionWithCols(3, m_fDuration/2.0f);
/// @todo return [CCSplitCols actionWithCols:3 duration:duration/2.0f];
} }
@ -1302,8 +1289,7 @@ CCSplitRowsTransition::~CCSplitRowsTransition()
CCIntervalAction* CCSplitRowsTransition::action() CCIntervalAction* CCSplitRowsTransition::action()
{ {
return NULL; return CCSplitRows::actionWithRows(3, m_fDuration/2.0f);
/// @todo return [CCSplitRows actionWithRows:3 duration:duration/2.0f];
} }
IMPLEMENT_TRANSITIONWITHDURATION(CCSplitRowsTransition) IMPLEMENT_TRANSITIONWITHDURATION(CCSplitRowsTransition)
@ -1350,8 +1336,7 @@ void CCFadeTRTransition::onEnter()
CCIntervalAction* CCFadeTRTransition::actionWithSize(ccGridSize size) CCIntervalAction* CCFadeTRTransition::actionWithSize(ccGridSize size)
{ {
return NULL; return CCFadeOutTRTiles::actionWithSize(size, m_fDuration);
/// @todo return [CCFadeOutTRTiles actionWithSize:v duration:duration];
} }
CCIntervalAction* CCFadeTRTransition:: easeActionWithAction(CCIntervalAction* action) CCIntervalAction* CCFadeTRTransition:: easeActionWithAction(CCIntervalAction* action)
@ -1375,8 +1360,7 @@ CCFadeBLTransition::~CCFadeBLTransition()
CCIntervalAction* CCFadeBLTransition::actionWithSize(ccGridSize size) CCIntervalAction* CCFadeBLTransition::actionWithSize(ccGridSize size)
{ {
return NULL; return CCFadeOutBLTiles::actionWithSize(size, m_fDuration);
/// @todo return [CCFadeOutBLTiles actionWithSize:v duration:duration];
} }
IMPLEMENT_TRANSITIONWITHDURATION(CCFadeBLTransition) IMPLEMENT_TRANSITIONWITHDURATION(CCFadeBLTransition)
@ -1393,8 +1377,7 @@ CCFadeUpTransition::~CCFadeUpTransition()
CCIntervalAction* CCFadeUpTransition::actionWithSize(ccGridSize size) CCIntervalAction* CCFadeUpTransition::actionWithSize(ccGridSize size)
{ {
return NULL; return CCFadeOutUpTiles::actionWithSize(size, m_fDuration);
/// @todo return [CCFadeOutUpTiles actionWithSize:v duration:duration];
} }
IMPLEMENT_TRANSITIONWITHDURATION(CCFadeUpTransition) IMPLEMENT_TRANSITIONWITHDURATION(CCFadeUpTransition)
@ -1411,8 +1394,7 @@ CCFadeDownTransition::~CCFadeDownTransition()
CCIntervalAction* CCFadeDownTransition::actionWithSize(ccGridSize size) CCIntervalAction* CCFadeDownTransition::actionWithSize(ccGridSize size)
{ {
return NULL; return CCFadeOutDownTiles::actionWithSize(size, m_fDuration);
/// @todo return [CCFadeOutDownTiles actionWithSize:v duration:duration];
} }
IMPLEMENT_TRANSITIONWITHDURATION(CCFadeDownTransition) IMPLEMENT_TRANSITIONWITHDURATION(CCFadeDownTransition)

View File

@ -79,14 +79,14 @@ CCTextureCache::CCTextureCache()
CCTextureCache::~CCTextureCache() CCTextureCache::~CCTextureCache()
{ {
CCLOG("cocos2d: deallocing CCTextureCache."); CCLOG("cocos2d: deallocing CCTextureCache.");
CCX_SAFE_RELEASE(m_pTextures);
CCX_SAFE_DELETE(m_pDictLock);
CCX_SAFE_DELETE(m_pContextLock);
CCX_SAFE_RELEASE(g_sharedTextureCache);
/// @todo release /// @todo release
// [textures release];
// [dictLock release];
// [contextLock release];
// [auxEAGLcontext release]; // [auxEAGLcontext release];
// auxEAGLcontext = nil; // auxEAGLcontext = nil;
// sharedTextureCache = nil;
// [super dealloc];
} }
void CCTextureCache::purgeSharedTextureCache() void CCTextureCache::purgeSharedTextureCache()
@ -187,15 +187,17 @@ CCTexture2D * CCTextureCache::addImage(const char * path)
texture = m_pTextures->objectForKey(temp); texture = m_pTextures->objectForKey(temp);
if( ! texture ) { if( ! texture )
{
// Split up directory and filename // Split up directory and filename
std::string fullpath(CCFileUtils::fullPathFromRelativePath(path)); std::string fullpath(CCFileUtils::fullPathFromRelativePath(path));
// all images are handled by UIImage except PVR extension that is handled by our own handler // all images are handled by UIImage except PVR extension that is handled by our own handler
// if ( [[path lowercaseString] hasSuffix:@".pvr"] ) // if ( [[path lowercaseString] hasSuffix:@".pvr"] )
for (unsigned int i = 0; i < temp.length(); ++i) for (unsigned int i = 0; i < temp.length(); ++i)
{
temp[i] = tolower(temp[i]); temp[i] = tolower(temp[i]);
}
if (std::string::npos != temp.find(".pvr")) if (std::string::npos != temp.find(".pvr"))
{ {
#ifdef _POWERVR_SUPPORT_ #ifdef _POWERVR_SUPPORT_