From 7c5784005c27c9df2556137f3cf6a9d72a8b884d Mon Sep 17 00:00:00 2001 From: Jason Xu Date: Sat, 23 Nov 2013 00:07:15 +0800 Subject: [PATCH 01/30] Fix: on android, Device::setAccelerometerInterval will causes dead loop --- cocos/2d/platform/android/CCDevice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/2d/platform/android/CCDevice.cpp b/cocos/2d/platform/android/CCDevice.cpp index 96b1c8e597..6f04c55e57 100644 --- a/cocos/2d/platform/android/CCDevice.cpp +++ b/cocos/2d/platform/android/CCDevice.cpp @@ -28,7 +28,7 @@ void Device::setAccelerometerEnabled(bool isEnabled) void Device::setAccelerometerInterval(float interval) { - setAccelerometerInterval(interval); + ::setAccelerometerInterval(interval); } NS_CC_END From 0d9cd9784b5caddb8a2a64d5020cd648aa7e609b Mon Sep 17 00:00:00 2001 From: signmotion Date: Sat, 23 Nov 2013 07:23:06 +0200 Subject: [PATCH 02/30] * Fixed warnings in VS2012: C4018 (signed/unsigned mismatch) and C4244 (conversion from 'double' to 'float'). --- cocos/gui/UIListView.cpp | 3 ++- cocos/network/SocketIO.cpp | 2 +- .../TestCpp/Classes/PerformanceTest/PerformanceSpriteTest.cpp | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cocos/gui/UIListView.cpp b/cocos/gui/UIListView.cpp index 8e45662c3e..dbc2a1f840 100644 --- a/cocos/gui/UIListView.cpp +++ b/cocos/gui/UIListView.cpp @@ -301,7 +301,8 @@ void UIListView::removeLastItem() UIWidget* UIListView::getItem(unsigned int index) { - if ((int)index < 0 || index >= _items->count()) + // @todo Signed/unsigned mishmash. Index is must be unsigned int always. Yes? + if ( ((int)index < 0) || ((int)index >= _items->count()) ) { return nullptr; } diff --git a/cocos/network/SocketIO.cpp b/cocos/network/SocketIO.cpp index bb9acff3e1..d4d66ac137 100644 --- a/cocos/network/SocketIO.cpp +++ b/cocos/network/SocketIO.cpp @@ -367,7 +367,7 @@ void SIOClientImpl::onOpen(WebSocket* ws) c->onOpen(); } - Director::getInstance()->getScheduler()->scheduleSelector(schedule_selector(SIOClientImpl::heartbeat), this, (_heartbeat * .9), false); + Director::getInstance()->getScheduler()->scheduleSelector(schedule_selector(SIOClientImpl::heartbeat), this, (_heartbeat * .9f), false); log("SIOClientImpl::onOpen socket connected!"); } diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceSpriteTest.cpp b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceSpriteTest.cpp index ccf4ca602d..fd7fd7e042 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceSpriteTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceSpriteTest.cpp @@ -519,7 +519,7 @@ void SpriteMainScene::onEnter() auto director = Director::getInstance(); auto sched = director->getScheduler(); - sched->scheduleSelector(SEL_SCHEDULE(&SpriteMainScene::updateAutoTest), this, 0.2, false); + sched->scheduleSelector(SEL_SCHEDULE(&SpriteMainScene::updateAutoTest), this, 0.2f, false); } } From 5f74496d7a038c3f77c7fce2691c0459097d5c3b Mon Sep 17 00:00:00 2001 From: signmotion Date: Mon, 25 Nov 2013 10:00:09 +0200 Subject: [PATCH 03/30] - Reverted modification. See below. > @@ -301,7 +301,8 @@ void UIListView::removeLastItem() > > UIWidget* UIListView::getItem(unsigned int index) > { > - if ((int)index < 0 || index >= _items->count()) > + // @todo Signed/unsigned mishmash. Index is must be unsigned int always. Yes? > + if ( ((int)index < 0) || ((int)index >= _items->count()) ) May be we should change the type of parameter. So could you please revert the modification of this file? --- cocos/gui/UIListView.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cocos/gui/UIListView.cpp b/cocos/gui/UIListView.cpp index dbc2a1f840..8e45662c3e 100644 --- a/cocos/gui/UIListView.cpp +++ b/cocos/gui/UIListView.cpp @@ -301,8 +301,7 @@ void UIListView::removeLastItem() UIWidget* UIListView::getItem(unsigned int index) { - // @todo Signed/unsigned mishmash. Index is must be unsigned int always. Yes? - if ( ((int)index < 0) || ((int)index >= _items->count()) ) + if ((int)index < 0 || index >= _items->count()) { return nullptr; } From 86074c23d8aaf8ad8d87659b543bc952029b1caa Mon Sep 17 00:00:00 2001 From: boyu0 Date: Fri, 29 Nov 2013 14:31:42 +0800 Subject: [PATCH 04/30] issue #2345: class Image add tga image format support. --- cocos/2d/TGAlib.cpp | 55 +++++---- cocos/2d/TGAlib.h | 3 + cocos/2d/platform/CCImage.h | 5 + cocos/2d/platform/CCImageCommon_cpp.h | 105 +++++++++++++++++- .../Classes/Texture2dTest/Texture2dTest.cpp | 24 ++++ .../Classes/Texture2dTest/Texture2dTest.h | 9 ++ 6 files changed, 174 insertions(+), 27 deletions(-) diff --git a/cocos/2d/TGAlib.cpp b/cocos/2d/TGAlib.cpp index 160be2a907..fc870b9e0c 100644 --- a/cocos/2d/TGAlib.cpp +++ b/cocos/2d/TGAlib.cpp @@ -191,67 +191,63 @@ void tgaFlipImage( tImageTGA *psInfo ) free(row); psInfo->flipped = 0; } - -// this is the function to call when we want to load an image -tImageTGA * tgaLoad(const char *filename) + +tImageTGA* tgaLoadBuffer(unsigned char* buffer, long size) { int mode,total; - tImageTGA *info = NULL; + tImageTGA *info = nullptr; - long size = 0; - unsigned char* pBuffer = FileUtils::getInstance()->getFileData(filename, "rb", &size); - do { - CC_BREAK_IF(! pBuffer); + CC_BREAK_IF(! buffer); info = (tImageTGA *)malloc(sizeof(tImageTGA)); - + // get the file header info - if (! tgaLoadHeader(pBuffer, size, info)) + if (! tgaLoadHeader(buffer, size, info)) { info->status = TGA_ERROR_MEMORY; break; } - + // check if the image is color indexed if (info->type == 1) { info->status = TGA_ERROR_INDEXED_COLOR; break; } - + // check for other types (compressed images) if ((info->type != 2) && (info->type !=3) && (info->type !=10) ) { info->status = TGA_ERROR_COMPRESSED_FILE; break; } - + // mode equals the number of image components mode = info->pixelDepth / 8; // total is the number of unsigned chars to read total = info->height * info->width * mode; // allocate memory for image pixels info->imageData = (unsigned char *)malloc(sizeof(unsigned char) * total); - + // check to make sure we have the memory required if (info->imageData == NULL) { info->status = TGA_ERROR_MEMORY; break; } - + bool bLoadImage = false; // finally load the image pixels if ( info->type == 10 ) { - bLoadImage = tgaLoadRLEImageData(pBuffer, size, info); + bLoadImage = tgaLoadRLEImageData(buffer, size, info); } else { - bLoadImage = tgaLoadImageData(pBuffer, size, info); + bLoadImage = tgaLoadImageData(buffer, size, info); } - + // check for errors when reading the pixels if (! bLoadImage) { @@ -259,7 +255,7 @@ tImageTGA * tgaLoad(const char *filename) break; } info->status = TGA_OK; - + if ( info->flipped ) { tgaFlipImage( info ); @@ -269,12 +265,27 @@ tImageTGA * tgaLoad(const char *filename) } } } while(0); - - free(pBuffer); - + return info; } +// this is the function to call when we want to load an image +tImageTGA * tgaLoad(const char *filename) +{ + long size = 0; + unsigned char* buffer = FileUtils::getInstance()->getFileData(filename, "rb", &size); + + if (buffer != nullptr) + { + tImageTGA* data = tgaLoadBuffer(buffer, size); + free(buffer); + + return data; + } + + return nullptr; +} + // converts RGB to grayscale void tgaRGBtogreyscale(tImageTGA *psInfo) { diff --git a/cocos/2d/TGAlib.h b/cocos/2d/TGAlib.h index 28a19324b1..0f0c2012f1 100644 --- a/cocos/2d/TGAlib.h +++ b/cocos/2d/TGAlib.h @@ -58,6 +58,9 @@ bool tgaLoadHeader(unsigned char *Buffer, unsigned long bufSize, tImageTGA *psIn /// loads the image pixels. You shouldn't call this function directly bool tgaLoadImageData(unsigned char *Buffer, unsigned long bufSize, tImageTGA *psInfo); +/// this is the function to call when we want to load an image buffer. +tImageTGA* tgaLoadBuffer(unsigned char* buffer, long size); + /// this is the function to call when we want to load an image tImageTGA * tgaLoad(const char *filename); diff --git a/cocos/2d/platform/CCImage.h b/cocos/2d/platform/CCImage.h index 781689f238..ba90d380e3 100644 --- a/cocos/2d/platform/CCImage.h +++ b/cocos/2d/platform/CCImage.h @@ -85,6 +85,8 @@ public: S3TC, //! ATITC ATITC, + //! TGA + TGA, //! Raw Data RAW_DATA, //! Unknown format @@ -206,6 +208,8 @@ protected: bool initWithETCData(const unsigned char * data, int dataLen); bool initWithS3TCData(const unsigned char * data, int dataLen); bool initWithATITCData(const unsigned char *data, int dataLen); + typedef struct sImageTGA tImageTGA; + bool initWithTGAData(tImageTGA* tgaData); bool saveImageToPNG(const std::string& filePath, bool isToRGB = true); bool saveImageToJPG(const std::string& filePath); @@ -227,6 +231,7 @@ private: int _numberOfMipmaps; // false if we cann't auto detect the image is premultiplied or not. bool _hasPremultipliedAlpha; + std::string _filePath; private: diff --git a/cocos/2d/platform/CCImageCommon_cpp.h b/cocos/2d/platform/CCImageCommon_cpp.h index ba041dd0c9..0697a7c062 100644 --- a/cocos/2d/platform/CCImageCommon_cpp.h +++ b/cocos/2d/platform/CCImageCommon_cpp.h @@ -25,6 +25,7 @@ THE SOFTWARE. #include "CCImage.h" +#include #include #include @@ -42,6 +43,7 @@ extern "C" } #include "s3tc.h" #include "atitc.h" +#include "TGAlib.h" #include "decode.h" @@ -394,7 +396,7 @@ Image::~Image() bool Image::initWithImageFile(const char * strPath) { bool bRet = false; - std::string fullPath = FileUtils::getInstance()->fullPathForFilename(strPath); + _filePath = FileUtils::getInstance()->fullPathForFilename(strPath); #ifdef EMSCRIPTEN // Emscripten includes a re-implementation of SDL that uses HTML5 canvas @@ -417,7 +419,7 @@ bool Image::initWithImageFile(const char * strPath) SDL_FreeSurface(iSurf); #else long bufferLen = 0; - unsigned char* buffer = FileUtils::getInstance()->getFileData(fullPath.c_str(), "rb", &bufferLen); + unsigned char* buffer = FileUtils::getInstance()->getFileData(_filePath.c_str(), "rb", &bufferLen); if (buffer != nullptr && bufferLen > 0) { @@ -434,6 +436,7 @@ bool Image::initWithImageFileThreadSafe(const char *fullpath) { bool ret = false; long dataLen = 0; + _filePath = fullpath; #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) FileUtilsAndroid *fileUitls = (FileUtilsAndroid*)FileUtils::getInstance(); unsigned char *buffer = fileUitls->getFileDataForAsync(fullpath, "rb", &dataLen); @@ -503,8 +506,22 @@ bool Image::initWithImageData(const unsigned char * data, long dataLen) ret = initWithATITCData(unpackedData, unpackedLen); break; default: - CCAssert(false, "unsupport image format!"); - break; + { + // load and detect image format + tImageTGA* tgaData = tgaLoadBuffer(unpackedData, unpackedLen); + + if (tgaData != nullptr && tgaData->status == TGA_OK) + { + ret = initWithTGAData(tgaData); + } + else + { + CCAssert(false, "unsupport image format!"); + } + + free(tgaData); + break; + } } if(unpackedData != data) @@ -613,7 +630,6 @@ bool Image::isPvr(const unsigned char * data, int dataLen) return memcmp(&headerv2->pvrTag, gPVRTexIdentifier, strlen(gPVRTexIdentifier)) == 0 || CC_SWAP_INT32_BIG_TO_HOST(headerv3->version) == 0x50565203; } - Image::Format Image::detectFormat(const unsigned char * data, int dataLen) { if (isPng(data, dataLen)) @@ -1460,6 +1476,85 @@ bool Image::initWithETCData(const unsigned char * data, int dataLen) return false; } +bool Image::initWithTGAData(tImageTGA* tgaData) +{ + bool ret = false; + + do + { + CC_BREAK_IF(tgaData == nullptr); + + // tgaLoadBuffer only support type 2, 3, 10 + if (2 == tgaData->type || 10 == tgaData->type) + { + // true color + // unsupport RGB555 + if (tgaData->pixelDepth == 16) + { + _renderFormat = Texture2D::PixelFormat::RGB5A1; + } + else if(tgaData->pixelDepth == 24) + { + _renderFormat = Texture2D::PixelFormat::RGB888; + } + else if(tgaData->pixelDepth == 32) + { + _renderFormat = Texture2D::PixelFormat::RGBA8888; + } + else + { + CCLOG("Image WARNING: unsupport true color tga data pixel format. FILE: %s", _filePath.c_str()); + break; + } + } + else if(3 == tgaData->type) + { + // gray + if (8 == tgaData->pixelDepth) + { + _renderFormat = Texture2D::PixelFormat::I8; + } + else + { + // actually this won't happen, if it happens, maybe the image file is not a tga + CCLOG("Image WARNING: unsupport gray tga data pixel format. FILE: %s", _filePath.c_str()); + break; + } + } + + _width = tgaData->width; + _height = tgaData->height; + _data = tgaData->imageData; + _dataLen = _width * _height * tgaData->pixelDepth / 8; + _fileType = Format::TGA; + _preMulti = false; + ret = true; + + }while(false); + + if (!ret) + { + const unsigned char tgaSuffix[] = ".tga"; + for(int i = 0; i < 4; ++i) + { + if (std::tolower(_filePath[_filePath.length() - i - 1]) != tgaSuffix[3 - i]) + { + CCLOG("Image WARNING: the image file suffix is not tga, but parsed as a tga image file. FILE: %s", _filePath.c_str()); + break; + }; + } + } + else + { + if (tgaData->imageData != nullptr) + { + free(tgaData->imageData); + } + } + + return ret; +} + namespace { static const uint32_t makeFourCC(char ch0, char ch1, char ch2, char ch3) diff --git a/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp b/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp index 206f3f086a..99a684a555 100644 --- a/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp +++ b/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp @@ -52,6 +52,7 @@ static std::function createFunctions[] = CL(TexturePNG), CL(TextureJPEG), CL(TextureTIFF), + CL(TextureTGA), CL(TextureWEBP), CL(TexturePixelFormat), CL(TextureBlend), @@ -190,6 +191,29 @@ std::string TextureTIFF::title() return "TIFF Test"; } + +//------------------------------------------------------------------ +// +// TextureTGA +// +//------------------------------------------------------------------ + +void TextureTGA::onEnter() +{ + TextureDemo::onEnter(); + auto s = Director::getInstance()->getWinSize(); + + auto img = Sprite::create("TileMaps/levelmap.tga"); + img->setPosition(Point( s.width/2.0f, s.height/2.0f)); + this->addChild(img); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); +} + +std::string TextureTGA::title() +{ + return "TGA Test"; +} + //------------------------------------------------------------------ // // TexturePNG diff --git a/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.h b/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.h index 7de47425a3..f38c6df453 100644 --- a/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.h +++ b/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.h @@ -26,6 +26,15 @@ public: virtual void onEnter(); }; + +class TextureTGA : public TextureDemo +{ +public: + CREATE_FUNC(TextureTGA); + virtual std::string title(); + virtual void onEnter(); +}; + class TexturePNG : public TextureDemo { public: From dffc12e648879d15b4331ad5874ab1bcc23ac0a8 Mon Sep 17 00:00:00 2001 From: boyu0 Date: Fri, 29 Nov 2013 15:13:16 +0800 Subject: [PATCH 05/30] issue #2345: new/delete -> malloc/free --- cocos/2d/platform/CCImageCommon_cpp.h | 71 +++++++++++++++++---------- 1 file changed, 46 insertions(+), 25 deletions(-) diff --git a/cocos/2d/platform/CCImageCommon_cpp.h b/cocos/2d/platform/CCImageCommon_cpp.h index 0697a7c062..222dcf1ffb 100644 --- a/cocos/2d/platform/CCImageCommon_cpp.h +++ b/cocos/2d/platform/CCImageCommon_cpp.h @@ -390,7 +390,10 @@ Image::Image() Image::~Image() { - CC_SAFE_DELETE_ARRAY(_data); + if (_data != nullptr) + { + free(_data); + } } bool Image::initWithImageFile(const char * strPath) @@ -803,11 +806,11 @@ bool Image::initWithJpgData(const unsigned char * data, int dataLen) _width = cinfo.output_width; _height = cinfo.output_height; _preMulti = false; - row_pointer[0] = new unsigned char[cinfo.output_width*cinfo.output_components]; + row_pointer[0] = static_cast(malloc(cinfo.output_width*cinfo.output_components * sizeof(unsigned char))); CC_BREAK_IF(! row_pointer[0]); _dataLen = cinfo.output_width*cinfo.output_height*cinfo.output_components; - _data = new unsigned char[_dataLen]; + _data = static_cast(malloc(_dataLen * sizeof(unsigned char))); CC_BREAK_IF(! _data); /* now actually read the jpeg into the raw buffer */ @@ -832,7 +835,10 @@ bool Image::initWithJpgData(const unsigned char * data, int dataLen) bRet = true; } while (0); - CC_SAFE_DELETE_ARRAY(row_pointer[0]); + if (row_pointer[0] != nullptr) + { + free(row_pointer[0]); + }; return bRet; } @@ -942,7 +948,7 @@ bool Image::initWithPngData(const unsigned char * data, int dataLen) rowbytes = png_get_rowbytes(png_ptr, info_ptr); _dataLen = rowbytes * _height; - _data = new unsigned char[_dataLen]; + _data = static_cast(malloc(_dataLen * sizeof(unsigned char))); CC_BREAK_IF(!_data); for (unsigned short i = 0; i < _height; ++i) @@ -955,7 +961,10 @@ bool Image::initWithPngData(const unsigned char * data, int dataLen) _preMulti = false; - CC_SAFE_FREE(row_pointers); + if (row_pointers != nullptr) + { + free(row_pointers); + }; bRet = true; } while (0); @@ -1113,7 +1122,7 @@ bool Image::initWithTiffData(const unsigned char * data, int dataLen) _height = h; _dataLen = npixels * sizeof (uint32); - _data = new unsigned char[_dataLen]; + _data = static_cast(malloc(_dataLen * sizeof(unsigned char))); uint32* raster = (uint32*) _TIFFmalloc(npixels * sizeof (uint32)); if (raster != NULL) @@ -1238,7 +1247,7 @@ bool Image::initWithPVRv2Data(const unsigned char * data, int dataLen) //Move by size of header _dataLen = dataLen - sizeof(PVRv2TexHeader); - _data = new unsigned char[_dataLen]; + _data = static_cast(malloc(_dataLen * sizeof(unsigned char))); memcpy(_data, (unsigned char*)data + sizeof(PVRv2TexHeader), _dataLen); // Calculate the data size for each texture level and respect the minimum number of blocks @@ -1360,7 +1369,7 @@ bool Image::initWithPVRv3Data(const unsigned char * data, int dataLen) int blockSize = 0, widthBlocks = 0, heightBlocks = 0; _dataLen = dataLen - (sizeof(PVRv3TexHeader) + header->metadataLength); - _data = new unsigned char[_dataLen]; + _data = static_cast(malloc(_dataLen * sizeof(unsigned char))); memcpy(_data, static_cast(data) + sizeof(PVRv3TexHeader) + header->metadataLength, _dataLen); _numberOfMipmaps = header->numberOfMipmaps; @@ -1447,7 +1456,7 @@ bool Image::initWithETCData(const unsigned char * data, int dataLen) #ifdef GL_ETC1_RGB8_OES _renderFormat = Texture2D::PixelFormat::ETC; _dataLen = dataLen - ETC_PKM_HEADER_SIZE; - _data = new unsigned char[_dataLen]; + _data = static_cast(malloc(_dataLen * sizeof(unsigned char))); memcpy(_data, static_cast(data) + ETC_PKM_HEADER_SIZE, _dataLen); return true; #endif @@ -1462,12 +1471,15 @@ bool Image::initWithETCData(const unsigned char * data, int dataLen) _renderFormat = Texture2D::PixelFormat::RGB888; _dataLen = _width * _height * bytePerPixel; - _data = new unsigned char[_dataLen]; + _data = static_cast(malloc(_dataLen * sizeof(unsigned char))); if (etc1_decode_image(static_cast(data) + ETC_PKM_HEADER_SIZE, static_cast(_data), _width, _height, bytePerPixel, stride) != 0) { _dataLen = 0; - CC_SAFE_DELETE_ARRAY(_data); + if (_data != nullptr) + { + free(_data); + } return false; } @@ -1574,7 +1586,7 @@ bool Image::initWithS3TCData(const unsigned char * data, int dataLen) /* load the .dds file */ S3TCTexHeader *header = (S3TCTexHeader *)data; - unsigned char *pixelData = new unsigned char [dataLen - sizeof(S3TCTexHeader)]; + unsigned char *pixelData = static_cast(malloc((dataLen - sizeof(S3TCTexHeader)) * sizeof(unsigned char))); memcpy((void *)pixelData, data + sizeof(S3TCTexHeader), dataLen - sizeof(S3TCTexHeader)); _width = header->ddsd.width; @@ -1591,7 +1603,7 @@ bool Image::initWithS3TCData(const unsigned char * data, int dataLen) if (Configuration::getInstance()->supportsS3TC()) //compressed data length { _dataLen = dataLen - sizeof(S3TCTexHeader); - _data = new unsigned char [_dataLen]; + _data = static_cast(malloc(_dataLen * sizeof(unsigned char))); memcpy((void *)_data,(void *)pixelData , _dataLen); } else //decompressed data length @@ -1606,7 +1618,7 @@ bool Image::initWithS3TCData(const unsigned char * data, int dataLen) width >>= 1; height >>= 1; } - _data = new unsigned char [_dataLen]; + _data = static_cast(malloc(_dataLen * sizeof(unsigned char))); } /* load the mipmaps */ @@ -1677,7 +1689,10 @@ bool Image::initWithS3TCData(const unsigned char * data, int dataLen) /* end load the mipmaps */ - CC_SAFE_DELETE_ARRAY(pixelData); + if (pixelData != nullptr) + { + free(pixelData); + }; return true; } @@ -1717,7 +1732,7 @@ bool Image::initWithATITCData(const unsigned char *data, int dataLen) if (Configuration::getInstance()->supportsATITC()) //compressed data length { _dataLen = dataLen - sizeof(ATITCTexHeader) - header->bytesOfKeyValueData - 4; - _data = new unsigned char [_dataLen]; + _data = static_cast(malloc(_dataLen * sizeof(unsigned char))); memcpy((void *)_data,(void *)pixelData , _dataLen); } else //decompressed data length @@ -1732,7 +1747,7 @@ bool Image::initWithATITCData(const unsigned char *data, int dataLen) width >>= 1; height >>= 1; } - _data = new unsigned char [_dataLen]; + _data = static_cast(malloc(_dataLen * sizeof(unsigned char))); } /* load the mipmaps */ @@ -1833,7 +1848,7 @@ bool Image::initWithWebpData(const unsigned char * data, int dataLen) _height = config.input.height; _dataLen = _width * _height * 4; - _data = new unsigned char[_dataLen]; + _data = static_cast(malloc(_dataLen * sizeof(unsigned char))); config.output.u.RGBA.rgba = static_cast(_data); config.output.u.RGBA.stride = _width * 4; @@ -1842,7 +1857,7 @@ bool Image::initWithWebpData(const unsigned char * data, int dataLen) if (WebPDecode(static_cast(data), dataLen, &config) != VP8_STATUS_OK) { - delete []_data; + free(_data); _data = NULL; break; } @@ -1867,7 +1882,7 @@ bool Image::initWithRawData(const unsigned char * data, long dataLen, long width // only RGBA8888 supported int bytesPerComponent = 4; _dataLen = height * width * bytesPerComponent; - _data = new unsigned char[_dataLen]; + _data = static_cast(malloc(_dataLen * sizeof(unsigned char))); CC_BREAK_IF(! _data); memcpy(_data, data, _dataLen); @@ -2002,7 +2017,7 @@ bool Image::saveImageToPNG(const std::string& filePath, bool isToRGB) { if (isToRGB) { - unsigned char *pTempData = new unsigned char[_width * _height * 3]; + unsigned char *pTempData = static_cast(malloc(_width * _height * 3 * sizeof(unsigned char*))); if (NULL == pTempData) { fclose(fp); @@ -2030,7 +2045,10 @@ bool Image::saveImageToPNG(const std::string& filePath, bool isToRGB) free(row_pointers); row_pointers = NULL; - CC_SAFE_DELETE_ARRAY(pTempData); + if (pTempData != nullptr) + { + free(pTempData); + } } else { @@ -2091,7 +2109,7 @@ bool Image::saveImageToJPG(const std::string& filePath) if (hasAlpha()) { - unsigned char *pTempData = new unsigned char[_width * _height * 3]; + unsigned char *pTempData = static_cast(malloc(_width * _height * 3 * sizeof(unsigned char))); if (NULL == pTempData) { jpeg_finish_compress(&cinfo); @@ -2116,7 +2134,10 @@ bool Image::saveImageToJPG(const std::string& filePath) (void) jpeg_write_scanlines(&cinfo, row_pointer, 1); } - CC_SAFE_DELETE_ARRAY(pTempData); + if (pTempData != nullptr) + { + free(pTempData); + } } else { From 04c3d950056fbf47339b23353f5ef834b8d44a42 Mon Sep 17 00:00:00 2001 From: boyu0 Date: Fri, 29 Nov 2013 15:25:21 +0800 Subject: [PATCH 06/30] issue #2345: namespace cocos2d { -> NS_CC_BEGIN --- cocos/2d/TGAlib.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/cocos/2d/TGAlib.cpp b/cocos/2d/TGAlib.cpp index fc870b9e0c..9320b887ce 100644 --- a/cocos/2d/TGAlib.cpp +++ b/cocos/2d/TGAlib.cpp @@ -28,7 +28,7 @@ THE SOFTWARE. #include "TGAlib.h" #include "platform/CCFileUtils.h" -namespace cocos2d { +NS_CC_BEGIN static bool tgaLoadRLEImageData(unsigned char* Buffer, unsigned long bufSize, tImageTGA *psInfo); void tgaFlipImage( tImageTGA *info ); @@ -201,42 +201,42 @@ tImageTGA* tgaLoadBuffer(unsigned char* buffer, long size) { CC_BREAK_IF(! buffer); info = (tImageTGA *)malloc(sizeof(tImageTGA)); - + // get the file header info if (! tgaLoadHeader(buffer, size, info)) { info->status = TGA_ERROR_MEMORY; break; } - + // check if the image is color indexed if (info->type == 1) { info->status = TGA_ERROR_INDEXED_COLOR; break; } - + // check for other types (compressed images) if ((info->type != 2) && (info->type !=3) && (info->type !=10) ) { info->status = TGA_ERROR_COMPRESSED_FILE; break; } - + // mode equals the number of image components mode = info->pixelDepth / 8; // total is the number of unsigned chars to read total = info->height * info->width * mode; // allocate memory for image pixels info->imageData = (unsigned char *)malloc(sizeof(unsigned char) * total); - + // check to make sure we have the memory required if (info->imageData == NULL) { info->status = TGA_ERROR_MEMORY; break; } - + bool bLoadImage = false; // finally load the image pixels if ( info->type == 10 ) @@ -247,7 +247,7 @@ tImageTGA* tgaLoadBuffer(unsigned char* buffer, long size) { bLoadImage = tgaLoadImageData(buffer, size, info); } - + // check for errors when reading the pixels if (! bLoadImage) { @@ -255,7 +255,7 @@ tImageTGA* tgaLoadBuffer(unsigned char* buffer, long size) break; } info->status = TGA_OK; - + if ( info->flipped ) { tgaFlipImage( info ); @@ -265,7 +265,7 @@ tImageTGA* tgaLoadBuffer(unsigned char* buffer, long size) } } } while(0); - + return info; } @@ -337,4 +337,4 @@ void tgaDestroy(tImageTGA *psInfo) { free(psInfo); } } -}//namespace cocos2d +NS_CC_END From 83f855e2ec7cd40d0b948695f5ae725aac10a5e5 Mon Sep 17 00:00:00 2001 From: boyu0 Date: Fri, 29 Nov 2013 15:31:58 +0800 Subject: [PATCH 07/30] issue #2345: delete unnecessary include --- cocos/2d/platform/CCImageCommon_cpp.h | 1 - 1 file changed, 1 deletion(-) diff --git a/cocos/2d/platform/CCImageCommon_cpp.h b/cocos/2d/platform/CCImageCommon_cpp.h index 222dcf1ffb..edbf424868 100644 --- a/cocos/2d/platform/CCImageCommon_cpp.h +++ b/cocos/2d/platform/CCImageCommon_cpp.h @@ -25,7 +25,6 @@ THE SOFTWARE. #include "CCImage.h" -#include #include #include From 27c3a459ed497616da2d8cd20d50606e3d47b152 Mon Sep 17 00:00:00 2001 From: Jason Xu Date: Fri, 29 Nov 2013 17:17:15 +0800 Subject: [PATCH 08/30] rename android native function names. --- cocos/2d/platform/android/CCDevice.cpp | 6 +++--- cocos/2d/platform/android/nativeactivity.cpp | 12 ++++++------ cocos/2d/platform/android/nativeactivity.h | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cocos/2d/platform/android/CCDevice.cpp b/cocos/2d/platform/android/CCDevice.cpp index 6f04c55e57..4d33c181d5 100644 --- a/cocos/2d/platform/android/CCDevice.cpp +++ b/cocos/2d/platform/android/CCDevice.cpp @@ -18,17 +18,17 @@ void Device::setAccelerometerEnabled(bool isEnabled) { if (isEnabled) { - enableAccelerometer(); + enableAccelerometer_native(); } else { - disableAccelerometer(); + disableAccelerometer_native(); } } void Device::setAccelerometerInterval(float interval) { - ::setAccelerometerInterval(interval); + setAccelerometerInterval_native(interval); } NS_CC_END diff --git a/cocos/2d/platform/android/nativeactivity.cpp b/cocos/2d/platform/android/nativeactivity.cpp index e92d9e5b78..5772a410ab 100644 --- a/cocos/2d/platform/android/nativeactivity.cpp +++ b/cocos/2d/platform/android/nativeactivity.cpp @@ -471,8 +471,8 @@ static int32_t engine_handle_input(struct android_app* app, AInputEvent* event) return 0; } -void enableAccelerometer(void) { - LOGI("enableAccelerometer()"); +void enableAccelerometer_native(void) { + LOGI("enableAccelerometer_native()"); if (engine.accelerometerSensor != NULL) { ASensorEventQueue_enableSensor(engine.sensorEventQueue, @@ -485,8 +485,8 @@ void enableAccelerometer(void) { } } -void disableAccelerometer(void) { - LOGI("disableAccelerometer()"); +void disableAccelerometer_native(void) { + LOGI("disableAccelerometer_native()"); if (engine.accelerometerSensor != NULL) { ASensorEventQueue_disableSensor(engine.sensorEventQueue, @@ -494,8 +494,8 @@ void disableAccelerometer(void) { } } -void setAccelerometerInterval(float interval) { - LOGI("setAccelerometerInterval(%f)", interval); +void setAccelerometerInterval_native(float interval) { + LOGI("setAccelerometerInterval_native(%f)", interval); // We'd like to get 60 events per second (in us). ASensorEventQueue_setEventRate(engine.sensorEventQueue, engine.accelerometerSensor, interval * 1000000L); diff --git a/cocos/2d/platform/android/nativeactivity.h b/cocos/2d/platform/android/nativeactivity.h index 4f263a6032..4d6236aca8 100644 --- a/cocos/2d/platform/android/nativeactivity.h +++ b/cocos/2d/platform/android/nativeactivity.h @@ -5,8 +5,8 @@ * This is the interface to the Android native activity */ -void enableAccelerometer(void); -void disableAccelerometer(void); -void setAccelerometerInterval(float interval); +void enableAccelerometer_native(void); +void disableAccelerometer_native(void); +void setAccelerometerInterval_native(float interval); #endif // __COCOSNATIVEACTIVITY_H__ From 266e4e165404d218fcf860e1a73dcfdf6f60b4e1 Mon Sep 17 00:00:00 2001 From: Jason Xu Date: Fri, 29 Nov 2013 19:34:36 +0800 Subject: [PATCH 09/30] rename to with Jni suffex --- cocos/2d/platform/android/CCDevice.cpp | 6 +++--- cocos/2d/platform/android/nativeactivity.cpp | 12 ++++++------ cocos/2d/platform/android/nativeactivity.h | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cocos/2d/platform/android/CCDevice.cpp b/cocos/2d/platform/android/CCDevice.cpp index 4d33c181d5..2915cf6994 100644 --- a/cocos/2d/platform/android/CCDevice.cpp +++ b/cocos/2d/platform/android/CCDevice.cpp @@ -18,17 +18,17 @@ void Device::setAccelerometerEnabled(bool isEnabled) { if (isEnabled) { - enableAccelerometer_native(); + enableAccelerometerJni(); } else { - disableAccelerometer_native(); + disableAccelerometerJni(); } } void Device::setAccelerometerInterval(float interval) { - setAccelerometerInterval_native(interval); + setAccelerometerIntervalJni(interval); } NS_CC_END diff --git a/cocos/2d/platform/android/nativeactivity.cpp b/cocos/2d/platform/android/nativeactivity.cpp index 5772a410ab..e7eeb1606a 100644 --- a/cocos/2d/platform/android/nativeactivity.cpp +++ b/cocos/2d/platform/android/nativeactivity.cpp @@ -471,8 +471,8 @@ static int32_t engine_handle_input(struct android_app* app, AInputEvent* event) return 0; } -void enableAccelerometer_native(void) { - LOGI("enableAccelerometer_native()"); +void enableAccelerometerJni(void) { + LOGI("enableAccelerometerJni()"); if (engine.accelerometerSensor != NULL) { ASensorEventQueue_enableSensor(engine.sensorEventQueue, @@ -485,8 +485,8 @@ void enableAccelerometer_native(void) { } } -void disableAccelerometer_native(void) { - LOGI("disableAccelerometer_native()"); +void disableAccelerometerJni(void) { + LOGI("disableAccelerometerJni()"); if (engine.accelerometerSensor != NULL) { ASensorEventQueue_disableSensor(engine.sensorEventQueue, @@ -494,8 +494,8 @@ void disableAccelerometer_native(void) { } } -void setAccelerometerInterval_native(float interval) { - LOGI("setAccelerometerInterval_native(%f)", interval); +void setAccelerometerIntervalJni(float interval) { + LOGI("setAccelerometerIntervalJni(%f)", interval); // We'd like to get 60 events per second (in us). ASensorEventQueue_setEventRate(engine.sensorEventQueue, engine.accelerometerSensor, interval * 1000000L); diff --git a/cocos/2d/platform/android/nativeactivity.h b/cocos/2d/platform/android/nativeactivity.h index 4d6236aca8..677fff3adf 100644 --- a/cocos/2d/platform/android/nativeactivity.h +++ b/cocos/2d/platform/android/nativeactivity.h @@ -5,8 +5,8 @@ * This is the interface to the Android native activity */ -void enableAccelerometer_native(void); -void disableAccelerometer_native(void); -void setAccelerometerInterval_native(float interval); +void enableAccelerometerJni(void); +void disableAccelerometerJni(void); +void setAccelerometerIntervalJni(float interval); #endif // __COCOSNATIVEACTIVITY_H__ From 940b0ffd56b6d85d35b4ea20c45b85bc4f81b5ec Mon Sep 17 00:00:00 2001 From: Marc Lepage Date: Fri, 29 Nov 2013 12:09:38 -0500 Subject: [PATCH 10/30] Fix typos --- cocos/2d/CCNode.h | 400 +++++++++--------- cocos/2d/CCParticleBatchNode.cpp | 28 +- .../CocoStudioArmatureTest/ArmatureScene.cpp | 20 +- .../CocoStudioArmatureTest/ArmatureScene.h | 6 +- .../Classes/ParticleTest/ParticleTest.cpp | 272 ++++++------ .../CocoStudioArmatureTest.lua | 124 +++--- .../luaScript/ParticleTest/ParticleTest.lua | 6 +- 7 files changed, 428 insertions(+), 428 deletions(-) diff --git a/cocos/2d/CCNode.h b/cocos/2d/CCNode.h index 9212676669..4e036b01b2 100644 --- a/cocos/2d/CCNode.h +++ b/cocos/2d/CCNode.h @@ -158,14 +158,14 @@ public: * @lua NA */ const char* description(void) const; - + /// @} end of initializers - - - + + + /// @{ /// @name Setters & Getters for Graphic Peroperties - + /** * Sets the Z order which stands for the drawing order, and reorder this node in its parent's children array. * @@ -194,7 +194,7 @@ public: * @return The Z order. */ virtual int getZOrder() const; - + /** * Sets the real OpenGL Z vertex. * @@ -235,7 +235,7 @@ public: */ virtual float getScaleX() const; - + /** * Changes the scale factor on Y axis of this node * @@ -249,11 +249,11 @@ public: * * @see `setScaleY(float)` * - * @return The scale factor on Y axis. + * @return The scale factor on Y axis. */ virtual float getScaleY() const; - + /** * Changes both X and Y scale factor of the node. * @@ -271,7 +271,7 @@ public: * @return The scale factor of the node. */ virtual float getScale() const; - + /** * Changes both X and Y scale factor of the node. * @@ -281,7 +281,7 @@ public: * @param scaleY The scale factor on Y axis. */ virtual void setScale(float scaleX,float scaleY); - + /** * Changes the position (x,y) of the node in OpenGL coordinates * @@ -298,7 +298,7 @@ public: virtual void setPosition(const Point &position); /** * Gets the position (x,y) of the node in OpenGL coordinates - * + * * @see setPosition(const Point&) * * @return The position (x,y) of the node in OpenGL coordinates @@ -311,7 +311,7 @@ public: * Sets position in a more efficient way. * * Passing two numbers (x,y) is much efficient than passing Point object. - * This method is binded to lua and javascript. + * This method is binded to lua and javascript. * Passing a number is 10 times faster than passing a object from lua to c++ * @code @@ -339,8 +339,8 @@ public: virtual float getPositionX(void) const; virtual void setPositionY(float y); virtual float getPositionY(void) const; - - + + /** * Changes the X skew angle of the node in degrees. * @@ -360,7 +360,7 @@ public: */ virtual float getSkewX() const; - + /** * Changes the Y skew angle of the node in degrees. * @@ -380,7 +380,7 @@ public: */ virtual float getSkewY() const; - + /** * Sets the anchor point in percent. * @@ -393,7 +393,7 @@ public: * @param anchorPoint The anchor point of node. */ virtual void setAnchorPoint(const Point& anchorPoint); - /** + /** * Returns the anchor point in percent. * * @see `setAnchorPoint(const Point&)` @@ -403,15 +403,15 @@ public: virtual const Point& getAnchorPoint() const; /** * Returns the anchorPoint in absolute pixels. - * + * * @warning You can only read it. If you wish to modify it, use anchorPoint instead. * @see `getAnchorPoint()` * * @return The anchor point in absolute pixels. */ virtual const Point& getAnchorPointInPoints() const; - - + + /** * Sets the untransformed size of the node. * @@ -430,7 +430,7 @@ public: */ virtual const Size& getContentSize() const; - + /** * Sets whether the node is visible * @@ -448,13 +448,13 @@ public: */ virtual bool isVisible() const; - - /** - * Sets the rotation (angle) of the node in degrees. - * - * 0 is the default rotation angle. + + /** + * Sets the rotation (angle) of the node in degrees. + * + * 0 is the default rotation angle. * Positive values rotate node clockwise, and negative values for anti-clockwise. - * + * * @param rotation The rotation of the node in degrees. */ virtual void setRotation(float rotation); @@ -467,13 +467,13 @@ public: */ virtual float getRotation() const; - - /** + + /** * Sets the X rotation (angle) of the node in degrees which performs a horizontal rotational skew. - * - * 0 is the default rotation angle. + * + * 0 is the default rotation angle. * Positive values rotate node clockwise, and negative values for anti-clockwise. - * + * * @param rotationX The X rotation in degrees which performs a horizontal rotational skew. */ virtual void setRotationX(float rotationX); @@ -486,11 +486,11 @@ public: */ virtual float getRotationX() const; - - /** + + /** * Sets the Y rotation (angle) of the node in degrees which performs a vertical rotational skew. - * - * 0 is the default rotation angle. + * + * 0 is the default rotation angle. * Positive values rotate node clockwise, and negative values for anti-clockwise. * * @param rotationY The Y rotation in degrees. @@ -505,7 +505,7 @@ public: */ virtual float getRotationY() const; - + /** * Sets the arrival order when this node has a same ZOrder with other children. * @@ -525,9 +525,9 @@ public: * @return The arrival order. */ virtual int getOrderOfArrival() const; - - - /** @deprecated No longer needed + + + /** @deprecated No longer needed * @js NA * @lua NA */ @@ -537,7 +537,7 @@ public: * @lua NA */ CC_DEPRECATED_ATTRIBUTE int getGLServerState() const { return 0; } - + /** * Sets whether the anchor point will be (0,0) when you position this node. * @@ -556,14 +556,14 @@ public: * @return true if the anchor point will be (0,0) when you position this node. */ virtual bool isIgnoreAnchorPointForPosition() const; - + /// @} end of Setters & Getters for Graphic Peroperties - - + + /// @{ /// @name Children and Parent - - /** + + /** * Adds a child to the container with z-order as 0. * * If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately. @@ -571,7 +571,7 @@ public: * @param child A child node */ virtual void addChild(Node * child); - /** + /** * Adds a child to the container with a z-order * * If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately. @@ -580,7 +580,7 @@ public: * @param zOrder Z order for drawing priority. Please refer to setZOrder(int) */ virtual void addChild(Node * child, int zOrder); - /** + /** * Adds a child to the container with z order and tag * * If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately. @@ -616,41 +616,41 @@ public: */ virtual Array* getChildren() { return _children; } virtual const Array *getChildren() const { return _children; } - - /** + + /** * Get the amount of children. * * @return The amount of children. */ long getChildrenCount() const; - + /** * Sets the parent node * - * @param parent A pointer to the parnet node + * @param parent A pointer to the parent node */ virtual void setParent(Node* parent); /** * Returns a pointer to the parent node - * + * * @see `setParent(Node*)` * - * @returns A pointer to the parnet node + * @returns A pointer to the parent node */ virtual Node* getParent() { return _parent; } virtual const Node* getParent() const { return _parent; } - + ////// REMOVES ////// - - /** + + /** * Removes this node itself from its parent node with a cleanup. * If the node orphan, then nothing happens. * @see `removeFromParentAndCleanup(bool)` */ virtual void removeFromParent(); - /** - * Removes this node itself from its parent node. + /** + * Removes this node itself from its parent node. * If the node orphan, then nothing happens. * @param cleanup true if all actions and callbacks on this node should be removed, false otherwise. * @js removeFromParent @@ -658,28 +658,28 @@ public: */ virtual void removeFromParentAndCleanup(bool cleanup); - /** + /** * Removes a child from the container. It will also cleanup all running actions depending on the cleanup parameter. - * + * * @param child The child node which will be removed. * @param cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise. */ virtual void removeChild(Node* child, bool cleanup = true); - /** + /** * Removes a child from the container by tag value. It will also cleanup all running actions depending on the cleanup parameter - * + * * @param tag An interger number that identifies a child node - * @param cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise. + * @param cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise. */ virtual void removeChildByTag(int tag, bool cleanup = true); - /** + /** * Removes all children from the container with a cleanup. * * @see `removeAllChildrenWithCleanup(bool)` */ virtual void removeAllChildren(); - /** + /** * Removes all children from the container, and do a cleanup to all running actions depending on the cleanup parameter. * * @param cleanup true if all running actions on all children nodes should be cleanup, false oterwise. @@ -687,32 +687,32 @@ public: * @lua removeAllChildren */ virtual void removeAllChildrenWithCleanup(bool cleanup); - - /** + + /** * Reorders a child according to a new z value. * * @param child An already added child node. It MUST be already added. * @param zOrder Z order for drawing priority. Please refer to setZOrder(int) */ virtual void reorderChild(Node * child, int zOrder); - - /** + + /** * Sorts the children array once before drawing, instead of every time when a child is added or reordered. * This appraoch can improves the performance massively. - * @note Don't call this manually unless a child added needs to be removed in the same frame + * @note Don't call this manually unless a child added needs to be removed in the same frame */ virtual void sortAllChildren(); /// @} end of Children and Parent - - + + /// @{ /// @name Grid object for effects - + /** * Returns a grid object that is used when applying effects - * + * * @return A Grid object that is used when applying effects * @js NA */ @@ -728,13 +728,13 @@ public: * @param grid A Grid object that is used when applying effects */ virtual void setGrid(GridBase *grid); - + /// @} end of Grid - - + + /// @{ /// @name Tag & User data - + /** * Returns a tag that is used to identify the node easily. * @@ -777,12 +777,12 @@ public: * @param tag A interger that indentifies the node. */ virtual void setTag(int tag); - + /** * Returns a custom user data pointer * * You can set everything in UserData pointer, a data block, a structure or an object. - * + * * @return A custom user data pointer * @js NA * @lua NA @@ -798,7 +798,7 @@ public: * Sets a custom user data pointer * * You can set everything in UserData pointer, a data block, a structure or an object, etc. - * @warning Don't forget to release the memory manually, + * @warning Don't forget to release the memory manually, * especially before you change this data pointer, and before this node is autoreleased. * * @param userData A custom user data pointer @@ -806,10 +806,10 @@ public: * @lua NA */ virtual void setUserData(void *userData); - - /** + + /** * Returns a user assigned Object - * + * * Similar to userData, but instead of holding a void* it holds an object * * @return A user assigned Object @@ -817,7 +817,7 @@ public: * @lua NA */ virtual Object* getUserObject() { return _userObject; } - /** + /** * @js NA * @lua NA */ @@ -834,15 +834,15 @@ public: * @param userObject A user assigned Object */ virtual void setUserObject(Object *userObject); - + /// @} end of Tag & User Data - - + + /// @{ /// @name Shader Program /** * Return the shader program currently used for this node - * + * * @return The shader program currelty used for this node */ virtual GLProgram* getShaderProgram() { return _shaderProgram; } @@ -856,13 +856,13 @@ public: @code node->setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); @endcode - * + * * @param shaderProgram The shader program which fetchs from ShaderCache. */ virtual void setShaderProgram(GLProgram *shaderProgram); /// @} end of Shader Program - - + + /** * Returns a camera object that lets you move the node using a gluLookAt * @@ -875,29 +875,29 @@ public: * @return A Camera object that lets you move the node using a gluLookAt */ virtual Camera* getCamera(); - - /** + + /** * Returns whether or not the node accepts event callbacks. - * + * * Running means the node accept event callbacks like onEnter(), onExit(), update() * * @return Whether or not the node is running. */ virtual bool isRunning() const; - - /** - * Schedules for lua script. + + /** + * Schedules for lua script. * @js NA */ void scheduleUpdateWithPriorityLua(int handler, int priority); - + /// @} end Script Bindings /// @{ /// @name Event Callbacks - - /** + + /** * Event callback that is invoked every time when Node enters the 'stage'. * If the Node enters the 'stage' with a transition, this event is called when the transition starts. * During onEnter you can't access a "sister/brother" node. @@ -915,7 +915,7 @@ public: */ virtual void onEnterTransitionDidFinish(); - /** + /** * Event callback that is invoked every time the Node leaves the 'stage'. * If the Node leaves the 'stage' with a transition, this event is called when the transition finishes. * During onExit you can't access a sibling node. @@ -925,23 +925,23 @@ public: */ virtual void onExit(); - /** + /** * Event callback that is called every time the Node leaves the 'stage'. * If the Node leaves the 'stage' with a transition, this callback is called when the transition starts. * @js NA * @lua NA */ virtual void onExitTransitionDidStart(); - + /// @} end of event callbacks. - /** + /** * Stops all running actions and schedulers */ virtual void cleanup(); - /** + /** * Override this method to draw your own node. * The following GL states will be enabled by default: * - `glEnableClientState(GL_VERTEX_ARRAY);` @@ -953,19 +953,19 @@ public: */ virtual void draw(); - /** + /** * Visits this node's children and draw them recursively. */ virtual void visit(); - - /** + + /** * Returns a "local" axis aligned bounding box of the node. * The returned box is relative only to its parent. * * @note This method returns a temporaty variable, so it can't returns const Rect& * @todo Rename to `getBoundingBox()` in the future versions. - * + * * @return A "local" axis aligned boudning box of the node. */ virtual Rect getBoundingBox() const; @@ -975,7 +975,7 @@ public: virtual void setEventDispatcher(EventDispatcher* dispatcher); virtual EventDispatcher* getEventDispatcher() const { return _eventDispatcher; }; - + /// @{ /// @name Actions @@ -995,7 +995,7 @@ public: virtual ActionManager* getActionManager() { return _actionManager; } virtual const ActionManager* getActionManager() const { return _actionManager; } - /** + /** * Executes an action, and returns the action that is executed. * * This node becomes the action's target. Refer to Action::getTarget() @@ -1005,26 +1005,26 @@ public: */ Action* runAction(Action* action); - /** + /** * Stops and removes all actions from the running action list . */ void stopAllActions(); - /** + /** * Stops and removes an action from the running action list. * * @param action The action object to be removed. */ void stopAction(Action* action); - /** + /** * Removes an action from the running action list by its tag. * * @param tag A tag that indicates the action to be removed. */ void stopActionByTag(int tag); - /** + /** * Gets an action from the running action list by its tag. * * @see `setTag(int)`, `getTag()`. @@ -1033,7 +1033,7 @@ public: */ Action* getActionByTag(int tag); - /** + /** * Returns the numbers of actions that are running plus the ones that are schedule to run (actions in actionsToAdd and actions arrays). * * Composable actions are counted as 1 action. Example: @@ -1049,8 +1049,8 @@ public: CC_DEPRECATED_ATTRIBUTE unsigned int numberOfRunningActions() const { return getNumberOfRunningActions(); }; /// @} end of Actions - - + + /// @{ /// @name Scheduler and Timer @@ -1070,8 +1070,8 @@ public: virtual Scheduler* getScheduler() { return _scheduler; } virtual const Scheduler* getScheduler() const { return _scheduler; } - - /** + + /** * Checks whether a selector is scheduled. * * @param selector A function selector @@ -1081,8 +1081,8 @@ public: */ bool isScheduled(SEL_SCHEDULE selector); - /** - * Schedules the "update" method. + /** + * Schedules the "update" method. * * It will use the order number 0. This method will be called every frame. * Scheduled methods with a lower order value will be called before the ones that have a higher order value. @@ -1092,8 +1092,8 @@ public: */ void scheduleUpdate(void); - /** - * Schedules the "update" method with a custom priority. + /** + * Schedules the "update" method with a custom priority. * * This selector will be called every frame. * Scheduled methods with a lower priority will be called before the ones that have a higher value. @@ -1103,7 +1103,7 @@ public: */ void scheduleUpdateWithPriority(int priority); - /* + /* * Unschedules the "update" method. * @see scheduleUpdate(); */ @@ -1127,7 +1127,7 @@ public: * @lua NA */ void schedule(SEL_SCHEDULE selector, float interval, unsigned int repeat, float delay); - + /** * Schedules a custom selector with an interval time in seconds. * @see `schedule(SEL_SCHEDULE, float, unsigned int, float)` @@ -1137,7 +1137,7 @@ public: * @lua NA */ void schedule(SEL_SCHEDULE selector, float interval); - + /** * Schedules a selector that runs only once, with a delay of 0 or larger * @see `schedule(SEL_SCHEDULE, float, unsigned int, float)` @@ -1147,7 +1147,7 @@ public: * @lua NA */ void scheduleOnce(SEL_SCHEDULE selector, float delay); - + /** * Schedules a custom selector, the scheduled selector will be ticked every frame * @see schedule(SEL_SCHEDULE, float, unsigned int, float) @@ -1156,8 +1156,8 @@ public: * @lua NA */ void schedule(SEL_SCHEDULE selector); - - /** + + /** * Unschedules a custom selector. * @see `schedule(SEL_SCHEDULE, float, unsigned int, float)` * @@ -1166,7 +1166,7 @@ public: */ void unschedule(SEL_SCHEDULE selector); - /** + /** * Unschedule all scheduled selectors: custom selectors, and the 'update' selector. * Actions are not affected by this method. * @lua NA @@ -1183,19 +1183,19 @@ public: * This method is called internally by onExit */ void pause(void); - + /** * Resumes all scheduled selectors, actions and event listeners. * This method is called internally by onEnter */ CC_DEPRECATED_ATTRIBUTE void resumeSchedulerAndActions(void); - /** + /** * Pauses all scheduled selectors, actions and event listeners.. * This method is called internally by onExit */ CC_DEPRECATED_ATTRIBUTE void pauseSchedulerAndActions(void); - - /* + + /* * Update method will be called automatically every frame if "scheduleUpdate" is called, and the node is "live" */ virtual void update(float delta); @@ -1204,7 +1204,7 @@ public: /// @{ /// @name Transformations - + /** * Performs OpenGL view-matrix transformation based on position, scale, rotation and other attributes. */ @@ -1223,8 +1223,8 @@ public: * e.g., `batchNode->addChild(myCustomNode)`, while you can only addChild(sprite) before. */ virtual void updateTransform(); - - /** + + /** * Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates. * The matrix is in Pixels. */ @@ -1233,7 +1233,7 @@ public: /** @deprecated use getNodeToParentTransform() instead */ CC_DEPRECATED_ATTRIBUTE inline virtual AffineTransform nodeToParentTransform() const { return getNodeToParentTransform(); } - /** + /** * Returns the matrix that transform parent's space coordinates to the node's (local) space coordinates. * The matrix is in Pixels. */ @@ -1242,7 +1242,7 @@ public: /** @deprecated Use getParentToNodeTransform() instead */ CC_DEPRECATED_ATTRIBUTE inline virtual AffineTransform parentToNodeTransform() const { return getParentToNodeTransform(); } - /** + /** * Returns the world affine transform matrix. The matrix is in Pixels. */ virtual AffineTransform getNodeToWorldTransform() const; @@ -1250,7 +1250,7 @@ public: /** @deprecated Use getNodeToWorldTransform() instead */ CC_DEPRECATED_ATTRIBUTE inline virtual AffineTransform nodeToWorldTransform() const { return getNodeToWorldTransform(); } - /** + /** * Returns the inverse world affine transform matrix. The matrix is in Pixels. */ virtual AffineTransform getWorldToNodeTransform() const; @@ -1259,43 +1259,43 @@ public: CC_DEPRECATED_ATTRIBUTE inline virtual AffineTransform worldToNodeTransform() const { return getWorldToNodeTransform(); } /// @} end of Transformations - - + + /// @{ /// @name Coordinate Converters - - /** + + /** * Converts a Point to node (local) space coordinates. The result is in Points. */ Point convertToNodeSpace(const Point& worldPoint) const; - - /** + + /** * Converts a Point to world space coordinates. The result is in Points. */ Point convertToWorldSpace(const Point& nodePoint) const; - - /** + + /** * Converts a Point to node (local) space coordinates. The result is in Points. * treating the returned/received node point as anchor relative. */ Point convertToNodeSpaceAR(const Point& worldPoint) const; - - /** + + /** * Converts a local Point to world space coordinates.The result is in Points. * treating the returned/received node point as anchor relative. */ Point convertToWorldSpaceAR(const Point& nodePoint) const; - /** + /** * convenience methods which take a Touch instead of Point */ Point convertTouchToNodeSpace(Touch * touch) const; - /** + /** * converts a Touch (world coordinates) into a local coordinate. This method is AR (Anchor Relative). */ Point convertTouchToNodeSpaceAR(Touch * touch) const; - + /** * Sets the additional transform. * @@ -1345,51 +1345,51 @@ public: @endcode */ void setAdditionalTransform(const AffineTransform& additionalTransform); - + /// @} end of Coordinate Converters /// @{ /// @name component functions - /** + /** * gets a component by its name */ Component* getComponent(const char *pName); - - /** + + /** * adds a component */ virtual bool addComponent(Component *pComponent); - - /** - * removes a component by its name + + /** + * removes a component by its name */ virtual bool removeComponent(const char *pName); - + /** * removes all components */ virtual void removeAllComponents(); /// @} end of component functions - - + + #ifdef CC_USE_PHYSICS /** * set the PhysicsBody that let the sprite effect with physics */ void setPhysicsBody(PhysicsBody* body); - + /** * get the PhysicsBody the sprite have */ PhysicsBody* getPhysicsBody() const; - + /** * update rotation and position from physics body */ virtual void updatePhysicsTransform(); #endif - + protected: // Nodes should be created using create(); Node(); @@ -1398,35 +1398,35 @@ protected: /// lazy allocs void childrenAlloc(void); - + /// helper that reorder a child void insertChild(Node* child, int z); - + /// Removes a child, call child->onExit(), do cleanup, remove it from children array. void detachChild(Node *child, long index, bool doCleanup); - + /// Convert cocos2d coordinates to UI windows coordinate. Point convertToWindowSpace(const Point& nodePoint) const; float _rotationX; ///< rotation angle on x-axis float _rotationY; ///< rotation angle on y-axis - + float _scaleX; ///< scaling factor on x-axis float _scaleY; ///< scaling factor on y-axis - + float _vertexZ; ///< OpenGL real Z vertex - + Point _position; ///< position of the node - + float _skewX; ///< skew angle on x-axis float _skewY; ///< skew angle on y-axis - + Point _anchorPointInPoints; ///< anchor point in points Point _anchorPoint; ///< anchor point normalized (NOT in points) - + Size _contentSize; ///< untransformed size of the node - + // "cache" variables are allowed to be mutable mutable AffineTransform _additionalTransform; ///< transform mutable AffineTransform _transform; ///< transform @@ -1436,45 +1436,45 @@ protected: mutable bool _inverseDirty; ///< inverse transform dirty flag Camera *_camera; ///< a camera - + GridBase *_grid; ///< a grid - + int _ZOrder; ///< z-order value that affects the draw order - + Array *_children; ///< array of children nodes Node *_parent; ///< weak reference to parent node - + int _tag; ///< a tag. Can be any number you assigned just to identify this node - + void *_userData; ///< A user assingned void pointer, Can be point to any cpp object Object *_userObject; ///< A user assigned Object - + GLProgram *_shaderProgram; ///< OpenGL shader int _orderOfArrival; ///< used to preserve sequence while sorting children with the same zOrder - + Scheduler *_scheduler; ///< scheduler used to schedule timers and updates - + ActionManager *_actionManager; ///< a pointer to ActionManager singleton, which is used to handle all the actions - + EventDispatcher* _eventDispatcher; ///< event dispatcher used to dispatch all kinds of events - + bool _running; ///< is running - + bool _visible; ///< is this node visible - + bool _ignoreAnchorPointForPosition; ///< true if the Anchor Point will be (0,0) when you position the Node, false otherwise. ///< Used by Layer and Scene. - + bool _reorderChildDirty; ///< children order dirty flag bool _isTransitionFinished; ///< flag to indicate whether the transition was finished - + int _scriptHandler; ///< script handler for onEnter() & onExit(), used in Javascript binding and Lua binding. int _updateScriptHandler; ///< script handler for update() callback per frame, which is invoked from lua & javascript. ccScriptType _scriptType; ///< type of script binding, lua or javascript - + ComponentContainer *_componentContainer; ///< Dictionary of components - + #ifdef CC_USE_PHYSICS PhysicsBody* _physicsBody; ///< the physicsBody the node have #endif @@ -1486,11 +1486,11 @@ private: //#pragma mark - NodeRGBA /** NodeRGBA is a subclass of Node that implements the RGBAProtocol protocol. - + All features from Node are valid, plus the following new features: - opacity - RGB colors - + Opacity/Color propagates into children that conform to the RGBAProtocol if cascadeOpacity/cascadeColor is enabled. @since v2.1 */ @@ -1504,14 +1504,14 @@ public: virtual void updateDisplayedOpacity(GLubyte parentOpacity) override; virtual bool isCascadeOpacityEnabled() const override; virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled) override; - + virtual const Color3B& getColor(void) const override; virtual const Color3B& getDisplayedColor() const override; virtual void setColor(const Color3B& color) override; virtual void updateDisplayedColor(const Color3B& parentColor) override; virtual bool isCascadeColorEnabled() const override; virtual void setCascadeColorEnabled(bool cascadeColorEnabled) override; - + virtual void setOpacityModifyRGB(bool bValue) override {CC_UNUSED_PARAM(bValue);}; virtual bool isOpacityModifyRGB() const override { return false; }; diff --git a/cocos/2d/CCParticleBatchNode.cpp b/cocos/2d/CCParticleBatchNode.cpp index 0d1eccae48..a6d1fff5cb 100644 --- a/cocos/2d/CCParticleBatchNode.cpp +++ b/cocos/2d/CCParticleBatchNode.cpp @@ -102,7 +102,7 @@ bool ParticleBatchNode::initWithTexture(Texture2D *tex, int capacity) _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); - + return true; } @@ -144,7 +144,7 @@ void ParticleBatchNode::visit() transform(); draw(); - + if ( _grid && _grid->isActive()) { _grid->afterDraw(this); @@ -171,12 +171,12 @@ void ParticleBatchNode::addChild(Node * aChild, int zOrder, int tag) ParticleSystem* child = static_cast(aChild); CCASSERT( child->getTexture()->getName() == _textureAtlas->getTexture()->getName(), "CCParticleSystem is not using the same texture id"); // If this is the 1st children, then copy blending function - if( _children->count() == 0 ) + if( _children->count() == 0 ) { setBlendFunc(child->getBlendFunc()); } - CCASSERT( _blendFunc.src == child->getBlendFunc().src && _blendFunc.dst == child->getBlendFunc().dst, "Can't add a PaticleSystem that uses a different blending function"); + CCASSERT( _blendFunc.src == child->getBlendFunc().src && _blendFunc.dst == child->getBlendFunc().dst, "Can't add a ParticleSystem that uses a different blending function"); //no lazy sorting, so don't call super addChild, call helper instead unsigned int pos = addChildHelper(child,zOrder,tag); @@ -184,7 +184,7 @@ void ParticleBatchNode::addChild(Node * aChild, int zOrder, int tag) //get new atlasIndex int atlasIndex = 0; - if (pos != 0) + if (pos != 0) { ParticleSystem* p = (ParticleSystem*)_children->getObjectAtIndex(pos-1); atlasIndex = p->getAtlasIndex() + p->getTotalParticles(); @@ -210,7 +210,7 @@ unsigned int ParticleBatchNode::addChildHelper(ParticleSystem* child, int z, int CCASSERT( child != NULL, "Argument must be non-nil"); CCASSERT( child->getParent() == NULL, "child already added. It can't be added again"); - if( ! _children ) + if( ! _children ) { _children = new Array(); _children->initWithCapacity(4); @@ -226,7 +226,7 @@ unsigned int ParticleBatchNode::addChildHelper(ParticleSystem* child, int z, int child->setParent(this); - if( _running ) + if( _running ) { child->onEnter(); child->onEnterTransitionDidFinish(); @@ -243,7 +243,7 @@ void ParticleBatchNode::reorderChild(Node * aChild, int zOrder) ParticleSystem* child = static_cast(aChild); - if( zOrder == child->getZOrder() ) + if( zOrder == child->getZOrder() ) { return; } @@ -275,7 +275,7 @@ void ParticleBatchNode::reorderChild(Node * aChild, int zOrder) for( int i=0;i < _children->count();i++) { ParticleSystem* pNode = (ParticleSystem*)_children->getObjectAtIndex(i); - if( pNode == child ) + if( pNode == child ) { newAtlasIndex = child->getAtlasIndex(); break; @@ -300,12 +300,12 @@ void ParticleBatchNode::getCurrentIndex(unsigned int* oldIndex, unsigned int* ne int minusOne = 0; unsigned int count = _children->count(); - for( unsigned int i=0; i < count; i++ ) + for( unsigned int i=0; i < count; i++ ) { Node* pNode = (Node *)_children->getObjectAtIndex(i); // new index - if( pNode->getZOrder() > z && ! foundNewIdx ) + if( pNode->getZOrder() > z && ! foundNewIdx ) { *newIndex = i; foundNewIdx = true; @@ -317,7 +317,7 @@ void ParticleBatchNode::getCurrentIndex(unsigned int* oldIndex, unsigned int* ne } // current index - if( child == pNode ) + if( child == pNode ) { *oldIndex = i; foundCurrentIdx = true; @@ -347,7 +347,7 @@ unsigned int ParticleBatchNode::searchNewPositionInChildrenForZ(int z) { unsigned int count = _children->count(); - for( unsigned int i=0; i < count; i++ ) + for( unsigned int i=0; i < count; i++ ) { Node *child = (Node *)_children->getObjectAtIndex(i); if (child->getZOrder() > z) @@ -364,7 +364,7 @@ void ParticleBatchNode::removeChild(Node* aChild, bool cleanup) // explicit nil handling if (aChild == NULL) return; - + CCASSERT( dynamic_cast(aChild) != NULL, "CCParticleBatchNode only supports QuadParticleSystems as children"); CCASSERT(_children->containsObject(aChild), "CCParticleBatchNode doesn't contain the sprite. Can't remove it"); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp index 65cd9044ef..8bd9af7a80 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp @@ -184,7 +184,7 @@ void ArmatureTestLayer::onExit() removeAllChildren(); backItem = restartItem = nextItem = nullptr; - + Layer::onExit(); } @@ -371,7 +371,7 @@ void TestPerformance::onEnter() decrease->setColor(Color3B(0,200,20)); MenuItemFont *increase = MenuItemFont::create(" + ", CC_CALLBACK_1(TestPerformance::onIncrease, this)); increase->setColor(Color3B(0,200,20)); - + Menu *menu = Menu::create(decrease, increase, nullptr); menu->alignItemsHorizontally(); menu->setPosition(Point(VisibleRect::getVisibleRect().size.width/2, VisibleRect::getVisibleRect().size.height-100)); @@ -404,7 +404,7 @@ void TestPerformance::onDecrease(Object* pSender) { removeArmatureFromParent(ArmaturePerformanceTag + armatureCount); armatureCount --; - refreshTitile(); + refreshTitle(); } } void TestPerformance::addArmature(int number) @@ -423,7 +423,7 @@ void TestPerformance::addArmature(int number) armature->release(); } - refreshTitile(); + refreshTitle(); } void TestPerformance::addArmatureToParent(cocostudio::Armature *armature) { @@ -433,7 +433,7 @@ void TestPerformance::removeArmatureFromParent(int tag) { removeChildByTag(ArmaturePerformanceTag + armatureCount); } -void TestPerformance::refreshTitile() +void TestPerformance::refreshTitle() { char pszCount[255]; sprintf(pszCount, "%s %i", subtitle().c_str(), armatureCount); @@ -601,7 +601,7 @@ void TestFrameEvent::onFrameEvent(Bone *bone, const char *evt, int originFrameIn { this->stopAllActions(); - ActionInterval *action = ShatteredTiles3D::create(0.2f, Size(16,12), 5, false); + ActionInterval *action = ShatteredTiles3D::create(0.2f, Size(16,12), 5, false); action->setTag(FRAME_EVENT_ACTION_TAG); this->runAction(action); } @@ -617,7 +617,7 @@ void TestFrameEvent::checkAction(float dt) void TestParticleDisplay::onEnter() { ArmatureTestLayer::onEnter(); - + auto listener = EventListenerTouchAllAtOnce::create(); listener->onTouchesEnded = CC_CALLBACK_2(TestParticleDisplay::onTouchesEnded, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); @@ -681,7 +681,7 @@ void TestUseMutiplePicture::onEnter() auto listener = EventListenerTouchAllAtOnce::create(); listener->onTouchesEnded = CC_CALLBACK_2(TestUseMutiplePicture::onTouchesEnded, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); - + displayIndex = 0; armature = Armature::create("Knight_f/Knight"); @@ -1076,7 +1076,7 @@ std::string TestAnchorPoint::title() void TestArmatureNesting::onEnter() { ArmatureTestLayer::onEnter(); - + auto listener = EventListenerTouchAllAtOnce::create(); listener->onTouchesEnded = CC_CALLBACK_2(TestArmatureNesting::onTouchesEnded, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); @@ -1241,7 +1241,7 @@ void TestArmatureNesting2::onTouchesEnded(const std::vector& touches, Ev { Point point = touches[0]->getLocation(); - Armature *armature = hero->getMount() == nullptr ? hero : hero->getMount(); + Armature *armature = hero->getMount() == nullptr ? hero : hero->getMount(); //Set armature direction if (point.x < armature->getPositionX()) diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h index 79e29b61dc..dc0eed2493 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h @@ -16,7 +16,7 @@ class ArmatureTestScene : public TestScene { -public: +public: ArmatureTestScene(bool bPortrait = false); virtual void runThisTest(); @@ -114,7 +114,7 @@ public: virtual void addArmature(int number); virtual void addArmatureToParent(cocostudio::Armature *armature); virtual void removeArmatureFromParent(int tag); - virtual void refreshTitile(); + virtual void refreshTitle(); int armatureCount; @@ -327,4 +327,4 @@ public: bool touchedMenu; }; -#endif // __HELLOWORLD_SCENE_H__ \ No newline at end of file +#endif // __HELLOWORLD_SCENE_H__ diff --git a/samples/Cpp/TestCpp/Classes/ParticleTest/ParticleTest.cpp b/samples/Cpp/TestCpp/Classes/ParticleTest/ParticleTest.cpp index f8bfc895af..bab33d56c3 100644 --- a/samples/Cpp/TestCpp/Classes/ParticleTest/ParticleTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ParticleTest/ParticleTest.cpp @@ -21,9 +21,9 @@ void DemoFirework::onEnter() _emitter = ParticleFireworks::create(); _emitter->retain(); _background->addChild(_emitter, 10); - + _emitter->setTexture( Director::getInstance()->getTextureCache()->addImage(s_stars1) ); - + setEmitterPosition(); } @@ -45,11 +45,11 @@ void DemoFire::onEnter() _emitter = ParticleFire::create(); _emitter->retain(); _background->addChild(_emitter, 10); - + _emitter->setTexture( Director::getInstance()->getTextureCache()->addImage(s_fire) );//.pvr"); auto p = _emitter->getPosition(); _emitter->setPosition( Point(p.x, 100) ); - + setEmitterPosition(); } @@ -72,7 +72,7 @@ void DemoSun::onEnter() _background->addChild(_emitter, 10); _emitter->setTexture( Director::getInstance()->getTextureCache()->addImage(s_fire) ); - + setEmitterPosition(); } @@ -93,10 +93,10 @@ void DemoGalaxy::onEnter() _emitter = ParticleGalaxy::create(); _emitter->retain(); _background->addChild(_emitter, 10); - + _emitter->setTexture( Director::getInstance()->getTextureCache()->addImage(s_fire) ); - - setEmitterPosition(); + + setEmitterPosition(); } std::string DemoGalaxy::title() @@ -117,7 +117,7 @@ void DemoFlower::onEnter() _emitter->retain(); _background->addChild(_emitter, 10); _emitter->setTexture( Director::getInstance()->getTextureCache()->addImage(s_stars1) ); - + setEmitterPosition(); } @@ -143,61 +143,61 @@ void DemoBigFlower::onEnter() _emitter->setTexture( Director::getInstance()->getTextureCache()->addImage(s_stars1) ); _emitter->setDuration(-1); - + // gravity _emitter->setGravity(Point::ZERO); - + // angle _emitter->setAngle(90); _emitter->setAngleVar(360); - + // speed of particles _emitter->setSpeed(160); _emitter->setSpeedVar(20); - + // radial _emitter->setRadialAccel(-120); _emitter->setRadialAccelVar(0); - + // tagential _emitter->setTangentialAccel(30); _emitter->setTangentialAccelVar(0); - + // emitter position _emitter->setPosition( Point(160,240) ); _emitter->setPosVar(Point::ZERO); - + // life of particles _emitter->setLife(4); _emitter->setLifeVar(1); - + // spin of particles _emitter->setStartSpin(0); _emitter->setStartSizeVar(0); _emitter->setEndSpin(0); _emitter->setEndSpinVar(0); - + // color of particles Color4F startColor(0.5f, 0.5f, 0.5f, 1.0f); _emitter->setStartColor(startColor); - + Color4F startColorVar(0.5f, 0.5f, 0.5f, 1.0f); _emitter->setStartColorVar(startColorVar); - + Color4F endColor(0.1f, 0.1f, 0.1f, 0.2f); _emitter->setEndColor(endColor); - - Color4F endColorVar(0.1f, 0.1f, 0.1f, 0.2f); + + Color4F endColorVar(0.1f, 0.1f, 0.1f, 0.2f); _emitter->setEndColorVar(endColorVar); - + // size, in pixels _emitter->setStartSize(80.0f); _emitter->setStartSizeVar(40.0f); _emitter->setEndSize(ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE); - + // emits per second _emitter->setEmissionRate(_emitter->getTotalParticles()/_emitter->getLife()); - + // additive _emitter->setBlendAdditive(true); @@ -224,33 +224,33 @@ void DemoRotFlower::onEnter() _background->addChild(_emitter, 10); ////_emitter->release(); // win32 : Remove this line _emitter->setTexture( Director::getInstance()->getTextureCache()->addImage(s_stars2) ); - + // duration _emitter->setDuration(-1); - + // gravity _emitter->setGravity(Point::ZERO); - + // angle _emitter->setAngle(90); _emitter->setAngleVar(360); - + // speed of particles _emitter->setSpeed(160); _emitter->setSpeedVar(20); - + // radial _emitter->setRadialAccel(-120); _emitter->setRadialAccelVar(0); - + // tagential _emitter->setTangentialAccel(30); _emitter->setTangentialAccelVar(0); - + // emitter position _emitter->setPosition( Point(160,240) ); _emitter->setPosVar(Point::ZERO); - + // life of particles _emitter->setLife(3); _emitter->setLifeVar(1); @@ -260,31 +260,31 @@ void DemoRotFlower::onEnter() _emitter->setStartSpinVar(0); _emitter->setEndSpin(0); _emitter->setEndSpinVar(2000); - + // color of particles Color4F startColor(0.5f, 0.5f, 0.5f, 1.0f); _emitter->setStartColor(startColor); - + Color4F startColorVar(0.5f, 0.5f, 0.5f, 1.0f); _emitter->setStartColorVar(startColorVar); - + Color4F endColor(0.1f, 0.1f, 0.1f, 0.2f); _emitter->setEndColor(endColor); - - Color4F endColorVar(0.1f, 0.1f, 0.1f, 0.2f); + + Color4F endColorVar(0.1f, 0.1f, 0.1f, 0.2f); _emitter->setEndColorVar(endColorVar); // size, in pixels _emitter->setStartSize(30.0f); _emitter->setStartSizeVar(00.0f); _emitter->setEndSize(ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE); - + // emits per second _emitter->setEmissionRate(_emitter->getTotalParticles()/_emitter->getLife()); // additive _emitter->setBlendAdditive(false); - + setEmitterPosition(); } @@ -305,9 +305,9 @@ void DemoMeteor::onEnter() _emitter = ParticleMeteor::create(); _emitter->retain(); _background->addChild(_emitter, 10); - + _emitter->setTexture( Director::getInstance()->getTextureCache()->addImage(s_fire) ); - + setEmitterPosition(); } @@ -328,9 +328,9 @@ void DemoSpiral::onEnter() _emitter = ParticleSpiral::create(); _emitter->retain(); _background->addChild(_emitter, 10); - + _emitter->setTexture( Director::getInstance()->getTextureCache()->addImage(s_fire) ); - + setEmitterPosition(); } @@ -351,11 +351,11 @@ void DemoExplosion::onEnter() _emitter = ParticleExplosion::create(); _emitter->retain(); _background->addChild(_emitter, 10); - + _emitter->setTexture( Director::getInstance()->getTextureCache()->addImage(s_stars1) ); - + _emitter->setAutoRemoveOnFinish(true); - + setEmitterPosition(); } @@ -377,10 +377,10 @@ void DemoSmoke::onEnter() _emitter->retain(); _background->addChild(_emitter, 10); _emitter->setTexture( Director::getInstance()->getTextureCache()->addImage(s_fire) ); - + auto p = _emitter->getPosition(); _emitter->setPosition( Point( p.x, 100) ); - + setEmitterPosition(); } @@ -401,34 +401,34 @@ void DemoSnow::onEnter() _emitter = ParticleSnow::create(); _emitter->retain(); _background->addChild(_emitter, 10); - + auto p = _emitter->getPosition(); _emitter->setPosition( Point( p.x, p.y-110) ); _emitter->setLife(3); _emitter->setLifeVar(1); - + // gravity _emitter->setGravity(Point(0,-10)); - + // speed of particles _emitter->setSpeed(130); _emitter->setSpeedVar(30); - - + + Color4F startColor = _emitter->getStartColor(); startColor.r = 0.9f; startColor.g = 0.9f; startColor.b = 0.9f; _emitter->setStartColor(startColor); - + Color4F startColorVar = _emitter->getStartColorVar(); startColorVar.b = 0.1f; _emitter->setStartColorVar(startColorVar); - + _emitter->setEmissionRate(_emitter->getTotalParticles()/_emitter->getLife()); - + _emitter->setTexture( Director::getInstance()->getTextureCache()->addImage(s_snow) ); - + setEmitterPosition(); } @@ -449,13 +449,13 @@ void DemoRain::onEnter() _emitter = ParticleRain::create(); _emitter->retain(); _background->addChild(_emitter, 10); - + auto p = _emitter->getPosition(); _emitter->setPosition( Point( p.x, p.y-100) ); _emitter->setLife(4); - + _emitter->setTexture( Director::getInstance()->getTextureCache()->addImage(s_fire) ); - + setEmitterPosition(); } @@ -473,74 +473,74 @@ void DemoModernArt::onEnter() { ParticleDemo::onEnter(); -//FIXME: If use ParticleSystemPoint, bada 1.0 device will crash. +//FIXME: If use ParticleSystemPoint, bada 1.0 device will crash. // Crash place: ParticleSystemPoint.cpp Line 149, function: glDrawArrays(GL_POINTS, 0, _particleIdx); _emitter = ParticleSystemQuad::createWithTotalParticles(1000); _emitter->retain(); _background->addChild(_emitter, 10); ////_emitter->release(); - + auto s = Director::getInstance()->getWinSize(); - + // duration _emitter->setDuration(-1); - + // gravity _emitter->setGravity(Point(0,0)); - + // angle _emitter->setAngle(0); _emitter->setAngleVar(360); - + // radial _emitter->setRadialAccel(70); _emitter->setRadialAccelVar(10); - + // tagential _emitter->setTangentialAccel(80); _emitter->setTangentialAccelVar(0); - + // speed of particles _emitter->setSpeed(50); _emitter->setSpeedVar(10); - + // emitter position _emitter->setPosition( Point( s.width/2, s.height/2) ); _emitter->setPosVar(Point::ZERO); - + // life of particles _emitter->setLife(2.0f); _emitter->setLifeVar(0.3f); - + // emits per frame _emitter->setEmissionRate(_emitter->getTotalParticles()/_emitter->getLife()); - + // color of particles Color4F startColor(0.5f, 0.5f, 0.5f, 1.0f); _emitter->setStartColor(startColor); - + Color4F startColorVar(0.5f, 0.5f, 0.5f, 1.0f); _emitter->setStartColorVar(startColorVar); - + Color4F endColor(0.1f, 0.1f, 0.1f, 0.2f); _emitter->setEndColor(endColor); - - Color4F endColorVar(0.1f, 0.1f, 0.1f, 0.2f); + + Color4F endColorVar(0.1f, 0.1f, 0.1f, 0.2f); _emitter->setEndColorVar(endColorVar); - + // size, in pixels _emitter->setStartSize(1.0f); _emitter->setStartSizeVar(1.0f); _emitter->setEndSize(32.0f); _emitter->setEndSizeVar(8.0f); - + // texture _emitter->setTexture( Director::getInstance()->getTextureCache()->addImage(s_fire) ); - + // additive _emitter->setBlendAdditive(false); - + setEmitterPosition(); } @@ -551,7 +551,7 @@ std::string DemoModernArt::title() //------------------------------------------------------------------ // -// DemoRing +// DemoRing // //------------------------------------------------------------------ void DemoRing::onEnter() @@ -569,7 +569,7 @@ void DemoRing::onEnter() _emitter->setSpeed(100); _emitter->setSpeedVar(0); _emitter->setEmissionRate(10000); - + setEmitterPosition(); } @@ -586,16 +586,16 @@ std::string DemoRing::title() void ParallaxParticle::onEnter() { ParticleDemo::onEnter(); - + _background->getParent()->removeChild(_background, true); _background = NULL; - auto p = ParallaxNode::create(); + auto p = ParallaxNode::create(); addChild(p, 5); auto p1 = Sprite::create(s_back3); auto p2 = Sprite::create(s_back3); - + p->addChild( p1, 1, Point(0.5f,1), Point(0,250) ); p->addChild(p2, 2, Point(1.5f,1), Point(0,50) ); @@ -605,15 +605,15 @@ void ParallaxParticle::onEnter() p1->addChild(_emitter, 10); _emitter->setPosition( Point(250,200) ); - + auto par = ParticleSun::create(); p2->addChild(par, 10); par->setTexture( Director::getInstance()->getTextureCache()->addImage(s_fire) ); - + auto move = MoveBy::create(4, Point(300,0)); auto move_back = move->reverse(); auto seq = Sequence::create( move, move_back, NULL); - p->runAction(RepeatForever::create(seq)); + p->runAction(RepeatForever::create(seq)); } std::string ParallaxParticle::title() @@ -685,7 +685,7 @@ void RadiusMode1::onEnter() Color4F endColor(0.1f, 0.1f, 0.1f, 0.2f); _emitter->setEndColor(endColor); - Color4F endColorVar(0.1f, 0.1f, 0.1f, 0.2f); + Color4F endColorVar(0.1f, 0.1f, 0.1f, 0.2f); _emitter->setEndColorVar(endColorVar); // size, in pixels @@ -769,7 +769,7 @@ void RadiusMode2::onEnter() Color4F endColor(0.1f, 0.1f, 0.1f, 0.2f); _emitter->setEndColor(endColor); - Color4F endColorVar(0.1f, 0.1f, 0.1f, 0.2f); + Color4F endColorVar(0.1f, 0.1f, 0.1f, 0.2f); _emitter->setEndColorVar(endColorVar); // size, in pixels @@ -853,7 +853,7 @@ void Issue704::onEnter() Color4F endColor(0.1f, 0.1f, 0.1f, 0.2f); _emitter->setEndColor(endColor); - Color4F endColorVar(0.1f, 0.1f, 0.1f, 0.2f); + Color4F endColorVar(0.1f, 0.1f, 0.1f, 0.2f); _emitter->setEndColorVar(endColorVar); // size, in pixels @@ -956,7 +956,7 @@ enum IDC_TOGGLE }; -static int sceneIdx = -1; +static int sceneIdx = -1; #define MAX_LAYER 44 @@ -1033,8 +1033,8 @@ Layer* backParticleAction() sceneIdx--; int total = MAX_LAYER; if( sceneIdx < 0 ) - sceneIdx += total; - + sceneIdx += total; + auto layer = createParticleLayer(sceneIdx); layer->autorelease(); @@ -1047,7 +1047,7 @@ Layer* restartParticleAction() layer->autorelease(); return layer; -} +} ParticleDemo::~ParticleDemo(void) { @@ -1060,46 +1060,46 @@ void ParticleDemo::onEnter(void) _color = LayerColor::create( Color4B(127,127,127,255) ); this->addChild(_color); - + _emitter = NULL; - + auto listener = EventListenerTouchAllAtOnce::create(); listener->onTouchesBegan = CC_CALLBACK_2(ParticleDemo::onTouchesBegan, this); listener->onTouchesMoved = CC_CALLBACK_2(ParticleDemo::onTouchesMoved, this); listener->onTouchesEnded = CC_CALLBACK_2(ParticleDemo::onTouchesEnded, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); - + auto s = Director::getInstance()->getWinSize(); - + auto item4 = MenuItemToggle::createWithCallback( CC_CALLBACK_1(ParticleDemo::toggleCallback, this), MenuItemFont::create( "Free Movement" ), MenuItemFont::create( "Relative Movement" ), MenuItemFont::create( "Grouped Movement" ), NULL ); - + auto menu = Menu::create(item4, NULL); - + menu->setPosition( Point::ZERO ); item4->setPosition( Point( VisibleRect::left().x, VisibleRect::bottom().y+ 100) ); item4->setAnchorPoint( Point(0,0) ); - + addChild( menu, 100 ); - + auto labelAtlas = LabelAtlas::create("0000", "fps_images.png", 12, 32, '.'); addChild(labelAtlas, 100, kTagParticleCount); labelAtlas->setPosition(Point(s.width-66,50)); - + // moving background _background = Sprite::create(s_back3); addChild(_background, 5); _background->setPosition( Point(s.width/2, s.height-180) ); - + auto move = MoveBy::create(4, Point(300,0) ); auto move_back = move->reverse(); auto seq = Sequence::create( move, move_back, NULL); _background->runAction( RepeatForever::create(seq) ); - - + + scheduleUpdate(); } @@ -1110,7 +1110,7 @@ std::string ParticleDemo::title() std::string ParticleDemo::subtitle() { - return "No titile"; + return "No title"; } void ParticleDemo::onTouchesBegan(const std::vector& touches, Event *event) @@ -1126,7 +1126,7 @@ void ParticleDemo::onTouchesMoved(const std::vector& touches, Event *ev void ParticleDemo::onTouchesEnded(const std::vector& touches, Event *event) { auto touch = touches[0]; - + auto location = touch->getLocation(); auto pos = Point::ZERO; @@ -1169,7 +1169,7 @@ void ParticleDemo::restartCallback(Object* sender) { if (_emitter != NULL) { - _emitter->resetSystem(); + _emitter->resetSystem(); } } @@ -1187,7 +1187,7 @@ void ParticleDemo::backCallback(Object* sender) s->addChild( backParticleAction() ); Director::getInstance()->replaceScene(s); s->release(); -} +} void ParticleDemo::setEmitterPosition() { @@ -1217,10 +1217,10 @@ void ParticleBatchHybrid::onEnter() addChild(batch, 10); schedule(schedule_selector(ParticleBatchHybrid::switchRender), 2.0f); - + auto node = Node::create(); addChild(node); - + _parent1 = batch; _parent2 = node; } @@ -1229,16 +1229,16 @@ void ParticleBatchHybrid::switchRender(float dt) { bool usingBatch = ( _emitter->getBatchNode() != NULL ); _emitter->removeFromParentAndCleanup(false); - + auto newParent = (usingBatch ? _parent2 : _parent1 ); newParent->addChild(_emitter); - + log("Particle: Using new parent: %s", usingBatch ? "CCNode" : "CCParticleBatchNode"); } std::string ParticleBatchHybrid::title() { - return "Paticle Batch"; + return "Particle Batch"; } std::string ParticleBatchHybrid::subtitle() @@ -1280,7 +1280,7 @@ void ParticleBatchMultipleEmitters::onEnter() std::string ParticleBatchMultipleEmitters::title() { - return "Paticle Batch"; + return "Particle Batch"; } std::string ParticleBatchMultipleEmitters::subtitle() @@ -1304,7 +1304,7 @@ void ParticleReorder::onEnter() auto parent2 = ParticleBatchNode::createWithTexture(ignore->getTexture()); ignore->unscheduleUpdate(); - for( unsigned int i=0; i<2;i++) + for( unsigned int i=0; i<2;i++) { auto parent = ( i==0 ? parent1 : parent2 ); @@ -1499,7 +1499,7 @@ void MultipleParticleSystems::onEnter() removeChild(_background, true); _background = NULL; - Director::getInstance()->getTextureCache()->addImage("Images/particles.png"); + Director::getInstance()->getTextureCache()->addImage("Images/particles.png"); for (int i = 0; i<5; i++) { auto particleSystem = ParticleSystemQuad::create("Particles/SpinningPeas.plist"); @@ -1528,15 +1528,15 @@ void MultipleParticleSystems::update(float dt) { auto atlas = (LabelAtlas*) getChildByTag(kTagParticleCount); - unsigned int count = 0; - + unsigned int count = 0; + Object* pObj = NULL; CCARRAY_FOREACH(getChildren(), pObj) { auto item = dynamic_cast(pObj); if (item != NULL) { - count += item->getParticleCount(); + count += item->getParticleCount(); } } char str[100] = {0}; @@ -1579,8 +1579,8 @@ void MultipleParticleSystemsBatched::update(float dt) { auto atlas = (LabelAtlas*) getChildByTag(kTagParticleCount); - unsigned count = 0; - + unsigned count = 0; + auto batchNode = getChildByTag(2); Object* pObj = NULL; CCARRAY_FOREACH(batchNode->getChildren(), pObj) @@ -1588,7 +1588,7 @@ void MultipleParticleSystemsBatched::update(float dt) auto item = dynamic_cast(pObj); if (item != NULL) { - count += item->getParticleCount(); + count += item->getParticleCount(); } } char str[50] = {0}; @@ -1631,7 +1631,7 @@ void AddAndDeleteParticleSystems::onEnter() particleSystem->setPosition(Point(i*15 +100,i*15+100)); - unsigned int randZ = rand() % 100; + unsigned int randZ = rand() % 100; _batchNode->addChild(particleSystem, randZ, -1); } @@ -1644,7 +1644,7 @@ void AddAndDeleteParticleSystems::onEnter() void AddAndDeleteParticleSystems::removeSystem(float dt) { int nChildrenCount = _batchNode->getChildren()->count(); - if (nChildrenCount > 0) + if (nChildrenCount > 0) { CCLOG("remove random system"); unsigned int uRand = rand() % (nChildrenCount - 1); @@ -1659,7 +1659,7 @@ void AddAndDeleteParticleSystems::removeSystem(float dt) particleSystem->setPosition(Point(rand() % 300 ,rand() % 400)); CCLOG("add a new system"); - unsigned int randZ = rand() % 100; + unsigned int randZ = rand() % 100; _batchNode->addChild(particleSystem, randZ, -1); } } @@ -1668,8 +1668,8 @@ void AddAndDeleteParticleSystems::update(float dt) { auto atlas = (LabelAtlas*) getChildByTag(kTagParticleCount); - unsigned int count = 0; - + unsigned int count = 0; + auto batchNode = getChildByTag(2); Object* pObj = NULL; CCARRAY_FOREACH(batchNode->getChildren(), pObj) @@ -1677,7 +1677,7 @@ void AddAndDeleteParticleSystems::update(float dt) auto item = dynamic_cast(pObj); if (item != NULL) { - count += item->getParticleCount(); + count += item->getParticleCount(); } } char str[100] = {0}; @@ -1796,7 +1796,7 @@ void ReorderParticleSystems::onEnter() void ReorderParticleSystems::reorderSystem(float time) { auto system = (ParticleSystem*)_batchNode->getChildren()->getObjectAtIndex(1); - _batchNode->reorderChild(system, system->getZOrder() - 1); + _batchNode->reorderChild(system, system->getZOrder() - 1); } @@ -1804,8 +1804,8 @@ void ReorderParticleSystems::update(float dt) { auto atlas = (LabelAtlas*) getChildByTag(kTagParticleCount); - unsigned int count = 0; - + unsigned int count = 0; + auto batchNode = getChildByTag(2); Object* pObj = NULL; CCARRAY_FOREACH(batchNode->getChildren(), pObj) @@ -1813,7 +1813,7 @@ void ReorderParticleSystems::update(float dt) auto item = dynamic_cast(pObj); if (item != NULL) { - count += item->getParticleCount(); + count += item->getParticleCount(); } } char str[100] = {0}; diff --git a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioArmatureTest/CocoStudioArmatureTest.lua b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioArmatureTest/CocoStudioArmatureTest.lua index feb1b19290..7531500dc8 100644 --- a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioArmatureTest/CocoStudioArmatureTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioArmatureTest/CocoStudioArmatureTest.lua @@ -3,7 +3,7 @@ local armaturePerformanceTag = 20000 local frameEventActionTag = 10000 local winSize = cc.Director:getInstance():getWinSize() local scheduler = cc.Director:getInstance():getScheduler() -local ArmatureTestIndex = +local ArmatureTestIndex = { TEST_ASYNCHRONOUS_LOADING = 1, TEST_DIRECT_LOADING = 2, @@ -52,7 +52,7 @@ function ArmatureTestScene.create() bg:setScaleY(scaleY) scene:addChild(bg) - return scene + return scene end function ArmatureTestScene.toMainMenuCallback() @@ -66,7 +66,7 @@ ArmatureTestLayer._restarItem = nil ArmatureTestLayer._nextItem = nil function ArmatureTestLayer:onEnter() - + end function ArmatureTestLayer.title(idx) @@ -97,7 +97,7 @@ function ArmatureTestLayer.title(idx) elseif ArmatureTestIndex.TEST_ARMATURE_NESTING == idx then return "Test Armature Nesting" elseif ArmatureTestIndex.TEST_ARMATURE_NESTING_2 == idx then - return "Test Armature Nesting 2" + return "Test Armature Nesting 2" end end @@ -127,7 +127,7 @@ function ArmatureTestLayer.create() layer:createToExtensionMenu() layer:onEnter() layer:creatTitleAndSubTitle(armatureSceneIdx) - end + end return layer end @@ -152,7 +152,7 @@ end function ArmatureTestLayer:createMenu() local menu = cc.Menu:create() - + self._backItem = cc.MenuItemImage:create(s_pPathB1, s_pPathB2) self._backItem:registerScriptTapHandler(self.backCallback) menu:addChild(self._backItem,itemTagBasic) @@ -160,14 +160,14 @@ function ArmatureTestLayer:createMenu() self._restarItem:registerScriptTapHandler(self.restartCallback) menu:addChild(self._restarItem,itemTagBasic) self._nextItem = cc.MenuItemImage:create(s_pPathF1, s_pPathF2) - menu:addChild(self._nextItem,itemTagBasic) + menu:addChild(self._nextItem,itemTagBasic) self._nextItem:registerScriptTapHandler(self.nextCallback) - - local size = cc.Director:getInstance():getWinSize() + + local size = cc.Director:getInstance():getWinSize() self._backItem:setPosition(cc.p(size.width / 2 - self._restarItem:getContentSize().width * 2, self._restarItem:getContentSize().height / 2)) self._restarItem:setPosition(cc.p(size.width / 2, self._restarItem:getContentSize().height / 2)) self._nextItem:setPosition(cc.p(size.width / 2 + self._restarItem:getContentSize().width * 2, self._restarItem:getContentSize().height / 2)) - + menu:setPosition(cc.p(0, 0)) self:addChild(menu) @@ -181,7 +181,7 @@ function ArmatureTestLayer.toExtensionMenu() end end -function ArmatureTestLayer:createToExtensionMenu() +function ArmatureTestLayer:createToExtensionMenu() cc.MenuItemFont:setFontName("Arial") cc.MenuItemFont:setFontSize(24) local menuItemFont = cc.MenuItemFont:create("Back") @@ -279,7 +279,7 @@ function TestAsynchronousLoading.create() layer:createMenu() layer:createToExtensionMenu() layer:onEnter() - end + end return layer end @@ -313,7 +313,7 @@ function TestDirectLoading.create() layer:createToExtensionMenu() layer:onEnter() layer:creatTitleAndSubTitle(armatureSceneIdx) - end + end return layer end @@ -348,7 +348,7 @@ function TestCSWithSkeleton.create() layer:createToExtensionMenu() layer:onEnter() layer:creatTitleAndSubTitle(armatureSceneIdx) - end + end return layer end @@ -366,7 +366,7 @@ function TestDragonBones20.extend(target) return target end -function TestDragonBones20:onEnter() +function TestDragonBones20:onEnter() local armature = ccs.Armature:create("Dragon") armature:getAnimation():playByIndex(1) armature:getAnimation():setSpeedScale(0.4) @@ -383,8 +383,8 @@ function TestDragonBones20.create() layer:createToExtensionMenu() layer:onEnter() layer:creatTitleAndSubTitle(armatureSceneIdx) - end - return layer + end + return layer end local TestPerformance = class("TestPerformance",ArmatureTestLayer) @@ -405,7 +405,7 @@ function TestPerformance.extend(target) return target end -function TestPerformance:refreshTitile() +function TestPerformance:refreshTitle() local subTitleInfo = ArmatureTestLayer.subTitle(5) .. self._armatureCount local label = tolua.cast(self:getChildByTag(10001),"LabelTTF") label:setString(subTitleInfo) @@ -429,7 +429,7 @@ function TestPerformance:addArmature(num) self:addArmatureToParent(armature) end - self:refreshTitile() + self:refreshTitle() end function TestPerformance:onEnter() @@ -446,7 +446,7 @@ function TestPerformance:onEnter() for i = 1, 20 do self:removeArmatureFromParent(armaturePerformanceTag + self._armatureCount) self._armatureCount = self._armatureCount - 1 - self:refreshTitile() + self:refreshTitle() end end @@ -458,7 +458,7 @@ function TestPerformance:onEnter() local increase = cc.MenuItemFont:create(" + ") increase:setColor(cc.c3b(0,200,20)) increase:registerScriptTapHandler(onIncrease) - + local menu = cc.Menu:create(decrease, increase ) menu:alignItemsHorizontally() menu:setPosition(cc.p(VisibleRect:getVisibleRect().width/2, VisibleRect:getVisibleRect().height-100)) @@ -481,8 +481,8 @@ function TestPerformance.create() layer:createToExtensionMenu() layer:creatTitleAndSubTitle(armatureSceneIdx) layer:onEnter() - end - return layer + end + return layer end local TestPerformanceBatchNode = class("TestPerformanceBatchNode",TestPerformance) @@ -507,7 +507,7 @@ function TestPerformanceBatchNode:removeArmatureFromParent(tag) self._batchNode:removeChildByTag(armaturePerformanceTag + self._armatureCount, true) end -function TestPerformanceBatchNode:onEnter() +function TestPerformanceBatchNode:onEnter() self._batchNode = ccs.BatchNode:create() self:addChild(self._batchNode) @@ -523,7 +523,7 @@ function TestPerformanceBatchNode:onEnter() for i = 1, 20 do self:removeArmatureFromParent(armaturePerformanceTag + self._armatureCount) self._armatureCount = self._armatureCount - 1 - self:refreshTitile() + self:refreshTitle() end end @@ -535,7 +535,7 @@ function TestPerformanceBatchNode:onEnter() local increase = cc.MenuItemFont:create(" + ") increase:setColor(cc.c3b(0,200,20)) increase:registerScriptTapHandler(onIncrease) - + local menu = cc.Menu:create(decrease, increase ) menu:alignItemsHorizontally() menu:setPosition(cc.p(VisibleRect:getVisibleRect().width/2, VisibleRect:getVisibleRect().height-100)) @@ -558,8 +558,8 @@ function TestPerformanceBatchNode.create() layer:createToExtensionMenu() layer:creatTitleAndSubTitle(armatureSceneIdx) layer:onEnter() - end - return layer + end + return layer end local TestChangeZorder = class("TestChangeZorder",ArmatureTestLayer) @@ -576,7 +576,7 @@ function TestChangeZorder.extend(target) return target end -function TestChangeZorder:onEnter() +function TestChangeZorder:onEnter() self.currentTag = -1 local armature = ccs.Armature:create("Knight_f/Knight") @@ -617,8 +617,8 @@ function TestChangeZorder.create() layer:createToExtensionMenu() layer:onEnter() layer:creatTitleAndSubTitle(armatureSceneIdx) - end - return layer + end + return layer end --UNDO callback @@ -635,7 +635,7 @@ function TestAnimationEvent.extend(target) return target end -function TestAnimationEvent:onEnter() +function TestAnimationEvent:onEnter() local armature = ccs.Armature:create("Cowboy") armature:getAnimation():play("Fire") armature:setScaleX(-0.24) @@ -682,8 +682,8 @@ function TestAnimationEvent.create() layer:createToExtensionMenu() layer:onEnter() layer:creatTitleAndSubTitle(armatureSceneIdx) - end - return layer + end + return layer end local TestFrameEvent = class("TestFrameEvent",ArmatureTestLayer) @@ -699,7 +699,7 @@ function TestFrameEvent.extend(target) return target end -function TestFrameEvent:onEnter() +function TestFrameEvent:onEnter() local armature = ccs.Armature:create("HeroAnimation") armature:getAnimation():play("attack") armature:getAnimation():setSpeedScale(0.5) @@ -708,7 +708,7 @@ function TestFrameEvent:onEnter() local function onFrameEvent( bone,evt,originFrameIndex,currentFrameIndex) if (not self:getActionByTag(frameEventActionTag)) or (not self:getActionByTag(frameEventActionTag):isDone()) then self:stopAllActions() - local action = cc.ShatteredTiles3D:create(0.2, cc.size(16,12), 5, false) + local action = cc.ShatteredTiles3D:create(0.2, cc.size(16,12), 5, false) action:setTag(frameEventActionTag) self:runAction(action) end @@ -741,8 +741,8 @@ function TestFrameEvent.create() layer:createToExtensionMenu() layer:creatTitleAndSubTitle(armatureSceneIdx) layer:onEnter() - end - return layer + end + return layer end local TestParticleDisplay = class("TestParticleDisplay",ArmatureTestLayer) @@ -760,8 +760,8 @@ function TestParticleDisplay.extend(target) return target end -function TestParticleDisplay:onEnter() - self:setTouchEnabled(true) +function TestParticleDisplay:onEnter() + self:setTouchEnabled(true) self.animationID = 0 self.armature = ccs.Armature:create("robot") @@ -780,7 +780,7 @@ function TestParticleDisplay:onEnter() bone:setZOrder(100) bone:setScale(1.2) self.armature:addBone(bone, "bady-a3") - + bone = ccs.Bone:create("p2") bone:addDisplay(p2, 0) bone:changeDisplayByIndex(0, true) @@ -812,9 +812,9 @@ function TestParticleDisplay.create() layer:createToExtensionMenu() layer:onEnter() layer:creatTitleAndSubTitle(armatureSceneIdx) - end + end - return layer + return layer end local TestUseMutiplePicture = class("TestUseMutiplePicture",ArmatureTestLayer) @@ -832,8 +832,8 @@ function TestUseMutiplePicture.extend(target) return target end -function TestUseMutiplePicture:onEnter() - self:setTouchEnabled(true) +function TestUseMutiplePicture:onEnter() + self:setTouchEnabled(true) self.displayIndex = 1 self.armature = ccs.Armature:create("Knight_f/Knight") @@ -842,14 +842,14 @@ function TestUseMutiplePicture:onEnter() self.armature:setScale(1.2) self:addChild(self.armature) - local weapon = + local weapon = { - "weapon_f-sword.png", - "weapon_f-sword2.png", - "weapon_f-sword3.png", - "weapon_f-sword4.png", - "weapon_f-sword5.png", - "weapon_f-knife.png", + "weapon_f-sword.png", + "weapon_f-sword2.png", + "weapon_f-sword3.png", + "weapon_f-sword4.png", + "weapon_f-sword5.png", + "weapon_f-knife.png", "weapon_f-hammer.png", } @@ -882,9 +882,9 @@ function TestUseMutiplePicture.create() layer:createToExtensionMenu() layer:onEnter() layer:creatTitleAndSubTitle(armatureSceneIdx) - end + end - return layer + return layer end local TestAnchorPoint = class("TestAnchorPoint",ArmatureTestLayer) @@ -925,7 +925,7 @@ function TestAnchorPoint.create() layer:createToExtensionMenu() layer:onEnter() layer:creatTitleAndSubTitle(armatureSceneIdx) - end + end return layer end @@ -946,7 +946,7 @@ function TestArmatureNesting.extend(target) end function TestArmatureNesting:onEnter() - self:setTouchEnabled(true) + self:setTouchEnabled(true) self.weaponIndex = 0 self.armature = ccs.Armature:create("cyborg") @@ -980,9 +980,9 @@ function TestArmatureNesting.create() layer:createToExtensionMenu() layer:onEnter() layer:creatTitleAndSubTitle(armatureSceneIdx) - end + end - return layer + return layer end local Hero = class("Hero") @@ -1140,9 +1140,9 @@ function TestArmatureNesting2.create() layer:createToExtensionMenu() layer:creatTitleAndSubTitle(armatureSceneIdx) layer:onEnter() - end + end - return layer + return layer end @@ -1173,7 +1173,7 @@ function nextArmatureTest() return armatureSceneArr[armatureSceneIdx]() end -function backArmatureTest() +function backArmatureTest() armatureSceneIdx = armatureSceneIdx - 1 if armatureSceneIdx <= 0 then armatureSceneIdx = armatureSceneIdx + table.getn(armatureSceneArr) @@ -1187,7 +1187,7 @@ function restartArmatureTest() end local function addFileInfo() - + end function runArmatureTestScene() diff --git a/samples/Lua/TestLua/Resources/luaScript/ParticleTest/ParticleTest.lua b/samples/Lua/TestLua/Resources/luaScript/ParticleTest/ParticleTest.lua index 8b4dca5692..f0a9c1ae7c 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ParticleTest/ParticleTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ParticleTest/ParticleTest.lua @@ -330,7 +330,7 @@ local function ParticleBatchHybrid() layer:registerScriptHandler(ParticleBatchHybrid_onEnterOrExit) - titleLabel:setString("Paticle Batch") + titleLabel:setString("Particle Batch") subtitleLabel:setString("Hybrid: batched and non batched every 2 seconds") return layer end @@ -364,7 +364,7 @@ local function ParticleBatchMultipleEmitters() layer:addChild(batch, 10) - titleLabel:setString("Paticle Batch") + titleLabel:setString("Particle Batch") subtitleLabel:setString("Multiple emitters. One Batch") return layer end @@ -900,7 +900,7 @@ local function RadiusMode1() emitter:setTexture(cc.TextureCache:getInstance():addImage("Images/stars-grayscale.png")) -- duration - emitter:setDuration(cc.PARTICLE_DURATION_INFINITY) + emitter:setDuration(cc.PARTICLE_DURATION_INFINITY) -- radius mode emitter:setEmitterMode(cc.PARTICLE_MODE_RADIUS) From 03d64e0689ae328bf0b7c88fcece165f92363fc8 Mon Sep 17 00:00:00 2001 From: signmotion Date: Fri, 29 Nov 2013 20:34:15 +0200 Subject: [PATCH 11/30] - Corrected CC_DISALLOW_COPY_AND_ASSIGN. --- cocos/base/CCPlatformMacros.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos/base/CCPlatformMacros.h b/cocos/base/CCPlatformMacros.h index f3c8c91ba7..7c1259e49c 100644 --- a/cocos/base/CCPlatformMacros.h +++ b/cocos/base/CCPlatformMacros.h @@ -243,8 +243,8 @@ public: virtual void set##funName(varType var) \ TypeName &operator =(const TypeName &) = delete; #else #define CC_DISALLOW_COPY_AND_ASSIGN(TypeName) \ - Class(const TypeName &); \ - Class &operator =(const TypeName &); + TypeName(const TypeName &); \ + TypeName &operator =(const TypeName &); #endif // A macro to disallow all the implicit constructors, namely the From 79401a7596787f5e6bb164eea73624d859df9b32 Mon Sep 17 00:00:00 2001 From: martell Date: Sat, 30 Nov 2013 06:09:12 +0000 Subject: [PATCH 12/30] quickly added win32 cmake --- CMakeLists.txt | 150 ++++++++++++++++++++-------- cocos/2d/CMakeLists.txt | 88 ++++++++++++---- cocos/audio/CMakeLists.txt | 30 ++++-- samples/Cpp/HelloCpp/CMakeLists.txt | 15 +++ 4 files changed, 210 insertions(+), 73 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c03a1e9d87..8603cc728f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,20 +10,19 @@ include(build/BuildHelpers.CMakeLists.txt) option(USE_CHIPMUNK "Use chipmunk for physics library" ON) option(USE_BOX2D "Use box2d for physics library" OFF) option(DEBUG_MODE "Debug or release?" ON) -option(BUILD_LIBS_LUA "Build lua libraries" ON) -option(BUILD_GUI "Build GUI library" ON) -option(BUILD_NETWORK "Build network library" ON) -option(BUILD_EXTENSIONS "Build extension library" ON) -option(BUILD_EDITOR_SPINE "Build editor support for spine" ON) -option(BUILD_EDITOR_COCOSTUDIO "Build editor support for cocostudio" ON) -option(BUILD_EDITOR_COCOSBUILDER "Build editor support for cocosbuilder" ON) +option(BUILD_LIBS_LUA "Build lua libraries" OFF) +option(BUILD_GUI "Build GUI library" OFF) +option(BUILD_NETWORK "Build network library" OFF) +option(BUILD_EXTENSIONS "Build extension library" OFF) +option(BUILD_EDITOR_SPINE "Build editor support for spine" OFF) +option(BUILD_EDITOR_COCOSTUDIO "Build editor support for cocostudio" OFF) +option(BUILD_EDITOR_COCOSBUILDER "Build editor support for cocosbuilder" OFF) option(BUILD_HelloCpp "Only build HelloCpp sample" ON) -option(BUILD_TestCpp "Only build TestCpp sample" ON) -option(BUILD_HelloLua "Only build HelloLua sample" ON) -option(BUILD_TestLua "Only build TestLua sample" ON) - +option(BUILD_TestCpp "Only build TestCpp sample" OFF) +option(BUILD_HelloLua "Only build HelloLua sample" OFF) +option(BUILD_TestLua "Only build TestLua sample" OFF) if(DEBUG_MODE) set(CMAKE_BUILD_TYPE DEBUG) @@ -31,18 +30,35 @@ else(DEBUG_MODE) set(CMAKE_BUILD_TYPE RELEASE) endif(DEBUG_MODE) +set(CMAKE_C_FLAGS_DEBUG "-DCOCOS2D_DEBUG=1") +set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG}) + +if(NOT MSVC) + set(CMAKE_C_FLAGS_DEBUG "-g -Wall -DCOCOS2D_DEBUG=1") set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG}) set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} "-std=c99") set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-std=c++11") +add_definitions(-DLINUX) +else() + +ADD_DEFINITIONS (-D_USRDLL -DCOCOS2DXWIN32_EXPORTS -DGL_GLEXT_PROTOTYPES) +ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS + -D_SCL_SECURE_NO_WARNINGS + -wd4251 -wd4244 -wd4334 -wd4005 -wd4820 -wd4710 + -wd4514) + +endif() + + if(USE_CHIPMUNK) message("Using chipmunk ...") - add_definitions(-DLINUX -DCC_ENABLE_CHIPMUNK_INTEGRATION=1) + add_definitions(-DCC_ENABLE_CHIPMUNK_INTEGRATION=1) elseif(USE_BOX2D) message("Using box2d ...") - add_definitions(-DLINUX -DCC_ENABLE_BOX2D_INTEGRATION=1) + add_definitions(-DCC_ENABLE_BOX2D_INTEGRATION=1) else(USE_CHIPMUNK) message(FATAL_ERROR "Must choose a physics library.") endif(USE_CHIPMUNK) @@ -54,40 +70,86 @@ else() set(ARCH_DIR "32-bit") endif() +if(WIN32) # Win32 + set(PLATFORM_FOLDER win32) +elseif(APPLE)# osx or ios + set(PLATFORM_FOLDER mac) +else() # Assume Linux + set(PLATFORM_FOLDER linux) +endif() + include_directories( - . - cocos - cocos/audio/include - cocos/2d - cocos/2d/platform - cocos/2d/platform/linux - cocos/base - cocos/physics - cocos/editor-support - cocos/math/kazmath/include - extensions - external - external/jpeg/include/linux - external/tiff/include/linux - external/webp/include/linux - external/glfw3/include/linux - external/curl/include/linux/${ARCH_DIR} - external/tinyxml2 - external/unzip - external/chipmunk/include/chipmunk - external/freetype2/include/linux - external/linux-specific/fmod/include/${ARCH_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/cocos + ${CMAKE_CURRENT_SOURCE_DIR}/cocos/audio/include + ${CMAKE_CURRENT_SOURCE_DIR}/cocos/2d + ${CMAKE_CURRENT_SOURCE_DIR}/cocos/2d/platform + ${CMAKE_CURRENT_SOURCE_DIR}/cocos/base + ${CMAKE_CURRENT_SOURCE_DIR}/cocos/physics + ${CMAKE_CURRENT_SOURCE_DIR}/cocos/editor-support + ${CMAKE_CURRENT_SOURCE_DIR}/cocos/math/kazmath/include + ${CMAKE_CURRENT_SOURCE_DIR}/extensions + ${CMAKE_CURRENT_SOURCE_DIR}/external + ${CMAKE_CURRENT_SOURCE_DIR}/external/tinyxml2 + ${CMAKE_CURRENT_SOURCE_DIR}/external/unzip + ${CMAKE_CURRENT_SOURCE_DIR}/external/chipmunk/include/chipmunk + ${CMAKE_CURRENT_SOURCE_DIR}/cocos/2d/platform/${PLATFORM_FOLDER} + ${CMAKE_CURRENT_SOURCE_DIR}/external/jpeg/include/${PLATFORM_FOLDER} + ${CMAKE_CURRENT_SOURCE_DIR}/external/png/include/${PLATFORM_FOLDER} + ${CMAKE_CURRENT_SOURCE_DIR}/external/tiff/include/${PLATFORM_FOLDER} + ${CMAKE_CURRENT_SOURCE_DIR}/external/webp/include/${PLATFORM_FOLDER} + ${CMAKE_CURRENT_SOURCE_DIR}/external/glfw3/include/${PLATFORM_FOLDER} + ${CMAKE_CURRENT_SOURCE_DIR}/external/freetype2/include/${PLATFORM_FOLDER} ) -link_directories( - /usr/local/lib - ${CMAKE_SOURCE_DIR}/external/jpeg/prebuilt/linux/${ARCH_DIR} - ${CMAKE_SOURCE_DIR}/external/tiff/prebuilt/linux/${ARCH_DIR} - ${CMAKE_SOURCE_DIR}/external/webp/prebuilt/linux/${ARCH_DIR} - ${CMAKE_SOURCE_DIR}/external/freetype2/prebuilt/linux/${ARCH_DIR} - ${CMAKE_SOURCE_DIR}/external/curl/prebuilt/linux/${ARCH_DIR} - ${CMAKE_SOURCE_DIR}/external/linux-specific/fmod/prebuilt/${ARCH_DIR} -) +if(WIN32) + include_directories( + ${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/gles/include/OGLES + ${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/icon/include + ${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/zlib/include + external/curl/include/${PLATFORM_FOLDER} + ) +elseif(APPLE) + include_directories( + ${CMAKE_CURRENT_SOURCE_DIR}/external/curl/include/${PLATFORM_FOLDER} + ) +else() + include_directories( + ${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/fmod/include/${ARCH_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/external/curl/include/${PLATFORM_FOLDER}/${ARCH_DIR} + ) +endif() + + +if(WIN32) + link_directories( + ${CMAKE_CURRENT_SOURCE_DIR}/external/jpeg/prebuilt/${PLATFORM_FOLDER} + ${CMAKE_CURRENT_SOURCE_DIR}/external/tiff/prebuilt/${PLATFORM_FOLDER} + ${CMAKE_CURRENT_SOURCE_DIR}/external/png/prebuilt/${PLATFORM_FOLDER} + ${CMAKE_CURRENT_SOURCE_DIR}/external/webp/prebuilt/${PLATFORM_FOLDER} + ${CMAKE_CURRENT_SOURCE_DIR}/external/glfw3/prebuilt/${PLATFORM_FOLDER} + ${CMAKE_CURRENT_SOURCE_DIR}/external/freetype2/prebuilt/${PLATFORM_FOLDER} + ${CMAKE_CURRENT_SOURCE_DIR}/external/curl/prebuilt/${PLATFORM_FOLDER} + ${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/gles/prebuilt + ${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/icon/prebuilt + ${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/zlib/prebuilt + ) +elseif(APPLE) + +else() + + link_directories( + /usr/local/lib + ${CMAKE_CURRENT_SOURCE_DIR}/external/jpeg/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/external/tiff/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/external/webp/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/external/png/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/external/freetype2/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/external/curl/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/fmod/prebuilt/${ARCH_DIR} + ) + +endif() # kazmath diff --git a/cocos/2d/CMakeLists.txt b/cocos/2d/CMakeLists.txt index 9446d95364..21eb76e8f1 100644 --- a/cocos/2d/CMakeLists.txt +++ b/cocos/2d/CMakeLists.txt @@ -1,3 +1,34 @@ +if(WIN32) + +ADD_DEFINITIONS(-DUNICODE -D_UNICODE) + +set(PLATFORM_SRC + platform/win32/CCStdC.cpp + platform/win32/CCFileUtilsWin32.cpp + platform/win32/CCCommon.cpp + platform/win32/CCApplication.cpp + platform/win32/CCEGLView.cpp + platform/win32/CCImage.cpp + platform/win32/CCDevice.cpp +) + +elseif(APPLE) + +else() + +set(PLATFORM_SRC + platform/linux/CCStdC.cpp + platform/linux/CCFileUtilsLinux.cpp + platform/linux/CCCommon.cpp + platform/linux/CCApplication.cpp + platform/linux/CCEGLView.cpp + platform/linux/CCImage.cpp + platform/linux/CCDevice.cpp +) + +endif() + + set(COCOS2D_SRC CCAction.cpp CCActionCamera.cpp @@ -107,40 +138,57 @@ set(COCOS2D_SRC platform/CCThread.cpp platform/CCEGLViewProtocol.cpp platform/CCFileUtils.cpp - platform/linux/CCStdC.cpp - platform/linux/CCFileUtilsLinux.cpp - platform/linux/CCCommon.cpp - platform/linux/CCApplication.cpp - platform/linux/CCEGLView.cpp - platform/linux/CCImage.cpp - platform/linux/CCDevice.cpp ) include(../physics/CMakeLists.txt) add_library(cocos2d STATIC ${COCOS2D_SRC} + ${PLATFORM_SRC} ${COCOS_PHYSICS_SRC} ) + +if(WIN32) +set(COCOS_LINK + libjpeg + libpng + libwebp + libtiff + freetype250 + glfw3 + glew32 + opengl32 + libiconv + libzlib + ) +elseif(APPLE) + +else() +set(COCOS_LINK + jpeg + png + webp + tiff + freetype + pthread + fontconfig + glfw + gles + GLEW + GL + X11 + rt + z +) +endif() + target_link_libraries(cocos2d cocosbase chipmunk_static tinyxml2 kazmath unzip - jpeg - webp - tiff - freetype - fontconfig - png - pthread - glfw - GLEW - GL - X11 - rt - z + ${COCOS_LINK} ) set_target_properties(cocos2d diff --git a/cocos/audio/CMakeLists.txt b/cocos/audio/CMakeLists.txt index 2f1d642cb2..0cdbb98dba 100644 --- a/cocos/audio/CMakeLists.txt +++ b/cocos/audio/CMakeLists.txt @@ -1,8 +1,3 @@ -set(AUDIO_SRC - linux/SimpleAudioEngineFMOD.cpp - linux/FmodAudioPlayer.cpp -) - # architecture if ( CMAKE_SIZEOF_VOID_P EQUAL 8 ) set(ARCH_DIR "64-bit") @@ -10,14 +5,31 @@ else() set(ARCH_DIR "32-bit") endif() -include_directories( - ../../external/linux-specific/fmod/include/${ARCH_DIR} -) +if(WIN32) + set(AUDIO_SRC + win32/SimpleAudioEngine.cpp + win32/MciPlayer.cpp + ) +else(APPLE) + +else() + set(AUDIO_SRC + linux/SimpleAudioEngineFMOD.cpp + linux/FmodAudioPlayer.cpp + ) + + include_directories( + ../../external/linux-specific/fmod/include/${ARCH_DIR} + ) + +endif() add_library(audio STATIC ${AUDIO_SRC} ) +if((NOT APPLE) AND (NOT WIN32)) + if ( CMAKE_SIZEOF_VOID_P EQUAL 8 ) set(FMOD_LIB "fmodex64") else() @@ -33,4 +45,4 @@ set_target_properties(audio ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" ) - +endif() diff --git a/samples/Cpp/HelloCpp/CMakeLists.txt b/samples/Cpp/HelloCpp/CMakeLists.txt index 667bf7cd18..a1fd45a40b 100644 --- a/samples/Cpp/HelloCpp/CMakeLists.txt +++ b/samples/Cpp/HelloCpp/CMakeLists.txt @@ -1,16 +1,31 @@ set(APP_NAME hellocpp) +if(WIN32) +set(SAMPLE_SRC + proj.win32/main.cpp + Classes/AppDelegate.cpp + Classes/HelloWorldScene.cpp +) + +else() set(SAMPLE_SRC proj.linux/main.cpp Classes/AppDelegate.cpp Classes/HelloWorldScene.cpp ) +endif() + # add the executable add_executable(${APP_NAME} ${SAMPLE_SRC} ) +if(WIN32) +set_target_properties(${APP_NAME} PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:WINDOWS") +set_target_properties(${APP_NAME} PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS") +endif(WIN32) + target_link_libraries(${APP_NAME} audio cocos2d) set(APP_BIN_DIR "${CMAKE_SOURCE_DIR}/bin/${APP_NAME}") From f369606d7762c41a77b05410bceaddf91ce5fdd6 Mon Sep 17 00:00:00 2001 From: martell Date: Sat, 30 Nov 2013 06:13:40 +0000 Subject: [PATCH 13/30] fix cocos2d-x for vs2013 --- cocos/2d/platform/win32/CCEGLView.cpp | 4 ++-- cocos/base/CCPlatformMacros.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos/2d/platform/win32/CCEGLView.cpp b/cocos/2d/platform/win32/CCEGLView.cpp index 3a18b81917..ce9b7f43d8 100644 --- a/cocos/2d/platform/win32/CCEGLView.cpp +++ b/cocos/2d/platform/win32/CCEGLView.cpp @@ -413,7 +413,7 @@ EGLView::EGLView() { g_keyCodeMap.insert(std::make_pair(item.glfwKeyCode, item.keyCode)); } - strcpy(_viewName, "Cocos2dxWin32"); + _viewName = "Cocos2dxWin32"; glfwSetErrorCallback(EGLViewEventHandler::OnGLFWError); glfwInit(); } @@ -433,7 +433,7 @@ bool EGLView::init(const char* viewName, float width, float height, float frameZ setFrameZoomFactor(frameZoomFactor); glfwWindowHint(GLFW_RESIZABLE,GL_FALSE); - _mainWindow = glfwCreateWindow(_screenSize.width * _frameZoomFactor, _screenSize.height * _frameZoomFactor, _viewName, nullptr, nullptr); + _mainWindow = glfwCreateWindow(_screenSize.width * _frameZoomFactor, _screenSize.height * _frameZoomFactor, _viewName.c_str(), nullptr, nullptr); glfwMakeContextCurrent(_mainWindow); glfwGetFramebufferSize(_mainWindow, &_frameBufferSize[0], &_frameBufferSize[1]); diff --git a/cocos/base/CCPlatformMacros.h b/cocos/base/CCPlatformMacros.h index f3c8c91ba7..76d5890240 100644 --- a/cocos/base/CCPlatformMacros.h +++ b/cocos/base/CCPlatformMacros.h @@ -237,7 +237,7 @@ public: virtual void set##funName(varType var) \ // A macro to disallow the copy constructor and operator= functions // This should be used in the private: declarations for a class #if defined(__GNUC__) && ((__GNUC__ >= 5) || ((__GNUG__ == 4) && (__GNUC_MINOR__ >= 4))) \ -|| (defined(__clang__) && (__clang_major__ >= 3)) + || (defined(__clang__) && (__clang_major__ >= 3)) || (_MSC_VER >= 1800) #define CC_DISALLOW_COPY_AND_ASSIGN(TypeName) \ TypeName(const TypeName &) = delete; \ TypeName &operator =(const TypeName &) = delete; From 5c40fecd5e9ce0305a3fc81d87810f2cc64bae64 Mon Sep 17 00:00:00 2001 From: martell Date: Sat, 30 Nov 2013 08:08:58 +0000 Subject: [PATCH 14/30] fix cmake for linux --- CMakeLists.txt | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8603cc728f..4cf8450079 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,23 +33,31 @@ endif(DEBUG_MODE) set(CMAKE_C_FLAGS_DEBUG "-DCOCOS2D_DEBUG=1") set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG}) -if(NOT MSVC) +if(WIN32) + ADD_DEFINITIONS (-D_USRDLL -DCOCOS2DXWIN32_EXPORTS) -set(CMAKE_C_FLAGS_DEBUG "-g -Wall -DCOCOS2D_DEBUG=1") + if(MSVC) + ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS + -D_SCL_SECURE_NO_WARNINGS + -wd4251 -wd4244 -wd4334 + -wd4005 -wd4820 -wd4710 + -wd4514) + else(MSVC)#MINGW + + endif(MSVC) +elseif(APPLE) + + +else()#Linux +ADD_DEFINITIONS(-DLINUX) +endif() + + +if(NOT MSVC)# all gcc +set(CMAKE_C_FLAGS_DEBUG "-g -Wall" ${CMAKE_C_FLAGS_DEBUG}) set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG}) - set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} "-std=c99") set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-std=c++11") - -add_definitions(-DLINUX) -else() - -ADD_DEFINITIONS (-D_USRDLL -DCOCOS2DXWIN32_EXPORTS -DGL_GLEXT_PROTOTYPES) -ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS - -D_SCL_SECURE_NO_WARNINGS - -wd4251 -wd4244 -wd4334 -wd4005 -wd4820 -wd4710 - -wd4514) - endif() From 2abca22bf4a8b824c2627ca25a5f4060c7d112c1 Mon Sep 17 00:00:00 2001 From: martell Date: Sat, 30 Nov 2013 08:27:34 +0000 Subject: [PATCH 15/30] Disabled some annoying Level 4 Warnings --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4cf8450079..5a281b6553 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,7 +41,7 @@ if(WIN32) -D_SCL_SECURE_NO_WARNINGS -wd4251 -wd4244 -wd4334 -wd4005 -wd4820 -wd4710 - -wd4514) + -wd4514 -wd4056 -wd4996 -wd4099) else(MSVC)#MINGW endif(MSVC) From 1a94e393afc9cfe53ff74844ad6617995bae693c Mon Sep 17 00:00:00 2001 From: martell Date: Sat, 30 Nov 2013 09:11:36 +0000 Subject: [PATCH 16/30] Setup for testing for every windows user --- CMakeLists.txt | 2 +- build/win32-msvc-2010-x86.cmd | 8 +++ build/win32-msvc-2012-x86.cmd | 8 +++ build/win32-msvc-2013-x86.cmd | 8 +++ samples/Cpp/HelloCpp/CMakeLists.txt | 77 +++++++++++++++++++---------- 5 files changed, 77 insertions(+), 26 deletions(-) create mode 100644 build/win32-msvc-2010-x86.cmd create mode 100644 build/win32-msvc-2012-x86.cmd create mode 100644 build/win32-msvc-2013-x86.cmd diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a281b6553..04f87eb31d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.6) +cmake_minimum_required(VERSION 2.8) project (Cocos2dx) # The version number diff --git a/build/win32-msvc-2010-x86.cmd b/build/win32-msvc-2010-x86.cmd new file mode 100644 index 0000000000..cf3d9e893f --- /dev/null +++ b/build/win32-msvc-2010-x86.cmd @@ -0,0 +1,8 @@ +@echo off +SETLOCAL + +:start +mkdir win32-msvc-vs2010-x86 +cd win32-msvc-vs2010-x86 +cmake -G "Visual Studio 10" ../.. +pause diff --git a/build/win32-msvc-2012-x86.cmd b/build/win32-msvc-2012-x86.cmd new file mode 100644 index 0000000000..7331e5b6b4 --- /dev/null +++ b/build/win32-msvc-2012-x86.cmd @@ -0,0 +1,8 @@ +@echo off +SETLOCAL + +:start +mkdir win32-msvc-vs2012-x86 +cd win32-msvc-vs2012-x86 +cmake -G "Visual Studio 11" ../.. +pause diff --git a/build/win32-msvc-2013-x86.cmd b/build/win32-msvc-2013-x86.cmd new file mode 100644 index 0000000000..35cad7dc85 --- /dev/null +++ b/build/win32-msvc-2013-x86.cmd @@ -0,0 +1,8 @@ +@echo off +SETLOCAL + +:start +mkdir win32-msvc-vs2013-x86 +cd win32-msvc-vs2013-x86 +cmake -G "Visual Studio 12" ../.. +pause diff --git a/samples/Cpp/HelloCpp/CMakeLists.txt b/samples/Cpp/HelloCpp/CMakeLists.txt index a1fd45a40b..cb9c3f0fd1 100644 --- a/samples/Cpp/HelloCpp/CMakeLists.txt +++ b/samples/Cpp/HelloCpp/CMakeLists.txt @@ -1,40 +1,67 @@ set(APP_NAME hellocpp) -if(WIN32) -set(SAMPLE_SRC - proj.win32/main.cpp - Classes/AppDelegate.cpp - Classes/HelloWorldScene.cpp -) - +if(QT) + set(PLATFORM_SRC + proj.qt/main.cpp + ) +elseif(ANDROID) + set(PLATFORM_SRC + proj.android/jni/hellocpp/main.cpp + ) +elseif(WIN32) + set(PLATFORM_SRC + proj.win32/main.cpp + ) +elseif(APPLE) + if(IOS) + set(PLATFORM_SRC + proj.ios/main.m + proj.ios/AppController.mm + proj.ios/RootViewController.mm + ) + else() + set(PLATFORM_SRC + proj.mac/main.m + ) + endif() else() + set(PLATFORM_SRC + proj.linux/main.cpp + ) + endif() + set(SAMPLE_SRC - proj.linux/main.cpp + ${PLATFORM_SRC} Classes/AppDelegate.cpp Classes/HelloWorldScene.cpp ) -endif() - # add the executable add_executable(${APP_NAME} ${SAMPLE_SRC} ) -if(WIN32) -set_target_properties(${APP_NAME} PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:WINDOWS") -set_target_properties(${APP_NAME} PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS") -endif(WIN32) +#get our resources +add_custom_command(TARGET ${APP_NAME} PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_directory + ${CMAKE_CURRENT_SOURCE_DIR}/Resources ${CMAKE_CURRENT_BINARY_DIR}) + +if(WIN32 AND MSVC) + + #get our dlls + add_custom_command(TARGET ${APP_NAME} PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_SOURCE_DIR}/../../../external/win32-specific/gles/prebuilt/glew32.dll + ${CMAKE_CURRENT_BINARY_DIR}) + + add_custom_command(TARGET ${APP_NAME} PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_SOURCE_DIR}/../../../external/win32-specific/zlib/prebuilt/zlib1.dll + ${CMAKE_CURRENT_BINARY_DIR}/Debug) + + #Visual Studio Defaults to wrong type + set_target_properties(${APP_NAME} PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:WINDOWS") + set_target_properties(${APP_NAME} PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS") +endif() target_link_libraries(${APP_NAME} audio cocos2d) - -set(APP_BIN_DIR "${CMAKE_SOURCE_DIR}/bin/${APP_NAME}") - -set_target_properties(${APP_NAME} PROPERTIES - RUNTIME_OUTPUT_DIRECTORY "${APP_BIN_DIR}") - -pre_build(${APP_NAME} - COMMAND ${CMAKE_COMMAND} -E remove_directory ${APP_BIN_DIR}/Resources - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/Resources ${APP_BIN_DIR}/Resources - ) - From e4883fb105696789365bdf588745aa0de54a4240 Mon Sep 17 00:00:00 2001 From: minggo Date: Mon, 2 Dec 2013 10:19:39 +0800 Subject: [PATCH 17/30] [ci skip] --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 6e593585b2..c27b41ef19 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ cocos2d-x-3.0beta0 ?? 2013 [All] [NEW] Upgrated Box2D to 2.3.0 [NEW] Added ThreadHelper, ThreadHelper::runOnGLThread() simplify invoking engine codes and OpenGL ES commands in a thread other then gl thread. + [NEW] Added tga format support again. [Android] [NEW] build/android-build.sh: add supporting to generate .apk file [FIX] XMLHttpRequest receives wrong binary array. From 7a8653525b5527e9220f758648d6960c1796357b Mon Sep 17 00:00:00 2001 From: martell Date: Mon, 2 Dec 2013 06:37:32 +0000 Subject: [PATCH 18/30] fixed Audio for Linux --- cocos/audio/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/audio/CMakeLists.txt b/cocos/audio/CMakeLists.txt index 0cdbb98dba..9ad9e99b12 100644 --- a/cocos/audio/CMakeLists.txt +++ b/cocos/audio/CMakeLists.txt @@ -10,7 +10,7 @@ if(WIN32) win32/SimpleAudioEngine.cpp win32/MciPlayer.cpp ) -else(APPLE) +elseif(APPLE) else() set(AUDIO_SRC From 4f0f3f32358e43d4fa8e7783eb9115582b2bcf70 Mon Sep 17 00:00:00 2001 From: martell Date: Mon, 2 Dec 2013 06:57:47 +0000 Subject: [PATCH 19/30] fix for -DEBUG=1 --- CMakeLists.txt | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 04f87eb31d..7b0db88ca5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,7 +34,7 @@ set(CMAKE_C_FLAGS_DEBUG "-DCOCOS2D_DEBUG=1") set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG}) if(WIN32) - ADD_DEFINITIONS (-D_USRDLL -DCOCOS2DXWIN32_EXPORTS) + ADD_DEFINITIONS (-D_USRDLL -DCOCOS2DXWIN32_EXPORTS -D_WINDOWS -DWIN32) if(MSVC) ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS @@ -54,12 +54,16 @@ endif() if(NOT MSVC)# all gcc -set(CMAKE_C_FLAGS_DEBUG "-g -Wall" ${CMAKE_C_FLAGS_DEBUG}) +set(CMAKE_C_FLAGS_DEBUG "-g -Wall -DCOCOS2D_DEBUG=1") set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG}) set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} "-std=c99") set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-std=c++11") endif() +if(MINGW) + add_definitions(-DGLEW_STATIC) +endif() + if(USE_CHIPMUNK) message("Using chipmunk ...") @@ -130,18 +134,25 @@ endif() if(WIN32) + + if(NOT MINGW) link_directories( ${CMAKE_CURRENT_SOURCE_DIR}/external/jpeg/prebuilt/${PLATFORM_FOLDER} ${CMAKE_CURRENT_SOURCE_DIR}/external/tiff/prebuilt/${PLATFORM_FOLDER} ${CMAKE_CURRENT_SOURCE_DIR}/external/png/prebuilt/${PLATFORM_FOLDER} - ${CMAKE_CURRENT_SOURCE_DIR}/external/webp/prebuilt/${PLATFORM_FOLDER} - ${CMAKE_CURRENT_SOURCE_DIR}/external/glfw3/prebuilt/${PLATFORM_FOLDER} ${CMAKE_CURRENT_SOURCE_DIR}/external/freetype2/prebuilt/${PLATFORM_FOLDER} ${CMAKE_CURRENT_SOURCE_DIR}/external/curl/prebuilt/${PLATFORM_FOLDER} - ${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/gles/prebuilt ${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/icon/prebuilt ${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/zlib/prebuilt ) + endif() + + link_directories( + ${CMAKE_CURRENT_SOURCE_DIR}/external/webp/prebuilt/${PLATFORM_FOLDER} + ${CMAKE_CURRENT_SOURCE_DIR}/external/glfw3/prebuilt/${PLATFORM_FOLDER} + ${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/gles/prebuilt + ) + elseif(APPLE) else() From 06ff1bc5947a762623853754161a8cded6870aa4 Mon Sep 17 00:00:00 2001 From: martell Date: Mon, 2 Dec 2013 07:10:37 +0000 Subject: [PATCH 20/30] Fixed HelloCpp Linking on Linux --- cocos/2d/CMakeLists.txt | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/cocos/2d/CMakeLists.txt b/cocos/2d/CMakeLists.txt index 21eb76e8f1..a5838f5dcb 100644 --- a/cocos/2d/CMakeLists.txt +++ b/cocos/2d/CMakeLists.txt @@ -149,6 +149,26 @@ add_library(cocos2d STATIC ) if(WIN32) + +if(MINGW) + +set(COCOS_LINK + z + jpeg + png + webp + tiff + glfw3 + glew32 + opengl32 + iconv + freetype + bz2 + ) + +else() + + set(COCOS_LINK libjpeg libpng @@ -161,19 +181,21 @@ set(COCOS_LINK libiconv libzlib ) + +endif() + elseif(APPLE) else() set(COCOS_LINK jpeg - png webp tiff freetype - pthread fontconfig + png + pthread glfw - gles GLEW GL X11 From 3b9d8274f8306d340ec2257cacc7da6fa8210fa7 Mon Sep 17 00:00:00 2001 From: martell Date: Mon, 2 Dec 2013 07:41:27 +0000 Subject: [PATCH 21/30] Restore Linux CMake to default --- CMakeLists.txt | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b0db88ca5..08c2eddb1f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,8 @@ set(Cocos2dxSamples_VERSION_MINOR 0) include(build/BuildHelpers.CMakeLists.txt) +if(WIN32 OR APPLE) + option(USE_CHIPMUNK "Use chipmunk for physics library" ON) option(USE_BOX2D "Use box2d for physics library" OFF) option(DEBUG_MODE "Debug or release?" ON) @@ -18,12 +20,33 @@ option(BUILD_EDITOR_SPINE "Build editor support for spine" OFF) option(BUILD_EDITOR_COCOSTUDIO "Build editor support for cocostudio" OFF) option(BUILD_EDITOR_COCOSBUILDER "Build editor support for cocosbuilder" OFF) - option(BUILD_HelloCpp "Only build HelloCpp sample" ON) option(BUILD_TestCpp "Only build TestCpp sample" OFF) option(BUILD_HelloLua "Only build HelloLua sample" OFF) option(BUILD_TestLua "Only build TestLua sample" OFF) +else()#temp + +option(USE_CHIPMUNK "Use chipmunk for physics library" ON) +option(USE_BOX2D "Use box2d for physics library" OFF) +option(DEBUG_MODE "Debug or release?" ON) +option(BUILD_LIBS_LUA "Build lua libraries" ON) +option(BUILD_GUI "Build GUI library" ON) +option(BUILD_NETWORK "Build network library" ON) +option(BUILD_EXTENSIONS "Build extension library" ON) +option(BUILD_EDITOR_SPINE "Build editor support for spine" ON) +option(BUILD_EDITOR_COCOSTUDIO "Build editor support for cocostudio" ON) +option(BUILD_EDITOR_COCOSBUILDER "Build editor support for cocosbuilder" ON) + + +option(BUILD_HelloCpp "Only build HelloCpp sample" ON) +option(BUILD_TestCpp "Only build TestCpp sample" ON) +option(BUILD_HelloLua "Only build HelloLua sample" ON) +option(BUILD_TestLua "Only build TestLua sample" ON) + +endif()#temp + + if(DEBUG_MODE) set(CMAKE_BUILD_TYPE DEBUG) else(DEBUG_MODE) From 7378c0ded06d60851781c4e10d41f2b4ac9055c6 Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 2 Dec 2013 17:26:19 +0800 Subject: [PATCH 22/30] Update AUTHORS [ci skip] --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 98a6d05ea4..ce0802b6e3 100644 --- a/AUTHORS +++ b/AUTHORS @@ -93,6 +93,7 @@ Developers: martell use tinyxml2 to replace libxml2 Added Mingw-crt Support without breaking VS SDK + CMake support for windows. mchinen fix emulator issue for OpenGL ES 2.0 on Android From 229aa5433c5763b72b5551b8c27a11df19334791 Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 2 Dec 2013 17:27:28 +0800 Subject: [PATCH 23/30] Update CHANGELOG [ci skip] --- CHANGELOG | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index c27b41ef19..c8a8607ac8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,6 +8,9 @@ cocos2d-x-3.0beta0 ?? 2013 [FIX] XMLHttpRequest receives wrong binary array. [NEW] Bindings-generator supports to bind 'unsigned long'. [FIX] 'Test Frame Event' of TestJavascript/CocoStudioArmatureTest Crashes. +[Windows] + [NEW] CMake support for windows. + cocos2d-x-3.0alpha1 Nov.19 2013 [all platforms] [DOC] Added RELEASE_NOTES and CODING_STYLE.md files From dba58f6a9ba09b8a6732d0de411bf8b78e26c33c Mon Sep 17 00:00:00 2001 From: boyu0 Date: Mon, 2 Dec 2013 18:29:04 +0800 Subject: [PATCH 24/30] issue #2771: add more joints --- cocos/physics/CCPhysicsJoint.cpp | 491 +++++++++++++++++++++++++++---- cocos/physics/CCPhysicsJoint.h | 164 ++++++++++- 2 files changed, 592 insertions(+), 63 deletions(-) diff --git a/cocos/physics/CCPhysicsJoint.cpp b/cocos/physics/CCPhysicsJoint.cpp index 295560a9e6..91fc2a4dee 100644 --- a/cocos/physics/CCPhysicsJoint.cpp +++ b/cocos/physics/CCPhysicsJoint.cpp @@ -97,46 +97,6 @@ void PhysicsJoint::setEnable(bool enable) } } -PhysicsJointPin::PhysicsJointPin() -{ - -} - -PhysicsJointPin::~PhysicsJointPin() -{ - -} - -PhysicsJointFixed::PhysicsJointFixed() -{ - -} - -PhysicsJointFixed::~PhysicsJointFixed() -{ - -} - -PhysicsJointLimit::PhysicsJointLimit() -{ - -} - -PhysicsJointLimit::~PhysicsJointLimit() -{ - -} - -PhysicsJointDistance::PhysicsJointDistance() -{ - -} - -PhysicsJointDistance::~PhysicsJointDistance() -{ - -} - PhysicsBodyInfo* PhysicsJoint::getBodyInfo(PhysicsBody* body) const { return body->_info; @@ -147,7 +107,6 @@ Node* PhysicsJoint::getBodyNode(PhysicsBody* body) const return body->_node; } - void PhysicsJoint::setCollisionEnable(bool enable) { if (_collisionEnable != enable) @@ -190,6 +149,19 @@ void PhysicsJoint::destroy(PhysicsJoint* joint) } } +void PhysicsJoint::setMaxForce(float force) +{ + for (cpConstraint* joint : _info->getJoints()) + { + joint->maxForce = PhysicsHelper::float2cpfloat(force); + } +} + +float PhysicsJoint::getMaxForce() const +{ + return PhysicsHelper::cpfloat2float(_info->getJoints().front()->maxForce); +} + PhysicsJointFixed* PhysicsJointFixed::construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr) { PhysicsJointFixed* joint = new PhysicsJointFixed(); @@ -262,16 +234,6 @@ bool PhysicsJointPin::init(PhysicsBody *a, PhysicsBody *b, const Point& anchr) return false; } -void PhysicsJointPin::setMaxForce(float force) -{ - _info->getJoints().front()->maxForce = PhysicsHelper::float2cpfloat(force); -} - -float PhysicsJointPin::getMaxForce() const -{ - return PhysicsHelper::cpfloat2float(_info->getJoints().front()->maxForce); -} - PhysicsJointLimit* PhysicsJointLimit::construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2) { PhysicsJointLimit* joint = new PhysicsJointLimit(); @@ -295,7 +257,7 @@ bool PhysicsJointLimit::init(PhysicsBody* a, PhysicsBody* b, const Point& anchr1 PhysicsHelper::point2cpv(anchr1), PhysicsHelper::point2cpv(anchr2), 0, - PhysicsHelper::float2cpfloat(_bodyA->local2World(anchr1).getDistance(_bodyB->local2World(anchr2)))); + PhysicsHelper::float2cpfloat(_bodyB->local2World(anchr1).getDistance(_bodyA->local2World(anchr2)))); CC_BREAK_IF(joint == nullptr); @@ -327,6 +289,26 @@ void PhysicsJointLimit::setMax(float max) cpSlideJointSetMax(_info->getJoints().front(), PhysicsHelper::float2cpfloat(max)); } +Point PhysicsJointLimit::getAnchr1() const +{ + return PhysicsHelper::cpv2point(cpSlideJointGetAnchr1(_info->getJoints().front())); +} + +void PhysicsJointLimit::setAnchr1(const Point& anchr) +{ + cpSlideJointSetAnchr1(_info->getJoints().front(), PhysicsHelper::point2cpv(anchr)); +} + +Point PhysicsJointLimit::getAnchr2() const +{ + return PhysicsHelper::cpv2point(cpSlideJointGetAnchr2(_info->getJoints().front())); +} + +void PhysicsJointLimit::setAnchr2(const Point& anchr) +{ + cpSlideJointSetAnchr1(_info->getJoints().front(), PhysicsHelper::point2cpv(anchr)); +} + PhysicsJointDistance* PhysicsJointDistance::construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2) { PhysicsJointDistance* joint = new PhysicsJointDistance(); @@ -361,5 +343,410 @@ bool PhysicsJointDistance::init(PhysicsBody* a, PhysicsBody* b, const Point& anc return false; } +float PhysicsJointDistance::getDistance() const +{ + return PhysicsHelper::cpfloat2float(cpPinJointGetDist(_info->getJoints().front())); +} + +void PhysicsJointDistance::setDistance(float distance) +{ + cpPinJointSetDist(_info->getJoints().front(), PhysicsHelper::float2cpfloat(distance)); +} + +PhysicsJointSpring* PhysicsJointSpring::construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2, float stiffness, float damping) +{ + PhysicsJointSpring* joint = new PhysicsJointSpring(); + + if (joint && joint->init(a, b, anchr1, anchr2, stiffness, damping)) + { + return joint; + } + + CC_SAFE_DELETE(joint); + return nullptr; +} + +bool PhysicsJointSpring::init(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2, float stiffness, float damping) +{ + do { + CC_BREAK_IF(!PhysicsJoint::init(a, b)); + + cpConstraint* joint = cpDampedSpringNew(getBodyInfo(a)->getBody(), + getBodyInfo(b)->getBody(), + PhysicsHelper::point2cpv(anchr1), + PhysicsHelper::point2cpv(anchr2), + PhysicsHelper::float2cpfloat(_bodyB->local2World(anchr1).getDistance(_bodyA->local2World(anchr2))), + PhysicsHelper::float2cpfloat(stiffness), + PhysicsHelper::float2cpfloat(damping)); + + CC_BREAK_IF(joint == nullptr); + + _info->add(joint); + + return true; + } while (false); + + return false; +} + +Point PhysicsJointSpring::getAnchr1() const +{ + return PhysicsHelper::cpv2point(cpDampedSpringGetAnchr1(_info->getJoints().front())); +} + +void PhysicsJointSpring::setAnchr1(const Point& anchr) +{ + cpDampedSpringSetAnchr1(_info->getJoints().front(), PhysicsHelper::point2cpv(anchr)); +} + +Point PhysicsJointSpring::getAnchr2() const +{ + return PhysicsHelper::cpv2point(cpDampedSpringGetAnchr2(_info->getJoints().front())); +} + +void PhysicsJointSpring::setAnchr2(const Point& anchr) +{ + cpDampedSpringSetAnchr1(_info->getJoints().front(), PhysicsHelper::point2cpv(anchr)); +} + +float PhysicsJointSpring::getRestLength() const +{ + return PhysicsHelper::cpfloat2float(cpDampedSpringGetRestLength(_info->getJoints().front())); +} + +void PhysicsJointSpring::setRestLength(float restLength) +{ + cpDampedSpringSetRestLength(_info->getJoints().front(), PhysicsHelper::float2cpfloat(restLength)); +} + +float PhysicsJointSpring::getStiffness() const +{ + return PhysicsHelper::cpfloat2float(cpDampedSpringGetStiffness(_info->getJoints().front())); +} + +void PhysicsJointSpring::setStiffness(float stiffness) +{ + cpDampedSpringSetStiffness(_info->getJoints().front(), PhysicsHelper::float2cpfloat(stiffness)); +} + +float PhysicsJointSpring::getDamping() const +{ + return PhysicsHelper::cpfloat2float(cpDampedSpringGetDamping(_info->getJoints().front())); +} + +void PhysicsJointSpring::setDamping(float damping) +{ + cpDampedSpringSetDamping(_info->getJoints().front(), PhysicsHelper::float2cpfloat(damping)); +} + +Point PhysicsJointGroove::getGrooveA() const +{ + return PhysicsHelper::cpv2point(cpGrooveJointGetGrooveA(_info->getJoints().front())); +} + +void PhysicsJointGroove::setGrooveA(const Point& grooveA) +{ + cpGrooveJointSetGrooveA(_info->getJoints().front(), PhysicsHelper::point2cpv(grooveA)); +} + +Point PhysicsJointGroove::getGrooveB() const +{ + return PhysicsHelper::cpv2point(cpGrooveJointGetGrooveB(_info->getJoints().front())); +} + +void PhysicsJointGroove::setGrooveB(const Point& grooveB) +{ + cpGrooveJointSetGrooveB(_info->getJoints().front(), PhysicsHelper::point2cpv(grooveB)); +} + +Point PhysicsJointGroove::getAnchr2() const +{ + return PhysicsHelper::cpv2point(cpGrooveJointGetAnchr2(_info->getJoints().front())); +} + +void PhysicsJointGroove::setAnchr2(const Point& anchr2) +{ + cpGrooveJointSetAnchr2(_info->getJoints().front(), PhysicsHelper::point2cpv(anchr2)); +} + +PhysicsJointRotarySpring* PhysicsJointRotarySpring::construct(PhysicsBody* a, PhysicsBody* b, float stiffness, float damping) +{ + PhysicsJointRotarySpring* joint = new PhysicsJointRotarySpring(); + + if (joint && joint->init(a, b, stiffness, damping)) + { + return joint; + } + + CC_SAFE_DELETE(joint); + return nullptr; +} + +bool PhysicsJointRotarySpring::init(PhysicsBody* a, PhysicsBody* b, float stiffness, float damping) +{ + do { + CC_BREAK_IF(!PhysicsJoint::init(a, b)); + + cpConstraint* joint = cpDampedRotarySpringNew(getBodyInfo(a)->getBody(), + getBodyInfo(b)->getBody(), + PhysicsHelper::float2cpfloat(_bodyB->getRotation() - _bodyA->getRotation()), + PhysicsHelper::float2cpfloat(stiffness), + PhysicsHelper::float2cpfloat(damping)); + + CC_BREAK_IF(joint == nullptr); + + _info->add(joint); + + return true; + } while (false); + + return false; +} + +float PhysicsJointRotarySpring::getRestAngle() const +{ + return PhysicsHelper::cpfloat2float(cpDampedRotarySpringGetRestAngle(_info->getJoints().front())); +} + +void PhysicsJointRotarySpring::setRestAngle(float restAngle) +{ + cpDampedRotarySpringSetRestAngle(_info->getJoints().front(), PhysicsHelper::float2cpfloat(restAngle)); +} + +float PhysicsJointRotarySpring::getStiffness() const +{ + return PhysicsHelper::cpfloat2float(cpDampedRotarySpringGetStiffness(_info->getJoints().front())); +} + +void PhysicsJointRotarySpring::setStiffness(float stiffness) +{ + cpDampedRotarySpringSetStiffness(_info->getJoints().front(), PhysicsHelper::float2cpfloat(stiffness)); +} + +float PhysicsJointRotarySpring::getDamping() const +{ + return PhysicsHelper::cpfloat2float(cpDampedRotarySpringGetDamping(_info->getJoints().front())); +} + +void PhysicsJointRotarySpring::setDamping(float damping) +{ + cpDampedRotarySpringSetDamping(_info->getJoints().front(), PhysicsHelper::float2cpfloat(damping)); +} + +PhysicsJointRotaryLimit* PhysicsJointRotaryLimit::construct(PhysicsBody* a, PhysicsBody* b) +{ + PhysicsJointRotaryLimit* joint = new PhysicsJointRotaryLimit(); + + if (joint && joint->init(a, b)) + { + return joint; + } + + CC_SAFE_DELETE(joint); + return nullptr; +} + +bool PhysicsJointRotaryLimit::init(PhysicsBody* a, PhysicsBody* b) +{ + do + { + CC_BREAK_IF(!PhysicsJoint::init(a, b)); + + cpConstraint* joint = cpRotaryLimitJointNew(getBodyInfo(a)->getBody(), + getBodyInfo(b)->getBody(), + 0, + PhysicsHelper::float2cpfloat(_bodyB->getRotation() - _bodyA->getRotation())); + + CC_BREAK_IF(joint == nullptr); + + _info->add(joint); + + return true; + } while (false); + + return false; +} + +float PhysicsJointRotaryLimit::getMin() const +{ + return PhysicsHelper::cpfloat2float(cpRotaryLimitJointGetMin(_info->getJoints().front())); +} + +void PhysicsJointRotaryLimit::setMin(float min) +{ + cpRotaryLimitJointSetMin(_info->getJoints().front(), PhysicsHelper::float2cpfloat(min)); +} + +float PhysicsJointRotaryLimit::getMax() const +{ + return PhysicsHelper::cpfloat2float(cpRotaryLimitJointGetMax(_info->getJoints().front())); +} + +void PhysicsJointRotaryLimit::setMax(float max) +{ + cpRotaryLimitJointSetMax(_info->getJoints().front(), PhysicsHelper::float2cpfloat(max)); +} + +PhysicsJointRatchet* PhysicsJointRatchet::construct(PhysicsBody* a, PhysicsBody* b, float phase, float ratchet) +{ + PhysicsJointRatchet* joint = new PhysicsJointRatchet(); + + if (joint && joint->init(a, b, phase, ratchet)) + { + return joint; + } + + CC_SAFE_DELETE(joint); + return nullptr; +} + +bool PhysicsJointRatchet::init(PhysicsBody* a, PhysicsBody* b, float phase, float ratchet) +{ + do + { + CC_BREAK_IF(!PhysicsJoint::init(a, b)); + + cpConstraint* joint = cpRatchetJointNew(getBodyInfo(a)->getBody(), + getBodyInfo(b)->getBody(), + PhysicsHelper::float2cpfloat(phase), + PhysicsHelper::cpfloat2float(ratchet)); + + CC_BREAK_IF(joint == nullptr); + + _info->add(joint); + + return true; + } while (false); + + return false; +} + +float PhysicsJointRatchet::getAngle() const +{ + return PhysicsHelper::cpfloat2float(cpRatchetJointGetAngle(_info->getJoints().front())); +} + +void PhysicsJointRatchet::setAngle(float angle) +{ + cpRatchetJointSetAngle(_info->getJoints().front(), PhysicsHelper::float2cpfloat(angle)); +} + +float PhysicsJointRatchet::getPhase() const +{ + return PhysicsHelper::cpfloat2float(cpRatchetJointGetPhase(_info->getJoints().front())); +} + +void PhysicsJointRatchet::setPhase(float phase) +{ + cpRatchetJointSetPhase(_info->getJoints().front(), PhysicsHelper::float2cpfloat(phase)); +} + +float PhysicsJointRatchet::getRatchet() const +{ + return PhysicsHelper::cpfloat2float(cpRatchetJointGetRatchet(_info->getJoints().front())); +} + +void PhysicsJointRatchet::setRatchet(float ratchet) +{ + cpRatchetJointSetRatchet(_info->getJoints().front(), PhysicsHelper::float2cpfloat(ratchet)); +} + +PhysicsJointGear* PhysicsJointGear::construct(PhysicsBody* a, PhysicsBody* b, float phase, float ratchet) +{ + PhysicsJointGear* joint = new PhysicsJointGear(); + + if (joint && joint->init(a, b, phase, ratchet)) + { + return joint; + } + + CC_SAFE_DELETE(joint); + return nullptr; +} + +bool PhysicsJointGear::init(PhysicsBody* a, PhysicsBody* b, float phase, float ratio) +{ + do + { + CC_BREAK_IF(!PhysicsJoint::init(a, b)); + + cpConstraint* joint = cpGearJointNew(getBodyInfo(a)->getBody(), + getBodyInfo(b)->getBody(), + PhysicsHelper::float2cpfloat(phase), + PhysicsHelper::cpfloat2float(ratio)); + + CC_BREAK_IF(joint == nullptr); + + _info->add(joint); + + return true; + } while (false); + + return false; +} + +float PhysicsJointGear::getPhase() const +{ + return PhysicsHelper::cpfloat2float(cpGearJointGetPhase(_info->getJoints().front())); +} + +void PhysicsJointGear::setPhase(float phase) +{ + cpGearJointSetPhase(_info->getJoints().front(), PhysicsHelper::float2cpfloat(phase)); +} + +float PhysicsJointGear::getRatio() const +{ + return PhysicsHelper::cpfloat2float(cpGearJointGetRatio(_info->getJoints().front())); +} + +void PhysicsJointGear::setRatio(float ratio) +{ + cpGearJointSetRatio(_info->getJoints().front(), PhysicsHelper::float2cpfloat(ratio)); +} + +PhysicsJointMotor* PhysicsJointMotor::construct(PhysicsBody* a, PhysicsBody* b, float rate) +{ + PhysicsJointMotor* joint = new PhysicsJointMotor(); + + if (joint && joint->init(a, b, rate)) + { + return joint; + } + + CC_SAFE_DELETE(joint); + return nullptr; +} + +bool PhysicsJointMotor::init(PhysicsBody* a, PhysicsBody* b, float rate) +{ + do + { + CC_BREAK_IF(!PhysicsJoint::init(a, b)); + + cpConstraint* joint = cpSimpleMotorNew(getBodyInfo(a)->getBody(), + getBodyInfo(b)->getBody(), + PhysicsHelper::float2cpfloat(rate)); + + CC_BREAK_IF(joint == nullptr); + + _info->add(joint); + + return true; + } while (false); + + return false; +} + +float PhysicsJointMotor::getRate() const +{ + return PhysicsHelper::cpfloat2float(cpSimpleMotorGetRate(_info->getJoints().front())); +} + +void PhysicsJointMotor::setRate(float rate) +{ + cpSimpleMotorSetRate(_info->getJoints().front(), PhysicsHelper::float2cpfloat(rate)); +} + NS_CC_END #endif // CC_USE_PHYSICS diff --git a/cocos/physics/CCPhysicsJoint.h b/cocos/physics/CCPhysicsJoint.h index 45e038a774..a5bd923b63 100644 --- a/cocos/physics/CCPhysicsJoint.h +++ b/cocos/physics/CCPhysicsJoint.h @@ -59,6 +59,9 @@ public: void removeFormWorld(); static void destroy(PhysicsJoint* joint); + void setMaxForce(float force); + float getMaxForce() const; + protected: bool init(PhysicsBody* a, PhysicsBody* b); @@ -95,8 +98,8 @@ protected: bool init(PhysicsBody* a, PhysicsBody* b, const Point& anchr); protected: - PhysicsJointFixed(); - virtual ~PhysicsJointFixed(); + PhysicsJointFixed() {} + virtual ~PhysicsJointFixed() {} }; /* @@ -107,6 +110,10 @@ class PhysicsJointLimit : public PhysicsJoint public: static PhysicsJointLimit* construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2); + Point getAnchr1() const; + void setAnchr1(const Point& anchr1); + Point getAnchr2() const; + void setAnchr2(const Point& anchr2); float getMin() const; void setMin(float min); float getMax() const; @@ -116,8 +123,8 @@ protected: bool init(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2); protected: - PhysicsJointLimit(); - virtual ~PhysicsJointLimit(); + PhysicsJointLimit() {} + virtual ~PhysicsJointLimit() {} }; /* @@ -128,15 +135,12 @@ class PhysicsJointPin : public PhysicsJoint public: static PhysicsJointPin* construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr); - void setMaxForce(float force); - float getMaxForce() const; - protected: bool init(PhysicsBody* a, PhysicsBody* b, const Point& anchr); protected: - PhysicsJointPin(); - virtual ~PhysicsJointPin(); + PhysicsJointPin() {} + virtual ~PhysicsJointPin() {} }; class PhysicsJointDistance : public PhysicsJoint @@ -144,12 +148,150 @@ class PhysicsJointDistance : public PhysicsJoint public: static PhysicsJointDistance* construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2); + float getDistance() const; + void setDistance(float distance); + protected: bool init(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2); protected: - PhysicsJointDistance(); - virtual ~PhysicsJointDistance(); + PhysicsJointDistance() {} + virtual ~PhysicsJointDistance() {} +}; + +class PhysicsJointSpring : public PhysicsJoint +{ +public: + static PhysicsJointSpring* construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2, float stiffness, float damping); + Point getAnchr1() const; + void setAnchr1(const Point& anchr1); + Point getAnchr2() const; + void setAnchr2(const Point& anchr2); + float getRestLength() const; + void setRestLength(float restLength); + float getStiffness() const; + void setStiffness(float stiffness); + float getDamping() const; + void setDamping(float damping); + +protected: + bool init(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2, float stiffness, float damping); + +protected: + PhysicsJointSpring() {} + virtual ~PhysicsJointSpring() {} +}; + +class PhysicsJointGroove : public PhysicsJoint +{ +public: + static PhysicsJointGroove* construct(PhysicsBody* a, PhysicsBody* b, const Point& grooveA, const Point& grooveB, const Point& anchr2); + + Point getGrooveA() const; + void setGrooveA(const Point& grooveA); + Point getGrooveB() const; + void setGrooveB(const Point& grooveB); + Point getAnchr2() const; + void setAnchr2(const Point& anchr2); + +protected: + bool init(PhysicsBody* a, PhysicsBody* b, const Point& grooveA, const Point& grooveB, const Point& anchr); + +protected: + PhysicsJointGroove() {} + virtual ~PhysicsJointGroove() {} +}; + +class PhysicsJointRotarySpring : public PhysicsJoint +{ +public: + static PhysicsJointRotarySpring* construct(PhysicsBody* a, PhysicsBody* b, float stiffness, float damping); + + float getRestAngle() const; + void setRestAngle(float restAngle); + float getStiffness() const; + void setStiffness(float stiffness); + float getDamping() const; + void setDamping(float damping); + +protected: + bool init(PhysicsBody* a, PhysicsBody* b, float stiffness, float damping); + +protected: + PhysicsJointRotarySpring() {} + virtual ~PhysicsJointRotarySpring() {} +}; + +class PhysicsJointRotaryLimit : public PhysicsJoint +{ +public: + static PhysicsJointRotaryLimit* construct(PhysicsBody* a, PhysicsBody* b); + + float getMin() const; + void setMin(float min); + float getMax() const; + void setMax(float max); + +protected: + bool init(PhysicsBody* a, PhysicsBody* b); + +protected: + PhysicsJointRotaryLimit() {} + virtual ~PhysicsJointRotaryLimit() {} +}; + +class PhysicsJointRatchet : public PhysicsJoint +{ +public: + static PhysicsJointRatchet* construct(PhysicsBody* a, PhysicsBody* b, float phase, float ratchet); + + float getAngle() const; + void setAngle(float angle); + float getPhase() const; + void setPhase(float phase); + float getRatchet() const; + void setRatchet(float ratchet); + +protected: + bool init(PhysicsBody* a, PhysicsBody* b, float phase, float ratchet); + +protected: + PhysicsJointRatchet() {} + virtual ~PhysicsJointRatchet() {} +}; + +class PhysicsJointGear : public PhysicsJoint +{ +public: + static PhysicsJointGear* construct(PhysicsBody* a, PhysicsBody* b, float phase, float ratio); + + float getPhase() const; + void setPhase(float phase); + float getRatio() const; + void setRatio(float ratchet); + +protected: + bool init(PhysicsBody* a, PhysicsBody* b, float phase, float ratio); + +protected: + PhysicsJointGear() {} + virtual ~PhysicsJointGear() {} +}; + +class PhysicsJointMotor : public PhysicsJoint +{ +public: + static PhysicsJointMotor* construct(PhysicsBody* a, PhysicsBody* b, float rate); + + float getRate() const; + void setRate(float rate); + +protected: + bool init(PhysicsBody* a, PhysicsBody* b, float rate); + +protected: + PhysicsJointMotor() {} + virtual ~PhysicsJointMotor() {} }; NS_CC_END From 225348cddec298bc74039397ef7e92b9b8dafb13 Mon Sep 17 00:00:00 2001 From: minggo Date: Tue, 3 Dec 2013 11:09:39 +0800 Subject: [PATCH 25/30] use size_t instead of long in Array --- cocos/base/CCArray.cpp | 84 +++++++++++++++++++++--------------------- cocos/base/CCArray.h | 32 ++++++++-------- 2 files changed, 58 insertions(+), 58 deletions(-) diff --git a/cocos/base/CCArray.cpp b/cocos/base/CCArray.cpp index 90c88ebe34..fdb96b2de9 100644 --- a/cocos/base/CCArray.cpp +++ b/cocos/base/CCArray.cpp @@ -105,7 +105,7 @@ Array* Array::createWithArray(Array* otherArray) return otherArray->clone(); } -Array* Array::createWithCapacity(long capacity) +Array* Array::createWithCapacity(size_t capacity) { CCASSERT(capacity>=0, "Invalid capacity"); @@ -182,7 +182,7 @@ bool Array::initWithObjects(Object* object, ...) return ret; } -bool Array::initWithCapacity(long capacity) +bool Array::initWithCapacity(size_t capacity) { CCASSERT(capacity>=0, "Invalid capacity"); @@ -196,11 +196,11 @@ bool Array::initWithArray(Array* otherArray) return true; } -int Array::getIndexOfObject(Object* object) const +size_t Array::getIndexOfObject(Object* object) const { auto it = data.begin(); - for (long i = 0; it != data.end(); ++it, ++i) + for (size_t i = 0; it != data.end(); ++it, ++i) { if (it->get() == object) { @@ -232,13 +232,13 @@ Object* Array::getRandomObject() bool Array::containsObject(Object* object) const { - int i = this->getIndexOfObject(object); - return (i >=0); + auto i = this->getIndexOfObject(object); + return (i >= 0); } bool Array::isEqualToArray(Array* otherArray) { - for (long i = 0; i< this->count(); i++) + for (size_t i = 0; i < this->count(); ++i) { if (!this->getObjectAtIndex(i)->isEqual(otherArray->getObjectAtIndex(i))) { @@ -250,7 +250,7 @@ bool Array::isEqualToArray(Array* otherArray) void Array::addObject(Object* object) { - data.push_back( RCPtr(object) ); + data.push_back(RCPtr(object)); } void Array::addObjectsFromArray(Array* otherArray) @@ -258,12 +258,12 @@ void Array::addObjectsFromArray(Array* otherArray) data.insert(data.end(), otherArray->data.begin(), otherArray->data.end()); } -void Array::insertObject(Object* object, int index) +void Array::insertObject(Object* object, size_t index) { - data.insert( std::begin(data) + index, RCPtr(object) ); + data.insert(std::begin(data) + index, RCPtr(object)); } -void Array::setObject(Object* object, int index) +void Array::setObject(Object* object, size_t index) { data[index] = RCPtr(object); } @@ -276,13 +276,13 @@ void Array::removeLastObject(bool releaseObj) void Array::removeObject(Object* object, bool releaseObj /* ignored */) { - data.erase( std::remove( data.begin(), data.end(), object ) ); + data.erase(std::remove(data.begin(), data.end(), object)); } -void Array::removeObjectAtIndex(long index, bool releaseObj /* ignored */) +void Array::removeObjectAtIndex(size_t index, bool releaseObj /* ignored */) { auto obj = data[index]; - data.erase( data.begin() + index ); + data.erase(data.begin() + index); } void Array::removeObjectsInArray(Array* otherArray) @@ -295,7 +295,7 @@ void Array::removeAllObjects() data.erase(std::begin(data), std::end(data)); } -void Array::fastRemoveObjectAtIndex(long index) +void Array::fastRemoveObjectAtIndex(size_t index) { removeObjectAtIndex(index); } @@ -307,27 +307,27 @@ void Array::fastRemoveObject(Object* object) void Array::exchangeObject(Object* object1, Object* object2) { - int idx1 = getIndexOfObject(object1); - int idx2 = getIndexOfObject(object2); + auto idx1 = getIndexOfObject(object1); + auto idx2 = getIndexOfObject(object2); - CCASSERT(idx1>=0 && idx2>=2, "invalid object index"); + CCASSERT(idx1 >= 0 && idx2 >= 2, "invalid object index"); - std::swap( data[idx1], data[idx2] ); + std::swap(data[idx1], data[idx2]); } -void Array::exchangeObjectAtIndex(long index1, long index2) +void Array::exchangeObjectAtIndex(size_t index1, size_t index2) { - std::swap( data[index1], data[index2] ); + std::swap(data[index1], data[index2]); } -void Array::replaceObjectAtIndex(long index, Object* object, bool releaseObject /* ignored */) +void Array::replaceObjectAtIndex(size_t index, Object* object, bool releaseObject /* ignored */) { data[index] = object; } void Array::reverseObjects() { - std::reverse( std::begin(data), std::end(data) ); + std::reverse(std::begin(data), std::end(data)); } void Array::reduceMemoryFootprint() @@ -448,7 +448,7 @@ Array* Array::createWithArray(Array* otherArray) return otherArray->clone(); } -Array* Array::createWithCapacity(long capacity) +Array* Array::createWithCapacity(size_t capacity) { CCASSERT(capacity>=0, "Invalid capacity"); @@ -531,7 +531,7 @@ bool Array::initWithObjects(Object* object, ...) return ret; } -bool Array::initWithCapacity(long capacity) +bool Array::initWithCapacity(size_t capacity) { CCASSERT(capacity>=0 && !data, "Array cannot be re-initialized"); @@ -555,7 +555,7 @@ bool Array::initWithArray(Array* otherArray) return ret; } -long Array::getIndexOfObject(Object* object) const +size_t Array::getIndexOfObject(Object* object) const { return ccArrayGetIndexOfObject(data, object); } @@ -574,7 +574,7 @@ Object* Array::getRandomObject() r = 0; } - return data->arr[(long)(data->num * r)]; + return data->arr[static_cast(data->num * r)]; } bool Array::containsObject(Object* object) const @@ -584,7 +584,7 @@ bool Array::containsObject(Object* object) const bool Array::isEqualToArray(Array* otherArray) { - for (long i = 0; i< this->count(); i++) + for (size_t i = 0; i < this->count(); ++i) { if (!this->getObjectAtIndex(i)->isEqual(otherArray->getObjectAtIndex(i))) { @@ -606,15 +606,15 @@ void Array::addObjectsFromArray(Array* otherArray) ccArrayAppendArrayWithResize(data, otherArray->data); } -void Array::insertObject(Object* object, long index) +void Array::insertObject(Object* object, size_t index) { CCASSERT(data, "Array not initialized"); ccArrayInsertObjectAtIndex(data, object, index); } -void Array::setObject(Object* object, long index) +void Array::setObject(Object* object, size_t index) { - CCASSERT(index>=0 && index < count(), "Invalid index"); + CCASSERT(index >= 0 && index < count(), "Invalid index"); if (object != data->arr[index]) { @@ -627,7 +627,7 @@ void Array::setObject(Object* object, long index) void Array::removeLastObject(bool releaseObj) { CCASSERT(data->num, "no objects added"); - ccArrayRemoveObjectAtIndex(data, data->num-1, releaseObj); + ccArrayRemoveObjectAtIndex(data, data->num - 1, releaseObj); } void Array::removeObject(Object* object, bool releaseObj/* = true*/) @@ -635,7 +635,7 @@ void Array::removeObject(Object* object, bool releaseObj/* = true*/) ccArrayRemoveObject(data, object, releaseObj); } -void Array::removeObjectAtIndex(long index, bool releaseObj) +void Array::removeObjectAtIndex(size_t index, bool releaseObj) { ccArrayRemoveObjectAtIndex(data, index, releaseObj); } @@ -650,7 +650,7 @@ void Array::removeAllObjects() ccArrayRemoveAllObjects(data); } -void Array::fastRemoveObjectAtIndex(long index) +void Array::fastRemoveObjectAtIndex(size_t index) { ccArrayFastRemoveObjectAtIndex(data, index); } @@ -662,13 +662,13 @@ void Array::fastRemoveObject(Object* object) void Array::exchangeObject(Object* object1, Object* object2) { - long index1 = ccArrayGetIndexOfObject(data, object1); + auto index1 = ccArrayGetIndexOfObject(data, object1); if (index1 == CC_INVALID_INDEX) { return; } - long index2 = ccArrayGetIndexOfObject(data, object2); + auto index2 = ccArrayGetIndexOfObject(data, object2); if (index2 == CC_INVALID_INDEX) { return; @@ -677,15 +677,15 @@ void Array::exchangeObject(Object* object1, Object* object2) ccArraySwapObjectsAtIndexes(data, index1, index2); } -void Array::exchangeObjectAtIndex(long index1, long index2) +void Array::exchangeObjectAtIndex(size_t index1, size_t index2) { ccArraySwapObjectsAtIndexes(data, index1, index2); } -void Array::replaceObjectAtIndex(long index, Object* object, bool releaseObject/* = true*/) +void Array::replaceObjectAtIndex(size_t index, Object* object, bool releaseObject/* = true*/) { ccArrayInsertObjectAtIndex(data, object, index); - ccArrayRemoveObjectAtIndex(data, index+1); + ccArrayRemoveObjectAtIndex(data, index + 1); } void Array::reverseObjects() @@ -693,10 +693,10 @@ void Array::reverseObjects() if (data->num > 1) { // floorf(), since in the case of an even number, the number of swaps stays the same - long count = (long) floorf(data->num/2.f); - long maxIndex = data->num - 1; + auto count = static_cast(floorf(data->num/2.f)); + auto maxIndex = data->num - 1; - for (long i = 0; i < count ; i++) + for (int i = 0; i < count ; ++i) { ccArraySwapObjectsAtIndexes(data, i, maxIndex); --maxIndex; diff --git a/cocos/base/CCArray.h b/cocos/base/CCArray.h index f68ee8b64d..32b57d8a4d 100644 --- a/cocos/base/CCArray.h +++ b/cocos/base/CCArray.h @@ -250,7 +250,7 @@ public: /** Create an array with a default capacity * @js NA */ - static Array* createWithCapacity(long capacity); + static Array* createWithCapacity(size_t capacity); /** Create an array with from an existing array * @js NA */ @@ -295,7 +295,7 @@ public: * @js NA * @lua NA */ - bool initWithCapacity(long capacity); + bool initWithCapacity(size_t capacity); /** Initializes an array with an existing array * @js NA * @lua NA @@ -307,7 +307,7 @@ public: /** Returns element count of the array * @js NA */ - long count() const + size_t count() const { #if CC_USE_ARRAY_VECTOR return data.size(); @@ -318,7 +318,7 @@ public: /** Returns capacity of the array * @js NA */ - long capacity() const + size_t capacity() const { #if CC_USE_ARRAY_VECTOR return data.capacity(); @@ -330,17 +330,17 @@ public: * @js NA * @lua NA */ - long getIndexOfObject(Object* object) const; + size_t getIndexOfObject(Object* object) const; /** * @js NA */ - CC_DEPRECATED_ATTRIBUTE long indexOfObject(Object* object) const { return getIndexOfObject(object); } + CC_DEPRECATED_ATTRIBUTE size_t indexOfObject(Object* object) const { return getIndexOfObject(object); } /** Returns an element with a certain index * @js NA * @lua NA */ - Object* getObjectAtIndex(long index) + Object* getObjectAtIndex(size_t index) { CCASSERT(index>=0 && index < count(), "index out of range in getObjectAtIndex()"); #if CC_USE_ARRAY_VECTOR @@ -349,7 +349,7 @@ public: return data->arr[index]; #endif } - CC_DEPRECATED_ATTRIBUTE Object* objectAtIndex(long index) { return getObjectAtIndex(index); } + CC_DEPRECATED_ATTRIBUTE Object* objectAtIndex(size_t index) { return getObjectAtIndex(index); } /** Returns the last element of the array * @js NA */ @@ -401,17 +401,17 @@ public: /** Insert a certain object at a certain index * @js NA */ - void insertObject(Object* object, long index); + void insertObject(Object* object, size_t index); /** sets a certain object at a certain index * @js NA * @lua NA */ - void setObject(Object* object, long index); + void setObject(Object* object, size_t index); /** sets a certain object at a certain index without retaining. Use it with caution * @js NA * @lua NA */ - void fastSetObject(Object* object, long index) + void fastSetObject(Object* object, size_t index) { #if CC_USE_ARRAY_VECTOR setObject(object, index); @@ -424,7 +424,7 @@ public: * @js NA * @lua NA */ - void swap( long indexOne, long indexTwo ) + void swap( size_t indexOne, size_t indexTwo ) { CCASSERT(indexOne >=0 && indexOne < count() && indexTwo >= 0 && indexTwo < count(), "Invalid indices"); #if CC_USE_ARRAY_VECTOR @@ -447,7 +447,7 @@ public: /** Remove an element with a certain index * @js NA */ - void removeObjectAtIndex(long index, bool releaseObj = true); + void removeObjectAtIndex(size_t index, bool releaseObj = true); /** Remove all elements * @js NA */ @@ -463,7 +463,7 @@ public: /** Fast way to remove an element with a certain index * @js NA */ - void fastRemoveObjectAtIndex(long index); + void fastRemoveObjectAtIndex(size_t index); // Rearranging Content @@ -474,12 +474,12 @@ public: /** Swap two elements with certain indexes * @js NA */ - void exchangeObjectAtIndex(long index1, long index2); + void exchangeObjectAtIndex(size_t index1, size_t index2); /** Replace object at index with another object. * @js NA */ - void replaceObjectAtIndex(long index, Object* object, bool releaseObject = true); + void replaceObjectAtIndex(size_t index, Object* object, bool releaseObject = true); /** Revers the array * @js NA From 63a4e09c905ae87df47b269d7455f644d5268aeb Mon Sep 17 00:00:00 2001 From: boyu0 Date: Tue, 3 Dec 2013 12:47:03 +0800 Subject: [PATCH 26/30] issue #2771: add more joint tests, add some joint api, fix bugs --- cocos/physics/CCPhysicsBody.cpp | 5 +- cocos/physics/CCPhysicsJoint.cpp | 66 ++++++++-- cocos/physics/CCPhysicsJoint.h | 6 +- cocos/physics/CCPhysicsWorld.cpp | 13 ++ .../Classes/PhysicsTest/PhysicsTest.cpp | 113 +++++++++++++++++- 5 files changed, 184 insertions(+), 19 deletions(-) diff --git a/cocos/physics/CCPhysicsBody.cpp b/cocos/physics/CCPhysicsBody.cpp index 5378526c93..d351444abd 100644 --- a/cocos/physics/CCPhysicsBody.cpp +++ b/cocos/physics/CCPhysicsBody.cpp @@ -26,6 +26,7 @@ #include #include +#include #include "chipmunk.h" @@ -348,7 +349,7 @@ void PhysicsBody::setPosition(Point position) void PhysicsBody::setRotation(float rotation) { - cpBodySetAngle(_info->getBody(), PhysicsHelper::float2cpfloat(rotation)); + cpBodySetAngle(_info->getBody(), PhysicsHelper::float2cpfloat(rotation * M_PI / 180.0f)); } Point PhysicsBody::getPosition() const @@ -359,7 +360,7 @@ Point PhysicsBody::getPosition() const float PhysicsBody::getRotation() const { - return -PhysicsHelper::cpfloat2float(cpBodyGetAngle(_info->getBody()) / 3.14f * 180.0f); + return -PhysicsHelper::cpfloat2float(cpBodyGetAngle(_info->getBody()) / M_PI * 180.0f); } PhysicsShape* PhysicsBody::addShape(PhysicsShape* shape, bool addMassAndMoment/* = true*/) diff --git a/cocos/physics/CCPhysicsJoint.cpp b/cocos/physics/CCPhysicsJoint.cpp index 91fc2a4dee..7300b01dd7 100644 --- a/cocos/physics/CCPhysicsJoint.cpp +++ b/cocos/physics/CCPhysicsJoint.cpp @@ -234,11 +234,11 @@ bool PhysicsJointPin::init(PhysicsBody *a, PhysicsBody *b, const Point& anchr) return false; } -PhysicsJointLimit* PhysicsJointLimit::construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2) +PhysicsJointLimit* PhysicsJointLimit::construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2, float min, float max) { PhysicsJointLimit* joint = new PhysicsJointLimit(); - if (joint && joint->init(a, b, anchr1, anchr2)) + if (joint && joint->init(a, b, anchr1, anchr2, min, max)) { return joint; } @@ -247,7 +247,12 @@ PhysicsJointLimit* PhysicsJointLimit::construct(PhysicsBody* a, PhysicsBody* b, return nullptr; } -bool PhysicsJointLimit::init(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2) +PhysicsJointLimit* PhysicsJointLimit::construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2) +{ + return construct(a, b, anchr1, anchr2, 0, b->local2World(anchr1).getDistance(a->local2World(anchr2))); +} + +bool PhysicsJointLimit::init(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2, float min, float max) { do { @@ -256,8 +261,8 @@ bool PhysicsJointLimit::init(PhysicsBody* a, PhysicsBody* b, const Point& anchr1 cpConstraint* joint = cpSlideJointNew(getBodyInfo(a)->getBody(), getBodyInfo(b)->getBody(), PhysicsHelper::point2cpv(anchr1), PhysicsHelper::point2cpv(anchr2), - 0, - PhysicsHelper::float2cpfloat(_bodyB->local2World(anchr1).getDistance(_bodyA->local2World(anchr2)))); + PhysicsHelper::float2cpfloat(min), + PhysicsHelper::float2cpfloat(max)); CC_BREAK_IF(joint == nullptr); @@ -439,6 +444,40 @@ void PhysicsJointSpring::setDamping(float damping) cpDampedSpringSetDamping(_info->getJoints().front(), PhysicsHelper::float2cpfloat(damping)); } +PhysicsJointGroove* PhysicsJointGroove::construct(PhysicsBody* a, PhysicsBody* b, const Point& grooveA, const Point& grooveB, const Point& anchr2) +{ + PhysicsJointGroove* joint = new PhysicsJointGroove(); + + if (joint && joint->init(a, b, grooveA, grooveB, anchr2)) + { + return joint; + } + + CC_SAFE_DELETE(joint); + return nullptr; +} + +bool PhysicsJointGroove::init(PhysicsBody* a, PhysicsBody* b, const Point& grooveA, const Point& grooveB, const Point& anchr2) +{ + do { + CC_BREAK_IF(!PhysicsJoint::init(a, b)); + + cpConstraint* joint = cpGrooveJointNew(getBodyInfo(a)->getBody(), + getBodyInfo(b)->getBody(), + PhysicsHelper::point2cpv(grooveA), + PhysicsHelper::point2cpv(grooveB), + PhysicsHelper::point2cpv(anchr2)); + + CC_BREAK_IF(joint == nullptr); + + _info->add(joint); + + return true; + } while (false); + + return false; +} + Point PhysicsJointGroove::getGrooveA() const { return PhysicsHelper::cpv2point(cpGrooveJointGetGrooveA(_info->getJoints().front())); @@ -533,11 +572,11 @@ void PhysicsJointRotarySpring::setDamping(float damping) cpDampedRotarySpringSetDamping(_info->getJoints().front(), PhysicsHelper::float2cpfloat(damping)); } -PhysicsJointRotaryLimit* PhysicsJointRotaryLimit::construct(PhysicsBody* a, PhysicsBody* b) +PhysicsJointRotaryLimit* PhysicsJointRotaryLimit::construct(PhysicsBody* a, PhysicsBody* b, float min, float max) { PhysicsJointRotaryLimit* joint = new PhysicsJointRotaryLimit(); - if (joint && joint->init(a, b)) + if (joint && joint->init(a, b, min, max)) { return joint; } @@ -546,7 +585,12 @@ PhysicsJointRotaryLimit* PhysicsJointRotaryLimit::construct(PhysicsBody* a, Phys return nullptr; } -bool PhysicsJointRotaryLimit::init(PhysicsBody* a, PhysicsBody* b) +PhysicsJointRotaryLimit* PhysicsJointRotaryLimit::construct(PhysicsBody* a, PhysicsBody* b) +{ + return construct(a, b, 0.0f, 0.0f); +} + +bool PhysicsJointRotaryLimit::init(PhysicsBody* a, PhysicsBody* b, float min, float max) { do { @@ -554,8 +598,8 @@ bool PhysicsJointRotaryLimit::init(PhysicsBody* a, PhysicsBody* b) cpConstraint* joint = cpRotaryLimitJointNew(getBodyInfo(a)->getBody(), getBodyInfo(b)->getBody(), - 0, - PhysicsHelper::float2cpfloat(_bodyB->getRotation() - _bodyA->getRotation())); + PhysicsHelper::float2cpfloat(min), + PhysicsHelper::float2cpfloat(max)); CC_BREAK_IF(joint == nullptr); @@ -673,7 +717,7 @@ bool PhysicsJointGear::init(PhysicsBody* a, PhysicsBody* b, float phase, float r cpConstraint* joint = cpGearJointNew(getBodyInfo(a)->getBody(), getBodyInfo(b)->getBody(), PhysicsHelper::float2cpfloat(phase), - PhysicsHelper::cpfloat2float(ratio)); + PhysicsHelper::float2cpfloat(ratio)); CC_BREAK_IF(joint == nullptr); diff --git a/cocos/physics/CCPhysicsJoint.h b/cocos/physics/CCPhysicsJoint.h index a5bd923b63..ad90a1a7a8 100644 --- a/cocos/physics/CCPhysicsJoint.h +++ b/cocos/physics/CCPhysicsJoint.h @@ -109,6 +109,7 @@ class PhysicsJointLimit : public PhysicsJoint { public: static PhysicsJointLimit* construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2); + static PhysicsJointLimit* construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2, float min, float max); Point getAnchr1() const; void setAnchr1(const Point& anchr1); @@ -120,7 +121,7 @@ public: void setMax(float max); protected: - bool init(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2); + bool init(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2, float min, float max); protected: PhysicsJointLimit() {} @@ -225,6 +226,7 @@ protected: class PhysicsJointRotaryLimit : public PhysicsJoint { public: + static PhysicsJointRotaryLimit* construct(PhysicsBody* a, PhysicsBody* b, float min, float max); static PhysicsJointRotaryLimit* construct(PhysicsBody* a, PhysicsBody* b); float getMin() const; @@ -233,7 +235,7 @@ public: void setMax(float max); protected: - bool init(PhysicsBody* a, PhysicsBody* b); + bool init(PhysicsBody* a, PhysicsBody* b, float min, float max); protected: PhysicsJointRotaryLimit() {} diff --git a/cocos/physics/CCPhysicsWorld.cpp b/cocos/physics/CCPhysicsWorld.cpp index e90f48b478..70bae33eff 100644 --- a/cocos/physics/CCPhysicsWorld.cpp +++ b/cocos/physics/CCPhysicsWorld.cpp @@ -519,6 +519,19 @@ void PhysicsDebugDraw::drawJoint(PhysicsJoint& joint) _drawNode->drawSegment(PhysicsHelper::cpv2point(a), PhysicsHelper::cpv2point(b), 1, Color4F(0.0f, 0.0f, 1.0f, 1.0f)); _drawNode->drawDot(PhysicsHelper::cpv2point(c), 2, Color4F(0.0f, 1.0f, 0.0f, 1.0f)); } + else if(klass == cpDampedSpringGetClass()) + { + cpDampedSpring *subJoint = (cpDampedSpring *)constraint; + + cpVect a = cpvadd(body_a->p, cpvrotate(subJoint->anchr1, body_a->rot)); + cpVect b = cpvadd(body_b->p, cpvrotate(subJoint->anchr2, body_b->rot)); + + _drawNode->drawSegment(PhysicsHelper::cpv2point(a), PhysicsHelper::cpv2point(b), 1, Color4F(0.0f, 0.0f, 1.0f, 1.0f)); + _drawNode->drawDot(PhysicsHelper::cpv2point(a), 2, Color4F(0.0f, 1.0f, 0.0f, 1.0f)); + _drawNode->drawDot(PhysicsHelper::cpv2point(b), 2, Color4F(0.0f, 1.0f, 0.0f, 1.0f)); + + + } } } diff --git a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp index 88cba0c099..ed291dc5ff 100644 --- a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp @@ -686,7 +686,6 @@ void PhysicsDemoJoints::onEnter() node->setPhysicsBody(box); box->setDynamic(false); node->setPosition(Point::ZERO); - this->addChild(node); for (int i = 0; i < 4; ++i) @@ -749,9 +748,115 @@ void PhysicsDemoJoints::onEnter() auto sp2 = makeBox(offset + Point(30, 0), Size(30, 10)); sp2->getPhysicsBody()->setTag(DRAG_BODYS_TAG); - PhysicsJointLimit* joint = PhysicsJointLimit::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), Point::ZERO, Point::ZERO); - joint->setMin(30.0f); - joint->setMax(60.0f); + PhysicsJointLimit* joint = PhysicsJointLimit::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), Point::ZERO, Point::ZERO, 30.0f, 60.0f); + _scene->getPhysicsWorld()->addJoint(joint); + + this->addChild(sp1); + this->addChild(sp2); + break; + } + case 4: + { + auto sp1 = makeBall(offset - Point(30, 0), 10); + sp1->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + auto sp2 = makeBox(offset + Point(30, 0), Size(30, 10)); + sp2->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + + PhysicsJointSpring* joint = PhysicsJointSpring::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), Point::ZERO, Point::ZERO, 500.0f, 0.3f); + _scene->getPhysicsWorld()->addJoint(joint); + + this->addChild(sp1); + this->addChild(sp2); + break; + } + case 5: + { + auto sp1 = makeBall(offset - Point(30, 0), 10); + sp1->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + auto sp2 = makeBox(offset + Point(30, 0), Size(30, 10)); + sp2->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + + PhysicsJointGroove* joint = PhysicsJointGroove::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), Point(30, 15), Point(30, -15), Point(-30, 0)); + _scene->getPhysicsWorld()->addJoint(joint); + + this->addChild(sp1); + this->addChild(sp2); + break; + } + case 6: + { + auto sp1 = makeBox(offset - Point(30, 0), Size(30, 10)); + sp1->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + auto sp2 = makeBox(offset + Point(30, 0), Size(30, 10)); + sp2->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + + _scene->getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp1->getPhysicsBody(), box, sp1->getPosition())); + _scene->getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp2->getPhysicsBody(), box, sp2->getPosition())); + PhysicsJointRotarySpring* joint = PhysicsJointRotarySpring::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), 3000.0f, 60.0f); + _scene->getPhysicsWorld()->addJoint(joint); + + this->addChild(sp1); + this->addChild(sp2); + break; + } + case 7: + { + auto sp1 = makeBox(offset - Point(30, 0), Size(30, 10)); + sp1->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + auto sp2 = makeBox(offset + Point(30, 0), Size(30, 10)); + sp2->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + + _scene->getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp1->getPhysicsBody(), box, sp1->getPosition())); + _scene->getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp2->getPhysicsBody(), box, sp2->getPosition())); + PhysicsJointRotaryLimit* joint = PhysicsJointRotaryLimit::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), 0.0f, M_PI_2); + _scene->getPhysicsWorld()->addJoint(joint); + + this->addChild(sp1); + this->addChild(sp2); + break; + } + case 8: + { + auto sp1 = makeBox(offset - Point(30, 0), Size(30, 10)); + sp1->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + auto sp2 = makeBox(offset + Point(30, 0), Size(30, 10)); + sp2->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + + _scene->getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp1->getPhysicsBody(), box, sp1->getPosition())); + _scene->getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp2->getPhysicsBody(), box, sp2->getPosition())); + PhysicsJointRatchet* joint = PhysicsJointRatchet::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), 0.0f, M_PI_2); + _scene->getPhysicsWorld()->addJoint(joint); + + this->addChild(sp1); + this->addChild(sp2); + break; + } + case 9: + { + auto sp1 = makeBox(offset - Point(30, 0), Size(30, 10)); + sp1->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + auto sp2 = makeBox(offset + Point(30, 0), Size(30, 10)); + sp2->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + + _scene->getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp1->getPhysicsBody(), box, sp1->getPosition())); + _scene->getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp2->getPhysicsBody(), box, sp2->getPosition())); + PhysicsJointGear* joint = PhysicsJointGear::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), 0.0f, 2.0f); + _scene->getPhysicsWorld()->addJoint(joint); + + this->addChild(sp1); + this->addChild(sp2); + break; + } + case 10: + { + auto sp1 = makeBox(offset - Point(30, 0), Size(30, 10)); + sp1->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + auto sp2 = makeBox(offset + Point(30, 0), Size(30, 10)); + sp2->getPhysicsBody()->setTag(DRAG_BODYS_TAG); + + _scene->getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp1->getPhysicsBody(), box, sp1->getPosition())); + _scene->getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp2->getPhysicsBody(), box, sp2->getPosition())); + PhysicsJointMotor* joint = PhysicsJointMotor::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), M_PI_2); _scene->getPhysicsWorld()->addJoint(joint); this->addChild(sp1); From a8c1bba464620a4521035166a2e99740cddde3aa Mon Sep 17 00:00:00 2001 From: samuele3 Date: Tue, 3 Dec 2013 15:40:59 +0800 Subject: [PATCH 27/30] issue #3309:Add some deprecated functions and classes to support master cocostudio lua bindings --- cocos/scripting/lua/script/Cocos2d.lua | 68 ++++ cocos/scripting/lua/script/Deprecated.lua | 228 ++++++++++---- .../scripting/lua/script/DeprecatedClass.lua | 297 +++++++++++++++++- cocos/scripting/lua/script/DeprecatedEnum.lua | 86 ++++- .../scripting/lua/script/StudioConstants.lua | 23 +- tools/tolua/cocos2dx_studio.ini | 8 +- 6 files changed, 632 insertions(+), 78 deletions(-) diff --git a/cocos/scripting/lua/script/Cocos2d.lua b/cocos/scripting/lua/script/Cocos2d.lua index c364c7f32a..404e8584b7 100644 --- a/cocos/scripting/lua/script/Cocos2d.lua +++ b/cocos/scripting/lua/script/Cocos2d.lua @@ -291,4 +291,72 @@ function cc.c4f( _r,_g,_b,_a ) return { r = _r, g = _g, b = _b, a = _a } end +--Vertex2F +function cc.vertex2F(_x,_y) + return { x = _x, y = _y } +end +--Vertex3F +function cc.Vertex3F(_x,_y,_z) + return { x = _x, y = _y, z = _z } +end + +--Tex2F +function cc.tex2F(_u,_v) + return { u = _u, v = _v } +end + +--PointSprite +function cc.PointSprite(_pos,_color,_size) + return { pos = _pos, color = _color, size = _size } +end + +--Quad2 +function cc.Quad2(_tl,_tr,_bl,_br) + return { tl = _tl, tr = _tr, bl = _bl, br = _br } +end + +--Quad3 +function cc.Quad3(_tl, _tr, _bl, _br) + return { tl = _tl, tr = _tr, bl = _bl, br = _br } +end + +--V2F_C4B_T2F +function cc.V2F_C4B_T2F(_vertices, _colors, _texCoords) + return { vertices = _vertices, colors = _colors, texCoords = _texCoords } +end + +--V2F_C4F_T2F +function cc.V2F_C4F_T2F(_vertices, _colors, _texCoords) + return { vertices = _vertices, colors = _colors, texCoords = _texCoords } +end + +--V3F_C4B_T2F +function cc.V3F_C4B_T2F(_vertices, _colors, _texCoords) + return { vertices = _vertices, colors = _colors, texCoords = _texCoords } +end + +--V2F_C4B_T2F_Quad +function cc.V2F_C4B_T2F_Quad(_bl, _br, _tl, _tr) + return { bl = _bl, br = _br, tl = _tl, tr = _tr } +end + +--V3F_C4B_T2F_Quad +function cc.V3F_C4B_T2F_Quad(_tl, _bl, _tr, _br) + return { tl = _tl, bl = _bl, tr = _tr, br = _br } +end + +--V2F_C4F_T2F_Quad +function cc.V2F_C4F_T2F_Quad(_bl, _br, _tl, _tr) + return { bl = _bl, br = _br, tl = _tl, tr = _tr } +end + +--T2F_Quad +function cc.T2F_Quad(_bl, _br, _tl, _tr) + return { bl = _bl, br = _br, tl = _tl, tr = _tr } +end + +--AnimationFrameData +function cc.AnimationFrameData( _texCoords, _delay, _size) + return { texCoords = _texCoords, delay = _delay, size = _size } +end diff --git a/cocos/scripting/lua/script/Deprecated.lua b/cocos/scripting/lua/script/Deprecated.lua index 055d417532..935a07514f 100644 --- a/cocos/scripting/lua/script/Deprecated.lua +++ b/cocos/scripting/lua/script/Deprecated.lua @@ -591,20 +591,20 @@ rawset(_G,"ccpIntersectPoint",ccpIntersectPoint) local function vertex2(x,y) - deprecatedTip("vertex2(x,y)","Vertex2F(x,y)") - return Vertex2F(x,y) + deprecatedTip("vertex2(x,y)","cc.vertex2F(x,y)") + return cc.vertex2F(x,y) end rawset(_G,"vertex2",vertex2) local function vertex3(x,y,z) - deprecatedTip("vertex3(x,y,z)","Vertex3F(x,y,z)") - return Vertex3F(x,y,z) + deprecatedTip("vertex3(x,y,z)","cc.Vertex3F(x,y,z)") + return cc.Vertex3F(x,y,z) end rawset(_G,"vertex3",vertex3) local function tex2(u,v) - deprecatedTip("tex2(u,v)","Tex2F(u,v)") - return Tex2F(u,v) + deprecatedTip("tex2(u,v)","cc.tex2f(u,v)") + return cc.tex2f(u,v) end rawset(_G,"tex2",tex2) @@ -615,109 +615,134 @@ end rawset(_G,"ccc4BFromccc4F",ccc4BFromccc4F) local function ccColor3BDeprecated() - deprecatedTip("ccColor3B","Color3B") - return Color3B + deprecatedTip("ccColor3B","cc.c3b(0,0,0)") + return cc.c3b(0,0,0) end -_G["ccColor3B"] = ccColor3BDeprecated() +_G["ccColor3B"] = ccColor3BDeprecated local function ccColor4BDeprecated() - deprecatedTip("ccColor4B","Color4B") - return Color4B + deprecatedTip("ccColor4B","cc.c4b(0,0,0,0)") + return cc.c4b(0,0,0,0) end -_G["ccColor4B"] = ccColor4BDeprecated() +_G["ccColor4B"] = ccColor4BDeprecated local function ccColor4FDeprecated() - deprecatedTip("ccColor4F","Color4F") - return Color4F + deprecatedTip("ccColor4F","cc.c4f(0.0,0.0,0.0,0.0)") + return cc.c4f(0.0,0.0,0.0,0.0) end -_G["ccColor4F"] = ccColor4FDeprecated() +_G["ccColor4F"] = ccColor4FDeprecated local function ccVertex2FDeprecated() - deprecatedTip("ccVertex2F","Vertex2F") - return Vertex2F + deprecatedTip("ccVertex2F","cc.vertex2F(0.0,0.0)") + return cc.vertex2F(0.0,0.0) end -_G["ccVertex2F"] = ccVertex2FDeprecated() +_G["ccVertex2F"] = ccVertex2FDeprecated local function ccVertex3FDeprecated() - deprecatedTip("ccVertex3F","Vertex3F") - return Vertex3F + deprecatedTip("ccVertex3F","cc.Vertex3F(0.0, 0.0, 0.0)") + return cc.Vertex3F(0.0, 0.0, 0.0) end -_G["ccVertex3F"] = ccVertex3FDeprecated() +_G["ccVertex3F"] = ccVertex3FDeprecated local function ccTex2FDeprecated() - deprecatedTip("ccTex2F","Tex2F") - return Tex2F + deprecatedTip("ccTex2F","cc.tex2F(0.0, 0.0)") + return cc.tex2F(0.0, 0.0) end -_G["ccTex2F"] = ccTex2FDeprecated() +_G["ccTex2F"] = ccTex2FDeprecated local function ccPointSpriteDeprecated() - deprecatedTip("ccPointSprite","PointSprite") - return PointSprite + deprecatedTip("ccPointSprite","cc.PointSprite(cc.vertex2F(0.0, 0.0),cc.c4b(0.0, 0.0, 0.0),0)") + return cc.PointSprite(cc.vertex2F(0.0, 0.0),cc.c4b(0.0, 0.0, 0.0),0) end -_G["ccPointSprite"] = ccPointSpriteDeprecated() +_G["ccPointSprite"] = ccPointSpriteDeprecated local function ccQuad2Deprecated() - deprecatedTip("ccQuad2","Quad2") - return Quad2 + deprecatedTip("ccQuad2","cc.Quad2(cc.vertex2F(0.0, 0.0), cc.vertex2F(0.0, 0.0), cc.vertex2F(0.0, 0.0), cc.vertex2F(0.0, 0.0))") + return cc.Quad2(cc.vertex2F(0.0, 0.0), cc.vertex2F(0.0, 0.0), cc.vertex2F(0.0, 0.0), cc.vertex2F(0.0, 0.0)) end -_G["ccQuad2"] = ccQuad2Deprecated() +_G["ccQuad2"] = ccQuad2Deprecated local function ccQuad3Deprecated() - deprecatedTip("ccQuad3","Quad3") - return Quad3 + deprecatedTip("ccQuad3","cc.Quad3(cc.Vertex3F(0.0, 0.0 ,0.0), cc.Vertex3F(0.0, 0.0 ,0.0), cc.Vertex3F(0.0, 0.0 ,0.0), cc.Vertex3F(0.0, 0.0 ,0.0))") + return cc.Quad3(cc.Vertex3F(0.0, 0.0 ,0.0), cc.Vertex3F(0.0, 0.0 ,0.0), cc.Vertex3F(0.0, 0.0 ,0.0), cc.Vertex3F(0.0, 0.0 ,0.0)) end -_G["ccQuad3"] = ccQuad3Deprecated() +_G["ccQuad3"] = ccQuad3Deprecated local function ccV2FC4BT2FDeprecated() - deprecatedTip("ccV2F_C4B_T2F","V2F_C4B_T2F") - return V2F_C4B_T2F + deprecatedTip("ccV2F_C4B_T2F","cc.V2F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0))") + return cc.V2F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)) end -_G["ccV2F_C4B_T2F"] = ccV2FC4BT2FDeprecated() +_G["ccV2F_C4B_T2F"] = ccV2FC4BT2FDeprecated local function ccV2FC4FT2FDeprecated() - deprecatedTip("ccV2F_C4F_T2F","V2F_C4F_T2F") - return V2F_C4F_T2F + deprecatedTip("ccV2F_C4F_T2F","cc.V2F_C4F_T2F(cc.vertex2F(0.0, 0.0), cc.c4f(0.0 , 0.0 , 0.0 , 0.0 ), cc.tex2F(0.0, 0.0))") + return cc.V2F_C4F_T2F(cc.vertex2F(0.0, 0.0), cc.c4f(0.0 , 0.0 , 0.0 , 0.0), cc.tex2F(0.0, 0.0)) end -_G["ccV2F_C4F_T2F"] = ccV2FC4FT2FDeprecated() +_G["ccV2F_C4F_T2F"] = ccV2FC4FT2FDeprecated local function ccV3FC4BT2FDeprecated() - deprecatedTip("ccV3F_C4B_T2F","V3F_C4B_T2F") - return V3F_C4B_T2F + deprecatedTip("ccV3F_C4B_T2F","cc.V3F_C4B_T2F(cc.vertex3F(0.0, 0.0, 0.0), cc.c4b(0 , 0 , 0, 0 ), cc.tex2F(0.0, 0.0))") + return cc.V3F_C4B_T2F(cc.vertex3F(0.0, 0.0, 0.0), cc.c4b(0 , 0 , 0, 0 ), cc.tex2F(0.0, 0.0)) end -_G["ccV3F_C4B_T2F"] = ccV3FC4BT2FDeprecated() +_G["ccV3F_C4B_T2F"] = ccV3FC4BT2FDeprecated local function ccV2FC4BT2FQuadDeprecated() - deprecatedTip("ccV2F_C4B_T2F_Quad","V2F_C4B_T2F_Quad") - return V2F_C4B_T2F_Quad + deprecatedTip("ccV2F_C4B_T2F_Quad","cc.V2F_C4B_T2F_Quad(cc.V2F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)), cc.V2F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)), cc.V2F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)), cc.V2F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)))") + return cc.V2F_C4B_T2F_Quad(cc.V2F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)), cc.V2F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)), cc.V2F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)), cc.V2F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0))) end -_G["ccV2F_C4B_T2F_Quad"] = ccV2FC4BT2FQuadDeprecated() +_G["ccV2F_C4B_T2F_Quad"] = ccV2FC4BT2FQuadDeprecated local function ccV3FC4BT2FQuadDeprecated() - deprecatedTip("ccV3F_C4B_T2F_Quad","V3F_C4B_T2F_Quad") - return V3F_C4B_T2F_Quad + deprecatedTip("ccV3F_C4B_T2F_Quad","cc.V3F_C4B_T2F_Quad(_tl, _bl, _tr, _br)") + return cc.V3F_C4B_T2F_Quad(cc.V3F_C4B_T2F(cc.vertex3F(0.0, 0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)), cc.V3F_C4B_T2F(cc.vertex3F(0.0, 0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)), cc.V3F_C4B_T2F(cc.vertex3F(0.0, 0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)), cc.V3F_C4B_T2F(cc.vertex3F(0.0, 0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0))) end -_G["ccV3F_C4B_T2F_Quad"] = ccV3FC4BT2FQuadDeprecated() +_G["ccV3F_C4B_T2F_Quad"] = ccV3FC4BT2FQuadDeprecated local function ccV2FC4FT2FQuadDeprecated() - deprecatedTip("ccV2F_C4F_T2F_Quad","V2F_C4F_T2F_Quad") - return V2F_C4F_T2F_Quad + deprecatedTip("ccV2F_C4F_T2F_Quad","cc.V2F_C4F_T2F_Quad(_bl, _br, _tl, _tr)") + return cc.V2F_C4F_T2F_Quad(cc.V2F_C4F_T2F(cc.vertex2F(0.0, 0.0), cc.c4f(0.0 , 0.0, 0.0, 0.0 ), cc.tex2F(0.0, 0.0)), cc.V2F_C4F_T2F(cc.vertex2F(0.0, 0.0), cc.c4f(0.0 , 0.0, 0.0, 0.0 ), cc.tex2F(0.0, 0.0)), cc.V3F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4f(0.0 , 0.0, 0.0, 0.0 ), cc.tex2F(0.0, 0.0)), cc.V2F_C4F_T2F(cc.vertex2F(0.0, 0.0), cc.c4f(0.0 , 0.0, 0.0, 0.0 ), cc.tex2F(0.0, 0.0))) end -_G["ccV2F_C4F_T2F_Quad"] = ccV2FC4FT2FQuadDeprecated() +_G["ccV2F_C4F_T2F_Quad"] = ccV2FC4FT2FQuadDeprecated local function ccT2FQuadDeprecated() - deprecatedTip("ccT2F_Quad","T2F_Quad") - return T2F_Quad + deprecatedTip("ccT2F_Quad","cc.T2F_Quad(_bl, _br, _tl, _tr)") + return cc.T2F_Quad(cc.tex2F(0.0,0.0), cc.tex2F(0.0,0.0), cc.tex2F(0.0,0.0), cc.tex2F(0.0,0.0)) end -_G["ccT2F_Quad"] = ccT2FQuadDeprecated() +_G["ccT2F_Quad"] = ccT2FQuadDeprecated local function ccAnimationFrameDataDeprecated() - deprecatedTip("ccAnimationFrameData","AnimationFrameData") - return AnimationFrameData + deprecatedTip("ccAnimationFrameData","cc.AnimationFrameData( _texCoords, _delay, _size)") + return cc.AnimationFrameData(cc.T2F_Quad(cc.tex2F(0.0,0.0), cc.tex2F(0.0,0.0), cc.tex2F(0.0,0.0), cc.tex2F(0.0,0.0)), 0, cc.size(0,0)) end -_G["ccAnimationFrameData"] = ccAnimationFrameDataDeprecated() +_G["ccAnimationFrameData"] = ccAnimationFrameDataDeprecated + +local function tex2(u,v) + deprecatedTip("tex2(u,v)","cc.tex2f(u,v)") + return cc.tex2f(u,v) +end +rawset(_G,"tex2",tex2) + +local function CCPoint( x, y) + deprecatedTip("CCPoint(x,y)","cc.p(x,y)") + return cc.p(x,y) +end +rawset(_G,"CCPoint",CCPoint) + +local function CCSize( width, height) + deprecatedTip("CCSize(width,height)","cc.size(width,height)") + return cc.size(width,height) +end +rawset(_G,"CCSize",CCSize) + +local function CCRect( x,y, width, height) + deprecatedTip("CCRect(x,y,width,height)","cc.rect(x,y,width,height)") + return cc.rect(x,y,width,height) +end +rawset(_G,"CCRect",CCRect) + --functions of CCControl will be deprecated end local CCControlDeprecated = { } function CCControlDeprecated.addHandleOfControlEvent(self,func,controlEvent) @@ -1047,3 +1072,92 @@ function CCLayerDeprecated.isKeypadEnabled(self) end rawset(cc.Layer, "isKeypadEnabled", CCLayerDeprecated.isKeypadEnabled ) --functions of Layer will be deprecated end + +--functions of ccs.GUIReader will be deprecated begin +local CCSGUIReaderDeprecated = { } +function CCSGUIReaderDeprecated.purgeGUIReader() + deprecatedTip("ccs.GUIReader:purgeGUIReader","ccs.GUIReader:destroyInstance") + return ccs.GUIReader:destroyInstance() +end +rawset(ccs.GUIReader,"purgeGUIReader",CCSGUIReaderDeprecated.purgeGUIReader) +--functions of ccs.GUIReader will be deprecated end + +--functions of ccs.ActionManagerEx will be deprecated begin +local CCSActionManagerExDeprecated = { } +function CCSActionManagerExDeprecated.destroyActionManager() + deprecatedTip("ccs.ActionManagerEx:destroyActionManager","ccs.ActionManagerEx:destroyInstance") + return ccs.ActionManagerEx:destroyInstance() +end +rawset(ccs.ActionManagerEx,"destroyActionManager",CCSActionManagerExDeprecated.destroyActionManager) +--functions of ccs.ActionManagerEx will be deprecated end + +--functions of ccs.SceneReader will be deprecated begin +local CCSSceneReaderDeprecated = { } +function CCSSceneReaderDeprecated.destroySceneReader(self) + deprecatedTip("ccs.SceneReader:destroySceneReader","ccs.SceneReader:destroyInstance") + return self:destroyInstance() +end +rawset(ccs.SceneReader,"destroySceneReader",CCSSceneReaderDeprecated.destroySceneReader) +--functions of ccs.SceneReader will be deprecated end + +--functions of CCArmatureDataManager will be deprecated begin +local CCArmatureDataManagerDeprecated = { } +function CCArmatureDataManagerDeprecated.sharedArmatureDataManager() + deprecatedTip("CCArmatureDataManager:sharedArmatureDataManager","ccs.ArmatureDataManager:getInstance") + return ccs.ArmatureDataManager:getInstance() +end +rawset(CCArmatureDataManager,"sharedArmatureDataManager",CCArmatureDataManagerDeprecated.sharedArmatureDataManager) + +function CCArmatureDataManagerDeprecated.purge() + deprecatedTip("CCArmatureDataManager:purge","ccs.ArmatureDataManager:destoryInstance") + return ccs.ArmatureDataManager:destoryInstance() +end +rawset(CCArmatureDataManager,"purge",CCArmatureDataManagerDeprecated.purge) +--functions of CCArmatureDataManager will be deprecated end + +--functions of GUIReader will be deprecated begin +local GUIReaderDeprecated = { } +function GUIReaderDeprecated.shareReader() + deprecatedTip("GUIReader:shareReader","ccs.GUIReader:getInstance") + return ccs.GUIReader:getInstance() +end +rawset(GUIReader,"shareReader",GUIReaderDeprecated.shareReader) + +function GUIReaderDeprecated.purgeGUIReader() + deprecatedTip("GUIReader:purgeGUIReader","ccs.GUIReader:destroyInstance") + return ccs.GUIReader:destroyInstance() +end +rawset(GUIReader,"purgeGUIReader",GUIReaderDeprecated.purgeGUIReader) +--functions of GUIReader will be deprecated end + +--functions of SceneReader will be deprecated begin +local SceneReaderDeprecated = { } +function SceneReaderDeprecated.sharedSceneReader() + deprecatedTip("SceneReader:sharedSceneReader","ccs.SceneReader:getInstance") + return ccs.SceneReader:getInstance() +end +rawset(SceneReader,"sharedSceneReader",SceneReaderDeprecated.sharedSceneReader) + +function SceneReaderDeprecated.purgeSceneReader(self) + deprecatedTip("SceneReader:purgeSceneReader","ccs.SceneReader:destroyInstance") + return self:destroyInstance() +end +rawset(SceneReader,"purgeSceneReader",SceneReaderDeprecated.purgeSceneReader) +--functions of SceneReader will be deprecated end + +--functions of ActionManager will be deprecated begin +local ActionManagerDeprecated = { } +function ActionManagerDeprecated.shareManager() + deprecatedTip("ActionManager:shareManager","ccs.ActionManagerEx:getInstance") + return ccs.ActionManagerEx:getInstance() +end +rawset(ActionManager,"shareManager",ActionManagerDeprecated.shareManager) + +function ActionManagerDeprecated.purgeActionManager() + deprecatedTip("ActionManager:purgeActionManager","ccs.ActionManagerEx:destroyActionManager") + return ccs.ActionManagerEx:destroyActionManager() +end +rawset(ActionManager,"purgeActionManager",ActionManagerDeprecated.purgeActionManager) +--functions of ActionManager will be deprecated end + + diff --git a/cocos/scripting/lua/script/DeprecatedClass.lua b/cocos/scripting/lua/script/DeprecatedClass.lua index dbd7dfff02..15e94b5189 100644 --- a/cocos/scripting/lua/script/DeprecatedClass.lua +++ b/cocos/scripting/lua/script/DeprecatedClass.lua @@ -1815,13 +1815,298 @@ end _G["CCCallFuncN"] = DeprecatedClass.CCCallFuncN() --CCCallFuncN class will be Deprecated,end ---ccBlendFunc class will be Deprecated,begin -function DeprecatedClass.ccBlendFunc() - deprecatedTip("ccBlendFunc","BlendFunc") - return BlendFunc +--CCArmature class will be Deprecated,begin +function DeprecatedClass.CCArmature() + deprecatedTip("CCArmature","ccs.Armature") + return ccs.Armature end -_G["ccBlendFunc"] = DeprecatedClass.ccBlendFunc() ---ccBlendFunc class will be Deprecated,end +_G["CCArmature"] = DeprecatedClass.CCArmature() +--CCArmature class will be Deprecated,end +--CCArmatureAnimation class will be Deprecated,begin +function DeprecatedClass.CCArmatureAnimation() + deprecatedTip("CCArmatureAnimation","ccs.ArmatureAnimation") + return ccs.ArmatureAnimation +end +_G["CCArmatureAnimation"] = DeprecatedClass.CCArmatureAnimation() +--CCArmatureAnimation class will be Deprecated,end +--CCSkin class will be Deprecated,begin +function DeprecatedClass.CCSkin() + deprecatedTip("CCSkin","ccs.Skin") + return ccs.Skin +end +_G["CCSkin"] = DeprecatedClass.CCSkin() +--CCSkin class will be Deprecated,end +--CCBone class will be Deprecated,begin +function DeprecatedClass.CCBone() + deprecatedTip("CCBone","ccs.Bone") + return ccs.Bone +end +_G["CCBone"] = DeprecatedClass.CCBone() +--CCBone class will be Deprecated,end + +--CCArmatureDataManager class will be Deprecated,begin +function DeprecatedClass.CCArmatureDataManager() + deprecatedTip("CCArmatureDataManager","ccs.ArmatureDataManager") + return ccs.ArmatureDataManager +end +_G["CCArmatureDataManager"] = DeprecatedClass.CCArmatureDataManager() +--CCArmatureDataManager class will be Deprecated,end + +--CCBatchNode class will be Deprecated,begin +function DeprecatedClass.CCBatchNode() + deprecatedTip("CCBatchNode","ccs.BatchNode") + return ccs.BatchNode +end +_G["CCBatchNode"] = DeprecatedClass.CCBatchNode() +--CCBatchNode class will be Deprecated,end + +--CCTween class will be Deprecated,begin +function DeprecatedClass.CCTween() + deprecatedTip("CCTween","ccs.Tween") + return ccs.Tween +end +_G["CCTween"] = DeprecatedClass.CCTween() +--CCTween class will be Deprecated,end + +--CCBaseData class will be Deprecated,begin +function DeprecatedClass.CCBaseData() + deprecatedTip("CCBaseData","ccs.BaseData") + return ccs.BaseData +end +_G["CCBaseData"] = DeprecatedClass.CCBaseData() +--CCBaseData class will be Deprecated,end + +--CCDisplayManager class will be Deprecated,begin +function DeprecatedClass.CCDisplayManager() + deprecatedTip("CCDisplayManager","ccs.DisplayManager") + return ccs.DisplayManager +end +_G["CCDisplayManager"] = DeprecatedClass.CCDisplayManager() +--CCDisplayManager class will be Deprecated,end + +--UIHelper class will be Deprecated,begin +function DeprecatedClass.UIHelper() + deprecatedTip("UIHelper","ccs.UIHelper") + return ccs.UIHelper +end +_G["UIHelper"] = DeprecatedClass.UIHelper() +--UIHelper class will be Deprecated,end + +--UILayout class will be Deprecated,begin +function DeprecatedClass.UILayout() + deprecatedTip("UILayout","ccs.UILayout") + return ccs.UILayout +end +_G["UILayout"] = DeprecatedClass.UILayout() +--UILayout class will be Deprecated,end + +--UIWidget class will be Deprecated,begin +function DeprecatedClass.UIWidget() + deprecatedTip("UIWidget","ccs.UIWidget") + return ccs.UIWidget +end +_G["UIWidget"] = DeprecatedClass.UIWidget() +--UIWidget class will be Deprecated,end + +--UILayer class will be Deprecated,begin +function DeprecatedClass.UILayer() + deprecatedTip("UILayer","ccs.UILayer") + return ccs.UILayer +end +_G["UILayer"] = DeprecatedClass.UILayer() +--UILayer class will be Deprecated,end + +--UIButton class will be Deprecated,begin +function DeprecatedClass.UIButton() + deprecatedTip("UIButton","ccs.UIButton") + return ccs.UIButton +end +_G["UIButton"] = DeprecatedClass.UIButton() +--UIButton class will be Deprecated,end + +--UICheckBox class will be Deprecated,begin +function DeprecatedClass.UICheckBox() + deprecatedTip("UICheckBox","ccs.UICheckBox") + return ccs.UICheckBox +end +_G["UICheckBox"] = DeprecatedClass.UICheckBox() +--UICheckBox class will be Deprecated,end + +--UIImageView class will be Deprecated,begin +function DeprecatedClass.UIImageView() + deprecatedTip("UIImageView","ccs.UIImageView") + return ccs.UIImageView +end +_G["UIImageView"] = DeprecatedClass.UIImageView() +--UIImageView class will be Deprecated,end + +--UILabel class will be Deprecated,begin +function DeprecatedClass.UILabel() + deprecatedTip("UILabel","ccs.UILabel") + return ccs.UILabel +end +_G["UILabel"] = DeprecatedClass.UILabel() +--UILabel class will be Deprecated,end + +--UILabelAtlas class will be Deprecated,begin +function DeprecatedClass.UILabelAtlas() + deprecatedTip("UILabelAtlas","ccs.UILabelAtlas") + return ccs.UILabelAtlas +end +_G["UILabelAtlas"] = DeprecatedClass.UILabelAtlas() +--UILabelAtlas class will be Deprecated,end + +--UILabelBMFont class will be Deprecated,begin +function DeprecatedClass.UILabelBMFont() + deprecatedTip("UILabelBMFont","ccs.UILabelBMFont") + return ccs.UILabelBMFont +end +_G["UILabelBMFont"] = DeprecatedClass.UILabelBMFont() +--UILabelBMFont class will be Deprecated,end + +--UILoadingBar class will be Deprecated,begin +function DeprecatedClass.UILoadingBar() + deprecatedTip("UILoadingBar","ccs.UILoadingBar") + return ccs.UILoadingBar +end +_G["UILoadingBar"] = DeprecatedClass.UILoadingBar() +--UILoadingBar class will be Deprecated,end + +--UISlider class will be Deprecated,begin +function DeprecatedClass.UISlider() + deprecatedTip("UISlider","ccs.UISlider") + return ccs.UISlider +end +_G["UISlider"] = DeprecatedClass.UISlider() +--UISlider class will be Deprecated,end + +--UITextField class will be Deprecated,begin +function DeprecatedClass.UITextField() + deprecatedTip("UITextField","ccs.UITextField") + return ccs.UITextField +end +_G["UITextField"] = DeprecatedClass.UITextField() +--UITextField class will be Deprecated,end + +--UIScrollView class will be Deprecated,begin +function DeprecatedClass.UIScrollView() + deprecatedTip("UIScrollView","ccs.UIScrollView") + return ccs.UIScrollView +end +_G["UIScrollView"] = DeprecatedClass.UIScrollView() +--UIScrollView class will be Deprecated,end + +--UIPageView class will be Deprecated,begin +function DeprecatedClass.UIPageView() + deprecatedTip("UIPageView","ccs.UIPageView") + return ccs.UIPageView +end +_G["UIPageView"] = DeprecatedClass.UIPageView() +--UIPageView class will be Deprecated,end + +--UIListView class will be Deprecated,begin +function DeprecatedClass.UIListView() + deprecatedTip("UIListView","ccs.UIListView") + return ccs.UIListView +end +_G["UIListView"] = DeprecatedClass.UIListView() +--UIListView class will be Deprecated,end + +--UILayoutParameter class will be Deprecated,begin +function DeprecatedClass.UILayoutParameter() + deprecatedTip("UILayoutParameter","ccs.UILayoutParameter") + return ccs.UILayoutParameter +end +_G["UILayoutParameter"] = DeprecatedClass.UILayoutParameter() +--UILayoutParameter class will be Deprecated,end + +--UILinearLayoutParameter class will be Deprecated,begin +function DeprecatedClass.UILinearLayoutParameter() + deprecatedTip("UILinearLayoutParameter","ccs.UILinearLayoutParameter") + return ccs.UILinearLayoutParameter +end +_G["UILinearLayoutParameter"] = DeprecatedClass.UILinearLayoutParameter() +--UILinearLayoutParameter class will be Deprecated,end + +--UIRelativeLayoutParameter class will be Deprecated,begin +function DeprecatedClass.UIRelativeLayoutParameter() + deprecatedTip("UIRelativeLayoutParameter","ccs.UIRelativeLayoutParameter") + return ccs.UIRelativeLayoutParameter +end +_G["UIRelativeLayoutParameter"] = DeprecatedClass.UIRelativeLayoutParameter() +--UIRelativeLayoutParameter class will be Deprecated,end + +--CCComController class will be Deprecated,begin +function DeprecatedClass.CCComController() + deprecatedTip("CCComController","ccs.ComController") + return ccs.CCComController +end +_G["CCComController"] = DeprecatedClass.CCComController() +--CCComController class will be Deprecated,end + +--CCComAudio class will be Deprecated,begin +function DeprecatedClass.CCComAudio() + deprecatedTip("CCComAudio","ccs.ComAudio") + return ccs.ComAudio +end +_G["CCComAudio"] = DeprecatedClass.CCComAudio() +--CCComAudio class will be Deprecated,end + +--CCComAttribute class will be Deprecated,begin +function DeprecatedClass.CCComAttribute() + deprecatedTip("CCComAttribute","ccs.ComAttribute") + return ccs.ComAttribute +end +_G["CCComAttribute"] = DeprecatedClass.CCComAttribute() +--CCComAttribute class will be Deprecated,end + +--CCComRender class will be Deprecated,begin +function DeprecatedClass.CCComRender() + deprecatedTip("CCComRender","ccs.ComRender") + return ccs.ComRender +end +_G["CCComRender"] = DeprecatedClass.CCComRender() +--CCComRender class will be Deprecated,end + +--ActionManager class will be Deprecated,begin +function DeprecatedClass.ActionManager() + deprecatedTip("ActionManager","ccs.ActionManagerEx") + return ccs.ActionManagerEx +end +_G["ActionManager"] = DeprecatedClass.ActionManager() +--CCComRender class will be Deprecated,end + +--SceneReader class will be Deprecated,begin +function DeprecatedClass.SceneReader() + deprecatedTip("SceneReader","ccs.SceneReader") + return ccs.SceneReader +end +_G["SceneReader"] = DeprecatedClass.SceneReader() +--SceneReader class will be Deprecated,end + +--GUIReader class will be Deprecated,begin +function DeprecatedClass.GUIReader() + deprecatedTip("GUIReader","ccs.GUIReader") + return ccs.GUIReader +end +_G["GUIReader"] = DeprecatedClass.GUIReader() +--GUIReader class will be Deprecated,end + +--UIRootWidget class will be Deprecated,begin +function DeprecatedClass.UIRootWidget() + deprecatedTip("UIRootWidget","ccs.UIRootWidget") + return ccs.UIRootWidget +end +_G["UIRootWidget"] = DeprecatedClass.UIRootWidget() +--UIRootWidget class will be Deprecated,end + +--ActionObject class will be Deprecated,begin +function DeprecatedClass.ActionObject() + deprecatedTip("ActionObject","ccs.ActionObject") + return ccs.ActionObject +end +_G["ActionObject"] = DeprecatedClass.ActionObject() +--ActionObject class will be Deprecated,end diff --git a/cocos/scripting/lua/script/DeprecatedEnum.lua b/cocos/scripting/lua/script/DeprecatedEnum.lua index 7c22fe23d8..03c7619f83 100644 --- a/cocos/scripting/lua/script/DeprecatedEnum.lua +++ b/cocos/scripting/lua/script/DeprecatedEnum.lua @@ -394,4 +394,88 @@ _G.kWebSocketScriptHandlerError = cc.WEBSOCKET_ERROR _G.kStateConnecting = cc.WEBSOCKET_STATE_CONNECTING _G.kStateOpen = cc.WEBSOCKET_STATE_OPEN _G.kStateClosing = cc.WEBSOCKET_STATE_CLOSING -_G.kStateClosed = cc.WEBSOCKET_STATE_CLOSED +_G.kStateClosed = cc.WEBSOCKET_STATE_CLOSED + +_G.LAYOUT_COLOR_NONE = ccs.LayoutBackGroundColorType.none +_G.LAYOUT_COLOR_SOLID = ccs.LayoutBackGroundColorType.solid +_G.LAYOUT_COLOR_GRADIENT = ccs.LayoutBackGroundColorType.gradient + +_G.LAYOUT_ABSOLUTE = ccs.LayoutType.absolute +_G.LAYOUT_LINEAR_VERTICAL = ccs.LayoutType.linearVertical +_G.LAYOUT_LINEAR_HORIZONTAL = ccs.LayoutType.linearHorizontal +_G.LAYOUT_RELATIVE = ccs.LayoutType.relative + +_G.BRIGHT_NONE = ccs.BrightStyle.none +_G.BRIGHT_NORMAL = ccs.BrightStyle.normal +_G.BRIGHT_HIGHLIGHT = ccs.BrightStyle.highlight + +_G.WidgetTypeWidget = ccs.WidgetType.widget +_G.WidgetTypeContainer = ccs.WidgetType.container + +_G.UI_TEX_TYPE_LOCAL = ccs.TextureResType.UI_TEX_TYPE_LOCAL +_G.UI_TEX_TYPE_PLIST = ccs.TextureResType.UI_TEX_TYPE_PLIST + +_G.TOUCH_EVENT_BEGAN = ccs.TouchEventType.began +_G.TOUCH_EVENT_MOVED = ccs.TouchEventType.moved +_G.TOUCH_EVENT_ENDED = ccs.TouchEventType.ended +_G.TOUCH_EVENT_CANCELED = ccs.TouchEventType.canceled + +_G.SIZE_ABSOLUTE = ccs.SizeType.absolute +_G.SIZE_PERCENT = ccs.SizeType.percent + +_G.POSITION_ABSOLUTE = ccs.PositionType.absolute +_G.POSITION_PERCENT = ccs.PositionType.percent + +_G.CHECKBOX_STATE_EVENT_SELECTED = ccs.CheckBoxEventType.selected +_G.CHECKBOX_STATE_EVENT_UNSELECTED = ccs.CheckBoxEventType.unselected + +_G.CHECKBOX_STATE_EVENT_SELECTED = ccs.CheckBoxEventType.selected +_G.CHECKBOX_STATE_EVENT_UNSELECTED = ccs.CheckBoxEventType.unselected + +_G.LoadingBarTypeLeft = ccs.LoadingBarType.left +_G.LoadingBarTypeRight = ccs.LoadingBarType.right + +_G.LoadingBarTypeRight = ccs.SliderEventType.percent_changed + +_G.TEXTFIELD_EVENT_ATTACH_WITH_IME = ccs.TextFiledEventType.attach_with_ime +_G.TEXTFIELD_EVENT_DETACH_WITH_IME = ccs.TextFiledEventType.detach_with_ime +_G.TEXTFIELD_EVENT_INSERT_TEXT = ccs.TextFiledEventType.insert_text +_G.TEXTFIELD_EVENT_DELETE_BACKWARD = ccs.TextFiledEventType.delete_backward + +_G.SCROLLVIEW_EVENT_SCROLL_TO_TOP = ccs.SCROLLVIEW_DIR.none +_G.SCROLLVIEW_DIR_VERTICAL = ccs.SCROLLVIEW_DIR.vertical +_G.SCROLLVIEW_DIR_HORIZONTAL = ccs.SCROLLVIEW_DIR.horizontal +_G.SCROLLVIEW_DIR_BOTH = ccs.SCROLLVIEW_DIR.both + +_G.SCROLLVIEW_EVENT_SCROLL_TO_TOP = ccs.ScrollviewEventType.SCROLL_TO_TOP +_G.SCROLLVIEW_EVENT_SCROLL_TO_BOTTOM = ccs.ScrollviewEventType.SCROLL_TO_BOTTOM +_G.SCROLLVIEW_EVENT_SCROLL_TO_LEFT = ccs.ScrollviewEventType.SCROLL_TO_LEFT +_G.SCROLLVIEW_EVENT_SCROLL_TO_RIGHT = ccs.ScrollviewEventType.SCROLL_TO_RIGHT +_G.SCROLLVIEW_EVENT_SCROLLING = ccs.ScrollviewEventType.SCROLLING +_G.SCROLLVIEW_EVENT_BOUNCE_TOP = ccs.ScrollviewEventType.BOUNCE_TOP +_G.SCROLLVIEW_EVENT_BOUNCE_BOTTOM = ccs.ScrollviewEventType.BOUNCE_BOTTOM +_G.SCROLLVIEW_EVENT_BOUNCE_LEFT = ccs.ScrollviewEventType.BOUNCE_LEFT +_G.SCROLLVIEW_EVENT_BOUNCE_RIGHT = ccs.ScrollviewEventType.BOUNCE_RIGHT + +_G.PAGEVIEW_EVENT_TURNING = ccs.PageViewEventType.turning + +_G.PAGEVIEW_TOUCHLEFT = ccs.PVTouchDir.touch_left +_G.PAGEVIEW_TOUCHRIGHT = ccs.PVTouchDir.touch_right + +_G.LISTVIEW_DIR_NONE = ccs.ListViewDirection.none +_G.LISTVIEW_DIR_VERTICAL = ccs.ListViewDirection.vertical +_G.LISTVIEW_DIR_HORIZONTAL = ccs.ListViewDirection.horizontal + +_G.LISTVIEW_MOVE_DIR_NONE = ccs.ListViewMoveDirection.none +_G.LISTVIEW_MOVE_DIR_UP = ccs.ListViewMoveDirection.up +_G.LISTVIEW_MOVE_DIR_DOWN = ccs.ListViewMoveDirection.down +_G.LISTVIEW_MOVE_DIR_LEFT = ccs.ListViewMoveDirection.left +_G.LISTVIEW_MOVE_DIR_RIGHT = ccs.ListViewMoveDirection.right + +_G.LISTVIEW_EVENT_INIT_CHILD = ccs.ListViewEventType.init_child +_G.LISTVIEW_EVENT_UPDATE_CHILD = ccs.ListViewEventType.update_child + +_G.LAYOUT_PARAMETER_NONE = ccs.UILayoutParameterType.none +_G.LAYOUT_PARAMETER_LINEAR = ccs.UILayoutParameterType.linear +_G.LAYOUT_PARAMETER_RELATIVE = ccs.UILayoutParameterType.relative + diff --git a/cocos/scripting/lua/script/StudioConstants.lua b/cocos/scripting/lua/script/StudioConstants.lua index 001ebe7341..107b0f8406 100644 --- a/cocos/scripting/lua/script/StudioConstants.lua +++ b/cocos/scripting/lua/script/StudioConstants.lua @@ -20,11 +20,11 @@ ccs.WidgetType = container = 1, --container } --- ccs.TextureResType = --- { --- "local" = 0, --- "plist" = 1, --- } +ccs.TextureResType = +{ + UI_TEX_TYPE_LOCAL = 0, + UI_TEX_TYPE_PLIST = 1, +} ccs.TouchEventType = { @@ -138,10 +138,15 @@ ccs.SCROLLVIEW_MOVE_DIR = { } ccs.ScrollviewEventType = { - top = 0, - bottom = 1, - left = 2, - right = 3, + SCROLL_TO_TOP = 0, + SCROLL_TO_BOTTOM = 1, + SCROLL_TO_LEFT = 2, + SCROLL_TO_RIGHT = 3, + SCROLLING = 4, + BOUNCE_TOP = 5, + BOUNCE_BOTTOM = 6, + BOUNCE_LEFT = 7, + BOUNCE_RIGHT = 8, } ccs.ListViewDirection = { diff --git a/tools/tolua/cocos2dx_studio.ini b/tools/tolua/cocos2dx_studio.ini index 5fd5cacc31..d38fcd86cd 100644 --- a/tools/tolua/cocos2dx_studio.ini +++ b/tools/tolua/cocos2dx_studio.ini @@ -49,11 +49,9 @@ skip = *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .* UIWidget::[(s|g)etUserObject], UIImageView::[doubleClickEvent] -rename_functions = UIHelper::[instance=getInstance], - ArmatureDataManager::[sharedArmatureDataManager=getInstance], - GUIReader::[shareReader=getInstance], - ActionManagerEx::[shareManager=getInstance purgeActionManager=destroyActionManager], - SceneReader::[purgeSceneReader=destroySceneReader] +rename_functions = GUIReader::[shareReader=getInstance purgeGUIReader=destroyInstance], + ActionManagerEx::[shareManager=getInstance purgeActionManager=destroyInstance], + SceneReader::[purgeSceneReader=destroyInstance] rename_classes = From fd68dc4f9f9b1a6689427aa145c2ffe80d05600b Mon Sep 17 00:00:00 2001 From: boyu0 Date: Tue, 3 Dec 2013 16:28:18 +0800 Subject: [PATCH 28/30] issue #2771: add condition test to updatePhysicsTransform --- cocos/2d/CCNode.cpp | 7 +++++-- cocos/2d/CCNode.h | 2 +- cocos/2d/CCSprite.cpp | 6 ++++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/cocos/2d/CCNode.cpp b/cocos/2d/CCNode.cpp index c665b254b4..bdff745edf 100644 --- a/cocos/2d/CCNode.cpp +++ b/cocos/2d/CCNode.cpp @@ -1341,14 +1341,17 @@ Point Node::convertTouchToNodeSpaceAR(Touch *touch) const } #ifdef CC_USE_PHYSICS -void Node::updatePhysicsTransform() +bool Node::updatePhysicsTransform() { - if (_physicsBody) + if (_physicsBody != nullptr && _physicsBody->getWorld() != nullptr && !_physicsBody->isResting()) { _position = _physicsBody->getPosition(); _rotationX = _rotationY = _physicsBody->getRotation(); _transformDirty = _inverseDirty = true; + return true; } + + return false; } #endif diff --git a/cocos/2d/CCNode.h b/cocos/2d/CCNode.h index 9212676669..1beda38d4c 100644 --- a/cocos/2d/CCNode.h +++ b/cocos/2d/CCNode.h @@ -1386,7 +1386,7 @@ public: /** * update rotation and position from physics body */ - virtual void updatePhysicsTransform(); + virtual bool updatePhysicsTransform(); #endif diff --git a/cocos/2d/CCSprite.cpp b/cocos/2d/CCSprite.cpp index b4be678d87..36577238b0 100644 --- a/cocos/2d/CCSprite.cpp +++ b/cocos/2d/CCSprite.cpp @@ -496,8 +496,10 @@ void Sprite::updateTransform(void) CCASSERT(_batchNode, "updateTransform is only valid when Sprite is being rendered using an SpriteBatchNode"); #ifdef CC_USE_PHYSICS - updatePhysicsTransform(); - setDirty(true); + if (updatePhysicsTransform()) + { + setDirty(true); + }; #endif // recalculate matrix only if it is dirty From c1a226686fd07baae29937e4ba9bc96a12cf7c8f Mon Sep 17 00:00:00 2001 From: samuele3 Date: Wed, 4 Dec 2013 15:15:55 +0800 Subject: [PATCH 29/30] issue #3309:Modify some deprecated cpp files and lua files --- .../lua/bindings/lua_cocos2dx_deprecated.cpp | 2259 +++++++++++++++++ ...lua_cocos2dx_deprecated.cpp.REMOVED.git-id | 1 - cocos/scripting/lua/script/CCBReaderLoad.lua | 7 + cocos/scripting/lua/script/Deprecated.lua | 40 +- .../scripting/lua/script/DeprecatedClass.lua | 26 + cocos/scripting/lua/script/DeprecatedEnum.lua | 5 + tools/tolua/cocos2dx.ini | 12 +- 7 files changed, 2326 insertions(+), 24 deletions(-) create mode 100644 cocos/scripting/lua/bindings/lua_cocos2dx_deprecated.cpp delete mode 100644 cocos/scripting/lua/bindings/lua_cocos2dx_deprecated.cpp.REMOVED.git-id diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_deprecated.cpp b/cocos/scripting/lua/bindings/lua_cocos2dx_deprecated.cpp new file mode 100644 index 0000000000..780ad41a31 --- /dev/null +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_deprecated.cpp @@ -0,0 +1,2259 @@ +#include "lua_cocos2dx_deprecated.h" + +#ifdef __cplusplus +extern "C" { +#endif +#include "tolua_fix.h" +#ifdef __cplusplus +} +#endif + +#include "cocos2d.h" +#include "LuaBasicConversions.h" +#include "LuaScriptHandlerMgr.h" +#include "CCLuaValue.h" +#include "cocos-ext.h" + +USING_NS_CC; +USING_NS_CC_EXT; + +#define deprecatedClassTip(className) CCLOG("%s will be not binded in lua,please use the lua's table instead",className) +#define deprecatedFunctionTip(oldFun,newFun) CCLOG("%s was deprecated please use %s instead ",oldFun, newFun) +static int tolua_Cocos2d_CCPoint_new00(lua_State* tolua_S) +{ + deprecatedClassTip("CCPoint"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"CCPoint",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Point tolua_ret; + point_to_luaval(tolua_S, tolua_ret); + } + return 1; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_Cocos2d_CCPoint_new00_local(lua_State* tolua_S) +{ + deprecatedClassTip("CCPoint"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"CCPoint",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Point tolua_ret; + point_to_luaval(tolua_S, tolua_ret); + } + return 1; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_Cocos2d_CCPoint_new01(lua_State* tolua_S) +{ + deprecatedClassTip("CCPoint"); + + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"CCPoint",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnoobj(tolua_S,4,&tolua_err) + ) + goto tolua_lerror; + else + { + float x = ((float) tolua_tonumber(tolua_S,2,0)); + float y = ((float) tolua_tonumber(tolua_S,3,0)); + Point tolua_ret(x,y); + point_to_luaval(tolua_S, tolua_ret); + } + return 1; +tolua_lerror: + return tolua_Cocos2d_CCPoint_new00(tolua_S); +} + + +static int tolua_Cocos2d_CCPoint_new01_local(lua_State* tolua_S) +{ + deprecatedClassTip("CCPoint"); + + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"CCPoint",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnoobj(tolua_S,4,&tolua_err) + ) + goto tolua_lerror; + else + { + float x = ((float) tolua_tonumber(tolua_S,2,0)); + float y = ((float) tolua_tonumber(tolua_S,3,0)); + Point tolua_ret(x,y); + point_to_luaval(tolua_S, tolua_ret); + } + return 1; +tolua_lerror: + return tolua_Cocos2d_CCPoint_new00_local(tolua_S); +} + +static int tolua_collect_CCPoint (lua_State* tolua_S) +{ + Point* self = (Point*) tolua_tousertype(tolua_S,1,0); + Mtolua_delete(self); + return 0; +} + +static int register_cocos2dx_deprecated_Point(lua_State* tolua_S) +{ + tolua_usertype(tolua_S,"CCPoint"); +#ifdef __cplusplus + tolua_cclass(tolua_S,"CCPoint","CCPoint","",tolua_collect_CCPoint); +#else + tolua_cclass(tolua_S,"CCPoint","CCPoint","",NULL); +#endif + tolua_beginmodule(tolua_S,"CCPoint"); + tolua_function(tolua_S,"new",tolua_Cocos2d_CCPoint_new00); + tolua_function(tolua_S,"new_local",tolua_Cocos2d_CCPoint_new00_local); + tolua_function(tolua_S,".call",tolua_Cocos2d_CCPoint_new00_local); + tolua_function(tolua_S,"new",tolua_Cocos2d_CCPoint_new01); + tolua_function(tolua_S,"new_local",tolua_Cocos2d_CCPoint_new01_local); + tolua_function(tolua_S,".call",tolua_Cocos2d_CCPoint_new01_local); + tolua_endmodule(tolua_S); + + return 1; +} + +static int tolua_Cocos2d_CCRect_new00(lua_State* tolua_S) +{ + deprecatedClassTip("CCRect"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"CCRect",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Rect tolua_ret; + rect_to_luaval(tolua_S, tolua_ret); + } + return 1; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_Cocos2d_CCRect_new00_local(lua_State* tolua_S) +{ + deprecatedClassTip("CCRect"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"CCRect",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Rect tolua_ret; + rect_to_luaval(tolua_S, tolua_ret); + } + return 1; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); + return 0; +#endif +} + +static int tolua_Cocos2d_CCRect_new01(lua_State* tolua_S) +{ + deprecatedClassTip("CCRect"); + + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"CCRect",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnumber(tolua_S,5,0,&tolua_err) || + !tolua_isnoobj(tolua_S,6,&tolua_err) + ) + goto tolua_lerror; + else + { + float x = ((float) tolua_tonumber(tolua_S,2,0)); + float y = ((float) tolua_tonumber(tolua_S,3,0)); + float width = ((float) tolua_tonumber(tolua_S,4,0)); + float height = ((float) tolua_tonumber(tolua_S,5,0)); + Rect tolua_ret(x, y, width, height); + rect_to_luaval(tolua_S, tolua_ret); + } + return 1; +tolua_lerror: + return tolua_Cocos2d_CCRect_new00(tolua_S); +} + + +static int tolua_Cocos2d_CCRect_new01_local(lua_State* tolua_S) +{ + deprecatedClassTip("CCRect"); + + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"CCRect",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnumber(tolua_S,5,0,&tolua_err) || + !tolua_isnoobj(tolua_S,6,&tolua_err) + ) + goto tolua_lerror; + else + { + float x = ((float) tolua_tonumber(tolua_S,2,0)); + float y = ((float) tolua_tonumber(tolua_S,3,0)); + float width = ((float) tolua_tonumber(tolua_S,4,0)); + float height = ((float) tolua_tonumber(tolua_S,5,0)); + Rect tolua_ret(x, y, width, height); + rect_to_luaval(tolua_S, tolua_ret); + } + return 1; +tolua_lerror: + return tolua_Cocos2d_CCRect_new00_local(tolua_S); +} + +static int register_cocos2dx_deprecated_Rect(lua_State* tolua_S) +{ + + tolua_usertype(tolua_S,"CCRect"); + tolua_cclass(tolua_S,"CCRect","CCRect","",NULL); + tolua_beginmodule(tolua_S,"CCRect"); + tolua_function(tolua_S,"new",tolua_Cocos2d_CCRect_new00); + tolua_function(tolua_S,"new_local",tolua_Cocos2d_CCRect_new00_local); + tolua_function(tolua_S,".call",tolua_Cocos2d_CCRect_new00_local); + tolua_function(tolua_S,"new",tolua_Cocos2d_CCRect_new01); + tolua_function(tolua_S,"new_local",tolua_Cocos2d_CCRect_new01_local); + tolua_function(tolua_S,".call",tolua_Cocos2d_CCRect_new01_local); + tolua_endmodule(tolua_S); + + return 1; +} + +static int tolua_Cocos2d_CCSize_new00(lua_State* tolua_S) +{ + deprecatedClassTip("CCSize"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"CCSize",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Size tolua_ret; + size_to_luaval(tolua_S, tolua_ret); + } + return 1; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_Cocos2d_CCSize_new00_local(lua_State* tolua_S) +{ + deprecatedClassTip("CCSize"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"CCSize",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Size tolua_ret; + size_to_luaval(tolua_S, tolua_ret); + } + return 1; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_Cocos2d_CCSize_new01(lua_State* tolua_S) +{ + deprecatedClassTip("CCSize"); + + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"CCSize",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnoobj(tolua_S,4,&tolua_err) + ) + goto tolua_lerror; + else + { + float width = ((float) tolua_tonumber(tolua_S,2,0)); + float height = ((float) tolua_tonumber(tolua_S,3,0)); + Size tolua_ret(width, height); + size_to_luaval(tolua_S, tolua_ret); + } + return 1; +tolua_lerror: + return tolua_Cocos2d_CCSize_new00(tolua_S); +} + + + +static int tolua_Cocos2d_CCSize_new01_local(lua_State* tolua_S) +{ + + deprecatedClassTip("CCSize"); + + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"CCSize",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnoobj(tolua_S,4,&tolua_err) + ) + goto tolua_lerror; + else + { + float width = ((float) tolua_tonumber(tolua_S,2,0)); + float height = ((float) tolua_tonumber(tolua_S,3,0)); + Size tolua_ret(width, height); + size_to_luaval(tolua_S, tolua_ret); + } + return 1; +tolua_lerror: + return tolua_Cocos2d_CCSize_new00_local(tolua_S); +} + + +static int register_cocos2dx_deprecated_Size(lua_State* tolua_S) +{ + + tolua_usertype(tolua_S,"CCSize"); + tolua_cclass(tolua_S,"CCSize","CCSize","",NULL); + tolua_beginmodule(tolua_S,"CCSize"); + tolua_function(tolua_S,"new",tolua_Cocos2d_CCSize_new00); + tolua_function(tolua_S,"new_local",tolua_Cocos2d_CCSize_new00_local); + tolua_function(tolua_S,".call",tolua_Cocos2d_CCSize_new00_local); + tolua_function(tolua_S,"new",tolua_Cocos2d_CCSize_new01); + tolua_function(tolua_S,"new_local",tolua_Cocos2d_CCSize_new01_local); + tolua_function(tolua_S,".call",tolua_Cocos2d_CCSize_new01_local); + tolua_endmodule(tolua_S); + + return 1; +} + + +static int tolua_Cocos2d_CCArray_create00(lua_State* tolua_S) +{ + + deprecatedClassTip("CCArray"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"CCArray",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + { + Array* tolua_ret = (Array*) Array::create(); + int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; + int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; + toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"CCArray"); + } + } + return 1; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_Cocos2d_CCArray_createWithObject00(lua_State* tolua_S) +{ + deprecatedClassTip("CCArray"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"CCArray",0,&tolua_err) || + !tolua_isusertype(tolua_S,2,"Object",0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Object* pObject = ((Object*) tolua_tousertype(tolua_S,2,0)); + { + Array* tolua_ret = (Array*) Array::createWithObject(pObject); + int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; + int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; + toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"CCArray"); + } + } + return 1; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'createWithObject'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_Cocos2d_CCArray_createWithArray00(lua_State* tolua_S) +{ + deprecatedClassTip("CCArray"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"CCArray",0,&tolua_err) || + !tolua_isusertype(tolua_S,2,"CCArray",0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Array* otherArray = ((Array*) tolua_tousertype(tolua_S,2,0)); + { + Array* tolua_ret = (Array*) Array::createWithArray(otherArray); + int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; + int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; + toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"CCArray"); + } + } + return 1; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'createWithArray'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_Cocos2d_CCArray_createWithCapacity00(lua_State* tolua_S) +{ + + deprecatedClassTip("CCArray"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"CCArray",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + unsigned int capacity = ((unsigned int) tolua_tonumber(tolua_S,2,0)); + { + Array* tolua_ret = (Array*) Array::createWithCapacity(capacity); + int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; + int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; + toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"CCArray"); + } + } + return 1; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'createWithCapacity'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_Cocos2d_CCArray_createWithContentsOfFile00(lua_State* tolua_S) +{ + deprecatedClassTip("CCArray"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"CCArray",0,&tolua_err) || + !tolua_isstring(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const char* pFileName = ((const char*) tolua_tostring(tolua_S,2,0)); + { + Array* tolua_ret = (Array*) Array::createWithContentsOfFile(pFileName); + int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; + int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; + toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"CCArray"); + } + } + return 1; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'createWithContentsOfFile'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_Cocos2d_CCArray_count00(lua_State* tolua_S) +{ + deprecatedClassTip("CCArray"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Array* self = (Array*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'count'", NULL); +#endif + { + unsigned int tolua_ret = (unsigned int) self->count(); + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'count'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_Cocos2d_CCArray_capacity00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Array* self = (Array*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'capacity'", NULL); +#endif + { + unsigned int tolua_ret = (unsigned int) self->capacity(); + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'capacity'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_Cocos2d_CCArray_indexOfObject00(lua_State* tolua_S) +{ + deprecatedClassTip("CCArray"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || + !tolua_isusertype(tolua_S,2,"Object",0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Array* self = (Array*) tolua_tousertype(tolua_S,1,0); + Object* object = ((Object*) tolua_tousertype(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'indexOfObject'", NULL); +#endif + { + unsigned int tolua_ret = (unsigned int) self->getIndexOfObject(object); + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'indexOfObject'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_Cocos2d_CCArray_objectAtIndex00(lua_State* tolua_S) +{ + deprecatedClassTip("CCArray"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Array* self = (Array*) tolua_tousertype(tolua_S,1,0); + unsigned int index = ((unsigned int) tolua_tonumber(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'objectAtIndex'", NULL); +#endif + { + Object* tolua_ret = (Object*) self->getObjectAtIndex(index); + int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; + int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; + toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"Object"); + } + } + return 1; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'objectAtIndex'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_Cocos2d_CCArray_lastObject00(lua_State* tolua_S) +{ + deprecatedClassTip("CCArray"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Array* self = (Array*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'lastObject'", NULL); +#endif + { + Object* tolua_ret = (Object*) self->getLastObject(); + int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; + int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; + toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"Object"); + } + } + return 1; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lastObject'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_Cocos2d_CCArray_randomObject00(lua_State* tolua_S) +{ + deprecatedClassTip("CCArray"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Array* self = (Array*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'randomObject'", NULL); +#endif + { + Object* tolua_ret = (Object*) self->getRandomObject(); + int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; + int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; + toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"Object"); + } + } + return 1; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'randomObject'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_Cocos2d_CCArray_isEqualToArray00(lua_State* tolua_S) +{ + deprecatedClassTip("CCArray"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || + !tolua_isusertype(tolua_S,2,"CCArray",0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Array* self = (Array*) tolua_tousertype(tolua_S,1,0); + Array* pOtherArray = ((Array*) tolua_tousertype(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isEqualToArray'", NULL); +#endif + { + bool tolua_ret = (bool) self->isEqualToArray(pOtherArray); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'isEqualToArray'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_Cocos2d_CCArray_containsObject00(lua_State* tolua_S) +{ + deprecatedClassTip("CCArray"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || + !tolua_isusertype(tolua_S,2,"Object",0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Array* self = (Array*) tolua_tousertype(tolua_S,1,0); + Object* object = ((Object*) tolua_tousertype(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'containsObject'", NULL); +#endif + { + bool tolua_ret = (bool) self->containsObject(object); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'containsObject'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_Cocos2d_CCArray_addObject00(lua_State* tolua_S) +{ + deprecatedClassTip("CCArray"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || + !tolua_isusertype(tolua_S,2,"Object",0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Array* self = (Array*) tolua_tousertype(tolua_S,1,0); + Object* object = ((Object*) tolua_tousertype(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addObject'", NULL); +#endif + { + self->addObject(object); + } + } + return 0; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'addObject'.",&tolua_err); + return 0; +#endif +} + +static int tolua_Cocos2d_CCArray_addObjectsFromArray00(lua_State* tolua_S) +{ + deprecatedClassTip("CCArray"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || + !tolua_isusertype(tolua_S,2,"CCArray",0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Array* self = (Array*) tolua_tousertype(tolua_S,1,0); + Array* otherArray = ((Array*) tolua_tousertype(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addObjectsFromArray'", NULL); +#endif + { + self->addObjectsFromArray(otherArray); + } + } + return 0; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'addObjectsFromArray'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_Cocos2d_CCArray_insertObject00(lua_State* tolua_S) +{ + deprecatedClassTip("CCArray"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || + !tolua_isusertype(tolua_S,2,"Object",0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnoobj(tolua_S,4,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Array* self = (Array*) tolua_tousertype(tolua_S,1,0); + Object* object = ((Object*) tolua_tousertype(tolua_S,2,0)); + unsigned int index = ((unsigned int) tolua_tonumber(tolua_S,3,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'insertObject'", NULL); +#endif + { + self->insertObject(object,index); + } + } + return 0; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'insertObject'.",&tolua_err); + return 0; +#endif +} + +static int tolua_Cocos2d_CCArray_removeLastObject00(lua_State* tolua_S) +{ + deprecatedClassTip("CCArray"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || + !tolua_isboolean(tolua_S,2,1,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Array* self = (Array*) tolua_tousertype(tolua_S,1,0); + bool bReleaseObj = ((bool) tolua_toboolean(tolua_S,2,true)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeLastObject'", NULL); +#endif + { + self->removeLastObject(bReleaseObj); + } + } + return 0; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'removeLastObject'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_Cocos2d_CCArray_removeObject00(lua_State* tolua_S) +{ + deprecatedClassTip("CCArray"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || + !tolua_isusertype(tolua_S,2,"Object",0,&tolua_err) || + !tolua_isboolean(tolua_S,3,1,&tolua_err) || + !tolua_isnoobj(tolua_S,4,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Array* self = (Array*) tolua_tousertype(tolua_S,1,0); + Object* object = ((Object*) tolua_tousertype(tolua_S,2,0)); + bool bReleaseObj = ((bool) tolua_toboolean(tolua_S,3,true)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeObject'", NULL); +#endif + { + self->removeObject(object,bReleaseObj); + } + } + return 0; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'removeObject'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_Cocos2d_CCArray_removeObjectAtIndex00(lua_State* tolua_S) +{ + deprecatedClassTip("CCArray"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isboolean(tolua_S,3,1,&tolua_err) || + !tolua_isnoobj(tolua_S,4,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Array* self = (Array*) tolua_tousertype(tolua_S,1,0); + unsigned int index = ((unsigned int) tolua_tonumber(tolua_S,2,0)); + bool bReleaseObj = ((bool) tolua_toboolean(tolua_S,3,true)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeObjectAtIndex'", NULL); +#endif + { + self->removeObjectAtIndex(index,bReleaseObj); + } + } + return 0; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'removeObjectAtIndex'.",&tolua_err); + return 0; +#endif +} + +static int tolua_Cocos2d_CCArray_removeObjectsInArray00(lua_State* tolua_S) +{ + deprecatedClassTip("CCArray"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || + !tolua_isusertype(tolua_S,2,"CCArray",0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Array* self = (Array*) tolua_tousertype(tolua_S,1,0); + Array* otherArray = ((Array*) tolua_tousertype(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeObjectsInArray'", NULL); +#endif + { + self->removeObjectsInArray(otherArray); + } + } + return 0; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'removeObjectsInArray'.",&tolua_err); + return 0; +#endif +} + +static int tolua_Cocos2d_CCArray_removeAllObjects00(lua_State* tolua_S) +{ + deprecatedClassTip("CCArray"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Array* self = (Array*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeAllObjects'", NULL); +#endif + { + self->removeAllObjects(); + } + } + return 0; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'removeAllObjects'.",&tolua_err); + return 0; +#endif +} + +static int tolua_Cocos2d_CCArray_fastRemoveObject00(lua_State* tolua_S) +{ + deprecatedClassTip("CCArray"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || + !tolua_isusertype(tolua_S,2,"Object",0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Array* self = (Array*) tolua_tousertype(tolua_S,1,0); + Object* object = ((Object*) tolua_tousertype(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'fastRemoveObject'", NULL); +#endif + { + self->fastRemoveObject(object); + } + } + return 0; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'fastRemoveObject'.",&tolua_err); + return 0; +#endif +} + +static int tolua_Cocos2d_CCArray_fastRemoveObjectAtIndex00(lua_State* tolua_S) +{ + deprecatedClassTip("CCArray"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Array* self = (Array*) tolua_tousertype(tolua_S,1,0); + unsigned int index = ((unsigned int) tolua_tonumber(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'fastRemoveObjectAtIndex'", NULL); +#endif + { + self->fastRemoveObjectAtIndex(index); + } + } + return 0; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'fastRemoveObjectAtIndex'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_Cocos2d_CCArray_exchangeObject00(lua_State* tolua_S) +{ + deprecatedClassTip("CCArray"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || + !tolua_isusertype(tolua_S,2,"Object",0,&tolua_err) || + !tolua_isusertype(tolua_S,3,"Object",0,&tolua_err) || + !tolua_isnoobj(tolua_S,4,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Array* self = (Array*) tolua_tousertype(tolua_S,1,0); + Object* object1 = ((Object*) tolua_tousertype(tolua_S,2,0)); + Object* object2 = ((Object*) tolua_tousertype(tolua_S,3,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'exchangeObject'", NULL); +#endif + { + self->exchangeObject(object1,object2); + } + } + return 0; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'exchangeObject'.",&tolua_err); + return 0; +#endif +} + +static int tolua_Cocos2d_CCArray_exchangeObjectAtIndex00(lua_State* tolua_S) +{ + deprecatedClassTip("CCArray"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnoobj(tolua_S,4,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Array* self = (Array*) tolua_tousertype(tolua_S,1,0); + unsigned int index1 = ((unsigned int) tolua_tonumber(tolua_S,2,0)); + unsigned int index2 = ((unsigned int) tolua_tonumber(tolua_S,3,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'exchangeObjectAtIndex'", NULL); +#endif + { + self->exchangeObjectAtIndex(index1,index2); + } + } + return 0; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'exchangeObjectAtIndex'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_Cocos2d_CCArray_reverseObjects00(lua_State* tolua_S) +{ + deprecatedClassTip("CCArray"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Array* self = (Array*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'reverseObjects'", NULL); +#endif + { + self->reverseObjects(); + } + } + return 0; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'reverseObjects'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_Cocos2d_CCArray_reduceMemoryFootprint00(lua_State* tolua_S) +{ + deprecatedClassTip("CCArray"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Array* self = (Array*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'reduceMemoryFootprint'", NULL); +#endif + { + self->reduceMemoryFootprint(); + } + } + return 0; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'reduceMemoryFootprint'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_Cocos2d_CCArray_replaceObjectAtIndex00(lua_State* tolua_S) +{ + deprecatedClassTip("CCArray"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isusertype(tolua_S,3,"Object",0,&tolua_err) || + !tolua_isboolean(tolua_S,4,1,&tolua_err) || + !tolua_isnoobj(tolua_S,5,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Array* self = (Array*) tolua_tousertype(tolua_S,1,0); + unsigned int uIndex = ((unsigned int) tolua_tonumber(tolua_S,2,0)); + Object* pObject = ((Object*) tolua_tousertype(tolua_S,3,0)); + bool bReleaseObject = ((bool) tolua_toboolean(tolua_S,4,true)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'replaceObjectAtIndex'", NULL); +#endif + { + self->replaceObjectAtIndex(uIndex,pObject,bReleaseObject); + } + } + return 0; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'replaceObjectAtIndex'.",&tolua_err); + return 0; +#endif +} + +static int register_cocos2dx_deprecated_Array(lua_State* tolua_S) +{ + tolua_usertype(tolua_S, "CCArray"); + + tolua_cclass(tolua_S,"CCArray","CCArray","CCObject",NULL); + tolua_beginmodule(tolua_S,"CCArray"); + tolua_function(tolua_S,"create",tolua_Cocos2d_CCArray_create00); + tolua_function(tolua_S,"createWithObject",tolua_Cocos2d_CCArray_createWithObject00); + tolua_function(tolua_S,"createWithArray",tolua_Cocos2d_CCArray_createWithArray00); + tolua_function(tolua_S,"createWithCapacity",tolua_Cocos2d_CCArray_createWithCapacity00); + tolua_function(tolua_S,"createWithContentsOfFile",tolua_Cocos2d_CCArray_createWithContentsOfFile00); + tolua_function(tolua_S,"count",tolua_Cocos2d_CCArray_count00); + tolua_function(tolua_S,"capacity",tolua_Cocos2d_CCArray_capacity00); + tolua_function(tolua_S,"indexOfObject",tolua_Cocos2d_CCArray_indexOfObject00); + tolua_function(tolua_S,"objectAtIndex",tolua_Cocos2d_CCArray_objectAtIndex00); + tolua_function(tolua_S,"lastObject",tolua_Cocos2d_CCArray_lastObject00); + tolua_function(tolua_S,"randomObject",tolua_Cocos2d_CCArray_randomObject00); + tolua_function(tolua_S,"isEqualToArray",tolua_Cocos2d_CCArray_isEqualToArray00); + tolua_function(tolua_S,"containsObject",tolua_Cocos2d_CCArray_containsObject00); + tolua_function(tolua_S,"addObject",tolua_Cocos2d_CCArray_addObject00); + tolua_function(tolua_S,"addObjectsFromArray",tolua_Cocos2d_CCArray_addObjectsFromArray00); + tolua_function(tolua_S,"insertObject",tolua_Cocos2d_CCArray_insertObject00); + tolua_function(tolua_S,"removeLastObject",tolua_Cocos2d_CCArray_removeLastObject00); + tolua_function(tolua_S,"removeObject",tolua_Cocos2d_CCArray_removeObject00); + tolua_function(tolua_S,"removeObjectAtIndex",tolua_Cocos2d_CCArray_removeObjectAtIndex00); + tolua_function(tolua_S,"removeObjectsInArray",tolua_Cocos2d_CCArray_removeObjectsInArray00); + tolua_function(tolua_S,"removeAllObjects",tolua_Cocos2d_CCArray_removeAllObjects00); + tolua_function(tolua_S,"fastRemoveObject",tolua_Cocos2d_CCArray_fastRemoveObject00); + tolua_function(tolua_S,"fastRemoveObjectAtIndex",tolua_Cocos2d_CCArray_fastRemoveObjectAtIndex00); + tolua_function(tolua_S,"exchangeObject",tolua_Cocos2d_CCArray_exchangeObject00); + tolua_function(tolua_S,"exchangeObjectAtIndex",tolua_Cocos2d_CCArray_exchangeObjectAtIndex00); + tolua_function(tolua_S,"reverseObjects",tolua_Cocos2d_CCArray_reverseObjects00); + tolua_function(tolua_S,"reduceMemoryFootprint",tolua_Cocos2d_CCArray_reduceMemoryFootprint00); + tolua_function(tolua_S,"replaceObjectAtIndex",tolua_Cocos2d_CCArray_replaceObjectAtIndex00); + tolua_endmodule(tolua_S); + + return 1; +} + +static int tolua_cocos2d_kmGLPushMatrix00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isnoobj(tolua_S,1,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + kmGLPushMatrix(); + } + return 0; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'kmGLPushMatrix'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2d_kmGLTranslatef00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isnumber(tolua_S,1,0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnoobj(tolua_S,4,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + float x = ((float) tolua_tonumber(tolua_S,1,0)); + float y = ((float) tolua_tonumber(tolua_S,2,0)); + float z = ((float) tolua_tonumber(tolua_S,3,0)); + { + kmGLTranslatef(x,y,z); + } + } + return 0; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'kmGLTranslatef'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2d_kmGLPopMatrix00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isnoobj(tolua_S,1,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + { + kmGLPopMatrix(); + } + } + return 0; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'kmGLPopMatrix'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_Cocos2d_CCString_intValue00(lua_State* tolua_S) +{ + deprecatedClassTip("CCString"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const CCString",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const String* self = (const String*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'intValue'", NULL); +#endif + { + int tolua_ret = (int) self->intValue(); + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'intValue'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_Cocos2d_CCString_uintValue00(lua_State* tolua_S) +{ + deprecatedClassTip("CCString"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const CCString",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const String* self = (const String*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'uintValue'", NULL); +#endif + { + unsigned int tolua_ret = (unsigned int) self->uintValue(); + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'uintValue'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_Cocos2d_CCString_floatValue00(lua_State* tolua_S) +{ + deprecatedClassTip("CCString"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const CCString",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const String* self = (const String*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'floatValue'", NULL); +#endif + { + float tolua_ret = (float) self->floatValue(); + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'floatValue'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_Cocos2d_CCString_doubleValue00(lua_State* tolua_S) +{ + deprecatedClassTip("CCString"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const CCString",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const String* self = (const String*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'doubleValue'", NULL); +#endif + { + double tolua_ret = (double) self->doubleValue(); + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'doubleValue'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_Cocos2d_CCString_boolValue00(lua_State* tolua_S) +{ + deprecatedClassTip("CCString"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const CCString",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const String* self = (const String*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'boolValue'", NULL); +#endif + { + bool tolua_ret = (bool) self->boolValue(); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'boolValue'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_Cocos2d_CCString_getCString00(lua_State* tolua_S) +{ + deprecatedClassTip("CCString"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const CCString",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const String* self = (const String*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCString'", NULL); +#endif + { + const char* tolua_ret = (const char*) self->getCString(); + tolua_pushstring(tolua_S,(const char*)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'getCString'.",&tolua_err); + return 0; +#endif +} + + + +static int tolua_Cocos2d_CCString_length00(lua_State* tolua_S) +{ + deprecatedClassTip("CCString"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const CCString",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const String* self = (const String*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'length'", NULL); +#endif + { + unsigned int tolua_ret = (unsigned int) self->length(); + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'length'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_Cocos2d_CCString_compare00(lua_State* tolua_S) +{ + deprecatedClassTip("CCString"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const CCString",0,&tolua_err) || + !tolua_isstring(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const String* self = (const String*) tolua_tousertype(tolua_S,1,0); + const char* str = ((const char*) tolua_tostring(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'compare'", NULL); +#endif + { + int tolua_ret = (int) self->compare(str); + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'compare'.",&tolua_err); + return 0; +#endif +} + + + +static int tolua_Cocos2d_CCString_isEqual00(lua_State* tolua_S) +{ + deprecatedClassTip("CCString"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"CCString",0,&tolua_err) || + !tolua_isusertype(tolua_S,2,"const CCObject",0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + String* self = (String*) tolua_tousertype(tolua_S,1,0); + const Object* pObject = ((const Object*) tolua_tousertype(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isEqual'", NULL); +#endif + { + bool tolua_ret = (bool) self->isEqual(pObject); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'isEqual'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_Cocos2d_CCString_create00(lua_State* tolua_S) +{ + deprecatedClassTip("CCString"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"CCString",0,&tolua_err) || + !tolua_isstring(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const char* pStr = ((const char*) tolua_tostring(tolua_S,2,0)); + { + String* tolua_ret = (String*) String::create(pStr); + int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; + int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; + toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"CCString"); + } + } + return 1; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_Cocos2d_CCString_createWithData00(lua_State* tolua_S) +{ + deprecatedClassTip("CCString"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"CCString",0,&tolua_err) || + !tolua_isstring(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnoobj(tolua_S,4,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + unsigned char* pData = ((unsigned char*) tolua_tostring(tolua_S,2,0)); + unsigned long nLen = ((unsigned long) tolua_tonumber(tolua_S,3,0)); + { + String* tolua_ret = (String*) String::createWithData(pData,nLen); + int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; + int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; + toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"CCString"); + } + } + return 1; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'createWithData'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_Cocos2d_CCString_createWithContentsOfFile00(lua_State* tolua_S) +{ + deprecatedClassTip("CCString"); + +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"CCString",0,&tolua_err) || + !tolua_isstring(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const char* pszFileName = ((const char*) tolua_tostring(tolua_S,2,0)); + { + String* tolua_ret = (String*) String::createWithContentsOfFile(pszFileName); + int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; + int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; + toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"CCString"); + } + } + return 1; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'createWithContentsOfFile'.",&tolua_err); + return 0; +#endif +} + +static int register_cocos2dx_deprecated_String(lua_State* tolua_S) +{ + tolua_usertype(tolua_S, "CCString"); + tolua_cclass(tolua_S,"CCString","CCString","Object",NULL); + tolua_beginmodule(tolua_S,"CCString"); + tolua_function(tolua_S,"intValue",tolua_Cocos2d_CCString_intValue00); + tolua_function(tolua_S,"uintValue",tolua_Cocos2d_CCString_uintValue00); + tolua_function(tolua_S,"floatValue",tolua_Cocos2d_CCString_floatValue00); + tolua_function(tolua_S,"doubleValue",tolua_Cocos2d_CCString_doubleValue00); + tolua_function(tolua_S,"boolValue",tolua_Cocos2d_CCString_boolValue00); + tolua_function(tolua_S,"getCString",tolua_Cocos2d_CCString_getCString00); + tolua_function(tolua_S,"length",tolua_Cocos2d_CCString_length00); + tolua_function(tolua_S,"compare",tolua_Cocos2d_CCString_compare00); + tolua_function(tolua_S,"isEqual",tolua_Cocos2d_CCString_isEqual00); + tolua_function(tolua_S,"create",tolua_Cocos2d_CCString_create00); + tolua_function(tolua_S,"createWithData",tolua_Cocos2d_CCString_createWithData00); + tolua_function(tolua_S,"createWithContentsOfFile",tolua_Cocos2d_CCString_createWithContentsOfFile00); + tolua_endmodule(tolua_S); + return 1; +} + + +int register_all_cocos2dx_deprecated(lua_State* tolua_S) +{ + tolua_open(tolua_S); + + tolua_module(tolua_S,NULL,0); + tolua_beginmodule(tolua_S,NULL); + register_cocos2dx_deprecated_Point(tolua_S); + register_cocos2dx_deprecated_Rect(tolua_S); + register_cocos2dx_deprecated_Size(tolua_S); + register_cocos2dx_deprecated_Array(tolua_S); + register_cocos2dx_deprecated_String(tolua_S); + tolua_function(tolua_S,"kmGLPushMatrix",tolua_cocos2d_kmGLPushMatrix00); + tolua_function(tolua_S,"kmGLTranslatef",tolua_cocos2d_kmGLTranslatef00); + tolua_function(tolua_S,"kmGLPopMatrix",tolua_cocos2d_kmGLPopMatrix00); + tolua_endmodule(tolua_S); + + return 0; +} + +extern int lua_cocos2dx_Animation_createWithSpriteFrames(lua_State* tolua_S); + +static int tolua_cocos2d_Animation_createWithSpriteFrames_deprecated00(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"Animation",0,&tolua_err) || + !tolua_isusertype(tolua_S,2,"CCArray",0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnoobj(tolua_S,4,&tolua_err) + ) + goto tolua_lerror; + else + { + Array* arrayOfSpriteFrameNames = ((Array*) tolua_tousertype(tolua_S,2,0)); + float delay = ((float) tolua_tonumber(tolua_S,3,0)); + { + cocos2d::Animation* tolua_ret = (cocos2d::Animation*) cocos2d::Animation::createWithSpriteFrames(arrayOfSpriteFrameNames,delay); + int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; + int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; + toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"Animation"); + } + } + return 1; +tolua_lerror: + return lua_cocos2dx_Animation_createWithSpriteFrames(tolua_S); +} + +static int tolua_cocos2d_Animation_createWithSpriteFrames_deprecated01(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"Animation",0,&tolua_err) || + !tolua_isusertype(tolua_S,2,"CCArray",0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else + { + Array* arrayOfSpriteFrameNames = ((Array*) tolua_tousertype(tolua_S,2,0)); + { + cocos2d::Animation* tolua_ret = (cocos2d::Animation*) cocos2d::Animation::createWithSpriteFrames(arrayOfSpriteFrameNames); + int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; + int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; + toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"Animation"); + } + } + return 1; +tolua_lerror: + return tolua_cocos2d_Animation_createWithSpriteFrames_deprecated00(tolua_S); +} + +static void extendAnimationDeprecated(lua_State* tolua_S) +{ + lua_pushstring(tolua_S,"Animation"); + lua_rawget(tolua_S,LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"createWithSpriteFrames"); + lua_pushcfunction(tolua_S,tolua_cocos2d_Animation_createWithSpriteFrames_deprecated00); + lua_rawset(tolua_S,-3); + lua_pushstring(tolua_S,"createWithSpriteFrames"); + lua_pushcfunction(tolua_S,tolua_cocos2d_Animation_createWithSpriteFrames_deprecated01); + lua_rawset(tolua_S,-3); + } +} + +static int tolua_cocos2d_Sequence_createWithTwoActions(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"Sequence",0,&tolua_err) || + !tolua_isusertype(tolua_S,2,"FiniteTimeAction",0,&tolua_err) || + !tolua_isusertype(tolua_S,3,"FiniteTimeAction",0,&tolua_err) || + !tolua_isnoobj(tolua_S,4,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + FiniteTimeAction* pActionOne = ((FiniteTimeAction*) tolua_tousertype(tolua_S,2,0)); + FiniteTimeAction* pActionTwo = ((FiniteTimeAction*) tolua_tousertype(tolua_S,3,0)); + { + Sequence* tolua_ret = (Sequence*) Sequence::createWithTwoActions(pActionOne,pActionTwo); + int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; + int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; + toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"Sequence"); + } + } + return 1; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'createWithTwoActions'.",&tolua_err); + return 0; +#endif +} + +extern int tolua_cocos2d_Sequence_create(lua_State* tolua_S); +static int tolua_Cocos2d_Sequence_create_deprecated00(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"Sequence",0,&tolua_err) || + !tolua_isusertype(tolua_S,2,"CCArray",0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else + { + Array* actions = ((Array*) tolua_tousertype(tolua_S,2,0)); + { + Sequence* tolua_ret = (Sequence*) Sequence::create(actions); + int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; + int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; + toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"Sequence"); + } + } + return 1; +tolua_lerror: + return tolua_cocos2d_Sequence_create(tolua_S); +} + +static int extendSequenceDeprecated(lua_State* tolua_S) +{ + lua_pushstring(tolua_S,"Sequence"); + lua_rawget(tolua_S,LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + tolua_function(tolua_S, "createWithTwoActions",tolua_cocos2d_Sequence_createWithTwoActions); + tolua_function(tolua_S, "create", tolua_Cocos2d_Sequence_create_deprecated00); + } + + return 1; +} + +#ifdef __cplusplus +extern "C" { +#endif +extern int tolua_bnd_cast(lua_State* tolua_S); +#ifdef __cplusplus +} +#endif + +static int tolua_bnd_cast_deprecated00(lua_State* tolua_S) +{ + void* v = nullptr; + std::string strValue = ""; + strValue = tolua_tostring(tolua_S,2,NULL); + int pos = strValue.find("CC"); + if (pos == 0 && + std::string::npos == strValue.find("CCBAnimationManager") && + std::string::npos == strValue.find("CCString") && + std::string::npos == strValue.find("CCPoint") && + std::string::npos == strValue.find("CCRect") && + std::string::npos == strValue.find("CCSize") && + std::string::npos == strValue.find("CCArray")) + { + strValue = strValue.substr(2); + if (lua_islightuserdata(tolua_S, 1)) { + v = tolua_touserdata(tolua_S, 1, NULL); + } else { + v = tolua_tousertype(tolua_S, 1, 0); + }; + if (v && !strValue.empty()) + tolua_pushusertype(tolua_S,v,strValue.c_str()); + else + lua_pushnil(tolua_S); + return 1; + } + else + { + return tolua_bnd_cast(tolua_S); + } +} + +static int extendToluaDeprecated(lua_State* tolua_S) +{ + lua_getglobal(tolua_S, "_G"); + if (lua_istable(tolua_S,-1))//stack:...,_G, + { + lua_pushstring(tolua_S,"tolua");//stack:_G,keyValue + lua_gettable(tolua_S, -2);//stack:_G,toluaModule + if (lua_istable(tolua_S,-1)) + { + tolua_function(tolua_S, "cast", tolua_bnd_cast_deprecated00); + } + lua_pop(tolua_S, 1);//statck:_G + } + lua_pop(tolua_S, 1);//statck:... + + return 1; +} + +static int tolua_cocos2d_Spawn_createWithTwoActions_deprcated00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"Spawn",0,&tolua_err) || + !tolua_isusertype(tolua_S,2,"FiniteTimeAction",0,&tolua_err) || + !tolua_isusertype(tolua_S,3,"FiniteTimeAction",0,&tolua_err) || + !tolua_isnoobj(tolua_S,4,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + FiniteTimeAction* pAction1 = ((FiniteTimeAction*) tolua_tousertype(tolua_S,2,0)); + FiniteTimeAction* pAction2 = ((FiniteTimeAction*) tolua_tousertype(tolua_S,3,0)); + { + Spawn* tolua_ret = (Spawn*) Spawn::createWithTwoActions(pAction1,pAction2); + int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; + int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; + toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"Spawn"); + } + } + return 1; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'createWithTwoActions'.",&tolua_err); + return 0; +#endif +} + +static int extendSpawnDeprecated(lua_State* tolua_S) +{ + lua_pushstring(tolua_S,"Spawn"); + lua_rawget(tolua_S,LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + tolua_function(tolua_S, "createWithTwoActions", tolua_cocos2d_Spawn_createWithTwoActions_deprcated00); + } + + return 1; +} + + +static int tolua_cocos2d_Menu_createWithArray00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"Menu",0,&tolua_err) || + !tolua_isusertype(tolua_S,2,"CCArray",0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Array* pArrayOfItems = ((Array*) tolua_tousertype(tolua_S,2,0)); + { + Menu* tolua_ret = (Menu*) Menu::createWithArray(pArrayOfItems); + int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; + int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; + toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"Menu"); + } + } + return 1; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'createWithArray'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2d_Menu_alignItemsInColumnsWithArray00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"Menu",0,&tolua_err) || + !tolua_isusertype(tolua_S,2,"CCArray",0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Menu* self = (Menu*) tolua_tousertype(tolua_S,1,0); + Array* rows = ((Array*) tolua_tousertype(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'alignItemsInColumnsWithArray'", NULL); +#endif + { + self->alignItemsInColumnsWithArray(rows); + } + } + return 0; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'alignItemsInColumnsWithArray'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_cocos2d_Menu_alignItemsInRowsWithArray00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"Menu",0,&tolua_err) || + !tolua_isusertype(tolua_S,2,"CCArray",0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Menu* self = (Menu*) tolua_tousertype(tolua_S,1,0); + Array* columns = ((Array*) tolua_tousertype(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'alignItemsInRowsWithArray'", NULL); +#endif + { + self->alignItemsInRowsWithArray(columns); + } + } + return 0; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'alignItemsInRowsWithArray'.",&tolua_err); + return 0; +#endif +} + +static int extendMenuDeprecated(lua_State* tolua_S) +{ + lua_pushstring(tolua_S,"Menu"); + lua_rawget(tolua_S,LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + tolua_function(tolua_S, "createWithArray", tolua_cocos2d_Menu_createWithArray00); + tolua_function(tolua_S, "alignItemsInColumnsWithArray", tolua_cocos2d_Menu_alignItemsInColumnsWithArray00); + tolua_function(tolua_S, "alignItemsInRowsWithArray", tolua_cocos2d_Menu_alignItemsInRowsWithArray00); + } + + return 1; +} + +static int tolua_cocos2d_LayerMultiplex_createWithArray00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"LayerMultiplex",0,&tolua_err) || + !tolua_isusertype(tolua_S,2,"CCArray",0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Array* arrayOfLayers = ((Array*) tolua_tousertype(tolua_S,2,0)); + { + LayerMultiplex* tolua_ret = (LayerMultiplex*) LayerMultiplex::createWithArray(arrayOfLayers); + int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; + int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; + toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"LayerMultiplex"); + } + } + return 1; +#ifndef TOLUA_RELEASE +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'createWithArray'.",&tolua_err); + return 0; +#endif +} + +static int extendLayerMultiplexDeprecated(lua_State* tolua_S) +{ + lua_pushstring(tolua_S,"LayerMultiplex"); + lua_rawget(tolua_S,LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + tolua_function(tolua_S, "createWithArray", tolua_cocos2d_LayerMultiplex_createWithArray00); + } + return 1; +} + + +int register_all_cocos2dx_manual_deprecated(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + extendAnimationDeprecated(tolua_S); + extendSequenceDeprecated(tolua_S); + extendToluaDeprecated(tolua_S); + extendMenuDeprecated(tolua_S); + extendLayerMultiplexDeprecated(tolua_S); + return 0; +} diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_deprecated.cpp.REMOVED.git-id b/cocos/scripting/lua/bindings/lua_cocos2dx_deprecated.cpp.REMOVED.git-id deleted file mode 100644 index 1307b885c9..0000000000 --- a/cocos/scripting/lua/bindings/lua_cocos2dx_deprecated.cpp.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -e70a68a07977b12b3f233641ac8d558e48c5517c \ No newline at end of file diff --git a/cocos/scripting/lua/script/CCBReaderLoad.lua b/cocos/scripting/lua/script/CCBReaderLoad.lua index 6acfe432fa..733a432317 100644 --- a/cocos/scripting/lua/script/CCBReaderLoad.lua +++ b/cocos/scripting/lua/script/CCBReaderLoad.lua @@ -112,3 +112,10 @@ function CCBReaderLoad(strFilePath,proxy,owner) return node end + + +local function CCBuilderReaderLoad(strFilePath,proxy,owner) + print("\n********** \n".."CCBuilderReaderLoad(strFilePath,proxy,owner)".." was deprecated please use ".. "CCBReaderLoad(strFilePath,proxy,owner)" .. " instead.\n**********") + return CCBReaderLoad(strFilePath,proxy,owner) +end +rawset(_G,"CCBuilderReaderLoad",CCBuilderReaderLoad) \ No newline at end of file diff --git a/cocos/scripting/lua/script/Deprecated.lua b/cocos/scripting/lua/script/Deprecated.lua index 935a07514f..83d7b07989 100644 --- a/cocos/scripting/lua/script/Deprecated.lua +++ b/cocos/scripting/lua/script/Deprecated.lua @@ -725,24 +725,6 @@ local function tex2(u,v) end rawset(_G,"tex2",tex2) -local function CCPoint( x, y) - deprecatedTip("CCPoint(x,y)","cc.p(x,y)") - return cc.p(x,y) -end -rawset(_G,"CCPoint",CCPoint) - -local function CCSize( width, height) - deprecatedTip("CCSize(width,height)","cc.size(width,height)") - return cc.size(width,height) -end -rawset(_G,"CCSize",CCSize) - -local function CCRect( x,y, width, height) - deprecatedTip("CCRect(x,y,width,height)","cc.rect(x,y,width,height)") - return cc.rect(x,y,width,height) -end -rawset(_G,"CCRect",CCRect) - --functions of CCControl will be deprecated end local CCControlDeprecated = { } function CCControlDeprecated.addHandleOfControlEvent(self,func,controlEvent) @@ -1160,4 +1142,26 @@ end rawset(ActionManager,"purgeActionManager",ActionManagerDeprecated.purgeActionManager) --functions of ActionManager will be deprecated end +--functions of CCEGLView will be deprecated begin +local CCEGLViewDeprecated = { } +function CCEGLViewDeprecated.sharedOpenGLView() + deprecatedTip("CCEGLView:sharedOpenGLView","cc.EGLView:getInstance") + return cc.EGLView:getInstance() +end +rawset(CCEGLView,"sharedOpenGLView",CCEGLViewDeprecated.sharedOpenGLView) +--functions of CCEGLView will be deprecated end + +--Enums of CCTableView will be deprecated begin +rawset(CCTableView, "kTableViewScroll",cc.SCROLLVIEW_SCRIPT_SCROLL) +rawset(CCTableView,"kTableViewZoom",cc.SCROLLVIEW_SCRIPT_ZOOM) +rawset(CCTableView,"kTableCellTouched",cc.TABLECELL_TOUCHED) +rawset(CCTableView,"kTableCellSizeForIndex",cc.TABLECELL_SIZE_FOR_INDEX) +rawset(CCTableView,"kTableCellSizeAtIndex",cc.TABLECELL_SIZE_AT_INDEX) +rawset(CCTableView,"kNumberOfCellsInTableView",cc.NUMBER_OF_CELLS_IN_TABLEVIEW) +--Enums of CCTableView will be deprecated end + +--Enums of CCScrollView will be deprecated begin +rawset(CCScrollView, "kScrollViewScroll",cc.SCROLLVIEW_SCRIPT_SCROLL) +rawset(CCScrollView,"kScrollViewZoom",cc.SCROLLVIEW_SCRIPT_ZOOM) +--Enums of CCScrollView will be deprecated end diff --git a/cocos/scripting/lua/script/DeprecatedClass.lua b/cocos/scripting/lua/script/DeprecatedClass.lua index 15e94b5189..82ffa3446b 100644 --- a/cocos/scripting/lua/script/DeprecatedClass.lua +++ b/cocos/scripting/lua/script/DeprecatedClass.lua @@ -2110,3 +2110,29 @@ function DeprecatedClass.ActionObject() end _G["ActionObject"] = DeprecatedClass.ActionObject() --ActionObject class will be Deprecated,end + +--CCEGLViewProtocol class will be Deprecated,begin +function DeprecatedClass.CCEGLViewProtocol() + deprecatedTip("CCEGLViewProtocol","cc.EGLViewProtocol") + return cc.EGLViewProtocol +end +_G["CCEGLViewProtocol"] = DeprecatedClass.CCEGLViewProtocol() +--CCEGLViewProtocol class will be Deprecated,end + +--CCEGLView class will be Deprecated,begin +function DeprecatedClass.CCEGLView() + deprecatedTip("CCEGLView","cc.EGLView") + return cc.EGLView +end +_G["CCEGLView"] = DeprecatedClass.CCEGLView() +--CCEGLView class will be Deprecated,end + +--CCBProxy class will be Deprecated,begin +function DeprecatedClass.CCBProxy() + deprecatedTip("CCBProxy","cc.CCBProxy") + return cc.CCBProxy +end +_G["CCBProxy"] = DeprecatedClass.CCBProxy() +--CCBProxy class will be Deprecated,end + + diff --git a/cocos/scripting/lua/script/DeprecatedEnum.lua b/cocos/scripting/lua/script/DeprecatedEnum.lua index 03c7619f83..d3bc6738dc 100644 --- a/cocos/scripting/lua/script/DeprecatedEnum.lua +++ b/cocos/scripting/lua/script/DeprecatedEnum.lua @@ -1,5 +1,6 @@ require "Cocos2dConstants.lua" require "OpenglConstants.lua" +require "StudioConstants.lua" --Enums will be deprecated,begin _G.kCCTextAlignmentLeft = cc.TEXT_ALIGNMENT_LEFT _G.kCCTextAlignmentRight = cc.TEXT_ALIGNMENT_RIGHT @@ -479,3 +480,7 @@ _G.LAYOUT_PARAMETER_NONE = ccs.UILayoutParameterType.none _G.LAYOUT_PARAMETER_LINEAR = ccs.UILayoutParameterType.linear _G.LAYOUT_PARAMETER_RELATIVE = ccs.UILayoutParameterType.relative +_G.kCCScrollViewDirectionHorizontal = cc.SCROLLVIEW_DIRECTION_HORIZONTAL +_G.kCCScrollViewDirectionVertical = cc.SCROLLVIEW_DIRECTION_VERTICAL +_G.kCCTableViewFillTopDown = cc.TABLEVIEW_FILL_TOPDOWN +_G.kCCTableViewFillBottomUp = cc.TABLEVIEW_FILL_BOTTOMUP diff --git a/tools/tolua/cocos2dx.ini b/tools/tolua/cocos2dx.ini index 5cdd7c2781..36a6a98ed9 100644 --- a/tools/tolua/cocos2dx.ini +++ b/tools/tolua/cocos2dx.ini @@ -26,7 +26,7 @@ headers = %(cocosdir)s/cocos/2d/cocos2d.h %(cocosdir)s/cocos/audio/include/Simpl # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set Data SimpleAudioEngine Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak ^Object$ UserDefault Image +classes = Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set Data SimpleAudioEngine Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak ^Object$ UserDefault EGLViewProtocol EGLView Image # what should we skip? in the format ClassName::[function function] # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also @@ -50,7 +50,8 @@ skip = Node::[setGLServerState description getUserObject .*UserData getGLServerS MenuItem.*::[create setCallback initWithCallback], Label::[getLettersInfo], Copying::[*], - .*Protocol::[*], + LabelProtocol::[*], + LabelTextFormatProtocol::[*], .*Delegate::[*], PoolManager::[*], Texture2D::[initWithPVRTCData addPVRTCImage releaseData setTexParameters initWithData keepData], @@ -68,7 +69,6 @@ skip = Node::[setGLServerState description getUserObject .*UserData getGLServerS ScriptEngineManager::[*], KeypadHandler::[*], Invocation::[*], - EGLView::[*], SchedulerScriptHandlerEntry::[*], Size::[*], Point::[*], @@ -105,7 +105,9 @@ skip = Node::[setGLServerState description getUserObject .*UserData getGLServerS ccFontDefinition::[*], Object::[autorelease isEqual acceptVisitor update], UserDefault::[getInstance (s|g)etDataForKey], - Label::[getLettersInfo] + Label::[getLettersInfo], + EGLViewProtocol::[setTouchDelegate], + EGLView::[end swapBuffers] rename_functions = SpriteFrameCache::[addSpriteFramesWithFile=addSpriteFrames getSpriteFrameByName=getSpriteFrame], ProgressTimer::[setReverseProgress=setReverseDirection], @@ -136,7 +138,7 @@ base_classes_to_skip = Clonable # classes that create no constructor # Set is special and we will use a hand-written constructor -abstract_classes = Action FiniteTimeAction ActionInterval ActionEase EaseRateAction EaseElastic EaseBounce ActionInstant GridAction Grid3DAction TiledGrid3DAction Director SpriteFrameCache TransitionEaseScene Set SimpleAudioEngine FileUtils Application ClippingNode Label +abstract_classes = Action FiniteTimeAction ActionInterval ActionEase EaseRateAction EaseElastic EaseBounce ActionInstant GridAction Grid3DAction TiledGrid3DAction Director SpriteFrameCache TransitionEaseScene Set SimpleAudioEngine FileUtils Application ClippingNode Label EGLViewProtocol EGLView # Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'. script_control_cpp = no From a354031526f6836c9293e5d3aa00f4681539a9b9 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Wed, 4 Dec 2013 07:47:50 +0000 Subject: [PATCH 30/30] [AUTO] : updating submodule reference to latest autogenerated bindings --- cocos/scripting/auto-generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/scripting/auto-generated b/cocos/scripting/auto-generated index 8b8a881547..567077c985 160000 --- a/cocos/scripting/auto-generated +++ b/cocos/scripting/auto-generated @@ -1 +1 @@ -Subproject commit 8b8a8815474b2dcef3de12161bf7c0621f3c3e05 +Subproject commit 567077c9856e175cc867be4687c089e3a8dc33bc