This commit is contained in:
natural-law 2011-08-03 11:39:03 +08:00
commit 3a80e51d25
52 changed files with 398 additions and 629 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

@ -102,7 +102,7 @@ bool CCDirector::init(void)
// FPS
m_bDisplayFPS = false;
m_nFrames = 0;
m_uTotalFrames = m_uFrames = 0;
m_pszFPS = new char[10];
m_pLastUpdate = new struct cc_timeval();
@ -227,6 +227,8 @@ void CCDirector::drawScene(void)
glPopMatrix();
m_uTotalFrames++;
// swap buffers
if (m_pobOpenGLView)
{
@ -669,13 +671,13 @@ void CCDirector::resume(void)
// updates the FPS every frame
void CCDirector::showFPS(void)
{
m_nFrames++;
m_uFrames++;
m_fAccumDt += m_fDeltaTime;
if (m_fAccumDt > CC_DIRECTOR_FPS_INTERVAL)
{
m_fFrameRate = m_nFrames / m_fAccumDt;
m_nFrames = 0;
m_fFrameRate = m_uFrames / m_fAccumDt;
m_uFrames = 0;
m_fAccumDt = 0;
sprintf(m_pszFPS, "%.1f", m_fFrameRate);

View File

@ -2180,8 +2180,7 @@ CCActionInterval* CCAnimate::reverse(void)
}
}
CCAnimation *pNewAnim = CCAnimation::animationWithName(m_pAnimation->getName(),
m_pAnimation->getDelay(), pNewArray);
CCAnimation *pNewAnim = CCAnimation::animationWithFrames(pNewArray, m_pAnimation->getDelay());
pNewArray->release();

View File

@ -166,7 +166,7 @@ void CCNode::setZOrder(int z)
/// ertexZ getter
float CCNode::getVertexZ()
{
return m_fVertexZ;
return m_fVertexZ / CC_CONTENT_SCALE_FACTOR();
}
@ -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

@ -29,7 +29,7 @@ namespace cocos2d {
const char* cocos2dVersion()
{
return "cocos2d v1.0.0";
return "cocos2d v1.0.1";
}
}//namespace cocos2d

View File

@ -86,28 +86,6 @@ namespace cocos2d {
*/
bool initWithFrames(CCMutableArray<CCSpriteFrame*> *pFrames, float delay);
/** Initializes a CCAnimation with a name
@since v0.99.3
@deprecated Will be removed in 1.0.1. Use "init" instead.
*/
bool initWithName(const char *pszName);
/** Initializes a CCAnimation with a name and frames
@since v0.99.3
@deprecated Will be removed in 1.0.1. Use "initWithFrames" instead.
*/
bool initWithName(const char *pszName, CCMutableArray<CCSpriteFrame*> *pFrames);
/** Initializes a CCAnimation with a name and delay between frames.
@deprecated Will be removed in 1.0.1. Use "initWithFrames:nil delay:delay" instead.
*/
bool initWithName(const char *pszName, float fDelay);
/** Initializes a CCAnimation with a name, delay and an array of CCSpriteFrames.
@deprecated Will be removed in 1.0.1. Use "initWithFrames:frames delay:delay" instead.
*/
bool initWithName(const char *pszName, float fDelay, CCMutableArray<CCSpriteFrame*> *pFrames);
/** adds a frame to a CCAnimation */
void addFrame(CCSpriteFrame *pFrame);
@ -138,24 +116,6 @@ namespace cocos2d {
@since v0.99.5
*/
static CCAnimation* animationWithFrames(CCMutableArray<CCSpriteFrame*> *frames, float delay);
/** Creates a CCAnimation with a name
@since v0.99.3
@deprecated Will be removed in 1.0.1. Use "animation" instead.
*/
static CCAnimation* animationWithName(const char *pszName);
/** Creates a CCAnimation with a name and frames
@since v0.99.3
@deprecated Will be removed in 1.0.1. Use "animationWithFrames" instead.
*/
static CCAnimation* animationWithName(const char *pszName, CCMutableArray<CCSpriteFrame*> *pFrames);
/** Creates a CCAnimation with a name and delay between frames. */
static CCAnimation* animationWithName(const char *pszName, float fDelay);
/** Creates a CCAnimation with a name, delay and an array of CCSpriteFrames. */
static CCAnimation* animationWithName(const char *pszName, float fDelay, CCMutableArray<CCSpriteFrame*> *pFrames);
};
} // end of name sapce cocos2d

View File

@ -404,7 +404,6 @@ protected:
bool m_bLandscape;
bool m_bDisplayFPS;
int m_nFrames;
ccTime m_fAccumDt;
ccTime m_fFrameRate;
#if CC_DIRECTOR_FAST_FPS
@ -415,6 +414,7 @@ protected:
bool m_bPaused;
/* How many frames were called since the director started */
unsigned int m_uTotalFrames;
unsigned int m_uFrames;
/* The running scene */

View File

@ -52,12 +52,6 @@ namespace cocos2d{
/** creates the CCLabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas */
static CCLabelAtlas * labelWithString(const char *label, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned char startCharMap);
/** creates the CCLabelAtlas with a string, a char map file(the atlas), the width and height of each element in points and the starting char of the atlas.
@deprecated Will be removed in 1.0.1. Use "labelWithString:" instead
*/
static CCLabelAtlas * labelAtlasWithString(const char *label, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned char startCharMap);
/** initializes the CCLabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas */
bool initWithString(const char *label, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned char startCharMap);
// super methods

View File

@ -171,12 +171,6 @@ namespace cocos2d{
/** creates a bitmap font altas with an initial string and the FNT file */
static CCLabelBMFont * labelWithString(const char *str, const char *fntFile);
/** creates a BMFont label with an initial string and the FNT file
@deprecated Will be removed in 1.0.1. Use "labelWithString" instead.
@since v0.99.5
*/
static CCLabelBMFont * bitmapFontAtlasWithString(const char *str, const char *fntFile);
/** init a bitmap font altas with an initial string and the FNT file */
bool initWithString(const char *str, const char *fntFile);
/** updates the font chars based on the string to render */
@ -203,14 +197,6 @@ namespace cocos2d{
/** Purges the FNT config cache
*/
CC_DLL void FNTConfigRemoveCache( void );
/** CCBitmapFontAtlas
@deprecated Use CCLabelBMFont instead. Will be removed 1.0.1
*/
class CCBitmapFontAtlas : public CCLabelBMFont
{
};
}// namespace cocos2d
#endif //__CCBITMAP_FONT_ATLAS_H__

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
//
@ -177,18 +196,6 @@ protected:
virtual void updateColor();
};
/** CCColorLayer
It is the same as CCLayerColor.
@deprecated Use CCLayerColor instead. This class will be removed in v1.0.1
*/
class CC_DLL CCColorLayer : public CCLayerColor
{
public:
static CCColorLayer * layerWithColorWidthHeight(ccColor4B color, GLfloat width, GLfloat height);
static CCColorLayer * layerWithColor(ccColor4B color);
};
//
// CCLayerGradient
//
@ -283,14 +290,6 @@ public:
LAYER_NODE_FUNC(CCLayerMultiplex);
};
/** CCMultiplexLayer
It is the same as CCLayerMultiplex.
@deprecated Use CCLayerMultiplex instead. This class will be removed in v1.0.1
*/
class CCMultiplexLayer : public CCLayerMultiplex
{
};
}//namespace cocos2d
#endif // __CCLAYER_H__

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

@ -86,14 +86,28 @@ public:
/** saves the texture into a file */
// para szFilePath the absolute path to save
bool saveBuffer(const char *szFilePath);
/** saves the texture into a file. The format can be JPG or PNG */
bool saveBuffer(const char *name, int format);
// para x,y the lower left corner coordinates of the buffer to save
// pare nWidth,nHeight the size of the buffer to save
// when nWidth = 0 and nHeight = 0, the image size to save equals to buffer texture size
bool saveBuffer(const char *szFilePath, int x = 0, int y = 0, int nWidth = 0, int nHeight = 0);
/** saves the texture into a file.
// para name the file name to save
// para format the image format to save, here it supports kCCImageFormatPNG and kCCImageFormatJPG */
// para x,y the lower left corner coordinates of the buffer to save
// pare nWidth,nHeight the size of the buffer to save
// when nWidth = 0 and nHeight = 0, the image size to save equals to buffer texture size
bool saveBuffer(int format, const char *name, int x = 0, int y = 0, int nWidth = 0, int nHeight = 0);
/* get buffer as UIImage, can only save a render buffer which has a RGBA8888 pixel format */
CCData *getUIImageAsDataFromBuffer(int format);
bool getUIImageFromBuffer(CCImage *pImage);
/** save the buffer data to a CCImage */
// para pImage the CCImage to save
// para x,y the lower left corner coordinates of the buffer to save
// pare nWidth,nHeight the size of the buffer to save
// when nWidth = 0 and nHeight = 0, the image size to save equals to buffer texture size
bool getUIImageFromBuffer(CCImage *pImage, int x = 0, int y = 0, int nWidth = 0, int nHeight = 0);
protected:
GLuint m_uFBO;

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* node(__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

@ -327,25 +327,8 @@ public:
/** returns the current displayed frame. */
CCSpriteFrame* displayedFrame(void);
/** adds an Animation to the Sprite.
@deprecated Use CCAnimationCache instead. Will be removed in 1.0.1
*/
void addAnimation(CCAnimation *pAnimation);
/** returns an Animation given it's name.
@deprecated Use CCAnimationCache instead. Will be removed in 1.0.1
*/
CCAnimation* animationByName(const char *pszAnimationName);
// Animation
/** changes the display frame based on an animation and an index.
@deprecated Will be removed in 1.0.1. Use setDisplayFrameWithAnimationName:index instead
*/
void setDisplayFrame(const char *pszAnimationName, int nFrameIndex);
/** changes the display frame with animation name and index.
The animation name will be get from the CCAnimationCache
@since v0.99.5
@ -355,7 +338,6 @@ public:
protected:
void updateTextureCoords(CCRect rect);
void updateBlendFunc(void);
void initAnimationDictionary(void);
void getTransformValues(struct transformValues_ *tv); // optimization
protected:
@ -404,9 +386,6 @@ protected:
// image is flipped
bool m_bFlipX;
bool m_bFlipY;
// Animations that belong to the sprite
CCMutableDictionary<std::string, CCAnimation*> *m_pAnimations;
};
}//namespace cocos2d

View File

@ -78,27 +78,23 @@ namespace cocos2d
The capacity will be increased in 33% in runtime if it run out of space.
*/
static CCSpriteBatchNode* batchNodeWithTexture(CCTexture2D *tex);
static CCSpriteBatchNode* spriteSheetWithTexture(CCTexture2D *tex); // deprecated
/** creates a CCSpriteBatchNode with a texture2d and capacity of children.
The capacity will be increased in 33% in runtime if it run out of space.
*/
static CCSpriteBatchNode* batchNodeWithTexture(CCTexture2D* tex, unsigned int capacity);
static CCSpriteBatchNode* spriteSheetWithTexture(CCTexture2D *tex, unsigned int capacity); // deprecated
/** creates a CCSpriteBatchNode with a file image (.png, .jpeg, .pvr, etc) with a default capacity of 29 children.
The capacity will be increased in 33% in runtime if it run out of space.
The file will be loaded using the TextureMgr.
*/
static CCSpriteBatchNode* batchNodeWithFile(const char* fileImage);
static CCSpriteBatchNode* spriteSheetWithFile(const char* fileImage); // deprecated
/** creates a CCSpriteBatchNode with a file image (.png, .jpeg, .pvr, etc) and capacity of children.
The capacity will be increased in 33% in runtime if it run out of space.
The file will be loaded using the TextureMgr.
*/
static CCSpriteBatchNode* batchNodeWithFile(const char* fileImage, unsigned int capacity);
static CCSpriteBatchNode* spriteSheetWithFile(const char* fileImage, unsigned int capacity); // deprecated
/** initializes a CCSpriteBatchNode with a texture2d and capacity of children.
The capacity will be increased in 33% in runtime if it run out of space.
@ -112,25 +108,6 @@ namespace cocos2d
void increaseAtlasCapacity();
/** creates an sprite with a rect in the CCSpriteBatchNode.
It's the same as:
- create an standard CCSsprite
- set the usingSpriteSheet = YES
- set the textureAtlas to the same texture Atlas as the CCSpriteBatchNode
@deprecated Use [CCSprite spriteWithBatchNode:rect:] instead;
*/
CCSprite* createSpriteWithRect(CCRect rect);
/** initializes a previously created sprite with a rect. This sprite will have the same texture as the CCSpriteBatchNode.
It's the same as:
- initialize an standard CCSsprite
- set the usingBatchNode = YES
- set the textureAtlas to the same texture Atlas as the CCSpriteBatchNode
@since v0.99.0
@deprecated Use [CCSprite initWithBatchNode:rect:] instead;
*/
void initSprite(CCSprite *sprite, CCRect rect);
/** removes a child given a certain index. It will also cleanup the running actions depending on the cleanup parameter.
@warning Removing a child from a CCSpriteBatchNode is very slow
*/

View File

@ -117,13 +117,6 @@ public:
*/
CCSpriteFrame* spriteFrameByName(const char *pszName);
/** Creates an sprite with the name of an sprite frame.
The created sprite will contain the texture, rect and offset of the sprite frame.
It returns an autorelease object.
@deprecated use CCSprite::spriteWithSpriteFrameName(name). This method will be removed on final v0.9
*/
CCSprite* createSpriteWithFrameName(const char *pszName);
public:
/** Returns the shared instance of the Sprite Frame cache */
static CCSpriteFrameCache* sharedSpriteFrameCache(void);

View File

@ -128,11 +128,6 @@ namespace cocos2d {
/** return the TMXObjectGroup for the secific group */
CCTMXObjectGroup* objectGroupNamed(const char *groupName);
/** return the TMXObjectGroup for the secific group
@deprecated Use map#objectGroupNamed instead
*/
CCTMXObjectGroup* groupNamed(const char *groupName);
/** return the value for the specific property name */
CCString *propertyNamed(const char *propertyName);

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

@ -28,6 +28,10 @@ THE SOFTWARE.
#ifndef __COCOS2D_H__
#define __COCOS2D_H__
// 0x00 HI ME LO
// 00 01 00 01
#define COCOS2D_VERSION 0x00010001
//
// all cocos2d include files
//
@ -80,6 +84,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

@ -44,11 +44,6 @@ namespace cocos2d{
return NULL;
}
CCLabelAtlas * CCLabelAtlas::labelAtlasWithString(const char *label, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned char startCharMap)
{
return labelWithString(label, charMapFile, itemWidth, itemHeight, startCharMap);
}
bool CCLabelAtlas::initWithString(const char *label, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned char startCharMap)
{
assert(label != NULL);

View File

@ -392,11 +392,6 @@ namespace cocos2d{
return NULL;
}
CCLabelBMFont * CCLabelBMFont::bitmapFontAtlasWithString(const char *str, const char *fntFile)
{
return labelWithString(str, fntFile);
}
bool CCLabelBMFont::initWithString(const char *theString, const char *fntFile)
{
assert(theString != NULL);

View File

@ -469,33 +469,6 @@ void CCLayerColor::draw()
glEnable(GL_TEXTURE_2D);
}
//
// CCColorLayer
//
CCColorLayer* CCColorLayer::layerWithColorWidthHeight(ccColor4B color, GLfloat width, GLfloat height)
{
CCColorLayer * pLayer = new CCColorLayer();
if( pLayer && pLayer->initWithColorWidthHeight(color,width,height))
{
pLayer->autorelease();
return pLayer;
}
CC_SAFE_DELETE(pLayer);
return NULL;
}
CCColorLayer* CCColorLayer::layerWithColor(ccColor4B color)
{
CCColorLayer * pLayer = new CCColorLayer();
if(pLayer && pLayer->initWithColor(color))
{
pLayer->autorelease();
return pLayer;
}
CC_SAFE_DELETE(pLayer);
return NULL;
}
//
// CCLayerGradient
//

View File

@ -31,6 +31,7 @@ THE SOFTWARE.
#include "CCStdC.h"
#include <vector>
#include <stdarg.h>
using namespace std;
@ -77,11 +78,11 @@ namespace cocos2d{
return menuWithItems(item, NULL);
}
bool CCMenu::init()
{
va_list args;
return initWithItems(0, args);
}
bool CCMenu::init()
{
va_list args;
return initWithItems(0, args);
}
bool CCMenu::initWithItems(CCMenuItem* item, va_list args)
{
@ -174,6 +175,15 @@ namespace cocos2d{
{
return false;
}
for (CCNode *c = this->m_pParent; c != NULL; c = c->getParent())
{
if (c->getIsVisible() == false)
{
return false;
}
}
m_pSelectedItem = this->itemForTouch(touch);
if (m_pSelectedItem)
{

View File

@ -216,12 +216,12 @@ void CCRenderTexture::clear(float r, float g, float b, float a)
this->end();
}
bool CCRenderTexture::saveBuffer(const char *szFilePath)
bool CCRenderTexture::saveBuffer(const char *szFilePath, int x, int y, int nWidth, int nHeight)
{
bool bRet = false;
CCImage *pImage = new CCImage();
if (pImage != NULL && getUIImageFromBuffer(pImage))
if (pImage != NULL && getUIImageFromBuffer(pImage, x, y, nWidth, nHeight))
{
bRet = pImage->saveToFile(szFilePath);
}
@ -229,14 +229,14 @@ bool CCRenderTexture::saveBuffer(const char *szFilePath)
CC_SAFE_DELETE(pImage);
return bRet;
}
bool CCRenderTexture::saveBuffer(const char *fileName, int format)
bool CCRenderTexture::saveBuffer(int format, const char *fileName, int x, int y, int nWidth, int nHeight)
{
bool bRet = false;
CCAssert(format == kCCImageFormatJPG || format == kCCImageFormatPNG,
"the image can only be saved as JPG or PNG format");
CCImage *pImage = new CCImage();
if (pImage != NULL && getUIImageFromBuffer(pImage))
if (pImage != NULL && getUIImageFromBuffer(pImage, x, y, nWidth, nHeight))
{
std::string fullpath = CCFileUtils::getWriteablePath() + fileName;
if (kCCImageFormatPNG == format)
@ -257,43 +257,86 @@ bool CCRenderTexture::saveBuffer(const char *fileName, int format)
}
/* get buffer as UIImage */
bool CCRenderTexture::getUIImageFromBuffer(CCImage *pImage)
bool CCRenderTexture::getUIImageFromBuffer(CCImage *pImage, int x, int y, int nWidth, int nHeight)
{
if (NULL == pImage)
if (NULL == pImage || NULL == m_pTexture)
{
return false;
}
GLubyte *pBuffer = NULL;
GLubyte *pTempData = NULL;
bool bRet = false;
CCSize s = m_pTexture->getContentSizeInPixels();
int tx = (int)s.width;
int ty = (int)s.height;
do
{
CCAssert(m_ePixelFormat == kCCTexture2DPixelFormat_RGBA8888, "only RGBA8888 can be saved as image");
if (x < 0 || x >= tx || y < 0 || y >= ty)
{
return false;
}
CCSize s = m_pTexture->getContentSizeInPixels();
int tx = (int)s.width;
int ty = (int)s.height;
if (nWidth < 0
|| nHeight < 0
|| (0 == nWidth && 0 != nHeight)
|| (0 == nHeight && 0 != nWidth))
{
return false;
}
// to get the image size to save
// if the saving image domain exeeds the buffer texture domain,
// it should be cut
int nSavedBufferWidth = nWidth;
int nSavedBufferHeight = nHeight;
if (0 == nWidth)
{
nSavedBufferWidth = tx;
}
if (0 == nHeight)
{
nSavedBufferHeight = ty;
}
nSavedBufferWidth = x + nSavedBufferWidth > tx ? (tx - x): nSavedBufferWidth;
nSavedBufferHeight = y + nSavedBufferHeight > ty ? (ty - y): nSavedBufferHeight;
CC_BREAK_IF(! (pBuffer = new GLubyte[tx * ty * 4]));
CC_BREAK_IF(! (pTempData = new GLubyte[tx * ty * 4]));
GLubyte *pBuffer = NULL;
GLubyte *pTempData = NULL;
bool bRet = false;
do
{
CCAssert(m_ePixelFormat == kCCTexture2DPixelFormat_RGBA8888, "only RGBA8888 can be saved as image");
CC_BREAK_IF(! (pBuffer = new GLubyte[nSavedBufferWidth * nSavedBufferHeight * 4]));
// On some machines, like Samsung i9000, Motorola Defy,
// the dimension need to be a power of 2
int nReadBufferWidth = 0;
int nReadBufferHeight = 0;
int nMaxTextureSize = 0;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &nMaxTextureSize);
nReadBufferWidth = ccNextPOT(tx);
nReadBufferHeight = ccNextPOT(ty);
CC_BREAK_IF(0 == nReadBufferWidth || 0 == nReadBufferHeight);
CC_BREAK_IF(nReadBufferWidth > nMaxTextureSize || nReadBufferHeight > nMaxTextureSize);
CC_BREAK_IF(! (pTempData = new GLubyte[nReadBufferWidth * nReadBufferHeight * 4]));
this->begin();
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glReadPixels(0,0,tx,ty,GL_RGBA,GL_UNSIGNED_BYTE, pBuffer);
glReadPixels(0,0,nReadBufferWidth,nReadBufferHeight,GL_RGBA,GL_UNSIGNED_BYTE, pTempData);
this->end();
// to get the actual texture data
// #640 the image read from rendertexture is upseted
int nRowBytes = tx * 4;
for (int i = 0; i < ty; ++i)
for (int i = 0; i < nSavedBufferHeight; ++i)
{
memcpy(&pTempData[(ty - 1 - i) * nRowBytes],
&pBuffer[i * nRowBytes],
nRowBytes);
memcpy(&pBuffer[i * nSavedBufferWidth * 4],
&pTempData[(y + nSavedBufferHeight - i - 1) * nReadBufferWidth * 4 + x * 4],
nSavedBufferWidth * 4);
}
bRet = pImage->initWithImageData(pTempData, tx * ty * 4, CCImage::kFmtRawData, tx, ty, 8);
bRet = pImage->initWithImageData(pBuffer, nSavedBufferWidth * nSavedBufferHeight * 4, CCImage::kFmtRawData, nSavedBufferWidth, nSavedBufferHeight, 8);
} while (0);
CC_SAFE_DELETE_ARRAY(pBuffer);

View File

@ -34,6 +34,8 @@ THE SOFTWARE.
#define JAVAVM cocos2d::JniHelper::getJavaVM()
using namespace std;
extern "C"
{
@ -161,34 +163,24 @@ extern "C"
return bRet;
}
static char* jstringToChar_(jstring jstr)
static string jstring2string_(jstring jstr)
{
char* rtn = 0;
JNIEnv *env = 0;
jboolean isCopy;
if (! getEnv(&env))
{
return 0;
}
// convert jstring to byte array
jclass clsstring = env->FindClass("java/lang/String");
jstring strencode = env->NewStringUTF("utf-8");
jmethodID mid = env->GetMethodID(clsstring, "getBytes", "(Ljava/lang/String;)[B");
jbyteArray barr= (jbyteArray)env->CallObjectMethod(jstr, mid, strencode);
jsize alen = env->GetArrayLength(barr);
jbyte* ba = env->GetByteArrayElements(barr, JNI_FALSE);
// copy byte array into char[]
if (alen > 0)
const char* chars = env->GetStringUTFChars(jstr, &isCopy);
string ret(chars);
if (isCopy)
{
rtn = new char[alen + 1];
memcpy(rtn, ba, alen);
rtn[alen] = 0;
env->ReleaseStringUTFChars(jstr, chars);
}
env->ReleaseByteArrayElements(barr, ba, 0);
return rtn;
return ret;
}
}
@ -221,8 +213,8 @@ namespace cocos2d {
return getMethodInfo_(methodinfo, className, methodName, paramCode);
}
char* JniHelper::jstringToChar(jstring str)
string JniHelper::jstring2string(jstring str)
{
return jstringToChar_(str);
return jstring2string_(str);
}
}

View File

@ -25,6 +25,7 @@ THE SOFTWARE.
#define __ANDROID_JNI_HELPER_H__
#include <jni.h>
#include <string>
#include "CCPlatformMacros.h"
namespace cocos2d {
@ -44,7 +45,7 @@ namespace cocos2d {
static jclass getClassID(const char *className, JNIEnv *env=0);
static bool getStaticMethodInfo(JniMethodInfo &methodinfo, const char *className, const char *methodName, const char *paramCode);
static bool getMethodInfo(JniMethodInfo &methodinfo, const char *className, const char *methodName, const char *paramCode);
static char* jstringToChar(jstring str);
static std::string jstring2string(jstring str);
private:
static JavaVM *m_psJavaVM;

View File

@ -25,6 +25,7 @@ THE SOFTWARE.
#include "CCDirector.h"
#include "JniHelper.h"
#include "CCApplication.h"
#include "CCFileUtils.h"
#include <android/log.h>
#include <jni.h>
@ -111,4 +112,18 @@ extern "C"
t.env->CallStaticObjectMethod(t.classID, t.methodID);
}
}
//////////////////////////////////////////////////////////////////////////
// set apk path
//////////////////////////////////////////////////////////////////////////
void Java_org_cocos2dx_lib_Cocos2dxActivity_nativeSetPaths(JNIEnv* env, jobject thiz, jstring apkPath)
{
const char* str;
jboolean isCopy;
str = env->GetStringUTFChars(apkPath, &isCopy);
if (isCopy) {
cocos2d::CCFileUtils::setResourcePath(str);
env->ReleaseStringUTFChars(apkPath, str);
}
}
}

View File

@ -26,7 +26,6 @@ THE SOFTWARE.
#include "CCAccelerometer.h"
#include "platform/android/CCAccelerometer_android.h"
#include "CCEGLView.h"
#include "CCFileUtils.h"
#include "JniHelper.h"
#include <android/log.h>
#include <jni.h>
@ -57,19 +56,7 @@ extern "C"
(y - rcRect.origin.y) / fScreenScaleFactor,
z,
timeStamp);
}
void Java_org_cocos2dx_lib_Cocos2dxActivity_nativeSetPaths(JNIEnv* env, jobject thiz, jstring apkPath)
{
const char* str;
jboolean isCopy;
str = env->GetStringUTFChars(apkPath, &isCopy);
if (isCopy) {
cocos2d::CCFileUtils::setResourcePath(str);
env->ReleaseStringUTFChars(apkPath, str);
}
}
}
void enableAccelerometerJNI()
{

View File

@ -50,7 +50,7 @@ extern "C"
"()Ljava/lang/String;"))
{
jstring str = (jstring)t.env->CallStaticObjectMethod(t.classID, t.methodID);
ret = JniHelper::jstringToChar(str);
ret = (char*)JniHelper::jstring2string(str).c_str();
LOGD("package name %s", ret);
}
@ -72,7 +72,7 @@ extern "C"
, "()Ljava/lang/String;"))
{
jstring str = (jstring)t.env->CallStaticObjectMethod(t.classID, t.methodID);
ret = JniHelper::jstringToChar(str);
ret = (char*)JniHelper::jstring2string(str).c_str();
LOGD("language name %s", ret);
}

View File

@ -24,6 +24,7 @@ THE SOFTWARE.
#include "TG3.h"
#include <string>
#include "CCApplication.h"
NS_CC_BEGIN
@ -35,6 +36,7 @@ public:
BitmapDC()
: m_pBmp(NULL)
, m_pMemWnd(NULL)
, m_pFont(NULL)
{
}
@ -42,16 +44,59 @@ public:
~BitmapDC(void)
{
prepareBitmap(0, 0);
if (m_pFont)
{
delete m_pFont;
m_pFont = NULL;
}
}
bool setFont(const char * pFontName = NULL, int nSize = 0)
{
bool bRet = false;
TFont * pNewFont = new TFont;
do
{
CC_BREAK_IF(! m_hFont.Create(0, (Int32)nSize));
bRet = true;
if (NULL == pFontName)
{
break;
}
TUChar szFullPath[MAX_PATH] = {0};
std::string fullpath;
#ifdef _TRANZDA_VM_
fullpath = pFontName;
CCLog("++fullpath %s",fullpath.c_str());
fullpath = CCFileUtils::fullPathFromRelativePath(fullpath.c_str());
CCLog("--fullpath %s",fullpath.c_str());
fullpath = &fullpath.c_str()[strlen("D:/Work7")];
#else
fullpath = CCApplication::sharedApplication().getAppDataPath();
fullpath += pFontName;
#endif
TUString::StrGBToUnicode(szFullPath,(const Char*)fullpath.c_str());
CCLog("path %s,++pNewFont->Create",fullpath.c_str());
CC_BREAK_IF(! pNewFont->Create(szFullPath,0, (Int32)nSize,0,NULL));
CCLog("path %s,--pNewFont->Create",fullpath.c_str());
bRet = true;
} while (0);
// create default font
if (!bRet &&
pNewFont->Create(0, (Int32)nSize))
{
bRet = true;
}
// delete old font
if (bRet)
{
if (m_pFont)
{
delete m_pFont;
m_pFont = NULL;
}
m_pFont = pNewFont;
}
return bRet;
}
@ -96,7 +141,7 @@ public:
}
// calculate the width of current line and update the window width
int nTempWidth = m_hFont.CharsWidth(strLine.c_str(), strLine.length() + 1);
int nTempWidth = m_pFont->CharsWidth(strLine.c_str(), strLine.length() + 1);
if (nTempWidth >= nWinWidth)
{
nWinWidth = nTempWidth;
@ -115,14 +160,14 @@ public:
int nCurPos = 0;
do
{
nCurPos = m_hFont.WordWrap(strLeft.c_str(), nWinWidth);
nCurPos = m_pFont->WordWrap(strLeft.c_str(), nWinWidth);
strLeft = strLeft.substr(nCurPos);
++nLineCount;
} while (strLeft.length() > 0);
}
// calculate the window height.
tSize.SetHeight(nLineCount * m_hFont.LineHeight());
tSize.SetHeight(nLineCount * m_pFont->LineHeight());
tSize.SetWidth(nWinWidth);
bRet = true;
@ -205,7 +250,7 @@ public:
m_pMemWnd->GetMemWindowTBitmapPtr()->Fill32(RGBA(0, 0, 0, 0), 0, 0, nWidth, nHeight);
TRectangle rect(0, 0, nWidth, nHeight);
dc.DrawTextInRectangleEx(pszText, 0, RGBA(255,255,255,255), RGBA(0,0,0,255), m_hFont, &rect, style);
dc.DrawTextInRectangleEx(pszText, 0, RGBA(255,255,255,255), RGBA(0,0,0,255), *m_pFont, &rect, style);
dc.ReadBitmap(m_pBmp, 0, 0);
@ -217,7 +262,7 @@ public:
CC_SYNTHESIZE_READONLY(TBitmap*, m_pBmp, Bitmap);
private:
TFont m_hFont;
TFont * m_pFont;
TWindow * m_pMemWnd;
};

View File

@ -65,42 +65,6 @@ namespace cocos2d
return pAnimation;
}
CCAnimation* CCAnimation::animationWithName(const char *pszName)
{
CCAnimation *pAnimation = new CCAnimation();
pAnimation->initWithName(pszName);
pAnimation->autorelease();
return pAnimation;
}
CCAnimation* CCAnimation::animationWithName(const char *pszName, CCMutableArray<CCSpriteFrame*> *pFrames)
{
CCAnimation *pAnimation = new CCAnimation();
pAnimation->initWithName(pszName, pFrames);
pAnimation->autorelease();
return pAnimation;
}
CCAnimation* CCAnimation::animationWithName(const char *pszName, float fDelay, CCMutableArray<CCSpriteFrame*> *pFrames)
{
CCAnimation *pAnimation = new CCAnimation();
pAnimation->initWithName(pszName, fDelay, pFrames);
pAnimation->autorelease();
return pAnimation;
}
CCAnimation* CCAnimation::animationWithName(const char *pszName, float fDelay)
{
CCAnimation *pAnimation = new CCAnimation();
pAnimation->initWithName(pszName, fDelay);
pAnimation->autorelease();
return pAnimation;
}
bool CCAnimation::initWithFrames(CCMutableArray<CCSpriteFrame*> *pFrames, float delay)
{
m_fDelay = delay;
@ -115,31 +79,6 @@ namespace cocos2d
return initWithFrames(pFrames, 0);
}
bool CCAnimation::initWithName(const char *pszName)
{
return initWithName(pszName, 0, NULL);
}
bool CCAnimation::initWithName(const char *pszName, float fDelay)
{
return initWithName(pszName, fDelay, NULL);
}
bool CCAnimation::initWithName(const char *pszName, CCMutableArray<CCSpriteFrame*> *pFrames)
{
return initWithName(pszName, 0, pFrames);
}
bool CCAnimation::initWithName(const char *pszName, float fDelay, CCMutableArray<CCSpriteFrame*> *pFrames)
{
m_fDelay = fDelay;
m_nameStr = pszName;
m_pobFrames = CCMutableArray<CCSpriteFrame*>::arrayWithArray(pFrames);
m_pobFrames->retain();
return true;
}
CCAnimation::~CCAnimation(void)
{
CCLOGINFO("cocos2d, deallocing %p", this);

View File

@ -195,9 +195,6 @@ bool CCSprite::init(void)
m_bFlipX = m_bFlipY = false;
// lazy alloc
m_pAnimations = NULL;
// default transform anchor: center
setAnchorPoint(ccp(0.5f, 0.5f));
@ -332,7 +329,6 @@ CCSprite::CCSprite()
CCSprite::~CCSprite(void)
{
CC_SAFE_RELEASE(m_pobTexture);
CC_SAFE_RELEASE(m_pAnimations);
}
void CCSprite::useSelfRender(void)
@ -360,11 +356,6 @@ void CCSprite::useBatchNode(CCSpriteBatchNode *batchNode)
m_pobBatchNode = batchNode;
}
void CCSprite::initAnimationDictionary(void)
{
m_pAnimations = new CCMutableDictionary<string, CCAnimation*>();
}
void CCSprite::setTextureRect(CCRect rect)
{
CCRect rectInPixels = CC_RECT_POINTS_TO_PIXELS(rect);
@ -1039,22 +1030,6 @@ void CCSprite::setDisplayFrame(CCSpriteFrame *pNewFrame)
setTextureRectInPixels(pNewFrame->getRectInPixels(), pNewFrame->isRotated(), pNewFrame->getOriginalSizeInPixels());
}
// XXX deprecated
void CCSprite::setDisplayFrame(const char *pszAnimationName, int nFrameIndex)
{
if (! m_pAnimations)
{
initAnimationDictionary();
}
CCAnimation *pAnimation = m_pAnimations->objectForKey(std::string(pszAnimationName));
CCSpriteFrame *pFrame = pAnimation->getFrames()->getObjectAtIndex(nFrameIndex);
assert(pFrame);
setDisplayFrame(pFrame);
}
void CCSprite::setDisplayFrameWithAnimationName(const char *animationName, int frameIndex)
{
assert(animationName);
@ -1087,24 +1062,6 @@ CCSpriteFrame* CCSprite::displayedFrame(void)
m_tContentSizeInPixels);
}
void CCSprite::addAnimation(CCAnimation *pAnimation)
{
// lazy alloc
if (! m_pAnimations)
{
initAnimationDictionary();
}
m_pAnimations->setObject(pAnimation, pAnimation->getName());
}
CCAnimation* CCSprite::animationByName(const char *pszAnimationName)
{
assert(pszAnimationName != NULL);
return m_pAnimations->objectForKey(std::string(pszAnimationName));
}
// Texture protocol
void CCSprite::updateBlendFunc(void)

View File

@ -48,11 +48,6 @@ namespace cocos2d
return batchNode;
}
CCSpriteBatchNode* CCSpriteBatchNode::spriteSheetWithTexture(cocos2d::CCTexture2D *tex)
{
return batchNodeWithTexture(tex);
}
CCSpriteBatchNode* CCSpriteBatchNode::batchNodeWithTexture(CCTexture2D* tex, unsigned int capacity)
{
CCSpriteBatchNode *batchNode = new CCSpriteBatchNode();
@ -62,11 +57,6 @@ namespace cocos2d
return batchNode;
}
CCSpriteBatchNode* CCSpriteBatchNode::spriteSheetWithTexture(CCTexture2D *tex, unsigned int capacity)
{
return batchNodeWithTexture(tex, capacity);
}
/*
* creation with File Image
*/
@ -79,11 +69,6 @@ namespace cocos2d
return batchNode;
}
CCSpriteBatchNode* CCSpriteBatchNode::spriteSheetWithFile(const char *fileImage, unsigned int capacity)
{
return batchNodeWithFile(fileImage, capacity);
}
CCSpriteBatchNode* CCSpriteBatchNode::batchNodeWithFile(const char *fileImage)
{
CCSpriteBatchNode *batchNode = new CCSpriteBatchNode();
@ -93,11 +78,6 @@ namespace cocos2d
return batchNode;
}
CCSpriteBatchNode* CCSpriteBatchNode::spriteSheetWithFile(const char *fileImage)
{
return batchNodeWithFile(fileImage);
}
/*
* init with CCTexture2D
*/
@ -170,25 +150,6 @@ namespace cocos2d
glPopMatrix();
}
// xxx deprecated
CCSprite* CCSpriteBatchNode::createSpriteWithRect(CCRect rect)
{
CCSprite *pSprite = CCSprite::spriteWithTexture(m_pobTextureAtlas->getTexture(), rect);
pSprite->useBatchNode(this);
return pSprite;
}
// XXX deprecated
void CCSpriteBatchNode::initSprite(cocos2d::CCSprite *sprite, cocos2d::CCRect rect)
{
if (sprite)
{
sprite->initWithTexture(m_pobTextureAtlas->getTexture(), rect);
sprite->useBatchNode(this);
}
}
void CCSpriteBatchNode::addChild(CCNode *child, int zOrder, int tag)
{
assert(child != NULL);

View File

@ -388,11 +388,6 @@ CCSpriteFrame* CCSpriteFrameCache::spriteFrameByName(const char *pszName)
return frame;
}
CCSprite* CCSpriteFrameCache::createSpriteWithFrameName(const char *pszName)
{
CCSpriteFrame *frame = m_pSpriteFrames->objectForKey(std::string(pszName));
return CCSprite::spriteWithSpriteFrame(frame);
}
const char * CCSpriteFrameCache::valueForKey(const char *key, CCDictionary<std::string, CCObject*> *dict)
{
if (dict)

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)

View File

@ -227,11 +227,6 @@ namespace cocos2d{
return NULL;
}
// XXX deprecated
CCTMXObjectGroup * CCTMXTiledMap::groupNamed(const char *groupName)
{
return objectGroupNamed(groupName);
}
CCString * CCTMXTiledMap::propertyNamed(const char *propertyName)
{
return m_pProperties->objectForKey(std::string(propertyName));

View File

@ -119,7 +119,8 @@ OBJECTS = \
$(OBJECTS_DIR)/TouchesTest.o \
$(OBJECTS_DIR)/TransitionsTest.o \
$(OBJECTS_DIR)/UserDefaultTest.o \
$(OBJECTS_DIR)/ZwoptexTest.o
$(OBJECTS_DIR)/ZwoptexTest.o \
$(OBJECTS_DIR)/FontTest.o
ADD_OBJECTS +=
@ -390,3 +391,6 @@ $(OBJECTS_DIR)/UserDefaultTest.o : ../tests/UserDefaultTest/UserDefaultTest.cpp
$(OBJECTS_DIR)/ZwoptexTest.o : ../tests/ZwoptexTest/ZwoptexTest.cpp
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/ZwoptexTest.o ../tests/ZwoptexTest/ZwoptexTest.cpp
$(OBJECTS_DIR)/FontTest.o : ../tests/FontTest/FontTest.cpp
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/FontTest.o ../tests/FontTest/FontTest.cpp

View File

@ -1090,6 +1090,18 @@
>
</File>
</Filter>
<Filter
Name="FontTest"
>
<File
RelativePath="..\tests\FontTest\FontTest.cpp"
>
</File>
<File
RelativePath="..\tests\FontTest\FontTest.h"
>
</File>
</Filter>
</Filter>
</Filter>
<Filter

View File

@ -609,7 +609,7 @@ void ActionAnimate::onEnter()
centerSprites(1);
CCAnimation* animation = CCAnimation::animationWithName("dance", 0.2f);
CCAnimation* animation = CCAnimation::animation();
char frameName[100] = {0};
for( int i=1;i<15;i++)
{
@ -617,7 +617,7 @@ void ActionAnimate::onEnter()
animation->addFrameWithFileName(frameName);
}
CCActionInterval* action = CCAnimate::actionWithAnimation( animation, false);
CCActionInterval* action = CCAnimate::actionWithDuration(3, animation, false);
CCActionInterval* action_back = action->reverse();
m_grossini->runAction( CCSequence::actions( action, action_back, NULL));

View File

@ -120,7 +120,7 @@ void Box2DTestLayer::addNewSpriteWithCoords(CCPoint p)
//just randomly picking one of the images
int idx = (CCRANDOM_0_1() > .5 ? 0:1);
int idy = (CCRANDOM_0_1() > .5 ? 0:1);
CCSprite *sprite = batch->createSpriteWithRect( CCRectMake(32 * idx,32 * idy,32,32));
CCSprite *sprite = CCSprite::spriteWithTexture(batch->getTexture(), CCRectMake(32 * idx,32 * idy,32,32));
batch->addChild(sprite);
sprite->setPosition( CCPointMake( p.x, p.y) );

View File

@ -19,6 +19,8 @@
* SOFTWARE.
*/
#include "cocos2d.h"
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
@ -26,7 +28,7 @@
#include <string.h>
#include "chipmunk.h"
#include "drawSpace.h"
#include "cocos2d.h"
using namespace cocos2d;

View File

@ -106,7 +106,7 @@ static TestScene* CreateTestScene(int nIdx)
pScene = new DirectorTestScene(); break;
case TEST_BUGS:
pScene = new BugsTestScene(); break;
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
#if (CC_TARGET_PLATFORM != CC_PLATFORM_AIRPLAY)
case TEST_FONTS:
pScene = new FontTestScene(); break;
#endif

View File

@ -20,29 +20,14 @@ namespace cocos2d {
void setDelay(float fDelay);
CCMutableArray<CCSpriteFrame*>* getFrames(void);
void setFrames(CCMutableArray<CCSpriteFrame*> *pFrames);
bool initWithFrames(CCMutableArray<CCSpriteFrame*> *pFrames);
bool initWithFrames(CCMutableArray<CCSpriteFrame*> *pFrames, float delay);
bool initWithName(const char *pszName);
bool initWithName(const char *pszName, CCMutableArray<CCSpriteFrame*> *pFrames);
bool initWithName(const char *pszName, float fDelay);
bool initWithName(const char *pszName, float fDelay, CCMutableArray<CCSpriteFrame*> *pFrames);
void addFrame(CCSpriteFrame *pFrame);
void addFrameWithFileName(const char *pszFileName);
void addFrameWithTexture(CCTexture2D* pobTexture, CCRect rect);
@ -55,18 +40,6 @@ namespace cocos2d {
static CCAnimation* animationWithFrames(CCMutableArray<CCSpriteFrame*> *frames);
static CCAnimation* animationWithFrames(CCMutableArray<CCSpriteFrame*> *frames, float delay);
static CCAnimation* animationWithName(const char *pszName);
static CCAnimation* animationWithName(const char *pszName, CCMutableArray<CCSpriteFrame*> *pFrames);
/** Creates a CCAnimation with a name and delay between frames. */
static CCAnimation* animationWithName(const char *pszName, float fDelay);
/** Creates a CCAnimation with a name, delay and an array of CCSpriteFrames. */
static CCAnimation* animationWithName(const char *pszName, float fDelay, CCMutableArray<CCSpriteFrame*> *pFrames);
};
} // end of name sapce cocos2d

View File

@ -9,8 +9,6 @@ namespace cocos2d{
/** creates the CCLabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas */
static CCLabelAtlas * labelWithString(const char *label, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap);
static CCLabelAtlas * labelAtlasWithString(const char *label, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap);
/** initializes the CCLabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas */
bool initWithString(const char *label, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap);

View File

@ -51,7 +51,6 @@ namespace cocos2d{
CCLabelBMFont();
static void purgeCachedData();
static CCLabelBMFont * labelWithString(const char *str, const char *fntFile);
static CCLabelBMFont * bitmapFontAtlasWithString(const char *str, const char *fntFile);
bool initWithString(const char *str, const char *fntFile);
void createFontChars();
void setString(const char *label);
@ -68,10 +67,6 @@ namespace cocos2d{
void FNTConfigRemoveCache( void );
class CCBitmapFontAtlas : public CCLabelBMFont
{
};
}// namespace cocos2d

View File

@ -74,12 +74,6 @@ namespace cocos2d {
};
class CCColorLayer : public CCLayerColor
{
static CCColorLayer * layerWithColorWidthHeight(ccColor4B color, GLfloat width, GLfloat height);
static CCColorLayer * layerWithColor(ccColor4B color);
};
class CCLayerGradient : public CCLayerColor
{
@ -128,8 +122,4 @@ namespace cocos2d {
void switchTo(unsigned int n);
void switchToAndReleaseMe(unsigned int n);
};
class CCMultiplexLayer : public CCLayerMultiplex
{
};
}//namespace cocos2d

View File

@ -145,21 +145,13 @@ class CCSprite : public CCNode, public CCTextureProtocol, public CCRGBAProtocol
void useSelfRender(void);
void setTextureRect(CCRect rect);
void setTextureRect(CCRect rect);
void setTextureRectInPixels(CCRect rect, bool rotated, CCSize size);
void useBatchNode(CCSpriteBatchNode *batchNode);
void setDisplayFrame(CCSpriteFrame *pNewFrame);
bool isFrameDisplayed(CCSpriteFrame *pFrame);
CCSpriteFrame* displayedFrame(void);
void addAnimation(CCAnimation *pAnimation);
CCAnimation* animationByName(const char *pszAnimationName);
void setDisplayFrame(const char *pszAnimationName, int nFrameIndex);
void setDisplayFrameWithAnimationName(const char *animationName, int frameIndex);
};

View File

@ -12,24 +12,15 @@ namespace cocos2d
CCArray* getDescendants(void);
static CCSpriteBatchNode* batchNodeWithTexture(CCTexture2D *tex);
static CCSpriteBatchNode* spriteSheetWithTexture(CCTexture2D *tex); // deprecated
static CCSpriteBatchNode* batchNodeWithTexture(CCTexture2D* tex, unsigned int capacity);
static CCSpriteBatchNode* spriteSheetWithTexture(CCTexture2D *tex, unsigned int capacity); // deprecated
static CCSpriteBatchNode* batchNodeWithTexture(CCTexture2D* tex, unsigned int capacity);
static CCSpriteBatchNode* batchNodeWithFile(const char* fileImage);
static CCSpriteBatchNode* spriteSheetWithFile(const char* fileImage); // deprecated
static CCSpriteBatchNode* batchNodeWithFile(const char* fileImage, unsigned int capacity);
static CCSpriteBatchNode* spriteSheetWithFile(const char* fileImage, unsigned int capacity); // deprecated
bool initWithTexture(CCTexture2D *tex, unsigned int capacity);
bool initWithFile(const char* fileImage, unsigned int capacity);
void increaseAtlasCapacity();
CCSprite* createSpriteWithRect(CCRect rect);
void initSprite(CCSprite *sprite, CCRect rect);
void removeChildAtIndex(unsigned int index, bool doCleanup);
void insertChild(CCSprite *child, unsigned int index);

View File

@ -35,8 +35,6 @@ class CCSpriteFrameCache : public CCObject
CCSpriteFrame* spriteFrameByName(const char *pszName);
CCSprite* createSpriteWithFrameName(const char *pszName);
/** Returns the shared instance of the Sprite Frame cache */
static CCSpriteFrameCache* sharedSpriteFrameCache(void);

View File

@ -11,24 +11,24 @@ namespace cocos2d {
CCTMXOrientationIso,
};
class CCTMXTiledMap : public CCNode
{
/** the map's size property measured in tiles */
CCSize getMapSize();
/** the map's size property measured in tiles */
CCSize getMapSize();
void setMapSize(CCSize sz);
/** the tiles's size property measured in pixels */
CCSize getTileSize();
/** the tiles's size property measured in pixels */
CCSize getTileSize();
void setTileSize(CCSize sz);
/** map orientation */
int getMapOrientation();
/** map orientation */
int getMapOrientation();
void setMapOrientation(int val);
/** object groups */
CCMutableArray<CCTMXObjectGroup*>* getObjectGroups();
CCMutableArray<CCTMXObjectGroup*>* getObjectGroups();
void setObjectGroups(CCMutableArray<CCTMXObjectGroup*>* pval);
/** properties */
CCStringToStringDictionary* getProperties();
/** properties */
CCStringToStringDictionary* getProperties();
void setProperties(CCStringToStringDictionary* pval);
CCTMXTiledMap();
@ -46,11 +46,6 @@ namespace cocos2d {
/** return the TMXObjectGroup for the secific group */
CCTMXObjectGroup* objectGroupNamed(const char *groupName);
/** return the TMXObjectGroup for the secific group
@deprecated Use map#objectGroupNamed instead
*/
CCTMXObjectGroup* groupNamed(const char *groupName);
/** return the value for the specific property name */
CCString *propertyNamed(const char *propertyName);
@ -58,8 +53,8 @@ namespace cocos2d {
CCDictionary<std::string, CCString*> *propertiesForGID(int GID);
};
}// namespace cocos2d
}// namespace cocos2d