This commit is contained in:
minggo 2011-08-02 14:03:34 +08:00
commit c4d1dedba8
10 changed files with 157 additions and 124 deletions

View File

@ -25,7 +25,7 @@ echo.
call %VSVARS%
if %VC_VER%==90 (
vcbuild cocos2d-win32.vc2008.sln $ALL
vcbuild /MP /M10 cocos2d-win32.vc2008.sln $ALL
) else if %VC_VER%==100 (
msbuild cocos2d-win32.vc2010.sln /p:Configuration="Debug"
msbuild cocos2d-win32.vc2010.sln /p:Configuration="Release"

View File

@ -852,13 +852,13 @@ void CCNode::transform()
if (m_fRotation != 0.0f )
glRotatef( -m_fRotation, 0.0f, 0.0f, 1.0f );
// skew
if ( (skewX_ != 0.0f) || (skewY_ != 0.0f) )
{
CCAffineTransform skewMatrix = CCAffineTransformMake( 1.0f, tanf(CC_DEGREES_TO_RADIANS(skewY_)), tanf(CC_DEGREES_TO_RADIANS(skewX_)), 1.0f, 0.0f, 0.0f );
GLfloat glMatrix[16];
CCAffineToGL(&skewMatrix, glMatrix);
glMultMatrixf(glMatrix);
// skew
if ( (skewX_ != 0.0f) || (skewY_ != 0.0f) )
{
CCAffineTransform skewMatrix = CCAffineTransformMake( 1.0f, tanf(CC_DEGREES_TO_RADIANS(skewY_)), tanf(CC_DEGREES_TO_RADIANS(skewX_)), 1.0f, 0.0f, 0.0f );
GLfloat glMatrix[16];
CCAffineToGL(&skewMatrix, glMatrix);
glMultMatrixf(glMatrix);
}
// scale
@ -1022,12 +1022,12 @@ CCAffineTransform CCNode::nodeToParentTransform(void)
m_tTransform = CCAffineTransformRotate(m_tTransform, -CC_DEGREES_TO_RADIANS(m_fRotation));
}
if(m_fSkewX != 0 || m_fSkewY != 0)
{
// create a skewed coordinate system
CCAffineTransform skew = CCAffineTransformMake(1.0f, tanf(CC_DEGREES_TO_RADIANS(m_fSkewY)), tanf(CC_DEGREES_TO_RADIANS(m_fSkewX)), 1.0f, 0.0f, 0.0f);
// apply the skew to the transform
m_tTransform = CCAffineTransformConcat(skew, m_tTransform);
if(m_fSkewX != 0 || m_fSkewY != 0)
{
// create a skewed coordinate system
CCAffineTransform skew = CCAffineTransformMake(1.0f, tanf(CC_DEGREES_TO_RADIANS(m_fSkewY)), tanf(CC_DEGREES_TO_RADIANS(m_fSkewX)), 1.0f, 0.0f, 0.0f);
// apply the skew to the transform
m_tTransform = CCAffineTransformConcat(skew, m_tTransform);
}
if(! (m_fScaleX == 1 && m_fScaleY == 1))

View File

@ -121,6 +121,25 @@ return NULL; \
} \
};
#define LAYER_NODE_FUNC_PARAM(layer,__PARAMTYPE__,__PARAM__) \
static layer* node(__PARAMTYPE__ __PARAM__) \
{ \
layer *pRet = new layer(); \
if (pRet && pRet->init(__PARAM__)) \
{ \
pRet->autorelease(); \
return pRet; \
} \
else \
{ \
delete pRet; \
pRet = NULL; \
return NULL; \
} \
};
//
// CCLayerColor
//

View File

@ -124,10 +124,8 @@ namespace cocos2d{
virtual CCRGBAProtocol* convertToRGBAProtocol() { return (CCRGBAProtocol*)this; }
private:
CCMenuItem* itemForTouch(CCTouch * touch);
protected:
CCMenuItem* itemForTouch(CCTouch * touch);
tCCMenuState m_eState;
GLubyte m_cOpacity;
CCMenuItem *m_pSelectedItem;

View File

@ -1,82 +1,99 @@
/****************************************************************************
Copyright (c) 2010-2011 cocos2d-x.org
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2011 Zynga Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __CCSCENE_H__
#define __CCSCENE_H__
#include "CCNode.h"
namespace cocos2d {
typedef enum
{
ccNormalScene = 1 << 0,
ccTransitionScene = 1 << 1,
} ccSceneFlag;
/** @brief CCScene is a subclass of CCNode that is used only as an abstract concept.
CCScene an CCNode are almost identical with the difference that CCScene has it's
anchor point (by default) at the center of the screen.
For the moment CCScene has no other logic than that, but in future releases it might have
additional logic.
It is a good practice to use and CCScene as the parent of all your nodes.
*/
class CC_DLL CCScene : public CCNode
{
public:
CCScene();
virtual ~CCScene();
bool init();
static CCScene *node(void);
inline ccSceneFlag getSceneType(void) { return m_eSceneType; }
protected:
ccSceneFlag m_eSceneType;
};
}//namespace cocos2d
// for the subclass of CCScene, each has to implement the static "node" method
#define SCENE_NODE_FUNC(scene) \
static scene* node() \
{ \
scene *pRet = new scene(); \
if (pRet && pRet->init()) \
{ \
pRet->autorelease(); \
return pRet; \
} \
else \
{ \
delete pRet; \
pRet = NULL; \
return NULL; \
} \
};
#endif // __CCSCENE_H__
/****************************************************************************
Copyright (c) 2010-2011 cocos2d-x.org
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2011 Zynga Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __CCSCENE_H__
#define __CCSCENE_H__
#include "CCNode.h"
namespace cocos2d {
typedef enum
{
ccNormalScene = 1 << 0,
ccTransitionScene = 1 << 1,
} ccSceneFlag;
/** @brief CCScene is a subclass of CCNode that is used only as an abstract concept.
CCScene an CCNode are almost identical with the difference that CCScene has it's
anchor point (by default) at the center of the screen.
For the moment CCScene has no other logic than that, but in future releases it might have
additional logic.
It is a good practice to use and CCScene as the parent of all your nodes.
*/
class CC_DLL CCScene : public CCNode
{
public:
CCScene();
virtual ~CCScene();
bool init();
static CCScene *node(void);
inline ccSceneFlag getSceneType(void) { return m_eSceneType; }
protected:
ccSceneFlag m_eSceneType;
};
}//namespace cocos2d
// for the subclass of CCScene, each has to implement the static "node" method
#define SCENE_NODE_FUNC(scene) \
static scene* node() \
{ \
scene *pRet = new scene(); \
if (pRet && pRet->init()) \
{ \
pRet->autorelease(); \
return pRet; \
} \
else \
{ \
delete pRet; \
pRet = NULL; \
return NULL; \
} \
};
#define SCENE_FUNC_PARAM(__TYPE__,__PARAMTYPE__,__PARAM__) \
static cocos2d::CCScene* scene(__PARAMTYPE__ __PARAM__) \
{ \
cocos2d::CCScene * scene = NULL; \
do \
{ \
scene = cocos2d::CCScene::node(); \
CC_BREAK_IF(! scene); \
__TYPE__ *layer = __TYPE__::node(__PARAM__); \
CC_BREAK_IF(! layer); \
scene->addChild(layer); \
} while (0); \
return scene; \
};
#endif // __CCSCENE_H__

View File

@ -142,13 +142,13 @@ public:
public:
/** singleton of the CCTouchDispatcher */
static CCTouchDispatcher* sharedDispatcher();
CCTouchHandler* findHandler(CCTouchDelegate *pDelegate);
protected:
void forceRemoveDelegate(CCTouchDelegate *pDelegate);
void forceAddHandler(CCTouchHandler *pHandler, CCMutableArray<CCTouchHandler*> *pArray);
void forceRemoveAllDelegates(void);
void rearrangeHandlers(CCMutableArray<CCTouchHandler*> *pArray);
CCTouchHandler* findHandler(CCTouchDelegate *pDelegate);
protected:
CCMutableArray<CCTouchHandler*> *m_pTargetedHandlers;

View File

@ -36,7 +36,7 @@ namespace cocos2d {
CCTouchHandler
Object than contains the delegate and priority of the event handler.
*/
class CCTouchHandler : public CCObject
class CC_DLL CCTouchHandler : public CCObject
{
public:
virtual ~CCTouchHandler(void);
@ -69,7 +69,7 @@ protected:
/** CCStandardTouchHandler
It forwardes each event to the delegate.
*/
class CCStandardTouchHandler : public CCTouchHandler
class CC_DLL CCStandardTouchHandler : public CCTouchHandler
{
public:
/** initializes a TouchHandler with a delegate and a priority */
@ -85,7 +85,7 @@ public:
Object than contains the claimed touches and if it swallos touches.
Used internally by TouchDispatcher
*/
class CCTargetedTouchHandler : public CCTouchHandler
class CC_DLL CCTargetedTouchHandler : public CCTouchHandler
{
public:
~CCTargetedTouchHandler(void);

View File

@ -38,18 +38,18 @@ public:
~CCUserDefault();
// get value methods
bool getBoolForKey(const char* pKey);
int getIntegerForKey(const char* pKey);
float getFloatForKey(const char* pKey);
double getDoubleForKey(const char* pKey);
std::string getStringForKey(const char* pKey);
bool getBoolForKey(const char* pKey, bool defaultValue = false);
int getIntegerForKey(const char* pKey, int defaultValue = 0);
float getFloatForKey(const char* pKey, float defaultValue=0.0f);
double getDoubleForKey(const char* pKey, double defaultValue=0.0);
std::string getStringForKey(const char* pKey, const std::string & defaultValue = "");
// set value methods
void setBoolForKey(const char* pKey, bool value);
void setIntegerForKey(const char* pKey, int value);
void setFloatForKey(const char* pKey, float value);
void setDoubleForKey(const char* pKey, double value);
void setStringForKey(const char* pKey, std::string value);
void setStringForKey(const char* pKey, const std::string & value);
static CCUserDefault* sharedUserDefault();
static void purgeSharedUserDefault();

View File

@ -80,6 +80,7 @@ THE SOFTWARE.
#include "CCTexturePVR.h"
#include "CCTransitionRadial.h"
#include "CCActionProgressTimer.h"
#include "CCTouchHandler.h"
#include "CCTouchDispatcher.h"
#include "CCDrawingPrimitives.h"
#include "CCScheduler.h"

View File

@ -148,26 +148,24 @@ void CCUserDefault::purgeSharedUserDefault()
m_spUserDefault = NULL;
}
bool CCUserDefault::getBoolForKey(const char* pKey)
bool CCUserDefault::getBoolForKey(const char* pKey, bool defaultValue)
{
const char* value = getValueForKey(pKey);
bool ret = false;
bool ret = defaultValue;
if (value)
{
if (! strcmp(value, "true"))
{
ret = true;
}
ret = (! strcmp(value, "true"));
xmlFree((void*)value);
}
return ret;
}
int CCUserDefault::getIntegerForKey(const char* pKey)
int CCUserDefault::getIntegerForKey(const char* pKey, int defaultValue)
{
const char* value = getValueForKey(pKey);
int ret = 0;
int ret = defaultValue;
if (value)
{
@ -178,17 +176,17 @@ int CCUserDefault::getIntegerForKey(const char* pKey)
return ret;
}
float CCUserDefault::getFloatForKey(const char* pKey)
float CCUserDefault::getFloatForKey(const char* pKey, float defaultValue)
{
float ret = (float)getDoubleForKey(pKey);
float ret = (float)getDoubleForKey(pKey, (double)defaultValue);
return ret;
}
double CCUserDefault::getDoubleForKey(const char* pKey)
double CCUserDefault::getDoubleForKey(const char* pKey, double defaultValue)
{
const char* value = getValueForKey(pKey);
double ret = 0.0;
double ret = defaultValue;
if (value)
{
@ -199,10 +197,10 @@ double CCUserDefault::getDoubleForKey(const char* pKey)
return ret;
}
string CCUserDefault::getStringForKey(const char* pKey)
string CCUserDefault::getStringForKey(const char* pKey, const std::string & defaultValue)
{
const char* value = getValueForKey(pKey);
string ret("");
string ret = defaultValue;
if (value)
{
@ -264,7 +262,7 @@ void CCUserDefault::setDoubleForKey(const char* pKey, double value)
setValueForKey(pKey, tmp);
}
void CCUserDefault::setStringForKey(const char* pKey, std::string value)
void CCUserDefault::setStringForKey(const char* pKey, const std::string & value)
{
// check key
if (! pKey)