diff --git a/CocosDenshion/win32/SimpleAudioEngine.cpp b/CocosDenshion/win32/SimpleAudioEngine.cpp index fd8b9bb3e6..45ba191855 100644 --- a/CocosDenshion/win32/SimpleAudioEngine.cpp +++ b/CocosDenshion/win32/SimpleAudioEngine.cpp @@ -201,17 +201,14 @@ const char * _FullPath(const char * szPath) { if (! s_szRootPath[0]) { - s_dwRootLen = GetModuleFileName(NULL, s_szRootPath, sizeof(s_szRootPath)); - while (--s_dwRootLen) - { - if ('\\' == s_szRootPath[s_dwRootLen]) - { - s_szRootPath[s_dwRootLen + 1] = 0; - strcpy_s(s_szFullPath, sizeof(s_szFullPath), s_szRootPath); - ++s_dwRootLen; - break; - } - } + WCHAR wszPath[MAX_PATH]; + s_dwRootLen = WideCharToMultiByte(CP_ACP, 0, wszPath, + GetCurrentDirectoryW(sizeof(wszPath), wszPath), + s_szRootPath, MAX_PATH, NULL, NULL); + s_szRootPath[s_dwRootLen] = '\\'; + s_szRootPath[s_dwRootLen + 1] = 0; + strcpy_s(s_szFullPath, sizeof(s_szFullPath), s_szRootPath); + ++s_dwRootLen; } if (0 != szPath[0] && ':' != szPath[1]) diff --git a/cocos2dx/CCScheduler.cpp b/cocos2dx/CCScheduler.cpp index 965476ee58..4d1e59c5e1 100644 --- a/cocos2dx/CCScheduler.cpp +++ b/cocos2dx/CCScheduler.cpp @@ -653,6 +653,20 @@ void CCScheduler::pauseTarget(SelectorProtocol *pTarget) } } +bool CCScheduler::isTargetPaused(SelectorProtocol *pTarget) +{ + CCAssert( pTarget != NULL, "target must be non nil" ); + + // Custom selectors + tHashSelectorEntry *pElement = NULL; + HASH_FIND_INT(m_pHashForSelectors, &pTarget, pElement); + if( pElement ) + { + return pElement->paused; + } + return false; // should never get here +} + // main loop void CCScheduler::tick(ccTime dt) { diff --git a/cocos2dx/actions/CCActionGrid.cpp b/cocos2dx/actions/CCActionGrid.cpp index 04c076c07b..f5e34ab897 100644 --- a/cocos2dx/actions/CCActionGrid.cpp +++ b/cocos2dx/actions/CCActionGrid.cpp @@ -151,7 +151,7 @@ namespace cocos2d void CCGrid3DAction::setVertex(cocos2d::ccGridSize pos, cocos2d::ccVertex3F vertex) { CCGrid3D *g = (CCGrid3D*)m_pTarget->getGrid(); - return g->setVertex(pos, vertex); + g->setVertex(pos, vertex); } // implementation of TiledGrid3DAction diff --git a/cocos2dx/actions/CCActionInterval.cpp b/cocos2dx/actions/CCActionInterval.cpp index 1e60dbb0ac..43c5fbed9d 100644 --- a/cocos2dx/actions/CCActionInterval.cpp +++ b/cocos2dx/actions/CCActionInterval.cpp @@ -542,28 +542,33 @@ bool CCSpawn:: initOneTwo(CCFiniteTimeAction *pAction1, CCFiniteTimeAction *pAct assert(pAction1 != NULL); assert(pAction2 != NULL); + bool bRet = false; + ccTime d1 = pAction1->getDuration(); ccTime d2 = pAction2->getDuration(); - // __super::initWithDuration(fmaxf(d1, d2)); - float maxd = (d1 >= d2 || isnan(d2)) ? d1 : d2; - CCActionInterval::initWithDuration(maxd); - - m_pOne = pAction1; - m_pTwo = pAction2; - - if (d1 > d2) + if (CCActionInterval::initWithDuration(MAX(d1, d2))) { - m_pTwo = CCSequence::actionOneTwo(pAction2, CCDelayTime::actionWithDuration(d1 - d2)); - } else - if (d1 < d2) - { - m_pOne = CCSequence::actionOneTwo(pAction1, CCDelayTime::actionWithDuration(d2 - d1)); + m_pOne = pAction1; + m_pTwo = pAction2; + + if (d1 > d2) + { + m_pTwo = CCSequence::actionOneTwo(pAction2, CCDelayTime::actionWithDuration(d1 - d2)); + } else + if (d1 < d2) + { + m_pOne = CCSequence::actionOneTwo(pAction1, CCDelayTime::actionWithDuration(d2 - d1)); + } + + m_pOne->retain(); + m_pTwo->retain(); + + bRet = true; } - m_pOne->retain(); - m_pTwo->retain(); - return true; + + return bRet; } CCObject* CCSpawn::copyWithZone(cocos2d::CCZone *pZone) diff --git a/cocos2dx/actions/CCActionManager.cpp b/cocos2dx/actions/CCActionManager.cpp index 9c746fa507..dc55d97f3a 100644 --- a/cocos2dx/actions/CCActionManager.cpp +++ b/cocos2dx/actions/CCActionManager.cpp @@ -303,14 +303,10 @@ void CCActionManager::removeActionByTag(unsigned int tag, CCObject *pTarget) if (pAction->getTag() == tag && pAction->getOriginalTarget() == pTarget) { - return removeActionAtIndex(i, pElement); + removeActionAtIndex(i, pElement); + break; } } - CCLOG("cocos2d: removeActionByTag: Action not found!"); - } - else - { - CCLOG("cocos2d: removeActionByTag: Target not found!"); } } diff --git a/cocos2dx/include/CCArray.h b/cocos2dx/include/CCArray.h index 88c5c041dd..a2c07fdffa 100644 --- a/cocos2dx/include/CCArray.h +++ b/cocos2dx/include/CCArray.h @@ -32,6 +32,17 @@ A convience macro to iterate over a CCArray using. It is faster than the "fast e @since v0.99.4 */ +/* +In cocos2d-iphone 1.0.0, This macro have been update to like this: + +#define CCARRAY_FOREACH(__array__, __object__) \ +if (__array__ && __array__->data->num > 0) \ +for(id *__arr__ = __array__->data->arr, *end = __array__->data->arr + __array__->data->num-1; \ +__arr__ <= end && ((__object__ = *__arr__) != nil || true); \ +__arr__++) + +I found that it's not work in C++. So it keep what it's look like in version 1.0.0-rc3. ---By Bin +*/ #define CCARRAY_FOREACH(__array__, __object__) \ if (__array__ && __array__->data->num > 0) \ for(CCObject** arr = __array__->data->arr, **end = __array__->data->arr + __array__->data->num-1; \ diff --git a/cocos2dx/include/CCLabelAtlas.h b/cocos2dx/include/CCLabelAtlas.h index c795cf3611..896ebc47eb 100644 --- a/cocos2dx/include/CCLabelAtlas.h +++ b/cocos2dx/include/CCLabelAtlas.h @@ -37,7 +37,7 @@ namespace cocos2d{ - CCLabelAtlas "characters" have a fixed height and width - CCLabelAtlas "characters" can be anything you want since they are taken from an image file - A more flexible class is CCBitmapFontAtlas. It supports variable width characters and it also has a nice editor. + A more flexible class is CCLabelBMFont. It supports variable width characters and it also has a nice editor. */ class CC_DLL CCLabelAtlas : public CCAtlasNode, public CCLabelProtocol { diff --git a/cocos2dx/include/CCLabelBMFont.h b/cocos2dx/include/CCLabelBMFont.h index 62588ce52b..320f1e9cca 100644 --- a/cocos2dx/include/CCLabelBMFont.h +++ b/cocos2dx/include/CCLabelBMFont.h @@ -22,6 +22,13 @@ 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. + +Use any of these editors to generate BMFonts: + http://glyphdesigner.71squared.com/ (Commercial, Mac OS X) + http://www.n4te.com/hiero/hiero.jnlp (Free, Java) + http://slick.cokeandcode.com/demos/hiero.jnlp (Free, Java) + http://www.angelcode.com/products/bmfont/ (Free, Windows only) + ****************************************************************************/ #ifndef __CCBITMAP_FONT_ATLAS_H__ #define __CCBITMAP_FONT_ATLAS_H__ @@ -127,10 +134,11 @@ namespace cocos2d{ CCLabelBMFont has the flexibility of CCLabel, the speed of CCLabelAtlas and all the features of CCSprite. If in doubt, use CCLabelBMFont instead of CCLabelAtlas / CCLabel. - Supported editors: - - http://www.n4te.com/hiero/hiero.jnlp - - http://slick.cokeandcode.com/demos/hiero.jnlp - - http://www.angelcode.com/products/bmfont/ + Supported editors: + http://glyphdesigner.71squared.com/ (Commercial, Mac OS X) + http://www.n4te.com/hiero/hiero.jnlp (Free, Java) + http://slick.cokeandcode.com/demos/hiero.jnlp (Free, Java) + http://www.angelcode.com/products/bmfont/ (Free, Windows only) @since v0.8 */ diff --git a/cocos2dx/include/CCLabelTTF.h b/cocos2dx/include/CCLabelTTF.h index a9fdbd5acc..5deeb1011d 100644 --- a/cocos2dx/include/CCLabelTTF.h +++ b/cocos2dx/include/CCLabelTTF.h @@ -33,7 +33,7 @@ namespace cocos2d{ * * All features from CCTextureNode are valid in CCLabelTTF * - * CCLabelTTF objects are slow. Consider using CCLabelAtlas or CCBitmapFontAtlas instead. + * CCLabelTTF objects are slow. Consider using CCLabelAtlas or CCLabelBMFont instead. */ class CC_DLL CCLabelTTF : public CCSprite, public CCLabelProtocol { diff --git a/cocos2dx/include/CCPointExtension.h b/cocos2dx/include/CCPointExtension.h index 22a4c2506e..c72b9f9816 100644 --- a/cocos2dx/include/CCPointExtension.h +++ b/cocos2dx/include/CCPointExtension.h @@ -301,10 +301,22 @@ CCPoint CC_DLL ccpRotateByAngle(const CCPoint& v, const CCPoint& pivot, float an the hit point also is p1 + s * (p2 - p1); @since v0.99.1 */ -bool CC_DLL ccpLineIntersect(CCPoint p1, CCPoint p2, - CCPoint p3, CCPoint p4, +bool CC_DLL ccpLineIntersect(const CCPoint& p1, const CCPoint& p2, + const CCPoint& p3, const CCPoint& p4, float *s, float *t); +/* +ccpSegmentIntersect returns YES if Segment A-B intersects with segment C-D +@since v1.0.0 +*/ +bool ccpSegmentIntersect(const CCPoint& A, const CCPoint& B, const CCPoint& C, const CCPoint& D); + +/* +ccpIntersectPoint returns the intersection point of line A-B, C-D +@since v1.0.0 +*/ +CCPoint ccpIntersectPoint(const CCPoint& A, const CCPoint& B, const CCPoint& C, const CCPoint& D); + }//namespace cocos2d #endif // __SUPPORT_CGPOINTEXTENSION_H__ diff --git a/cocos2dx/include/CCScheduler.h b/cocos2dx/include/CCScheduler.h index 81d3fa1ad9..19d356f2d8 100644 --- a/cocos2dx/include/CCScheduler.h +++ b/cocos2dx/include/CCScheduler.h @@ -177,6 +177,11 @@ public: */ void resumeTarget(SelectorProtocol *pTarget); + /** Returns whether or not the target is paused + @since v1.0.0 + */ + bool isTargetPaused(SelectorProtocol *pTarget); + public: /** returns a shared instance of the Scheduler */ static CCScheduler* sharedScheduler(void); diff --git a/cocos2dx/include/CCSprite.h b/cocos2dx/include/CCSprite.h index f9e49961b4..56ed3d985a 100644 --- a/cocos2dx/include/CCSprite.h +++ b/cocos2dx/include/CCSprite.h @@ -45,10 +45,7 @@ class CCSize; class CCTexture2D; struct transformValues_; -enum { - /// CCSprite invalid index on the CCSpriteBatchNode - CCSpriteIndexNotInitialized = 0xffffffff, -}; +#define CCSpriteIndexNotInitialized 0xffffffff /// CCSprite invalid index on the CCSpriteBatchode /** Whether or not an CCSprite will rotate, scale or translate with it's parent. diff --git a/cocos2dx/include/CCTouchDispatcher.h b/cocos2dx/include/CCTouchDispatcher.h index 0f530afead..389a08e2b2 100644 --- a/cocos2dx/include/CCTouchDispatcher.h +++ b/cocos2dx/include/CCTouchDispatcher.h @@ -147,6 +147,8 @@ protected: void forceRemoveDelegate(CCTouchDelegate *pDelegate); void forceAddHandler(CCTouchHandler *pHandler, CCMutableArray *pArray); void forceRemoveAllDelegates(void); + void rearrangeHandlers(CCMutableArray *pArray); + CCTouchHandler* findHandler(CCTouchDelegate *pDelegate); protected: CCMutableArray *m_pTargetedHandlers; diff --git a/cocos2dx/include/ccConfig.h b/cocos2dx/include/ccConfig.h index 1d53d29b48..78c8ab1943 100644 --- a/cocos2dx/include/ccConfig.h +++ b/cocos2dx/include/ccConfig.h @@ -40,7 +40,7 @@ This formula prevents artifacts by using 99% of the texture. The "correct" way to prevent artifacts is by using the spritesheet-artifact-fixer.py or a similar tool. Affected nodes: -- CCSprite / CCSpriteBatchNode and subclasses: CCBitmapFontAtlas, CCTMXTiledMap +- CCSprite / CCSpriteBatchNode and subclasses: CCLabelBMFont, CCTMXTiledMap - CCLabelAtlas - CCQuadParticleSystem - CCTileMap @@ -143,7 +143,7 @@ Disabled by default on iPhone with ARMv6 processors. Using the translate/rotate/scale requires 5 GL calls. But computing the Affine matrix is relative expensive. But according to performance tests, Affine matrix performs better. - This parameter doesn't affect SpriteSheet nodes. + This parameter doesn't affect CCSpriteBatchNode nodes. To enable set it to a value different than 0. Enabled by default. @@ -177,6 +177,11 @@ To enable set it to a value different than 0. Enabled by default. To enable set it to a value different than 0. Disabled by default. + This value governs only the PNG, GIF, BMP, images. + This value DOES NOT govern the PVR (PVR.GZ, PVR.CCZ) files. If NPOT PVR is loaded, then it will create an NPOT texture ignoring this value. + + @deprecated This value will be removed in 1.1 and NPOT textures will be loaded by default if the device supports it. + @since v0.99.2 */ #define CC_TEXTURE_NPOT_SUPPORT 0 @@ -187,6 +192,11 @@ For performance reasons, it's recommended disable it in games without retina dis To enable set it to 1. Use 0 to disable it. Enabled by default. +This value governs only the PNG, GIF, BMP, images. +This value DOES NOT govern the PVR (PVR.GZ, PVR.CCZ) files. If NPOT PVR is loaded, then it will create an NPOT texture ignoring this value. + +@deprecated This value will be removed in 1.1 and NPOT textures will be loaded by default if the device supports it. + @since v0.99.5 */ #define CC_RETINA_DISPLAY_SUPPORT 1 @@ -220,8 +230,14 @@ Platforms: Only used on ARM Neon architectures like iPhone 3GS or newer and iPad If enabled, all subclasses of CCSprite will draw a bounding box Useful for debugging purposes only. It is recommened to leave it disabled. - To enable set it to a value different than 0. Disabled by default. - */ + To enable set it to a value different than 0. Disabled by default: + 0 -- disabled + 1 -- draw bounding box + 2 -- draw texture box + 0 -- disabled + 1 -- draw bounding box + 2 -- draw texture box +*/ #define CC_SPRITE_DEBUG_DRAW 0 /** @def CC_SPRITEBATCHNODE_DEBUG_DRAW diff --git a/cocos2dx/label_nodes/CCLabelBMFont.cpp b/cocos2dx/label_nodes/CCLabelBMFont.cpp index 81d2528dc2..d58591bc14 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.cpp +++ b/cocos2dx/label_nodes/CCLabelBMFont.cpp @@ -22,6 +22,13 @@ 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. + +Use any of these editors to generate BMFonts: +http://glyphdesigner.71squared.com/ (Commercial, Mac OS X) +http://www.n4te.com/hiero/hiero.jnlp (Free, Java) +http://slick.cokeandcode.com/demos/hiero.jnlp (Free, Java) +http://www.angelcode.com/products/bmfont/ (Free, Windows only) + ****************************************************************************/ #include "CCLabelBMFont.h" @@ -206,7 +213,7 @@ namespace cocos2d{ int index = line.find('=')+1; int index2 = line.find(' ', index); std::string value = line.substr(index, index2-index); - CCAssert(atoi(value.c_str()) == 0, "BitmapFontAtlas file could not be found"); + CCAssert(atoi(value.c_str()) == 0, "LabelBMFont file could not be found"); // file index = line.find('"')+1; index2 = line.find('"', index); @@ -366,13 +373,13 @@ namespace cocos2d{ //CCLabelBMFont // - //BitmapFontAtlas - Purge Cache + //LabelBMFont - Purge Cache void CCLabelBMFont::purgeCachedData() { FNTConfigRemoveCache(); } - //BitmapFontAtlas - Creation & Init + //LabelBMFont - Creation & Init CCLabelBMFont *CCLabelBMFont::labelWithString(const char *str, const char *fntFile) { CCLabelBMFont *pRet = new CCLabelBMFont(); @@ -396,7 +403,7 @@ namespace cocos2d{ CC_SAFE_RELEASE(m_pConfiguration);// allow re-init m_pConfiguration = FNTConfigLoadFile(fntFile); m_pConfiguration->retain(); - CCAssert( m_pConfiguration, "Error creating config for BitmapFontAtlas"); + CCAssert( m_pConfiguration, "Error creating config for LabelBMFont"); if (CCSpriteBatchNode::initWithFile(m_pConfiguration->m_sAtlasName.c_str(), strlen(theString))) { @@ -416,7 +423,7 @@ namespace cocos2d{ CC_SAFE_RELEASE(m_pConfiguration); } - // BitmapFontAtlas - Atlas generation + // LabelBMFont - Atlas generation int CCLabelBMFont::kerningAmountForFirst(unsigned short first, unsigned short second) { int ret = 0; @@ -466,7 +473,7 @@ namespace cocos2d{ for(int i=0; isetContentSizeInPixels(tmpSize); } - //BitmapFontAtlas - CCLabelProtocol protocol + //LabelBMFont - CCLabelProtocol protocol void CCLabelBMFont::setString(const char *newString) { m_sString.clear(); @@ -565,7 +572,7 @@ namespace cocos2d{ setString(label); } - //BitmapFontAtlas - CCRGBAProtocol protocol + //LabelBMFont - CCRGBAProtocol protocol void CCLabelBMFont::setColor(ccColor3B var) { m_tColor = var; @@ -633,7 +640,7 @@ namespace cocos2d{ return m_bIsOpacityModifyRGB; } - // BitmapFontAtlas - AnchorPoint + // LabelBMFont - AnchorPoint void CCLabelBMFont::setAnchorPoint(CCPoint point) { if( ! CCPoint::CCPointEqualToPoint(point, m_tAnchorPoint) ) @@ -643,7 +650,7 @@ namespace cocos2d{ } } - //BitmapFontAtlas - Debug draw + //LabelBMFont - Debug draw #if CC_LABELBMFONT_DEBUG_DRAW void CCLabelBMFont::draw() { diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp index 922f1edcad..b5573c8d47 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp @@ -39,9 +39,7 @@ THE SOFTWARE. #include "CCActionTiledGrid.h" namespace cocos2d { -enum { - kSceneFade = 0xFADEFADE, -}; +const unsigned int kSceneFade = 0xFADEFADE; #define IMPLEMENT_TRANSITIONWITHDURATION(_Type)\ _Type* _Type::transitionWithDuration(ccTime t, CCScene* scene)\ diff --git a/cocos2dx/menu_nodes/CCMenu.cpp b/cocos2dx/menu_nodes/CCMenu.cpp index 774a9e83f4..d57d1ed5c1 100644 --- a/cocos2dx/menu_nodes/CCMenu.cpp +++ b/cocos2dx/menu_nodes/CCMenu.cpp @@ -223,7 +223,7 @@ namespace cocos2d{ //Menu - Alignment void CCMenu::alignItemsVertically() { - return this->alignItemsVerticallyWithPadding(kDefaultPadding); + this->alignItemsVerticallyWithPadding(kDefaultPadding); } void CCMenu::alignItemsVerticallyWithPadding(float padding) @@ -260,7 +260,7 @@ namespace cocos2d{ void CCMenu::alignItemsHorizontally(void) { - return this->alignItemsHorizontallyWithPadding(kDefaultPadding); + this->alignItemsHorizontallyWithPadding(kDefaultPadding); } void CCMenu::alignItemsHorizontallyWithPadding(float padding) diff --git a/cocos2dx/menu_nodes/CCMenuItem.cpp b/cocos2dx/menu_nodes/CCMenuItem.cpp index 01ae0939fe..7987cfa32d 100644 --- a/cocos2dx/menu_nodes/CCMenuItem.cpp +++ b/cocos2dx/menu_nodes/CCMenuItem.cpp @@ -40,13 +40,9 @@ namespace cocos2d{ static std::string _fontName = "Marker Felt"; static bool _fontNameRelease = false; - enum { - kCurrentItem = 0xc0c05001, - }; + const unsigned int kCurrentItem = 0xc0c05001; + const unsigned int kZoomActionTag = 0xc0c05002; - enum { - kZoomActionTag = 0xc0c05002, - }; // // CCMenuItem // diff --git a/cocos2dx/sprite_nodes/CCSprite.cpp b/cocos2dx/sprite_nodes/CCSprite.cpp index f23dc4783e..73114de31b 100644 --- a/cocos2dx/sprite_nodes/CCSprite.cpp +++ b/cocos2dx/sprite_nodes/CCSprite.cpp @@ -165,6 +165,10 @@ CCSprite* CCSprite::spriteWithSpriteFrame(CCSpriteFrame *pSpriteFrame) CCSprite* CCSprite::spriteWithSpriteFrameName(const char *pszSpriteFrameName) { CCSpriteFrame *pFrame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(pszSpriteFrameName); + + char msg[256] = {0}; + sprintf(msg, "Invalid spriteFrameName: %s", pszSpriteFrameName); + CCAssert(pFrame != NULL, msg); return spriteWithSpriteFrame(pFrame); } @@ -695,13 +699,23 @@ void CCSprite::draw(void) glBlendFunc(CC_BLEND_SRC, CC_BLEND_DST); } -#if CC_SPRITE_DEBUG_DRAW - CCSize s = m_tContentSize; - CCPoint vertices[4]={ - ccp(0,0),ccp(s.width,0), - ccp(s.width,s.height),ccp(0,s.height), - }; - ccDrawPoly(vertices, 4, true); +#if CC_SPRITE_DEBUG_DRAW == 1 + // draw bounding box + CCSize s = m_tContentSize; + CCPoint vertices[4] = { + ccp(0,0), ccp(s.width,0), + ccp(s.width,s.height), ccp(0,s.height) + }; + ccDrawPoly(vertices, 4, true); +#elif CC_SPRITE_DEBUG_DRAW == 2 + // draw texture box + CCSize s = m_obRect.size; + CCPoint offsetPix = getOffsetPositionInPixels(); + CCPoint vertices[4] = { + ccp(offsetPix.x,offsetPix.y), ccp(offsetPix.x+s.width,offsetPix.y), + ccp(offsetPix.x+s.width,offsetPix.y+s.height), ccp(offsetPix.x,offsetPix.y+s.height) + }; + ccDrawPoly(vertices, 4, true); #endif // CC_SPRITE_DEBUG_DRAW } diff --git a/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp b/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp index ca25c89488..78188410bc 100644 --- a/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp @@ -199,7 +199,7 @@ void CCSpriteFrameCache::addSpriteFramesWithFile(const char *pszPlist, CCTexture const char *pszPath = CCFileUtils::fullPathFromRelativePath(pszPlist); CCDictionary *dict = CCFileUtils::dictionaryWithContentsOfFile(pszPath); - return addSpriteFramesWithDictionary(dict, pobTexture); + addSpriteFramesWithDictionary(dict, pobTexture); } void CCSpriteFrameCache::addSpriteFramesWithFile(const char* plist, const char* textureFileName) diff --git a/cocos2dx/support/CCPointExtension.cpp b/cocos2dx/support/CCPointExtension.cpp index 02059a4f2d..d51961af79 100644 --- a/cocos2dx/support/CCPointExtension.cpp +++ b/cocos2dx/support/CCPointExtension.cpp @@ -124,8 +124,36 @@ CCPoint ccpRotateByAngle(const CCPoint& v, const CCPoint& pivot, float angle) return r; } -bool ccpLineIntersect(CCPoint A, CCPoint B, - CCPoint C, CCPoint D, + +bool ccpSegmentIntersect(const CCPoint& A, const CCPoint& B, const CCPoint& C, const CCPoint& D) +{ + float S, T; + + if( ccpLineIntersect(A, B, C, D, &S, &T ) + && (S >= 0.0f && S <= 1.0f && T >= 0.0f && T <= 1.0f) ) + return true; + + return false; +} + +CCPoint ccpIntersectPoint(const CCPoint& A, const CCPoint& B, const CCPoint& C, const CCPoint& D) +{ + float S, T; + + if( ccpLineIntersect(A, B, C, D, &S, &T) ) + { + // Point of intersection + CCPoint P; + P.x = A.x + S * (B.x - A.x); + P.y = A.y + S * (B.y - A.y); + return P; + } + + return CCPointZero; +} + +bool ccpLineIntersect(const CCPoint& A, const CCPoint& B, + const CCPoint& C, const CCPoint& D, float *S, float *T) { // FAIL: Line undefined @@ -133,51 +161,37 @@ bool ccpLineIntersect(CCPoint A, CCPoint B, { return false; } + const float BAx = B.x - A.x; + const float BAy = B.y - A.y; + const float DCx = D.x - C.x; + const float DCy = D.y - C.y; + const float ACx = A.x - C.x; + const float ACy = A.y - C.y; - // Translate system to make A the origin - B.x-=A.x; B.y-=A.y; - C.x-=A.x; C.y-=A.y; - D.x-=A.x; D.y-=A.y; + const float denom = DCy*BAx - DCx*BAy; - // Cache - CCPoint C2 = C, D2 = D; + *S = DCx*ACy - DCy*ACx; + *T = BAx*ACy - BAy*ACx; - // Length of segment AB - float distAB = sqrtf(B.x*B.x+B.y*B.y); - - // Rotate the system so that point B is on the positive X axis. - float theCos = B.x/distAB; - float theSin = B.y/distAB; - float newX = C.x*theCos+C.y*theSin; - C.y = C.y*theCos-C.x*theSin; C.x = newX; - newX = D.x*theCos+D.y*theSin; - D.y = D.y*theCos-D.x*theSin; D.x = newX; - - // FAIL: Lines are parallel. - if (C.y == D.y) + if (denom == 0) { + if (*S == 0 || *T == 0) + { + // Lines incident + return true; + } + // Lines parallel and not incident return false; } - // Discover position of the intersection in the line AB - float ABpos = D.x+(C.x-D.x)*D.y/(D.y-C.y); + *S = *S / denom; + *T = *T / denom; - // Vector CD - C.x = D2.x-C2.x; - C.y = D2.y-C2.y; + // Point of intersection + // CGPoint P; + // P.x = A.x + *S * (B.x - A.x); + // P.y = A.y + *S * (B.y - A.y); - // Vector between intersection and point C - A.x = ABpos*theCos-C2.x; - A.y = ABpos*theSin-C2.y; - - newX = sqrtf((A.x*A.x+A.y*A.y)/(C.x*C.x+C.y*C.y)); - if(((A.y<0) != (C.y<0)) || ((A.x<0) != (C.x<0))) - newX *= -1.0f; - - *S = ABpos/distAB; - *T = newX; - - // Success. return true; } diff --git a/cocos2dx/support/base64.cpp b/cocos2dx/support/base64.cpp index c11f8b0b62..5bd1304568 100644 --- a/cocos2dx/support/base64.cpp +++ b/cocos2dx/support/base64.cpp @@ -29,6 +29,8 @@ namespace cocos2d { unsigned char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; +int _base64Decode( unsigned char *input, unsigned int input_len, unsigned char *output, unsigned int *output_len ); + int _base64Decode( unsigned char *input, unsigned int input_len, unsigned char *output, unsigned int *output_len ) { static char inalphabet[256], decoder[256]; diff --git a/cocos2dx/support/data_support/ccCArray.h b/cocos2dx/support/data_support/ccCArray.h index 7618c58aa9..dc361faad3 100644 --- a/cocos2dx/support/data_support/ccCArray.h +++ b/cocos2dx/support/data_support/ccCArray.h @@ -339,17 +339,13 @@ static inline void ccCArrayFree(ccCArray *arr) /** Doubles C array capacity */ static inline void ccCArrayDoubleCapacity(ccCArray *arr) { - arr->max *= 2; - arr->arr = (void**) realloc(arr->arr, arr->max * sizeof(void*)); + ccArrayDoubleCapacity((ccArray*)arr); } /** Increases array capacity such that max >= num + extra. */ static inline void ccCArrayEnsureExtraCapacity(ccCArray *arr, unsigned int extra) { - while (arr->max < arr->num + extra) - { - ccCArrayDoubleCapacity(arr); - } + ccArrayEnsureExtraCapacity((ccArray*)arr,extra); } /** Returns index of first occurence of value, NSNotFound if value not found. */ diff --git a/cocos2dx/support/image_support/TGAlib.cpp b/cocos2dx/support/image_support/TGAlib.cpp index 120bda911a..5941636949 100644 --- a/cocos2dx/support/image_support/TGAlib.cpp +++ b/cocos2dx/support/image_support/TGAlib.cpp @@ -30,6 +30,9 @@ THE SOFTWARE. namespace cocos2d { +void tgaLoadRLEImageData(FILE *file, tImageTGA *info); +void tgaFlipImage( tImageTGA *info ); + // load the image header field from stream bool tgaLoadHeader(unsigned char* Buffer, unsigned long bufSize, tImageTGA *psInfo) { diff --git a/cocos2dx/textures/CCTexture2D.cpp b/cocos2dx/textures/CCTexture2D.cpp index ead88c92e7..80d46e5268 100644 --- a/cocos2dx/textures/CCTexture2D.cpp +++ b/cocos2dx/textures/CCTexture2D.cpp @@ -157,6 +157,7 @@ bool CCTexture2D::getHasPremultipliedAlpha() bool CCTexture2D::initWithData(const void *data, CCTexture2DPixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, CCSize contentSize) { + glPixelStorei(GL_UNPACK_ALIGNMENT,1); glGenTextures(1, &m_uName); glBindTexture(GL_TEXTURE_2D, m_uName); diff --git a/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp b/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp index 332d32b4c4..5586a90da8 100644 --- a/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp +++ b/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp @@ -32,6 +32,16 @@ THE SOFTWARE. #include "support/data_support/ccCArray.h" #include +#include + +/** + * Used for sort + */ +static bool less(const cocos2d::CCTouchHandler *p1, const cocos2d::CCTouchHandler *p2) +{ + return ((cocos2d::CCTouchHandler*)p1)->getPriority() < ((cocos2d::CCTouchHandler*)p2)->getPriority(); +} + namespace cocos2d { bool CCTouchDispatcher::isDispatchEvents(void) @@ -229,11 +239,48 @@ void CCTouchDispatcher::removeAllDelegates(void) } } +CCTouchHandler* CCTouchDispatcher::findHandler(CCTouchDelegate *pDelegate) +{ + CCMutableArray::CCMutableArrayIterator iter; + + for (iter = m_pTargetedHandlers->begin(); iter != m_pTargetedHandlers->end(); ++iter) + { + if ((*iter)->getDelegate() == pDelegate) + { + return *iter; + } + } + + for (iter = m_pStandardHandlers->begin(); iter != m_pStandardHandlers->end(); ++iter) + { + if ((*iter)->getDelegate() == pDelegate) + { + return *iter; + } + } + + return NULL; +} + +void CCTouchDispatcher::rearrangeHandlers(CCMutableArray *pArray) +{ + sort(pArray->begin(), pArray->end(), less); +} + void CCTouchDispatcher::setPriority(int nPriority, CCTouchDelegate *pDelegate) { - CC_UNUSED_PARAM(nPriority); - CC_UNUSED_PARAM(pDelegate); - assert(0); + assert(pDelegate != NULL); + + CCTouchHandler *handler = NULL; + + handler = this->findHandler(pDelegate); + + assert(handler != NULL); + + handler->setPriority(nPriority); + + this->rearrangeHandlers(m_pTargetedHandlers); + this->rearrangeHandlers(m_pStandardHandlers); } // diff --git a/tests/tests/ActionManagerTest/ActionManagerTest.cpp b/tests/tests/ActionManagerTest/ActionManagerTest.cpp index 3bcff32f2f..7776201b32 100644 --- a/tests/tests/ActionManagerTest/ActionManagerTest.cpp +++ b/tests/tests/ActionManagerTest/ActionManagerTest.cpp @@ -9,6 +9,10 @@ enum kTagSequence, }; +CCLayer* nextActionManagerAction(); +CCLayer* backActionManagerAction(); +CCLayer* restartActionManagerAction(); + static int sceneIdx = -1; #define MAX_LAYER 5 diff --git a/tests/tests/ActionsTest/ActionsTest.cpp b/tests/tests/ActionsTest/ActionsTest.cpp index 9ef39b219e..73afb42d40 100644 --- a/tests/tests/ActionsTest/ActionsTest.cpp +++ b/tests/tests/ActionsTest/ActionsTest.cpp @@ -1,6 +1,10 @@ #include "ActionsTest.h" #include "../testResource.h" +CCLayer* NextAction(); +CCLayer* BackAction(); +CCLayer* RestartAction(); + static int s_nActionIdx = -1; CCLayer* CreateLayer(int nIndex) @@ -376,19 +380,19 @@ void ActionSkewRotateScale::onEnter() CCSize boxSize = CCSizeMake(100.0f, 100.0f); - CCColorLayer *box = CCColorLayer::layerWithColor(ccc4(255, 255, 0, 255)); + CCLayerColor *box = CCLayerColor::layerWithColor(ccc4(255, 255, 0, 255)); box->setAnchorPoint(ccp(0, 0)); box->setPosition(ccp(190, 110)); box->setContentSize(boxSize); static float markrside = 10.0f; - CCColorLayer *uL = CCColorLayer::layerWithColor(ccc4(255, 0, 0, 255)); + CCLayerColor *uL = CCLayerColor::layerWithColor(ccc4(255, 0, 0, 255)); box->addChild(uL); uL->setContentSize(CCSizeMake(markrside, markrside)); uL->setPosition(ccp(0.f, boxSize.height - markrside)); uL->setAnchorPoint(ccp(0, 0)); - CCColorLayer *uR = CCColorLayer::layerWithColor(ccc4(0, 0, 255, 255)); + CCLayerColor *uR = CCLayerColor::layerWithColor(ccc4(0, 0, 255, 255)); box->addChild(uR); uR->setContentSize(CCSizeMake(markrside, markrside)); uR->setPosition(ccp(boxSize.width - markrside, boxSize.height - markrside)); diff --git a/tests/tests/BugsTest/Bug-1159.cpp b/tests/tests/BugsTest/Bug-1159.cpp index e0d0a82a56..266ec5d156 100644 --- a/tests/tests/BugsTest/Bug-1159.cpp +++ b/tests/tests/BugsTest/Bug-1159.cpp @@ -30,12 +30,12 @@ bool Bug1159Layer::init() CCLayerColor *sprite_a = CCLayerColor::layerWithColorWidthHeight(ccc4(255, 0, 0, 255), 700, 700); sprite_a->setAnchorPoint(ccp(0.5f, 0.5f)); sprite_a->setIsRelativeAnchorPoint(true); - sprite_a->setPosition(ccp(0.0, s.height/2)); + sprite_a->setPosition(ccp(0.0f, s.height/2)); addChild(sprite_a); sprite_a->runAction(CCRepeatForever::actionWithAction((CCActionInterval*) CCSequence::actions( - CCMoveTo::actionWithDuration(1.0f, ccp(1024.0, 384.0)), - CCMoveTo::actionWithDuration(1.0f, ccp(0.0, 384.0)), + CCMoveTo::actionWithDuration(1.0f, ccp(1024.0f, 384.0f)), + CCMoveTo::actionWithDuration(1.0f, ccp(0.0f, 384.0f)), NULL))); CCLayerColor *sprite_b = CCLayerColor::layerWithColorWidthHeight(ccc4(0, 0, 255, 255), 400, 400); @@ -46,7 +46,7 @@ bool Bug1159Layer::init() CCMenuItemLabel *label = CCMenuItemLabel::itemWithLabel(CCLabelTTF::labelWithString("Flip Me", "Helvetica", 24), this, menu_selector(Bug1159Layer::callBack)); CCMenu *menu = CCMenu::menuWithItems(label, NULL); - menu->setPosition(ccp(s.width - 200, 50.0)); + menu->setPosition(ccp(s.width - 200.0f, 50.0f)); addChild(menu); return true; diff --git a/tests/tests/BugsTest/Bug-1174.cpp b/tests/tests/BugsTest/Bug-1174.cpp index ab060cc6fa..71572511bf 100644 --- a/tests/tests/BugsTest/Bug-1174.cpp +++ b/tests/tests/BugsTest/Bug-1174.cpp @@ -5,6 +5,8 @@ #include "Bug-1174.h" +int check_for_error( CCPoint p1, CCPoint p2, CCPoint p3, CCPoint p4, float s, float t ); + int check_for_error( CCPoint p1, CCPoint p2, CCPoint p3, CCPoint p4, float s, float t ) { // the hit point is p3 + t * (p4 - p3); diff --git a/tests/tests/CocosNodeTest/CocosNodeTest.cpp b/tests/tests/CocosNodeTest/CocosNodeTest.cpp index 10a1a489da..0117f12615 100644 --- a/tests/tests/CocosNodeTest/CocosNodeTest.cpp +++ b/tests/tests/CocosNodeTest/CocosNodeTest.cpp @@ -9,6 +9,11 @@ enum kTagSlider, }; + +CCLayer* nextCocosNodeAction(); +CCLayer* backCocosNodeAction(); +CCLayer* restartCocosNodeAction(); + //------------------------------------------------------------------ // // TestCocosNodeDemo diff --git a/tests/tests/DirectorTest/DirectorTest.cpp b/tests/tests/DirectorTest/DirectorTest.cpp index 0b13f838a2..5e0a83b449 100644 --- a/tests/tests/DirectorTest/DirectorTest.cpp +++ b/tests/tests/DirectorTest/DirectorTest.cpp @@ -3,6 +3,10 @@ #define MAX_LAYER 1 +CCLayer* nextDirectorTestCase(); +CCLayer* backDirectorTestCase(); +CCLayer* restartDirectorTestCase(); + static int sceneIdx=-1; static ccDeviceOrientation s_currentOrientation = CCDeviceOrientationPortrait; diff --git a/tests/tests/EaseActionsTest/EaseActionsTest.cpp b/tests/tests/EaseActionsTest/EaseActionsTest.cpp index 17e80c3e10..4332550448 100644 --- a/tests/tests/EaseActionsTest/EaseActionsTest.cpp +++ b/tests/tests/EaseActionsTest/EaseActionsTest.cpp @@ -7,6 +7,10 @@ enum { kTagSlider = 1, }; +CCLayer* nextEaseAction(); +CCLayer* backEaseAction(); +CCLayer* restartEaseAction(); + //------------------------------------------------------------------ // // SpriteEase diff --git a/tests/tests/EffectsAdvancedTest/EffectsAdvancedTest.cpp b/tests/tests/EffectsAdvancedTest/EffectsAdvancedTest.cpp index a5d0071940..63943ef011 100644 --- a/tests/tests/EffectsAdvancedTest/EffectsAdvancedTest.cpp +++ b/tests/tests/EffectsAdvancedTest/EffectsAdvancedTest.cpp @@ -244,6 +244,10 @@ static int sceneIdx = -1; #define MAX_LAYER 6 +CCLayer* nextEffectAdvanceAction(); +CCLayer* backEffectAdvanceAction(); +CCLayer* restartEffectAdvanceAction(); + CCLayer* createEffectAdvanceLayer(int nIndex) { switch(nIndex) diff --git a/tests/tests/HiResTest/HiResTest.cpp b/tests/tests/HiResTest/HiResTest.cpp index f2050116dc..8224b98192 100644 --- a/tests/tests/HiResTest/HiResTest.cpp +++ b/tests/tests/HiResTest/HiResTest.cpp @@ -4,6 +4,10 @@ #define MAX_LAYERS 2; static int sceneIdx = -1; +CCLayer* nextHiResAction(); +CCLayer* restartHiResAction(); +CCLayer* backHiResAction(); + CCLayer* createHiResLayer(int idx) { CCLayer* pLayer = NULL; diff --git a/tests/tests/LabelTest/LabelTest.cpp b/tests/tests/LabelTest/LabelTest.cpp index 5e58bc98f2..380f93bd68 100644 --- a/tests/tests/LabelTest/LabelTest.cpp +++ b/tests/tests/LabelTest/LabelTest.cpp @@ -33,6 +33,10 @@ enum IDC_BACK, IDC_RESTART }; + +CCLayer* nextAtlasAction(); +CCLayer* backAtlasAction(); +CCLayer* restartAtlasAction(); static int sceneIdx = -1; @@ -351,6 +355,12 @@ std::string LabelAtlasColorTest::subtitle() //------------------------------------------------------------------ // // Atlas3 +// +// Use any of these editors to generate BMFonts: +// http://glyphdesigner.71squared.com/ (Commercial, Mac OS X) +// http://www.n4te.com/hiero/hiero.jnlp (Free, Java) +// http://slick.cokeandcode.com/demos/hiero.jnlp (Free, Java) +// http://www.angelcode.com/products/bmfont/ (Free, Windows only) // //------------------------------------------------------------------ Atlas3::Atlas3() @@ -429,6 +439,12 @@ std::string Atlas3::subtitle() //------------------------------------------------------------------ // // Atlas4 +// +// Use any of these editors to generate BMFonts: +// http://glyphdesigner.71squared.com/ (Commercial, Mac OS X) +// http://www.n4te.com/hiero/hiero.jnlp (Free, Java) +// http://slick.cokeandcode.com/demos/hiero.jnlp (Free, Java) +// http://www.angelcode.com/products/bmfont/ (Free, Windows only) // //------------------------------------------------------------------ Atlas4::Atlas4() @@ -515,6 +531,12 @@ std::string Atlas4::subtitle() //------------------------------------------------------------------ // // Atlas5 +// +// Use any of these editors to generate BMFonts: +// http://glyphdesigner.71squared.com/ (Commercial, Mac OS X) +// http://www.n4te.com/hiero/hiero.jnlp (Free, Java) +// http://slick.cokeandcode.com/demos/hiero.jnlp (Free, Java) +// http://www.angelcode.com/products/bmfont/ (Free, Windows only) // //------------------------------------------------------------------ @@ -541,6 +563,12 @@ std::string Atlas5::subtitle() //------------------------------------------------------------------ // // Atlas6 +// +// Use any of these editors to generate BMFonts: +// http://glyphdesigner.71squared.com/ (Commercial, Mac OS X) +// http://www.n4te.com/hiero/hiero.jnlp (Free, Java) +// http://slick.cokeandcode.com/demos/hiero.jnlp (Free, Java) +// http://www.angelcode.com/products/bmfont/ (Free, Windows only) // //------------------------------------------------------------------ @@ -578,16 +606,14 @@ std::string Atlas6::subtitle() //------------------------------------------------------------------ // // AtlasBitmapColor +// +// Use any of these editors to generate BMFonts: +// http://glyphdesigner.71squared.com/ (Commercial, Mac OS X) +// http://www.n4te.com/hiero/hiero.jnlp (Free, Java) +// http://slick.cokeandcode.com/demos/hiero.jnlp (Free, Java) +// http://www.angelcode.com/products/bmfont/ (Free, Windows only) // //------------------------------------------------------------------ - -/* - * Use any of these editors to generate bitmap font atlas: - * http://www.n4te.com/hiero/hiero.jnlp - * http://slick.cokeandcode.com/demos/hiero.jnlp - * http://www.angelcode.com/products/bmfont/ - */ - AtlasBitmapColor::AtlasBitmapColor() { CCSize s = CCDirector::sharedDirector()->getWinSize(); @@ -626,6 +652,12 @@ std::string AtlasBitmapColor::subtitle() //------------------------------------------------------------------ // // AtlasFastBitmap +// +// Use any of these editors to generate BMFonts: +// http://glyphdesigner.71squared.com/ (Commercial, Mac OS X) +// http://www.n4te.com/hiero/hiero.jnlp (Free, Java) +// http://slick.cokeandcode.com/demos/hiero.jnlp (Free, Java) +// http://www.angelcode.com/products/bmfont/ (Free, Windows only) // //------------------------------------------------------------------ @@ -660,6 +692,12 @@ std::string AtlasFastBitmap::subtitle() //------------------------------------------------------------------ // // BitmapFontMultiLine +// +// Use any of these editors to generate BMFonts: +// http://glyphdesigner.71squared.com/ (Commercial, Mac OS X) +// http://www.n4te.com/hiero/hiero.jnlp (Free, Java) +// http://slick.cokeandcode.com/demos/hiero.jnlp (Free, Java) +// http://www.angelcode.com/products/bmfont/ (Free, Windows only) // //------------------------------------------------------------------ BitmapFontMultiLine::BitmapFontMultiLine() @@ -767,7 +805,7 @@ std::string LabelsEmpty::title() std::string LabelsEmpty::subtitle() { - return "3 empty labels: LabelAtlas, Label and BitmapFontAtlas"; + return "3 empty labels: LabelAtlas, LabelTTF and LabelBMFont"; } //------------------------------------------------------------------ diff --git a/tests/tests/LayerTest/LayerTest.cpp b/tests/tests/LayerTest/LayerTest.cpp index 4140a98389..693aa39fb5 100644 --- a/tests/tests/LayerTest/LayerTest.cpp +++ b/tests/tests/LayerTest/LayerTest.cpp @@ -6,6 +6,10 @@ enum kTagLayer = 1, }; +CCLayer* nextTestAction(); +CCLayer* backTestAction(); +CCLayer* restartTestAction(); + static int sceneIdx = -1; #define MAX_LAYER 4 diff --git a/tests/tests/MenuTest/MenuTest.cpp b/tests/tests/MenuTest/MenuTest.cpp index 0ddd3e3470..561abd5046 100644 --- a/tests/tests/MenuTest/MenuTest.cpp +++ b/tests/tests/MenuTest/MenuTest.cpp @@ -28,6 +28,7 @@ MenuLayer1::MenuLayer1() CCMenuItemFont::setFontSize( 30 ); CCMenuItemFont::setFontName("Courier New"); + setIsTouchEnabled(true); // Font Item CCSprite* spriteNormal = CCSprite::spriteWithFile(s_MenuItem, CCRectMake(0,23*2,115,23)); @@ -51,7 +52,7 @@ MenuLayer1::MenuLayer1() // Font Item CCMenuItem *item4 = CCMenuItemFont::itemFromString("I toggle enable items", this, menu_selector(MenuLayer1::menuCallbackEnable) ); - // Label Item (BitmapFontAtlas) + // Label Item (CCLabelBMFont) CCLabelBMFont* label = CCLabelBMFont::labelWithString("configuration", "fonts/bitmapFontTest3.fnt"); CCMenuItemLabel* item5 = CCMenuItemLabel::itemWithLabel(label, this, menu_selector(MenuLayer1::menuCallbackConfig)); @@ -105,6 +106,28 @@ MenuLayer1::MenuLayer1() } +void MenuLayer1::registerWithTouchDispatcher() +{ + CCTouchDispatcher::sharedDispatcher()->addTargetedDelegate(this, kCCMenuTouchPriority+1, true); +} + +bool MenuLayer1::ccTouchBegan(CCTouch *touch, CCEvent * pEvent) +{ + return true; +} + +void MenuLayer1::ccTouchEnded(CCTouch *touch, CCEvent * pEvent) +{ +} + +void MenuLayer1::ccTouchCancelled(CCTouch *touch, CCEvent * pEvent) +{ +} + +void MenuLayer1::ccTouchMoved(CCTouch *touch, CCEvent * pEvent) +{ +} + MenuLayer1::~MenuLayer1() { m_disabledItem->release(); @@ -120,8 +143,19 @@ void MenuLayer1::menuCallbackConfig(CCObject* sender) ((CCLayerMultiplex*)m_pParent)->switchTo(3); } +void MenuLayer1::allowTouches(ccTime dt) +{ + CCTouchDispatcher::sharedDispatcher()->setPriority(kCCMenuTouchPriority+1, this); + unscheduleAllSelectors(); + CCLog("TOUCHES ALLOWED AGAIN"); +} + void MenuLayer1::menuCallbackDisabled(CCObject* sender) { + // hijack all touch events for 5 seconds + CCTouchDispatcher::sharedDispatcher()->setPriority(kCCMenuTouchPriority-1, this); + schedule(schedule_selector(MenuLayer1::allowTouches), 5.0f); + CCLog("TOUCHES DISABLED FOR 5 SECONDS"); } void MenuLayer1::menuCallbackEnable(CCObject* sender) diff --git a/tests/tests/MenuTest/MenuTest.h b/tests/tests/MenuTest/MenuTest.h index 5c5a0e8a22..6e98d1ae95 100644 --- a/tests/tests/MenuTest/MenuTest.h +++ b/tests/tests/MenuTest/MenuTest.h @@ -14,6 +14,13 @@ public: ~MenuLayer1(); public: + virtual void registerWithTouchDispatcher(); + virtual bool ccTouchBegan(CCTouch *touch, CCEvent * pEvent); + virtual void ccTouchEnded(CCTouch *touch, CCEvent * pEvent); + virtual void ccTouchCancelled(CCTouch *touch, CCEvent * pEvent); + virtual void ccTouchMoved(CCTouch *touch, CCEvent * pEvent); + + void allowTouches(ccTime dt); void menuCallback(CCObject* pSender); void menuCallbackConfig(CCObject* pSender); void menuCallbackDisabled(CCObject* pSender); diff --git a/tests/tests/MotionStreakTest/MotionStreakTest.cpp b/tests/tests/MotionStreakTest/MotionStreakTest.cpp index 9729a71af9..a683dfcadb 100644 --- a/tests/tests/MotionStreakTest/MotionStreakTest.cpp +++ b/tests/tests/MotionStreakTest/MotionStreakTest.cpp @@ -1,6 +1,10 @@ #include "MotionStreakTest.h" #include "../testResource.h" +CCLayer* nextMotionAction(); +CCLayer* backMotionAction(); +CCLayer* restartMotionAction(); + //------------------------------------------------------------------ // // MotionStreakTest1 diff --git a/tests/tests/ParallaxTest/ParallaxTest.cpp b/tests/tests/ParallaxTest/ParallaxTest.cpp index 11210018c1..8e53bb4354 100644 --- a/tests/tests/ParallaxTest/ParallaxTest.cpp +++ b/tests/tests/ParallaxTest/ParallaxTest.cpp @@ -7,6 +7,10 @@ enum kTagGrossini, }; +CCLayer* nextParallaxAction(); +CCLayer* backParallaxAction(); +CCLayer* restartParallaxAction(); + //------------------------------------------------------------------ // // Parallax1 diff --git a/tests/tests/ParticleTest/ParticleTest.cpp b/tests/tests/ParticleTest/ParticleTest.cpp index 1a12e8c65e..b41d98522f 100644 --- a/tests/tests/ParticleTest/ParticleTest.cpp +++ b/tests/tests/ParticleTest/ParticleTest.cpp @@ -12,6 +12,10 @@ enum kTagLabelAtlas = 1, }; +CCLayer* nextParticleAction(); +CCLayer* backParticleAction(); +CCLayer* restartParticleAction(); + //------------------------------------------------------------------ // // DemoFirework diff --git a/tests/tests/ProgressActionsTest/ProgressActionsTest.cpp b/tests/tests/ProgressActionsTest/ProgressActionsTest.cpp index 0665e3f09c..22b0bf537b 100644 --- a/tests/tests/ProgressActionsTest/ProgressActionsTest.cpp +++ b/tests/tests/ProgressActionsTest/ProgressActionsTest.cpp @@ -5,6 +5,10 @@ static int sceneIdx = -1; #define MAX_LAYER 3 +CCLayer* nextAction(); +CCLayer* backAction(); +CCLayer* restartAction(); + CCLayer* createLayer(int nIndex) { switch(nIndex) diff --git a/tests/tests/RenderTextureTest/RenderTextureTest.cpp b/tests/tests/RenderTextureTest/RenderTextureTest.cpp index a38edef99e..8c2443cef3 100644 --- a/tests/tests/RenderTextureTest/RenderTextureTest.cpp +++ b/tests/tests/RenderTextureTest/RenderTextureTest.cpp @@ -1,9 +1,12 @@ #include "CCConfiguration.h" #include "RenderTextureTest.h" +// Test #1 by Jason Booth (slipster216) +// Test #3 by David Deaco (ddeaco) + static int sceneIdx = -1; -#define MAX_LAYER 2 +#define MAX_LAYER 3 CCLayer* createTestCase(int nIndex) { @@ -12,6 +15,7 @@ CCLayer* createTestCase(int nIndex) { case 0: return new RenderTextureTest(); case 1: return new RenderTextureIssue937(); + case 2: return new RenderTextureZbuffer(); } return NULL; @@ -265,3 +269,143 @@ void RenderTextureScene::runThisTest() CCDirector::sharedDirector()->replaceScene(this); } + +RenderTextureZbuffer::RenderTextureZbuffer() +{ + this->setIsTouchEnabled(true); + CCSize size = CCDirector::sharedDirector()->getWinSize(); + CCLabelTTF *label = CCLabelTTF::labelWithString("vertexZ = 50", "Marker Felt", 64); + label->setPosition(ccp(size.width / 2, size.height * 0.25f)); + this->addChild(label); + + CCLabelTTF *label2 = CCLabelTTF::labelWithString("vertexZ = 0", "Marker Felt", 64); + label2->setPosition(ccp(size.width / 2, size.height * 0.5f)); + this->addChild(label2); + + CCLabelTTF *label3 = CCLabelTTF::labelWithString("vertexZ = -50", "Marker Felt", 64); + label3->setPosition(ccp(size.width / 2, size.height * 0.75f)); + this->addChild(label3); + + label->setVertexZ(50); + label2->setVertexZ(0); + label3->setVertexZ(-50); + + CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("Images/bugs/circle.plist"); + mgr = CCSpriteBatchNode::batchNodeWithFile("Images/bugs/circle.png", 9); + this->addChild(mgr); + sp1 = CCSprite::spriteWithSpriteFrameName("circle.png"); + sp2 = CCSprite::spriteWithSpriteFrameName("circle.png"); + sp3 = CCSprite::spriteWithSpriteFrameName("circle.png"); + sp4 = CCSprite::spriteWithSpriteFrameName("circle.png"); + sp5 = CCSprite::spriteWithSpriteFrameName("circle.png"); + sp6 = CCSprite::spriteWithSpriteFrameName("circle.png"); + sp7 = CCSprite::spriteWithSpriteFrameName("circle.png"); + sp8 = CCSprite::spriteWithSpriteFrameName("circle.png"); + sp9 = CCSprite::spriteWithSpriteFrameName("circle.png"); + + mgr->addChild(sp1, 9); + mgr->addChild(sp2, 8); + mgr->addChild(sp3, 7); + mgr->addChild(sp4, 6); + mgr->addChild(sp5, 5); + mgr->addChild(sp6, 4); + mgr->addChild(sp7, 3); + mgr->addChild(sp8, 2); + mgr->addChild(sp9, 1); + + sp1->setVertexZ(400); + sp2->setVertexZ(300); + sp3->setVertexZ(200); + sp4->setVertexZ(100); + sp5->setVertexZ(0); + sp6->setVertexZ(-100); + sp7->setVertexZ(-200); + sp8->setVertexZ(-300); + sp9->setVertexZ(-400); + + sp9->setScale(2); + sp9->setColor(ccYELLOW); +} + +string RenderTextureZbuffer::title() +{ + return "Testing Z Buffer in Render Texture"; +} + +string RenderTextureZbuffer::subtitle() +{ + return "Touch screen. It should be green"; +} + +void RenderTextureZbuffer::ccTouchesBegan(cocos2d::CCSet *touches, cocos2d::CCEvent *event) +{ + CCSetIterator iter; + CCTouch *touch; + for (iter = touches->begin(); iter != touches->end(); ++iter) + { + touch = (CCTouch *)(*iter); + CCPoint location = touch->locationInView(touch->view()); + + location = CCDirector::sharedDirector()->convertToGL(location); + sp1->setPosition(location); + sp2->setPosition(location); + sp3->setPosition(location); + sp4->setPosition(location); + sp5->setPosition(location); + sp6->setPosition(location); + sp7->setPosition(location); + sp8->setPosition(location); + sp9->setPosition(location); + } +} + +void RenderTextureZbuffer::ccTouchesMoved(CCSet* touches, CCEvent* event) +{ + CCSetIterator iter; + CCTouch *touch; + for (iter = touches->begin(); iter != touches->end(); ++iter) + { + touch = (CCTouch *)(*iter); + CCPoint location = touch->locationInView(touch->view()); + + location = CCDirector::sharedDirector()->convertToGL(location); + sp1->setPosition(location); + sp2->setPosition(location); + sp3->setPosition(location); + sp4->setPosition(location); + sp5->setPosition(location); + sp6->setPosition(location); + sp7->setPosition(location); + sp8->setPosition(location); + sp9->setPosition(location); + } +} + +void RenderTextureZbuffer::ccTouchesEnded(CCSet* touches, CCEvent* event) +{ + this->renderScreenShot(); +} + +void RenderTextureZbuffer::renderScreenShot() +{ + CCRenderTexture *texture = CCRenderTexture::renderTextureWithWidthAndHeight(512, 512); + texture->setAnchorPoint(ccp(0, 0)); + texture->begin(); + + this->visit(); + + texture->end(); + + CCSprite *sprite = CCSprite::spriteWithTexture(texture->getSprite()->getTexture()); + + sprite->setPosition(ccp(256, 256)); + sprite->setOpacity(182); + sprite->setFlipY(1); + this->addChild(sprite, 999999); + sprite->setColor(ccGREEN); + + sprite->runAction(CCSequence::actions(CCFadeTo::actionWithDuration(2, 0), + CCHide::action(), + NULL)); +} + diff --git a/tests/tests/RenderTextureTest/RenderTextureTest.h b/tests/tests/RenderTextureTest/RenderTextureTest.h index 01488f133c..8a95abfb6f 100644 --- a/tests/tests/RenderTextureTest/RenderTextureTest.h +++ b/tests/tests/RenderTextureTest/RenderTextureTest.h @@ -45,4 +45,31 @@ public: virtual void runThisTest(); }; +class RenderTextureZbuffer : public RenderTextureTestDemo +{ +public: + RenderTextureZbuffer(); + + virtual void ccTouchesMoved(CCSet* touches, CCEvent* event); + virtual void ccTouchesBegan(CCSet* touches, CCEvent* event); + virtual void ccTouchesEnded(CCSet* touches, CCEvent* event); + virtual std::string title(); + virtual std::string subtitle(); + + void renderScreenShot(); + +private: + cocos2d::CCSpriteBatchNode *mgr;; + + cocos2d::CCSprite *sp1; + cocos2d::CCSprite *sp2; + cocos2d::CCSprite *sp3; + cocos2d::CCSprite *sp4; + cocos2d::CCSprite *sp5; + cocos2d::CCSprite *sp6; + cocos2d::CCSprite *sp7; + cocos2d::CCSprite *sp8; + cocos2d::CCSprite *sp9; +}; + #endif diff --git a/tests/tests/SchedulerTest/SchedulerTest.cpp b/tests/tests/SchedulerTest/SchedulerTest.cpp index 49a04af47d..5b787a580b 100644 --- a/tests/tests/SchedulerTest/SchedulerTest.cpp +++ b/tests/tests/SchedulerTest/SchedulerTest.cpp @@ -8,6 +8,10 @@ enum { #define MAX_TESTS 8 static int sceneIdx = -1; +CCLayer* nextSchedulerTest(); +CCLayer* backSchedulerTest(); +CCLayer* restartSchedulerTest(); + CCLayer* createSchedulerTest(int nIndex) { CCLayer* pLayer = NULL; diff --git a/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id b/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id index 777e20a3f2..398cc842aa 100644 --- a/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id +++ b/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id @@ -1 +1 @@ -a269232296e7dc61dea36f970051f49e0e3de527 \ No newline at end of file +3dfc0a1466d723c0efd4186440040fa78c875e13 \ No newline at end of file diff --git a/tests/tests/TileMapTest/TileMapTest.cpp b/tests/tests/TileMapTest/TileMapTest.cpp index c62e0f5a65..b5f08406c4 100644 --- a/tests/tests/TileMapTest/TileMapTest.cpp +++ b/tests/tests/TileMapTest/TileMapTest.cpp @@ -6,6 +6,10 @@ enum kTagTileMap = 1, }; +CCLayer* nextTileMapAction(); +CCLayer* backTileMapAction(); +CCLayer* restartTileMapAction(); + //------------------------------------------------------------------ // // TileMapTest diff --git a/tests/tests/ZwoptexTest/ZwoptexTest.cpp b/tests/tests/ZwoptexTest/ZwoptexTest.cpp index 06ece467ca..bca0f23ade 100644 --- a/tests/tests/ZwoptexTest/ZwoptexTest.cpp +++ b/tests/tests/ZwoptexTest/ZwoptexTest.cpp @@ -5,6 +5,10 @@ static int sceneIdx = -1; +CCLayer* nextZwoptexTest(); +CCLayer* backZwoptexTest(); +CCLayer* restartZwoptexTest(); + CCLayer* createZwoptexLayer(int nIndex) { switch(nIndex) diff --git a/tools/tolua++/tolua++.rar.REMOVED.git-id b/tools/tolua++/tolua++.rar.REMOVED.git-id new file mode 100644 index 0000000000..6be0fb75bc --- /dev/null +++ b/tools/tolua++/tolua++.rar.REMOVED.git-id @@ -0,0 +1 @@ +eea7ee6d1eab766660efb216ab5fb16640957e75 \ No newline at end of file