fixed #1189: updated linebreak and tab(4 space) for all source files.

This commit is contained in:
James Chen 2012-04-25 18:17:04 +08:00
parent a5f0bc3cbc
commit 1d94ba05a0
11 changed files with 339 additions and 339 deletions

View File

@ -83,9 +83,9 @@ bool CCConfiguration::init(void)
bEnableProfilers ? "YES - *** Disable it when you finish profiling ***" : "NO"); bEnableProfilers ? "YES - *** Disable it when you finish profiling ***" : "NO");
#if CC_ENABLE_GL_STATE_CACHE == 0 #if CC_ENABLE_GL_STATE_CACHE == 0
CCLOG(""); CCLOG("");
CCLOG("cocos2d: **** WARNING **** CC_ENABLE_GL_STATE_CACHE is disabled. To improve performance, enable it by editing ccConfig.h"); CCLOG("cocos2d: **** WARNING **** CC_ENABLE_GL_STATE_CACHE is disabled. To improve performance, enable it by editing ccConfig.h");
printf("\n"); printf("\n");
#endif #endif
CHECK_GL_ERROR_DEBUG(); CHECK_GL_ERROR_DEBUG();

View File

@ -353,10 +353,10 @@ void CCDirector::setProjection(ccDirectorProjection kProjection)
case kCCDirectorProjection3D: case kCCDirectorProjection3D:
{ {
// reset the viewport if 3d proj & retina display // reset the viewport if 3d proj & retina display
if( CC_CONTENT_SCALE_FACTOR() != 1.0f ) if( CC_CONTENT_SCALE_FACTOR() != 1.0f )
{ {
glViewport((GLint)-size.width/2, (GLint)-size.height/2, (GLsizei)(size.width * CC_CONTENT_SCALE_FACTOR()), (GLsizei)(size.height * CC_CONTENT_SCALE_FACTOR()) ); glViewport((GLint)-size.width/2, (GLint)-size.height/2, (GLsizei)(size.width * CC_CONTENT_SCALE_FACTOR()), (GLsizei)(size.height * CC_CONTENT_SCALE_FACTOR()) );
} }
float zeye = this->getZEye(); float zeye = this->getZEye();

View File

@ -34,16 +34,16 @@ THE SOFTWARE.
#include "ccConfig.h" #include "ccConfig.h"
// actions // actions
#include "CCAction.h" #include "CCAction.h"
#include "CCActionInterval.h" #include "CCActionInterval.h"
#include "CCActionCamera.h" #include "CCActionCamera.h"
#include "CCActionManager.h" #include "CCActionManager.h"
#include "CCActionEase.h" #include "CCActionEase.h"
#include "CCActionPageTurn3D.h" #include "CCActionPageTurn3D.h"
#include "CCActionGrid.h" #include "CCActionGrid.h"
#include "CCActionProgressTimer.h" #include "CCActionProgressTimer.h"
#include "CCActionGrid3D.h" #include "CCActionGrid3D.h"
#include "CCActionTiledGrid.h" #include "CCActionTiledGrid.h"
#include "CCActionInstant.h" #include "CCActionInstant.h"
#include "CCActionTween.h" #include "CCActionTween.h"
@ -52,15 +52,15 @@ THE SOFTWARE.
#include "CCAtlasNode.h" #include "CCAtlasNode.h"
// cocoa // cocoa
#include "CCAffineTransform.h" #include "CCAffineTransform.h"
#include "CCDictionary.h" #include "CCDictionary.h"
#include "CCObject.h" #include "CCObject.h"
#include "CCArray.h" #include "CCArray.h"
#include "CCGeometry.h" #include "CCGeometry.h"
#include "CCSet.h" #include "CCSet.h"
#include "CCAutoreleasePool.h" #include "CCAutoreleasePool.h"
#include "CCInteger.h" #include "CCInteger.h"
#include "CCString.h" #include "CCString.h"
#include "CCData.h" #include "CCData.h"
#include "CCNS.h" #include "CCNS.h"
#include "CCZone.h" #include "CCZone.h"
@ -70,11 +70,11 @@ THE SOFTWARE.
#include "CCGrid.h" #include "CCGrid.h"
// include // include
#include "CCEventType.h" #include "CCEventType.h"
#include "CCProtocols.h" #include "CCProtocols.h"
#include "ccConfig.h" #include "ccConfig.h"
#include "ccMacros.h" #include "ccMacros.h"
#include "ccTypes.h" #include "ccTypes.h"
#include "cocos2dExt.h" #include "cocos2dExt.h"
// kazmath // kazmath
@ -86,15 +86,15 @@ THE SOFTWARE.
#include "CCKeypadDispatcher.h" #include "CCKeypadDispatcher.h"
// label_nodes // label_nodes
#include "CCLabelAtlas.h" #include "CCLabelAtlas.h"
#include "CCLabelTTF.h" #include "CCLabelTTF.h"
#include "CCLabelBMFont.h" #include "CCLabelBMFont.h"
// layers_scenes_transitions_nodes // layers_scenes_transitions_nodes
#include "CCLayer.h" #include "CCLayer.h"
#include "CCScene.h" #include "CCScene.h"
#include "CCTransition.h" #include "CCTransition.h"
#include "CCTransitionPageTurn.h" #include "CCTransitionPageTurn.h"
#include "CCTransitionProgress.h" #include "CCTransitionProgress.h"
// menu_nodes // menu_nodes
@ -107,8 +107,8 @@ THE SOFTWARE.
#include "CCRenderTexture.h" #include "CCRenderTexture.h"
// particle_nodes // particle_nodes
#include "CCParticleBatchNode.h" #include "CCParticleBatchNode.h"
#include "CCParticleSystem.h" #include "CCParticleSystem.h"
#include "CCParticleExamples.h" #include "CCParticleExamples.h"
#include "CCParticleSystemQuad.h" #include "CCParticleSystemQuad.h"
@ -135,18 +135,18 @@ THE SOFTWARE.
#include "ccShaders.h" #include "ccShaders.h"
// sprite_nodes // sprite_nodes
#include "CCAnimation.h" #include "CCAnimation.h"
#include "CCAnimationCache.h" #include "CCAnimationCache.h"
#include "CCSprite.h" #include "CCSprite.h"
#include "CCSpriteBatchNode.h" #include "CCSpriteBatchNode.h"
#include "CCSpriteFrame.h" #include "CCSpriteFrame.h"
#include "CCSpriteFrameCache.h" #include "CCSpriteFrameCache.h"
// support // support
#include "CCPointExtension.h" #include "CCPointExtension.h"
#include "CCProfiling.h" #include "CCProfiling.h"
#include "CCUserDefault.h" #include "CCUserDefault.h"
#include "CCVertex.h" #include "CCVertex.h"
// text_input_node // text_input_node
#include "CCIMEDelegate.h" #include "CCIMEDelegate.h"
@ -160,17 +160,17 @@ THE SOFTWARE.
#include "CCTexturePVR.h" #include "CCTexturePVR.h"
// tileMap_parallax_nodes // tileMap_parallax_nodes
#include "CCParallaxNode.h" #include "CCParallaxNode.h"
#include "CCTMXLayer.h" #include "CCTMXLayer.h"
#include "CCTMXObjectGroup.h" #include "CCTMXObjectGroup.h"
#include "CCTMXTiledMap.h" #include "CCTMXTiledMap.h"
#include "CCTMXXMLParser.h" #include "CCTMXXMLParser.h"
#include "CCTileMapAtlas.h" #include "CCTileMapAtlas.h"
// touch_dispatcher // touch_dispatcher
#include "CCTouch.h" #include "CCTouch.h"
#include "CCTouchDelegateProtocol.h" #include "CCTouchDelegateProtocol.h"
#include "CCTouchDispatcher.h" #include "CCTouchDispatcher.h"
#include "CCTouchHandler.h" #include "CCTouchHandler.h"
// root // root

View File

@ -954,9 +954,9 @@ void CCLabelBMFont::setString(const char *newString)
void CCLabelBMFont::setString(const char *newString, bool fromUpdate) void CCLabelBMFont::setString(const char *newString, bool fromUpdate)
{ {
CC_SAFE_DELETE_ARRAY(m_sString); CC_SAFE_DELETE_ARRAY(m_sString);
m_sString = cc_utf8_from_cstr(newString); m_sString = cc_utf8_from_cstr(newString);
m_sString_initial = newString; m_sString_initial = newString;
updateString(fromUpdate); updateString(fromUpdate);
} }
@ -1082,11 +1082,11 @@ void CCLabelBMFont::updateLabel()
vector<unsigned short> str_whole = cc_utf8_vec_from_cstr(m_sString); vector<unsigned short> str_whole = cc_utf8_vec_from_cstr(m_sString);
unsigned int stringLength = str_whole.size(); unsigned int stringLength = str_whole.size();
vector<unsigned short> multiline_string; vector<unsigned short> multiline_string;
multiline_string.reserve( stringLength ); multiline_string.reserve( stringLength );
vector<unsigned short> last_word; vector<unsigned short> last_word;
last_word.reserve( stringLength ); last_word.reserve( stringLength );
unsigned int line = 1, i = 0; unsigned int line = 1, i = 0;
bool start_line = false, start_word = false; bool start_line = false, start_word = false;
float startOfLine = -1, startOfWord = -1; float startOfLine = -1, startOfWord = -1;
int skip = 0; int skip = 0;
@ -1108,7 +1108,7 @@ void CCLabelBMFont::updateLabel()
if (!start_word) if (!start_word)
{ {
startOfWord = getLetterPosXLeft( characterSprite ); startOfWord = getLetterPosXLeft( characterSprite );
start_word = true; start_word = true;
} }
if (!start_line) if (!start_line)
@ -1122,15 +1122,15 @@ void CCLabelBMFont::updateLabel()
{ {
cc_utf8_trim_ws(&last_word); cc_utf8_trim_ws(&last_word);
last_word.push_back('\n'); last_word.push_back('\n');
multiline_string.insert(multiline_string.end(), last_word.begin(), last_word.end()); multiline_string.insert(multiline_string.end(), last_word.begin(), last_word.end());
last_word.clear(); last_word.clear();
start_word = false; start_word = false;
start_line = false; start_line = false;
startOfWord = -1; startOfWord = -1;
startOfLine = -1; startOfLine = -1;
i++; i++;
line++; line++;
if (i >= stringLength || i < 0) if (i >= stringLength || i < 0)
break; break;
@ -1139,7 +1139,7 @@ void CCLabelBMFont::updateLabel()
if (!startOfWord) if (!startOfWord)
{ {
startOfWord = getLetterPosXLeft( characterSprite ); startOfWord = getLetterPosXLeft( characterSprite );
start_word = true; start_word = true;
} }
if (!startOfLine) if (!startOfLine)
@ -1162,7 +1162,7 @@ void CCLabelBMFont::updateLabel()
} }
// Out of bounds. // Out of bounds.
if ( getLetterPosXRight( characterSprite ) - startOfLine > m_fWidth ) if ( getLetterPosXRight( characterSprite ) - startOfLine > m_fWidth )
{ {
if (!m_bLineBreakWithoutSpaces) if (!m_bLineBreakWithoutSpaces)
{ {
@ -1200,7 +1200,7 @@ void CCLabelBMFont::updateLabel()
if (!startOfWord) if (!startOfWord)
{ {
startOfWord = getLetterPosXLeft( characterSprite ); startOfWord = getLetterPosXLeft( characterSprite );
start_word = true; start_word = true;
} }
if (!startOfLine) if (!startOfLine)
@ -1251,13 +1251,13 @@ void CCLabelBMFont::updateLabel()
if (m_sString[ctr] == '\n' || m_sString[ctr] == 0) if (m_sString[ctr] == '\n' || m_sString[ctr] == 0)
{ {
float lineWidth = 0.0f; float lineWidth = 0.0f;
unsigned int line_length = last_line.size(); unsigned int line_length = last_line.size();
int index = i + line_length - 1 + lineNumber; int index = i + line_length - 1 + lineNumber;
if (index < 0) continue; if (index < 0) continue;
CCSprite* lastChar = (CCSprite*)getChildByTag(index); CCSprite* lastChar = (CCSprite*)getChildByTag(index);
if ( lastChar == NULL ) if ( lastChar == NULL )
continue; continue;
lineWidth = lastChar->getPosition().x + lastChar->getContentSize().width/2.0f; lineWidth = lastChar->getPosition().x + lastChar->getContentSize().width/2.0f;
@ -1318,30 +1318,30 @@ void CCLabelBMFont::setLineBreakWithoutSpace( bool breakWithoutSpace )
void CCLabelBMFont::setScale(float scale) void CCLabelBMFont::setScale(float scale)
{ {
CCSpriteBatchNode::setScale(scale); CCSpriteBatchNode::setScale(scale);
updateLabel(); updateLabel();
} }
void CCLabelBMFont::setScaleX(float scaleX) void CCLabelBMFont::setScaleX(float scaleX)
{ {
CCSpriteBatchNode::setScaleX(scaleX); CCSpriteBatchNode::setScaleX(scaleX);
updateLabel(); updateLabel();
} }
void CCLabelBMFont::setScaleY(float scaleY) void CCLabelBMFont::setScaleY(float scaleY)
{ {
CCSpriteBatchNode::setScaleY(scaleY); CCSpriteBatchNode::setScaleY(scaleY);
updateLabel(); updateLabel();
} }
float CCLabelBMFont::getLetterPosXLeft( CCSprite* sp ) float CCLabelBMFont::getLetterPosXLeft( CCSprite* sp )
{ {
return sp->getPosition().x * m_fScaleX - (sp->getContentSize().width * m_fScaleX * sp->getAnchorPoint().x); return sp->getPosition().x * m_fScaleX - (sp->getContentSize().width * m_fScaleX * sp->getAnchorPoint().x);
} }
float CCLabelBMFont::getLetterPosXRight( CCSprite* sp ) float CCLabelBMFont::getLetterPosXRight( CCSprite* sp )
{ {
return sp->getPosition().x * m_fScaleX + (sp->getContentSize().width * m_fScaleX * sp->getAnchorPoint().x); return sp->getPosition().x * m_fScaleX + (sp->getContentSize().width * m_fScaleX * sp->getAnchorPoint().x);
} }
//LabelBMFont - Debug draw //LabelBMFont - Debug draw
#if CC_LABELBMFONT_DEBUG_DRAW #if CC_LABELBMFONT_DEBUG_DRAW

View File

@ -198,9 +198,9 @@ public:
virtual void setAlignment(CCTextAlignment alignment); virtual void setAlignment(CCTextAlignment alignment);
virtual void setWidth(float width); virtual void setWidth(float width);
virtual void setLineBreakWithoutSpace(bool breakWithoutSpace); virtual void setLineBreakWithoutSpace(bool breakWithoutSpace);
virtual void setScale(float scale); virtual void setScale(float scale);
virtual void setScaleX(float scaleX); virtual void setScaleX(float scaleX);
virtual void setScaleY(float scaleY); virtual void setScaleY(float scaleY);
#if CC_LABELBMFONT_DEBUG_DRAW #if CC_LABELBMFONT_DEBUG_DRAW
virtual void draw(); virtual void draw();
@ -208,8 +208,8 @@ public:
private: private:
char * atlasNameFromFntFile(const char *fntFile); char * atlasNameFromFntFile(const char *fntFile);
int kerningAmountForFirst(unsigned short first, unsigned short second); int kerningAmountForFirst(unsigned short first, unsigned short second);
float getLetterPosXLeft( CCSprite* characterSprite ); float getLetterPosXLeft( CCSprite* characterSprite );
float getLetterPosXRight( CCSprite* characterSprite ); float getLetterPosXRight( CCSprite* characterSprite );
}; };

View File

@ -229,19 +229,19 @@ void CCRenderTexture::end(bool bIsTOCacheTexture)
{ {
CC_SAFE_DELETE(m_pUITextureImage); CC_SAFE_DELETE(m_pUITextureImage);
// to get the rendered texture data // to get the rendered texture data
const CCSize& s = m_pTexture->getContentSizeInPixels(); const CCSize& s = m_pTexture->getContentSizeInPixels();
m_pUITextureImage = newCCImage(); m_pUITextureImage = newCCImage();
if (m_pUITextureImage) if (m_pUITextureImage)
{ {
VolatileTexture::addDataTexture(m_pTexture, m_pUITextureImage->getData(), kTexture2DPixelFormat_RGBA8888, s); VolatileTexture::addDataTexture(m_pTexture, m_pUITextureImage->getData(), kTexture2DPixelFormat_RGBA8888, s);
} }
else else
{ {
CCLOG("Cache rendertexture failed!"); CCLOG("Cache rendertexture failed!");
} }
} }
#endif #endif
} }

View File

@ -1,28 +1,28 @@
#ifndef __CCPLATFORMDEFINE_H__ #ifndef __CCPLATFORMDEFINE_H__
#define __CCPLATFORMDEFINE_H__ #define __CCPLATFORMDEFINE_H__
#define CC_DLL #define CC_DLL
#define CC_ASSERT(cond) \ #define CC_ASSERT(cond) \
if (! (cond)) \ if (! (cond)) \
{ \ { \
char content[100]; \ char content[100]; \
sprintf(content, "%s function:%s line:%d", __FILE__, __FUNCTION__, __LINE__ - 3); \ sprintf(content, "%s function:%s line:%d", __FILE__, __FUNCTION__, __LINE__ - 3); \
CCMessageBox(content, "Assert error"); \ CCMessageBox(content, "Assert error"); \
} }
#define CC_UNUSED_PARAM(unusedparam) (void)unusedparam #define CC_UNUSED_PARAM(unusedparam) (void)unusedparam
/* Define NULL pointer value */ /* Define NULL pointer value */
#ifndef NULL #ifndef NULL
#ifdef __cplusplus #ifdef __cplusplus
#define NULL 0 #define NULL 0
#else #else
#define NULL ((void *)0) #define NULL ((void *)0)
#endif #endif
#endif #endif
#endif /* __CCPLATFORMDEFINE_H__*/ #endif /* __CCPLATFORMDEFINE_H__*/

View File

@ -1,28 +1,28 @@
#ifndef __CCPLATFORMDEFINE_H__ #ifndef __CCPLATFORMDEFINE_H__
#define __CCPLATFORMDEFINE_H__ #define __CCPLATFORMDEFINE_H__
#define CC_DLL #define CC_DLL
#define CC_ASSERT(cond) \ #define CC_ASSERT(cond) \
if (! (cond)) \ if (! (cond)) \
{ \ { \
char content[100]; \ char content[100]; \
sprintf(content, "%s function:%s line:%d", __FILE__, __FUNCTION__, __LINE__ - 3); \ sprintf(content, "%s function:%s line:%d", __FILE__, __FUNCTION__, __LINE__ - 3); \
CCMessageBox(content, "Assert error"); \ CCMessageBox(content, "Assert error"); \
} }
#define CC_UNUSED_PARAM(unusedparam) (void)unusedparam #define CC_UNUSED_PARAM(unusedparam) (void)unusedparam
/* Define NULL pointer value */ /* Define NULL pointer value */
#ifndef NULL #ifndef NULL
#ifdef __cplusplus #ifdef __cplusplus
#define NULL 0 #define NULL 0
#else #else
#define NULL ((void *)0) #define NULL ((void *)0)
#endif #endif
#endif #endif
#endif /* __CCPLATFORMDEFINE_H__*/ #endif /* __CCPLATFORMDEFINE_H__*/

View File

@ -1,26 +1,26 @@
#ifndef __CCPLATFORMDEFINE_H__ #ifndef __CCPLATFORMDEFINE_H__
#define __CCPLATFORMDEFINE_H__ #define __CCPLATFORMDEFINE_H__
#if defined(_USRDLL) #if defined(_USRDLL)
#define CC_DLL __declspec(dllexport) #define CC_DLL __declspec(dllexport)
#else /* use a DLL library */ #else /* use a DLL library */
#define CC_DLL __declspec(dllimport) #define CC_DLL __declspec(dllimport)
#endif #endif
#include <assert.h> #include <assert.h>
#define CC_ASSERT(cond) assert(cond) #define CC_ASSERT(cond) assert(cond)
#define CC_UNUSED_PARAM(unusedparam) (void)unusedparam #define CC_UNUSED_PARAM(unusedparam) (void)unusedparam
/* Define NULL pointer value */ /* Define NULL pointer value */
#ifndef NULL #ifndef NULL
#ifdef __cplusplus #ifdef __cplusplus
#define NULL 0 #define NULL 0
#else #else
#define NULL ((void *)0) #define NULL ((void *)0)
#endif #endif
#endif #endif
#endif /* __CCPLATFORMDEFINE_H__*/ #endif /* __CCPLATFORMDEFINE_H__*/

View File

@ -1,129 +1,129 @@
#include "MutiTouchTest.h" #include "MutiTouchTest.h"
static ccColor3B s_TouchColors[CC_MAX_TOUCHES] = { static ccColor3B s_TouchColors[CC_MAX_TOUCHES] = {
ccYELLOW, ccYELLOW,
ccBLUE, ccBLUE,
ccGREEN, ccGREEN,
ccRED, ccRED,
ccMAGENTA ccMAGENTA
}; };
class TouchPoint : public CCNode class TouchPoint : public CCNode
{ {
public: public:
TouchPoint() TouchPoint()
{ {
setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionTextureColor)); setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionTextureColor));
} }
virtual void draw() virtual void draw()
{ {
ccDrawColor4B(m_TouchColor.r, m_TouchColor.g, m_TouchColor.b, 255); ccDrawColor4B(m_TouchColor.r, m_TouchColor.g, m_TouchColor.b, 255);
glLineWidth(10); glLineWidth(10);
ccDrawLine( ccp(0, m_pTouchPoint.y), ccp(getContentSize().width, m_pTouchPoint.y) ); ccDrawLine( ccp(0, m_pTouchPoint.y), ccp(getContentSize().width, m_pTouchPoint.y) );
ccDrawLine( ccp(m_pTouchPoint.x, 0), ccp(m_pTouchPoint.x, getContentSize().height) ); ccDrawLine( ccp(m_pTouchPoint.x, 0), ccp(m_pTouchPoint.x, getContentSize().height) );
glLineWidth(1); glLineWidth(1);
ccPointSize(30); ccPointSize(30);
ccDrawPoint(m_pTouchPoint); ccDrawPoint(m_pTouchPoint);
} }
void setTouchPos(const CCPoint& pt) void setTouchPos(const CCPoint& pt)
{ {
m_pTouchPoint = pt; m_pTouchPoint = pt;
} }
void setTouchColor(ccColor3B color) void setTouchColor(ccColor3B color)
{ {
m_TouchColor = color; m_TouchColor = color;
} }
static TouchPoint* touchPointWithParent(CCNode* pParent) static TouchPoint* touchPointWithParent(CCNode* pParent)
{ {
TouchPoint* pRet = new TouchPoint(); TouchPoint* pRet = new TouchPoint();
pRet->setContentSize(pParent->getContentSize()); pRet->setContentSize(pParent->getContentSize());
pRet->setAnchorPoint(ccp(0.0f, 0.0f)); pRet->setAnchorPoint(ccp(0.0f, 0.0f));
pRet->autorelease(); pRet->autorelease();
return pRet; return pRet;
} }
private: private:
CCPoint m_pTouchPoint; CCPoint m_pTouchPoint;
ccColor3B m_TouchColor; ccColor3B m_TouchColor;
}; };
bool MutiTouchTestLayer::init() bool MutiTouchTestLayer::init()
{ {
if (CCLayer::init()) if (CCLayer::init())
{ {
setIsTouchEnabled(true); setIsTouchEnabled(true);
return true; return true;
} }
return false; return false;
} }
static CCDictionary s_dic; static CCDictionary s_dic;
void MutiTouchTestLayer::registerWithTouchDispatcher(void) void MutiTouchTestLayer::registerWithTouchDispatcher(void)
{ {
CCDirector::sharedDirector()->getTouchDispatcher()->addStandardDelegate(this, 0); CCDirector::sharedDirector()->getTouchDispatcher()->addStandardDelegate(this, 0);
} }
void MutiTouchTestLayer::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent) void MutiTouchTestLayer::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent)
{ {
CCSetIterator iter = pTouches->begin(); CCSetIterator iter = pTouches->begin();
for (; iter != pTouches->end(); iter++) for (; iter != pTouches->end(); iter++)
{ {
CCTouch* pTouch = (CCTouch*)(*iter); CCTouch* pTouch = (CCTouch*)(*iter);
TouchPoint* pTouchPoint = TouchPoint::touchPointWithParent(this); TouchPoint* pTouchPoint = TouchPoint::touchPointWithParent(this);
CCPoint location = pTouch->locationInView(); CCPoint location = pTouch->locationInView();
location = CCDirector::sharedDirector()->convertToGL(location); location = CCDirector::sharedDirector()->convertToGL(location);
pTouchPoint->setTouchPos(location); pTouchPoint->setTouchPos(location);
pTouchPoint->setTouchColor(s_TouchColors[pTouch->getID()]); pTouchPoint->setTouchColor(s_TouchColors[pTouch->getID()]);
addChild(pTouchPoint); addChild(pTouchPoint);
s_dic.setObject(pTouchPoint, pTouch->getID()); s_dic.setObject(pTouchPoint, pTouch->getID());
} }
} }
void MutiTouchTestLayer::ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent) void MutiTouchTestLayer::ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent)
{ {
CCSetIterator iter = pTouches->begin(); CCSetIterator iter = pTouches->begin();
for (; iter != pTouches->end(); iter++) for (; iter != pTouches->end(); iter++)
{ {
CCTouch* pTouch = (CCTouch*)(*iter); CCTouch* pTouch = (CCTouch*)(*iter);
TouchPoint* pTP = (TouchPoint*)s_dic.objectForKey(pTouch->getID()); TouchPoint* pTP = (TouchPoint*)s_dic.objectForKey(pTouch->getID());
CCPoint location = pTouch->locationInView(); CCPoint location = pTouch->locationInView();
location = CCDirector::sharedDirector()->convertToGL(location); location = CCDirector::sharedDirector()->convertToGL(location);
pTP->setTouchPos(location); pTP->setTouchPos(location);
} }
} }
void MutiTouchTestLayer::ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent) void MutiTouchTestLayer::ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent)
{ {
CCSetIterator iter = pTouches->begin(); CCSetIterator iter = pTouches->begin();
for (; iter != pTouches->end(); iter++) for (; iter != pTouches->end(); iter++)
{ {
CCTouch* pTouch = (CCTouch*)(*iter); CCTouch* pTouch = (CCTouch*)(*iter);
TouchPoint* pTP = (TouchPoint*)s_dic.objectForKey(pTouch->getID()); TouchPoint* pTP = (TouchPoint*)s_dic.objectForKey(pTouch->getID());
removeChild(pTP, true); removeChild(pTP, true);
s_dic.removeObjectForKey(pTouch->getID()); s_dic.removeObjectForKey(pTouch->getID());
} }
} }
void MutiTouchTestLayer::ccTouchesCancelled(CCSet *pTouches, CCEvent *pEvent) void MutiTouchTestLayer::ccTouchesCancelled(CCSet *pTouches, CCEvent *pEvent)
{ {
ccTouchesEnded(pTouches, pEvent); ccTouchesEnded(pTouches, pEvent);
} }
void MutiTouchTestScene::runThisTest() void MutiTouchTestScene::runThisTest()
{ {
MutiTouchTestLayer* pLayer = MutiTouchTestLayer::node(); MutiTouchTestLayer* pLayer = MutiTouchTestLayer::node();
addChild(pLayer, 0); addChild(pLayer, 0);
CCDirector::sharedDirector()->replaceScene(this); CCDirector::sharedDirector()->replaceScene(this);
} }

View File

@ -1,26 +1,26 @@
#ifndef __MUTITOUCHTEST_H__ #ifndef __MUTITOUCHTEST_H__
#define __MUTITOUCHTEST_H__ #define __MUTITOUCHTEST_H__
#include "../testBasic.h" #include "../testBasic.h"
class MutiTouchTestLayer : public CCLayer class MutiTouchTestLayer : public CCLayer
{ {
public: public:
bool init(); bool init();
virtual void registerWithTouchDispatcher(void); virtual void registerWithTouchDispatcher(void);
virtual void ccTouchesBegan(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent); virtual void ccTouchesBegan(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent);
virtual void ccTouchesMoved(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent); virtual void ccTouchesMoved(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent);
virtual void ccTouchesEnded(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent); virtual void ccTouchesEnded(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent);
virtual void ccTouchesCancelled(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent); virtual void ccTouchesCancelled(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent);
LAYER_NODE_FUNC(MutiTouchTestLayer) LAYER_NODE_FUNC(MutiTouchTestLayer)
}; };
class MutiTouchTestScene : public TestScene class MutiTouchTestScene : public TestScene
{ {
public: public:
virtual void runThisTest(); virtual void runThisTest();
}; };
#endif /* __MUTITOUCHTEST_H__ */ #endif /* __MUTITOUCHTEST_H__ */