From 82a64ed2c7e4043df65607b9fc6f17b3fa154bb8 Mon Sep 17 00:00:00 2001 From: Rene Klacan Date: Wed, 5 Jun 2013 20:29:52 +0200 Subject: [PATCH 001/126] tilemap supports XML layer format --- .../tilemap_parallax_nodes/CCTMXXMLParser.cpp | 47 +++++++++++++++---- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp b/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp index 09986b6783..6cdd60e291 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp @@ -404,14 +404,32 @@ void CCTMXMapInfo::startElement(void *ctx, const char *name, const char **atts) } else if (elementName == "tile") { - CCTMXTilesetInfo* info = (CCTMXTilesetInfo*)pTMXMapInfo->getTilesets()->lastObject(); - CCDictionary *dict = new CCDictionary(); - pTMXMapInfo->setParentGID(info->m_uFirstGid + atoi(valueForKey("id", attributeDict))); - pTMXMapInfo->getTileProperties()->setObject(dict, pTMXMapInfo->getParentGID()); - CC_SAFE_RELEASE(dict); - - pTMXMapInfo->setParentElement(TMXPropertyTile); + if (pTMXMapInfo->getParentElement() == TMXPropertyLayer) + { + CCTMXLayerInfo* layer = (CCTMXLayerInfo*)pTMXMapInfo->getLayers()->lastObject(); + CCSize layerSize = layer->m_tLayerSize; + unsigned int gid = (unsigned int)atoi(valueForKey("gid", attributeDict)); + int tilesAmount = layerSize.width*layerSize.height; + for (int i = 0; i < tilesAmount; i++) + { + if (((int *)layer->m_pTiles)[i] == -1) + { + layer->m_pTiles[i] = gid; + break; + } + } + } + else + { + CCTMXTilesetInfo* info = (CCTMXTilesetInfo*)pTMXMapInfo->getTilesets()->lastObject(); + CCDictionary *dict = new CCDictionary(); + pTMXMapInfo->setParentGID(info->m_uFirstGid + atoi(valueForKey("id", attributeDict))); + pTMXMapInfo->getTileProperties()->setObject(dict, pTMXMapInfo->getParentGID()); + CC_SAFE_RELEASE(dict); + + pTMXMapInfo->setParentElement(TMXPropertyTile); + } } else if (elementName == "layer") { @@ -485,7 +503,19 @@ void CCTMXMapInfo::startElement(void *ctx, const char *name, const char **atts) std::string encoding = valueForKey("encoding", attributeDict); std::string compression = valueForKey("compression", attributeDict); - if( encoding == "base64" ) + if (encoding == "") + { + CCTMXLayerInfo* layer = (CCTMXLayerInfo*)pTMXMapInfo->getLayers()->lastObject(); + CCSize layerSize = layer->m_tLayerSize; + int tilesAmount = layerSize.width*layerSize.height; + + int *tiles = (int *) malloc(tilesAmount*sizeof(int)); + for (int i = 0; i < tilesAmount; i++) + tiles[i] = -1; + + layer->m_pTiles = (unsigned int*) tiles; + } + else if (encoding == "base64") { int layerAttribs = pTMXMapInfo->getLayerAttribs(); pTMXMapInfo->setLayerAttribs(layerAttribs | TMXLayerAttribBase64); @@ -503,7 +533,6 @@ void CCTMXMapInfo::startElement(void *ctx, const char *name, const char **atts) } CCAssert( compression == "" || compression == "gzip" || compression == "zlib", "TMX: unsupported compression method" ); } - CCAssert( pTMXMapInfo->getLayerAttribs() != TMXLayerAttribNone, "TMX tile map: Only base64 and/or gzip/zlib maps are supported" ); } else if (elementName == "object") From 6149f52ffd34247a7dd977c791daab2ae2d60643 Mon Sep 17 00:00:00 2001 From: zcgit Date: Thu, 20 Jun 2013 21:27:22 +0800 Subject: [PATCH 002/126] a potential bug in Layer. https://github.com/cocos2d/cocos2d-x/issues/2948 --- cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp index ae5d984085..caa7eec53e 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp @@ -77,7 +77,8 @@ bool Layer::init() Director * pDirector; CC_BREAK_IF(!(pDirector = Director::sharedDirector())); this->setContentSize(pDirector->getWinSize()); - _touchEnabled = false; + //_touchEnabled = false; + setTouchEnabled(false); _accelerometerEnabled = false; // success bRet = true; From c9627abd3d6ff35e2c857f09d0823335cc50f9df Mon Sep 17 00:00:00 2001 From: zcgit Date: Thu, 20 Jun 2013 21:48:27 +0800 Subject: [PATCH 003/126] Update CCLayer.cpp change "_accelerometerEnabled = false" to "setAccelerometerEnabled(false)" in method init(). --- cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp index caa7eec53e..c473b06b1f 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp @@ -77,9 +77,8 @@ bool Layer::init() Director * pDirector; CC_BREAK_IF(!(pDirector = Director::sharedDirector())); this->setContentSize(pDirector->getWinSize()); - //_touchEnabled = false; setTouchEnabled(false); - _accelerometerEnabled = false; + setAccelerometerEnabled(false); // success bRet = true; } while(0); From 912a52a677819be1ae50e898ac9e42a64ce19a7e Mon Sep 17 00:00:00 2001 From: zcgit Date: Fri, 21 Jun 2013 18:00:56 +0800 Subject: [PATCH 004/126] a potential bug in ScrollView check _touches in setTouchEnabled --- extensions/GUI/CCScrollView/CCScrollView.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/GUI/CCScrollView/CCScrollView.cpp b/extensions/GUI/CCScrollView/CCScrollView.cpp index d4144466e1..d56d3e3be5 100644 --- a/extensions/GUI/CCScrollView/CCScrollView.cpp +++ b/extensions/GUI/CCScrollView/CCScrollView.cpp @@ -183,7 +183,7 @@ void ScrollView::setTouchEnabled(bool e) { _dragging = false; _touchMoved = false; - _touches->removeAllObjects(); + if(_touches)_touches->removeAllObjects(); } } From c753f79497716a969d2cd8a766e27891b6b2e2d3 Mon Sep 17 00:00:00 2001 From: Rene Klacan Date: Thu, 4 Jul 2013 13:07:44 +0200 Subject: [PATCH 005/126] added _currentTileIndex member to TMXLayerInfo --- cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp | 14 +++----------- cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.h | 7 ++++--- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp b/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp index f631b8e358..fd717c6b32 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp @@ -72,6 +72,7 @@ TMXLayerInfo::TMXLayerInfo() , _minGID(100000) , _maxGID(0) , _offset(PointZero) +, _currentTileIndex(0) { _properties= new Dictionary();; } @@ -407,18 +408,9 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) if (pTMXMapInfo->getParentElement() == TMXPropertyLayer) { TMXLayerInfo* layer = (TMXLayerInfo*)pTMXMapInfo->getLayers()->lastObject(); - Size layerSize = layer->_layerSize; unsigned int gid = (unsigned int)atoi(valueForKey("gid", attributeDict)); - int tilesAmount = layerSize.width*layerSize.height; - - for (int i = 0; i < tilesAmount; i++) - { - if (((int *)layer->_tiles)[i] == -1) - { - layer->_tiles[i] = gid; - break; - } - } + layer->_tiles[layer->_currentTileIndex] = gid; + layer->_currentTileIndex++; } else { diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.h b/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.h index b6d64c6d01..ea459d6084 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.h +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.h @@ -91,14 +91,15 @@ class CC_DLL TMXLayerInfo : public Object CC_PROPERTY(Dictionary*, _properties, Properties); public: std::string _name; - Size _layerSize; - unsigned int *_tiles; + Size _layerSize; + unsigned int *_tiles; bool _visible; unsigned char _opacity; bool _ownTiles; unsigned int _minGID; unsigned int _maxGID; - Point _offset; + Point _offset; + unsigned int _currentTileIndex; public: TMXLayerInfo(); virtual ~TMXLayerInfo(); From 5d5b962f381cc20dd9b9065c255590acaa2f024d Mon Sep 17 00:00:00 2001 From: Rene Klacan Date: Thu, 4 Jul 2013 13:28:54 +0200 Subject: [PATCH 006/126] removed extra _currentTileIndex --- cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp | 14 ++++++++++---- cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.h | 1 - 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp b/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp index fd717c6b32..cb762ccdd1 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp @@ -72,7 +72,6 @@ TMXLayerInfo::TMXLayerInfo() , _minGID(100000) , _maxGID(0) , _offset(PointZero) -, _currentTileIndex(0) { _properties= new Dictionary();; } @@ -408,9 +407,16 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) if (pTMXMapInfo->getParentElement() == TMXPropertyLayer) { TMXLayerInfo* layer = (TMXLayerInfo*)pTMXMapInfo->getLayers()->lastObject(); + Size layerSize = layer->_layerSize; unsigned int gid = (unsigned int)atoi(valueForKey("gid", attributeDict)); - layer->_tiles[layer->_currentTileIndex] = gid; - layer->_currentTileIndex++; + int tilesAmount = layerSize.width*layerSize.height; + int currentTileIndex = layer->_tiles[tilesAmount - 1]; + layer->_tiles[currentTileIndex] = gid; + + if (currentTileIndex != tilesAmount - 1) + { + layer->_tiles[tilesAmount - 1] = currentTileIndex + 1; + } } else { @@ -503,7 +509,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) int *tiles = (int *) malloc(tilesAmount*sizeof(int)); for (int i = 0; i < tilesAmount; i++) - tiles[i] = -1; + tiles[i] = 0; layer->_tiles = (unsigned int*) tiles; } diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.h b/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.h index ea459d6084..ea5e73c3da 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.h +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.h @@ -99,7 +99,6 @@ public: unsigned int _minGID; unsigned int _maxGID; Point _offset; - unsigned int _currentTileIndex; public: TMXLayerInfo(); virtual ~TMXLayerInfo(); From 3a1d4e7e2843c395f7d22a540d63d381afdacf55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grzegorz=20Kos=CC=81cio=CC=81=C5=82ek?= Date: Fri, 26 Jul 2013 22:20:19 +0200 Subject: [PATCH 007/126] Fix for #2892. 1. Updatet the API documentation and parameter name from "object" to "sender" to reflect it's true purpose. 2. Fixed addObserver and observerExisted because it didn't allowed to add observers to notifications that only differs by sender --- cocos2dx/support/CCNotificationCenter.cpp | 32 +++++++++++------------ cocos2dx/support/CCNotificationCenter.h | 20 +++++++------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/cocos2dx/support/CCNotificationCenter.cpp b/cocos2dx/support/CCNotificationCenter.cpp index c4aca29a6f..0a83775a48 100644 --- a/cocos2dx/support/CCNotificationCenter.cpp +++ b/cocos2dx/support/CCNotificationCenter.cpp @@ -74,7 +74,7 @@ void NotificationCenter::purgeNotificationCenter(void) // // internal functions // -bool NotificationCenter::observerExisted(Object *target,const char *name) +bool NotificationCenter::observerExisted(Object *target,const char *name, Object *sender) { Object* obj = NULL; CCARRAY_FOREACH(_observers, obj) @@ -83,7 +83,7 @@ bool NotificationCenter::observerExisted(Object *target,const char *name) if (!observer) continue; - if (!strcmp(observer->getName(),name) && observer->getTarget() == target) + if (!strcmp(observer->getName(),name) && observer->getTarget() == target && observer->getSender() == sender) return true; } return false; @@ -95,12 +95,12 @@ bool NotificationCenter::observerExisted(Object *target,const char *name) void NotificationCenter::addObserver(Object *target, SEL_CallFuncO selector, const char *name, - Object *obj) + Object *sender) { - if (this->observerExisted(target, name)) + if (this->observerExisted(target, name, sender)) return; - NotificationObserver *observer = new NotificationObserver(target, selector, name, obj); + NotificationObserver *observer = new NotificationObserver(target, selector, name, sender); if (!observer) return; @@ -177,7 +177,7 @@ void NotificationCenter::unregisterScriptObserver(Object *target,const char* nam } } -void NotificationCenter::postNotification(const char *name, Object *object) +void NotificationCenter::postNotification(const char *name, Object *sender) { Array* ObserversCopy = Array::createWithCapacity(_observers->count()); ObserversCopy->addObjectsFromArray(_observers); @@ -188,7 +188,7 @@ void NotificationCenter::postNotification(const char *name, Object *object) if (!observer) continue; - if (!strcmp(name,observer->getName()) && (observer->getObject() == object || observer->getObject() == NULL || object == NULL)) + if (!strcmp(name,observer->getName()) && (observer->getSender() == sender || observer->getSender() == NULL || sender == NULL)) { if (0 != observer->getHandler()) { @@ -198,7 +198,7 @@ void NotificationCenter::postNotification(const char *name, Object *object) } else { - observer->performSelector(object); + observer->performSelector(sender); } } } @@ -241,11 +241,11 @@ int NotificationCenter::getObserverHandlerByName(const char* name) NotificationObserver::NotificationObserver(Object *target, SEL_CallFuncO selector, const char *name, - Object *obj) + Object *sender) { _target = target; _selector = selector; - _object = obj; + _sender = sender; _name = name; _handler = 0; @@ -256,14 +256,14 @@ NotificationObserver::~NotificationObserver() } -void NotificationObserver::performSelector(Object *obj) +void NotificationObserver::performSelector(Object *sender) { if (_target) { - if (obj) { - (_target->*_selector)(obj); + if (sender) { + (_target->*_selector)(sender); } else { - (_target->*_selector)(_object); + (_target->*_selector)(_sender); } } } @@ -283,9 +283,9 @@ const char* NotificationObserver::getName() const return _name.c_str(); } -Object* NotificationObserver::getObject() const +Object* NotificationObserver::getSender() const { - return _object; + return _sender; } int NotificationObserver::getHandler() const diff --git a/cocos2dx/support/CCNotificationCenter.h b/cocos2dx/support/CCNotificationCenter.h index b12a2b3d16..c584d4276d 100644 --- a/cocos2dx/support/CCNotificationCenter.h +++ b/cocos2dx/support/CCNotificationCenter.h @@ -58,12 +58,12 @@ public: * @param target The target which wants to observe notification events. * @param selector The callback function which will be invoked when the specified notification event was posted. * @param name The name of this notification. - * @param obj The extra parameter which will be passed to the callback function. + * @param sender The object whose notifications the target wants to receive. Only notifications sent by this sender are delivered to the target. NULL means that the sender is not used to decide whether to deliver the notification to target. */ void addObserver(Object *target, SEL_CallFuncO selector, const char *name, - Object *obj); + Object *sender); /** @brief Removes the observer by the specified target and name. * @param target The target of this notification. @@ -93,9 +93,9 @@ public: /** @brief Posts one notification event by name. * @param name The name of this notification. - * @param object The extra parameter. + * @param sender The object posting the notification. Can be NULL */ - void postNotification(const char *name, Object *object); + void postNotification(const char *name, Object *sender); /** @brief Gets script handler. * @note Only supports Lua Binding now. @@ -112,7 +112,7 @@ private: // internal functions // Check whether the observer exists by the specified target and name. - bool observerExisted(Object *target,const char *name); + bool observerExisted(Object *target,const char *name, Object *sender); // variables // @@ -127,24 +127,24 @@ public: * @param target The target which wants to observer notification events. * @param selector The callback function which will be invoked when the specified notification event was posted. * @param name The name of this notification. - * @param obj The extra parameter which will be passed to the callback function. + * @param sender The object whose notifications the target wants to receive. Only notifications sent by this sender are delivered to the target. NULL means that the sender is not used to decide whether to deliver the notification to target. */ NotificationObserver(Object *target, SEL_CallFuncO selector, const char *name, - Object *obj); + Object *sender); /** NotificationObserver destructor function */ ~NotificationObserver(); /** Invokes the callback function of this observer */ - void performSelector(Object *obj); + void performSelector(Object *sender); // Getters / Setters Object* getTarget() const; SEL_CallFuncO getSelector() const; const char* getName() const; - Object* getObject() const; + Object* getSender() const; int getHandler() const; void setHandler(int handler); @@ -152,7 +152,7 @@ private: Object* _target; SEL_CallFuncO _selector; std::string _name; - Object* _object; + Object* _sender; int _handler; }; From 2083ab0454d2e488658f3851cbb08fe8236f8701 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grzegorz=20Kos=CC=81cio=CC=81=C5=82ek?= Date: Fri, 26 Jul 2013 22:42:00 +0200 Subject: [PATCH 008/126] Fix for #2892. 3. Fixed registerScriptObserver method. --- cocos2dx/support/CCNotificationCenter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2dx/support/CCNotificationCenter.cpp b/cocos2dx/support/CCNotificationCenter.cpp index 0a83775a48..a7f19d5ff0 100644 --- a/cocos2dx/support/CCNotificationCenter.cpp +++ b/cocos2dx/support/CCNotificationCenter.cpp @@ -149,7 +149,7 @@ int NotificationCenter::removeAllObservers(Object *target) void NotificationCenter::registerScriptObserver( Object *target, int handler,const char* name) { - if (this->observerExisted(target, name)) + if (this->observerExisted(target, name, NULL)) return; NotificationObserver *observer = new NotificationObserver(target, NULL, name, NULL); From 904f85e0a884f63257a65b07323ff606b009e1bb Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 5 Aug 2013 18:30:36 +0800 Subject: [PATCH 009/126] Adding tools/tolua . --- tools/tolua/README.mdown | 20 ++++ tools/tolua/cocos2dx.ini | 146 +++++++++++++++++++++++++++++ tools/tolua/cocos2dx_extension.ini | 69 ++++++++++++++ tools/tolua/genbindings.sh | 86 +++++++++++++++++ 4 files changed, 321 insertions(+) create mode 100644 tools/tolua/README.mdown create mode 100644 tools/tolua/cocos2dx.ini create mode 100644 tools/tolua/cocos2dx_extension.ini create mode 100755 tools/tolua/genbindings.sh diff --git a/tools/tolua/README.mdown b/tools/tolua/README.mdown new file mode 100644 index 0000000000..d0897de1d5 --- /dev/null +++ b/tools/tolua/README.mdown @@ -0,0 +1,20 @@ +How to Use bindings-generator +================== + +On Windows (Not available from 3.0-pre-alpha0, the reason is that Clang3.3 can't work perfectly on windows, therefore, disable windows support temporary.): +------------ + +* Make sure that you have installed `android-ndk-r8d` or higher version. +* Download python2.7.3 from (http://www.python.org/ftp/python/2.7.3/python-2.7.3.msi). +* Add the installed path of python (e.g. C:\Python27) to windows environment variable named 'PATH'. +* Download pyyaml from http://pyyaml.org/download/pyyaml/PyYAML-3.10.win32-py2.7.exe and install it. +* Download pyCheetah from https://raw.github.com/dumganhar/cocos2d-x/download/downloads/Cheetah.zip, unzip it to "C:\Python27\Lib\site-packages" +* Modify environment variables (`PYTHON_ROOT` and `NDK_ROOT`) in `genbindings-win32.bat`. +* Go to "cocos2d-x/tools/tojs" folder, and run "genbindings-win32.bat". The generated codes will be under "cocos2d-x\scripting\javascript\bindings\generated". + +On MAC: +---------- + +* Please refer to https://github.com/cocos2d/bindings-generator/blob/master/README.md + + diff --git a/tools/tolua/cocos2dx.ini b/tools/tolua/cocos2dx.ini new file mode 100644 index 0000000000..4b4909ae8f --- /dev/null +++ b/tools/tolua/cocos2dx.ini @@ -0,0 +1,146 @@ +[cocos2d-x] +# the prefix to be added to the generated functions. You might or might not use this in your own +# templates +prefix = cocos2dx + +# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`) +# all classes will be embedded in that namespace +target_namespace = cc + +android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include +android_flags = -D_SIZE_T_DEFINED_ + +clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include +clang_flags = -nostdinc -x c++ -std=c++11 + +cocos_headers = -I%(cocosdir)s/cocos2dx/include -I%(cocosdir)s/cocos2dx/platform -I%(cocosdir)s/cocos2dx/platform/android -I%(cocosdir)s/cocos2dx -I%(cocosdir)s/cocos2dx/kazmath/include +cocos_flags = -DANDROID -DCOCOS2D_JAVASCRIPT + +cxxgenerator_headers = -I%(cxxgeneratordir)s/targets/spidermonkey/common + +# extra arguments for clang +extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s + +# what headers to parse +headers = %(cocosdir)s/cocos2dx/include/cocos2d.h %(cocosdir)s/CocosDenshion/include/SimpleAudioEngine.h + +# 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 + +# 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 +# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just +# add a single "*" as functions. See bellow for several examples. A special class name is "*", which +# will apply to all class names. This is a convenience wildcard to be able to skip similar named +# functions from all classes. + +skip = Node::[^setPosition$ getGrid setGLServerState description getUserObject .*UserData getGLServerState .*schedule], + Sprite::[getQuad displayFrame getBlendFunc ^setPosition$ setBlendFunc setSpriteBatchNode getSpriteBatchNode], + SpriteBatchNode::[getBlendFunc setBlendFunc], + MotionStreak::[getBlendFunc setBlendFunc draw update], + AtlasNode::[getBlendFunc setBlendFunc], + ParticleBatchNode::[getBlendFunc setBlendFunc], + LayerColor::[getBlendFunc setBlendFunc], + ParticleSystem::[getBlendFunc setBlendFunc], + DrawNode::[getBlendFunc setBlendFunc drawPolygon listenBackToForeground], + Director::[getAccelerometer (g|s)et.*Dispatcher getOpenGLView getProjection getClassTypeInfo], + Layer.*::[didAccelerate (g|s)etBlendFunc keyPressed keyReleased], + Menu.*::[.*Target getSubItems create initWithItems alignItemsInRows alignItemsInColumns], + MenuItem.*::[create setCallback initWithCallback], + Copying::[*], + .*Protocol::[*], + .*Delegate::[*], + PoolManager::[*], + Texture2D::[initWithPVRTCData addPVRTCImage releaseData setTexParameters initWithData keepData], + Set::[begin end acceptVisitor], + IMEDispatcher::[*], + SAXParser::[*], + Thread::[*], + Profiler::[*], + ProfilingTimer::[*], + CallFunc::[create initWithFunction], + SAXDelegator::[*], + Color3bObject::[*], + TouchDispatcher::[*], + EGLTouchDelegate::[*], + ScriptEngineManager::[*], + KeypadHandler::[*], + Invocation::[*], + EGLView::[*], + SchedulerScriptHandlerEntry::[*], + Size::[*], + Point::[*], + PointArray::[*], + Rect::[*], + String::[*], + Data::[*], + Dictionary::[*], + Array::[*], + Range::[*], + NotificationObserver::[*], + Image::[initWithString initWithImageData], + Sequence::[create], + Spawn::[create], + Animation::[create], + GLProgram::[getProgram setUniformLocationWith2f.* setUniformLocationWith1f.* setUniformLocationWith3f.* setUniformLocationWith4f.*], + Grid3DAction::[create actionWith.* vertex originalVertex (g|s)etVertex getOriginalVertex], + Grid3D::[vertex originalVertex (g|s)etVertex getOriginalVertex], + TiledGrid3DAction::[create actionWith.* tile originalTile getOriginalTile (g|s)etTile], + TiledGrid3D::[tile originalTile getOriginalTile (g|s)etTile], + TMXLayer::[getTiles], + TMXMapInfo::[startElement endElement textHandler], + ParticleSystemQuad::[postStep setBatchNode draw setTexture$ setTotalParticles updateQuadWithParticle setupIndices listenBackToForeground initWithTotalParticles particleWithFile node], + LayerMultiplex::[create layerWith.* initWithLayers], + CatmullRom.*::[create actionWithDuration], + Bezier.*::[create actionWithDuration], + CardinalSpline.*::[create actionWithDuration setPoints], + Scheduler::[pause resume unschedule schedule update isTargetPaused], + TextureCache::[addPVRTCImage], + Timer::[getSelector createWithScriptHandler], + *::[copyWith.* onEnter.* onExit.* ^description$ getObjectType], + FileUtils::[(g|s)etSearchResolutionsOrder$ (g|s)etSearchPaths$ getClassTypeInfo], + SimpleAudioEngine::[getClassTypeInfo], + Application::[^application.* ^run$], + Camera::[getEyeXYZ getCenterXYZ getUpXYZ], + ccFontDefinition::[*] + +rename_functions = SpriteFrameCache::[addSpriteFramesWithFile=addSpriteFrames getSpriteFrameByName=getSpriteFrame isFlipX=isFlippedX isFlipY=isFlippedY], + MenuItemFont::[setFontNameObj=setFontName setFontSizeObj=setFontSize getFontSizeObj=getFontSize getFontNameObj=getFontName], + ProgressTimer::[setReverseProgress=setReverseDirection], + Animation::[addSpriteFrameWithFileName=addSpriteFrameWithFile], + AnimationCache::[addAnimationsWithFile=addAnimations animationByName=getAnimation removeAnimationByName=removeAnimation], + LayerGradient::[initWithColor=init], + LayerColor::[initWithColor=init], + GLProgram::[fragmentShaderLog=getFragmentShaderLog initWithVertexShaderByteArray=initWithString initWithVertexShaderFilename=init programLog=getProgramLog setUniformLocationWith1i=setUniformLocationI32 vertexShaderLog=getVertexShaderLog], + Node::[removeFromParentAndCleanup=removeFromParent removeAllChildrenWithCleanup=removeAllChildren], + LabelAtlas::[create=_create], + TMXLayer::[getPropertyNamed=getProperty], + Sprite::[isFlipX=isFlippedX isFlipY=isFlippedY initWithFile=init], + SpriteBatchNode::[initWithFile=init], + Touch::[getID=getId], + SimpleAudioEngine::[sharedEngine=getInstance preloadBackgroundMusic=preloadMusic setBackgroundMusicVolume=setMusicVolume getBackgroundMusicVolume=getMusicVolume playBackgroundMusic=playMusic stopBackgroundMusic=stopMusic pauseBackgroundMusic=pauseMusic resumeBackgroundMusic=resumeMusic rewindBackgroundMusic=rewindMusic isBackgroundMusicPlaying=isMusicPlaying willPlayBackgroundMusic=willPlayMusic], + Camera::[setUpXYZ=setUp setEyeXYZ=setEye setCenterXYZ=setCenter], + TMXTiledMap::[layerNamed=getLayer objectGroupNamed=getObjectGroup propertyNamed=getProperty], + ShaderCache::[programForKey=getProgram], + FileUtils::[loadFilenameLookupDictionaryFromFile=loadFilenameLookup] + +rename_classes = ParticleSystemQuad::ParticleSystem, + SimpleAudioEngine::AudioEngine + +# for all class names, should we remove something when registering in the target VM? +remove_prefix = + +# classes for which there will be no "parent" lookup +classes_have_no_parents = Node Director SimpleAudioEngine FileUtils TMXMapInfo Application + +# base classes which will be skipped when their sub-classes found them. +base_classes_to_skip = Object 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 + +# 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 + diff --git a/tools/tolua/cocos2dx_extension.ini b/tools/tolua/cocos2dx_extension.ini new file mode 100644 index 0000000000..6a31b61f3c --- /dev/null +++ b/tools/tolua/cocos2dx_extension.ini @@ -0,0 +1,69 @@ +[cocos2dx_extension] +# the prefix to be added to the generated functions. You might or might not use this in your own +# templates +prefix = cocos2dx_extension + +# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`) +# all classes will be embedded in that namespace +target_namespace = cc + +android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include +android_flags = -D_SIZE_T_DEFINED_ + +clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include +clang_flags = -nostdinc -x c++ -std=c++11 + +cocos_headers = -I%(cocosdir)s/cocos2dx/include -I%(cocosdir)s/cocos2dx/platform -I%(cocosdir)s/cocos2dx/platform/android -I%(cocosdir)s/cocos2dx -I%(cocosdir)s/cocos2dx/kazmath/include -I%(cocosdir)s/extensions +cocos_flags = -DANDROID -DCOCOS2D_JAVASCRIPT + +cxxgenerator_headers = -I%(cxxgeneratordir)s/targets/spidermonkey/common + +# extra arguments for clang +extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s + +# what headers to parse +headers = %(cocosdir)s/extensions/cocos-ext.h + +# 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 = CCBReader.* CCBAnimationManager.* Scale9Sprite Control$ ControlButton.* ScrollView$ TableView$ TableViewCell$ EditBox$ + +# 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 +# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just +# add a single "*" as functions. See bellow for several examples. A special class name is "*", which +# will apply to all class names. This is a convenience wildcard to be able to skip similar named +# functions from all classes. + +skip = CCBReader::[^CCBReader$ addOwnerCallbackName isJSControlled readByte getCCBMemberVariableAssigner readFloat getCCBSelectorResolver toLowerCase lastPathComponent deletePathExtension endsWith concat getResolutionScale getAnimatedProperties readBool readInt addOwnerCallbackNode addDocumentCallbackName readCachedString readNodeGraphFromData addDocumentCallbackNode getLoadedSpriteSheet initWithData readFileWithCleanUp getOwner$ readNodeGraphFromFile createSceneWithNodeGraphFromFile getAnimationManagers$ setAnimationManagers], + CCBAnimationManager::[setAnimationCompletedCallback], + ScrollView::[(g|s)etDelegate$], + .*Delegate::[*], + .*Loader.*::[*], + *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType], + EditBox::[(g|s)etDelegate ^keyboard.* touchDownAction getScriptEditBoxHandler registerScriptEditBoxHandler unregisterScriptEditBoxHandler], + TableView::[create (g|s)etDataSource$ (g|s)etDelegate], + Control::[removeHandleOfControlEvent addHandleOfControlEvent] + +rename_functions = CCBReader::[getAnimationManager=getActionManager setAnimationManager=setActionManager], + CCBAnimationManager::[setCallFunc=setCallFuncForJSCallbackNamed] + +rename_classes = CCBReader::_Reader, + CCBAnimationManager::AnimationManager + +# for all class names, should we remove something when registering in the target VM? +remove_prefix = + +# classes for which there will be no "parent" lookup +classes_have_no_parents = + +# base classes which will be skipped when their sub-classes found them. +base_classes_to_skip = Object + +# classes that create no constructor +# Set is special and we will use a hand-written constructor +abstract_classes = + +# 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 + diff --git a/tools/tolua/genbindings.sh b/tools/tolua/genbindings.sh new file mode 100755 index 0000000000..2a0a3759a3 --- /dev/null +++ b/tools/tolua/genbindings.sh @@ -0,0 +1,86 @@ +#!/bin/bash + +# exit this script if any commmand fails +set -e + +# read user.cfg if it exists and is readable + +_CFG_FILE=$(dirname "$0")"/user.cfg" +if [ -f "$_CFG_FILE" ] +then + [ -r "$_CFG_FILE" ] || die "Fatal Error: $_CFG_FILE exists but is unreadable" + . "$_CFG_FILE" +fi + +# paths + +if [ -z "${NDK_ROOT+aaa}" ]; then +# ... if NDK_ROOT is not set, use "$HOME/bin/android-ndk" + NDK_ROOT="$HOME/bin/android-ndk" +fi + +if [ -z "${CLANG_ROOT+aaa}" ]; then +# ... if CLANG_ROOT is not set, use "$HOME/bin/clang+llvm-3.3" + CLANG_ROOT="$HOME/bin/clang+llvm-3.3" +fi + +if [ -z "${PYTHON_BIN+aaa}" ]; then +# ... if PYTHON_BIN is not set, use "/usr/bin/python2.7" + PYTHON_BIN="/usr/bin/python2.7" +fi + +# find current dir +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +# paths with defaults hardcoded to relative paths + +if [ -z "${COCOS2DX_ROOT+aaa}" ]; then + COCOS2DX_ROOT="$DIR/../../" +fi + +if [ -z "${CXX_GENERATOR_ROOT+aaa}" ]; then + CXX_GENERATOR_ROOT="$COCOS2DX_ROOT/tools/bindings-generator" +fi + +if [ -z "${TOJS_ROOT+aaa}" ]; then + TO_JS_ROOT="$COCOS2DX_ROOT/tools/tolua" +fi + +echo "Paths" +echo " NDK_ROOT: $NDK_ROOT" +echo " CLANG_ROOT: $CLANG_ROOT" +echo " PYTHON_BIN: $PYTHON_BIN" +echo " COCOS2DX_ROOT: $COCOS2DX_ROOT" +echo " CXX_GENERATOR_ROOT: $CXX_GENERATOR_ROOT" +echo " TO_JS_ROOT: $TO_JS_ROOT" + +# write userconf.ini + +_CONF_INI_FILE="$PWD/userconf.ini" +if [ -f "$_CONF_INI_FILE" ] +then + rm "$_CONF_INI_FILE" +fi + +_CONTENTS="" +_CONTENTS+="[DEFAULT]"'\n' +_CONTENTS+="androidndkdir=$NDK_ROOT"'\n' +_CONTENTS+="clangllvmdir=$CLANG_ROOT"'\n' +_CONTENTS+="cocosdir=$COCOS2DX_ROOT"'\n' +_CONTENTS+="cxxgeneratordir=$CXX_GENERATOR_ROOT"'\n' +_CONTENTS+="extra_flags="'\n' + +echo +echo "generating userconf.ini..." +echo --- +echo -e "$_CONTENTS" +echo -e "$_CONTENTS" > "$_CONF_INI_FILE" +echo --- + +# Generate bindings for cocos2dx +echo "Generating bindings for cocos2dx..." +set -x +LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx.ini -s cocos2d-x -t lua -o ${COCOS2DX_ROOT}/scripting/lua/cocos2dx_support/generated -n lua_cocos2dx_auto + +echo "Generating bindings for cocos2dx_extension..." +LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx_extension.ini -s cocos2dx_extension -t lua -o ${COCOS2DX_ROOT}/scripting/lua/cocos2dx_support/generated -n lua_cocos2dx_extension_auto From ec49e7568f428cae8ac8868f319aa2576bf0d13c Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 5 Aug 2013 18:31:20 +0800 Subject: [PATCH 010/126] Updating bindings-generator, adding lua target. It's not finished. --- tools/bindings-generator | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/bindings-generator b/tools/bindings-generator index 4b76994a1f..232d40e539 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit 4b76994a1f54a78bdac944fcd5cae41d42123447 +Subproject commit 232d40e5395538439a127beac035ba13cb779dba From 77a9c91b3d2cadc2bd925792d99b90d36198047d Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 5 Aug 2013 18:33:13 +0800 Subject: [PATCH 011/126] We has to pass the target to bindings-generator since we have add lua target. --- tools/tojs/genbindings.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/tojs/genbindings.sh b/tools/tojs/genbindings.sh index cee5b17e7d..17c02f8606 100755 --- a/tools/tojs/genbindings.sh +++ b/tools/tojs/genbindings.sh @@ -80,7 +80,7 @@ echo --- # Generate bindings for cocos2dx echo "Generating bindings for cocos2dx..." set -x -LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx.ini -s cocos2d-x -o ${COCOS2DX_ROOT}/scripting/javascript/bindings/generated -n jsb_cocos2dx_auto +LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx.ini -s cocos2d-x -t spidermonkey -o ${COCOS2DX_ROOT}/scripting/javascript/bindings/generated -n jsb_cocos2dx_auto echo "Generating bindings for cocos2dx_extension..." -LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx_extension.ini -s cocos2dx_extension -o ${COCOS2DX_ROOT}/scripting/javascript/bindings/generated -n jsb_cocos2dx_extension_auto +LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx_extension.ini -s cocos2dx_extension -t spidermonkey -o ${COCOS2DX_ROOT}/scripting/javascript/bindings/generated -n jsb_cocos2dx_extension_auto From 0c4910ee953b813cbb8401c7c42e651753049c25 Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 5 Aug 2013 18:30:36 +0800 Subject: [PATCH 012/126] Adding tools/tolua . --- tools/tolua/README.mdown | 20 ++++ tools/tolua/cocos2dx.ini | 146 +++++++++++++++++++++++++++++ tools/tolua/cocos2dx_extension.ini | 69 ++++++++++++++ tools/tolua/genbindings.sh | 86 +++++++++++++++++ 4 files changed, 321 insertions(+) create mode 100644 tools/tolua/README.mdown create mode 100644 tools/tolua/cocos2dx.ini create mode 100644 tools/tolua/cocos2dx_extension.ini create mode 100755 tools/tolua/genbindings.sh diff --git a/tools/tolua/README.mdown b/tools/tolua/README.mdown new file mode 100644 index 0000000000..d0897de1d5 --- /dev/null +++ b/tools/tolua/README.mdown @@ -0,0 +1,20 @@ +How to Use bindings-generator +================== + +On Windows (Not available from 3.0-pre-alpha0, the reason is that Clang3.3 can't work perfectly on windows, therefore, disable windows support temporary.): +------------ + +* Make sure that you have installed `android-ndk-r8d` or higher version. +* Download python2.7.3 from (http://www.python.org/ftp/python/2.7.3/python-2.7.3.msi). +* Add the installed path of python (e.g. C:\Python27) to windows environment variable named 'PATH'. +* Download pyyaml from http://pyyaml.org/download/pyyaml/PyYAML-3.10.win32-py2.7.exe and install it. +* Download pyCheetah from https://raw.github.com/dumganhar/cocos2d-x/download/downloads/Cheetah.zip, unzip it to "C:\Python27\Lib\site-packages" +* Modify environment variables (`PYTHON_ROOT` and `NDK_ROOT`) in `genbindings-win32.bat`. +* Go to "cocos2d-x/tools/tojs" folder, and run "genbindings-win32.bat". The generated codes will be under "cocos2d-x\scripting\javascript\bindings\generated". + +On MAC: +---------- + +* Please refer to https://github.com/cocos2d/bindings-generator/blob/master/README.md + + diff --git a/tools/tolua/cocos2dx.ini b/tools/tolua/cocos2dx.ini new file mode 100644 index 0000000000..4b4909ae8f --- /dev/null +++ b/tools/tolua/cocos2dx.ini @@ -0,0 +1,146 @@ +[cocos2d-x] +# the prefix to be added to the generated functions. You might or might not use this in your own +# templates +prefix = cocos2dx + +# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`) +# all classes will be embedded in that namespace +target_namespace = cc + +android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include +android_flags = -D_SIZE_T_DEFINED_ + +clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include +clang_flags = -nostdinc -x c++ -std=c++11 + +cocos_headers = -I%(cocosdir)s/cocos2dx/include -I%(cocosdir)s/cocos2dx/platform -I%(cocosdir)s/cocos2dx/platform/android -I%(cocosdir)s/cocos2dx -I%(cocosdir)s/cocos2dx/kazmath/include +cocos_flags = -DANDROID -DCOCOS2D_JAVASCRIPT + +cxxgenerator_headers = -I%(cxxgeneratordir)s/targets/spidermonkey/common + +# extra arguments for clang +extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s + +# what headers to parse +headers = %(cocosdir)s/cocos2dx/include/cocos2d.h %(cocosdir)s/CocosDenshion/include/SimpleAudioEngine.h + +# 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 + +# 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 +# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just +# add a single "*" as functions. See bellow for several examples. A special class name is "*", which +# will apply to all class names. This is a convenience wildcard to be able to skip similar named +# functions from all classes. + +skip = Node::[^setPosition$ getGrid setGLServerState description getUserObject .*UserData getGLServerState .*schedule], + Sprite::[getQuad displayFrame getBlendFunc ^setPosition$ setBlendFunc setSpriteBatchNode getSpriteBatchNode], + SpriteBatchNode::[getBlendFunc setBlendFunc], + MotionStreak::[getBlendFunc setBlendFunc draw update], + AtlasNode::[getBlendFunc setBlendFunc], + ParticleBatchNode::[getBlendFunc setBlendFunc], + LayerColor::[getBlendFunc setBlendFunc], + ParticleSystem::[getBlendFunc setBlendFunc], + DrawNode::[getBlendFunc setBlendFunc drawPolygon listenBackToForeground], + Director::[getAccelerometer (g|s)et.*Dispatcher getOpenGLView getProjection getClassTypeInfo], + Layer.*::[didAccelerate (g|s)etBlendFunc keyPressed keyReleased], + Menu.*::[.*Target getSubItems create initWithItems alignItemsInRows alignItemsInColumns], + MenuItem.*::[create setCallback initWithCallback], + Copying::[*], + .*Protocol::[*], + .*Delegate::[*], + PoolManager::[*], + Texture2D::[initWithPVRTCData addPVRTCImage releaseData setTexParameters initWithData keepData], + Set::[begin end acceptVisitor], + IMEDispatcher::[*], + SAXParser::[*], + Thread::[*], + Profiler::[*], + ProfilingTimer::[*], + CallFunc::[create initWithFunction], + SAXDelegator::[*], + Color3bObject::[*], + TouchDispatcher::[*], + EGLTouchDelegate::[*], + ScriptEngineManager::[*], + KeypadHandler::[*], + Invocation::[*], + EGLView::[*], + SchedulerScriptHandlerEntry::[*], + Size::[*], + Point::[*], + PointArray::[*], + Rect::[*], + String::[*], + Data::[*], + Dictionary::[*], + Array::[*], + Range::[*], + NotificationObserver::[*], + Image::[initWithString initWithImageData], + Sequence::[create], + Spawn::[create], + Animation::[create], + GLProgram::[getProgram setUniformLocationWith2f.* setUniformLocationWith1f.* setUniformLocationWith3f.* setUniformLocationWith4f.*], + Grid3DAction::[create actionWith.* vertex originalVertex (g|s)etVertex getOriginalVertex], + Grid3D::[vertex originalVertex (g|s)etVertex getOriginalVertex], + TiledGrid3DAction::[create actionWith.* tile originalTile getOriginalTile (g|s)etTile], + TiledGrid3D::[tile originalTile getOriginalTile (g|s)etTile], + TMXLayer::[getTiles], + TMXMapInfo::[startElement endElement textHandler], + ParticleSystemQuad::[postStep setBatchNode draw setTexture$ setTotalParticles updateQuadWithParticle setupIndices listenBackToForeground initWithTotalParticles particleWithFile node], + LayerMultiplex::[create layerWith.* initWithLayers], + CatmullRom.*::[create actionWithDuration], + Bezier.*::[create actionWithDuration], + CardinalSpline.*::[create actionWithDuration setPoints], + Scheduler::[pause resume unschedule schedule update isTargetPaused], + TextureCache::[addPVRTCImage], + Timer::[getSelector createWithScriptHandler], + *::[copyWith.* onEnter.* onExit.* ^description$ getObjectType], + FileUtils::[(g|s)etSearchResolutionsOrder$ (g|s)etSearchPaths$ getClassTypeInfo], + SimpleAudioEngine::[getClassTypeInfo], + Application::[^application.* ^run$], + Camera::[getEyeXYZ getCenterXYZ getUpXYZ], + ccFontDefinition::[*] + +rename_functions = SpriteFrameCache::[addSpriteFramesWithFile=addSpriteFrames getSpriteFrameByName=getSpriteFrame isFlipX=isFlippedX isFlipY=isFlippedY], + MenuItemFont::[setFontNameObj=setFontName setFontSizeObj=setFontSize getFontSizeObj=getFontSize getFontNameObj=getFontName], + ProgressTimer::[setReverseProgress=setReverseDirection], + Animation::[addSpriteFrameWithFileName=addSpriteFrameWithFile], + AnimationCache::[addAnimationsWithFile=addAnimations animationByName=getAnimation removeAnimationByName=removeAnimation], + LayerGradient::[initWithColor=init], + LayerColor::[initWithColor=init], + GLProgram::[fragmentShaderLog=getFragmentShaderLog initWithVertexShaderByteArray=initWithString initWithVertexShaderFilename=init programLog=getProgramLog setUniformLocationWith1i=setUniformLocationI32 vertexShaderLog=getVertexShaderLog], + Node::[removeFromParentAndCleanup=removeFromParent removeAllChildrenWithCleanup=removeAllChildren], + LabelAtlas::[create=_create], + TMXLayer::[getPropertyNamed=getProperty], + Sprite::[isFlipX=isFlippedX isFlipY=isFlippedY initWithFile=init], + SpriteBatchNode::[initWithFile=init], + Touch::[getID=getId], + SimpleAudioEngine::[sharedEngine=getInstance preloadBackgroundMusic=preloadMusic setBackgroundMusicVolume=setMusicVolume getBackgroundMusicVolume=getMusicVolume playBackgroundMusic=playMusic stopBackgroundMusic=stopMusic pauseBackgroundMusic=pauseMusic resumeBackgroundMusic=resumeMusic rewindBackgroundMusic=rewindMusic isBackgroundMusicPlaying=isMusicPlaying willPlayBackgroundMusic=willPlayMusic], + Camera::[setUpXYZ=setUp setEyeXYZ=setEye setCenterXYZ=setCenter], + TMXTiledMap::[layerNamed=getLayer objectGroupNamed=getObjectGroup propertyNamed=getProperty], + ShaderCache::[programForKey=getProgram], + FileUtils::[loadFilenameLookupDictionaryFromFile=loadFilenameLookup] + +rename_classes = ParticleSystemQuad::ParticleSystem, + SimpleAudioEngine::AudioEngine + +# for all class names, should we remove something when registering in the target VM? +remove_prefix = + +# classes for which there will be no "parent" lookup +classes_have_no_parents = Node Director SimpleAudioEngine FileUtils TMXMapInfo Application + +# base classes which will be skipped when their sub-classes found them. +base_classes_to_skip = Object 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 + +# 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 + diff --git a/tools/tolua/cocos2dx_extension.ini b/tools/tolua/cocos2dx_extension.ini new file mode 100644 index 0000000000..6a31b61f3c --- /dev/null +++ b/tools/tolua/cocos2dx_extension.ini @@ -0,0 +1,69 @@ +[cocos2dx_extension] +# the prefix to be added to the generated functions. You might or might not use this in your own +# templates +prefix = cocos2dx_extension + +# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`) +# all classes will be embedded in that namespace +target_namespace = cc + +android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include +android_flags = -D_SIZE_T_DEFINED_ + +clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include +clang_flags = -nostdinc -x c++ -std=c++11 + +cocos_headers = -I%(cocosdir)s/cocos2dx/include -I%(cocosdir)s/cocos2dx/platform -I%(cocosdir)s/cocos2dx/platform/android -I%(cocosdir)s/cocos2dx -I%(cocosdir)s/cocos2dx/kazmath/include -I%(cocosdir)s/extensions +cocos_flags = -DANDROID -DCOCOS2D_JAVASCRIPT + +cxxgenerator_headers = -I%(cxxgeneratordir)s/targets/spidermonkey/common + +# extra arguments for clang +extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s + +# what headers to parse +headers = %(cocosdir)s/extensions/cocos-ext.h + +# 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 = CCBReader.* CCBAnimationManager.* Scale9Sprite Control$ ControlButton.* ScrollView$ TableView$ TableViewCell$ EditBox$ + +# 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 +# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just +# add a single "*" as functions. See bellow for several examples. A special class name is "*", which +# will apply to all class names. This is a convenience wildcard to be able to skip similar named +# functions from all classes. + +skip = CCBReader::[^CCBReader$ addOwnerCallbackName isJSControlled readByte getCCBMemberVariableAssigner readFloat getCCBSelectorResolver toLowerCase lastPathComponent deletePathExtension endsWith concat getResolutionScale getAnimatedProperties readBool readInt addOwnerCallbackNode addDocumentCallbackName readCachedString readNodeGraphFromData addDocumentCallbackNode getLoadedSpriteSheet initWithData readFileWithCleanUp getOwner$ readNodeGraphFromFile createSceneWithNodeGraphFromFile getAnimationManagers$ setAnimationManagers], + CCBAnimationManager::[setAnimationCompletedCallback], + ScrollView::[(g|s)etDelegate$], + .*Delegate::[*], + .*Loader.*::[*], + *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType], + EditBox::[(g|s)etDelegate ^keyboard.* touchDownAction getScriptEditBoxHandler registerScriptEditBoxHandler unregisterScriptEditBoxHandler], + TableView::[create (g|s)etDataSource$ (g|s)etDelegate], + Control::[removeHandleOfControlEvent addHandleOfControlEvent] + +rename_functions = CCBReader::[getAnimationManager=getActionManager setAnimationManager=setActionManager], + CCBAnimationManager::[setCallFunc=setCallFuncForJSCallbackNamed] + +rename_classes = CCBReader::_Reader, + CCBAnimationManager::AnimationManager + +# for all class names, should we remove something when registering in the target VM? +remove_prefix = + +# classes for which there will be no "parent" lookup +classes_have_no_parents = + +# base classes which will be skipped when their sub-classes found them. +base_classes_to_skip = Object + +# classes that create no constructor +# Set is special and we will use a hand-written constructor +abstract_classes = + +# 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 + diff --git a/tools/tolua/genbindings.sh b/tools/tolua/genbindings.sh new file mode 100755 index 0000000000..2a0a3759a3 --- /dev/null +++ b/tools/tolua/genbindings.sh @@ -0,0 +1,86 @@ +#!/bin/bash + +# exit this script if any commmand fails +set -e + +# read user.cfg if it exists and is readable + +_CFG_FILE=$(dirname "$0")"/user.cfg" +if [ -f "$_CFG_FILE" ] +then + [ -r "$_CFG_FILE" ] || die "Fatal Error: $_CFG_FILE exists but is unreadable" + . "$_CFG_FILE" +fi + +# paths + +if [ -z "${NDK_ROOT+aaa}" ]; then +# ... if NDK_ROOT is not set, use "$HOME/bin/android-ndk" + NDK_ROOT="$HOME/bin/android-ndk" +fi + +if [ -z "${CLANG_ROOT+aaa}" ]; then +# ... if CLANG_ROOT is not set, use "$HOME/bin/clang+llvm-3.3" + CLANG_ROOT="$HOME/bin/clang+llvm-3.3" +fi + +if [ -z "${PYTHON_BIN+aaa}" ]; then +# ... if PYTHON_BIN is not set, use "/usr/bin/python2.7" + PYTHON_BIN="/usr/bin/python2.7" +fi + +# find current dir +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +# paths with defaults hardcoded to relative paths + +if [ -z "${COCOS2DX_ROOT+aaa}" ]; then + COCOS2DX_ROOT="$DIR/../../" +fi + +if [ -z "${CXX_GENERATOR_ROOT+aaa}" ]; then + CXX_GENERATOR_ROOT="$COCOS2DX_ROOT/tools/bindings-generator" +fi + +if [ -z "${TOJS_ROOT+aaa}" ]; then + TO_JS_ROOT="$COCOS2DX_ROOT/tools/tolua" +fi + +echo "Paths" +echo " NDK_ROOT: $NDK_ROOT" +echo " CLANG_ROOT: $CLANG_ROOT" +echo " PYTHON_BIN: $PYTHON_BIN" +echo " COCOS2DX_ROOT: $COCOS2DX_ROOT" +echo " CXX_GENERATOR_ROOT: $CXX_GENERATOR_ROOT" +echo " TO_JS_ROOT: $TO_JS_ROOT" + +# write userconf.ini + +_CONF_INI_FILE="$PWD/userconf.ini" +if [ -f "$_CONF_INI_FILE" ] +then + rm "$_CONF_INI_FILE" +fi + +_CONTENTS="" +_CONTENTS+="[DEFAULT]"'\n' +_CONTENTS+="androidndkdir=$NDK_ROOT"'\n' +_CONTENTS+="clangllvmdir=$CLANG_ROOT"'\n' +_CONTENTS+="cocosdir=$COCOS2DX_ROOT"'\n' +_CONTENTS+="cxxgeneratordir=$CXX_GENERATOR_ROOT"'\n' +_CONTENTS+="extra_flags="'\n' + +echo +echo "generating userconf.ini..." +echo --- +echo -e "$_CONTENTS" +echo -e "$_CONTENTS" > "$_CONF_INI_FILE" +echo --- + +# Generate bindings for cocos2dx +echo "Generating bindings for cocos2dx..." +set -x +LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx.ini -s cocos2d-x -t lua -o ${COCOS2DX_ROOT}/scripting/lua/cocos2dx_support/generated -n lua_cocos2dx_auto + +echo "Generating bindings for cocos2dx_extension..." +LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx_extension.ini -s cocos2dx_extension -t lua -o ${COCOS2DX_ROOT}/scripting/lua/cocos2dx_support/generated -n lua_cocos2dx_extension_auto From 200c5de83fbb452188f9d9e5bf9cebc4566b142e Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Wed, 7 Aug 2013 10:37:20 +0800 Subject: [PATCH 013/126] issue #2433:lua binding generator --- .../project.pbxproj.REMOVED.git-id | 2 +- .../cocos2dx_support/LuaBasicConversions.cpp | 1182 +++++++++++ .../cocos2dx_support/LuaBasicConversions.h | 43 + .../lua_cocos2dx_auto.cpp.REMOVED.git-id | 1 + .../generated/lua_cocos2dx_auto.hpp | 1790 +++++++++++++++++ .../lua_cocos2dx_auto_api.js.REMOVED.git-id | 1 + ...cocos2dx_extension_auto.cpp.REMOVED.git-id | 1 + .../generated/lua_cocos2dx_extension_auto.hpp | 260 +++ .../lua_cocos2dx_extension_auto_api.js | 1547 ++++++++++++++ tools/tolua/userconf.ini | 7 + 10 files changed, 4833 insertions(+), 1 deletion(-) create mode 100644 scripting/lua/cocos2dx_support/LuaBasicConversions.cpp create mode 100644 scripting/lua/cocos2dx_support/LuaBasicConversions.h create mode 100644 scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id create mode 100644 scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.hpp create mode 100644 scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id create mode 100644 scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id create mode 100644 scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.hpp create mode 100644 scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto_api.js create mode 100644 tools/tolua/userconf.ini diff --git a/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id b/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id index 024c567a4c..2756f8be75 100644 --- a/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -2be27e9efb6c86c102b456842fc79a7b397910e0 \ No newline at end of file +6cf9234888d9a13b8d729d33a5dce7fa795c99ca \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/LuaBasicConversions.cpp b/scripting/lua/cocos2dx_support/LuaBasicConversions.cpp new file mode 100644 index 0000000000..5c35fa0199 --- /dev/null +++ b/scripting/lua/cocos2dx_support/LuaBasicConversions.cpp @@ -0,0 +1,1182 @@ +/**************************************************************************** + Copyright (c) 2011 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "LuaBasicConversions.h" +extern "C" { +#include "tolua++.h" +} + +#if COCOS2D_DEBUG >=1 +void luaval_to_native_err(lua_State* L,const char* msg,tolua_Error* err) +{ + if (NULL == L || NULL == err || NULL == msg || 0 == strlen(msg)) + return; + + if (msg[0] == '#') + { + const char* expected = err->type; + const char* provided = tolua_typename(L,err->index); + if (msg[1]=='f') + { + int narg = err->index; + if (err->array) + CCLOG("%s\n argument #%d is array of '%s'; array of '%s' expected.\n",msg+2,narg,provided,expected); + else + CCLOG("%s\n argument #%d is '%s'; '%s' expected.\n",msg+2,narg,provided,expected); + } + else if (msg[1]=='v') + { + if (err->array) + CCLOG("%s\n value is array of '%s'; array of '%s' expected.\n",msg+2,provided,expected); + else + CCLOG("%s\n value is '%s'; '%s' expected.\n",msg+2,provided,expected); + } + } +} +#endif + + +bool luaval_to_int32(lua_State* L,int lo,int* outValue) +{ + if (NULL == L || NULL == outValue) + return false; + + bool ok = true; +#if COCOS2D_DEBUG >=1 + tolua_Error tolua_err; + if (!tolua_isnumber(L,lo,0,&tolua_err)) + { + luaval_to_native_err(L,"#ferror:",&tolua_err); + ok = false; + } +#endif + + if (ok) + { + *outValue = (int)tolua_tonumber(L, lo, 0); + } + + return ok; +} + +bool luaval_to_uint32(lua_State* L, int lo, unsigned int* outValue) +{ + if (NULL == L || NULL == outValue) + return false; + + bool ok = true; +#if COCOS2D_DEBUG >=1 + tolua_Error tolua_err; + if (!tolua_isnumber(L,lo,0,&tolua_err)) + { + luaval_to_native_err(L,"#ferror:",&tolua_err); + ok = false; + } +#endif + + if (ok) + { + *outValue = (unsigned int)tolua_tonumber(L, lo, 0); + } + + return ok; +} + +bool luaval_to_uint16(lua_State* L,int lo,uint16_t* outValue) +{ + if (NULL == L || NULL == outValue) + return false; + + bool ok = true; +#if COCOS2D_DEBUG >=1 + tolua_Error tolua_err; + if (!tolua_isnumber(L,lo,0,&tolua_err)) + { + luaval_to_native_err(L,"#ferror:",&tolua_err); + ok = false; + } +#endif + + if (ok) + { + *outValue = (unsigned char)tolua_tonumber(L, lo, 0); + } + + return ok; +} + +bool luaval_to_boolean(lua_State* L,int lo,bool* outValue) +{ + if (NULL == L || NULL == outValue) + return false; + + bool ok = true; +#if COCOS2D_DEBUG >=1 + tolua_Error tolua_err; + if (!tolua_isboolean(L,lo,0,&tolua_err)) + { + luaval_to_native_err(L,"#ferror:",&tolua_err); + ok = false; + } +#endif + + if (ok) + { + *outValue = (bool)tolua_toboolean(L, lo, 0); + } + + return ok; +} + +bool luaval_to_number(lua_State* L,int lo,double* outValue) +{ + if (NULL == L || NULL == outValue) + return false; + + bool ok = true; +#if COCOS2D_DEBUG >=1 + tolua_Error tolua_err; + if (!tolua_isnumber(L,lo,0,&tolua_err)) + { + luaval_to_native_err(L,"#ferror:",&tolua_err); + ok = false; + } +#endif + + if (ok) + { + *outValue = tolua_tonumber(L, lo, 0); + } + + return ok; +} + +bool luaval_to_long_long(lua_State* L,int lo,long long* outValue) +{ + if (NULL == L || NULL == outValue) + return false; + + bool ok = true; +#if COCOS2D_DEBUG >=1 + tolua_Error tolua_err; + if (!tolua_isnumber(L,lo,0,&tolua_err)) + { + luaval_to_native_err(L,"#ferror:",&tolua_err); + ok = false; + } +#endif + + if (ok) + { + *outValue = (long long)tolua_tonumber(L, lo, 0); + } + + return ok; +} + +bool luaval_to_std_string(lua_State* L, int lo, std::string* outValue) +{ + if (NULL == L || NULL == outValue) + return false; + + bool ok = true; +#if COCOS2D_DEBUG >=1 + tolua_Error tolua_err; + if (!tolua_iscppstring(L,lo,0,&tolua_err)) + { + luaval_to_native_err(L,"#ferror:",&tolua_err); + ok = false; + } +#endif + + if (ok) + { + *outValue = tolua_tocppstring(L,lo,NULL); + } + + return ok; +} + +bool luaval_to_point(lua_State* L,int lo,Point* outValue) +{ + if (NULL == L || NULL == outValue) + return false; + + bool ok = true; +#if COCOS2D_DEBUG >=1 + tolua_Error tolua_err; + if (!tolua_istable(L, lo, 0, &tolua_err) ) + { + luaval_to_native_err(L,"#ferror:",&tolua_err); + ok = false; + } +#endif + + if (ok) + { + lua_pushstring(L, "x"); + lua_gettable(L, lo); + outValue->x = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1); + lua_pop(L, 1); + + lua_pushstring(L, "y"); + lua_gettable(L, lo); + outValue->y = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1); + lua_pop(L, 1); + } + return ok; +} + +bool luaval_to_size(lua_State* L,int lo,Size* outValue) +{ + if (NULL == L || NULL == outValue) + return false; + + bool ok = true; +#if COCOS2D_DEBUG >=1 + tolua_Error tolua_err; + if (!tolua_istable(L, lo, 0, &tolua_err) ) + { + luaval_to_native_err(L,"#ferror:",&tolua_err); + ok = false; + } +#endif + + if (ok) + { + lua_pushstring(L, "width"); /* L: paramStack key */ + lua_gettable(L,lo);/* L: paramStack paramStack[lo][key] */ + outValue->width = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + lua_pop(L,1);/* L: paramStack*/ + + lua_pushstring(L, "height"); + lua_gettable(L,lo); + outValue->height = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + lua_pop(L,1); + } + + return ok; +} + +bool luaval_to_rect(lua_State* L,int lo,Rect* outValue) +{ + if (NULL == L || NULL == outValue) + return false; + + bool ok = true; +#if COCOS2D_DEBUG >=1 + tolua_Error tolua_err; + if (!tolua_istable(L, lo, 0, &tolua_err) ) + { + luaval_to_native_err(L,"#ferror:",&tolua_err); + ok = false; + } +#endif + + if (ok) + { + lua_pushstring(L, "x"); + lua_gettable(L,lo); + outValue->origin.x = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + lua_pop(L,1); + + lua_pushstring(L, "y"); + lua_gettable(L,lo); + outValue->origin.y = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + lua_pop(L,1); + + lua_pushstring(L, "width"); + lua_gettable(L,lo); + outValue->size.width = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + lua_pop(L,1); + + lua_pushstring(L, "height"); + lua_gettable(L,lo); + outValue->size.height = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + lua_pop(L,1); + } + + return ok; +} + +bool luaval_to_color4b(lua_State* L,int lo,Color4B* outValue) +{ + if (NULL == L || NULL == outValue) + return false; + + bool ok = true; +#if COCOS2D_DEBUG >=1 + tolua_Error tolua_err; + if (!tolua_istable(L, lo, 0, &tolua_err) ) + { + luaval_to_native_err(L,"#ferror:",&tolua_err); + ok = false; + } +#endif + + if(ok) + { + lua_pushstring(L, "r"); + lua_gettable(L,lo); + outValue->r = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + lua_pop(L,1); + + lua_pushstring(L, "g"); + lua_gettable(L,lo); + outValue->g = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + lua_pop(L,1); + + lua_pushstring(L, "b"); + lua_gettable(L,lo); + outValue->b = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + lua_pop(L,1); + + lua_pushstring(L, "a"); + lua_gettable(L,lo); + outValue->a = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + lua_pop(L,1); + } + + return ok; +} + +bool luaval_to_color4f(lua_State* L,int lo,Color4F* outValue) +{ + if (NULL == L || NULL == outValue) + return false; + + bool ok = true; +#if COCOS2D_DEBUG >=1 + tolua_Error tolua_err; + if (!tolua_istable(L, lo, 0, &tolua_err) ) + { + luaval_to_native_err(L,"#ferror:",&tolua_err); + ok = false; + } +#endif + + if (ok) + { + lua_pushstring(L, "r"); + lua_gettable(L,lo); + outValue->r = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + lua_pop(L,1); + + lua_pushstring(L, "g"); + lua_gettable(L,lo); + outValue->g = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + lua_pop(L,1); + + lua_pushstring(L, "b"); + lua_gettable(L,lo); + outValue->b = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + lua_pop(L,1); + + lua_pushstring(L, "a"); + lua_gettable(L,lo); + outValue->a = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + lua_pop(L,1); + } + + return ok; +} + +bool luaval_to_color3b(lua_State* L,int lo,Color3B* outValue) +{ + if (NULL == L || NULL == outValue) + return false; + + bool ok = true; +#if COCOS2D_DEBUG >=1 + tolua_Error tolua_err; + if (!tolua_istable(L, lo, 0, &tolua_err) ) + { + luaval_to_native_err(L,"#ferror:",&tolua_err); + ok = false; + } +#endif + + if (ok) + { + lua_pushstring(L, "r"); + lua_gettable(L,lo); + outValue->r = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + lua_pop(L,1); + + lua_pushstring(L, "g"); + lua_gettable(L,lo); + outValue->g = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + lua_pop(L,1); + + lua_pushstring(L, "b"); + lua_gettable(L,lo); + outValue->b = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + lua_pop(L,1); + } + + return ok; +} + +bool luaval_to_affinetransform(lua_State* L,int lo, AffineTransform* outValue) +{ + if (NULL == L || NULL == outValue) + return false; + + bool ok = true; +#if COCOS2D_DEBUG >=1 + tolua_Error tolua_err; + if (!tolua_istable(L, lo, 0, &tolua_err) ) + { + luaval_to_native_err(L,"#ferror:",&tolua_err); + ok = false; + } +#endif + + if (ok) + { + lua_pushstring(L, "a"); + lua_gettable(L,lo); + outValue->a = lua_isnil(L,-1) ? 0 : (float)lua_tonumber(L,-1); + lua_pop(L,1); + + lua_pushstring(L, "b"); + lua_gettable(L,lo); + outValue->b = lua_isnil(L,-1) ? 0 : (float)lua_tonumber(L,-1); + lua_pop(L,1); + + lua_pushstring(L, "c"); + lua_gettable(L,lo); + outValue->b = lua_isnil(L,-1) ? 0 : (float)lua_tonumber(L,-1); + lua_pop(L,1); + + lua_pushstring(L, "d"); + lua_gettable(L,lo); + outValue->b = lua_isnil(L,-1) ? 0 : (float)lua_tonumber(L,-1); + lua_pop(L,1); + + lua_pushstring(L, "tx"); + lua_gettable(L,lo); + outValue->b = lua_isnil(L,-1) ? 0 : (float)lua_tonumber(L,-1); + lua_pop(L,1); + + lua_pushstring(L, "ty"); + lua_gettable(L,lo); + outValue->b = lua_isnil(L,-1) ? 0 : (float)lua_tonumber(L,-1); + lua_pop(L,1); + } + return ok; +} + +bool luaval_to_fontdefinition(lua_State* L, int lo, FontDefinition* outValue ) +{ + if (NULL == L || NULL == outValue) + return false; + + bool ok = true; +#if COCOS2D_DEBUG >=1 + tolua_Error tolua_err; + if (!tolua_istable(L, lo, 0, &tolua_err) ) + { + luaval_to_native_err(L,"#ferror:",&tolua_err); + ok = false; + } +#endif + + if (ok) + { + // defaul values + const char * defautlFontName = "Arial"; + const int defaultFontSize = 32; + TextHAlignment defaultTextAlignment = TextHAlignment::LEFT; + TextVAlignment defaultTextVAlignment = TextVAlignment::TOP; + + // by default shadow and stroke are off + outValue->_shadow._shadowEnabled = false; + outValue->_stroke._strokeEnabled = false; + + // white text by default + outValue->_fontFillColor = Color3B::WHITE; + + lua_pushstring(L, "fontName"); + lua_gettable(L,lo); + outValue->_fontName = tolua_tocppstring(L,lo,defautlFontName); + lua_pop(L,1); + + lua_pushstring(L, "fontSize"); + lua_gettable(L,lo); + outValue->_fontSize = lua_isnil(L,-1) ? defaultFontSize : (int)lua_tonumber(L,-1); + lua_pop(L,1); + + lua_pushstring(L, "fontAlignmentH"); + lua_gettable(L,lo); + outValue->_alignment = lua_isnil(L,-1) ? defaultTextAlignment : (TextHAlignment)(int)lua_tonumber(L,-1); + lua_pop(L,1); + + lua_pushstring(L, "fontAlignmentV"); + lua_gettable(L,lo); + outValue->_vertAlignment = lua_isnil(L,-1) ? defaultTextVAlignment : (TextVAlignment)(int)lua_tonumber(L,-1); + lua_pop(L,1); + + lua_pushstring(L, "fontFillColor"); + lua_gettable(L,lo); + if (!lua_isnil(L,-1)) + { + luaval_to_color3b(L, -1, &outValue->_fontFillColor); + } + lua_pop(L,1); + + lua_pushstring(L, "fontDimensions"); + lua_gettable(L,lo); + if (!lua_isnil(L,-1)) + { + luaval_to_size(L, -1, &outValue->_dimensions); + } + lua_pop(L,1); + + lua_pushstring(L, "shadowEnabled"); + lua_gettable(L,lo); + if (!lua_isnil(L,-1)) + { + luaval_to_boolean(L, -1, &outValue->_shadow._shadowEnabled); + if (outValue->_shadow._shadowEnabled) + { + // default shadow values + outValue->_shadow._shadowOffset = Size(5, 5); + outValue->_shadow._shadowBlur = 1; + outValue->_shadow._shadowOpacity = 1; + } + + lua_pushstring(L, "shadowOffset"); + lua_gettable(L,lo); + if (!lua_isnil(L,-1)) + { + luaval_to_size(L, -1, &outValue->_shadow._shadowOffset); + } + lua_pop(L,1); + + lua_pushstring(L, "shadowBlur"); + lua_gettable(L,lo); + if (!lua_isnil(L,-1)) + { + outValue->_shadow._shadowBlur = (float)lua_tonumber(L,-1); + } + lua_pop(L,1); + + lua_pushstring(L, "shadowOpacity"); + lua_gettable(L,lo); + if (!lua_isnil(L,-1)) + { + outValue->_shadow._shadowOpacity = lua_tonumber(L,-1); + } + lua_pop(L,1); + } + lua_pop(L,1); + + lua_pushstring(L, "strokeEnabled"); + lua_gettable(L,lo); + if (!lua_isnil(L,-1)) + { + luaval_to_boolean(L, -1, &outValue->_stroke._strokeEnabled); + if (outValue->_stroke._strokeEnabled) + { + // default stroke values + outValue->_stroke._strokeSize = 1; + outValue->_stroke._strokeColor = Color3B::BLUE; + + lua_pushstring(L, "strokeColor"); + lua_gettable(L,lo); + if (!lua_isnil(L,-1)) + { + luaval_to_color3b(L, -1, &outValue->_stroke._strokeColor); + } + lua_pop(L,1); + + lua_pushstring(L, "strokeSize"); + lua_gettable(L,lo); + if (!lua_isnil(L,-1)) + { + outValue->_stroke._strokeSize = (float)lua_tonumber(L,-1); + } + lua_pop(L,1); + } + } + lua_pop(L,1); + } + + + return ok; +} + +bool luaval_to_array(lua_State* L,int lo, Array** outValue) +{ + if (NULL == L || NULL == outValue) + return false; + + bool ok = true; +#if COCOS2D_DEBUG >=1 + tolua_Error tolua_err; + if (!tolua_istable(L, lo, 0, &tolua_err) ) + { + luaval_to_native_err(L,"#ferror:",&tolua_err); + ok = false; + } +#endif + + if (ok) + { + size_t len = lua_objlen(L, lo); + if (len > 0) + { + Array* arr = Array::createWithCapacity(len); + if (NULL == arr) + return false; + + for (int i = 0; i < len; i++) + { + lua_pushnumber(L,i + 1); + lua_gettable(L,lo); + if (lua_isnil(L,-1)) + { + lua_pop(L, 1); + continue; + } + + if (lua_isuserdata(L, -1)) + { + Object* obj = static_cast(tolua_tousertype(L, -1, NULL) ); + if (NULL != obj) + { + arr->addObject(obj); + } + } + else if(lua_istable(L, -1)) + { + lua_pushnumber(L,1); + lua_gettable(L,-2); + if (lua_isnil(L, -1) ) + { + lua_pop(L,1); + Dictionary* dictVal = NULL; + if (luaval_to_dictionary(L,-1,&dictVal)) + { + arr->addObject(dictVal); + } + } + else + { + lua_pop(L,1); + Array* arrVal = NULL; + if(luaval_to_array(L, -1, &arrVal)) + { + arr->addObject(arrVal); + } + } + } + else if(lua_isstring(L, -1)) + { + std::string stringValue = ""; + if(luaval_to_std_string(L, -1, &stringValue) ) + { + arr->addObject(String::create(stringValue)); + } + } + else if(lua_isboolean(L, -1)) + { + bool boolVal = false; + if (luaval_to_boolean(L, -1, &boolVal)) + { + arr->addObject(Bool::create(boolVal)); + } + } + else if(lua_isnumber(L, -1)) + { + arr->addObject(Double::create(tolua_tonumber(L, -1, 0))); + } + else + { + CCASSERT(false, "not supported type"); + } + lua_pop(L, 1); + } + + *outValue = arr; + } + } + + return ok; +} + +bool luaval_to_dictionary(lua_State* L,int lo, Dictionary** outValue) +{ + if (NULL == L || NULL == outValue) + return false; + + bool ok = true; +#if COCOS2D_DEBUG >=1 + tolua_Error tolua_err; + if (!tolua_istable(L, lo, 0, &tolua_err) ) + { + luaval_to_native_err(L,"#ferror:",&tolua_err); + ok = false; + } +#endif + + if (ok) + { + std::string stringKey = ""; + std::string stringValue = ""; + bool boolVal = false; + Dictionary* dict = NULL; + lua_pushnil(L); /* L: lotable ..... nil */ + while ( 0 != lua_next(L, lo ) ) /* L: lotable ..... key value */ + { + if (!lua_isstring(L, -2)) + { + lua_pop(L, 1); + continue; + } + + if (NULL == dict) + { + dict = Dictionary::create(); + } + + if(luaval_to_std_string(L, -2, &stringKey)) + { + if (lua_isuserdata(L, -1)) + { + Object* obj = static_cast(tolua_tousertype(L, -1, NULL) ); + if (NULL != obj) + { + //get the key to string + dict->setObject(obj, stringKey); + } + } + else if(lua_istable(L, -1)) + { + lua_pushnumber(L,1); + lua_gettable(L,-2); + if (lua_isnil(L, -1) ) + { + lua_pop(L,1); + Dictionary* dictVal = NULL; + if (luaval_to_dictionary(L,-1,&dictVal)) + { + dict->setObject(dictVal,stringKey); + } + } + else + { + lua_pop(L,1); + Array* arrVal = NULL; + if(luaval_to_array(L, -1, &arrVal)) + { + dict->setObject(arrVal,stringKey); + } + } + } + else if(lua_isstring(L, -1)) + { + if(luaval_to_std_string(L, -2, &stringValue)) + { + dict->setObject(String::create(stringValue), stringKey); + } + } + else if(lua_isboolean(L, -1)) + { + if (luaval_to_boolean(L, -1, &boolVal)) + { + dict->setObject(Bool::create(boolVal),stringKey); + } + } + else if(lua_isnumber(L, -1)) + { + dict->setObject(Double::create(tolua_tonumber(L, -1, 0)),stringKey); + } + else + { + CCASSERT(false, "not supported type"); + } + } + + lua_pop(L, 1); /* L: lotable ..... key */ + } + + /* L: lotable ..... */ + } + + return ok; +} + +void point_to_luaval(lua_State* L,const Point& pt) +{ + if (NULL == L) + return; + lua_newtable(L); /* L: table */ + lua_pushstring(L, "x"); /* L: table key */ + lua_pushnumber(L, (lua_Number) pt.x); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ + lua_pushstring(L, "y"); /* L: table key */ + lua_pushnumber(L, (lua_Number) pt.y); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ +} + +void size_to_luaval(lua_State* L,const Size& sz) +{ + if (NULL == L) + return; + lua_newtable(L); /* L: table */ + lua_pushstring(L, "width"); /* L: table key */ + lua_pushnumber(L, (lua_Number) sz.width); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ + lua_pushstring(L, "height"); /* L: table key */ + lua_pushnumber(L, (lua_Number) sz.height); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ +} + +void rect_to_luaval(lua_State* L,const Rect& rt) +{ + if (NULL == L) + return; + lua_newtable(L); /* L: table */ + lua_pushstring(L, "x"); /* L: table key */ + lua_pushnumber(L, (lua_Number) rt.origin.x); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ + lua_pushstring(L, "y"); /* L: table key */ + lua_pushnumber(L, (lua_Number) rt.origin.y); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ + lua_pushstring(L, "width"); /* L: table key */ + lua_pushnumber(L, (lua_Number) rt.size.width); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ + lua_pushstring(L, "height"); /* L: table key */ + lua_pushnumber(L, (lua_Number) rt.size.height); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ +} + +void color4b_to_luaval(lua_State* L,const Color4B& cc) +{ + if (NULL == L) + return; + lua_newtable(L); /* L: table */ + lua_pushstring(L, "r"); /* L: table key */ + lua_pushnumber(L, (lua_Number) cc.r); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ + lua_pushstring(L, "g"); /* L: table key */ + lua_pushnumber(L, (lua_Number) cc.g); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ + lua_pushstring(L, "b"); /* L: table key */ + lua_pushnumber(L, (lua_Number) cc.b); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ + lua_pushstring(L, "a"); /* L: table key */ + lua_pushnumber(L, (lua_Number) cc.a); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ +} + +void color4f_to_luaval(lua_State* L,const Color4F& cc) +{ + if (NULL == L) + return; + lua_newtable(L); /* L: table */ + lua_pushstring(L, "r"); /* L: table key */ + lua_pushnumber(L, (lua_Number) cc.r); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ + lua_pushstring(L, "g"); /* L: table key */ + lua_pushnumber(L, (lua_Number) cc.g); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ + lua_pushstring(L, "b"); /* L: table key */ + lua_pushnumber(L, (lua_Number) cc.b); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ + lua_pushstring(L, "a"); /* L: table key */ + lua_pushnumber(L, (lua_Number) cc.a); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ +} + +void color3b_to_luaval(lua_State* L,const Color3B& cc) +{ + if (NULL == L) + return; + lua_newtable(L); /* L: table */ + lua_pushstring(L, "r"); /* L: table key */ + lua_pushnumber(L, (lua_Number) cc.r); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ + lua_pushstring(L, "g"); /* L: table key */ + lua_pushnumber(L, (lua_Number) cc.g); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ + lua_pushstring(L, "b"); /* L: table key */ + lua_pushnumber(L, (lua_Number) cc.b); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ +} + +void affinetransform_to_luaval(lua_State* L,const AffineTransform& inValue) +{ + if (NULL == L) + return; + + lua_newtable(L); /* L: table */ + lua_pushstring(L, "a"); /* L: table key */ + lua_pushnumber(L, (lua_Number) inValue.a); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ + lua_pushstring(L, "b"); /* L: table key */ + lua_pushnumber(L, (lua_Number) inValue.b); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ + lua_pushstring(L, "c"); /* L: table key */ + lua_pushnumber(L, (lua_Number) inValue.c); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ + lua_pushstring(L, "d"); /* L: table key */ + lua_pushnumber(L, (lua_Number) inValue.d); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ + lua_pushstring(L, "tx"); /* L: table key */ + lua_pushnumber(L, (lua_Number) inValue.d); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ + lua_pushstring(L, "ty"); /* L: table key */ + lua_pushnumber(L, (lua_Number) inValue.d); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ +} + +void fontdefinition_to_luaval(lua_State* L,const FontDefinition& inValue) +{ + if (NULL == L) + return; + + lua_newtable(L); /* L: table */ + lua_pushstring(L, "fontName"); /* L: table key */ + tolua_pushcppstring(L, inValue._fontName); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ + lua_pushstring(L, "fontSize"); /* L: table key */ + lua_pushnumber(L,(lua_Number)inValue._fontSize); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ + lua_pushstring(L, "fontAlignmentH"); /* L: table key */ + lua_pushnumber(L, (lua_Number) inValue._alignment); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ + lua_pushstring(L, "fontAlignmentV"); /* L: table key */ + lua_pushnumber(L, (lua_Number) inValue._vertAlignment); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ + lua_pushstring(L, "fontFillColor"); /* L: table key */ + color3b_to_luaval(L, inValue._fontFillColor); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ + lua_pushstring(L, "fontDimensions"); /* L: table key */ + size_to_luaval(L, inValue._dimensions); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ + + //Shadow + lua_pushstring(L, "shadowEnabled"); /* L: table key */ + lua_pushboolean(L, inValue._shadow._shadowEnabled); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ + + lua_pushstring(L, "shadowOffset"); /* L: table key */ + size_to_luaval(L, inValue._shadow._shadowOffset); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ + + lua_pushstring(L, "shadowBlur"); /* L: table key */ + lua_pushnumber(L, (lua_Number)inValue._shadow._shadowBlur); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ + + lua_pushstring(L, "shadowOpacity"); /* L: table key */ + lua_pushnumber(L, (lua_Number)inValue._shadow._shadowOpacity); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ + + //Stroke + lua_pushstring(L, "shadowEnabled"); /* L: table key */ + lua_pushboolean(L, inValue._stroke._strokeEnabled); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ + + lua_pushstring(L, "strokeColor"); /* L: table key */ + color3b_to_luaval(L, inValue._stroke._strokeColor); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ + + lua_pushstring(L, "strokeSize"); /* L: table key */ + lua_pushnumber(L, (lua_Number)inValue._stroke._strokeSize); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ +} + +void array_to_luaval(lua_State* L,Array* inValue) +{ + if (NULL == L || NULL == inValue) + return; + + if (0 == inValue->count() ) + return; + + Object* obj = NULL; + lua_newtable(L); + + std::string className = ""; + int pos = 0; + String* strVal = NULL; + Dictionary* dictVal = NULL; + Array* arrVal = NULL; + Double* doubleVal = NULL; + Bool* boolVal = NULL; + Float* floatVal = NULL; + Integer* intVal = NULL; + + CCARRAY_FOREACH(inValue, obj) + { + if (NULL == obj) + continue; + + className = typeid(*obj).name(); + pos = className.rfind(":"); + if (pos > 0 && pos + 1 < className.length() ) + { + className = className.substr(pos + 1, std::string::npos); + + luaL_getmetatable(L, className.c_str()); /* stack: table mt */ + + if (!lua_isnil(L, -1)) + { + lua_pop(L, 1); + tolua_pushusertype(L, (void*)obj, className.c_str()); + } + else + { + lua_pop(L, -1); + if((strVal = dynamic_cast(obj))) + { + lua_pushstring(L, strVal->getCString()); + } + else if ((dictVal = dynamic_cast(obj))) + { + dictionary_to_luaval(L, dictVal); + } + else if ((arrVal = dynamic_cast(obj))) + { + array_to_luaval(L, arrVal); + } + else if ((doubleVal = dynamic_cast(obj))) + { + lua_pushnumber(L, (lua_Number)doubleVal->getValue()); + } + else if ((floatVal = dynamic_cast(obj))) + { + lua_pushnumber(L, (lua_Number)floatVal->getValue()); + } + else if ((intVal = dynamic_cast(obj))) + { + lua_pushinteger(L, (lua_Integer)intVal->getValue()); + } + else if ((boolVal = dynamic_cast(obj))) + { + lua_pushboolean(L, boolVal->getValue()); + } else + { + CCASSERT(false, "the type isn't suppored."); + } + } + } + } +} + +void dictionary_to_luaval(lua_State* L, Dictionary* dict) +{ + if (NULL == L || NULL == dict) + return; + + if (0 == dict->count() ) + return; + + DictElement* element = NULL; + lua_newtable(L); + + std::string className = ""; + int pos = 0; + String* strVal = NULL; + Dictionary* dictVal = NULL; + Array* arrVal = NULL; + Double* doubleVal = NULL; + Bool* boolVal = NULL; + Float* floatVal = NULL; + Integer* intVal = NULL; + Object* obj = NULL; + + CCDICT_FOREACH(dict, element) + { + if (NULL == element) + continue; + + className = typeid(*element).name(); + pos = className.rfind(":"); + if (pos > 0 && pos + 1 < className.length() ) + { + obj = element->getObject(); + if (NULL == obj) + continue; + + className = className.substr(pos + 1, std::string::npos); + + luaL_getmetatable(L, className.c_str()); /* stack: table mt */ + if (!lua_isnil(L, -1)) + { + lua_pop(L, 1); + tolua_pushusertype(L, (void*)obj, className.c_str()); + } + else + { + lua_pop(L, -1); + if((strVal = dynamic_cast(obj))) + { + lua_pushstring(L, element->getStrKey()); + lua_pushstring(L, strVal->getCString()); + lua_rawset(L, -3); + } + else if ((dictVal = dynamic_cast(obj))) + { + dictionary_to_luaval(L, dictVal); + } + else if ((arrVal = dynamic_cast(obj))) + { + array_to_luaval(L, arrVal); + } + else if ((doubleVal = dynamic_cast(obj))) + { + lua_pushstring(L, element->getStrKey()); + lua_pushnumber(L, (lua_Number)doubleVal->getValue()); + lua_rawset(L, -3); + } + else if ((floatVal = dynamic_cast(obj))) + { + lua_pushstring(L, element->getStrKey()); + lua_pushnumber(L, (lua_Number)floatVal->getValue()); + lua_rawset(L, -3); + } + else if ((intVal = dynamic_cast(obj))) + { + lua_pushstring(L, element->getStrKey()); + lua_pushinteger(L, (lua_Integer)intVal->getValue()); + lua_rawset(L, -3); + } + else if ((boolVal = dynamic_cast(obj))) + { + lua_pushstring(L, element->getStrKey()); + lua_pushboolean(L, boolVal->getValue()); + lua_rawset(L, -3); + } + else + { + CCASSERT(false, "the type isn't suppored."); + } + } + } + } +} diff --git a/scripting/lua/cocos2dx_support/LuaBasicConversions.h b/scripting/lua/cocos2dx_support/LuaBasicConversions.h new file mode 100644 index 0000000000..93d868d0e5 --- /dev/null +++ b/scripting/lua/cocos2dx_support/LuaBasicConversions.h @@ -0,0 +1,43 @@ +#ifndef __COCOS2DX_SCRIPTING_LUA_COCOS2DXSUPPORT_LUABAISCCONVERSIONS_H__ +#define __COCOS2DX_SCRIPTING_LUA_COCOS2DXSUPPORT_LUABAISCCONVERSIONS_H__ + +extern "C" { +#include "lua.h" +} + +#include "cocos2d.h" + +using namespace cocos2d; + +// to native +extern bool luaval_to_int32(lua_State* L,int lo,int* outValue); +extern bool luaval_to_uint32(lua_State* L, int lo, unsigned int* outValue); +extern bool luaval_to_uint16(lua_State* L,int lo,uint16_t* outValue); +extern bool luaval_to_boolean(lua_State* L,int lo,bool* outValue); +extern bool luaval_to_number(lua_State* L,int lo,double* outValue); +extern bool luaval_to_long_long(lua_State* L,int lo,long long* outValue); +extern bool luaval_to_std_string(lua_State* L, int lo, std::string* outValue); + +extern bool luaval_to_point(lua_State* L,int lo,Point* outValue); +extern bool luaval_to_size(lua_State* L,int lo,Size* outValue); +extern bool luaval_to_rect(lua_State* L,int lo,Rect* outValue); +extern bool luaval_to_color3b(lua_State* L,int lo,Color3B* outValue); +extern bool luaval_to_color4b(lua_State* L,int lo,Color4B* outValue); +extern bool luaval_to_color4f(lua_State* L,int lo,Color4F* outValue); +extern bool luaval_to_affinetransform(lua_State* L,int lo, AffineTransform* outValue); +extern bool luaval_to_fontdefinition(lua_State* L, int lo, FontDefinition* outValue ); +extern bool luaval_to_array(lua_State* L,int lo, Array** outValue); +extern bool luaval_to_dictionary(lua_State* L,int lo, Dictionary** outValue); + +// from native +extern void point_to_luaval(lua_State* L,const Point& pt); +extern void size_to_luaval(lua_State* L,const Size& sz); +extern void rect_to_luaval(lua_State* L,const Rect& rt); +extern void color3b_to_luaval(lua_State* L,const Color3B& cc); +extern void color4b_to_luaval(lua_State* L,const Color4B& cc); +extern void color4f_to_luaval(lua_State* L,const Color4F& cc); +extern void affinetransform_to_luaval(lua_State* L,const AffineTransform& inValue); +extern void fontdefinition_to_luaval(lua_State* L,const FontDefinition& inValue); +extern void array_to_luaval(lua_State* L,Array* inValue); +extern void dictionary_to_luaval(lua_State* L, Dictionary* dict); +#endif //__COCOS2DX_SCRIPTING_LUA_COCOS2DXSUPPORT_LUABAISCCONVERSIONS_H__ diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id new file mode 100644 index 0000000000..66b5083750 --- /dev/null +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id @@ -0,0 +1 @@ +2ea945aed91dd383cae87a2469493ffac155181c \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.hpp b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.hpp new file mode 100644 index 0000000000..0e1072e343 --- /dev/null +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.hpp @@ -0,0 +1,1790 @@ +#ifndef __cocos2dx_lua_cocos2dx_support_auto_h__ +#define __cocos2dx_lua_cocos2dx_support_auto_h__ + +#ifdef __cplusplus +extern "C" { +#endif +#include "tolua++.h" +#ifdef __cplusplus +} +#endif + +int register_all_cocos2dx(lua_State* tolua_S); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +#endif // #ifndef __cocos2dx_lua_cocos2dx_support_auto_h__ diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id new file mode 100644 index 0000000000..c2cb5d48ee --- /dev/null +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id @@ -0,0 +1 @@ +956ee97030f924b189608e9fce46324b28122bdc \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id new file mode 100644 index 0000000000..a6edf3870b --- /dev/null +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id @@ -0,0 +1 @@ +18780d84936216672ad6abe91769ea1e476708ce \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.hpp b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.hpp new file mode 100644 index 0000000000..e474109b14 --- /dev/null +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.hpp @@ -0,0 +1,260 @@ +#ifndef __cocos2dx_extension_lua_cocos2dx_support_auto_h__ +#define __cocos2dx_extension_lua_cocos2dx_support_auto_h__ + +#ifdef __cplusplus +extern "C" { +#endif +#include "tolua++.h" +#ifdef __cplusplus +} +#endif + +int register_all_cocos2dx_extension(lua_State* tolua_S); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +#endif // #ifndef __cocos2dx_extension_lua_cocos2dx_support_auto_h__ diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto_api.js b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto_api.js new file mode 100644 index 0000000000..7da2e75f17 --- /dev/null +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto_api.js @@ -0,0 +1,1547 @@ +/** + * @module cocos2dx_extension + */ +var cc = cc || {}; + +/** + * @class Control + */ +cc.Control = { + +/** + * @method setEnabled + * @param {bool} + */ +setEnabled : function () {}, + +/** + * @method getState + * @return A value converted from C/C++ "cocos2d::extension::Control::State" + */ +getState : function () {}, + +/** + * @method isTouchInside + * @return A value converted from C/C++ "bool" + * @param {cocos2d::Touch*} + */ +isTouchInside : function () {}, + +/** + * @method sendActionsForControlEvents + * @param {cocos2d::extension::Control::EventType} + */ +sendActionsForControlEvents : function () {}, + +/** + * @method setSelected + * @param {bool} + */ +setSelected : function () {}, + +/** + * @method registerWithTouchDispatcher + */ +registerWithTouchDispatcher : function () {}, + +/** + * @method isEnabled + * @return A value converted from C/C++ "bool" + */ +isEnabled : function () {}, + +/** + * @method setOpacityModifyRGB + * @param {bool} + */ +setOpacityModifyRGB : function () {}, + +/** + * @method needsLayout + */ +needsLayout : function () {}, + +/** + * @method hasVisibleParents + * @return A value converted from C/C++ "bool" + */ +hasVisibleParents : function () {}, + +/** + * @method isSelected + * @return A value converted from C/C++ "bool" + */ +isSelected : function () {}, + +/** + * @method init + * @return A value converted from C/C++ "bool" + */ +init : function () {}, + +/** + * @method setHighlighted + * @param {bool} + */ +setHighlighted : function () {}, + +/** + * @method isOpacityModifyRGB + * @return A value converted from C/C++ "bool" + */ +isOpacityModifyRGB : function () {}, + +/** + * @method getTouchLocation + * @return A value converted from C/C++ "cocos2d::Point" + * @param {cocos2d::Touch*} + */ +getTouchLocation : function () {}, + +/** + * @method isHighlighted + * @return A value converted from C/C++ "bool" + */ +isHighlighted : function () {}, + +/** + * @method create + * @return A value converted from C/C++ "cocos2d::extension::Control*" + */ +create : function () {}, + +/** + * @method Control + * @constructor + */ +Control : function () {}, + +}; + +/** + * @class CCBReader + */ +cc._Reader = { + +/** + * @method addOwnerOutletName + * @param {std::string} + */ +addOwnerOutletName : function () {}, + +/** + * @method getOwnerCallbackNames + * @return A value converted from C/C++ "cocos2d::Array*" + */ +getOwnerCallbackNames : function () {}, + +/** + * @method setCCBRootPath + * @param {const char*} + */ +setCCBRootPath : function () {}, + +/** + * @method addOwnerOutletNode + * @param {cocos2d::Node*} + */ +addOwnerOutletNode : function () {}, + +/** + * @method getOwnerCallbackNodes + * @return A value converted from C/C++ "cocos2d::Array*" + */ +getOwnerCallbackNodes : function () {}, + +/** + * @method readSoundKeyframesForSeq + * @return A value converted from C/C++ "bool" + * @param {cocos2d::extension::CCBSequence*} + */ +readSoundKeyframesForSeq : function () {}, + +/** + * @method getCCBRootPath + * @return A value converted from C/C++ "std::string" + */ +getCCBRootPath : function () {}, + +/** + * @method getOwnerOutletNodes + * @return A value converted from C/C++ "cocos2d::Array*" + */ +getOwnerOutletNodes : function () {}, + +/** + * @method readUTF8 + * @return A value converted from C/C++ "std::string" + */ +readUTF8 : function () {}, + +/** + * @method getOwnerOutletNames + * @return A value converted from C/C++ "cocos2d::Array*" + */ +getOwnerOutletNames : function () {}, + +/** + * @method setAnimationManager + * @param {cocos2d::extension::CCBAnimationManager*} + */ +setAnimationManager : function () {}, + +/** + * @method readCallbackKeyframesForSeq + * @return A value converted from C/C++ "bool" + * @param {cocos2d::extension::CCBSequence*} + */ +readCallbackKeyframesForSeq : function () {}, + +/** + * @method getAnimationManagersForNodes + * @return A value converted from C/C++ "cocos2d::Array*" + */ +getAnimationManagersForNodes : function () {}, + +/** + * @method getNodesWithAnimationManagers + * @return A value converted from C/C++ "cocos2d::Array*" + */ +getNodesWithAnimationManagers : function () {}, + +/** + * @method getAnimationManager + * @return A value converted from C/C++ "cocos2d::extension::CCBAnimationManager*" + */ +getAnimationManager : function () {}, + +/** + * @method setResolutionScale + * @param {float} + */ +setResolutionScale : function () {}, + +}; + +/** + * @class Scale9Sprite + */ +cc.Scale9Sprite = { + +/** + * @method resizableSpriteWithCapInsets + * @return A value converted from C/C++ "cocos2d::extension::Scale9Sprite*" + * @param {cocos2d::Rect} + */ +resizableSpriteWithCapInsets : function () {}, + +/** + * @method setOpacityModifyRGB + * @param {bool} + */ +setOpacityModifyRGB : function () {}, + +/** + * @method setContentSize + * @param {cocos2d::Size} + */ +setContentSize : function () {}, + +/** + * @method setInsetBottom + * @param {float} + */ +setInsetBottom : function () {}, + +/** + * @method isOpacityModifyRGB + * @return A value converted from C/C++ "bool" + */ +isOpacityModifyRGB : function () {}, + +/** + * @method setOpacity + * @param {unsigned char} + */ +setOpacity : function () {}, + +/** + * @method setInsetTop + * @param {float} + */ +setInsetTop : function () {}, + +/** + * @method updateDisplayedOpacity + * @param {unsigned char} + */ +updateDisplayedOpacity : function () {}, + +/** + * @method init + * @return A value converted from C/C++ "bool" + */ +init : function () {}, + +/** + * @method setPreferredSize + * @param {cocos2d::Size} + */ +setPreferredSize : function () {}, + +/** + * @method getOpacity + * @return A value converted from C/C++ "unsigned char" + */ +getOpacity : function () {}, + +/** + * @method setSpriteFrame + * @param {cocos2d::SpriteFrame*} + */ +setSpriteFrame : function () {}, + +/** + * @method getColor + * @return A value converted from C/C++ "cocos2d::Color3B" + */ +getColor : function () {}, + +/** + * @method getInsetBottom + * @return A value converted from C/C++ "float" + */ +getInsetBottom : function () {}, + +/** + * @method getCapInsets + * @return A value converted from C/C++ "cocos2d::Rect" + */ +getCapInsets : function () {}, + +/** + * @method updateWithBatchNode + * @return A value converted from C/C++ "bool" + * @param {cocos2d::SpriteBatchNode*} + * @param {cocos2d::Rect} + * @param {bool} + * @param {cocos2d::Rect} + */ +updateWithBatchNode : function () {}, + +/** + * @method getInsetRight + * @return A value converted from C/C++ "float" + */ +getInsetRight : function () {}, + +/** + * @method getOriginalSize + * @return A value converted from C/C++ "cocos2d::Size" + */ +getOriginalSize : function () {}, + +/** + * @method setColor + * @param {cocos2d::Color3B} + */ +setColor : function () {}, + +/** + * @method getInsetTop + * @return A value converted from C/C++ "float" + */ +getInsetTop : function () {}, + +/** + * @method setInsetLeft + * @param {float} + */ +setInsetLeft : function () {}, + +/** + * @method getPreferredSize + * @return A value converted from C/C++ "cocos2d::Size" + */ +getPreferredSize : function () {}, + +/** + * @method setCapInsets + * @param {cocos2d::Rect} + */ +setCapInsets : function () {}, + +/** + * @method getInsetLeft + * @return A value converted from C/C++ "float" + */ +getInsetLeft : function () {}, + +/** + * @method updateDisplayedColor + * @param {cocos2d::Color3B} + */ +updateDisplayedColor : function () {}, + +/** + * @method setInsetRight + * @param {float} + */ +setInsetRight : function () {}, + +/** + * @method Scale9Sprite + * @constructor + */ +Scale9Sprite : function () {}, + +}; + +/** + * @class ControlButton + */ +cc.ControlButton = { + +/** + * @method setTitleColorDispatchTable + * @param {cocos2d::Dictionary*} + */ +setTitleColorDispatchTable : function () {}, + +/** + * @method isPushed + * @return A value converted from C/C++ "bool" + */ +isPushed : function () {}, + +/** + * @method setSelected + * @param {bool} + */ +setSelected : function () {}, + +/** + * @method setTitleLabelForState + * @param {cocos2d::Node*} + * @param {cocos2d::extension::Control::State} + */ +setTitleLabelForState : function () {}, + +/** + * @method ccTouchBegan + * @return A value converted from C/C++ "bool" + * @param {cocos2d::Touch*} + * @param {Event*} + */ +ccTouchBegan : function () {}, + +/** + * @method setAdjustBackgroundImage + * @param {bool} + */ +setAdjustBackgroundImage : function () {}, + +/** + * @method ccTouchEnded + * @param {cocos2d::Touch*} + * @param {Event*} + */ +ccTouchEnded : function () {}, + +/** + * @method setHighlighted + * @param {bool} + */ +setHighlighted : function () {}, + +/** + * @method setZoomOnTouchDown + * @param {bool} + */ +setZoomOnTouchDown : function () {}, + +/** + * @method setBackgroundSpriteDispatchTable + * @param {cocos2d::Dictionary*} + */ +setBackgroundSpriteDispatchTable : function () {}, + +/** + * @method setTitleForState + * @param {cocos2d::String*} + * @param {cocos2d::extension::Control::State} + */ +setTitleForState : function () {}, + +/** + * @method getTitleDispatchTable + * @return A value converted from C/C++ "cocos2d::Dictionary*" + */ +getTitleDispatchTable : function () {}, + +/** + * @method setLabelAnchorPoint + * @param {cocos2d::Point} + */ +setLabelAnchorPoint : function () {}, + +/** + * @method getPreferredSize + * @return A value converted from C/C++ "cocos2d::Size" + */ +getPreferredSize : function () {}, + +/** + * @method getLabelAnchorPoint + * @return A value converted from C/C++ "cocos2d::Point" + */ +getLabelAnchorPoint : function () {}, + +/** + * @method initWithBackgroundSprite + * @return A value converted from C/C++ "bool" + * @param {cocos2d::extension::Scale9Sprite*} + */ +initWithBackgroundSprite : function () {}, + +/** + * @method getTitleTTFSizeForState + * @return A value converted from C/C++ "float" + * @param {cocos2d::extension::Control::State} + */ +getTitleTTFSizeForState : function () {}, + +/** + * @method setTitleDispatchTable + * @param {cocos2d::Dictionary*} + */ +setTitleDispatchTable : function () {}, + +/** + * @method setOpacity + * @param {unsigned char} + */ +setOpacity : function () {}, + +/** + * @method init + * @return A value converted from C/C++ "bool" + */ +init : function () {}, + +/** + * @method setTitleTTFForState + * @param {const char*} + * @param {cocos2d::extension::Control::State} + */ +setTitleTTFForState : function () {}, + +/** + * @method setTitleTTFSizeForState + * @param {float} + * @param {cocos2d::extension::Control::State} + */ +setTitleTTFSizeForState : function () {}, + +/** + * @method setTitleLabel + * @param {cocos2d::Node*} + */ +setTitleLabel : function () {}, + +/** + * @method ccTouchMoved + * @param {cocos2d::Touch*} + * @param {Event*} + */ +ccTouchMoved : function () {}, + +/** + * @method getOpacity + * @return A value converted from C/C++ "unsigned char" + */ +getOpacity : function () {}, + +/** + * @method getCurrentTitleColor + * @return A value converted from C/C++ "cocos2d::Color3B" + */ +getCurrentTitleColor : function () {}, + +/** + * @method getTitleColorDispatchTable + * @return A value converted from C/C++ "cocos2d::Dictionary*" + */ +getTitleColorDispatchTable : function () {}, + +/** + * @method setEnabled + * @param {bool} + */ +setEnabled : function () {}, + +/** + * @method setBackgroundSprite + * @param {cocos2d::extension::Scale9Sprite*} + */ +setBackgroundSprite : function () {}, + +/** + * @method getBackgroundSpriteForState + * @return A value converted from C/C++ "cocos2d::extension::Scale9Sprite*" + * @param {cocos2d::extension::Control::State} + */ +getBackgroundSpriteForState : function () {}, + +/** + * @method getColor + * @return A value converted from C/C++ "cocos2d::Color3B" + */ +getColor : function () {}, + +/** + * @method setMargins + * @param {int} + * @param {int} + */ +setMargins : function () {}, + +/** + * @method needsLayout + */ +needsLayout : function () {}, + +/** + * @method initWithTitleAndFontNameAndFontSize + * @return A value converted from C/C++ "bool" + * @param {std::string} + * @param {const char*} + * @param {float} + */ +initWithTitleAndFontNameAndFontSize : function () {}, + +/** + * @method getCurrentTitle + * @return A value converted from C/C++ "cocos2d::String*" + */ +getCurrentTitle : function () {}, + +/** + * @method getHorizontalOrigin + * @return A value converted from C/C++ "int" + */ +getHorizontalOrigin : function () {}, + +/** + * @method getTitleTTFForState + * @return A value converted from C/C++ "const char*" + * @param {cocos2d::extension::Control::State} + */ +getTitleTTFForState : function () {}, + +/** + * @method getBackgroundSprite + * @return A value converted from C/C++ "cocos2d::extension::Scale9Sprite*" + */ +getBackgroundSprite : function () {}, + +/** + * @method getTitleColorForState + * @return A value converted from C/C++ "cocos2d::Color3B" + * @param {cocos2d::extension::Control::State} + */ +getTitleColorForState : function () {}, + +/** + * @method setTitleColorForState + * @param {cocos2d::Color3B} + * @param {cocos2d::extension::Control::State} + */ +setTitleColorForState : function () {}, + +/** + * @method doesAdjustBackgroundImage + * @return A value converted from C/C++ "bool" + */ +doesAdjustBackgroundImage : function () {}, + +/** + * @method setBackgroundSpriteFrameForState + * @param {cocos2d::SpriteFrame*} + * @param {cocos2d::extension::Control::State} + */ +setBackgroundSpriteFrameForState : function () {}, + +/** + * @method setBackgroundSpriteForState + * @param {cocos2d::extension::Scale9Sprite*} + * @param {cocos2d::extension::Control::State} + */ +setBackgroundSpriteForState : function () {}, + +/** + * @method setColor + * @param {cocos2d::Color3B} + */ +setColor : function () {}, + +/** + * @method getTitleLabelDispatchTable + * @return A value converted from C/C++ "cocos2d::Dictionary*" + */ +getTitleLabelDispatchTable : function () {}, + +/** + * @method initWithLabelAndBackgroundSprite + * @return A value converted from C/C++ "bool" + * @param {cocos2d::Node*} + * @param {cocos2d::extension::Scale9Sprite*} + */ +initWithLabelAndBackgroundSprite : function () {}, + +/** + * @method setPreferredSize + * @param {cocos2d::Size} + */ +setPreferredSize : function () {}, + +/** + * @method setTitleLabelDispatchTable + * @param {cocos2d::Dictionary*} + */ +setTitleLabelDispatchTable : function () {}, + +/** + * @method getTitleLabel + * @return A value converted from C/C++ "cocos2d::Node*" + */ +getTitleLabel : function () {}, + +/** + * @method ccTouchCancelled + * @param {cocos2d::Touch*} + * @param {Event*} + */ +ccTouchCancelled : function () {}, + +/** + * @method getVerticalMargin + * @return A value converted from C/C++ "int" + */ +getVerticalMargin : function () {}, + +/** + * @method getBackgroundSpriteDispatchTable + * @return A value converted from C/C++ "cocos2d::Dictionary*" + */ +getBackgroundSpriteDispatchTable : function () {}, + +/** + * @method getTitleLabelForState + * @return A value converted from C/C++ "cocos2d::Node*" + * @param {cocos2d::extension::Control::State} + */ +getTitleLabelForState : function () {}, + +/** + * @method setTitleBMFontForState + * @param {const char*} + * @param {cocos2d::extension::Control::State} + */ +setTitleBMFontForState : function () {}, + +/** + * @method getTitleBMFontForState + * @return A value converted from C/C++ "const char*" + * @param {cocos2d::extension::Control::State} + */ +getTitleBMFontForState : function () {}, + +/** + * @method getZoomOnTouchDown + * @return A value converted from C/C++ "bool" + */ +getZoomOnTouchDown : function () {}, + +/** + * @method getTitleForState + * @return A value converted from C/C++ "cocos2d::String*" + * @param {cocos2d::extension::Control::State} + */ +getTitleForState : function () {}, + +/** + * @method ControlButton + * @constructor + */ +ControlButton : function () {}, + +}; + +/** + * @class ScrollView + */ +cc.ScrollView = { + +/** + * @method isClippingToBounds + * @return A value converted from C/C++ "bool" + */ +isClippingToBounds : function () {}, + +/** + * @method setContainer + * @param {cocos2d::Node*} + */ +setContainer : function () {}, + +/** + * @method setContentOffsetInDuration + * @param {cocos2d::Point} + * @param {float} + */ +setContentOffsetInDuration : function () {}, + +/** + * @method setZoomScaleInDuration + * @param {float} + * @param {float} + */ +setZoomScaleInDuration : function () {}, + +/** + * @method ccTouchBegan + * @return A value converted from C/C++ "bool" + * @param {cocos2d::Touch*} + * @param {cocos2d::Event*} + */ +ccTouchBegan : function () {}, + +/** + * @method getContainer + * @return A value converted from C/C++ "cocos2d::Node*" + */ +getContainer : function () {}, + +/** + * @method ccTouchEnded + * @param {cocos2d::Touch*} + * @param {cocos2d::Event*} + */ +ccTouchEnded : function () {}, + +/** + * @method getDirection + * @return A value converted from C/C++ "cocos2d::extension::ScrollView::Direction" + */ +getDirection : function () {}, + +/** + * @method getZoomScale + * @return A value converted from C/C++ "float" + */ +getZoomScale : function () {}, + +/** + * @method updateInset + */ +updateInset : function () {}, + +/** + * @method initWithViewSize + * @return A value converted from C/C++ "bool" + * @param {cocos2d::Size} + * @param {cocos2d::Node*} + */ +initWithViewSize : function () {}, + +/** + * @method pause + * @param {cocos2d::Object*} + */ +pause : function () {}, + +/** + * @method setDirection + * @param {cocos2d::extension::ScrollView::Direction} + */ +setDirection : function () {}, + +/** + * @method setBounceable + * @param {bool} + */ +setBounceable : function () {}, + +/** + * @method setContentOffset + * @param {cocos2d::Point} + * @param {bool} + */ +setContentOffset : function () {}, + +/** + * @method isDragging + * @return A value converted from C/C++ "bool" + */ +isDragging : function () {}, + +/** + * @method init + * @return A value converted from C/C++ "bool" + */ +init : function () {}, + +/** + * @method isBounceable + * @return A value converted from C/C++ "bool" + */ +isBounceable : function () {}, + +/** + * @method getContentSize + * @return A value converted from C/C++ "cocos2d::Size" + */ +getContentSize : function () {}, + +/** + * @method ccTouchMoved + * @param {cocos2d::Touch*} + * @param {cocos2d::Event*} + */ +ccTouchMoved : function () {}, + +/** + * @method setTouchEnabled + * @param {bool} + */ +setTouchEnabled : function () {}, + +/** + * @method getContentOffset + * @return A value converted from C/C++ "cocos2d::Point" + */ +getContentOffset : function () {}, + +/** + * @method resume + * @param {cocos2d::Object*} + */ +resume : function () {}, + +/** + * @method setClippingToBounds + * @param {bool} + */ +setClippingToBounds : function () {}, + +/** + * @method setViewSize + * @param {cocos2d::Size} + */ +setViewSize : function () {}, + +/** + * @method getViewSize + * @return A value converted from C/C++ "cocos2d::Size" + */ +getViewSize : function () {}, + +/** + * @method maxContainerOffset + * @return A value converted from C/C++ "cocos2d::Point" + */ +maxContainerOffset : function () {}, + +/** + * @method setContentSize + * @param {cocos2d::Size} + */ +setContentSize : function () {}, + +/** + * @method isTouchMoved + * @return A value converted from C/C++ "bool" + */ +isTouchMoved : function () {}, + +/** + * @method isNodeVisible + * @return A value converted from C/C++ "bool" + * @param {cocos2d::Node*} + */ +isNodeVisible : function () {}, + +/** + * @method ccTouchCancelled + * @param {cocos2d::Touch*} + * @param {cocos2d::Event*} + */ +ccTouchCancelled : function () {}, + +/** + * @method minContainerOffset + * @return A value converted from C/C++ "cocos2d::Point" + */ +minContainerOffset : function () {}, + +/** + * @method registerWithTouchDispatcher + */ +registerWithTouchDispatcher : function () {}, + +/** + * @method ScrollView + * @constructor + */ +ScrollView : function () {}, + +}; + +/** + * @class CCBAnimationManager + */ +cc.AnimationManager = { + +/** + * @method moveAnimationsFromNode + * @param {cocos2d::Node*} + * @param {cocos2d::Node*} + */ +moveAnimationsFromNode : function () {}, + +/** + * @method setAutoPlaySequenceId + * @param {int} + */ +setAutoPlaySequenceId : function () {}, + +/** + * @method getDocumentCallbackNames + * @return A value converted from C/C++ "cocos2d::Array*" + */ +getDocumentCallbackNames : function () {}, + +/** + * @method actionForSoundChannel + * @return A value converted from C/C++ "cocos2d::Object*" + * @param {cocos2d::extension::CCBSequenceProperty*} + */ +actionForSoundChannel : function () {}, + +/** + * @method setBaseValue + * @param {cocos2d::Object*} + * @param {cocos2d::Node*} + * @param {const char*} + */ +setBaseValue : function () {}, + +/** + * @method getDocumentOutletNodes + * @return A value converted from C/C++ "cocos2d::Array*" + */ +getDocumentOutletNodes : function () {}, + +/** + * @method addNode + * @param {cocos2d::Node*} + * @param {cocos2d::Dictionary*} + */ +addNode : function () {}, + +/** + * @method getLastCompletedSequenceName + * @return A value converted from C/C++ "std::string" + */ +getLastCompletedSequenceName : function () {}, + +/** + * @method setRootNode + * @param {cocos2d::Node*} + */ +setRootNode : function () {}, + +/** + * @method addDocumentOutletName + * @param {std::string} + */ +addDocumentOutletName : function () {}, + +/** + * @method getSequences + * @return A value converted from C/C++ "cocos2d::Array*" + */ +getSequences : function () {}, + +/** + * @method getRootContainerSize + * @return A value converted from C/C++ "cocos2d::Size" + */ +getRootContainerSize : function () {}, + +/** + * @method setDocumentControllerName + * @param {std::string} + */ +setDocumentControllerName : function () {}, + +/** + * @method getContainerSize + * @return A value converted from C/C++ "cocos2d::Size" + * @param {cocos2d::Node*} + */ +getContainerSize : function () {}, + +/** + * @method actionForCallbackChannel + * @return A value converted from C/C++ "cocos2d::Object*" + * @param {cocos2d::extension::CCBSequenceProperty*} + */ +actionForCallbackChannel : function () {}, + +/** + * @method getDocumentOutletNames + * @return A value converted from C/C++ "cocos2d::Array*" + */ +getDocumentOutletNames : function () {}, + +/** + * @method init + * @return A value converted from C/C++ "bool" + */ +init : function () {}, + +/** + * @method getKeyframeCallbacks + * @return A value converted from C/C++ "cocos2d::Array*" + */ +getKeyframeCallbacks : function () {}, + +/** + * @method runAnimationsForSequenceNamedTweenDuration + * @param {const char*} + * @param {float} + */ +runAnimationsForSequenceNamedTweenDuration : function () {}, + +/** + * @method setRootContainerSize + * @param {cocos2d::Size} + */ +setRootContainerSize : function () {}, + +/** + * @method runAnimationsForSequenceIdTweenDuration + * @param {int} + * @param {float} + */ +runAnimationsForSequenceIdTweenDuration : function () {}, + +/** + * @method getRunningSequenceName + * @return A value converted from C/C++ "const char*" + */ +getRunningSequenceName : function () {}, + +/** + * @method getAutoPlaySequenceId + * @return A value converted from C/C++ "int" + */ +getAutoPlaySequenceId : function () {}, + +/** + * @method addDocumentCallbackName + * @param {std::string} + */ +addDocumentCallbackName : function () {}, + +/** + * @method getRootNode + * @return A value converted from C/C++ "cocos2d::Node*" + */ +getRootNode : function () {}, + +/** + * @method addDocumentOutletNode + * @param {cocos2d::Node*} + */ +addDocumentOutletNode : function () {}, + +/** + * @method setDelegate + * @param {cocos2d::extension::CCBAnimationManagerDelegate*} + */ +setDelegate : function () {}, + +/** + * @method addDocumentCallbackNode + * @param {cocos2d::Node*} + */ +addDocumentCallbackNode : function () {}, + +/** + * @method setCallFunc + * @param {cocos2d::CallFunc*} + * @param {std::string} + */ +setCallFunc : function () {}, + +/** + * @method getDelegate + * @return A value converted from C/C++ "cocos2d::extension::CCBAnimationManagerDelegate*" + */ +getDelegate : function () {}, + +/** + * @method runAnimationsForSequenceNamed + * @param {const char*} + */ +runAnimationsForSequenceNamed : function () {}, + +/** + * @method getDocumentCallbackNodes + * @return A value converted from C/C++ "cocos2d::Array*" + */ +getDocumentCallbackNodes : function () {}, + +/** + * @method setSequences + * @param {cocos2d::Array*} + */ +setSequences : function () {}, + +/** + * @method debug + */ +debug : function () {}, + +/** + * @method getDocumentControllerName + * @return A value converted from C/C++ "std::string" + */ +getDocumentControllerName : function () {}, + +/** + * @method CCBAnimationManager + * @constructor + */ +CCBAnimationManager : function () {}, + +}; + +/** + * @class TableViewCell + */ +cc.TableViewCell = { + +/** + * @method reset + */ +reset : function () {}, + +/** + * @method setIdx + * @param {unsigned int} + */ +setIdx : function () {}, + +/** + * @method setObjectID + * @param {unsigned int} + */ +setObjectID : function () {}, + +/** + * @method getObjectID + * @return A value converted from C/C++ "unsigned int" + */ +getObjectID : function () {}, + +/** + * @method getIdx + * @return A value converted from C/C++ "unsigned int" + */ +getIdx : function () {}, + +/** + * @method TableViewCell + * @constructor + */ +TableViewCell : function () {}, + +}; + +/** + * @class TableView + */ +cc.TableView = { + +/** + * @method updateCellAtIndex + * @param {unsigned int} + */ +updateCellAtIndex : function () {}, + +/** + * @method setVerticalFillOrder + * @param {cocos2d::extension::TableView::VerticalFillOrder} + */ +setVerticalFillOrder : function () {}, + +/** + * @method scrollViewDidZoom + * @param {cocos2d::extension::ScrollView*} + */ +scrollViewDidZoom : function () {}, + +/** + * @method ccTouchBegan + * @return A value converted from C/C++ "bool" + * @param {cocos2d::Touch*} + * @param {cocos2d::Event*} + */ +ccTouchBegan : function () {}, + +/** + * @method getVerticalFillOrder + * @return A value converted from C/C++ "cocos2d::extension::TableView::VerticalFillOrder" + */ +getVerticalFillOrder : function () {}, + +/** + * @method removeCellAtIndex + * @param {unsigned int} + */ +removeCellAtIndex : function () {}, + +/** + * @method initWithViewSize + * @return A value converted from C/C++ "bool" + * @param {cocos2d::Size} + * @param {cocos2d::Node*} + */ +initWithViewSize : function () {}, + +/** + * @method scrollViewDidScroll + * @param {cocos2d::extension::ScrollView*} + */ +scrollViewDidScroll : function () {}, + +/** + * @method reloadData + */ +reloadData : function () {}, + +/** + * @method ccTouchCancelled + * @param {cocos2d::Touch*} + * @param {cocos2d::Event*} + */ +ccTouchCancelled : function () {}, + +/** + * @method ccTouchEnded + * @param {cocos2d::Touch*} + * @param {cocos2d::Event*} + */ +ccTouchEnded : function () {}, + +/** + * @method ccTouchMoved + * @param {cocos2d::Touch*} + * @param {cocos2d::Event*} + */ +ccTouchMoved : function () {}, + +/** + * @method _updateContentSize + */ +_updateContentSize : function () {}, + +/** + * @method insertCellAtIndex + * @param {unsigned int} + */ +insertCellAtIndex : function () {}, + +/** + * @method cellAtIndex + * @return A value converted from C/C++ "cocos2d::extension::TableViewCell*" + * @param {unsigned int} + */ +cellAtIndex : function () {}, + +/** + * @method dequeueCell + * @return A value converted from C/C++ "cocos2d::extension::TableViewCell*" + */ +dequeueCell : function () {}, + +/** + * @method TableView + * @constructor + */ +TableView : function () {}, + +}; + +/** + * @class EditBox + */ +cc.EditBox = { + +/** + * @method setAnchorPoint + * @param {cocos2d::Point} + */ +setAnchorPoint : function () {}, + +/** + * @method getText + * @return A value converted from C/C++ "const char*" + */ +getText : function () {}, + +/** + * @method setPlaceholderFontName + * @param {const char*} + */ +setPlaceholderFontName : function () {}, + +/** + * @method getPlaceHolder + * @return A value converted from C/C++ "const char*" + */ +getPlaceHolder : function () {}, + +/** + * @method setFontName + * @param {const char*} + */ +setFontName : function () {}, + +/** + * @method setPlaceholderFontSize + * @param {int} + */ +setPlaceholderFontSize : function () {}, + +/** + * @method setInputMode + * @param {cocos2d::extension::EditBox::InputMode} + */ +setInputMode : function () {}, + +/** + * @method setPlaceholderFontColor + * @param {cocos2d::Color3B} + */ +setPlaceholderFontColor : function () {}, + +/** + * @method setFontColor + * @param {cocos2d::Color3B} + */ +setFontColor : function () {}, + +/** + * @method setPlaceholderFont + * @param {const char*} + * @param {int} + */ +setPlaceholderFont : function () {}, + +/** + * @method setFontSize + * @param {int} + */ +setFontSize : function () {}, + +/** + * @method initWithSizeAndBackgroundSprite + * @return A value converted from C/C++ "bool" + * @param {cocos2d::Size} + * @param {cocos2d::extension::Scale9Sprite*} + */ +initWithSizeAndBackgroundSprite : function () {}, + +/** + * @method setPlaceHolder + * @param {const char*} + */ +setPlaceHolder : function () {}, + +/** + * @method setPosition + * @param {cocos2d::Point} + */ +setPosition : function () {}, + +/** + * @method setReturnType + * @param {cocos2d::extension::EditBox::KeyboardReturnType} + */ +setReturnType : function () {}, + +/** + * @method setInputFlag + * @param {cocos2d::extension::EditBox::InputFlag} + */ +setInputFlag : function () {}, + +/** + * @method getMaxLength + * @return A value converted from C/C++ "int" + */ +getMaxLength : function () {}, + +/** + * @method setText + * @param {const char*} + */ +setText : function () {}, + +/** + * @method setMaxLength + * @param {int} + */ +setMaxLength : function () {}, + +/** + * @method setContentSize + * @param {cocos2d::Size} + */ +setContentSize : function () {}, + +/** + * @method setFont + * @param {const char*} + * @param {int} + */ +setFont : function () {}, + +/** + * @method setVisible + * @param {bool} + */ +setVisible : function () {}, + +/** + * @method create + * @return A value converted from C/C++ "cocos2d::extension::EditBox*" + * @param {cocos2d::Size} + * @param {cocos2d::extension::Scale9Sprite*} + * @param {cocos2d::extension::Scale9Sprite*} + * @param {cocos2d::extension::Scale9Sprite*} + */ +create : function () {}, + +/** + * @method EditBox + * @constructor + */ +EditBox : function () {}, + +}; diff --git a/tools/tolua/userconf.ini b/tools/tolua/userconf.ini new file mode 100644 index 0000000000..8282d99b56 --- /dev/null +++ b/tools/tolua/userconf.ini @@ -0,0 +1,7 @@ +[DEFAULT] +androidndkdir=/Users/cocos2d/MyWork/android/android-ndk-r8e +clangllvmdir=/Users/cocos2d/bin/clang+llvm-3.3 +cocosdir=/Users/cocos2d/MyWork/cocos2d-x +cxxgeneratordir=/Users/cocos2d/MyWork/cocos2d-x/tools/bindings-generator +extra_flags= + From 3d8d0e40eec7326677947e7c63d2691fc583ab66 Mon Sep 17 00:00:00 2001 From: Timothy Qiu Date: Mon, 5 Aug 2013 20:46:57 +0800 Subject: [PATCH 014/126] Fixed broken links and wrong encoding in the doc. Fixed Obj-C names when referening functions. Changed some GB2312 encoded characters to UTF-8. --- extensions/GUI/CCControlExtension/CCControl.h | 4 ++-- .../CCControlSaturationBrightnessPicker.h | 6 +++--- .../GUI/CCControlExtension/CCControlSlider.h | 4 ++-- .../GUI/CCControlExtension/CCScale9Sprite.h | 16 ++++++++-------- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/extensions/GUI/CCControlExtension/CCControl.h b/extensions/GUI/CCControlExtension/CCControl.h index 021ae6d99f..a28d918108 100644 --- a/extensions/GUI/CCControlExtension/CCControl.h +++ b/extensions/GUI/CCControlExtension/CCControl.h @@ -164,7 +164,7 @@ public: * * @param touch A Touch object that represents a touch. * - * @return YES whether a touch is inside the receiver¡¯s rect. + * @return Whether a touch is inside the receiver's rect. */ virtual bool isTouchInside(Touch * touch); @@ -260,4 +260,4 @@ protected: NS_CC_EXT_END -#endif \ No newline at end of file +#endif diff --git a/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.h b/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.h index 07fb821551..9588280311 100644 --- a/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.h +++ b/extensions/GUI/CCControlExtension/CCControlSaturationBrightnessPicker.h @@ -47,9 +47,9 @@ NS_CC_EXT_BEGIN class ControlSaturationBrightnessPicker : public Control { - /** Contains the receiver¡¯s current saturation value. */ + /** Contains the receiver's current saturation value. */ CC_SYNTHESIZE_READONLY(float, _saturation, Saturation); - /** Contains the receiver¡¯s current brightness value. */ + /** Contains the receiver's current brightness value. */ CC_SYNTHESIZE_READONLY(float, _brightness, Brightness); //not sure if these need to be there actually. I suppose someone might want to access the sprite? @@ -88,4 +88,4 @@ protected: NS_CC_EXT_END -#endif \ No newline at end of file +#endif diff --git a/extensions/GUI/CCControlExtension/CCControlSlider.h b/extensions/GUI/CCControlExtension/CCControlSlider.h index 03f55a855f..f477429a62 100644 --- a/extensions/GUI/CCControlExtension/CCControlSlider.h +++ b/extensions/GUI/CCControlExtension/CCControlSlider.h @@ -55,7 +55,7 @@ public: * Creates a slider with a given background sprite and a progress bar and a * thumb item. * - * @see initWithBackgroundSprite:progressSprite:thumbMenuItem: + * @see initWithSprites */ static ControlSlider* create(Sprite * backgroundSprite, Sprite* pogressSprite, Sprite* thumbSprite); @@ -94,7 +94,7 @@ protected: float valueForLocation(Point location); //maunally put in the setters - /** Contains the receiver¡¯s current value. */ + /** Contains the receiver's current value. */ CC_SYNTHESIZE_READONLY(float, _value, Value); /** Contains the minimum value of the receiver. diff --git a/extensions/GUI/CCControlExtension/CCScale9Sprite.h b/extensions/GUI/CCControlExtension/CCScale9Sprite.h index 093101711d..a6bc2df7c3 100644 --- a/extensions/GUI/CCControlExtension/CCScale9Sprite.h +++ b/extensions/GUI/CCControlExtension/CCScale9Sprite.h @@ -63,7 +63,7 @@ public: * Creates a 9-slice sprite with a texture file, a delimitation zone and * with the specified cap insets. * - * @see initWithFile:rect:centerRegion: + * @see initWithFile(const char *file, Rect rect, Rect capInsets) */ static Scale9Sprite* create(const char* file, Rect rect, Rect capInsets); @@ -71,7 +71,7 @@ public: * Creates a 9-slice sprite with a texture file. The whole texture will be * broken down into a 3×3 grid of equal blocks. * - * @see initWithFile:capInsets: + * @see initWithFile(Rect capInsets, const char *file) */ static Scale9Sprite* create(Rect capInsets, const char* file); @@ -79,7 +79,7 @@ public: * Creates a 9-slice sprite with a texture file and a delimitation zone. The * texture will be broken down into a 3×3 grid of equal blocks. * - * @see initWithFile:rect: + * @see initWithFile(const char *file, Rect rect) */ static Scale9Sprite* create(const char* file, Rect rect); @@ -87,7 +87,7 @@ public: * Creates a 9-slice sprite with a texture file. The whole texture will be * broken down into a 3×3 grid of equal blocks. * - * @see initWithFile: + * @see initWithFile(const char *file) */ static Scale9Sprite* create(const char* file); @@ -97,7 +97,7 @@ public: * to resize the sprite will all it's 9-slice goodness intract. * It respects the anchorPoint too. * - * @see initWithSpriteFrame: + * @see initWithSpriteFrame(SpriteFrame *spriteFrame) */ static Scale9Sprite* createWithSpriteFrame(SpriteFrame* spriteFrame); @@ -107,7 +107,7 @@ public: * to resize the sprite will all it's 9-slice goodness intract. * It respects the anchorPoint too. * - * @see initWithSpriteFrame:centerRegion: + * @see initWithSpriteFrame(SpriteFrame *spriteFrame, Rect capInsets) */ static Scale9Sprite* createWithSpriteFrame(SpriteFrame* spriteFrame, Rect capInsets); @@ -117,7 +117,7 @@ public: * to resize the sprite will all it's 9-slice goodness intract. * It respects the anchorPoint too. * - * @see initWithSpriteFrameName: + * @see initWithSpriteFrameName(const char *spriteFrameName) */ static Scale9Sprite* createWithSpriteFrameName(const char*spriteFrameName); @@ -128,7 +128,7 @@ public: * to resize the sprite will all it's 9-slice goodness intract. * It respects the anchorPoint too. * - * @see initWithSpriteFrameName:centerRegion: + * @see initWithSpriteFrameName(const char *spriteFrameName, Rect capInsets) */ static Scale9Sprite* createWithSpriteFrameName(const char*spriteFrameName, Rect capInsets); From 3c394da6a48ce2a6b472860d231ac47aca995688 Mon Sep 17 00:00:00 2001 From: Timothy Qiu Date: Fri, 9 Aug 2013 02:16:52 +0800 Subject: [PATCH 015/126] Changed two 'XXX class for cocos2d for iphone'. --- extensions/GUI/CCScrollView/CCScrollView.h | 2 +- extensions/GUI/CCScrollView/CCTableView.h | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/extensions/GUI/CCScrollView/CCScrollView.h b/extensions/GUI/CCScrollView/CCScrollView.h index cf3c66a45f..886e894f76 100644 --- a/extensions/GUI/CCScrollView/CCScrollView.h +++ b/extensions/GUI/CCScrollView/CCScrollView.h @@ -48,7 +48,7 @@ public: /** - * ScrollView support for cocos2d for iphone. + * ScrollView support for cocos2d-x. * It provides scroll view functionalities to cocos2d projects natively. */ class ScrollView : public Layer diff --git a/extensions/GUI/CCScrollView/CCTableView.h b/extensions/GUI/CCScrollView/CCTableView.h index acbe9359ec..399b6a3e2e 100644 --- a/extensions/GUI/CCScrollView/CCTableView.h +++ b/extensions/GUI/CCScrollView/CCTableView.h @@ -124,10 +124,9 @@ public: /** - * UITableView counterpart for cocos2d for iphone. - * - * this is a very basic, minimal implementation to bring UITableView-like component into cocos2d world. + * UITableView support for cocos2d-x. * + * This is a very basic, minimal implementation to bring UITableView-like component into cocos2d world. */ class TableView : public ScrollView, public ScrollViewDelegate { From 980bea8a97173f61ecf870a71c3d30bf9bfdbf7d Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Fri, 9 Aug 2013 10:07:10 +0800 Subject: [PATCH 016/126] issue #2433:lua binding generator add hello.lua --- .../project.pbxproj.REMOVED.git-id | 2 +- samples/Lua/HelloLua/Resources/hello.lua | 77 +-- scripting/lua/cocos2dx_support/CCLuaStack.cpp | 9 +- .../LuaOpengl.cpp.REMOVED.git-id | 2 +- .../lua_cocos2dx_auto.cpp.REMOVED.git-id | 2 +- .../generated/lua_cocos2dx_auto.hpp | 3 + .../lua_cocos2dx_auto_api.js.REMOVED.git-id | 2 +- ...cocos2dx_extension_auto.cpp.REMOVED.git-id | 2 +- .../generated/lua_cocos2dx_manual.cpp | 513 ++++++++++++++++++ .../generated/lua_cocos2dx_manual.hpp | 14 + tools/tolua/cocos2dx.ini | 3 +- 11 files changed, 585 insertions(+), 44 deletions(-) create mode 100644 scripting/lua/cocos2dx_support/generated/lua_cocos2dx_manual.cpp create mode 100644 scripting/lua/cocos2dx_support/generated/lua_cocos2dx_manual.hpp diff --git a/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id b/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id index 2756f8be75..481819b255 100644 --- a/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -6cf9234888d9a13b8d729d33a5dce7fa795c99ca \ No newline at end of file +99d3caf2720c4bb7bca04c61f70a1f861bc1a698 \ No newline at end of file diff --git a/samples/Lua/HelloLua/Resources/hello.lua b/samples/Lua/HelloLua/Resources/hello.lua index e1224291d1..ea14452160 100644 --- a/samples/Lua/HelloLua/Resources/hello.lua +++ b/samples/Lua/HelloLua/Resources/hello.lua @@ -1,3 +1,7 @@ +cc = cc or {} +function cc.rect(_x,_y,_width,_height) + return { x = _x, y = _y, width = _width, height = _height } +end -- cclog cclog = function(...) print(string.format(...)) @@ -21,8 +25,8 @@ local function main() --------------- - local visibleSize = CCDirector:getInstance():getVisibleSize() - local origin = CCDirector:getInstance():getVisibleOrigin() + local visibleSize = cc.Director:getInstance():getVisibleSize() + local origin = cc.Director:getInstance():getVisibleOrigin() -- add the moving dog local function creatDog() @@ -30,29 +34,31 @@ local function main() local frameHeight = 95 -- create dog animate - local textureDog = CCTextureCache:getInstance():addImage("dog.png") - local rect = CCRect(0, 0, frameWidth, frameHeight) - local frame0 = CCSpriteFrame:createWithTexture(textureDog, rect) - rect = CCRect(frameWidth, 0, frameWidth, frameHeight) - local frame1 = CCSpriteFrame:createWithTexture(textureDog, rect) + local textureDog = cc.TextureCache:getInstance():addImage("dog.png") + local rect = cc.rect(0, 0, frameWidth, frameHeight) + local frame0 = cc.SpriteFrame:createWithTexture(textureDog, rect) + rect = cc.rect(frameWidth, 0, frameWidth, frameHeight) + local frame1 = cc.SpriteFrame:createWithTexture(textureDog, rect) - local spriteDog = CCSprite:createWithSpriteFrame(frame0) + local spriteDog = cc.Sprite:createWithSpriteFrame(frame0) spriteDog.isPaused = false spriteDog:setPosition(origin.x, origin.y + visibleSize.height / 4 * 3) - +--[[ local animFrames = CCArray:create() animFrames:addObject(frame0) animFrames:addObject(frame1) +]]-- - local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.5) - local animate = CCAnimate:create(animation); - spriteDog:runAction(CCRepeatForever:create(animate)) + local animation = cc.Animation:createWithSpriteFrames({frame0,frame1}, 0.5) + local animate = cc.Animate:create(animation); + spriteDog:runAction(cc.RepeatForever:create(animate)) -- moving dog at every frame local function tick() if spriteDog.isPaused then return end - local x, y = spriteDog:getPosition() + local position = spriteDog:getPosition() + local x, y = position.x,position.y if x > origin.x + visibleSize.width then x = origin.x else @@ -62,34 +68,34 @@ local function main() spriteDog:setPositionX(x) end - CCDirector:getInstance():getScheduler():scheduleScriptFunc(tick, 0, false) + cc.Director:getInstance():getScheduler():scheduleScriptFunc(tick, 0, false) return spriteDog end -- create farm local function createLayerFarm() - local layerFarm = CCLayer:create() + local layerFarm = cc.Layer:create() -- add in farm background - local bg = CCSprite:create("farm.jpg") + local bg = cc.Sprite:create("farm.jpg") bg:setPosition(origin.x + visibleSize.width / 2 + 80, origin.y + visibleSize.height / 2) layerFarm:addChild(bg) -- add land sprite for i = 0, 3 do for j = 0, 1 do - local spriteLand = CCSprite:create("land.png") + local spriteLand = cc.Sprite:create("land.png") spriteLand:setPosition(200 + j * 180 - i % 2 * 90, 10 + i * 95 / 2) layerFarm:addChild(spriteLand) end end -- add crop - local frameCrop = CCSpriteFrame:create("crop.png", CCRect(0, 0, 105, 95)) + local frameCrop = cc.SpriteFrame:create("crop.png", cc.rect(0, 0, 105, 95)) for i = 0, 3 do for j = 0, 1 do - local spriteCrop = CCSprite:createWithSpriteFrame(frameCrop); + local spriteCrop = cc.Sprite:createWithSpriteFrame(frameCrop); spriteCrop:setPosition(10 + 200 + j * 180 - i % 2 * 90, 30 + 10 + i * 95 / 2) layerFarm:addChild(spriteCrop) end @@ -113,7 +119,8 @@ local function main() local function onTouchMoved(x, y) cclog("onTouchMoved: %0.2f, %0.2f", x, y) if touchBeginPoint then - local cx, cy = layerFarm:getPosition() + local position = layerFarm:getPosition() + local cx, cy = position.x,position.y layerFarm:setPosition(cx + x - touchBeginPoint.x, cy + y - touchBeginPoint.y) touchBeginPoint = {x = x, y = y} @@ -145,37 +152,37 @@ local function main() -- create menu local function createLayerMenu() - local layerMenu = CCLayer:create() + local layerMenu = cc.Layer:create() local menuPopup, menuTools, effectID local function menuCallbackClosePopup() -- stop test sound effect - SimpleAudioEngine:getInstance():stopEffect(effectID) + cc.SimpleAudioEngine:getInstance():stopEffect(effectID) menuPopup:setVisible(false) end local function menuCallbackOpenPopup() -- loop test sound effect - local effectPath = CCFileUtils:getInstance():fullPathForFilename("effect1.wav") - effectID = SimpleAudioEngine:getInstance():playEffect(effectPath) + local effectPath = cc.FileUtils:getInstance():fullPathForFilename("effect1.wav") + effectID = cc.SimpleAudioEngine:getInstance():playEffect(effectPath) menuPopup:setVisible(true) end -- add a popup menu - local menuPopupItem = CCMenuItemImage:create("menu2.png", "menu2.png") + local menuPopupItem = cc.MenuItemImage:create("menu2.png", "menu2.png") menuPopupItem:setPosition(0, 0) menuPopupItem:registerScriptTapHandler(menuCallbackClosePopup) - menuPopup = CCMenu:createWithItem(menuPopupItem) + menuPopup = cc.Menu:create(menuPopupItem) menuPopup:setPosition(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2) menuPopup:setVisible(false) layerMenu:addChild(menuPopup) - + -- add the left-bottom "tools" menu to invoke menuPopup - local menuToolsItem = CCMenuItemImage:create("menu1.png", "menu1.png") + local menuToolsItem = cc.MenuItemImage:create("menu1.png", "menu1.png") menuToolsItem:setPosition(0, 0) menuToolsItem:registerScriptTapHandler(menuCallbackOpenPopup) - menuTools = CCMenu:createWithItem(menuToolsItem) + menuTools = cc.Menu:create(menuToolsItem) local itemWidth = menuToolsItem:getContentSize().width local itemHeight = menuToolsItem:getContentSize().height menuTools:setPosition(origin.x + itemWidth/2, origin.y + itemHeight/2) @@ -188,16 +195,16 @@ local function main() -- uncomment below for the BlackBerry version -- local bgMusicPath = CCFileUtils:getInstance():fullPathForFilename("background.ogg") - local bgMusicPath = CCFileUtils:getInstance():fullPathForFilename("background.mp3") - SimpleAudioEngine:getInstance():playBackgroundMusic(bgMusicPath, true) - local effectPath = CCFileUtils:getInstance():fullPathForFilename("effect1.wav") - SimpleAudioEngine:getInstance():preloadEffect(effectPath) + local bgMusicPath = cc.FileUtils:getInstance():fullPathForFilename("background.mp3") + cc.SimpleAudioEngine:getInstance():playMusic(bgMusicPath, true) + local effectPath = cc.FileUtils:getInstance():fullPathForFilename("effect1.wav") + cc.SimpleAudioEngine:getInstance():preloadEffect(effectPath) -- run - local sceneGame = CCScene:create() + local sceneGame = cc.Scene:create() sceneGame:addChild(createLayerFarm()) sceneGame:addChild(createLayerMenu()) - CCDirector:getInstance():runWithScene(sceneGame) + cc.Director:getInstance():runWithScene(sceneGame) end xpcall(main, __G__TRACKBACK__) diff --git a/scripting/lua/cocos2dx_support/CCLuaStack.cpp b/scripting/lua/cocos2dx_support/CCLuaStack.cpp index 657904ec10..a99835927b 100644 --- a/scripting/lua/cocos2dx_support/CCLuaStack.cpp +++ b/scripting/lua/cocos2dx_support/CCLuaStack.cpp @@ -46,6 +46,9 @@ extern "C" { #include "LuaOpengl.h" #include "LuaScrollView.h" #include "LuaScriptHandlerMgr.h" +#include "lua_cocos2dx_auto.hpp" +#include "lua_cocos2dx_extension_auto.hpp" +#include "lua_cocos2dx_manual.hpp" namespace { int lua_print(lua_State * luastate) @@ -113,7 +116,7 @@ bool LuaStack::init(void) { _state = lua_open(); luaL_openlibs(_state); - tolua_Cocos2d_open(_state); +// tolua_Cocos2d_open(_state); toluafix_open(_state); // Register our version of the global "print" function @@ -122,7 +125,9 @@ bool LuaStack::init(void) {NULL, NULL} }; luaL_register(_state, "_G", global_functions); - + register_all_cocos2dx(_state); + register_all_cocos2dx_extension(_state); + register_all_cocos2dx_manual(_state); #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) LuaObjcBridge::luaopen_luaoc(_state); #endif diff --git a/scripting/lua/cocos2dx_support/LuaOpengl.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/LuaOpengl.cpp.REMOVED.git-id index a66e8aaade..0d4f20ac67 100644 --- a/scripting/lua/cocos2dx_support/LuaOpengl.cpp.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/LuaOpengl.cpp.REMOVED.git-id @@ -1 +1 @@ -c5e888a17cf2f8757160b2baa5f876b59ddbf89e \ No newline at end of file +db5d393a48a8e12b2a8a0fefef11c4bb7c494d56 \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id index 66b5083750..09c6c03fa3 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id @@ -1 +1 @@ -2ea945aed91dd383cae87a2469493ffac155181c \ No newline at end of file +aa5612e5aef2fe92c3fed272d4de8a072dc1682f \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.hpp b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.hpp index 0e1072e343..e7613ff89a 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.hpp +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.hpp @@ -1783,6 +1783,9 @@ int register_all_cocos2dx(lua_State* tolua_S); + + + diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id index c2cb5d48ee..a8d76d6a7f 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id @@ -1 +1 @@ -956ee97030f924b189608e9fce46324b28122bdc \ No newline at end of file +63d07a801569560e761eb49303c77fdb54e6d57e \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id index a6edf3870b..cb866f3625 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id @@ -1 +1 @@ -18780d84936216672ad6abe91769ea1e476708ce \ No newline at end of file +19d626318d010f941ff497bb509888c194056b85 \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_manual.cpp b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_manual.cpp new file mode 100644 index 0000000000..388eff474b --- /dev/null +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_manual.cpp @@ -0,0 +1,513 @@ +#include "lua_cocos2dx_auto.hpp" + +#ifdef __cplusplus +extern "C" { +#endif +#include "tolua_fix.h" +#ifdef __cplusplus +} +#endif + +#include "cocos2d.h" +#include "LuaBasicConversions.h" +#include "LuaScriptHandlerMgr.h" +#include "CCLuaValue.h" + +static int tolua_cocos2d_MenuItemImage_create(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertable(tolua_S,1,"MenuItemImage",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + do { + if (argc == 0) + { + MenuItemImage* tolua_ret = (MenuItemImage*)MenuItemImage::create(); + //Uncheck + 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,"MenuItemImage"); + return 1; + } + } while (0); + do { +#if COCOS2D_DEBUG >= 1 + if (!tolua_isstring(tolua_S,2,0,&tolua_err) || + !tolua_isstring(tolua_S,3,0,&tolua_err)) + { + ok = false; + } +#endif + if (!ok) + { + ok = true; + break; + } + const char* normalImage = ((const char*) tolua_tostring(tolua_S,2,0)); + const char* selectedImage = ((const char*) tolua_tostring(tolua_S,3,0)); + MenuItemImage* tolua_ret = (MenuItemImage*) MenuItemImage::create(normalImage,selectedImage); + 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,"MenuItemImage"); + return 1; + + } while (0); + do { +#if COCOS2D_DEBUG >= 1 + if (!tolua_isstring(tolua_S,2,0,&tolua_err) || + !tolua_isstring(tolua_S,3,0,&tolua_err) || + !tolua_isstring(tolua_S,4,0,&tolua_err) ) + { + goto tolua_lerror; + break; + } +#endif + const char* normalImage = ((const char*) tolua_tostring(tolua_S,2,0)); + const char* selectedImage = ((const char*) tolua_tostring(tolua_S,3,0)); + const char* disabledImage = ((const char*) tolua_tostring(tolua_S,4,0)); + + MenuItemImage* tolua_ret = (MenuItemImage*) MenuItemImage::create(normalImage,selectedImage,disabledImage); + 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,"MenuItemImage"); + return 1; + + } while (0); + + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Follow_initWithTarget'.\n",&tolua_err); +#endif + return 0; + +} + +static int tolua_cocos2d_Menu_create(lua_State* tolua_S) +{ + int argc = 0; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertable(tolua_S,1,"Menu",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + if (argc > 0 ) + { + cocos2d::Array* array = cocos2d::Array::create(); + if (NULL == array) + { + printf("Menu create method create array fail\n"); + return 0; + } + uint32_t i = 1; + while (i <= argc) + { + if (!tolua_isuserdata(tolua_S, 1 + i, 0, &tolua_err) ) + { + goto tolua_lerror; + return 0; + } + + cocos2d::Object* item = static_cast(tolua_tousertype(tolua_S, 1 + i, NULL)); + if (NULL != item) + { + array->addObject(item); + ++i; + } + + } + cocos2d::Menu* tolua_ret = cocos2d::Menu::createWithArray(array); + //UnCheck + 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; + } + else if(argc == 0) + { + cocos2d::Menu* tolua_ret = cocos2d::Menu::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,"MenuItemImage"); + return 1; + } + + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Follow_initWithTarget'.\n",&tolua_err); +#endif + return 0; +} +//tolua_cocos2d_Menu_create +static int tolua_cocos2d_MenuItem_registerScriptTapHandler(lua_State* tolua_S) +{ + int argc = 0; + MenuItem* cobj = nullptr; +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"MenuItem",0,&tolua_err)) goto tolua_lerror; +#endif + cobj = static_cast(tolua_tousertype(tolua_S,1,0)); +#if COCOS2D_DEBUG >= 1 + if (nullptr == cobj) { + tolua_error(tolua_S,"invalid 'cobj' in function 'tolua_cocos2d_MenuItem_registerScriptTapHandler00'\n", NULL); + return 0; + } +#endif + argc = lua_gettop(tolua_S) - 1; + if (1 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err)) { + goto tolua_lerror; + } +#endif + LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0)); + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)cobj, handler, ScriptHandlerMgr::kMenuClickHandler); + return 0; + } + + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'registerScriptHandler'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2d_MenuItem_unregisterScriptTapHandler(lua_State* tolua_S) +{ + int argc = 0; + MenuItem* cobj = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"MenuItem",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = static_cast(tolua_tousertype(tolua_S,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == cobj) { + tolua_error(tolua_S,"invalid 'cobj' in function 'tolua_cocos2d_MenuItem_unregisterScriptTapHandler00'\n", NULL); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (0 == argc) + { + ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)cobj, ScriptHandlerMgr::kMenuClickHandler); + return 0; + } + + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'unregisterScriptTapHandler'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2d_Layer_registerScriptTouchHandler(lua_State* tolua_S) +{ + int argc = 0; + Layer* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"Layer",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(tolua_S,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Layer_registerScriptTouchHandler'\n", NULL); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc >=1 && argc <= 4) { +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err)) { + goto tolua_lerror; + } +#endif + LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0)); + bool isMultiTouches = false; + int priority = 0; + bool swallowTouches = true; + + if (argc >= 2) { +#if COCOS2D_DEBUG >= 1 + if (!tolua_isboolean(tolua_S,3,0,&tolua_err)) { + goto tolua_lerror; + } +#endif + isMultiTouches = (bool)tolua_toboolean(tolua_S,3,false); + } + + if (argc >= 3) { +#if COCOS2D_DEBUG >= 1 + if (!tolua_isnumber(tolua_S,4,0,&tolua_err)) { + goto tolua_lerror; + } +#endif + priority = (int)tolua_tonumber(tolua_S,4,0); + } + + if (argc == 4) { +#if COCOS2D_DEBUG >= 1 + if (!tolua_isboolean(tolua_S,5,0,&tolua_err)) { + goto tolua_lerror; + } +#endif + swallowTouches = (bool)tolua_toboolean(tolua_S,5,true); + } + + Touch::DispatchMode touchesMode = Touch::DispatchMode::ALL_AT_ONCE; + if (!isMultiTouches) + touchesMode = Touch::DispatchMode::ONE_BY_ONE; + self->setTouchMode(touchesMode); + self->setTouchPriority(priority); + self->setSwallowsTouches(swallowTouches); + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, ScriptHandlerMgr::kTouchesHandler); + return 0; + } + + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'registerScriptTouchHandler'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2d_Layer_unregisterScriptTouchHandler(lua_State* tolua_S) +{ + int argc = 0; + Layer* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"Layer",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(tolua_S,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Layer_unregisterScriptTouchHandler'\n", NULL); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (0 == argc) + { + ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)self, ScriptHandlerMgr::kTouchesHandler); + return 0; + } + + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'unregisterScriptTapHandler'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_cocos2d_Scheduler_scheduleScriptFunc00(lua_State* tolua_S) +{ + int argc = 0; + Scheduler* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"Scheduler",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(tolua_S,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Scheduler_scheduleScriptFunc00'\n", NULL); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + if (3 == argc) { +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isboolean(tolua_S,4,0,&tolua_err)) + { + goto tolua_lerror; + } +#endif + LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0)); + float interval = (float) tolua_tonumber(tolua_S,3,0); + bool paused = (bool) tolua_toboolean(tolua_S,4,0); + unsigned int tolua_ret = (unsigned int) self->scheduleScriptFunc(handler,interval,paused); + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); + return 1; + } + + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 3); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'scheduleScriptFunc'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_cocos2d_Scheduler_unscheduleScriptEntry(lua_State* tolua_S) +{ + int argc = 0; + Scheduler* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"Scheduler",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(tolua_S,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Scheduler_unscheduleScriptEntry'\n", NULL); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + if (1 == argc) { +#if COCOS2D_DEBUG >= 1 + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + { + goto tolua_lerror; + } +#endif + + unsigned int scheduleScriptEntryID = ((unsigned int) tolua_tonumber(tolua_S,2,0)); + self->unscheduleScriptEntry(scheduleScriptEntryID); + return 0; + } + + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'unscheduleScriptEntry'.",&tolua_err); + return 0; +#endif +} + +//void lua_extend_cocos2dx_MenuItem +//{ +// +//} + +int register_all_cocos2dx_manual(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + lua_pushstring(tolua_S,"MenuItem"); + lua_rawget(tolua_S,LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"registerScriptTapHandler"); + lua_pushcfunction(tolua_S,tolua_cocos2d_MenuItem_registerScriptTapHandler); + lua_rawset(tolua_S,-3); + lua_pushstring(tolua_S, "unregisterScriptTapHandler"); + lua_pushcfunction(tolua_S,tolua_cocos2d_MenuItem_unregisterScriptTapHandler); + lua_rawset(tolua_S, -3); + } + + lua_pushstring(tolua_S,"MenuItemImage"); + lua_rawget(tolua_S,LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"create"); + lua_pushcfunction(tolua_S,tolua_cocos2d_MenuItemImage_create); + lua_rawset(tolua_S,-3); + } + + lua_pushstring(tolua_S, "Menu"); + lua_rawget(tolua_S, LUA_REGISTRYINDEX); + if (lua_istable(tolua_S, -1)) + { + lua_pushstring(tolua_S,"create"); + lua_pushcfunction(tolua_S,tolua_cocos2d_Menu_create); + lua_rawset(tolua_S,-3); + } + + lua_pushstring(tolua_S,"Layer"); + lua_rawget(tolua_S,LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"registerScriptTouchHandler"); + lua_pushcfunction(tolua_S,tolua_cocos2d_Layer_registerScriptTouchHandler); + lua_rawset(tolua_S,-3); + lua_pushstring(tolua_S, "unregisterScriptTouchHandler"); + lua_pushcfunction(tolua_S,tolua_Cocos2d_unregisterScriptTouchHandler00); + lua_rawset(tolua_S, -3); +// lua_pushstring(lua_S, "registerScriptKeypadHandler"); +// lua_pushcfunction(lua_S, tolua_Cocos2d_registerScriptKeypadHandler00); +// lua_rawset(lua_S, -3); +// lua_pushstring(lua_S, "unregisterScriptKeypadHandler"); +// lua_pushcfunction(lua_S, tolua_Cocos2d_unregisterScriptKeypadHandler00); +// lua_rawset(lua_S, -3); +// lua_pushstring(lua_S, "registerScriptAccelerateHandler"); +// lua_pushcfunction(lua_S, tolua_Cocos2d_registerScriptAccelerateHandler00); +// lua_rawset(lua_S, -3); +// lua_pushstring(lua_S, "unregisterScriptAccelerateHandler"); +// lua_pushcfunction(lua_S, tolua_Cocos2d_unregisterScriptAccelerateHandler00); +// lua_rawset(lua_S, -3); + } + + lua_pushstring(tolua_S,"Scheduler"); + lua_rawget(tolua_S,LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"scheduleScriptFunc"); + lua_pushcfunction(tolua_S,tolua_cocos2d_Scheduler_scheduleScriptFunc00); + lua_rawset(tolua_S,-3); + lua_pushstring(tolua_S, "unscheduleScriptEntry"); + lua_pushcfunction(tolua_S,tolua_cocos2d_Scheduler_unscheduleScriptEntry); + lua_rawset(tolua_S, -3); + } + return 0; +} \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_manual.hpp b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_manual.hpp new file mode 100644 index 0000000000..8000eaf4b5 --- /dev/null +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_manual.hpp @@ -0,0 +1,14 @@ +#ifndef COCOS2DX_SCRIPT_LUA_COCOS2DX_SUPPORT_GENERATED_LUA_COCOS2DX_MANUAL_H +#define COCOS2DX_SCRIPT_LUA_COCOS2DX_SUPPORT_GENERATED_LUA_COCOS2DX_MANUAL_H + +#ifdef __cplusplus +extern "C" { +#endif +#include "tolua++.h" +#ifdef __cplusplus +} +#endif + +int register_all_cocos2dx_manual(lua_State* tolua_S); + +#endif // #ifndef COCOS2DX_SCRIPT_LUA_COCOS2DX_SUPPORT_GENERATED_LUA_COCOS2DX_MANUAL_H diff --git a/tools/tolua/cocos2dx.ini b/tools/tolua/cocos2dx.ini index 4b4909ae8f..4c2e13a97e 100644 --- a/tools/tolua/cocos2dx.ini +++ b/tools/tolua/cocos2dx.ini @@ -35,7 +35,7 @@ classes = Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* # will apply to all class names. This is a convenience wildcard to be able to skip similar named # functions from all classes. -skip = Node::[^setPosition$ getGrid setGLServerState description getUserObject .*UserData getGLServerState .*schedule], +skip = Node::[getGrid setGLServerState description getUserObject .*UserData getGLServerState .*schedule], Sprite::[getQuad displayFrame getBlendFunc ^setPosition$ setBlendFunc setSpriteBatchNode getSpriteBatchNode], SpriteBatchNode::[getBlendFunc setBlendFunc], MotionStreak::[getBlendFunc setBlendFunc draw update], @@ -82,7 +82,6 @@ skip = Node::[^setPosition$ getGrid setGLServerState description getUserObject . Image::[initWithString initWithImageData], Sequence::[create], Spawn::[create], - Animation::[create], GLProgram::[getProgram setUniformLocationWith2f.* setUniformLocationWith1f.* setUniformLocationWith3f.* setUniformLocationWith4f.*], Grid3DAction::[create actionWith.* vertex originalVertex (g|s)etVertex getOriginalVertex], Grid3D::[vertex originalVertex (g|s)etVertex getOriginalVertex], From 2bb119baef024440250709c92f95f9b120210c5c Mon Sep 17 00:00:00 2001 From: Timothy Qiu Date: Fri, 9 Aug 2013 12:40:20 +0800 Subject: [PATCH 017/126] Documentation & Cocos2d-x C++ Style --- cocos2dx/cocoa/CCAutoreleasePool.cpp | 41 ++++++------ cocos2dx/cocoa/CCAutoreleasePool.h | 96 +++++++++++++++++++++++----- cocos2dx/cocoa/CCObject.cpp | 18 +++--- cocos2dx/cocoa/CCObject.h | 84 ++++++++++++++++++++---- 4 files changed, 180 insertions(+), 59 deletions(-) diff --git a/cocos2dx/cocoa/CCAutoreleasePool.cpp b/cocos2dx/cocoa/CCAutoreleasePool.cpp index a736f316ff..8c360e383a 100644 --- a/cocos2dx/cocoa/CCAutoreleasePool.cpp +++ b/cocos2dx/cocoa/CCAutoreleasePool.cpp @@ -28,31 +28,31 @@ NS_CC_BEGIN static PoolManager* s_pPoolManager = NULL; -AutoreleasePool::AutoreleasePool(void) +AutoreleasePool::AutoreleasePool() { _managedObjectArray = new Array(); _managedObjectArray->init(); } -AutoreleasePool::~AutoreleasePool(void) +AutoreleasePool::~AutoreleasePool() { CC_SAFE_DELETE(_managedObjectArray); } -void AutoreleasePool::addObject(Object* pObject) +void AutoreleasePool::addObject(Object* object) { - _managedObjectArray->addObject(pObject); + _managedObjectArray->addObject(object); - CCASSERT(pObject->_reference > 1, "reference count should be greater than 1"); - ++(pObject->_autoReleaseCount); - pObject->release(); // no ref count, in this case autorelease pool added. + CCASSERT(object->_reference > 1, "reference count should be greater than 1"); + ++(object->_autoReleaseCount); + object->release(); // no ref count, in this case autorelease pool added. } -void AutoreleasePool::removeObject(Object* pObject) +void AutoreleasePool::removeObject(Object* object) { - for (unsigned int i = 0; i < pObject->_autoReleaseCount; ++i) + for (unsigned int i = 0; i < object->_autoReleaseCount; ++i) { - _managedObjectArray->removeObject(pObject, false); + _managedObjectArray->removeObject(object, false); } } @@ -113,14 +113,13 @@ PoolManager::PoolManager() PoolManager::~PoolManager() { - - finalize(); + finalize(); // we only release the last autorelease pool here _curReleasePool = 0; - _releasePoolStack->removeObjectAtIndex(0); + _releasePoolStack->removeObjectAtIndex(0); - CC_SAFE_DELETE(_releasePoolStack); + CC_SAFE_DELETE(_releasePoolStack); } void PoolManager::finalize() @@ -156,12 +155,12 @@ void PoolManager::pop() return; } - int nCount = _releasePoolStack->count(); + int nCount = _releasePoolStack->count(); _curReleasePool->clear(); - if(nCount > 1) - { + if (nCount > 1) + { _releasePoolStack->removeObjectAtIndex(nCount-1); // if(nCount > 1) @@ -175,16 +174,16 @@ void PoolManager::pop() /*_curReleasePool = NULL;*/ } -void PoolManager::removeObject(Object* pObject) +void PoolManager::removeObject(Object* object) { CCASSERT(_curReleasePool, "current auto release pool should not be null"); - _curReleasePool->removeObject(pObject); + _curReleasePool->removeObject(object); } -void PoolManager::addObject(Object* pObject) +void PoolManager::addObject(Object* object) { - getCurReleasePool()->addObject(pObject); + getCurReleasePool()->addObject(object); } diff --git a/cocos2dx/cocoa/CCAutoreleasePool.h b/cocos2dx/cocoa/CCAutoreleasePool.h index c443b2a4b3..2cf6bb839d 100644 --- a/cocos2dx/cocoa/CCAutoreleasePool.h +++ b/cocos2dx/cocoa/CCAutoreleasePool.h @@ -36,36 +36,98 @@ NS_CC_BEGIN class CC_DLL AutoreleasePool : public Object { - Array* _managedObjectArray; + /** + * The underlying array of object managed by the pool. + * + * Although Array retains the object once when an object is added, proper + * Object::release() is called outside the array to make sure that the pool + * does not affect the managed object's reference count. So an object can + * be destructed properly by calling Object::release() even if the object + * is in the pool. + */ + Array *_managedObjectArray; public: - AutoreleasePool(void); - ~AutoreleasePool(void); + AutoreleasePool(); + ~AutoreleasePool(); - void addObject(Object *pObject); - void removeObject(Object *pObject); + /** + * Add a given object to this pool. + * + * The same object may be added several times to the same pool; When the + * pool is destructed, the object's Object::release() method will be called + * for each time it was added. + * + * @param object The object to add to the pool. + */ + void addObject(Object *object); + /** + * Remove a given object from this pool. + * + * @param object The object to be removed from the pool. + */ + void removeObject(Object *object); + + /** + * Clear the autorelease pool. + * + * Object::release() will be called for each time the managed object is + * added to the pool. + */ void clear(); }; class CC_DLL PoolManager { - Array* _releasePoolStack; - AutoreleasePool* _curReleasePool; + Array *_releasePoolStack; + AutoreleasePool *_curReleasePool; - AutoreleasePool* getCurReleasePool(); + AutoreleasePool *getCurReleasePool(); public: - PoolManager(); - ~PoolManager(); - void finalize(); - void push(); - void pop(); - - void removeObject(Object* pObject); - void addObject(Object* pObject); - static PoolManager* sharedPoolManager(); static void purgePoolManager(); + PoolManager(); + ~PoolManager(); + + /** + * Clear all the AutoreleasePool on the pool stack. + */ + void finalize(); + + /** + * Push a new AutoreleasePool to the pool stack. + */ + void push(); + + /** + * Pop one AutoreleasePool from the pool stack. + * + * This method will ensure that there is at least one AutoreleasePool on + * the stack. + * + * The AutoreleasePool being poped is destructed. + */ + void pop(); + + /** + * Remove a given object from the current autorelease pool. + * + * @param object The object to be removed. + * + * @see AutoreleasePool::removeObject + */ + void removeObject(Object *object); + + /** + * Add a given object to the current autorelease pool. + * + * @param object The object to add. + * + * @see AutoreleasePool::addObject + */ + void addObject(Object *object); + friend class AutoreleasePool; }; diff --git a/cocos2dx/cocoa/CCObject.cpp b/cocos2dx/cocoa/CCObject.cpp index fbc1fa9836..d79fa8151f 100644 --- a/cocos2dx/cocoa/CCObject.cpp +++ b/cocos2dx/cocoa/CCObject.cpp @@ -30,7 +30,7 @@ THE SOFTWARE. NS_CC_BEGIN -Object::Object(void) +Object::Object() : _luaID(0) , _reference(1) // when the object is created, the reference count of it is 1 , _autoReleaseCount(0) @@ -40,7 +40,7 @@ Object::Object(void) _ID = ++uObjectCount; } -Object::~Object(void) +Object::~Object() { // if the object is managed, we should remove it // from pool manager @@ -64,7 +64,7 @@ Object::~Object(void) } } -void Object::release(void) +void Object::release() { CCASSERT(_reference > 0, "reference count should greater than 0"); --_reference; @@ -75,32 +75,32 @@ void Object::release(void) } } -void Object::retain(void) +void Object::retain() { CCASSERT(_reference > 0, "reference count should greater than 0"); ++_reference; } -Object* Object::autorelease(void) +Object* Object::autorelease() { PoolManager::sharedPoolManager()->addObject(this); return this; } -bool Object::isSingleReference(void) const +bool Object::isSingleReference() const { return _reference == 1; } -unsigned int Object::retainCount(void) const +unsigned int Object::retainCount() const { return _reference; } -bool Object::isEqual(const Object *pObject) +bool Object::isEqual(const Object *object) { - return this == pObject; + return this == object; } void Object::acceptVisitor(DataVisitor &visitor) diff --git a/cocos2dx/cocoa/CCObject.h b/cocos2dx/cocoa/CCObject.h index a5d7b612cf..b1fe11b7c2 100644 --- a/cocos2dx/cocoa/CCObject.h +++ b/cocos2dx/cocoa/CCObject.h @@ -64,25 +64,85 @@ public: class CC_DLL Object { public: - // object id, ScriptSupport need public _ID + /// object id, ScriptSupport need public _ID unsigned int _ID; - // Lua reference id + /// Lua reference id int _luaID; protected: - // count of references + /// count of references unsigned int _reference; - // count of autorelease + /// count of autorelease unsigned int _autoReleaseCount; public: - Object(void); - virtual ~Object(void); + /** + * Constructor + * + * The object's reference count is 1 after construction. + */ + Object(); + + virtual ~Object(); - void release(void); - void retain(void); - Object* autorelease(void); - bool isSingleReference(void) const; - unsigned int retainCount(void) const; - virtual bool isEqual(const Object* pObject); + /** + * Release the ownership immediately. + * + * This decrements the object's reference count. + * + * If the reference count reaches 0 after the descrement, this object is + * destructed. + * + * @see retain, autorelease + */ + void release(); + + /** + * Retains the ownership. + * + * This increases the object's reference count. + * + * @see release, autorelease + */ + void retain(); + + /** + * Release the ownership sometime soon automatically. + * + * This descrements the object's reference count at the end of current + * autorelease pool block. + * + * If the reference count reaches 0 after the descrement, this object is + * destructed. + * + * @returns The object itself. + * + * @see AutoreleasePool, retain, release + */ + Object* autorelease(); + + /** + * Returns a boolean value that indicates whether there is only one + * reference to the object. That is, whether the reference count is 1. + * + * @returns Whether the object's reference count is 1. + */ + bool isSingleReference() const; + + /** + * Returns the object's current reference count. + * + * @returns The object's reference count. + */ + unsigned int retainCount() const; + + /** + * Returns a boolean value that indicates whether this object and a given + * object are equal. + * + * @param object The object to be compared to this object. + * + * @returns True if this object and @p object are equal, otherwise false. + */ + virtual bool isEqual(const Object* object); virtual void acceptVisitor(DataVisitor &visitor); From 13fd369beb8d058ebfde68538f5ba63376bd140d Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Wed, 14 Aug 2013 21:35:55 +0800 Subject: [PATCH 018/126] issue #2433:Modify lua binding generator template and releated action test --- .../GUI/CCControlExtension/CCControlButton.h | 8 +- samples/Lua/HelloLua/Resources/hello.lua | 5 +- .../ActionManagerTest/ActionManagerTest.lua | 87 +- .../ActionsEaseTest/ActionsEaseTest.lua | 312 ++++--- .../ActionsProgressTest.lua | 265 +++--- .../luaScript/ActionsTest/ActionsTest.lua | 810 ++++++++++-------- .../Resources/luaScript/VisibleRect.lua | 57 +- .../Resources/luaScript/controller.lua | 4 +- .../TestLua/Resources/luaScript/helper.lua | 50 +- .../TestLua/Resources/luaScript/mainMenu.lua | 50 +- .../project.pbxproj.REMOVED.git-id | 2 +- .../lua/cocos2dx_support/CCLuaEngine.cpp | 4 +- scripting/lua/cocos2dx_support/CCLuaStack.cpp | 2 +- .../cocos2dx_support/LuaBasicConversions.cpp | 52 ++ .../cocos2dx_support/LuaBasicConversions.h | 1 + .../LuaOpengl.cpp.REMOVED.git-id | 2 +- .../generated/lua_cocos2dx_manual.cpp | 710 ++++++++++++++- scripting/lua/script/Cocos2d.lua | 28 + scripting/lua/script/Cocos2dConstants.lua | 341 ++++---- scripting/lua/script/Opengl.lua | 2 +- tools/tolua/cocos2dx.ini | 9 +- tools/tolua/cocos2dx_extension.ini | 2 +- 22 files changed, 1841 insertions(+), 962 deletions(-) create mode 100644 scripting/lua/script/Cocos2d.lua diff --git a/extensions/GUI/CCControlExtension/CCControlButton.h b/extensions/GUI/CCControlExtension/CCControlButton.h index db64680113..efe0a68963 100644 --- a/extensions/GUI/CCControlExtension/CCControlButton.h +++ b/extensions/GUI/CCControlExtension/CCControlButton.h @@ -179,10 +179,10 @@ public: virtual void setMargins(int marginH, int marginV); // Overrides - virtual bool ccTouchBegan(Touch *pTouch, cocos2d::Event *pEvent) override; - virtual void ccTouchMoved(Touch *pTouch, cocos2d::Event *pEvent) override; - virtual void ccTouchEnded(Touch *pTouch, cocos2d::Event *pEvent) override; - virtual void ccTouchCancelled(Touch *pTouch, cocos2d::Event *pEvent) override; + virtual bool ccTouchBegan(Touch *pTouch, Event *pEvent) override; + virtual void ccTouchMoved(Touch *pTouch, Event *pEvent) override; + virtual void ccTouchEnded(Touch *pTouch, Event *pEvent) override; + virtual void ccTouchCancelled(Touch *pTouch, Event *pEvent) override; virtual GLubyte getOpacity(void) const override; virtual void setOpacity(GLubyte var) override; virtual const Color3B& getColor(void) const override; diff --git a/samples/Lua/HelloLua/Resources/hello.lua b/samples/Lua/HelloLua/Resources/hello.lua index ea14452160..b6dd2e41d0 100644 --- a/samples/Lua/HelloLua/Resources/hello.lua +++ b/samples/Lua/HelloLua/Resources/hello.lua @@ -1,7 +1,4 @@ -cc = cc or {} -function cc.rect(_x,_y,_width,_height) - return { x = _x, y = _y, width = _width, height = _height } -end +require "Cocos2d" -- cclog cclog = function(...) print(string.format(...)) diff --git a/samples/Lua/TestLua/Resources/luaScript/ActionManagerTest/ActionManagerTest.lua b/samples/Lua/TestLua/Resources/luaScript/ActionManagerTest/ActionManagerTest.lua index 3ef748ffe4..bd1efd53d6 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ActionManagerTest/ActionManagerTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ActionManagerTest/ActionManagerTest.lua @@ -1,7 +1,7 @@ local kTagNode = 0 local kTagGrossini = 1 local kTagSequence = 2 -local scheduler = CCDirector:getInstance():getScheduler() +local scheduler = cc.Director:getInstance():getScheduler() -------------------------------------------------------------------- -- -- Test1 @@ -11,28 +11,33 @@ local scheduler = CCDirector:getInstance():getScheduler() local function CrashTest() local ret = createTestLayer("Test 1. Should not crash") - local child = CCSprite:create(s_pPathGrossini) - child:setPosition( VisibleRect:center() ) + local child = cc.Sprite:create(s_pPathGrossini) + child:setPosition( 200,200 ) ret:addChild(child, 1) --Sum of all action's duration is 1.5 second. - child:runAction(CCRotateBy:create(1.5, 90)) + child:runAction(cc.RotateBy:create(1.5, 90)) + --[[ local arr = CCArray:create() arr:addObject(CCDelayTime:create(1.4)) arr:addObject(CCFadeOut:create(1.1)) - child:runAction(CCSequence:create(arr)) + ]]-- + child:runAction(cc.Sequence:create(cc.DelayTime:create(1.4),cc.FadeOut:create(1.1))) + --[[ arr = CCArray:create() arr:addObject(CCDelayTime:create(1.4)) - + ]]-- local function removeThis() ret:getParent():removeChild(ret, true) Helper.nextAction() end + --[[ local callfunc = CCCallFunc:create(removeThis) arr:addObject(callfunc) + ]]-- --After 1.5 second, self will be removed. - ret:runAction( CCSequence:create(arr)) + ret:runAction( cc.Sequence:create(cc.DelayTime:create(1.4),cc.CallFunc:create(removeThis))) return ret end @@ -44,21 +49,22 @@ end -------------------------------------------------------------------- local function LogicTest() local ret = createTestLayer("Logic test") - local grossini = CCSprite:create(s_pPathGrossini) + local grossini = cc.Sprite:create(s_pPathGrossini) ret:addChild(grossini, 0, 2) - grossini:setPosition(VisibleRect:center()) - + grossini:setPosition(200,200) +--[[ local arr = CCArray:create() arr:addObject(CCMoveBy:create(1, CCPoint(150,0))) - +]]-- local function bugMe(node) node:stopAllActions() --After this stop next action not working, if remove this stop everything is working - node:runAction(CCScaleTo:create(2, 2)) + node:runAction(cc.ScaleTo:create(2, 2)) end - +--[[ local callfunc = CCCallFunc:create(bugMe) arr:addObject(callfunc) - grossini:runAction( CCSequence:create(arr)); +]]-- + grossini:runAction( cc.Sequence:create(cc.MoveBy:create(1, cc.p(150,0)) ,cc.CallFunc:create(bugMe))) return ret end @@ -75,23 +81,24 @@ local function PauseTest() scheduler:unscheduleScriptEntry(schedulerEntry) schedulerEntry = nil local node = ret:getChildByTag( kTagGrossini ) - local pDirector = CCDirector:getInstance() + local pDirector = cc.Director:getInstance() pDirector:getActionManager():resumeTarget(node) end local function onNodeEvent(event) if event == "enter" then - local l = CCLabelTTF:create("After 3 seconds grossini should move", "Thonburi", 16) + local s = cc.Director:getInstance():getWinSize() + local l = cc.LabelTTF:create("After 3 seconds grossini should move", "Thonburi", 16) ret:addChild(l) - l:setPosition( CCPoint(VisibleRect:center().x, VisibleRect:top().y-75) ) + l:setPosition( cc.p(s.width / 2, 245) ) - local grossini = CCSprite:create(s_pPathGrossini) + local grossini = cc.Sprite:create(s_pPathGrossini) ret:addChild(grossini, 0, kTagGrossini) - grossini:setPosition(VisibleRect:center() ) + grossini:setPosition(cc.p(200,200)) - local action = CCMoveBy:create(1, CCPoint(150,0)) + local action = cc.MoveBy:create(1, cc.p(150,0)) - local pDirector = CCDirector:getInstance() + local pDirector = cc.Director:getInstance() pDirector:getActionManager():addAction(action, grossini, true) schedulerEntry = scheduler:scheduleScriptFunc(unpause, 3.0, false) @@ -114,25 +121,28 @@ end -------------------------------------------------------------------- local function RemoveTest() local ret = createTestLayer("Remove Test") - local l = CCLabelTTF:create("Should not crash", "Thonburi", 16) + local l = cc.LabelTTF:create("Should not crash", "Thonburi", 16) + local s = cc.Director:getInstance():getWinSize() ret:addChild(l) - l:setPosition( CCPoint(VisibleRect:center().x, VisibleRect:top().y - 75) ) + l:setPosition( cc.p(s.width / 2, 245)) - local pMove = CCMoveBy:create(2, CCPoint(200, 0)) + local pMove = cc.MoveBy:create(2, cc.p(200, 0)) local function stopAction() local pSprite = ret:getChildByTag(kTagGrossini) pSprite:stopActionByTag(kTagSequence) end - local callfunc = CCCallFunc:create(stopAction) + local callfunc = cc.CallFunc:create(stopAction) + --[[ local arr = CCArray:create() arr:addObject(pMove) arr:addObject(callfunc) - local pSequence = CCSequence:create(arr) + ]]-- + local pSequence = cc.Sequence:create(pMove,callfunc) pSequence:setTag(kTagSequence) - local pChild = CCSprite:create(s_pPathGrossini) - pChild:setPosition( VisibleRect:center() ) + local pChild = cc.Sprite:create(s_pPathGrossini) + pChild:setPosition( 200, 200 ) ret:addChild(pChild, 1, kTagGrossini) pChild:runAction(pSequence) @@ -153,26 +163,27 @@ local function ResumeTest() scheduler:unscheduleScriptEntry(schedulerEntry) schedulerEntry = nil local pGrossini = ret:getChildByTag(kTagGrossini) - local pDirector = CCDirector:getInstance() + local pDirector = cc.Director:getInstance() pDirector:getActionManager():resumeTarget(pGrossini) end local function onNodeEvent(event) if event == "enter" then - local l = CCLabelTTF:create("Grossini only rotate/scale in 3 seconds", "Thonburi", 16) + local l = cc.LabelTTF:create("Grossini only rotate/scale in 3 seconds", "Thonburi", 16) ret:addChild(l) - l:setPosition( CCPoint(VisibleRect:center().x, VisibleRect:top().y - 75)) + local s = cc.Director:getInstance():getWinSize() + l:setPosition( s.width / 2, 245) - local pGrossini = CCSprite:create(s_pPathGrossini) + local pGrossini = cc.Sprite:create(s_pPathGrossini) ret:addChild(pGrossini, 0, kTagGrossini) - pGrossini:setPosition(VisibleRect:center()) + pGrossini:setPosition(200,200) - pGrossini:runAction(CCScaleBy:create(2, 2)) + pGrossini:runAction(cc.ScaleBy:create(2, 2)) - local pDirector = CCDirector:getInstance() + local pDirector = cc.Director:getInstance() pDirector:getActionManager():pauseTarget(pGrossini) - pGrossini:runAction(CCRotateBy:create(2, 360)) + pGrossini:runAction(cc.RotateBy:create(2, 360)) schedulerEntry = scheduler:scheduleScriptFunc(resumeGrossini, 3.0, false) elseif event == "exit" then @@ -191,8 +202,8 @@ end function ActionManagerTestMain() cclog("ActionManagerTestMain") Helper.index = 1 - CCDirector:getInstance():setDepthTest(true) - local scene = CCScene:create() + cc.Director:getInstance():setDepthTest(true) + local scene = cc.Scene:create() Helper.createFunctionTable = { CrashTest, diff --git a/samples/Lua/TestLua/Resources/luaScript/ActionsEaseTest/ActionsEaseTest.lua b/samples/Lua/TestLua/Resources/luaScript/ActionsEaseTest/ActionsEaseTest.lua index b13fe75638..6d5487df7b 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ActionsEaseTest/ActionsEaseTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ActionsEaseTest/ActionsEaseTest.lua @@ -2,37 +2,37 @@ local kTagAction1 = 1 local kTagAction2 = 2 local kTagSlider = 1 -local s = CCDirector:getInstance():getWinSize() -local scheduler = CCDirector:getInstance():getScheduler() +local s = cc.Director:getInstance():getWinSize() +local scheduler = cc.Director:getInstance():getScheduler() local function createSimpleMoveBy() - return CCMoveBy:create(3, CCPoint(s.width - 130, 0)) + return cc.MoveBy:create(3, cc.p(s.width - 130, 0)) end local function createSimpleDelayTime() - return CCDelayTime:create(0.25) + return cc.DelayTime:create(0.25) end local function positionForTwo() - grossini:setPosition(CCPoint(60, s.height * 1 / 5)) - tamara:setPosition(CCPoint(60, s.height * 4 / 5)) + grossini:setPosition(cc.p(60, s.height * 1 / 5)) + tamara:setPosition(cc.p(60, s.height * 4 / 5)) kathia:setVisible(false) end local function getBaseLayer() - local layer = CCLayer:create() + local layer = cc.Layer:create() - grossini = CCSprite:create(s_pPathGrossini) - tamara = CCSprite:create(s_pPathSister1) - kathia = CCSprite:create(s_pPathSister2) + grossini = cc.Sprite:create(s_pPathGrossini) + tamara = cc.Sprite:create(s_pPathSister1) + kathia = cc.Sprite:create(s_pPathSister2) layer:addChild(grossini, 3) layer:addChild(kathia, 2) layer:addChild(tamara, 1) - grossini:setPosition(CCPoint(60, s.height * 1 / 5)) - kathia:setPosition(CCPoint(60, s.height * 2.5 / 5)) - tamara:setPosition(CCPoint(60, s.height * 4 / 5)) + grossini:setPosition(cc.p(60, s.height * 1 / 5)) + kathia:setPosition(cc.p(60, s.height * 2.5 / 5)) + tamara:setPosition(cc.p(60, s.height * 4 / 5)) Helper.initWithLayer(layer) @@ -65,40 +65,43 @@ local function SpriteEase() local move = createSimpleMoveBy() local move_back = move:reverse() - local move_ease_in = CCEaseIn:create(createSimpleMoveBy(), 2.5) + local move_ease_in = cc.EaseIn:create(createSimpleMoveBy(), 2.5) local move_ease_in_back = move_ease_in:reverse() - local move_ease_out = CCEaseOut:create(createSimpleMoveBy(), 2.5) + local move_ease_out = cc.EaseOut:create(createSimpleMoveBy(), 2.5) local move_ease_out_back = move_ease_out:reverse() local delay = createSimpleDelayTime() - +--[[ local arr1 = CCArray:create() arr1:addObject(move) arr1:addObject(delay) arr1:addObject(move_back) arr1:addObject(createSimpleDelayTime()) - local seq1 = CCSequence:create(arr1) - + ]]-- + local seq1 = cc.Sequence:create(move, delay, move_back, createSimpleDelayTime()) +--[[ local arr2 = CCArray:create() arr2:addObject(move_ease_in) arr2:addObject(createSimpleDelayTime()) arr2:addObject(move_ease_in_back) arr2:addObject(createSimpleDelayTime()) - local seq2 = CCSequence:create(arr2) - + ]]-- + local seq2 = cc.Sequence:create(move_ease_in,createSimpleDelayTime(),move_ease_in_back,createSimpleDelayTime()) +--[[ local arr3 = CCArray:create() arr3:addObject(move_ease_out) arr3:addObject(createSimpleDelayTime()) arr3:addObject(move_ease_out_back) arr3:addObject(createSimpleDelayTime()) - local seq3 = CCSequence:create(arr3) + ]]-- + local seq3 = cc.Sequence:create(move_ease_out,createSimpleDelayTime(),move_ease_out_back,createSimpleDelayTime()) - local a2 = grossini:runAction(CCRepeatForever:create(seq1)) + local a2 = grossini:runAction(cc.RepeatForever:create(seq1)) a2:setTag(1) - local a1 = tamara:runAction(CCRepeatForever:create(seq2)) + local a1 = tamara:runAction(cc.RepeatForever:create(seq2)) a1:setTag(1) - local a = kathia:runAction(CCRepeatForever:create(seq3)) + local a = kathia:runAction(cc.RepeatForever:create(seq3)) a:setTag(1) layer:registerScriptHandler(SpriteEase_onEnterOrExit) @@ -115,41 +118,45 @@ local function SpriteEaseInOut() local move = createSimpleMoveBy() - local move_ease_inout1 = CCEaseInOut:create(createSimpleMoveBy(), 0.65) + local move_ease_inout1 = cc.EaseInOut:create(createSimpleMoveBy(), 0.65) local move_ease_inout_back1 = move_ease_inout1:reverse() - local move_ease_inout2 = CCEaseInOut:create(createSimpleMoveBy(), 1.35) + local move_ease_inout2 = cc.EaseInOut:create(createSimpleMoveBy(), 1.35) local move_ease_inout_back2 = move_ease_inout2:reverse() - local move_ease_inout3 = CCEaseInOut:create(createSimpleMoveBy(), 1.0) + local move_ease_inout3 = cc.EaseInOut:create(createSimpleMoveBy(), 1.0) local move_ease_inout_back3 = move_ease_inout3:reverse() local delay = createSimpleDelayTime() - +--[[ local arr1 = CCArray:create() arr1:addObject(move_ease_inout1) arr1:addObject(delay) arr1:addObject(move_ease_inout_back1) arr1:addObject(createSimpleDelayTime()) - local seq1 = CCSequence:create(arr1) + ]]-- + local seq1 = cc.Sequence:create(move_ease_inout1,delay,move_ease_inout_back1,createSimpleDelayTime()) +--[[ local arr2 = CCArray:create() arr2:addObject(move_ease_inout2) arr2:addObject(createSimpleDelayTime()) arr2:addObject(move_ease_inout_back2) arr2:addObject(createSimpleDelayTime()) - local seq2 = CCSequence:create(arr2) - + ]]-- + local seq2 = cc.Sequence:create(move_ease_inout2,createSimpleDelayTime(),move_ease_inout_back2,createSimpleDelayTime()) +--[[ local arr3 = CCArray:create() arr3:addObject(move_ease_inout3) arr3:addObject(createSimpleDelayTime()) arr3:addObject(move_ease_inout_back3) arr3:addObject(createSimpleDelayTime()) - local seq3 = CCSequence:create(arr3) +]]-- + local seq3 = cc.Sequence:create(move_ease_inout3, createSimpleDelayTime(), move_ease_inout_back3, createSimpleDelayTime() ) - tamara:runAction(CCRepeatForever:create(seq1)) - kathia:runAction(CCRepeatForever:create(seq2)) - grossini:runAction(CCRepeatForever:create(seq3)) + tamara:runAction(cc.RepeatForever:create(seq1)) + kathia:runAction(cc.RepeatForever:create(seq2)) + grossini:runAction(cc.RepeatForever:create(seq3)) Helper.titleLabel:setString("EaseInOut and rates") return layer @@ -164,22 +171,24 @@ local function SpriteEaseExponential() local move = createSimpleMoveBy() local move_back = move:reverse() - local move_ease_in = CCEaseExponentialIn:create(createSimpleMoveBy()) + local move_ease_in = cc.EaseExponentialIn:create(createSimpleMoveBy()) local move_ease_in_back = move_ease_in:reverse() - local move_ease_out = CCEaseExponentialOut:create(createSimpleMoveBy()) + local move_ease_out = cc.EaseExponentialOut:create(createSimpleMoveBy()) local move_ease_out_back = move_ease_out:reverse() local delay = createSimpleDelayTime() +--[[ local arr1 = CCArray:create() arr1:addObject(move) arr1:addObject(delay) arr1:addObject(move_back) arr1:addObject(createSimpleDelayTime()) - local seq1 = CCSequence:create(arr1) - +]]-- + local seq1 = cc.Sequence:create(move, delay, move_back, createSimpleDelayTime() ) +--[[ local arr2 = CCArray:create() arr2:addObject(move_ease_in) @@ -187,8 +196,10 @@ local function SpriteEaseExponential() arr2:addObject(move_ease_in_back) arr2:addObject(createSimpleDelayTime()) - local seq2 = CCSequence:create(arr2) + ]]-- + local seq2 = cc.Sequence:create(move_ease_in, createSimpleDelayTime(), move_ease_in_back, createSimpleDelayTime() ) +--[[ local arr3 = CCArray:create() arr3:addObject(move_ease_out) @@ -196,11 +207,12 @@ local function SpriteEaseExponential() arr3:addObject(move_ease_out_back) arr3:addObject(createSimpleDelayTime()) - local seq3 = CCSequence:create(arr3) + ]]-- + local seq3 = cc.Sequence:create(move_ease_out, createSimpleDelayTime(), move_ease_out_back, createSimpleDelayTime() ) - grossini:runAction(CCRepeatForever:create(seq1)) - tamara:runAction(CCRepeatForever:create(seq2)) - kathia:runAction(CCRepeatForever:create(seq3)) + grossini:runAction(cc.RepeatForever:create(seq1)) + tamara:runAction(cc.RepeatForever:create(seq2)) + kathia:runAction(cc.RepeatForever:create(seq3)) Helper.titleLabel:setString("ExpIn - ExpOut actions") return layer @@ -215,19 +227,21 @@ local function SpriteEaseExponentialInOut() local move = createSimpleMoveBy() local move_back = move:reverse() - local move_ease = CCEaseExponentialInOut:create(createSimpleMoveBy()) + local move_ease = cc.EaseExponentialInOut:create(createSimpleMoveBy()) local move_ease_back = move_ease:reverse() local delay = createSimpleDelayTime() - +--[[ local arr1 = CCArray:create() arr1:addObject(move) arr1:addObject(delay) arr1:addObject(move_back) arr1:addObject(createSimpleDelayTime()) - local seq1 = CCSequence:create(arr1) +]]-- + local seq1 = cc.Sequence:create(move, delay, move_back, createSimpleDelayTime()) +--[[ local arr2 = CCArray:create() arr2:addObject(move_ease) @@ -235,12 +249,13 @@ local function SpriteEaseExponentialInOut() arr2:addObject(move_ease_back) arr2:addObject(createSimpleDelayTime()) - local seq2 = CCSequence:create(arr2) + ]]-- + local seq2 = cc.Sequence:create(move_ease, createSimpleDelayTime(), move_ease_back, createSimpleDelayTime() ) positionForTwo() - grossini:runAction(CCRepeatForever:create(seq1)) - tamara:runAction(CCRepeatForever:create(seq2)) + grossini:runAction(cc.RepeatForever:create(seq1)) + tamara:runAction(cc.RepeatForever:create(seq2)) Helper.titleLabel:setString("EaseExponentialInOut action") return layer @@ -255,38 +270,41 @@ local function SpriteEaseSine() local move = createSimpleMoveBy() local move_back = move:reverse() - local move_ease_in = CCEaseSineIn:create(createSimpleMoveBy()) + local move_ease_in = cc.EaseSineIn:create(createSimpleMoveBy()) local move_ease_in_back = move_ease_in:reverse() - local move_ease_out = CCEaseSineOut:create(createSimpleMoveBy()) + local move_ease_out = cc.EaseSineOut:create(createSimpleMoveBy()) local move_ease_out_back = move_ease_out:reverse() local delay = createSimpleDelayTime() - +--[[ local arr1 = CCArray:create() arr1:addObject(move) arr1:addObject(delay) arr1:addObject(move_back) arr1:addObject(createSimpleDelayTime()) - local seq1 = CCSequence:create(arr1) - + ]]-- + local seq1 = cc.Sequence:create(move, delay, move_back, createSimpleDelayTime() ) +--[[ local arr2 = CCArray:create() arr2:addObject(move_ease_in) arr2:addObject(createSimpleDelayTime()) arr2:addObject(move_ease_in_back) arr2:addObject(createSimpleDelayTime()) - local seq2 = CCSequence:create(arr2) - + ]]-- + local seq2 = cc.Sequence:create(move_ease_in, createSimpleDelayTime(), move_ease_in_back, createSimpleDelayTime() ) +--[[ local arr3 = CCArray:create() arr3:addObject(move_ease_out) arr3:addObject(createSimpleDelayTime()) arr3:addObject(move_ease_out_back) arr3:addObject(createSimpleDelayTime()) - local seq3 = CCSequence:create(arr3) + ]]-- + local seq3 = cc.Sequence:create(move_ease_out, createSimpleDelayTime(), move_ease_out_back,createSimpleDelayTime() ) - grossini:runAction(CCRepeatForever:create(seq1)) - tamara:runAction(CCRepeatForever:create(seq2)) - kathia:runAction(CCRepeatForever:create(seq3)) + grossini:runAction(cc.RepeatForever:create(seq1)) + tamara:runAction(cc.RepeatForever:create(seq2)) + kathia:runAction(cc.RepeatForever:create(seq3)) Helper.titleLabel:setString("EaseSineIn - EaseSineOut") return layer @@ -301,29 +319,31 @@ local function SpriteEaseSineInOut() local move = createSimpleMoveBy() local move_back = move:reverse() - local move_ease = CCEaseSineInOut:create(createSimpleMoveBy()) + local move_ease = cc.EaseSineInOut:create(createSimpleMoveBy()) local move_ease_back = move_ease:reverse() local delay = createSimpleDelayTime() - +--[[ local arr1 = CCArray:create() arr1:addObject(move) arr1:addObject(delay) arr1:addObject(move_back) arr1:addObject(createSimpleDelayTime()) - local seq1 = CCSequence:create(arr1) - + ]]-- + local seq1 = cc.Sequence:create(move, delay, move_back, createSimpleDelayTime() ) +--[[ local arr2 = CCArray:create() arr2:addObject(move_ease) arr2:addObject(createSimpleDelayTime()) arr2:addObject(move_ease_back) arr2:addObject(createSimpleDelayTime()) - local seq2 = CCSequence:create(arr2) + ]]-- + local seq2 = cc.Sequence:create(move_ease, createSimpleDelayTime(), move_ease_back, createSimpleDelayTime()) positionForTwo() - grossini:runAction(CCRepeatForever:create(seq1)) - tamara:runAction(CCRepeatForever:create(seq2)) + grossini:runAction(cc.RepeatForever:create(seq1)) + tamara:runAction(cc.RepeatForever:create(seq2)) Helper.titleLabel:setString("EaseSineInOut action") return layer @@ -338,38 +358,41 @@ local function SpriteEaseElastic() local move = createSimpleMoveBy() local move_back = move:reverse() - local move_ease_in = CCEaseElasticIn:create(createSimpleMoveBy()) + local move_ease_in = cc.EaseElasticIn:create(createSimpleMoveBy()) local move_ease_in_back = move_ease_in:reverse() - local move_ease_out = CCEaseElasticOut:create(createSimpleMoveBy()) + local move_ease_out = cc.EaseElasticOut:create(createSimpleMoveBy()) local move_ease_out_back = move_ease_out:reverse() local delay = createSimpleDelayTime() - +--[[ local arr1 = CCArray:create() arr1:addObject(move) arr1:addObject(delay) arr1:addObject(move_back) arr1:addObject(createSimpleDelayTime()) - local seq1 = CCSequence:create(arr1) - + ]]-- + local seq1 = cc.Sequence:create(move, delay, move_back, createSimpleDelayTime() ) +--[[ local arr2 = CCArray:create() arr2:addObject(move_ease_in) arr2:addObject(createSimpleDelayTime()) arr2:addObject(move_ease_in_back) arr2:addObject(createSimpleDelayTime()) - local seq2 = CCSequence:create(arr2) - + ]]-- + local seq2 = cc.Sequence:create(move_ease_in, createSimpleDelayTime(), move_ease_in_back, createSimpleDelayTime()) +--[[ local arr3 = CCArray:create() arr3:addObject(move_ease_out) arr3:addObject(createSimpleDelayTime()) arr3:addObject(move_ease_out_back) arr3:addObject(createSimpleDelayTime()) - local seq3 = CCSequence:create(arr3) + ]]-- + local seq3 = cc.Sequence:create(move_ease_out, createSimpleDelayTime(), move_ease_out_back, createSimpleDelayTime()) - grossini:runAction(CCRepeatForever:create(seq1)) - tamara:runAction(CCRepeatForever:create(seq2)) - kathia:runAction(CCRepeatForever:create(seq3)) + grossini:runAction(cc.RepeatForever:create(seq1)) + tamara:runAction(cc.RepeatForever:create(seq2)) + kathia:runAction(cc.RepeatForever:create(seq3)) Helper.titleLabel:setString("Elastic In - Out actions") return layer @@ -383,41 +406,44 @@ local function SpriteEaseElasticInOut() local move = createSimpleMoveBy() - local move_ease_inout1 = CCEaseElasticInOut:create(createSimpleMoveBy(), 0.3) + local move_ease_inout1 = cc.EaseElasticInOut:create(createSimpleMoveBy(), 0.3) local move_ease_inout_back1 = move_ease_inout1:reverse() - local move_ease_inout2 = CCEaseElasticInOut:create(createSimpleMoveBy(), 0.45) + local move_ease_inout2 = cc.EaseElasticInOut:create(createSimpleMoveBy(), 0.45) local move_ease_inout_back2 = move_ease_inout2:reverse() - local move_ease_inout3 = CCEaseElasticInOut:create(createSimpleMoveBy(), 0.6) + local move_ease_inout3 = cc.EaseElasticInOut:create(createSimpleMoveBy(), 0.6) local move_ease_inout_back3 = move_ease_inout3:reverse() local delay = createSimpleDelayTime() - +--[[ local arr1 = CCArray:create() arr1:addObject(move_ease_inout1) arr1:addObject(delay) arr1:addObject(move_ease_inout_back1) arr1:addObject(createSimpleDelayTime()) - local seq1 = CCSequence:create(arr1) - + ]]-- + local seq1 = cc.Sequence:create(move_ease_inout1, delay, move_ease_inout_back1, createSimpleDelayTime()) +--[[ local arr2 = CCArray:create() arr2:addObject(move_ease_inout2) arr2:addObject(createSimpleDelayTime()) arr2:addObject(move_ease_inout_back2) arr2:addObject(createSimpleDelayTime()) - local seq2 = CCSequence:create(arr2) - + ]]-- + local seq2 = cc.Sequence:create(move_ease_inout2, createSimpleDelayTime(), move_ease_inout_back2, createSimpleDelayTime()) +--[[ local arr3 = CCArray:create() arr3:addObject(move_ease_inout3) arr3:addObject(createSimpleDelayTime()) arr3:addObject(move_ease_inout_back3) arr3:addObject(createSimpleDelayTime()) - local seq3 = CCSequence:create(arr3) + ]]-- + local seq3 = cc.Sequence:create(move_ease_inout3, createSimpleDelayTime(), move_ease_inout_back3, createSimpleDelayTime()) - tamara:runAction(CCRepeatForever:create(seq1)) - kathia:runAction(CCRepeatForever:create(seq2)) - grossini:runAction(CCRepeatForever:create(seq3)) + tamara:runAction(cc.RepeatForever:create(seq1)) + kathia:runAction(cc.RepeatForever:create(seq2)) + grossini:runAction(cc.RepeatForever:create(seq3)) Helper.titleLabel:setString("EaseElasticInOut action") return layer @@ -432,38 +458,41 @@ local function SpriteEaseBounce() local move = createSimpleMoveBy() local move_back = move:reverse() - local move_ease_in = CCEaseBounceIn:create(createSimpleMoveBy()) + local move_ease_in = cc.EaseBounceIn:create(createSimpleMoveBy()) local move_ease_in_back = move_ease_in:reverse() - local move_ease_out = CCEaseBounceOut:create(createSimpleMoveBy()) + local move_ease_out = cc.EaseBounceOut:create(createSimpleMoveBy()) local move_ease_out_back = move_ease_out:reverse() local delay = createSimpleDelayTime() - +--[[ local arr1 = CCArray:create() arr1:addObject(move) arr1:addObject(delay) arr1:addObject(move_back) arr1:addObject(createSimpleDelayTime()) - local seq1 = CCSequence:create(arr1) - + ]]-- + local seq1 = cc.Sequence:create(move, delay, move_back, createSimpleDelayTime() ) +--[[ local arr2 = CCArray:create() arr2:addObject(move_ease_in) arr2:addObject(createSimpleDelayTime()) arr2:addObject(move_ease_in_back) arr2:addObject(createSimpleDelayTime()) - local seq2 = CCSequence:create(arr2) - + ]]-- + local seq2 = cc.Sequence:create(move_ease_in, createSimpleDelayTime(), move_ease_in_back, createSimpleDelayTime() ) +--[[ local arr3 = CCArray:create() arr3:addObject(move_ease_out) arr3:addObject(createSimpleDelayTime()) arr3:addObject(move_ease_out_back) arr3:addObject(createSimpleDelayTime()) - local seq3 = CCSequence:create(arr3) + ]]-- + local seq3 = cc.Sequence:create(move_ease_out, createSimpleDelayTime(), move_ease_out_back, createSimpleDelayTime()) - grossini:runAction(CCRepeatForever:create(seq1)) - tamara:runAction(CCRepeatForever:create(seq2)) - kathia:runAction(CCRepeatForever:create(seq3)) + grossini:runAction(cc.RepeatForever:create(seq1)) + tamara:runAction(cc.RepeatForever:create(seq2)) + kathia:runAction(cc.RepeatForever:create(seq3)) Helper.titleLabel:setString("Bounce In - Out actions") return layer @@ -478,29 +507,31 @@ local function SpriteEaseBounceInOut() local move = createSimpleMoveBy() local move_back = move:reverse() - local move_ease = CCEaseBounceInOut:create(createSimpleMoveBy()) + local move_ease = cc.EaseBounceInOut:create(createSimpleMoveBy()) local move_ease_back = move_ease:reverse() local delay = createSimpleDelayTime() - +--[[ local arr1 = CCArray:create() arr1:addObject(move) arr1:addObject(delay) arr1:addObject(move_back) arr1:addObject(createSimpleDelayTime()) - local seq1 = CCSequence:create(arr1) - + ]]-- + local seq1 = cc.Sequence:create(move, delay, move_back, createSimpleDelayTime()) +--[[ local arr2 = CCArray:create() arr2:addObject(move_ease) arr2:addObject(createSimpleDelayTime()) arr2:addObject(move_ease_back) arr2:addObject(createSimpleDelayTime()) - local seq2 = CCSequence:create(arr2) + ]]-- + local seq2 = cc.Sequence:create(move_ease, createSimpleDelayTime(), move_ease_back, createSimpleDelayTime()) positionForTwo() - grossini:runAction(CCRepeatForever:create(seq1)) - tamara:runAction(CCRepeatForever:create(seq2)) + grossini:runAction(cc.RepeatForever:create(seq1)) + tamara:runAction(cc.RepeatForever:create(seq2)) Helper.titleLabel:setString("EaseBounceInOut action") return layer @@ -515,38 +546,41 @@ local function SpriteEaseBack() local move = createSimpleMoveBy() local move_back = move:reverse() - local move_ease_in = CCEaseBackIn:create(createSimpleMoveBy()) + local move_ease_in = cc.EaseBackIn:create(createSimpleMoveBy()) local move_ease_in_back = move_ease_in:reverse() - local move_ease_out = CCEaseBackOut:create(createSimpleMoveBy()) + local move_ease_out = cc.EaseBackOut:create(createSimpleMoveBy()) local move_ease_out_back = move_ease_out:reverse() local delay = createSimpleDelayTime() - +--[[ local arr1 = CCArray:create() arr1:addObject(move) arr1:addObject(delay) arr1:addObject(move_back) arr1:addObject(createSimpleDelayTime()) - local seq1 = CCSequence:create(arr1) - + ]]-- + local seq1 = cc.Sequence:create(move, delay, move_back, createSimpleDelayTime()) +--[[ local arr2 = CCArray:create() arr2:addObject(move_ease_in) arr2:addObject(createSimpleDelayTime()) arr2:addObject(move_ease_in_back) arr2:addObject(createSimpleDelayTime()) - local seq2 = CCSequence:create(arr2) - + ]]-- + local seq2 = cc.Sequence:create(move_ease_in, createSimpleDelayTime(), move_ease_in_back, createSimpleDelayTime()) +--[[ local arr3 = CCArray:create() arr3:addObject(move_ease_out) arr3:addObject(createSimpleDelayTime()) arr3:addObject(move_ease_out_back) arr3:addObject(createSimpleDelayTime()) - local seq3 = CCSequence:create(arr3) + ]]-- + local seq3 = cc.Sequence:create(move_ease_out, createSimpleDelayTime(), move_ease_out_back, createSimpleDelayTime()) - grossini:runAction(CCRepeatForever:create(seq1)) - tamara:runAction(CCRepeatForever:create(seq2)) - kathia:runAction(CCRepeatForever:create(seq3)) + grossini:runAction(cc.RepeatForever:create(seq1)) + tamara:runAction(cc.RepeatForever:create(seq2)) + kathia:runAction(cc.RepeatForever:create(seq3)) Helper.titleLabel:setString("Back In - Out actions") return layer @@ -561,29 +595,31 @@ local function SpriteEaseBackInOut() local move = createSimpleMoveBy() local move_back = move:reverse() - local move_ease = CCEaseBackInOut:create(createSimpleMoveBy()) + local move_ease = cc.EaseBackInOut:create(createSimpleMoveBy()) local move_ease_back = move_ease:reverse() local delay = createSimpleDelayTime() - +--[[ local arr1 = CCArray:create() arr1:addObject(move) arr1:addObject(delay) arr1:addObject(move_back) arr1:addObject(createSimpleDelayTime()) - local seq1 = CCSequence:create(arr1) - + ]]-- + local seq1 = cc.Sequence:create(move, delay, move_back, createSimpleDelayTime()) +--[[ local arr2 = CCArray:create() arr2:addObject(move_ease) arr2:addObject(createSimpleDelayTime()) arr2:addObject(move_ease_back) arr2:addObject(createSimpleDelayTime()) - local seq2 = CCSequence:create(arr2) + ]]-- + local seq2 = cc.Sequence:create(move_ease,createSimpleDelayTime(), move_ease_back, createSimpleDelayTime()) positionForTwo() - grossini:runAction(CCRepeatForever:create(seq1)) - tamara:runAction(CCRepeatForever:create(seq2)) + grossini:runAction(cc.RepeatForever:create(seq1)) + tamara:runAction(cc.RepeatForever:create(seq2)) Helper.titleLabel:setString("EaseBackInOut action") return layer @@ -614,22 +650,22 @@ end local function SpeedTest() local layer = getBaseLayer() - local jump1 = CCJumpBy:create(4, CCPoint(- s.width + 80, 0), 100, 4) + local jump1 = cc.JumpBy:create(4, cc.p(- s.width + 80, 0), 100, 4) local jump2 = jump1:reverse() - local rot1 = CCRotateBy:create(4, 360 * 2) + local rot1 = cc.RotateBy:create(4, 360 * 2) local rot2 = rot1:reverse() - local seq3_1 = CCSequence:createWithTwoActions(jump2, jump1) - local seq3_2 = CCSequence:createWithTwoActions(rot1, rot2) + local seq3_1 = cc.Sequence:create(jump2, jump1) + local seq3_2 = cc.Sequence:create(rot1, rot2) - local spawn = CCSpawn:createWithTwoActions(seq3_1, seq3_2) - SpeedTest_action1 = CCSpeed:create(CCRepeatForever:create(spawn), 1.0) + local spawn = cc.Spawn:create(seq3_1, seq3_2) + SpeedTest_action1 = cc.Speed:create(cc.RepeatForever:create(spawn), 1.0) - local spawn2 = tolua.cast(spawn:clone(), "CCSpawn") - SpeedTest_action2 = CCSpeed:create(CCRepeatForever:create(spawn2), 1.0) + local spawn2 = tolua.cast(spawn:clone(), "Spawn") + SpeedTest_action2 = cc.Speed:create(cc.RepeatForever:create(spawn2), 1.0) - local spawn3 = tolua.cast(spawn:clone(), "CCSpawn") - SpeedTest_action3 = CCSpeed:create(CCRepeatForever:create(spawn3), 1.0) + local spawn3 = tolua.cast(spawn:clone(), "Spawn") + SpeedTest_action3 = cc.Speed:create(cc.RepeatForever:create(spawn3), 1.0) grossini:runAction(SpeedTest_action2) tamara:runAction(SpeedTest_action3) @@ -642,7 +678,7 @@ local function SpeedTest() end function EaseActionsTest() - local scene = CCScene:create() + local scene = cc.Scene:create() cclog("EaseActionsTest") Helper.createFunctionTable = { diff --git a/samples/Lua/TestLua/Resources/luaScript/ActionsProgressTest/ActionsProgressTest.lua b/samples/Lua/TestLua/Resources/luaScript/ActionsProgressTest/ActionsProgressTest.lua index 392ca18048..ec1db2e6d1 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ActionsProgressTest/ActionsProgressTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ActionsProgressTest/ActionsProgressTest.lua @@ -1,28 +1,28 @@ -local s = CCDirector:getInstance():getWinSize() +local s = cc.Director:getInstance():getWinSize() ------------------------------------ -- SpriteProgressToRadial ------------------------------------ local function SpriteProgressToRadial() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) - local to1 = CCProgressTo:create(2, 100) - local to2 = CCProgressTo:create(2, 100) + local to1 = cc.ProgressTo:create(2, 100) + local to2 = cc.ProgressTo:create(2, 100) - local left = CCProgressTimer:create(CCSprite:create(s_pPathSister1)) - left:setType(kCCProgressTimerTypeRadial) - left:setPosition(CCPoint(100, s.height / 2)) - left:runAction(CCRepeatForever:create(to1)) + local left = cc.ProgressTimer:create(cc.Sprite:create(s_pPathSister1)) + left:setType(cc.PROGRESS_TIMER_TYPE_RADIAL) + left:setPosition(cc.p(100, s.height / 2)) + left:runAction(cc.RepeatForever:create(to1)) layer:addChild(left) - local right = CCProgressTimer:create(CCSprite:create(s_pPathBlock)) - right:setType(kCCProgressTimerTypeRadial) + local right = cc.ProgressTimer:create(cc.Sprite:create(s_pPathBlock)) + right:setType(cc.PROGRESS_TIMER_TYPE_RADIAL) -- Makes the ridial CCW - right:setReverseProgress(true) - right:setPosition(CCPoint(s.width - 100, s.height / 2)) - right:runAction(CCRepeatForever:create(to2)) + right:setReverseDirection(true) + right:setPosition(cc.p(s.width - 100, s.height / 2)) + right:runAction(cc.RepeatForever:create(to2)) layer:addChild(right) Helper.subtitleLabel:setString("ProgressTo Radial") @@ -33,30 +33,30 @@ end -- SpriteProgressToHorizontal ------------------------------------ local function SpriteProgressToHorizontal() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) - local to1 = CCProgressTo:create(2, 100) - local to2 = CCProgressTo:create(2, 100) + local to1 = cc.ProgressTo:create(2, 100) + local to2 = cc.ProgressTo:create(2, 100) - local left = CCProgressTimer:create(CCSprite:create(s_pPathSister1)) - left:setType(kCCProgressTimerTypeBar) + local left = cc.ProgressTimer:create(cc.Sprite:create(s_pPathSister1)) + left:setType(cc.PROGRESS_TIMER_TYPE_BAR) -- Setup for a bar starting from the left since the midpoint is 0 for the x - left:setMidpoint(CCPoint(0, 0)) + left:setMidpoint(cc.p(0, 0)) -- Setup for a horizontal bar since the bar change rate is 0 for y meaning no vertical change - left:setBarChangeRate(CCPoint(1, 0)) - left:setPosition(CCPoint(100, s.height / 2)) - left:runAction(CCRepeatForever:create(to1)) + left:setBarChangeRate(cc.p(1, 0)) + left:setPosition(cc.p(100, s.height / 2)) + left:runAction(cc.RepeatForever:create(to1)) layer:addChild(left) - local right = CCProgressTimer:create(CCSprite:create(s_pPathSister2)) - right:setType(kCCProgressTimerTypeBar) + local right = cc.ProgressTimer:create(cc.Sprite:create(s_pPathSister2)) + right:setType(cc.PROGRESS_TIMER_TYPE_BAR) -- Setup for a bar starting from the left since the midpoint is 1 for the x - right:setMidpoint(CCPoint(1, 0)) + right:setMidpoint(cc.p(1, 0)) -- Setup for a horizontal bar since the bar change rate is 0 for y meaning no vertical change - right:setBarChangeRate(CCPoint(1, 0)) - right:setPosition(CCPoint(s.width - 100, s.height / 2)) - right:runAction(CCRepeatForever:create(to2)) + right:setBarChangeRate(cc.p(1, 0)) + right:setPosition(cc.p(s.width - 100, s.height / 2)) + right:runAction(cc.RepeatForever:create(to2)) layer:addChild(right) Helper.subtitleLabel:setString("ProgressTo Horizontal") @@ -67,31 +67,31 @@ end -- SpriteProgressToVertical ------------------------------------ local function SpriteProgressToVertical() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) - local to1 = CCProgressTo:create(2, 100) - local to2 = CCProgressTo:create(2, 100) + local to1 = cc.ProgressTo:create(2, 100) + local to2 = cc.ProgressTo:create(2, 100) - local left = CCProgressTimer:create(CCSprite:create(s_pPathSister1)) - left:setType(kCCProgressTimerTypeBar) + local left = cc.ProgressTimer:create(cc.Sprite:create(s_pPathSister1)) + left:setType(cc.PROGRESS_TIMER_TYPE_BAR) -- Setup for a bar starting from the bottom since the midpoint is 0 for the y - left:setMidpoint(CCPoint(0,0)) + left:setMidpoint(cc.p(0,0)) -- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - left:setBarChangeRate(CCPoint(0, 1)) - left:setPosition(CCPoint(100, s.height / 2)) - left:runAction(CCRepeatForever:create(to1)) + left:setBarChangeRate(cc.p(0, 1)) + left:setPosition(cc.p(100, s.height / 2)) + left:runAction(cc.RepeatForever:create(to1)) layer:addChild(left) - local right = CCProgressTimer:create(CCSprite:create(s_pPathSister2)) - right:setType(kCCProgressTimerTypeBar) + local right = cc.ProgressTimer:create(cc.Sprite:create(s_pPathSister2)) + right:setType(cc.PROGRESS_TIMER_TYPE_BAR) -- Setup for a bar starting from the bottom since the midpoint is 0 for the y - right:setMidpoint(CCPoint(0, 1)) + right:setMidpoint(cc.p(0, 1)) -- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - right:setBarChangeRate(CCPoint(0, 1)) - right:setPosition(CCPoint(s.width - 100, s.height / 2)) - right:runAction(CCRepeatForever:create(to2)) + right:setBarChangeRate(cc.p(0, 1)) + right:setPosition(cc.p(s.width - 100, s.height / 2)) + right:runAction(cc.RepeatForever:create(to2)) layer:addChild(right) Helper.subtitleLabel:setString("ProgressTo Vertical") @@ -102,30 +102,30 @@ end -- SpriteProgressToRadialMidpointChanged ------------------------------------ local function SpriteProgressToRadialMidpointChanged() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) - local action = CCProgressTo:create(2, 100) + local action = cc.ProgressTo:create(2, 100) -- Our image on the left should be a radial progress indicator, clockwise - local left = CCProgressTimer:create(CCSprite:create(s_pPathBlock)) - left:setType(kCCProgressTimerTypeRadial) - left:setMidpoint(CCPoint(0.25, 0.75)) - left:setPosition(CCPoint(100, s.height / 2)) - left:runAction(CCRepeatForever:create(CCProgressTo:create(2, 100))) + local left = cc.ProgressTimer:create(cc.Sprite:create(s_pPathBlock)) + left:setType(cc.PROGRESS_TIMER_TYPE_RADIAL) + left:setMidpoint(cc.p(0.25, 0.75)) + left:setPosition(cc.p(100, s.height / 2)) + left:runAction(cc.RepeatForever:create(cc.ProgressTo:create(2, 100))) layer:addChild(left) -- Our image on the left should be a radial progress indicator, counter clockwise - local right = CCProgressTimer:create(CCSprite:create(s_pPathBlock)) - right:setType(kCCProgressTimerTypeRadial) - right:setMidpoint(CCPoint(0.75, 0.25)) + local right = cc.ProgressTimer:create(cc.Sprite:create(s_pPathBlock)) + right:setType(cc.PROGRESS_TIMER_TYPE_RADIAL) + right:setMidpoint(cc.p(0.75, 0.25)) --[[ Note the reverse property (default=NO) is only added to the right image. That's how we get a counter clockwise progress. ]] - right:setPosition(CCPoint(s.width - 100, s.height / 2)) - right:runAction(CCRepeatForever:create(CCProgressTo:create(2, 100))) + right:setPosition(cc.p(s.width - 100, s.height / 2)) + right:runAction(cc.RepeatForever:create(cc.ProgressTo:create(2, 100))) layer:addChild(right) Helper.subtitleLabel:setString("Radial w/ Different Midpoints") @@ -136,40 +136,40 @@ end -- SpriteProgressBarVarious ------------------------------------ local function SpriteProgressBarVarious() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) - local to = CCProgressTo:create(2, 100) + local to = cc.ProgressTo:create(2, 100) - local left = CCProgressTimer:create(CCSprite:create(s_pPathSister1)) - left:setType(kCCProgressTimerTypeBar) + local left = cc.ProgressTimer:create(cc.Sprite:create(s_pPathSister1)) + left:setType(cc.PROGRESS_TIMER_TYPE_BAR) -- Setup for a bar starting from the bottom since the midpoint is 0 for the y - left:setMidpoint(CCPoint(0.5, 0.5)) + left:setMidpoint(cc.p(0.5, 0.5)) -- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - left:setBarChangeRate(CCPoint(1, 0)) - left:setPosition(CCPoint(100, s.height / 2)) - left:runAction(CCRepeatForever:create(CCProgressTo:create(2, 100))) + left:setBarChangeRate(cc.p(1, 0)) + left:setPosition(cc.p(100, s.height / 2)) + left:runAction(cc.RepeatForever:create(cc.ProgressTo:create(2, 100))) layer:addChild(left) - local middle = CCProgressTimer:create(CCSprite:create(s_pPathSister2)) - middle:setType(kCCProgressTimerTypeBar) + local middle = cc.ProgressTimer:create(cc.Sprite:create(s_pPathSister2)) + middle:setType(cc.PROGRESS_TIMER_TYPE_BAR) -- Setup for a bar starting from the bottom since the midpoint is 0 for the y - middle:setMidpoint(CCPoint(0.5, 0.5)) + middle:setMidpoint(cc.p(0.5, 0.5)) -- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - middle:setBarChangeRate(CCPoint(1, 1)) - middle:setPosition(CCPoint(s.width/2, s.height/2)) - middle:runAction(CCRepeatForever:create(CCProgressTo:create(2, 100))) + middle:setBarChangeRate(cc.p(1, 1)) + middle:setPosition(cc.p(s.width/2, s.height/2)) + middle:runAction(cc.RepeatForever:create(cc.ProgressTo:create(2, 100))) layer:addChild(middle) - local right = CCProgressTimer:create(CCSprite:create(s_pPathSister2)) - right:setType(kCCProgressTimerTypeBar) + local right = cc.ProgressTimer:create(cc.Sprite:create(s_pPathSister2)) + right:setType(cc.PROGRESS_TIMER_TYPE_BAR) -- Setup for a bar starting from the bottom since the midpoint is 0 for the y - right:setMidpoint(CCPoint(0.5, 0.5)) + right:setMidpoint(cc.p(0.5, 0.5)) -- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - right:setBarChangeRate(CCPoint(0, 1)) - right:setPosition(CCPoint(s.width-100, s.height/2)) - right:runAction(CCRepeatForever:create(CCProgressTo:create(2, 100))) + right:setBarChangeRate(cc.p(0, 1)) + right:setPosition(cc.p(s.width-100, s.height/2)) + right:runAction(cc.RepeatForever:create(cc.ProgressTo:create(2, 100))) layer:addChild(right) Helper.subtitleLabel:setString("ProgressTo Bar Mid") @@ -180,65 +180,60 @@ end -- SpriteProgressBarTintAndFade ------------------------------------ local function SpriteProgressBarTintAndFade() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) - local to = CCProgressTo:create(6, 100) + local to = cc.ProgressTo:create(6, 100) + --[[ local array = CCArray:create() array:addObject(CCTintTo:create(1, 255, 0, 0)) array:addObject(CCTintTo:create(1, 0, 255, 0)) array:addObject(CCTintTo:create(1, 0, 0, 255)) - local tint = CCSequence:create(array) - local fade = CCSequence:createWithTwoActions( - CCFadeTo:create(1.0, 0), - CCFadeTo:create(1.0, 255)) - - local left = CCProgressTimer:create(CCSprite:create(s_pPathSister1)) - left:setType(kCCProgressTimerTypeBar) + ]]-- + local tint = cc.Sequence:create(cc.TintTo:create(1, 255, 0, 0), cc.TintTo:create(1, 0, 255, 0), cc.TintTo:create(1, 0, 0, 255)) + local fade = cc.Sequence:create(cc.FadeTo:create(1.0, 0),cc.FadeTo:create(1.0, 255)) + local left = cc.ProgressTimer:create(cc.Sprite:create(s_pPathSister1)) + left:setType(cc.PROGRESS_TIMER_TYPE_BAR) -- Setup for a bar starting from the bottom since the midpoint is 0 for the y - left:setMidpoint(CCPoint(0.5, 0.5)) + left:setMidpoint(cc.p(0.5, 0.5)) -- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - left:setBarChangeRate(CCPoint(1, 0)) - left:setPosition(CCPoint(100, s.height / 2)) - left:runAction(CCRepeatForever:create(CCProgressTo:create(6, 100))) - left:runAction(CCRepeatForever:create(CCSequence:create(array))) + left:setBarChangeRate(cc.p(1, 0)) + left:setPosition(cc.p(100, s.height / 2)) + left:runAction(cc.RepeatForever:create(cc.ProgressTo:create(6, 100))) + left:runAction(cc.RepeatForever:create(cc.Sequence:create(cc.TintTo:create(1, 255, 0, 0), cc.TintTo:create(1, 0, 255, 0), cc.TintTo:create(1, 0, 0, 255)))) layer:addChild(left) - left:addChild(CCLabelTTF:create("Tint", "Marker Felt", 20.0)) + left:addChild(cc.LabelTTF:create("Tint", "Marker Felt", 20.0)) - local middle = CCProgressTimer:create(CCSprite:create(s_pPathSister2)) - middle:setType(kCCProgressTimerTypeBar) + local middle = cc.ProgressTimer:create(cc.Sprite:create(s_pPathSister2)) + middle:setType(cc.PROGRESS_TIMER_TYPE_BAR) -- Setup for a bar starting from the bottom since the midpoint is 0 for the y - middle:setMidpoint(CCPoint(0.5, 0.5)) + middle:setMidpoint(cc.p(0.5, 0.5)) -- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - middle:setBarChangeRate(CCPoint(1, 1)) - middle:setPosition(CCPoint(s.width / 2, s.height / 2)) - middle:runAction(CCRepeatForever:create(CCProgressTo:create(6, 100))) + middle:setBarChangeRate(cc.p(1, 1)) + middle:setPosition(cc.p(s.width / 2, s.height / 2)) + middle:runAction(cc.RepeatForever:create(cc.ProgressTo:create(6, 100))) - local fade2 = CCSequence:createWithTwoActions( - CCFadeTo:create(1.0, 0), - CCFadeTo:create(1.0, 255)) - middle:runAction(CCRepeatForever:create(fade2)) + local fade2 = cc.Sequence:create(cc.FadeTo:create(1.0, 0), cc.FadeTo:create(1.0, 255)) + middle:runAction(cc.RepeatForever:create(fade2)) layer:addChild(middle) - middle:addChild(CCLabelTTF:create("Fade", "Marker Felt", 20.0)) + middle:addChild(cc.LabelTTF:create("Fade", "Marker Felt", 20.0)) - local right = CCProgressTimer:create(CCSprite:create(s_pPathSister2)) - right:setType(kCCProgressTimerTypeBar) + local right = cc.ProgressTimer:create(cc.Sprite:create(s_pPathSister2)) + right:setType(cc.PROGRESS_TIMER_TYPE_BAR) -- Setup for a bar starting from the bottom since the midpoint is 0 for the y - right:setMidpoint(CCPoint(0.5, 0.5)) + right:setMidpoint(cc.p(0.5, 0.5)) -- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - right:setBarChangeRate(CCPoint(0, 1)) - right:setPosition(CCPoint(s.width - 100, s.height / 2)) - right:runAction(CCRepeatForever:create(CCProgressTo:create(6, 100))) - right:runAction(CCRepeatForever:create(CCSequence:create(array))) - right:runAction(CCRepeatForever:create(CCSequence:createWithTwoActions( - CCFadeTo:create(1.0, 0), - CCFadeTo:create(1.0, 255)))) + right:setBarChangeRate(cc.p(0, 1)) + right:setPosition(cc.p(s.width - 100, s.height / 2)) + right:runAction(cc.RepeatForever:create(cc.ProgressTo:create(6, 100))) + right:runAction(cc.RepeatForever:create(cc.Sequence:create(cc.TintTo:create(1, 255, 0, 0), cc.TintTo:create(1, 0, 255, 0), cc.TintTo:create(1, 0, 0, 255)))) + right:runAction(cc.RepeatForever:create(cc.Sequence:create(cc.FadeTo:create(1.0, 0), cc.FadeTo:create(1.0, 255)))) layer:addChild(right) - right:addChild(CCLabelTTF:create("Tint and Fade", "Marker Felt", 20.0)) + right:addChild(cc.LabelTTF:create("Tint and Fade", "Marker Felt", 20.0)) Helper.subtitleLabel:setString("ProgressTo Bar Mid") return layer @@ -248,41 +243,41 @@ end -- SpriteProgressWithSpriteFrame ------------------------------------ local function SpriteProgressWithSpriteFrame() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) - local to = CCProgressTo:create(6, 100) + local to = cc.ProgressTo:create(6, 100) - CCSpriteFrameCache:getInstance():addSpriteFramesWithFile("zwoptex/grossini.plist") + cc.SpriteFrameCache:getInstance():addSpriteFrames("zwoptex/grossini.plist") - local left = CCProgressTimer:create(CCSprite:createWithSpriteFrameName("grossini_dance_01.png")) - left:setType(kCCProgressTimerTypeBar) + local left = cc.ProgressTimer:create(cc.Sprite:createWithSpriteFrameName("grossini_dance_01.png")) + left:setType(cc.PROGRESS_TIMER_TYPE_BAR) -- Setup for a bar starting from the bottom since the midpoint is 0 for the y - left:setMidpoint(CCPoint(0.5, 0.5)) + left:setMidpoint(cc.p(0.5, 0.5)) -- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - left:setBarChangeRate(CCPoint(1, 0)) - left:setPosition(CCPoint(100, s.height / 2)) - left:runAction(CCRepeatForever:create(CCProgressTo:create(6, 100))) + left:setBarChangeRate(cc.p(1, 0)) + left:setPosition(cc.p(100, s.height / 2)) + left:runAction(cc.RepeatForever:create(cc.ProgressTo:create(6, 100))) layer:addChild(left) - local middle = CCProgressTimer:create(CCSprite:createWithSpriteFrameName("grossini_dance_02.png")) - middle:setType(kCCProgressTimerTypeBar) + local middle = cc.ProgressTimer:create(cc.Sprite:createWithSpriteFrameName("grossini_dance_02.png")) + middle:setType(cc.PROGRESS_TIMER_TYPE_BAR) -- Setup for a bar starting from the bottom since the midpoint is 0 for the y - middle:setMidpoint(CCPoint(0.5, 0.5)) + middle:setMidpoint(cc.p(0.5, 0.5)) -- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - middle:setBarChangeRate(CCPoint(1, 1)) - middle:setPosition(CCPoint(s.width / 2, s.height / 2)) - middle:runAction(CCRepeatForever:create(CCProgressTo:create(6, 100))) + middle:setBarChangeRate(cc.p(1, 1)) + middle:setPosition(cc.p(s.width / 2, s.height / 2)) + middle:runAction(cc.RepeatForever:create(cc.ProgressTo:create(6, 100))) layer:addChild(middle) - local right = CCProgressTimer:create(CCSprite:createWithSpriteFrameName("grossini_dance_03.png")) - right:setType(kCCProgressTimerTypeRadial) + local right = cc.ProgressTimer:create(cc.Sprite:createWithSpriteFrameName("grossini_dance_03.png")) + right:setType(cc.PROGRESS_TIMER_TYPE_BAR) -- Setup for a bar starting from the bottom since the midpoint is 0 for the y - right:setMidpoint(CCPoint(0.5, 0.5)) + right:setMidpoint(cc.p(0.5, 0.5)) -- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - right:setBarChangeRate(CCPoint(0, 1)) - right:setPosition(CCPoint(s.width - 100, s.height / 2)) - right:runAction(CCRepeatForever:create(CCProgressTo:create(6, 100))) + right:setBarChangeRate(cc.p(0, 1)) + right:setPosition(cc.p(s.width - 100, s.height / 2)) + right:runAction(cc.RepeatForever:create(cc.ProgressTo:create(6, 100))) layer:addChild(right) Helper.subtitleLabel:setString("Progress With Sprite Frame") @@ -290,7 +285,7 @@ local function SpriteProgressWithSpriteFrame() end function ProgressActionsTest() - local scene = CCScene:create() + local scene = cc.Scene:create() Helper.createFunctionTable = { SpriteProgressToRadial, @@ -305,5 +300,5 @@ function ProgressActionsTest() scene:addChild(SpriteProgressToRadial()) scene:addChild(CreateBackMenuItem()) - CCDirector:getInstance():replaceScene(scene) + cc.Director:getInstance():replaceScene(scene) end diff --git a/samples/Lua/TestLua/Resources/luaScript/ActionsTest/ActionsTest.lua b/samples/Lua/TestLua/Resources/luaScript/ActionsTest/ActionsTest.lua index bfd2c86334..f866def795 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ActionsTest/ActionsTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ActionsTest/ActionsTest.lua @@ -1,17 +1,17 @@ -local size = CCDirector:getInstance():getWinSize() +local size = cc.Director:getInstance():getWinSize() local function initWithLayer(layer) - grossini = CCSprite:create(s_pPathGrossini) - tamara = CCSprite:create(s_pPathSister1) - kathia = CCSprite:create(s_pPathSister2) + grossini = cc.Sprite:create(s_pPathGrossini) + tamara = cc.Sprite:create(s_pPathSister1) + kathia = cc.Sprite:create(s_pPathSister2) layer:addChild(grossini, 1) layer:addChild(tamara, 2) layer:addChild(kathia, 3) - grossini:setPosition(CCPoint(size.width / 2, size.height / 3)) - tamara:setPosition(CCPoint(size.width / 2, 2 * size.height / 3)) - kathia:setPosition(CCPoint(size.width / 2, size.height / 2)) + grossini:setPosition(cc.p(size.width / 2, size.height / 3)) + tamara:setPosition(cc.p(size.width / 2, 2 * size.height / 3)) + kathia:setPosition(cc.p(size.width / 2, size.height / 2)) Helper.initWithLayer(layer) end @@ -25,15 +25,15 @@ local function centerSprites(numberOfSprites) elseif numberOfSprites == 1 then tamara:setVisible(false) kathia:setVisible(false) - grossini:setPosition(CCPoint(size.width / 2, size.height / 2)) + grossini:setPosition(cc.p(size.width / 2, size.height / 2)) elseif numberOfSprites == 2 then - kathia:setPosition(CCPoint(size.width / 3, size.height / 2)) - tamara:setPosition(CCPoint(2 * size.width / 3, size.height / 2)) + kathia:setPosition(cc.p(size.width / 3, size.height / 2)) + tamara:setPosition(cc.p(2 * size.width / 3, size.height / 2)) grossini:setVisible(false) elseif numberOfSprites == 3 then - grossini:setPosition(CCPoint(size.width / 2, size.height / 2)) - tamara:setPosition(CCPoint(size.width / 4, size.height / 2)) - kathia:setPosition(CCPoint(3 * size.width / 4, size.height / 2)) + grossini:setPosition(cc.p(size.width / 2, size.height / 2)) + tamara:setPosition(cc.p(size.width / 4, size.height / 2)) + kathia:setPosition(cc.p(3 * size.width / 4, size.height / 2)) end end @@ -41,15 +41,15 @@ local function alignSpritesLeft(numberOfSprites) if numberOfSprites == 1 then tamara:setVisible(false) kathia:setVisible(false) - grossini:setPosition(CCPoint(60, size.height / 2)) + grossini:setPosition(cc.p(60, size.height / 2)) elseif numberOfSprites == 2 then - kathia:setPosition(CCPoint(60, size.height / 3)) - tamara:setPosition(CCPoint(60, 2 * size.height / 3)) + kathia:setPosition(cc.p(60, size.height / 3)) + tamara:setPosition(cc.p(60, 2 * size.height / 3)) grossini:setVisible(false) elseif numberOfSprites == 3 then - grossini:setPosition(CCPoint(60, size.height / 2)) - tamara:setPosition(CCPoint(60, 2 * size.height / 3)) - kathia:setPosition(CCPoint(60, size.height / 3)) + grossini:setPosition(cc.p(60, size.height / 2)) + tamara:setPosition(cc.p(60, 2 * size.height / 3)) + kathia:setPosition(cc.p(60, size.height / 3)) end end @@ -58,20 +58,20 @@ end -- ActionManual -------------------------------------- local function ActionManual() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) tamara:setScaleX(2.5) tamara:setScaleY(-1.0) - tamara:setPosition(CCPoint(100, 70)) + tamara:setPosition(cc.p(100, 70)) tamara:setOpacity(128) grossini:setRotation(120) - grossini:setPosition(CCPoint(size.width / 2, size.height / 2)) - grossini:setColor(Color3B(255, 0, 0)) + grossini:setPosition(cc.p(size.width / 2, size.height / 2)) + grossini:setColor(cc.c3b(255, 0, 0)) - kathia:setPosition(CCPoint(size.width - 100, size.height / 2)) - kathia:setColor(Color3B(0, 0, 255)) + kathia:setPosition(cc.p(size.width - 100, size.height / 2)) + kathia:setColor(cc.c3b(0, 0, 255)) Helper.subtitleLabel:setString("Manual Transformation") return layer @@ -81,16 +81,16 @@ end -- ActionMove -------------------------------------- local function ActionMove() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(3) - local actionBy = CCMoveBy:create(2, CCPoint(80, 80)) + local actionBy = cc.MoveBy:create(2, cc.p(80, 80)) local actionByBack = actionBy:reverse() - tamara:runAction(CCMoveTo:create(2, CCPoint(size.width - 40, size.height - 40))) - grossini:runAction(CCSequence:createWithTwoActions(actionBy, actionByBack)) - kathia:runAction(CCMoveTo:create(1, CCPoint(40, 40))) + tamara:runAction(cc.MoveTo:create(2, cc.p(size.width - 40, size.height - 40))) + grossini:runAction(cc.Sequence:create(actionBy, actionByBack)) + kathia:runAction(cc.MoveTo:create(1, cc.p(40, 40))) Helper.subtitleLabel:setString("MoveTo / MoveBy") return layer @@ -100,18 +100,18 @@ end -- ActionScale -------------------------------------- local function ActionScale() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(3) - local actionTo = CCScaleTo:create(2.0, 0.5) - local actionBy = CCScaleBy:create(2.0, 1.0, 10.0) - local actionBy2 = CCScaleBy:create(2.0, 5.0, 1.0) + local actionTo = cc.ScaleTo:create(2.0, 0.5) + local actionBy = cc.ScaleBy:create(2.0, 1.0, 10.0) + local actionBy2 = cc.ScaleBy:create(2.0, 5.0, 1.0) grossini:runAction(actionTo) - tamara:runAction(CCSequence:createWithTwoActions(actionBy, actionBy:reverse())) - kathia:runAction(CCSequence:createWithTwoActions(actionBy2, actionBy2:reverse())) + tamara:runAction(cc.Sequence:create(actionBy, actionBy:reverse())) + kathia:runAction(cc.Sequence:create(actionBy2, actionBy2:reverse())) Helper.subtitleLabel:setString("ScaleTo / ScaleBy") return layer @@ -121,23 +121,23 @@ end -- ActionRotate -------------------------------------- local function ActionRotate() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(3) - local actionTo = CCRotateTo:create( 2, 45) - local actionTo2 = CCRotateTo:create( 2, -45) - local actionTo0 = CCRotateTo:create(2 , 0) - tamara:runAction(CCSequence:createWithTwoActions(actionTo, actionTo0)) + local actionTo = cc.RotateTo:create( 2, 45) + local actionTo2 = cc.RotateTo:create( 2, -45) + local actionTo0 = cc.RotateTo:create(2 , 0) + tamara:runAction(cc.Sequence:create(actionTo, actionTo0)) - local actionBy = CCRotateBy:create(2 , 360) + local actionBy = cc.RotateBy:create(2 , 360) local actionByBack = actionBy:reverse() - grossini:runAction(CCSequence:createWithTwoActions(actionBy, actionByBack)) + grossini:runAction(cc.Sequence:create(actionBy, actionByBack)) - local action0Retain = CCRotateTo:create(2 , 0) + local action0Retain = cc.RotateTo:create(2 , 0) - kathia:runAction(CCSequence:createWithTwoActions(actionTo2, action0Retain)) + kathia:runAction(cc.Sequence:create(actionTo2, action0Retain)) Helper.subtitleLabel:setString("RotateTo / RotateBy") return layer @@ -147,20 +147,20 @@ end -- ActionSkew -------------------------------------- local function ActionSkew() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(3) - local actionTo = CCSkewTo:create(2, 37.2, -37.2) - local actionToBack = CCSkewTo:create(2, 0, 0) - local actionBy = CCSkewBy:create(2, 0.0, -90.0) - local actionBy2 = CCSkewBy:create(2, 45.0, 45.0) + local actionTo = cc.SkewTo:create(2, 37.2, -37.2) + local actionToBack = cc.SkewTo:create(2, 0, 0) + local actionBy = cc.SkewBy:create(2, 0.0, -90.0) + local actionBy2 = cc.SkewBy:create(2, 45.0, 45.0) local actionByBack = actionBy:reverse() - tamara:runAction(CCSequence:createWithTwoActions(actionTo, actionToBack)) - grossini:runAction(CCSequence:createWithTwoActions(actionBy, actionByBack)) - kathia:runAction(CCSequence:createWithTwoActions(actionBy2, actionBy2:reverse())) + tamara:runAction(cc.Sequence:create(actionTo, actionToBack)) + grossini:runAction(cc.Sequence:create(actionBy, actionByBack)) + kathia:runAction(cc.Sequence:create(actionBy2, actionBy2:reverse())) Helper.subtitleLabel:setString("SkewTo / SkewBy") return layer @@ -169,42 +169,42 @@ end --ActionRotationalSkewVSStandardSkew local function ActionRotationalSkewVSStandardSkew() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) - tamara:removeFromParentAndCleanup(true); - grossini:removeFromParentAndCleanup(true); - kathia:removeFromParentAndCleanup(true); + tamara:removeFromParent(true); + grossini:removeFromParent(true); + kathia:removeFromParent(true); - local s = CCDirector:getInstance():getWinSize(); - local boxSize = CCSize(100.0, 100.0); - local box = CCLayerColor:create(Color4B(255,255,0,255)); - box:setAnchorPoint(CCPoint(0.5,0.5)); + local s = cc.Director:getInstance():getWinSize(); + local boxSize = cc.size(100.0, 100.0); + local box = cc.LayerColor:create(cc.c4b(255,255,0,255)); + box:setAnchorPoint(cc.p(0.5,0.5)); box:setContentSize( boxSize ); box:ignoreAnchorPointForPosition(false); - box:setPosition(CCPoint(s.width/2, s.height - 100 - box:getContentSize().height/2)); + box:setPosition(cc.p(s.width/2, s.height - 100 - box:getContentSize().height/2)); layer:addChild(box); - local label = CCLabelTTF:create("Standard cocos2d Skew", "Marker Felt", 16); - label:setPosition(CCPoint(s.width/2, s.height - 100 + label:getContentSize().height)); + local label = cc.LabelTTF:create("Standard cocos2d Skew", "Marker Felt", 16); + label:setPosition(cc.p(s.width/2, s.height - 100 + label:getContentSize().height)); layer:addChild(label); - local actionTo = CCSkewBy:create(2, 360, 0); - local actionToBack = CCSkewBy:create(2, -360, 0); - local seq = CCSequence:createWithTwoActions(actionTo, actionToBack) + local actionTo = cc.SkewBy:create(2, 360, 0); + local actionToBack = cc.SkewBy:create(2, -360, 0); + local seq = cc.Sequence:create(actionTo, actionToBack) box:runAction(seq); - box = CCLayerColor:create(Color4B(255,255,0,255)); - box:setAnchorPoint(CCPoint(0.5,0.5)); + box = cc.LayerColor:create(cc.c4b(255,255,0,255)); + box:setAnchorPoint(cc.p(0.5,0.5)); box:setContentSize(boxSize); box:ignoreAnchorPointForPosition(false); - box:setPosition(CCPoint(s.width/2, s.height - 250 - box:getContentSize().height/2)); + box:setPosition(cc.p(s.width/2, s.height - 250 - box:getContentSize().height/2)); layer:addChild(box); - label = CCLabelTTF:create("Rotational Skew", "Marker Felt", 16); - label:setPosition(CCPoint(s.width/2, s.height - 250 + label:getContentSize().height/2)); + label = cc.LabelTTF:create("Rotational Skew", "Marker Felt", 16); + label:setPosition(cc.p(s.width/2, s.height - 250 + label:getContentSize().height/2)); layer:addChild(label); - local actionTo2 = CCRotateBy:create(2, 360); - local actionToBack2 = CCRotateBy:create(2, -360); - seq = CCSequence:createWithTwoActions(actionTo2, actionToBack2) + local actionTo2 = cc.RotateBy:create(2, 360); + local actionToBack2 = cc.RotateBy:create(2, -360); + seq = cc.Sequence:create(actionTo2, actionToBack2) box:runAction(seq); Helper.subtitleLabel:setString("Skew Comparison") @@ -215,45 +215,45 @@ end -- ActionSkewRotate -------------------------------------- local function ActionSkewRotate() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) - tamara:removeFromParentAndCleanup(true) - grossini:removeFromParentAndCleanup(true) - kathia:removeFromParentAndCleanup(true) + tamara:removeFromParent(true) + grossini:removeFromParent(true) + kathia:removeFromParent(true) - local boxSize = CCSize(100.0, 100.0) + local boxSize = cc.size(100.0, 100.0) - local box = CCLayerColor:create(Color4B(255, 255, 0, 255)) - box:setAnchorPoint(CCPoint(0, 0)) + local box = cc.LayerColor:create(cc.c4b(255, 255, 0, 255)) + box:setAnchorPoint(cc.p(0, 0)) box:setPosition(190, 110) box:setContentSize(boxSize) local markrside = 10.0 - local uL = CCLayerColor:create(Color4B(255, 0, 0, 255)) + local uL = cc.LayerColor:create(cc.c4b(255, 0, 0, 255)) box:addChild(uL) - uL:setContentSize(CCSize(markrside, markrside)) + uL:setContentSize(cc.size(markrside, markrside)) uL:setPosition(0, boxSize.height - markrside) - uL:setAnchorPoint(CCPoint(0, 0)) + uL:setAnchorPoint(cc.p(0, 0)) - local uR = CCLayerColor:create(Color4B(0, 0, 255, 255)) + local uR = cc.LayerColor:create(cc.c4b(0, 0, 255, 255)) box:addChild(uR) - uR:setContentSize(CCSize(markrside, markrside)) + uR:setContentSize(cc.size(markrside, markrside)) uR:setPosition(boxSize.width - markrside, boxSize.height - markrside) - uR:setAnchorPoint(CCPoint(0, 0)) + uR:setAnchorPoint(cc.p(0, 0)) layer:addChild(box) - local actionTo = CCSkewTo:create(2, 0, 2) - local rotateTo = CCRotateTo:create(2, 61.0) - local actionScaleTo = CCScaleTo:create(2, -0.44, 0.47) + local actionTo = cc.SkewTo:create(2, 0, 2) + local rotateTo = cc.RotateTo:create(2, 61.0) + local actionScaleTo = cc.ScaleTo:create(2, -0.44, 0.47) - local actionScaleToBack = CCScaleTo:create(2, 1.0, 1.0) - local rotateToBack = CCRotateTo:create(2, 0) - local actionToBack = CCSkewTo:create(2, 0, 0) + local actionScaleToBack = cc.ScaleTo:create(2, 1.0, 1.0) + local rotateToBack = cc.RotateTo:create(2, 0) + local actionToBack = cc.SkewTo:create(2, 0, 0) - box:runAction(CCSequence:createWithTwoActions(actionTo, actionToBack)) - box:runAction(CCSequence:createWithTwoActions(rotateTo, rotateToBack)) - box:runAction(CCSequence:createWithTwoActions(actionScaleTo, actionScaleToBack)) + box:runAction(cc.Sequence:create(actionTo, actionToBack)) + box:runAction(cc.Sequence:create(rotateTo, rotateToBack)) + box:runAction(cc.Sequence:create(actionScaleTo, actionScaleToBack)) Helper.subtitleLabel:setString("Skew + Rotate + Scale") return layer @@ -263,19 +263,19 @@ end -- ActionJump -------------------------------------- local function ActionJump() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(3) - local actionTo = CCJumpTo:create(2, CCPoint(300,300), 50, 4) - local actionBy = CCJumpBy:create(2, CCPoint(300,0), 50, 4) - local actionUp = CCJumpBy:create(2, CCPoint(0,0), 80, 4) + local actionTo = cc.JumpTo:create(2, cc.p(300,300), 50, 4) + local actionBy = cc.JumpBy:create(2, cc.p(300,0), 50, 4) + local actionUp = cc.JumpBy:create(2, cc.p(0,0), 80, 4) local actionByBack = actionBy:reverse() tamara:runAction(actionTo) - grossini:runAction(CCSequence:createWithTwoActions(actionBy, actionByBack)) - kathia:runAction(CCRepeatForever:create(actionUp)) + grossini:runAction(cc.Sequence:create(actionBy, actionByBack)) + kathia:runAction(cc.RepeatForever:create(actionUp)) Helper.subtitleLabel:setString("JumpTo / JumpBy") return layer @@ -285,52 +285,59 @@ end -- ActionCardinalSpline -------------------------------------- local function ActionCardinalSpline() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(2) - - local array = CCPointArray:create(20) - array:addControlPoint(CCPoint(0, 0)) - array:addControlPoint(CCPoint(size.width / 2 - 30, 0)) - array:addControlPoint(CCPoint(size.width / 2 - 30, size.height - 80)) - array:addControlPoint(CCPoint(0, size.height - 80)) - array:addControlPoint(CCPoint(0, 0)) - - local action = CCCardinalSplineBy:create(3, array, 0) +--[[ + local array = cc.pArray:create(20) + array:addControlPoint(cc.p(0, 0)) + array:addControlPoint(cc.p(size.width / 2 - 30, 0)) + array:addControlPoint(cc.p(size.width / 2 - 30, size.height - 80)) + array:addControlPoint(cc.p(0, size.height - 80)) + array:addControlPoint(cc.p(0, 0)) +]]-- + local array = { + cc.p(0, 0), + cc.p(size.width / 2 - 30, 0), + cc.p(size.width / 2 - 30, size.height - 80), + cc.p(0, size.height - 80), + cc.p(0, 0), + } + local action = cc.CardinalSplineBy:create(3, array, 0) local reverse = action:reverse() - local seq = CCSequence:createWithTwoActions(action, reverse) + local seq = cc.Sequence:create(action, reverse) - tamara:setPosition(CCPoint(50, 50)) + tamara:setPosition(cc.p(50, 50)) tamara:runAction(seq) - local action2 = CCCardinalSplineBy:create(3, array, 1) + local action2 = cc.CardinalSplineBy:create(3, array, 1) local reverse2 = action2:reverse() - local seq2 = CCSequence:createWithTwoActions(action2, reverse2) + local seq2 = cc.Sequence:create(action2, reverse2) - kathia:setPosition(CCPoint(size.width / 2, 50)) + kathia:setPosition(cc.p(size.width / 2, 50)) kathia:runAction(seq2) - +--[[ local function drawCardinalSpline() kmGLPushMatrix() kmGLTranslatef(50, 50, 0) - CCDrawPrimitives.ccDrawCardinalSpline(array, 0, 100) + cc.DrawPrimitives.ccDrawCardinalSpline(array, 0, 100) kmGLPopMatrix() kmGLPushMatrix() kmGLTranslatef(size.width / 2, 50, 0) - CCDrawPrimitives.ccDrawCardinalSpline(array, 1, 100) + cc.DrawPrimitives.ccDrawCardinalSpline(array, 1, 100) kmGLPopMatrix() end array:retain() local glNode = gl.glNodeCreate() - glNode:setContentSize(CCSize(size.width, size.height)) - glNode:setAnchorPoint(CCPoint(0.5, 0.5)) + glNode:setContentSize(cc.size(size.width, size.height)) + glNode:setAnchorPoint(cc.p(0.5, 0.5)) glNode:registerScriptDrawHandler(drawCardinalSpline) layer:addChild(glNode,-10) glNode:setPosition( size.width / 2, size.height / 2) - +]]-- Helper.titleLabel:setString("CardinalSplineBy / CardinalSplineAt") Helper.subtitleLabel:setString("Cardinal Spline paths.\nTesting different tensions for one array") return layer @@ -340,56 +347,75 @@ end -- ActionCatmullRom -------------------------------------- local function ActionCatmullRom() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(2) - tamara:setPosition(CCPoint(50, 50)) + tamara:setPosition(cc.p(50, 50)) +--[[ + local array = cc.pArray:create(20) + array:addControlPoint(cc.p(0, 0)) + array:addControlPoint(cc.p(80, 80)) + array:addControlPoint(cc.p(size.width - 80, 80)) + array:addControlPoint(cc.p(size.width - 80, size.height - 80)) + array:addControlPoint(cc.p(80, size.height - 80)) + array:addControlPoint(cc.p(80, 80)) + array:addControlPoint(cc.p(size.width / 2, size.height / 2)) + ]]-- + local array = { + cc.p(0, 0), + cc.p(80, 80), + cc.p(size.width - 80, 80), + cc.p(size.width - 80, size.height - 80), + cc.p(80, size.height - 80), + cc.p(80, 80), + cc.p(size.width / 2, size.height / 2), + } - local array = CCPointArray:create(20) - array:addControlPoint(CCPoint(0, 0)) - array:addControlPoint(CCPoint(80, 80)) - array:addControlPoint(CCPoint(size.width - 80, 80)) - array:addControlPoint(CCPoint(size.width - 80, size.height - 80)) - array:addControlPoint(CCPoint(80, size.height - 80)) - array:addControlPoint(CCPoint(80, 80)) - array:addControlPoint(CCPoint(size.width / 2, size.height / 2)) - - local action = CCCatmullRomBy:create(3, array) + local action = cc.CatmullRomBy:create(3, array) local reverse = action:reverse() - local seq = CCSequence:createWithTwoActions(action, reverse) + local seq = cc.Sequence:create(action, reverse) tamara:runAction(seq) +--[[ + local array2 = cc.pArray:create(20) + array2:addControlPoint(cc.p(size.width / 2, 30)) + array2:addControlPoint(cc.p(size.width -80, 30)) + array2:addControlPoint(cc.p(size.width - 80, size.height - 80)) + array2:addControlPoint(cc.p(size.width / 2, size.height - 80)) + array2:addControlPoint(cc.p(size.width / 2, 30)) + ]]-- + local array2 = { + cc.p(size.width / 2, 30), + cc.p(size.width -80, 30), + cc.p(size.width - 80, size.height - 80), + cc.p(size.width / 2, size.height - 80), + cc.p(size.width / 2, 30), + } - local array2 = CCPointArray:create(20) - array2:addControlPoint(CCPoint(size.width / 2, 30)) - array2:addControlPoint(CCPoint(size.width -80, 30)) - array2:addControlPoint(CCPoint(size.width - 80, size.height - 80)) - array2:addControlPoint(CCPoint(size.width / 2, size.height - 80)) - array2:addControlPoint(CCPoint(size.width / 2, 30)) - - local action2 = CCCatmullRomTo:create(3, array2) + local action2 = cc.CatmullRomTo:create(3, array2) local reverse2 = action2:reverse() - local seq2 = CCSequence:createWithTwoActions(action2, reverse2) + local seq2 = cc.Sequence:create(action2, reverse2) kathia:runAction(seq2) - +--[[ local function drawCatmullRom() kmGLPushMatrix() kmGLTranslatef(50, 50, 0) - CCDrawPrimitives.ccDrawCatmullRom(array, 50) + cc.DrawPrimitives.ccDrawCatmullRom(array, 50) kmGLPopMatrix() - CCDrawPrimitives.ccDrawCatmullRom(array2,50) + cc.DrawPrimitives.ccDrawCatmullRom(array2,50) end array:retain() array2:retain() local glNode = gl.glNodeCreate() - glNode:setContentSize(CCSize(size.width, size.height)) - glNode:setAnchorPoint(CCPoint(0.5, 0.5)) + glNode:setContentSize(cc.size(size.width, size.height)) + glNode:setAnchorPoint(cc.p(0.5, 0.5)) glNode:registerScriptDrawHandler(drawCatmullRom) layer:addChild(glNode,-10) glNode:setPosition( size.width / 2, size.height / 2) + ]]-- Helper.titleLabel:setString("CatmullRomBy / CatmullRomTo") Helper.subtitleLabel:setString("Catmull Rom spline paths. Testing reverse too") @@ -400,33 +426,46 @@ end -- ActionBezier -------------------------------------- local function ActionBezier() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(3) -- sprite 1 + --[[ local bezier = ccBezierConfig() - bezier.controlPoint_1 = CCPoint(0, size.height / 2) - bezier.controlPoint_2 = CCPoint(300, - size.height / 2) - bezier.endPosition = CCPoint(300, 100) - - local bezierForward = CCBezierBy:create(3, bezier) + bezier.controlPoint_1 = cc.p(0, size.height / 2) + bezier.controlPoint_2 = cc.p(300, - size.height / 2) + bezier.endPosition = cc.p(300, 100) + ]]-- + local bezier = { + cc.p(0, size.height / 2), + cc.p(300, - size.height / 2), + cc.p(300, 100), + } + local bezierForward = cc.BezierBy:create(3, bezier) local bezierBack = bezierForward:reverse() - local rep = CCRepeatForever:create(CCSequence:createWithTwoActions(bezierForward, bezierBack)) + local rep = cc.RepeatForever:create(cc.Sequence:create(bezierForward, bezierBack)) -- sprite 2 - tamara:setPosition(CCPoint(80,160)) + tamara:setPosition(cc.p(80,160)) + --[[ local bezier2 = ccBezierConfig() - bezier2.controlPoint_1 = CCPoint(100, size.height / 2) - bezier2.controlPoint_2 = CCPoint(200, - size.height / 2) - bezier2.endPosition = CCPoint(240, 160) + bezier2.controlPoint_1 = cc.p(100, size.height / 2) + bezier2.controlPoint_2 = cc.p(200, - size.height / 2) + bezier2.endPosition = cc.p(240, 160) + ]]-- + local bezier2 ={ + cc.p(100, size.height / 2), + cc.p(200, - size.height / 2), + cc.p(240, 160) + } - local bezierTo1 = CCBezierTo:create(2, bezier2) + local bezierTo1 = cc.BezierTo:create(2, bezier2) -- sprite 3 - kathia:setPosition(CCPoint(400,160)) - local bezierTo2 = CCBezierTo:create(2, bezier2) + kathia:setPosition(cc.p(400,160)) + local bezierTo2 = cc.BezierTo:create(2, bezier2) grossini:runAction(rep) tamara:runAction(bezierTo1) @@ -440,13 +479,13 @@ end -- ActionBlink -------------------------------------- local function ActionBlink() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(2) - local action1 = CCBlink:create(2, 10) - local action2 = CCBlink:create(2, 5) + local action1 = cc.Blink:create(2, 10) + local action2 = cc.Blink:create(2, 5) tamara:runAction(action1) kathia:runAction(action2) @@ -460,20 +499,20 @@ end -- ActionFade -------------------------------------- local function ActionFade() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(2) tamara:setOpacity(0) - local action1 = CCFadeIn:create(1) + local action1 = cc.FadeIn:create(1) local action1Back = action1:reverse() - local action2 = CCFadeOut:create(1) + local action2 = cc.FadeOut:create(1) local action2Back = action2:reverse() - tamara:runAction(CCSequence:createWithTwoActions( action1, action1Back)) - kathia:runAction(CCSequence:createWithTwoActions( action2, action2Back)) + tamara:runAction(cc.Sequence:create( action1, action1Back)) + kathia:runAction(cc.Sequence:create( action2, action2Back)) Helper.subtitleLabel:setString("FadeIn / FadeOut") @@ -484,17 +523,17 @@ end -- ActionTint -------------------------------------- local function ActionTint() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(2) - local action1 = CCTintTo:create(2, 255, 0, 255) - local action2 = CCTintBy:create(2, -127, -255, -127) + local action1 = cc.TintTo:create(2, 255, 0, 255) + local action2 = cc.TintBy:create(2, -127, -255, -127) local action2Back = action2:reverse() tamara:runAction(action1) - kathia:runAction(CCSequence:createWithTwoActions(action2, action2Back)) + kathia:runAction(cc.Sequence:create(action2, action2Back)) Helper.subtitleLabel:setString("TintTo / TintBy") @@ -505,12 +544,12 @@ end -- ActionAnimate -------------------------------------- local function ActionAnimate() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(3) - local animation = CCAnimation:create() + local animation = cc.Animation:create() local number, name for i = 1, 14 do if i < 10 then @@ -519,27 +558,27 @@ local function ActionAnimate() number = i end name = "Images/grossini_dance_"..number..".png" - animation:addSpriteFrameWithFileName(name) + animation:addSpriteFrameWithFile(name) end -- should last 2.8 seconds. And there are 14 frames. animation:setDelayPerUnit(2.8 / 14.0) animation:setRestoreOriginalFrame(true) - local action = CCAnimate:create(animation) - grossini:runAction(CCSequence:createWithTwoActions(action, action:reverse())) + local action = cc.Animate:create(animation) + grossini:runAction(cc.Sequence:create(action, action:reverse())) - local cache = CCAnimationCache:getInstance() - cache:addAnimationsWithFile("animations/animations-2.plist") - local animation2 = cache:animationByName("dance_1") + local cache = cc.AnimationCache:getInstance() + cache:addAnimations("animations/animations-2.plist") + local animation2 = cache:getAnimation("dance_1") - local action2 = CCAnimate:create(animation2) - tamara:runAction(CCSequence:createWithTwoActions(action2, action2:reverse())) + local action2 = cc.Animate:create(animation2) + tamara:runAction(cc.Sequence:create(action2, action2:reverse())) local animation3 = animation2:clone() -- problem - tolua.cast(animation3,"CCAnimation"):setLoops(4) + tolua.cast(animation3,"Animation"):setLoops(4) - local action3 = CCAnimate:create(animation3) + local action3 = cc.Animate:create(animation3) kathia:runAction(action3) Helper.titleLabel:setString("Animation") @@ -552,14 +591,14 @@ end -- ActionSequence -------------------------------------- local function ActionSequence() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) alignSpritesLeft(1) - local action = CCSequence:createWithTwoActions( - CCMoveBy:create(2, CCPoint(240,0)), - CCRotateBy:create(2, 540)) + local action = cc.Sequence:create( + cc.MoveBy:create(2, cc.p(240,0)), + cc.RotateBy:create(2, 540)) grossini:runAction(action) @@ -574,42 +613,44 @@ end local actionSequenceLayer = nil local function ActionSequenceCallback1() - local label = CCLabelTTF:create("callback 1 called", "Marker Felt", 16) + local label = cc.LabelTTF:create("callback 1 called", "Marker Felt", 16) label:setPosition(size.width / 4, size.height / 2) actionSequenceLayer:addChild(label) end local function ActionSequenceCallback2(sender) - local label = CCLabelTTF:create("callback 2 called", "Marker Felt", 16) - label:setPosition(CCPoint(size.width / 4 * 2, size.height / 2)) + local label = cc.LabelTTF:create("callback 2 called", "Marker Felt", 16) + label:setPosition(cc.p(size.width / 4 * 2, size.height / 2)) actionSequenceLayer:addChild(label) end local function ActionSequenceCallback3(sender) - local label = CCLabelTTF:create("callback 3 called", "Marker Felt", 16) - label:setPosition(CCPoint(size.width / 4 * 3, size.height / 2)) + local label = cc.LabelTTF:create("callback 3 called", "Marker Felt", 16) + label:setPosition(cc.p(size.width / 4 * 3, size.height / 2)) actionSequenceLayer:addChild(label) end local function ActionSequence2() - actionSequenceLayer = CCLayer:create() + actionSequenceLayer = cc.Layer:create() initWithLayer(actionSequenceLayer) alignSpritesLeft(1) grossini:setVisible(false) - local array = CCArray:create() - array:addObject(CCPlace:create(CCPoint(200,200))) - array:addObject(CCShow:create()) - array:addObject(CCMoveBy:create(1, CCPoint(100,0))) - array:addObject(CCCallFunc:create(ActionSequenceCallback1)) - array:addObject(CCCallFunc:create(ActionSequenceCallback2)) - array:addObject(CCCallFunc:create(ActionSequenceCallback3)) + --[[ + local array = cc.Array:create() + array:addObject(cc.Place:create(cc.p(200,200))) + array:addObject(cc.Show:create()) + array:addObject(cc.MoveBy:create(1, cc.p(100,0))) + array:addObject(cc.CallFunc:create(ActionSequenceCallback1)) + array:addObject(cc.CallFunc:create(ActionSequenceCallback2)) + array:addObject(cc.CallFunc:create(ActionSequenceCallback3)) + ]]-- - local action = CCSequence:create(array) + local action = cc.Sequence:create(cc.Place:create(cc.p(200,200)),cc.Show:create(),cc.MoveBy:create(1, cc.p(100,0)), cc.CallFunc:create(ActionSequenceCallback1),cc.CallFunc:create(ActionSequenceCallback2),cc.CallFunc:create(ActionSequenceCallback3)) grossini:runAction(action) @@ -621,14 +662,14 @@ end -- ActionSpawn -------------------------------------- local function ActionSpawn() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) alignSpritesLeft(1) - local action = CCSpawn:createWithTwoActions( - CCJumpBy:create(2, CCPoint(300,0), 50, 4), - CCRotateBy:create( 2, 720)) + local action = cc.Spawn:create( + cc.JumpBy:create(2, cc.p(300,0), 50, 4), + cc.RotateBy:create( 2, 720)) grossini:runAction(action) @@ -641,13 +682,13 @@ end -- ActionReverse -------------------------------------- local function ActionReverse() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) alignSpritesLeft(1) - local jump = CCJumpBy:create(2, CCPoint(300,0), 50, 4) - local action = CCSequence:createWithTwoActions(jump, jump:reverse()) + local jump = cc.JumpBy:create(2, cc.p(300,0), 50, 4) + local action = cc.Sequence:create(jump, jump:reverse()) grossini:runAction(action) @@ -660,17 +701,19 @@ end -- ActionDelaytime -------------------------------------- local function ActionDelaytime() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) alignSpritesLeft(1) - local move = CCMoveBy:create(1, CCPoint(150,0)) - local array = CCArray:create() + local move = cc.MoveBy:create(1, cc.p(150,0)) + --[[ + local array = cc.Array:create() array:addObject(move) - array:addObject(CCDelayTime:create(2)) + array:addObject(cc.DelayTime:create(2)) array:addObject(move) - local action = CCSequence:create(array) + ]]-- + local action = cc.Sequence:create(move, cc.DelayTime:create(2), move) grossini:runAction(action) @@ -682,16 +725,16 @@ end -- ActionRepeat -------------------------------------- local function ActionRepeat() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) alignSpritesLeft(2) - local a1 = CCMoveBy:create(1, CCPoint(150,0)) - local action1 = CCRepeat:create(CCSequence:createWithTwoActions(CCPlace:create(CCPoint(60,60)), a1), 3) + local a1 = cc.MoveBy:create(1, cc.p(150,0)) + local action1 = cc.Repeat:create(cc.Sequence:create(cc.Place:create(cc.p(60,60)), a1), 3) - local a2 = CCMoveBy:create(1, CCPoint(150,0)) - local action2 = CCRepeatForever:create(CCSequence:createWithTwoActions(a2, a1:reverse())) + local a2 = cc.MoveBy:create(1, cc.p(150,0)) + local action2 = cc.RepeatForever:create(cc.Sequence:create(a2, a1:reverse())) kathia:runAction(action1) tamara:runAction(action2) @@ -704,20 +747,20 @@ end -- ActionRepeatForever -------------------------------------- local function repeatForever(sender) - local repeatAction = CCRepeatForever:create(CCRotateBy:create(1.0, 360)) + local repeatAction = cc.RepeatForever:create(cc.RotateBy:create(1.0, 360)) sender:runAction(repeatAction) end local function ActionRepeatForever() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(1) - local action = CCSequence:createWithTwoActions( - CCDelayTime:create(1), - CCCallFunc:create(repeatForever) ) + local action = cc.Sequence:create( + cc.DelayTime:create(1), + cc.CallFunc:create(repeatForever) ) grossini:runAction(action) @@ -729,16 +772,16 @@ end -- ActionRotateToRepeat -------------------------------------- local function ActionRotateToRepeat() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(2) - local act1 = CCRotateTo:create(1, 90) - local act2 = CCRotateTo:create(1, 0) - local seq = CCSequence:createWithTwoActions(act1, act2) - local rep1 = CCRepeatForever:create(seq) - local rep2 = CCRepeat:create(tolua.cast(seq:clone(), "CCSequence"), 10) + local act1 = cc.RotateTo:create(1, 90) + local act2 = cc.RotateTo:create(1, 0) + local seq = cc.Sequence:create(act1, act2) + local rep1 = cc.RepeatForever:create(seq) + local rep2 = cc.Repeat:create(tolua.cast(seq:clone(), "Sequence"), 10) tamara:runAction(rep1) kathia:runAction(rep2) @@ -752,22 +795,22 @@ end -- ActionRotateJerk -------------------------------------- local function ActionRotateJerk() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(2) - local seq = CCSequence:createWithTwoActions( - CCRotateTo:create(0.5, -20), - CCRotateTo:create(0.5, 20)) + local seq = cc.Sequence:create( + cc.RotateTo:create(0.5, -20), + cc.RotateTo:create(0.5, 20)) - local rep1 = CCRepeat:create(seq, 10) + local rep1 = cc.Repeat:create(seq, 10) - local seq2 = CCSequence:createWithTwoActions( - CCRotateTo:create(0.5, -20), - CCRotateTo:create(0.5, 20)) + local seq2 = cc.Sequence:create( + cc.RotateTo:create(0.5, -20), + cc.RotateTo:create(0.5, 20)) - local rep2 = CCRepeatForever:create(seq2) + local rep2 = cc.RepeatForever:create(seq2) tamara:runAction(rep1) kathia:runAction(rep2) @@ -782,47 +825,49 @@ end local callFuncLayer = nil local function CallFucnCallback1() - local label = CCLabelTTF:create("callback 1 called", "Marker Felt", 16) + local label = cc.LabelTTF:create("callback 1 called", "Marker Felt", 16) label:setPosition(size.width / 4, size.height / 2) callFuncLayer:addChild(label) end local function CallFucnCallback2(sender) - local label = CCLabelTTF:create("callback 2 called", "Marker Felt", 16) + local label = cc.LabelTTF:create("callback 2 called", "Marker Felt", 16) label:setPosition(size.width / 4 * 2, size.height / 2) callFuncLayer:addChild(label) end local function CallFucnCallback3(sender) - local label = CCLabelTTF:create("callback 3 called", "Marker Felt", 16) + local label = cc.LabelTTF:create("callback 3 called", "Marker Felt", 16) label:setPosition(size.width / 4 * 3, size.height / 2) callFuncLayer:addChild(label) end local function ActionCallFunc() - callFuncLayer = CCLayer:create() + callFuncLayer = cc.Layer:create() initWithLayer(callFuncLayer) centerSprites(3) - local action = CCSequence:createWithTwoActions( - CCMoveBy:create(2, CCPoint(200,0)), - CCCallFunc:create(CallFucnCallback1) ) - - local array = CCArray:create() - array:addObject(CCScaleBy:create(2, 2)) - array:addObject(CCFadeOut:create(2)) - array:addObject(CCCallFunc:create(CallFucnCallback2)) - local action2 = CCSequence:create(array) - - local array2 = CCArray:create() - array2:addObject(CCRotateBy:create(3 , 360)) - array2:addObject(CCFadeOut:create(2)) - array2:addObject(CCCallFunc:create(CallFucnCallback3)) - local action3 = CCSequence:create(array2) + local action = cc.Sequence:create( + cc.MoveBy:create(2, cc.p(200,0)), + cc.CallFunc:create(CallFucnCallback1) ) +--[[ + local array = cc.Array:create() + array:addObject(cc.ScaleBy:create(2, 2)) + array:addObject(cc.FadeOut:create(2)) + array:addObject(cc.CallFunc:create(CallFucnCallback2)) + ]]-- + local action2 = cc.Sequence:create(cc.ScaleBy:create(2, 2),cc.FadeOut:create(2),cc.CallFunc:create(CallFucnCallback2)) +--[[ + local array2 = cc.Array:create() + array2:addObject(cc.RotateBy:create(3 , 360)) + array2:addObject(cc.FadeOut:create(2)) + array2:addObject(cc.CallFunc:create(CallFucnCallback3)) + ]]-- + local action3 = cc.Sequence:create(cc.RotateBy:create(3 , 360),cc.FadeOut:create(2),cc.CallFunc:create(CallFucnCallback3)) grossini:runAction(action) tamara:runAction(action2) @@ -838,14 +883,14 @@ end -- passing more than one param to lua script -------------------------------------- local function ActionCallFuncND() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(1) Helper.titleLabel:setString("CallFuncND + auto remove") - Helper.subtitleLabel:setString("CallFuncND + removeFromParentAndCleanup. Grossini dissapears in 2s") + Helper.subtitleLabel:setString("CallFuncND + removeFromParent. Grossini dissapears in 2s") return layer end @@ -853,19 +898,21 @@ end -- ActionReverseSequence -------------------------------------- local function ActionReverseSequence() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) alignSpritesLeft(1) - local move1 = CCMoveBy:create(1, CCPoint(250,0)) - local move2 = CCMoveBy:create(1, CCPoint(0,50)) - local array = CCArray:create() + local move1 = cc.MoveBy:create(1, cc.p(250,0)) + local move2 = cc.MoveBy:create(1, cc.p(0,50)) + --[[ + local array = cc.Array:create() array:addObject(move1) array:addObject(move2) array:addObject(move1:reverse()) - local seq = CCSequence:create(array) - local action = CCSequence:createWithTwoActions(seq, seq:reverse()) + ]]-- + local seq = cc.Sequence:create(move1, move2, move1:reverse()) + local action = cc.Sequence:create(seq, seq:reverse()) grossini:runAction(action) @@ -877,40 +924,44 @@ end -- ActionReverseSequence2 -------------------------------------- local function ActionReverseSequence2() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) alignSpritesLeft(2) -- Test: -- Sequence should work both with IntervalAction and InstantActions - local move1 = CCMoveBy:create(1, CCPoint(250,0)) - local move2 = CCMoveBy:create(1, CCPoint(0,50)) - local tog1 = CCToggleVisibility:create() - local tog2 = CCToggleVisibility:create() - local array = CCArray:createWithCapacity(10) + local move1 = cc.MoveBy:create(1, cc.p(250,0)) + local move2 = cc.MoveBy:create(1, cc.p(0,50)) + local tog1 = cc.ToggleVisibility:create() + local tog2 = cc.ToggleVisibility:create() + --[[ + local array = cc.Array:createWithCapacity(10) array:addObject(move1) array:addObject(tog1) array:addObject(move2) array:addObject(tog2) array:addObject(move1:reverse()) - local seq = CCSequence:create(array) - local action = CCRepeat:create(CCSequence:createWithTwoActions(seq, seq:reverse()), 3) + ]]-- + local seq = cc.Sequence:create(move1, tog1, move2, tog2, move1:reverse()) + local action = cc.Repeat:create(cc.Sequence:create(seq, seq:reverse()), 3) -- Test: -- Also test that the reverse of Hide is Show, and vice-versa kathia:runAction(action) - local move_tamara = CCMoveBy:create(1, CCPoint(100,0)) - local move_tamara2 = CCMoveBy:create(1, CCPoint(50,0)) - local hide = CCHide:create() - local array2 = CCArray:createWithCapacity(10) + local move_tamara = cc.MoveBy:create(1, cc.p(100,0)) + local move_tamara2 = cc.MoveBy:create(1, cc.p(50,0)) + local hide = cc.Hide:create() + --[[ + local array2 = cc.Array:createWithCapacity(10) array2:addObject(move_tamara) array2:addObject(hide) array2:addObject(move_tamara2) - local seq_tamara = CCSequence:create(array2) + ]]-- + local seq_tamara = cc.Sequence:create(move_tamara, hide, move_tamara2) local seq_back = seq_tamara:reverse() - tamara:runAction(CCSequence:createWithTwoActions(seq_tamara, seq_back)) + tamara:runAction(cc.Sequence:create(seq_tamara, seq_back)) Helper.subtitleLabel:setString("Reverse a sequence2") return layer @@ -920,31 +971,31 @@ end -- ActionOrbit -------------------------------------- local function ActionOrbit() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(3) - local orbit1 = CCOrbitCamera:create(2,1, 0, 0, 180, 0, 0) - local action1 = CCSequence:createWithTwoActions(orbit1, orbit1:reverse()) + local orbit1 = cc.OrbitCamera:create(2,1, 0, 0, 180, 0, 0) + local action1 = cc.Sequence:create(orbit1, orbit1:reverse()) - local orbit2 = CCOrbitCamera:create(2,1, 0, 0, 180, -45, 0) - local action2 = CCSequence:createWithTwoActions(orbit2, orbit2:reverse()) + local orbit2 = cc.OrbitCamera:create(2,1, 0, 0, 180, -45, 0) + local action2 = cc.Sequence:create(orbit2, orbit2:reverse()) - local orbit3 = CCOrbitCamera:create(2,1, 0, 0, 180, 90, 0) - local action3 = CCSequence:createWithTwoActions(orbit3, orbit3:reverse()) + local orbit3 = cc.OrbitCamera:create(2,1, 0, 0, 180, 90, 0) + local action3 = cc.Sequence:create(orbit3, orbit3:reverse()) - kathia:runAction(CCRepeatForever:create(action1)) - tamara:runAction(CCRepeatForever:create(action2)) - grossini:runAction(CCRepeatForever:create(action3)) + kathia:runAction(cc.RepeatForever:create(action1)) + tamara:runAction(cc.RepeatForever:create(action2)) + grossini:runAction(cc.RepeatForever:create(action3)) - local move = CCMoveBy:create(3, CCPoint(100,-100)) + local move = cc.MoveBy:create(3, cc.p(100,-100)) local move_back = move:reverse() - local seq = CCSequence:createWithTwoActions(move, move_back) - local rfe = CCRepeatForever:create(seq) + local seq = cc.Sequence:create(move, move_back) + local rfe = cc.RepeatForever:create(seq) kathia:runAction(rfe) - tamara:runAction(tolua.cast(rfe:clone(), "CCActionInterval")) - grossini:runAction(tolua.cast(rfe:clone(), "CCActionInterval")) + tamara:runAction(tolua.cast(rfe:clone(), "ActionInterval")) + grossini:runAction(tolua.cast(rfe:clone(), "ActionInterval")) Helper.subtitleLabel:setString("OrbitCamera action") @@ -955,32 +1006,32 @@ end -- ActionFollow -------------------------------------- local function ActionFollow() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(1) - grossini:setPosition(CCPoint(-200, size.height / 2)) - local move = CCMoveBy:create(2, CCPoint(size.width * 3, 0)) + grossini:setPosition(cc.p(-200, size.height / 2)) + local move = cc.MoveBy:create(2, cc.p(size.width * 3, 0)) local move_back = move:reverse() - local seq = CCSequence:createWithTwoActions(move, move_back) - local rep = CCRepeatForever:create(seq) + local seq = cc.Sequence:create(move, move_back) + local rep = cc.RepeatForever:create(seq) grossini:runAction(rep) - layer:runAction(CCFollow:create(grossini, CCRect(0, 0, size.width * 2 - 100, size.height))) + layer:runAction(cc.Follow:create(grossini, cc.rect(0, 0, size.width * 2 - 100, size.height))) local function draw() - local winSize = CCDirector:getInstance():getWinSize() + local winSize = cc.Director:getInstance():getWinSize() local x = winSize.width * 2 - 100 local y = winSize.height - local vertices = { CCPoint(5, 5), CCPoint(x - 5, 5), CCPoint(x - 5,y - 5), CCPoint(5,y - 5) } - CCDrawPrimitives.ccDrawPoly(vertices, 4, true) + local vertices = { cc.p(5, 5), cc.p(x - 5, 5), cc.p(x - 5,y - 5), cc.p(5,y - 5) } + gl.DrawPrimitives.ccDrawPoly(vertices, 4, true) end local glNode = gl.glNodeCreate() - glNode:setContentSize(CCSize(size.width, size.height)) - glNode:setAnchorPoint(CCPoint(0.5, 0.5)) + glNode:setContentSize(cc.size(size.width, size.height)) + glNode:setAnchorPoint(cc.p(0.5, 0.5)) glNode:registerScriptDrawHandler(draw) layer:addChild(glNode,-10) glNode:setPosition( size.width / 2, size.height / 2) @@ -993,26 +1044,27 @@ end -- ActionTargeted -------------------------------------- local function ActionTargeted() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(2) - local jump1 = CCJumpBy:create(2, CCPoint(0, 0), 100, 3) - local jump2 = CCJumpBy:create(2, CCPoint(0, 0), 100, 3) - local rot1 = CCRotateBy:create(1, 360) - local rot2 = CCRotateBy:create(1, 360) + local jump1 = cc.JumpBy:create(2, cc.p(0, 0), 100, 3) + local jump2 = cc.JumpBy:create(2, cc.p(0, 0), 100, 3) + local rot1 = cc.RotateBy:create(1, 360) + local rot2 = cc.RotateBy:create(1, 360) - local t1 = CCTargetedAction:create(kathia, jump2) - local t2 = CCTargetedAction:create(kathia, rot2) - - local array = CCArray:createWithCapacity(10) + local t1 = cc.TargetedAction:create(kathia, jump2) + local t2 = cc.TargetedAction:create(kathia, rot2) +--[[ + local array = cc.Array:createWithCapacity(10) array:addObject(jump1) array:addObject(t1) array:addObject(rot1) array:addObject(t2) - local seq = CCSequence:create(array) - local always = CCRepeatForever:create(seq) + ]]-- + local seq = cc.Sequence:create(jump1, t1, rot1, t2) + local always = cc.RepeatForever:create(seq) tamara:runAction(always) @@ -1032,10 +1084,10 @@ local PauseResumeActions_resumeEntry = nil local function ActionPause(dt) cclog("Pausing") - local scheduler = CCDirector:getInstance():getScheduler() + local scheduler = cc.Director:getInstance():getScheduler() scheduler:unscheduleScriptEntry(PauseResumeActions_pauseEntry) - local director = CCDirector:getInstance() + local director = cc.Director:getInstance() pausedTargets = director:getActionManager():pauseAllRunningActions() pausedTargets:retain() end @@ -1043,10 +1095,10 @@ end local function ActionResume(dt) cclog("Resuming") - local scheduler = CCDirector:getInstance():getScheduler() + local scheduler = cc.Director:getInstance():getScheduler() scheduler:unscheduleScriptEntry(PauseResumeActions_resumeEntry) - local director = CCDirector:getInstance() + local director = cc.Director:getInstance() if pausedTargets ~= nil then -- problem: will crash here. Try fixing me! director:getActionManager():resumeTargets(pausedTargets) @@ -1055,7 +1107,7 @@ local function ActionResume(dt) end local function PauseResumeActions_onEnterOrExit(tag) - local scheduler = CCDirector:getInstance():getScheduler() + local scheduler = cc.Director:getInstance():getScheduler() if tag == "enter" then PauseResumeActions_pauseEntry = scheduler:scheduleScriptFunc(ActionPause, 3, false) PauseResumeActions_resumeEntry = scheduler:scheduleScriptFunc(ActionResume, 5, false) @@ -1066,13 +1118,13 @@ local function PauseResumeActions_onEnterOrExit(tag) end local function PauseResumeActions() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(2) - tamara:runAction(CCRepeatForever:create(CCRotateBy:create(3, 360))) - kathia:runAction(CCRepeatForever:create(CCRotateBy:create(3, 360))) + tamara:runAction(cc.RepeatForever:create(cc.RotateBy:create(3, 360))) + kathia:runAction(cc.RepeatForever:create(cc.RotateBy:create(3, 360))) layer:registerScriptHandler(PauseResumeActions_onEnterOrExit) @@ -1093,15 +1145,15 @@ local function Issue1305_log(sender) end local function addSprite(dt) - local scheduler = CCDirector:getInstance():getScheduler() + local scheduler = cc.Director:getInstance():getScheduler() scheduler:unscheduleScriptEntry(Issue1305_entry) - spriteTmp:setPosition(CCPoint(250, 250)) + spriteTmp:setPosition(cc.p(250, 250)) Issue1305_layer:addChild(spriteTmp) end local function Issue1305_onEnterOrExit(tag) - local scheduler = CCDirector:getInstance():getScheduler() + local scheduler = cc.Director:getInstance():getScheduler() if tag == "enter" then Issue1305_entry = scheduler:scheduleScriptFunc(addSprite, 2, false) elseif tag == "exit" then @@ -1110,13 +1162,13 @@ local function Issue1305_onEnterOrExit(tag) end local function ActionIssue1305() - Issue1305_layer = CCLayer:create() + Issue1305_layer = cc.Layer:create() initWithLayer(Issue1305_layer) centerSprites(0) - spriteTmp = CCSprite:create("Images/grossini.png") - spriteTmp:runAction(CCCallFunc:create(Issue1305_log)) + spriteTmp = cc.Sprite:create("Images/grossini.png") + spriteTmp:runAction(cc.CallFunc:create(Issue1305_log)) Issue1305_layer:registerScriptHandler(Issue1305_onEnterOrExit) @@ -1145,25 +1197,25 @@ local function Issue1305_2_log4() end local function ActionIssue1305_2() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(0) - local spr = CCSprite:create("Images/grossini.png") - spr:setPosition(CCPoint(200,200)) + local spr = cc.Sprite:create("Images/grossini.png") + spr:setPosition(cc.p(200,200)) layer:addChild(spr) - local act1 = CCMoveBy:create(2 ,CCPoint(0, 100)) - local act2 = CCCallFunc:create(Issue1305_2_log1) - local act3 = CCMoveBy:create(2, CCPoint(0, -100)) - local act4 = CCCallFunc:create(Issue1305_2_log2) - local act5 = CCMoveBy:create(2, CCPoint(100, -100)) - local act6 = CCCallFunc:create(Issue1305_2_log3) - local act7 = CCMoveBy:create(2, CCPoint(-100, 0)) - local act8 = CCCallFunc:create(Issue1305_2_log4) - - local array = CCArray:create() + local act1 = cc.MoveBy:create(2 ,cc.p(0, 100)) + local act2 = cc.CallFunc:create(Issue1305_2_log1) + local act3 = cc.MoveBy:create(2, cc.p(0, -100)) + local act4 = cc.CallFunc:create(Issue1305_2_log2) + local act5 = cc.MoveBy:create(2, cc.p(100, -100)) + local act6 = cc.CallFunc:create(Issue1305_2_log3) + local act7 = cc.MoveBy:create(2, cc.p(-100, 0)) + local act8 = cc.CallFunc:create(Issue1305_2_log4) +--[[ + local array = cc.Array:create() array:addObject(act1) array:addObject(act2) array:addObject(act3) @@ -1172,9 +1224,10 @@ local function ActionIssue1305_2() array:addObject(act6) array:addObject(act7) array:addObject(act8) - local actF = CCSequence:create(array) + ]]-- + local actF = cc.Sequence:create(act1, act2, act3, act4, act5, act6, act7, act8) - CCDirector:getInstance():getActionManager():addAction(actF ,spr, false) + cc.Director:getInstance():getActionManager():addAction(actF ,spr, false) Helper.titleLabel:setString("Issue 1305 #2") Helper.subtitleLabel:setString("See console. You should only see one message for each block") @@ -1185,19 +1238,19 @@ end -- ActionIssue1288 -------------------------------------- local function ActionIssue1288() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(0) - local spr = CCSprite:create("Images/grossini.png") - spr:setPosition(CCPoint(100, 100)) + local spr = cc.Sprite:create("Images/grossini.png") + spr:setPosition(cc.p(100, 100)) layer:addChild(spr) - local act1 = CCMoveBy:create(0.5, CCPoint(100, 0)) + local act1 = cc.MoveBy:create(0.5, cc.p(100, 0)) local act2 = act1:reverse() - local act3 = CCSequence:createWithTwoActions(act1, act2) - local act4 = CCRepeat:create(act3, 2) + local act3 = cc.Sequence:create(act1, act2) + local act4 = cc.Repeat:create(act3, 2) spr:runAction(act4) @@ -1210,17 +1263,17 @@ end -- ActionIssue1288_2 -------------------------------------- local function ActionIssue1288_2() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(0) - local spr = CCSprite:create("Images/grossini.png") - spr:setPosition(CCPoint(100, 100)) + local spr = cc.Sprite:create("Images/grossini.png") + spr:setPosition(cc.p(100, 100)) layer:addChild(spr) - local act1 = CCMoveBy:create(0.5, CCPoint(100, 0)) - spr:runAction(CCRepeat:create(act1, 1)) + local act1 = cc.MoveBy:create(0.5, cc.p(100, 0)) + spr:runAction(cc.Repeat:create(act1, 1)) Helper.titleLabel:setString("Issue 1288 #2") Helper.subtitleLabel:setString("Sprite should move 100 pixels, and stay there") @@ -1235,26 +1288,26 @@ local function logSprRotation(sender) end local function ActionIssue1327() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer) centerSprites(0) - local spr = CCSprite:create("Images/grossini.png") - spr:setPosition(CCPoint(100, 100)) + local spr = cc.Sprite:create("Images/grossini.png") + spr:setPosition(cc.p(100, 100)) layer:addChild(spr) - local act1 = CCCallFunc:create(logSprRotation) - local act2 = CCRotateBy:create(0.25, 45) - local act3 = CCCallFunc:create(logSprRotation) - local act4 = CCRotateBy:create(0.25, 45) - local act5 = CCCallFunc:create(logSprRotation) - local act6 = CCRotateBy:create(0.25, 45) - local act7 = CCCallFunc:create(logSprRotation) - local act8 = CCRotateBy:create(0.25, 45) - local act9 = CCCallFunc:create(logSprRotation) - - local array = CCArray:create() + local act1 = cc.CallFunc:create(logSprRotation) + local act2 = cc.RotateBy:create(0.25, 45) + local act3 = cc.CallFunc:create(logSprRotation) + local act4 = cc.RotateBy:create(0.25, 45) + local act5 = cc.CallFunc:create(logSprRotation) + local act6 = cc.RotateBy:create(0.25, 45) + local act7 = cc.CallFunc:create(logSprRotation) + local act8 = cc.RotateBy:create(0.25, 45) + local act9 = cc.CallFunc:create(logSprRotation) +--[[ + local array = cc.Array:create() array:addObject(act1) array:addObject(act2) array:addObject(act3) @@ -1264,7 +1317,8 @@ local function ActionIssue1327() array:addObject(act7) array:addObject(act8) array:addObject(act9) - spr:runAction(CCSequence:create(array)) + ]]-- + spr:runAction(cc.Sequence:create(act1, act2, act3, act4, act5, act6, act7,act8, act9)) Helper.titleLabel:setString("Issue 1327") Helper.subtitleLabel:setString("See console: You should see: 0, 45, 90, 135, 180") @@ -1273,7 +1327,7 @@ end function ActionsTest() cclog("ActionsTest") - local scene = CCScene:create() + local scene = cc.Scene:create() Helper.createFunctionTable = { ActionManual, diff --git a/samples/Lua/TestLua/Resources/luaScript/VisibleRect.lua b/samples/Lua/TestLua/Resources/luaScript/VisibleRect.lua index 2554843571..523c061e08 100644 --- a/samples/Lua/TestLua/Resources/luaScript/VisibleRect.lua +++ b/samples/Lua/TestLua/Resources/luaScript/VisibleRect.lua @@ -1,65 +1,72 @@ require "luaScript/extern" +require "Cocos2d" VisibleRect = class("VisibleRect") VisibleRect.__index = VisibleRect -VisibleRect.s_visibleRect = CCRect:new() +VisibleRect.s_visibleRect = cc.rect(0,0,0,0) function VisibleRect:lazyInit() - if (self.s_visibleRect.size.width == 0.0 and self.s_visibleRect.size.height == 0.0) then - local pEGLView = CCEGLView:getInstance(); - self.s_visibleRect.origin = pEGLView:getVisibleOrigin(); - self.s_visibleRect.size = pEGLView:getVisibleSize(); + if (self.s_visibleRect.width == 0.0 and self.s_visibleRect.height == 0.0) then + --[[ + local pEGLView = cc.EGLView:getInstance() + local origin = pEGLView:getVisibleOrigin() + ]]-- + self.s_visibleRect.x = 0 + self.s_visibleRect.y = 0 + local size = cc.Director:getInstance():getWinSize() + self.s_visibleRect.width = size.width + self.s_visibleRect.height = size.height end end function VisibleRect:getVisibleRect() - self:lazyInit(); - return CCRect(self.s_visibleRect.origin.x, self.s_visibleRect.origin.y, self.s_visibleRect.size.width, self.s_visibleRect.size.height); + self:lazyInit() + return cc.Rect(self.s_visibleRect.x, self.s_visibleRect.y, self.s_visibleRect.width, self.s_visibleRect.height) end function VisibleRect:left() - self:lazyInit(); - return CCPoint(self.s_visibleRect.origin.x, self.s_visibleRect.origin.y+self.s_visibleRect.size.height/2); + self:lazyInit() + return cc.p(self.s_visibleRect.x, self.s_visibleRect.y+self.s_visibleRect.height/2) end function VisibleRect:right() - self:lazyInit(); - return CCPoint(self.s_visibleRect.origin.x+self.s_visibleRect.size.width, self.s_visibleRect.origin.y+self.s_visibleRect.size.height/2); + self:lazyInit() + return cc.p(self.s_visibleRect.x+self.s_visibleRect.width, self.s_visibleRect.y+self.s_visibleRect.height/2) end function VisibleRect:top() - self:lazyInit(); - return CCPoint(self.s_visibleRect.origin.x+self.s_visibleRect.size.width/2, self.s_visibleRect.origin.y+self.s_visibleRect.size.height); + self:lazyInit() + return cc.p(self.s_visibleRect.x+self.s_visibleRect.width/2, self.s_visibleRect.y+self.s_visibleRect.height) end function VisibleRect:bottom() - self:lazyInit(); - return CCPoint(self.s_visibleRect.origin.x+self.s_visibleRect.size.width/2, self.s_visibleRect.origin.y); + self:lazyInit() + return cc.p(self.s_visibleRect.x+self.s_visibleRect.width/2, self.s_visibleRect.y) end function VisibleRect:center() - self:lazyInit(); - return CCPoint(self.s_visibleRect.origin.x+self.s_visibleRect.size.width/2, self.s_visibleRect.origin.y+self.s_visibleRect.size.height/2); + self:lazyInit() + return cc.p(self.s_visibleRect.x+self.s_visibleRect.width/2, self.s_visibleRect.y+self.s_visibleRect.height/2) end function VisibleRect:leftTop() - self:lazyInit(); - return CCPoint(self.s_visibleRect.origin.x, self.s_visibleRect.origin.y+self.s_visibleRect.size.height); + self:lazyInit() + return cc.p(self.s_visibleRect.x, self.s_visibleRect.y+self.s_visibleRect.height) end function VisibleRect:rightTop() - self:lazyInit(); - return CCPoint(self.s_visibleRect.origin.x+self.s_visibleRect.size.width, self.s_visibleRect.origin.y+self.s_visibleRect.size.height); + self:lazyInit() + return cc.p(self.s_visibleRect.x+self.s_visibleRect.width, self.s_visibleRect.y+self.s_visibleRect.height) end function VisibleRect:leftBottom() - self:lazyInit(); - return self.s_visibleRect.origin; + self:lazyInit() + return cc.p(self.s_visibleRect.x,self.s_visibleRect.y) end function VisibleRect:rightBottom() - self:lazyInit(); - return CCPoint(self.s_visibleRect.origin.x+self.s_visibleRect.size.width, self.s_visibleRect.origin.y); + self:lazyInit() + return cc.p(self.s_visibleRect.x+self.s_visibleRect.width, self.s_visibleRect.y) end diff --git a/samples/Lua/TestLua/Resources/luaScript/controller.lua b/samples/Lua/TestLua/Resources/luaScript/controller.lua index 26a4954403..7a8151f331 100644 --- a/samples/Lua/TestLua/Resources/luaScript/controller.lua +++ b/samples/Lua/TestLua/Resources/luaScript/controller.lua @@ -8,6 +8,6 @@ require "luaScript/mainMenu" -- run -local scene = CCScene:create() +local scene = cc.Scene:create() scene:addChild(CreateTestMenu()) -CCDirector:getInstance():runWithScene(scene) +cc.Director:getInstance():runWithScene(scene) diff --git a/samples/Lua/TestLua/Resources/luaScript/helper.lua b/samples/Lua/TestLua/Resources/luaScript/helper.lua index 04b9bc9a47..911924f1fe 100644 --- a/samples/Lua/TestLua/Resources/luaScript/helper.lua +++ b/samples/Lua/TestLua/Resources/luaScript/helper.lua @@ -1,14 +1,16 @@ +require "Cocos2d" + CC_CONTENT_SCALE_FACTOR = function() - return CCDirector:getInstance():getContentScaleFactor() + return cc.Director:getInstance():getContentScaleFactor() end CC_POINT_PIXELS_TO_POINTS = function(pixels) - return CCPoint(pixels.x/CC_CONTENT_SCALE_FACTOR(), pixels.y/CC_CONTENT_SCALE_FACTOR()) + return cc.p(pixels.x/CC_CONTENT_SCALE_FACTOR(), pixels.y/CC_CONTENT_SCALE_FACTOR()) end CC_POINT_POINTS_TO_PIXELS = function(points) - return CCPoint(points.x*CC_CONTENT_SCALE_FACTOR(), points.y*CC_CONTENT_SCALE_FACTOR()) + return cc.p(points.x*CC_CONTENT_SCALE_FACTOR(), points.y*CC_CONTENT_SCALE_FACTOR()) end @@ -29,20 +31,20 @@ end -- back menu callback local function MainMenuCallback() - local scene = CCScene:create() + local scene = cc.Scene:create() scene:addChild(CreateTestMenu()) - CCDirector:getInstance():replaceScene(scene) + cc.Director:getInstance():replaceScene(scene) end -- add the menu item for back to main menu function CreateBackMenuItem() - local label = CCLabelTTF:create("MainMenu", "Arial", 20) - local MenuItem = CCMenuItemLabel:create(label) + local label = cc.LabelTTF:create("MainMenu", "Arial", 20) + local MenuItem = cc.MenuItemLabel:create(label) MenuItem:registerScriptTapHandler(MainMenuCallback) - local s = CCDirector:getInstance():getWinSize() - local Menu = CCMenu:create() + local s = cc.Director:getInstance():getWinSize() + local Menu = cc.Menu:create() Menu:addChild(MenuItem) Menu:setPosition(0, 0) MenuItem:setPosition(s.width - 50, 25) @@ -80,50 +82,50 @@ function Helper.restartAction() end function Helper.newScene() - local scene = CCScene:create() + local scene = cc.Scene:create() Helper.currentLayer = Helper.createFunctionTable[Helper.index]() scene:addChild(Helper.currentLayer) scene:addChild(CreateBackMenuItem()) - CCDirector:getInstance():replaceScene(scene) + cc.Director:getInstance():replaceScene(scene) end function Helper.initWithLayer(layer) Helper.currentLayer = layer - local size = CCDirector:getInstance():getWinSize() - Helper.titleLabel = CCLabelTTF:create("", "Arial", 28) + local size = cc.Director:getInstance():getWinSize() + Helper.titleLabel = cc.LabelTTF:create("", "Arial", 28) layer:addChild(Helper.titleLabel, 1) Helper.titleLabel:setPosition(size.width / 2, size.height - 50) - Helper.subtitleLabel = CCLabelTTF:create("", "Thonburi", 16) + Helper.subtitleLabel = cc.LabelTTF:create("", "Thonburi", 16) layer:addChild(Helper.subtitleLabel, 1) Helper.subtitleLabel:setPosition(size.width / 2, size.height - 80) -- menu - local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2) - local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2) - local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2) + local item1 = cc.MenuItemImage:create(s_pPathB1, s_pPathB2) + local item2 = cc.MenuItemImage:create(s_pPathR1, s_pPathR2) + local item3 = cc.MenuItemImage:create(s_pPathF1, s_pPathF2) item1:registerScriptTapHandler(Helper.backAction) item2:registerScriptTapHandler(Helper.restartAction) item3:registerScriptTapHandler(Helper.nextAction) - local menu = CCMenu:create() + local menu = cc.Menu:create() menu:addChild(item1) menu:addChild(item2) menu:addChild(item3) - menu:setPosition(CCPoint(0, 0)) - item1:setPosition(CCPoint(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) - item2:setPosition(CCPoint(size.width / 2, item2:getContentSize().height / 2)) - item3:setPosition(CCPoint(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + menu:setPosition(cc.p(0, 0)) + item1:setPosition(cc.p(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + item2:setPosition(cc.p(size.width / 2, item2:getContentSize().height / 2)) + item3:setPosition(cc.p(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) layer:addChild(menu, 1) - local background = CCLayer:create() + local background = cc.Layer:create() layer:addChild(background, -10) end function createTestLayer(title, subtitle) - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) local titleStr = title == nil and "No title" or title local subTitleStr = subtitle == nil and "" or subtitle diff --git a/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua b/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua index c0ba606bca..b62b0528f0 100644 --- a/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua +++ b/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua @@ -1,14 +1,23 @@ + + +require "Cocos2d" +require "Cocos2dConstants" +require "Opengl" +require "OpenglConstants" require "luaScript/helper" require "luaScript/testResource" -require "luaScript/ActionsTest/ActionsTest" -require "luaScript/TransitionsTest/TransitionsTest" +require "luaScript/ActionManagerTest/ActionManagerTest" +require "luaScript/ActionsEaseTest/ActionsEaseTest" require "luaScript/ActionsProgressTest/ActionsProgressTest" +require "luaScript/ActionsTest/ActionsTest" + +--[[ +require "luaScript/TransitionsTest/TransitionsTest" require "luaScript/EffectsTest/EffectsTest" require "luaScript/ClickAndMoveTest/ClickAndMoveTest" require "luaScript/RotateWorldTest/RotateWorldTest" require "luaScript/ParticleTest/ParticleTest" -require "luaScript/ActionsEaseTest/ActionsEaseTest" require "luaScript/MotionStreakTest/MotionStreakTest" require "luaScript/DrawPrimitivesTest/DrawPrimitivesTest" require "luaScript/NodeTest/NodeTest" @@ -19,7 +28,7 @@ require "luaScript/PerformanceTest/PerformanceTest" require "luaScript/LabelTest/LabelTest" require "luaScript/ParallaxTest/ParallaxTest" require "luaScript/TileMapTest/TileMapTest" -require "luaScript/ActionManagerTest/ActionManagerTest" + require "luaScript/MenuTest/MenuTest" require "luaScript/IntervalTest/IntervalTest" require "luaScript/SceneTest/SceneTest" @@ -36,7 +45,7 @@ require "luaScript/ExtensionTest/ExtensionTest" require "luaScript/AccelerometerTest/AccelerometerTest" require "luaScript/KeypadTest/KeypadTest" require "luaScript/OpenGLTest/OpenGLTest" - +]]-- local LINE_SPACE = 40 @@ -96,15 +105,15 @@ local TESTS_COUNT = table.getn(_allTests) -- create scene local function CreateTestScene(nIdx) local scene = _allTests[nIdx].create_func() - CCDirector:getInstance():purgeCachedData() + cc.Director:getInstance():purgeCachedData() return scene end -- create menu function CreateTestMenu() - local menuLayer = CCLayer:create() + local menuLayer = cc.Layer:create() local function closeCallback() - CCDirector:getInstance():endToLua() + cc.Director:getInstance():endToLua() end local function menuCallback(tag) @@ -112,37 +121,37 @@ function CreateTestMenu() local Idx = tag - 10000 local testScene = CreateTestScene(Idx) if testScene then - CCDirector:getInstance():replaceScene(testScene) + cc.Director:getInstance():replaceScene(testScene) end end -- add close menu - local s = CCDirector:getInstance():getWinSize() - local CloseItem = CCMenuItemImage:create(s_pPathClose, s_pPathClose) + local s = cc.Director:getInstance():getWinSize() + local CloseItem = cc.MenuItemImage:create(s_pPathClose, s_pPathClose) CloseItem:registerScriptTapHandler(closeCallback) - CloseItem:setPosition(CCPoint(s.width - 30, s.height - 30)) + CloseItem:setPosition(cc.p(s.width - 30, s.height - 30)) - local CloseMenu = CCMenu:create() + local CloseMenu = cc.Menu:create() CloseMenu:setPosition(0, 0) CloseMenu:addChild(CloseItem) menuLayer:addChild(CloseMenu) -- add menu items for tests - local MainMenu = CCMenu:create() + local MainMenu = cc.Menu:create() local index = 0 local obj = nil for index, obj in pairs(_allTests) do - local testLabel = CCLabelTTF:create(obj.name, "Arial", 24) - local testMenuItem = CCMenuItemLabel:create(testLabel) + local testLabel = cc.LabelTTF:create(obj.name, "Arial", 24) + local testMenuItem = cc.MenuItemLabel:create(testLabel) if not obj.isSupported then testMenuItem:setEnabled(false) end testMenuItem:registerScriptTapHandler(menuCallback) - testMenuItem:setPosition(CCPoint(s.width / 2, (s.height - (index) * LINE_SPACE))) + testMenuItem:setPosition(cc.p(s.width / 2, (s.height - (index) * LINE_SPACE))) MainMenu:addChild(testMenuItem, index + 10000, index + 10000) end - MainMenu:setContentSize(CCSize(s.width, (TESTS_COUNT + 1) * (LINE_SPACE))) + MainMenu:setContentSize(cc.size(s.width, (TESTS_COUNT + 1) * (LINE_SPACE))) MainMenu:setPosition(CurPos.x, CurPos.y) menuLayer:addChild(MainMenu) @@ -155,9 +164,10 @@ function CreateTestMenu() local function onTouchMoved(x, y) local nMoveY = y - BeginPos.y - local curPosx, curPosy = MainMenu:getPosition() + local curPos = MainMenu:getPosition() + local curPosx, curPosy = curPos.x,curPos.y local nextPosy = curPosy + nMoveY - local winSize = CCDirector:getInstance():getWinSize() + local winSize = cc.Director:getInstance():getWinSize() if nextPosy < 0 then MainMenu:setPosition(0, 0) return diff --git a/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id b/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id index 543b758f11..98d25f9bbc 100644 --- a/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -daaf13ab82feffbd1c8e201d76cb83ed8f2dabca \ No newline at end of file +1cee6156624b42a16c97a0095a036f0b51b68e48 \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/CCLuaEngine.cpp b/scripting/lua/cocos2dx_support/CCLuaEngine.cpp index a5b18cb394..7bd6c2a65a 100644 --- a/scripting/lua/cocos2dx_support/CCLuaEngine.cpp +++ b/scripting/lua/cocos2dx_support/CCLuaEngine.cpp @@ -312,7 +312,7 @@ int LuaEngine::handleMenuClickedEvent(void* data) return 0; _stack->pushInt(menuItem->getTag()); - _stack->pushObject(menuItem, "CCMenuItem"); + _stack->pushObject(menuItem, "MenuItem"); int ret = _stack->executeFunctionByHandler(handler, 2); _stack->clean(); return ret; @@ -357,7 +357,7 @@ int LuaEngine::handleCallFuncActionEvent(void* data) Object* target = static_cast(basicScriptData->value); if (NULL != target) { - _stack->pushObject(target, "CCNode"); + _stack->pushObject(target, "Node"); } int ret = _stack->executeFunctionByHandler(handler, target ? 1 : 0); _stack->clean(); diff --git a/scripting/lua/cocos2dx_support/CCLuaStack.cpp b/scripting/lua/cocos2dx_support/CCLuaStack.cpp index a99835927b..e8ff07d4dc 100644 --- a/scripting/lua/cocos2dx_support/CCLuaStack.cpp +++ b/scripting/lua/cocos2dx_support/CCLuaStack.cpp @@ -126,6 +126,7 @@ bool LuaStack::init(void) }; luaL_register(_state, "_G", global_functions); register_all_cocos2dx(_state); + tolua_opengl_open(_state); register_all_cocos2dx_extension(_state); register_all_cocos2dx_manual(_state); #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) @@ -135,7 +136,6 @@ bool LuaStack::init(void) #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) tolua_web_socket_open(_state); #endif - tolua_opengl_open(_state); tolua_scroll_view_open(_state); tolua_script_handler_mgr_open(_state); diff --git a/scripting/lua/cocos2dx_support/LuaBasicConversions.cpp b/scripting/lua/cocos2dx_support/LuaBasicConversions.cpp index 5c35fa0199..e26a3d41df 100644 --- a/scripting/lua/cocos2dx_support/LuaBasicConversions.cpp +++ b/scripting/lua/cocos2dx_support/LuaBasicConversions.cpp @@ -829,6 +829,58 @@ bool luaval_to_dictionary(lua_State* L,int lo, Dictionary** outValue) return ok; } +bool luaval_to_array_of_Point(lua_State* L,int lo,Point **points, int *numPoints) +{ + if (NULL == L) + return false; + + bool ok = true; + +#if COCOS2D_DEBUG >=1 + tolua_Error tolua_err; + if (!tolua_istable(L, lo, 0, &tolua_err) ) + { + luaval_to_native_err(L,"#ferror:",&tolua_err); + ok = false; + } +#endif + + if (ok) + { + size_t len = lua_objlen(L, lo); + if (len > 0) + { + Point* array = (Point*)malloc(sizeof(Point) * len); + if (NULL == array) + return false; + for (uint32_t i = 0; i < len; ++i) + { + lua_pushnumber(L,i + 1); + lua_gettable(L,lo); + if (!tolua_istable(L,-1, 0, &tolua_err)) + { + luaval_to_native_err(L,"#ferror:",&tolua_err); + lua_pop(L, 1); + free(array); + return false; + } + ok &= luaval_to_point(L, lua_gettop(L), &array[i]); + if (!ok) + { + lua_pop(L, 1); + free(array); + return false; + } + lua_pop(L, 1); + } + + *numPoints = len; + *points = array; + } + } + return ok; +} + void point_to_luaval(lua_State* L,const Point& pt) { if (NULL == L) diff --git a/scripting/lua/cocos2dx_support/LuaBasicConversions.h b/scripting/lua/cocos2dx_support/LuaBasicConversions.h index 93d868d0e5..bbd6dca25a 100644 --- a/scripting/lua/cocos2dx_support/LuaBasicConversions.h +++ b/scripting/lua/cocos2dx_support/LuaBasicConversions.h @@ -28,6 +28,7 @@ extern bool luaval_to_affinetransform(lua_State* L,int lo, AffineTransform* outV extern bool luaval_to_fontdefinition(lua_State* L, int lo, FontDefinition* outValue ); extern bool luaval_to_array(lua_State* L,int lo, Array** outValue); extern bool luaval_to_dictionary(lua_State* L,int lo, Dictionary** outValue); +extern bool luaval_to_array_of_Point(lua_State* L,int lo,Point **points, int *numPoints); // from native extern void point_to_luaval(lua_State* L,const Point& pt); diff --git a/scripting/lua/cocos2dx_support/LuaOpengl.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/LuaOpengl.cpp.REMOVED.git-id index 0d4f20ac67..937b18fb64 100644 --- a/scripting/lua/cocos2dx_support/LuaOpengl.cpp.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/LuaOpengl.cpp.REMOVED.git-id @@ -1 +1 @@ -db5d393a48a8e12b2a8a0fefef11c4bb7c494d56 \ No newline at end of file +b3460818609e566b063e1c9b7404650048c81121 \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_manual.cpp b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_manual.cpp index 388eff474b..bf2ff83e2c 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_manual.cpp +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_manual.cpp @@ -15,6 +15,9 @@ extern "C" { static int tolua_cocos2d_MenuItemImage_create(lua_State* tolua_S) { + if (NULL == tolua_S) + return 0; + int argc = 0; bool ok = true; @@ -90,8 +93,48 @@ tolua_lerror: } +static int tolua_cocos2d_MenuItemLabel_create(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertable(tolua_S,1,"MenuItemLabel",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + if(1 == argc) + { + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,2,"Node",0,&tolua_err) ) + { + goto tolua_lerror; + } +#endif + Node* label = ((Node*) tolua_tousertype(tolua_S,2,0)); + MenuItemLabel* tolua_ret = (MenuItemLabel*) MenuItemLabel::create(label); + 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,"MenuItemLabel"); + return 1; + } + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); + return 0; +#endif +} + static int tolua_cocos2d_Menu_create(lua_State* tolua_S) { + if (NULL == tolua_S) + return 0; + int argc = 0; #if COCOS2D_DEBUG >= 1 @@ -105,13 +148,13 @@ static int tolua_cocos2d_Menu_create(lua_State* tolua_S) cocos2d::Array* array = cocos2d::Array::create(); if (NULL == array) { - printf("Menu create method create array fail\n"); + CCLOG("Menu create method create array fail\n"); return 0; } uint32_t i = 1; while (i <= argc) { - if (!tolua_isuserdata(tolua_S, 1 + i, 0, &tolua_err) ) + if (!tolua_isusertype(tolua_S, 1 + i, "Object", 0, &tolua_err)) { goto tolua_lerror; return 0; @@ -153,6 +196,9 @@ tolua_lerror: //tolua_cocos2d_Menu_create static int tolua_cocos2d_MenuItem_registerScriptTapHandler(lua_State* tolua_S) { + if (NULL == tolua_S) + return 0; + int argc = 0; MenuItem* cobj = nullptr; #if COCOS2D_DEBUG >= 1 @@ -184,13 +230,16 @@ static int tolua_cocos2d_MenuItem_registerScriptTapHandler(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'registerScriptHandler'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'registerScriptTapHandler'.",&tolua_err); return 0; #endif } static int tolua_cocos2d_MenuItem_unregisterScriptTapHandler(lua_State* tolua_S) { + if (NULL == tolua_S) + return 0; + int argc = 0; MenuItem* cobj = nullptr; @@ -228,6 +277,9 @@ tolua_lerror: static int tolua_cocos2d_Layer_registerScriptTouchHandler(lua_State* tolua_S) { + if (NULL == tolua_S) + return 0; + int argc = 0; Layer* self = nullptr; @@ -307,6 +359,9 @@ tolua_lerror: static int tolua_cocos2d_Layer_unregisterScriptTouchHandler(lua_State* tolua_S) { + if (NULL == tolua_S) + return 0; + int argc = 0; Layer* self = nullptr; @@ -343,8 +398,11 @@ tolua_lerror: } -static int tolua_cocos2d_Scheduler_scheduleScriptFunc00(lua_State* tolua_S) +static int tolua_cocos2d_Scheduler_scheduleScriptFunc(lua_State* tolua_S) { + if (NULL == tolua_S) + return 0; + int argc = 0; Scheduler* self = nullptr; @@ -357,7 +415,7 @@ static int tolua_cocos2d_Scheduler_scheduleScriptFunc00(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (nullptr == self) { - tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Scheduler_scheduleScriptFunc00'\n", NULL); + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Scheduler_scheduleScriptFunc'\n", NULL); return 0; } #endif @@ -393,6 +451,9 @@ tolua_lerror: static int tolua_cocos2d_Scheduler_unscheduleScriptEntry(lua_State* tolua_S) { + if (NULL == tolua_S) + return 0; + int argc = 0; Scheduler* self = nullptr; @@ -434,6 +495,547 @@ tolua_lerror: #endif } +static int tolua_cocos2d_Sequence_create(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertable(tolua_S,1,"Sequence",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + if(argc > 0) + { + cocos2d::Array* array = cocos2d::Array::create(); + if (NULL == array) + { + CCLOG("Sequence create method create array fail\n"); + return 0; + } + uint32_t i = 1; + while (i <= argc) + { + if (!tolua_isusertype(tolua_S, 1 + i, "Object", 0, &tolua_err)) + { + goto tolua_lerror; + return 0; + } + + cocos2d::Object* item = static_cast(tolua_tousertype(tolua_S, 1 + i, NULL)); + if (NULL != item) + { + array->addObject(item); + ++i; + } + + } + cocos2d::Sequence* tolua_ret = cocos2d::Sequence::create(array); + //issue 2433 uncheck + 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; + } + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2d_CallFunc_create(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertable(tolua_S,1,"CallFunc",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 1) + { +#if COCOS2D_DEBUG >= 1 + if(!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err)) + goto tolua_lerror; +#endif + + LUA_FUNCTION funcID = ( toluafix_ref_function(tolua_S,2,0)); + LuaCallFunc* tolua_ret = (LuaCallFunc*) LuaCallFunc::create(funcID); + 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,"CallFunc"); + return 1; + } + + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); + return 0; +#endif + +} + +static int tolua_cocos2d_Node_registerScriptHandler(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + Node* node = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"Node",0,&tolua_err)) goto tolua_lerror; +#endif + + node = static_cast(tolua_tousertype(tolua_S,1,0)); + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 1) + { +#if COCOS2D_DEBUG >= 1 + if(!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err)) + goto tolua_lerror; +#endif + + LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0)); + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)node, handler, ScriptHandlerMgr::kNodeHandler); + + return 0; + } + + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'registerScriptHandler'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2d_Node_unregisterScriptHandler(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + Node* node = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"Node",0,&tolua_err)) goto tolua_lerror; +#endif + + node = static_cast(tolua_tousertype(tolua_S,1,0)); + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 0) + { + ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)node, ScriptHandlerMgr::kNodeHandler); + return 0; + } + + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'unregisterScriptHandler'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2d_Spawn_create(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertable(tolua_S,1,"Spawn",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc > 0) + { + cocos2d::Array* array = cocos2d::Array::create(); + if (NULL == array) + { + CCLOG("Spawn create method create array fail\n"); + return 0; + } + + uint32_t i = 1; + while (i <= argc) + { + if (!tolua_isusertype(tolua_S, 1 + i, "Object", 0, &tolua_err)) + { + goto tolua_lerror; + return 0; + } + + cocos2d::Object* item = static_cast(tolua_tousertype(tolua_S, 1 + i, NULL)); + if (NULL != item) + { + array->addObject(item); + ++i; + } + } + + cocos2d::Spawn * tolua_ret = cocos2d::Spawn::create(array); + 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; + } + + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2d_CardinalSplineBy_create(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertable(tolua_S,1,"CardinalSplineBy",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 3) + { + double dur = 0.0; + ok &= luaval_to_number(tolua_S, 2, &dur); + if (!ok) + return false; + + int num = 0; + Point *arr = NULL; + ok &= luaval_to_array_of_Point(tolua_S, 3, &arr, &num); + if (!ok) + return false; + + double ten = 0.0; + ok &= luaval_to_number(tolua_S, 4, &ten); + if (!ok) + return false; + + if (num > 0) + { + PointArray* points = PointArray::create(num); + + if (NULL == points) + { + free(arr); + return 0; + } + + for( int i = 0; i < num; i++) { + points->addControlPoint(arr[i]); + } + + free(arr); + CardinalSplineBy* tolua_ret = CardinalSplineBy::create(dur, points, ten); + if (NULL != tolua_ret) + { + 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,"CardinalSplineBy"); + return 1; + } + } + } + + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 3); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2d_CatmullRomBy_create(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertable(tolua_S,1,"CatmullRomBy",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 2) + { + double dur = 0.0; + ok &= luaval_to_number(tolua_S, 2, &dur); + if (!ok) + return false; + + int num = 0; + Point *arr = NULL; + ok &= luaval_to_array_of_Point(tolua_S, 3, &arr, &num); + if (!ok) + return false; + + if (num > 0) + { + PointArray* points = PointArray::create(num); + + if (NULL == points) + { + free(arr); + return 0; + } + + for( int i = 0; i < num; i++) { + points->addControlPoint(arr[i]); + } + + free(arr); + CatmullRomBy* tolua_ret = CatmullRomBy::create(dur, points); + if (NULL != tolua_ret) + { + 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,"CatmullRomBy"); + return 1; + } + } + } + + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 2); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2d_CatmullRomTo_create(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertable(tolua_S,1,"CatmullRomTo",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 2) + { + double dur = 0.0; + ok &= luaval_to_number(tolua_S, 2, &dur); + if (!ok) + return false; + + int num = 0; + Point *arr = NULL; + ok &= luaval_to_array_of_Point(tolua_S, 3, &arr, &num); + if (!ok) + return false; + + if (num > 0) + { + PointArray* points = PointArray::create(num); + + if (NULL == points) + { + free(arr); + return 0; + } + + for( int i = 0; i < num; i++) { + points->addControlPoint(arr[i]); + } + + free(arr); + CatmullRomTo* tolua_ret = CatmullRomTo::create(dur, points); + if (NULL != tolua_ret) + { + 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,"CatmullRomTo"); + return 1; + } + } + } + + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 2); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2d_BezierBy_create(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertable(tolua_S,1,"BezierBy",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 2) + { + double t = 0.0; + ok &= luaval_to_number(tolua_S, 2, &t); + if (!ok) + return false; + + int num = 0; + Point *arr = NULL; + ok &= luaval_to_array_of_Point(tolua_S, 3, &arr, &num); + if (!ok) + return false; + + if (num < 3) + { + free(arr); + return false; + } + + ccBezierConfig config; + config.controlPoint_1 = arr[0]; + config.controlPoint_2 = arr[1]; + config.endPosition = arr[2]; + free(arr); + + BezierBy* tolua_ret = BezierBy::create(t, config); + if (NULL != tolua_ret) + { + 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,"BezierBy"); + return 1; + } + } + + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 2); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2d_BezierTo_create(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertable(tolua_S,1,"BezierTo",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 2) + { + double t = 0.0; + ok &= luaval_to_number(tolua_S, 2, &t); + if (!ok) + return false; + + int num = 0; + Point *arr = NULL; + ok &= luaval_to_array_of_Point(tolua_S, 3, &arr, &num); + if (!ok) + return false; + + if (num < 3) + { + free(arr); + return false; + } + + ccBezierConfig config; + config.controlPoint_1 = arr[0]; + config.controlPoint_2 = arr[1]; + config.endPosition = arr[2]; + free(arr); + + BezierTo* tolua_ret = BezierTo::create(t, config); + if (NULL != tolua_ret) + { + 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,"BezierTo"); + return 1; + } + } + + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 2); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); + return 0; +#endif +} //void lua_extend_cocos2dx_MenuItem //{ // @@ -465,6 +1067,15 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) lua_rawset(tolua_S,-3); } + lua_pushstring(tolua_S, "MenuItemLabel"); + lua_rawget(tolua_S,LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"create"); + lua_pushcfunction(tolua_S,tolua_cocos2d_MenuItemLabel_create); + lua_rawset(tolua_S,-3); + } + lua_pushstring(tolua_S, "Menu"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S, -1)) @@ -474,6 +1085,18 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) lua_rawset(tolua_S,-3); } + lua_pushstring(tolua_S,"Node"); + lua_rawget(tolua_S,LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"registerScriptHandler"); + lua_pushcfunction(tolua_S,tolua_cocos2d_Node_registerScriptHandler); + lua_rawset(tolua_S,-3); + lua_pushstring(tolua_S,"unregisterScriptHandler"); + lua_pushcfunction(tolua_S,tolua_cocos2d_Node_unregisterScriptHandler); + lua_rawset(tolua_S, -3); + } + lua_pushstring(tolua_S,"Layer"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) @@ -503,11 +1126,86 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"scheduleScriptFunc"); - lua_pushcfunction(tolua_S,tolua_cocos2d_Scheduler_scheduleScriptFunc00); + lua_pushcfunction(tolua_S,tolua_cocos2d_Scheduler_scheduleScriptFunc); lua_rawset(tolua_S,-3); lua_pushstring(tolua_S, "unscheduleScriptEntry"); lua_pushcfunction(tolua_S,tolua_cocos2d_Scheduler_unscheduleScriptEntry); lua_rawset(tolua_S, -3); } + + lua_pushstring(tolua_S,"Sequence"); + lua_rawget(tolua_S,LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"create"); + lua_pushcfunction(tolua_S,tolua_cocos2d_Sequence_create); + lua_rawset(tolua_S,-3); + } + + lua_pushstring(tolua_S,"CallFunc"); + lua_rawget(tolua_S,LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"create"); + lua_pushcfunction(tolua_S,tolua_cocos2d_CallFunc_create); + lua_rawset(tolua_S,-3); + } + + lua_pushstring(tolua_S,"Spawn"); + lua_rawget(tolua_S,LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"create"); + lua_pushcfunction(tolua_S,tolua_cocos2d_Spawn_create); + lua_rawset(tolua_S,-3); + } + + lua_pushstring(tolua_S,"CardinalSplineBy"); + lua_rawget(tolua_S,LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"create"); + lua_pushcfunction(tolua_S,tolua_cocos2d_CardinalSplineBy_create); + lua_rawset(tolua_S,-3); + } + + lua_pushstring(tolua_S,"CatmullRomBy"); + lua_rawget(tolua_S,LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"create"); + lua_pushcfunction(tolua_S,tolua_cocos2d_CatmullRomBy_create); + lua_rawset(tolua_S,-3); + } + + lua_pushstring(tolua_S,"CatmullRomTo"); + lua_rawget(tolua_S,LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"create"); + lua_pushcfunction(tolua_S,tolua_cocos2d_CatmullRomTo_create); + lua_rawset(tolua_S,-3); + } + + lua_pushstring(tolua_S,"BezierBy"); + lua_rawget(tolua_S,LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"create"); + lua_pushcfunction(tolua_S,tolua_cocos2d_BezierBy_create); + lua_rawset(tolua_S,-3); + } + + lua_pushstring(tolua_S,"BezierTo"); + lua_rawget(tolua_S,LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"create"); + lua_pushcfunction(tolua_S,tolua_cocos2d_BezierTo_create); + lua_rawset(tolua_S,-3); + } + + + return 0; } \ No newline at end of file diff --git a/scripting/lua/script/Cocos2d.lua b/scripting/lua/script/Cocos2d.lua new file mode 100644 index 0000000000..98c1b8e5f8 --- /dev/null +++ b/scripting/lua/script/Cocos2d.lua @@ -0,0 +1,28 @@ +cc = cc or {} + +--Point +function cc.p(_x,_y) + return { x = _x, y = _y } +end + +--Size +function cc.size( _width,_height ) + return { width = _width, height = _height } +end + +--Rect +function cc.rect(_x,_y,_width,_height) + return { x = _x, y = _y, width = _width, height = _height } +end + +--Color3B +function cc.c3b( _r,_g,_b ) + return { r = _r, g = _g, b = _b } +end + +--Color4B +function cc.c4b( _r,_g,_b,_a ) + return { r = _r, g = _g, b = _b, a = _a } +end + + diff --git a/scripting/lua/script/Cocos2dConstants.lua b/scripting/lua/script/Cocos2dConstants.lua index 55828a8f51..a86697dfef 100644 --- a/scripting/lua/script/Cocos2dConstants.lua +++ b/scripting/lua/script/Cocos2dConstants.lua @@ -1,178 +1,165 @@ -local CCConstants = {} +cc = cc or {} -CCConstants.SPRITE_INDEX_NOT_INITIALIZED = 0xffffffff -CCConstants.TMX_ORIENTATION_HEX = 0x1 -CCConstants.TMX_ORIENTATION_ISO = 0x2 -CCConstants.TMX_ORIENTATION_ORTHO = 0x0 -CCConstants.Z_COMPRESSION_BZIP2 = 0x1 -CCConstants.Z_COMPRESSION_GZIP = 0x2 -CCConstants.Z_COMPRESSION_NONE = 0x3 -CCConstants.Z_COMPRESSION_ZLIB = 0x0 -CCConstants.BLEND_DST = 0x303 -CCConstants.BLEND_SRC = 0x1 -CCConstants.DIRECTOR_IOS_USE_BACKGROUND_THREAD = 0x0 -CCConstants.DIRECTOR_MAC_THREAD = 0x0 -CCConstants.DIRECTOR_STATS_INTERVAL = 0.1 -CCConstants.ENABLE_BOX2_D_INTEGRATION = 0x0 -CCConstants.ENABLE_DEPRECATED = 0x1 -CCConstants.ENABLE_GL_STATE_CACHE = 0x1 -CCConstants.ENABLE_PROFILERS = 0x0 -CCConstants.ENABLE_STACKABLE_ACTIONS = 0x1 -CCConstants.FIX_ARTIFACTS_BY_STRECHING_TEXEL = 0x0 -CCConstants.GL_ALL = 0x0 -CCConstants.LABELATLAS_DEBUG_DRAW = 0x0 -CCConstants.LABELBMFONT_DEBUG_DRAW = 0x0 -CCConstants.MAC_USE_DISPLAY_LINK_THREAD = 0x0 -CCConstants.MAC_USE_MAIN_THREAD = 0x2 -CCConstants.MAC_USE_OWN_THREAD = 0x1 -CCConstants.NODE_RENDER_SUBPIXEL = 0x1 -CCConstants.PVRMIPMAP_MAX = 0x10 -CCConstants.SPRITEBATCHNODE_RENDER_SUBPIXEL = 0x1 -CCConstants.SPRITE_DEBUG_DRAW = 0x0 -CCConstants.TEXTURE_ATLAS_USE_TRIANGLE_STRIP = 0x0 -CCConstants.TEXTURE_ATLAS_USE_VAO = 0x1 -CCConstants.USE_L_A88_LABELS = 0x1 -CCConstants.ACTION_TAG_INVALID = -1 -CCConstants.DEVICE_MAC = 0x6 -CCConstants.DEVICE_MAC_RETINA_DISPLAY = 0x7 -CCConstants.DEVICEI_PAD = 0x4 -CCConstants.DEVICEI_PAD_RETINA_DISPLAY = 0x5 -CCConstants.DEVICEI_PHONE = 0x0 -CCConstants.DEVICEI_PHONE5 = 0x2 -CCConstants.DEVICEI_PHONE5_RETINA_DISPLAY = 0x3 -CCConstants.DEVICEI_PHONE_RETINA_DISPLAY = 0x1 -CCConstants.DIRECTOR_PROJECTION2_D = 0x0 -CCConstants.DIRECTOR_PROJECTION3_D = 0x1 -CCConstants.DIRECTOR_PROJECTION_CUSTOM = 0x2 -CCConstants.DIRECTOR_PROJECTION_DEFAULT = 0x1 -CCConstants.FILE_UTILS_SEARCH_DIRECTORY_MODE = 0x1 -CCConstants.FILE_UTILS_SEARCH_SUFFIX_MODE = 0x0 -CCConstants.FLIPED_ALL = 0xe0000000 -CCConstants.FLIPPED_MASK = 0x1fffffff -CCConstants.IMAGE_FORMAT_JPEG = 0x0 -CCConstants.IMAGE_FORMAT_PNG = 0x1 -CCConstants.ITEM_SIZE = 0x20 -CCConstants.LABEL_AUTOMATIC_WIDTH = -1 -CCConstants.LINE_BREAK_MODE_CHARACTER_WRAP = 0x1 -CCConstants.LINE_BREAK_MODE_CLIP = 0x2 -CCConstants.LINE_BREAK_MODE_HEAD_TRUNCATION = 0x3 -CCConstants.LINE_BREAK_MODE_MIDDLE_TRUNCATION = 0x5 -CCConstants.LINE_BREAK_MODE_TAIL_TRUNCATION = 0x4 -CCConstants.LINE_BREAK_MODE_WORD_WRAP = 0x0 -CCConstants.MAC_VERSION_10_6 = 0xa060000 -CCConstants.MAC_VERSION_10_7 = 0xa070000 -CCConstants.MAC_VERSION_10_8 = 0xa080000 -CCConstants.MENU_HANDLER_PRIORITY = -128 -CCConstants.MENU_STATE_TRACKING_TOUCH = 0x1 -CCConstants.MENU_STATE_WAITING = 0x0 -CCConstants.NODE_TAG_INVALID = -1 -CCConstants.PARTICLE_DURATION_INFINITY = -1 -CCConstants.PARTICLE_MODE_GRAVITY = 0x0 -CCConstants.PARTICLE_MODE_RADIUS = 0x1 -CCConstants.PARTICLE_START_RADIUS_EQUAL_TO_END_RADIUS = -1 -CCConstants.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE = -1 -CCConstants.POSITION_TYPE_FREE = 0x0 -CCConstants.POSITION_TYPE_GROUPED = 0x2 -CCConstants.POSITION_TYPE_RELATIVE = 0x1 -CCConstants.PRIORITY_NON_SYSTEM_MIN = -2147483647 -CCConstants.PRIORITY_SYSTEM = -2147483648 -CCConstants.PROGRESS_TIMER_TYPE_BAR = 0x1 -CCConstants.PROGRESS_TIMER_TYPE_RADIAL = 0x0 -CCConstants.REPEAT_FOREVER = 0xfffffffe -CCConstants.RESOLUTION_MAC = 0x1 -CCConstants.RESOLUTION_MAC_RETINA_DISPLAY = 0x2 -CCConstants.RESOLUTION_UNKNOWN = 0x0 -CCConstants.TMX_TILE_DIAGONAL_FLAG = 0x20000000 -CCConstants.TMX_TILE_HORIZONTAL_FLAG = 0x80000000 -CCConstants.TMX_TILE_VERTICAL_FLAG = 0x40000000 -CCConstants.TEXT_ALIGNMENT_CENTER = 0x1 -CCConstants.TEXT_ALIGNMENT_LEFT = 0x0 -CCConstants.TEXT_ALIGNMENT_RIGHT = 0x2 -CCConstants.TEXTURE2_D_PIXEL_FORMAT_A8 = 0x3 -CCConstants.TEXTURE2_D_PIXEL_FORMAT_A_I88 = 0x5 -CCConstants.TEXTURE2_D_PIXEL_FORMAT_DEFAULT = 0x0 -CCConstants.TEXTURE2_D_PIXEL_FORMAT_I8 = 0x4 -CCConstants.TEXTURE2_D_PIXEL_FORMAT_PVRTC2 = 0x9 -CCConstants.TEXTURE2_D_PIXEL_FORMAT_PVRTC4 = 0x8 -CCConstants.TEXTURE2_D_PIXEL_FORMAT_RG_B565 = 0x2 -CCConstants.TEXTURE2_D_PIXEL_FORMAT_RGB5_A1 = 0x7 -CCConstants.TEXTURE2_D_PIXEL_FORMAT_RG_B888 = 0x1 -CCConstants.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444 = 0x6 -CCConstants.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888 = 0x0 -CCConstants.TOUCHES_ALL_AT_ONCE = 0x0 -CCConstants.TOUCHES_ONE_BY_ONE = 0x1 -CCConstants.TRANSITION_ORIENTATION_DOWN_OVER = 0x1 -CCConstants.TRANSITION_ORIENTATION_LEFT_OVER = 0x0 -CCConstants.TRANSITION_ORIENTATION_RIGHT_OVER = 0x1 -CCConstants.TRANSITION_ORIENTATION_UP_OVER = 0x0 -CCConstants.UNIFORM_COS_TIME = 0x5 -CCConstants.UNIFORM_MV_MATRIX = 0x1 -CCConstants.UNIFORM_MVP_MATRIX = 0x2 -CCConstants.UNIFORM_P_MATRIX = 0x0 -CCConstants.UNIFORM_RANDOM01 = 0x6 -CCConstants.UNIFORM_SAMPLER = 0x7 -CCConstants.UNIFORM_SIN_TIME = 0x4 -CCConstants.UNIFORM_TIME = 0x3 -CCConstants.UNIFORM_MAX = 0x8 -CCConstants.VERTEX_ATTRIB_FLAG_COLOR = 0x2 -CCConstants.VERTEX_ATTRIB_FLAG_NONE = 0x0 -CCConstants.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX = 0x7 -CCConstants.VERTEX_ATTRIB_FLAG_POSITION = 0x1 -CCConstants.VERTEX_ATTRIB_FLAG_TEX_COORDS = 0x4 -CCConstants.VERTEX_ATTRIB_COLOR = 0x1 -CCConstants.VERTEX_ATTRIB_MAX = 0x3 -CCConstants.VERTEX_ATTRIB_POSITION = 0x0 -CCConstants.VERTEX_ATTRIB_TEX_COORDS = 0x2 -CCConstants.VERTICAL_TEXT_ALIGNMENT_BOTTOM = 0x2 -CCConstants.VERTICAL_TEXT_ALIGNMENT_CENTER = 0x1 -CCConstants.VERTICAL_TEXT_ALIGNMENT_TOP = 0x0 -CCConstants.OS_VERSION_4_0 = 0x4000000 -CCConstants.OS_VERSION_4_0_1 = 0x4000100 -CCConstants.OS_VERSION_4_1 = 0x4010000 -CCConstants.OS_VERSION_4_2 = 0x4020000 -CCConstants.OS_VERSION_4_2_1 = 0x4020100 -CCConstants.OS_VERSION_4_3 = 0x4030000 -CCConstants.OS_VERSION_4_3_1 = 0x4030100 -CCConstants.OS_VERSION_4_3_2 = 0x4030200 -CCConstants.OS_VERSION_4_3_3 = 0x4030300 -CCConstants.OS_VERSION_4_3_4 = 0x4030400 -CCConstants.OS_VERSION_4_3_5 = 0x4030500 -CCConstants.OS_VERSION_5_0 = 0x5000000 -CCConstants.OS_VERSION_5_0_1 = 0x5000100 -CCConstants.OS_VERSION_5_1_0 = 0x5010000 -CCConstants.OS_VERSION_6_0_0 = 0x6000000 -CCConstants.ANIMATION_FRAME_DISPLAYED_NOTIFICATION = 'CCAnimationFrameDisplayedNotification' -CCConstants.CHIPMUNK_IMPORT = 'chipmunk.h' -CCConstants.ATTRIBUTE_NAME_COLOR = 'a_color' -CCConstants.ATTRIBUTE_NAME_POSITION = 'a_position' -CCConstants.ATTRIBUTE_NAME_TEX_COORD = 'a_texCoord' -CCConstants.SHADER_POSITION_COLOR = 'ShaderPositionColor' -CCConstants.SHADER_POSITION_LENGTH_TEXURE_COLOR = 'ShaderPositionLengthTextureColor' -CCConstants.SHADER_POSITION_TEXTURE = 'ShaderPositionTexture' -CCConstants.SHADER_POSITION_TEXTURE_A8_COLOR = 'ShaderPositionTextureA8Color' -CCConstants.SHADER_POSITION_TEXTURE_COLOR = 'ShaderPositionTextureColor' -CCConstants.SHADER_POSITION_TEXTURE_COLOR_ALPHA_TEST = 'ShaderPositionTextureColorAlphaTest' -CCConstants.SHADER_POSITION_TEXTURE_U_COLOR = 'ShaderPositionTexture_uColor' -CCConstants.SHADER_POSITION_U_COLOR = 'ShaderPosition_uColor' -CCConstants.UNIFORM_ALPHA_TEST_VALUE_S = 'CC_AlphaValue' -CCConstants.UNIFORM_COS_TIME_S = 'CC_CosTime' -CCConstants.UNIFORM_MV_MATRIX_S = 'CC_MVMatrix' -CCConstants.UNIFORM_MVP_MATRIX_S = 'CC_MVPMatrix' -CCConstants.UNIFORM_P_MATRIX_S = 'CC_PMatrix' -CCConstants.UNIFORM_RANDOM01_S = 'CC_Random01' -CCConstants.UNIFORM_SAMPLER_S = 'CC_Texture0' -CCConstants.UNIFORM_SIN_TIME_S = 'CC_SinTime' -CCConstants.UNIFORM_TIME_S = 'CC_Time' - - -local modename = "CCConstants" -local CCConstantsproxy = {} -local CCConstantsMt = { - __index = CCConstants, - __newindex = function (t ,k ,v) - print("attemp to update a read-only table") - end -} -setmetatable(CCConstantsproxy,CCConstantsMt) -_G[modename] = CCConstantsproxy -package.loaded[modename] = CCConstantsproxy +cc.SPRITE_INDEX_NOT_INITIALIZED = 0xffffffff +cc.TMX_ORIENTATION_HEX = 0x1 +cc.TMX_ORIENTATION_ISO = 0x2 +cc.TMX_ORIENTATION_ORTHO = 0x0 +cc.Z_COMPRESSION_BZIP2 = 0x1 +cc.Z_COMPRESSION_GZIP = 0x2 +cc.Z_COMPRESSION_NONE = 0x3 +cc.Z_COMPRESSION_ZLIB = 0x0 +cc.BLEND_DST = 0x303 +cc.BLEND_SRC = 0x1 +cc.DIRECTOR_IOS_USE_BACKGROUND_THREAD = 0x0 +cc.DIRECTOR_MAC_THREAD = 0x0 +cc.DIRECTOR_STATS_INTERVAL = 0.1 +cc.ENABLE_BOX2_D_INTEGRATION = 0x0 +cc.ENABLE_DEPRECATED = 0x1 +cc.ENABLE_GL_STATE_CACHE = 0x1 +cc.ENABLE_PROFILERS = 0x0 +cc.ENABLE_STACKABLE_ACTIONS = 0x1 +cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL = 0x0 +cc.GL_ALL = 0x0 +cc.LABELATLAS_DEBUG_DRAW = 0x0 +cc.LABELBMFONT_DEBUG_DRAW = 0x0 +cc.MAC_USE_DISPLAY_LINK_THREAD = 0x0 +cc.MAC_USE_MAIN_THREAD = 0x2 +cc.MAC_USE_OWN_THREAD = 0x1 +cc.NODE_RENDER_SUBPIXEL = 0x1 +cc.PVRMIPMAP_MAX = 0x10 +cc.SPRITEBATCHNODE_RENDER_SUBPIXEL = 0x1 +cc.SPRITE_DEBUG_DRAW = 0x0 +cc.TEXTURE_ATLAS_USE_TRIANGLE_STRIP = 0x0 +cc.TEXTURE_ATLAS_USE_VAO = 0x1 +cc.USE_L_A88_LABELS = 0x1 +cc.ACTION_TAG_INVALID = -1 +cc.DEVICE_MAC = 0x6 +cc.DEVICE_MAC_RETINA_DISPLAY = 0x7 +cc.DEVICEI_PAD = 0x4 +cc.DEVICEI_PAD_RETINA_DISPLAY = 0x5 +cc.DEVICEI_PHONE = 0x0 +cc.DEVICEI_PHONE5 = 0x2 +cc.DEVICEI_PHONE5_RETINA_DISPLAY = 0x3 +cc.DEVICEI_PHONE_RETINA_DISPLAY = 0x1 +cc.DIRECTOR_PROJECTION2_D = 0x0 +cc.DIRECTOR_PROJECTION3_D = 0x1 +cc.DIRECTOR_PROJECTION_CUSTOM = 0x2 +cc.DIRECTOR_PROJECTION_DEFAULT = 0x1 +cc.FILE_UTILS_SEARCH_DIRECTORY_MODE = 0x1 +cc.FILE_UTILS_SEARCH_SUFFIX_MODE = 0x0 +cc.FLIPED_ALL = 0xe0000000 +cc.FLIPPED_MASK = 0x1fffffff +cc.IMAGE_FORMAT_JPEG = 0x0 +cc.IMAGE_FORMAT_PNG = 0x1 +cc.ITEM_SIZE = 0x20 +cc.LABEL_AUTOMATIC_WIDTH = -1 +cc.LINE_BREAK_MODE_CHARACTER_WRAP = 0x1 +cc.LINE_BREAK_MODE_CLIP = 0x2 +cc.LINE_BREAK_MODE_HEAD_TRUNCATION = 0x3 +cc.LINE_BREAK_MODE_MIDDLE_TRUNCATION = 0x5 +cc.LINE_BREAK_MODE_TAIL_TRUNCATION = 0x4 +cc.LINE_BREAK_MODE_WORD_WRAP = 0x0 +cc.MAC_VERSION_10_6 = 0xa060000 +cc.MAC_VERSION_10_7 = 0xa070000 +cc.MAC_VERSION_10_8 = 0xa080000 +cc.MENU_HANDLER_PRIORITY = -128 +cc.MENU_STATE_TRACKING_TOUCH = 0x1 +cc.MENU_STATE_WAITING = 0x0 +cc.NODE_TAG_INVALID = -1 +cc.PARTICLE_DURATION_INFINITY = -1 +cc.PARTICLE_MODE_GRAVITY = 0x0 +cc.PARTICLE_MODE_RADIUS = 0x1 +cc.PARTICLE_START_RADIUS_EQUAL_TO_END_RADIUS = -1 +cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE = -1 +cc.POSITION_TYPE_FREE = 0x0 +cc.POSITION_TYPE_GROUPED = 0x2 +cc.POSITION_TYPE_RELATIVE = 0x1 +cc.PRIORITY_NON_SYSTEM_MIN = -2147483647 +cc.PRIORITY_SYSTEM = -2147483648 +cc.PROGRESS_TIMER_TYPE_BAR = 0x1 +cc.PROGRESS_TIMER_TYPE_RADIAL = 0x0 +cc.REPEAT_FOREVER = 0xfffffffe +cc.RESOLUTION_MAC = 0x1 +cc.RESOLUTION_MAC_RETINA_DISPLAY = 0x2 +cc.RESOLUTION_UNKNOWN = 0x0 +cc.TMX_TILE_DIAGONAL_FLAG = 0x20000000 +cc.TMX_TILE_HORIZONTAL_FLAG = 0x80000000 +cc.TMX_TILE_VERTICAL_FLAG = 0x40000000 +cc.TEXT_ALIGNMENT_CENTER = 0x1 +cc.TEXT_ALIGNMENT_LEFT = 0x0 +cc.TEXT_ALIGNMENT_RIGHT = 0x2 +cc.TEXTURE2_D_PIXEL_FORMAT_A8 = 0x3 +cc.TEXTURE2_D_PIXEL_FORMAT_A_I88 = 0x5 +cc.TEXTURE2_D_PIXEL_FORMAT_DEFAULT = 0x0 +cc.TEXTURE2_D_PIXEL_FORMAT_I8 = 0x4 +cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC2 = 0x9 +cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC4 = 0x8 +cc.TEXTURE2_D_PIXEL_FORMAT_RG_B565 = 0x2 +cc.TEXTURE2_D_PIXEL_FORMAT_RGB5_A1 = 0x7 +cc.TEXTURE2_D_PIXEL_FORMAT_RG_B888 = 0x1 +cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444 = 0x6 +cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888 = 0x0 +cc.TOUCHES_ALL_AT_ONCE = 0x0 +cc.TOUCHES_ONE_BY_ONE = 0x1 +cc.TRANSITION_ORIENTATION_DOWN_OVER = 0x1 +cc.TRANSITION_ORIENTATION_LEFT_OVER = 0x0 +cc.TRANSITION_ORIENTATION_RIGHT_OVER = 0x1 +cc.TRANSITION_ORIENTATION_UP_OVER = 0x0 +cc.UNIFORM_COS_TIME = 0x5 +cc.UNIFORM_MV_MATRIX = 0x1 +cc.UNIFORM_MVP_MATRIX = 0x2 +cc.UNIFORM_P_MATRIX = 0x0 +cc.UNIFORM_RANDOM01 = 0x6 +cc.UNIFORM_SAMPLER = 0x7 +cc.UNIFORM_SIN_TIME = 0x4 +cc.UNIFORM_TIME = 0x3 +cc.UNIFORM_MAX = 0x8 +cc.VERTEX_ATTRIB_FLAG_COLOR = 0x2 +cc.VERTEX_ATTRIB_FLAG_NONE = 0x0 +cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX = 0x7 +cc.VERTEX_ATTRIB_FLAG_POSITION = 0x1 +cc.VERTEX_ATTRIB_FLAG_TEX_COORDS = 0x4 +cc.VERTEX_ATTRIB_COLOR = 0x1 +cc.VERTEX_ATTRIB_MAX = 0x3 +cc.VERTEX_ATTRIB_POSITION = 0x0 +cc.VERTEX_ATTRIB_TEX_COORDS = 0x2 +cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM = 0x2 +cc.VERTICAL_TEXT_ALIGNMENT_CENTER = 0x1 +cc.VERTICAL_TEXT_ALIGNMENT_TOP = 0x0 +cc.OS_VERSION_4_0 = 0x4000000 +cc.OS_VERSION_4_0_1 = 0x4000100 +cc.OS_VERSION_4_1 = 0x4010000 +cc.OS_VERSION_4_2 = 0x4020000 +cc.OS_VERSION_4_2_1 = 0x4020100 +cc.OS_VERSION_4_3 = 0x4030000 +cc.OS_VERSION_4_3_1 = 0x4030100 +cc.OS_VERSION_4_3_2 = 0x4030200 +cc.OS_VERSION_4_3_3 = 0x4030300 +cc.OS_VERSION_4_3_4 = 0x4030400 +cc.OS_VERSION_4_3_5 = 0x4030500 +cc.OS_VERSION_5_0 = 0x5000000 +cc.OS_VERSION_5_0_1 = 0x5000100 +cc.OS_VERSION_5_1_0 = 0x5010000 +cc.OS_VERSION_6_0_0 = 0x6000000 +cc.ANIMATION_FRAME_DISPLAYED_NOTIFICATION = 'CCAnimationFrameDisplayedNotification' +cc.CHIPMUNK_IMPORT = 'chipmunk.h' +cc.ATTRIBUTE_NAME_COLOR = 'a_color' +cc.ATTRIBUTE_NAME_POSITION = 'a_position' +cc.ATTRIBUTE_NAME_TEX_COORD = 'a_texCoord' +cc.SHADER_POSITION_COLOR = 'ShaderPositionColor' +cc.SHADER_POSITION_LENGTH_TEXURE_COLOR = 'ShaderPositionLengthTextureColor' +cc.SHADER_POSITION_TEXTURE = 'ShaderPositionTexture' +cc.SHADER_POSITION_TEXTURE_A8_COLOR = 'ShaderPositionTextureA8Color' +cc.SHADER_POSITION_TEXTURE_COLOR = 'ShaderPositionTextureColor' +cc.SHADER_POSITION_TEXTURE_COLOR_ALPHA_TEST = 'ShaderPositionTextureColorAlphaTest' +cc.SHADER_POSITION_TEXTURE_U_COLOR = 'ShaderPositionTexture_uColor' +cc.SHADER_POSITION_U_COLOR = 'ShaderPosition_uColor' +cc.UNIFORM_ALPHA_TEST_VALUE_S = 'CC_AlphaValue' +cc.UNIFORM_COS_TIME_S = 'CC_CosTime' +cc.UNIFORM_MV_MATRIX_S = 'CC_MVMatrix' +cc.UNIFORM_MVP_MATRIX_S = 'CC_MVPMatrix' +cc.UNIFORM_P_MATRIX_S = 'CC_PMatrix' +cc.UNIFORM_RANDOM01_S = 'CC_Random01' +cc.UNIFORM_SAMPLER_S = 'CC_Texture0' +cc.UNIFORM_SIN_TIME_S = 'CC_SinTime' +cc.UNIFORM_TIME_S = 'CC_Time' diff --git a/scripting/lua/script/Opengl.lua b/scripting/lua/script/Opengl.lua index e71bfb54fc..4f70703093 100644 --- a/scripting/lua/script/Opengl.lua +++ b/scripting/lua/script/Opengl.lua @@ -294,6 +294,6 @@ function gl.getAttachedShaders(program) end function gl.glNodeCreate() - return GLNode:create() + return cc.GLNode:create() end diff --git a/tools/tolua/cocos2dx.ini b/tools/tolua/cocos2dx.ini index 4c2e13a97e..9c45b05008 100644 --- a/tools/tolua/cocos2dx.ini +++ b/tools/tolua/cocos2dx.ini @@ -26,7 +26,7 @@ headers = %(cocosdir)s/cocos2dx/include/cocos2d.h %(cocosdir)s/CocosDenshion/inc # 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 +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$ # 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 @@ -97,12 +97,13 @@ skip = Node::[getGrid setGLServerState description getUserObject .*UserData getG Scheduler::[pause resume unschedule schedule update isTargetPaused], TextureCache::[addPVRTCImage], Timer::[getSelector createWithScriptHandler], - *::[copyWith.* onEnter.* onExit.* ^description$ getObjectType], + *::[copyWith.* onEnter.* onExit.* ^description$ getObjectType (g|s)etDelegate], FileUtils::[(g|s)etSearchResolutionsOrder$ (g|s)etSearchPaths$ getClassTypeInfo], SimpleAudioEngine::[getClassTypeInfo], Application::[^application.* ^run$], Camera::[getEyeXYZ getCenterXYZ getUpXYZ], - ccFontDefinition::[*] + ccFontDefinition::[*], + Object::[autorelease isEqual acceptVisitor update] rename_functions = SpriteFrameCache::[addSpriteFramesWithFile=addSpriteFrames getSpriteFrameByName=getSpriteFrame isFlipX=isFlippedX isFlipY=isFlippedY], MenuItemFont::[setFontNameObj=setFontName setFontSizeObj=setFontSize getFontSizeObj=getFontSize getFontNameObj=getFontName], @@ -134,7 +135,7 @@ remove_prefix = classes_have_no_parents = Node Director SimpleAudioEngine FileUtils TMXMapInfo Application # base classes which will be skipped when their sub-classes found them. -base_classes_to_skip = Object Clonable +base_classes_to_skip = Clonable # classes that create no constructor # Set is special and we will use a hand-written constructor diff --git a/tools/tolua/cocos2dx_extension.ini b/tools/tolua/cocos2dx_extension.ini index 6a31b61f3c..5b499f8cc1 100644 --- a/tools/tolua/cocos2dx_extension.ini +++ b/tools/tolua/cocos2dx_extension.ini @@ -40,7 +40,7 @@ skip = CCBReader::[^CCBReader$ addOwnerCallbackName isJSControlled readByte getC ScrollView::[(g|s)etDelegate$], .*Delegate::[*], .*Loader.*::[*], - *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType], + *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType (g|s)etDelegate], EditBox::[(g|s)etDelegate ^keyboard.* touchDownAction getScriptEditBoxHandler registerScriptEditBoxHandler unregisterScriptEditBoxHandler], TableView::[create (g|s)etDataSource$ (g|s)etDelegate], Control::[removeHandleOfControlEvent addHandleOfControlEvent] From f29525bbc6b1f25cc1f58fbd292c1c3983b2ccfb Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Thu, 15 Aug 2013 15:51:22 +0800 Subject: [PATCH 019/126] issue #2433:Modify Testlua sample and add some manual binding functions --- .../Resources/luaScript/BugsTest/BugsTest.lua | 299 +++++++------- .../ClickAndMoveTest/ClickAndMoveTest.lua | 27 +- .../CocosDenshionTest/CocosDenshionTest.lua | 35 +- .../CurrentLanguageTest.lua | 12 +- .../DrawPrimitivesTest/DrawPrimitivesTest.lua | 147 +++---- .../EffectsAdvancedTest.lua | 148 +++---- .../luaScript/EffectsTest/EffectsTest.lua | 172 ++++---- .../Resources/luaScript/VisibleRect.lua | 2 +- .../TestLua/Resources/luaScript/mainMenu.lua | 15 +- .../LuaOpengl.cpp.REMOVED.git-id | 2 +- .../lua_cocos2dx_auto.cpp.REMOVED.git-id | 2 +- .../generated/lua_cocos2dx_auto.hpp | 218 +++++++++- .../lua_cocos2dx_auto_api.js.REMOVED.git-id | 2 +- ...cocos2dx_extension_auto.cpp.REMOVED.git-id | 2 +- .../generated/lua_cocos2dx_extension_auto.hpp | 14 +- .../lua_cocos2dx_extension_auto_api.js | 20 +- .../generated/lua_cocos2dx_manual.cpp | 390 +++++++++++++++++- scripting/lua/script/AudioEngine.lua | 22 +- scripting/lua/script/Cocos2d.lua | 8 + tools/bindings-generator | 2 +- tools/tolua/cocos2dx.ini | 2 +- 21 files changed, 1028 insertions(+), 513 deletions(-) diff --git a/samples/Lua/TestLua/Resources/luaScript/BugsTest/BugsTest.lua b/samples/Lua/TestLua/Resources/luaScript/BugsTest/BugsTest.lua index 829cc14534..90325ab93d 100644 --- a/samples/Lua/TestLua/Resources/luaScript/BugsTest/BugsTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/BugsTest/BugsTest.lua @@ -2,7 +2,7 @@ local MAX_COUNT = 9; local LINE_SPACE = 40; local kItemTagBasic = 5432; -local Winsize = CCDirector:getInstance():getWinSize(); +local Winsize = cc.Director:getInstance():getWinSize(); local testNames = { "Bug-350", @@ -17,28 +17,28 @@ local testNames = { } local function CreateBugsTestBackMenuItem(pLayer) - CCMenuItemFont:setFontName("Arial") - CCMenuItemFont:setFontSize(24); - local pMenuItemFont = CCMenuItemFont:create("Back"); - pMenuItemFont:setPosition(CCPoint(VisibleRect:rightBottom().x - 50, VisibleRect:rightBottom().y + 25)) + cc.MenuItemFont:setFontName("Arial") + cc.MenuItemFont:setFontSize(24); + local pMenuItemFont = cc.MenuItemFont:create("Back"); + pMenuItemFont:setPosition(cc.p(VisibleRect:rightBottom().x - 50, VisibleRect:rightBottom().y + 25)) local function menuCallback() local pScene = BugsTestMain() if pScene ~= nil then - CCDirector:getInstance():replaceScene(pScene) + cc.Director:getInstance():replaceScene(pScene) end end pMenuItemFont:registerScriptTapHandler(menuCallback) - local pMenu = CCMenu:create() + local pMenu = cc.Menu:create() pMenu:addChild(pMenuItemFont) - pMenu:setPosition(CCPoint(0, 0)) + pMenu:setPosition(cc.p(0, 0)) pLayer:addChild(pMenu) end --BugTest350 local function BugTest350() - local pLayer = CCLayer:create() - local pBackground = CCSprite:create("Hello.png"); - pBackground:setPosition(CCPoint(Winsize.width/2, Winsize.height/2)); + local pLayer = cc.Layer:create() + local pBackground = cc.Sprite:create("Hello.png"); + pBackground:setPosition(cc.p(Winsize.width/2, Winsize.height/2)); pLayer:addChild(pBackground); return pLayer end @@ -50,7 +50,7 @@ local function BugTest422() nLocalTag = nLocalTag + 1 local pNode = pResetLayer:getChildByTag(nLocalTag - 1) if nil ~= pNode then - --userdata pointer + --userdata per local strLog = "Menu:"..nLocalTag print(strLog) end @@ -63,24 +63,27 @@ local function BugTest422() reset(pCallbackLayer) end end - CCMenuItemFont:setFontName("Arial") - CCMenuItemFont:setFontSize(24); - local pMenuItem1 = CCMenuItemFont:create("One") + cc.MenuItemFont:setFontName("Arial") + cc.MenuItemFont:setFontSize(24); + local pMenuItem1 = cc.MenuItemFont:create("One") pMenuItem1:registerScriptTapHandler(menuCallback) - local pMenuItem2 = CCMenuItemFont:create("Two") + local pMenuItem2 = cc.MenuItemFont:create("Two") pMenuItem2:registerScriptTapHandler(menuCallback) - local arr = CCArray:create() + --[[ + local arr = cc.Array:create() arr:addObject(pMenuItem1) arr:addObject(pMenuItem2) - local pMenu = CCMenu:createWithArray(arr) + ]]-- + local pMenu = cc.Menu:create(pMenuItem1, pMenuItem2) pMenu:alignItemsVertically() local fX = math.random() * 50 local fY = math.random() * 50 - pMenu:setPosition(CCPoint.__add(CCPoint(pMenu:getPosition()),CCPoint(fX,fY))) + local menuPos = pMenu:getPosition() + pMenu:setPosition(cc.p(menuPos.x + fX,menuPos.y + fY)) pResetLayer:addChild(pMenu,0,nLocalTag) end - local pLayer = CCLayer:create() + local pLayer = cc.Layer:create() reset(pLayer) return pLayer end @@ -88,99 +91,101 @@ end --BugTest458 local nColorFlag = 0 local function BugTest458() - local pLayer = CCLayer:create() + local pLayer = cc.Layer:create() local function InitQuestionContainerSprite(pSprite) --Add label - local pLabel = CCLabelTTF:create("Answer 1", "Arial", 12); + local pLabel = cc.LabelTTF:create("Answer 1", "Arial", 12); pLabel:setTag(100); --Add the background - local pCorner = CCSprite:create("Images/bugs/corner.png"); + local pCorner = cc.Sprite:create("Images/bugs/corner.png"); local nWidth = Winsize.width * 0.9 - (pCorner:getContentSize().width * 2); local nHeight = Winsize.height * 0.15 - (pCorner:getContentSize().height * 2); - local pColorLayer = CCLayerColor:create(Color4B(255, 255, 255, 255 * .75), nWidth, nHeight); - pColorLayer:setPosition(CCPoint(-nWidth / 2, -nHeight / 2)); + local pColorLayer = cc.LayerColor:create(cc.c4b(255, 255, 255, 255 * .75), nWidth, nHeight); + pColorLayer:setPosition(cc.p(-nWidth / 2, -nHeight / 2)); --First button is blue,Second is red,Used for testing - change later if (0 == nColorFlag) then - pLabel:setColor(Color3B(0,0,255)) + pLabel:setColor(cc.c3b(0,0,255)) else print("Color changed") - pLabel:setColor(Color3B(255,0,0)) + pLabel:setColor(cc.c3b(255,0,0)) end nColorFlag = nColorFlag + 1; pSprite:addChild(pColorLayer); - pCorner:setPosition(CCPoint(-(nWidth / 2 + pCorner:getContentSize().width / 2), -(nHeight / 2 + pCorner:getContentSize().height / 2))); + pCorner:setPosition(cc.p(-(nWidth / 2 + pCorner:getContentSize().width / 2), -(nHeight / 2 + pCorner:getContentSize().height / 2))); pSprite:addChild(pCorner); - local nX,nY = pCorner:getPosition() - local pCorner2 = CCSprite:create("Images/bugs/corner.png"); - pCorner2:setPosition(CCPoint(-nX, nY)); + local posCorner = pCorner:getPosition() + local nX,nY = posCorner.x,posCorner.y + local pCorner2 = cc.Sprite:create("Images/bugs/corner.png"); + pCorner2:setPosition(cc.p(-nX, nY)); pCorner2:setFlipX(true); pSprite:addChild(pCorner2); - local pCorner3 = CCSprite:create("Images/bugs/corner.png"); - pCorner3:setPosition(CCPoint(nX, -nY)); + local pCorner3 = cc.Sprite:create("Images/bugs/corner.png"); + pCorner3:setPosition(cc.p(nX, -nY)); pCorner3:setFlipY(true); pSprite:addChild(pCorner3); - local pCorner4 = CCSprite:create("Images/bugs/corner.png"); - pCorner4:setPosition(CCPoint(-nX, -nY)); + local pCorner4 = cc.Sprite:create("Images/bugs/corner.png"); + pCorner4:setPosition(cc.p(-nX, -nY)); pCorner4:setFlipX(true); pCorner4:setFlipY(true); pSprite:addChild(pCorner4); - local pEdge = CCSprite:create("Images/bugs/edge.png"); + local pEdge = cc.Sprite:create("Images/bugs/edge.png"); pEdge:setScaleX(nWidth); - pEdge:setPosition(CCPoint(nX + (pCorner:getContentSize().width / 2) + (nWidth / 2), nY)); + pEdge:setPosition(cc.p(nX + (pCorner:getContentSize().width / 2) + (nWidth / 2), nY)); pSprite:addChild(pEdge); - local pEdge2 = CCSprite:create("Images/bugs/edge.png"); + local pEdge2 = cc.Sprite:create("Images/bugs/edge.png"); pEdge2:setScaleX(nWidth); - pEdge2:setPosition(CCPoint(nX + (pCorner:getContentSize().width / 2) + (nWidth / 2), -nY)); + pEdge2:setPosition(cc.p(nX + (pCorner:getContentSize().width / 2) + (nWidth / 2), -nY)); pEdge2:setFlipY(true); pSprite:addChild(pEdge2); - local pEdge3 = CCSprite:create("Images/bugs/edge.png"); + local pEdge3 = cc.Sprite:create("Images/bugs/edge.png"); pEdge3:setRotation(90); pEdge3:setScaleX(nHeight); - pEdge3:setPosition(CCPoint(nX, nY + (pCorner:getContentSize().height / 2) + (nHeight / 2))); + pEdge3:setPosition(cc.p(nX, nY + (pCorner:getContentSize().height / 2) + (nHeight / 2))); pSprite:addChild(pEdge3); - local pEdge4 = CCSprite:create("Images/bugs/edge.png"); + local pEdge4 = cc.Sprite:create("Images/bugs/edge.png"); pEdge4:setRotation(270); pEdge4:setScaleX(nHeight); - pEdge4:setPosition(CCPoint(-nX, nY + (pCorner:getContentSize().height / 2) + (nHeight / 2))); + pEdge4:setPosition(cc.p(-nX, nY + (pCorner:getContentSize().height / 2) + (nHeight / 2))); pSprite:addChild(pEdge4); pSprite:addChild(pLabel); end - local pQuestion1 = CCSprite:create() + local pQuestion1 = cc.Sprite:create() InitQuestionContainerSprite(pQuestion1) - local pQuestion2 = CCSprite:create() + local pQuestion2 = cc.Sprite:create() InitQuestionContainerSprite(pQuestion2) local function menuCallback() print("Selected") end - local pMenuItemSprite = CCMenuItemSprite:create(pQuestion1,pQuestion2) + local pMenuItemSprite = cc.MenuItemSprite:create(pQuestion1,pQuestion2) pMenuItemSprite:registerScriptTapHandler(menuCallback) - local pLayerColor1 = CCLayerColor:create(Color4B(0,0,255,255), 100, 100); + local pLayerColor1 = cc.LayerColor:create(cc.c4b(0,0,255,255), 100, 100); -- question->release(); -- question2->release(); - local pLayerColor2 = CCLayerColor:create(Color4B(255,0,0,255), 100, 100); - local pMenuItemSprite2 = CCMenuItemSprite:create(pLayerColor1, pLayerColor2); + local pLayerColor2 = cc.LayerColor:create(cc.c4b(255,0,0,255), 100, 100); + local pMenuItemSprite2 = cc.MenuItemSprite:create(pLayerColor1, pLayerColor2); pMenuItemSprite2:registerScriptTapHandler(menuCallback) - - local arr = CCArray:create() +--[[ + local arr = cc.Array:create() arr:addObject(pMenuItemSprite) arr:addObject(pMenuItemSprite2) - local pMenu = CCMenu:createWithArray(arr) + ]]-- + local pMenu = cc.Menu:create(pMenuItemSprite, pMenuItemSprite2) pMenu:alignItemsVerticallyWithPadding(100); - pMenu:setPosition(CCPoint(Winsize.width / 2, Winsize.height / 2)); + pMenu:setPosition(cc.p(Winsize.width / 2, Winsize.height / 2)); -- add the label as a child to this Layer pLayer:addChild(pMenu); @@ -193,28 +198,28 @@ local BugTest624_entry = nil local BugTest624_2_entry = nil local function BugTest624() - local pLayer = CCLayer:create() + local pLayer = cc.Layer:create() - local pLabel = CCLabelTTF:create("Layer1", "Marker Felt", 36); - pLabel:setPosition(CCPoint(Winsize.width / 2, Winsize.height / 2)); + local pLabel = cc.LabelTTF:create("Layer1", "Marker Felt", 36); + pLabel:setPosition(cc.p(Winsize.width / 2, Winsize.height / 2)); pLayer:addChild(pLabel); pLayer:setAccelerometerEnabled(true); -- schedule(schedule_selector(Bug624Layer::switchLayer), 5.0f); local function BugTest624_SwitchLayer() - local scheduler = CCDirector:getInstance():getScheduler() + local scheduler = cc.Director:getInstance():getScheduler() scheduler:unscheduleScriptEntry(BugTest624_entry) - local pScene = CCScene:create(); + local pScene = cc.Scene:create(); local pNewPlayer = BugTest624_2() CreateBugsTestBackMenuItem(pNewPlayer) pScene:addChild(pNewPlayer); - CCDirector:getInstance():replaceScene(CCTransitionFade:create(2.0, pScene, Color3B(255,255,255))); + cc.Director:getInstance():replaceScene(cc.TransitionFade:create(2.0, pScene, cc.c3b(255,255,255))); end local function BugTest624_OnEnterOrExit(tag) - local scheduler = CCDirector:getInstance():getScheduler() + local scheduler = cc.Director:getInstance():getScheduler() if tag == "enter" then BugTest624_entry = scheduler:scheduleScriptFunc(BugTest624_SwitchLayer, 5.0, false) elseif tag == "exit" then @@ -232,26 +237,26 @@ local function BugTest624() end function BugTest624_2() - local pLayer = CCLayer:create() + local pLayer = cc.Layer:create() - local pLabel = CCLabelTTF:create("Layer2", "Marker Felt", 36); - pLabel:setPosition(CCPoint(Winsize.width / 2, Winsize.height / 2)); + local pLabel = cc.LabelTTF:create("Layer2", "Marker Felt", 36); + pLabel:setPosition(cc.p(Winsize.width / 2, Winsize.height / 2)); pLayer:addChild(pLabel); pLayer:setAccelerometerEnabled(true); local function BugTest624_2_SwitchLayer() - local scheduler = CCDirector:getInstance():getScheduler() + local scheduler = cc.Director:getInstance():getScheduler() scheduler:unscheduleScriptEntry(BugTest624_2_entry) - local pScene = CCScene:create(); + local pScene = cc.Scene:create(); local pNewPlayer = BugTest624() CreateBugsTestBackMenuItem(pNewPlayer) pScene:addChild(pNewPlayer); - CCDirector:getInstance():replaceScene(CCTransitionFade:create(2.0, pScene, Color3B(255,0,0))); + cc.Director:getInstance():replaceScene(cc.TransitionFade:create(2.0, pScene, cc.c3b(255,0,0))); end local function BugTest624_2_OnEnterOrExit(tag) - local scheduler = CCDirector:getInstance():getScheduler() + local scheduler = cc.Director:getInstance():getScheduler() if tag == "enter" then BugTest624_2_entry = scheduler:scheduleScriptFunc(BugTest624_2_SwitchLayer, 5.0, false) elseif tag == "exit" then @@ -270,18 +275,18 @@ end --BugTest886 local function BugTest886() - local pLayer = CCLayer:create() + local pLayer = cc.Layer:create() - local pSprite1 = CCSprite:create("Images/bugs/bug886.jpg") - pSprite1:setAnchorPoint(CCPoint(0, 0)) - pSprite1:setPosition(CCPoint(0, 0)) + local pSprite1 = cc.Sprite:create("Images/bugs/bug886.jpg") + pSprite1:setAnchorPoint(cc.p(0, 0)) + pSprite1:setPosition(cc.p(0, 0)) pSprite1:setScaleX(0.6) pLayer:addChild(pSprite1) - local pSprite2 = CCSprite:create("Images/bugs/bug886.jpg") - pSprite2:setAnchorPoint(CCPoint(0, 0)) + local pSprite2 = cc.Sprite:create("Images/bugs/bug886.jpg") + pSprite2:setAnchorPoint(cc.p(0, 0)) pSprite2:setScaleX(0.6) - pSprite2:setPosition(CCPoint(pSprite1:getContentSize().width * 0.6 + 10, 0)) + pSprite2:setPosition(cc.p(pSprite1:getContentSize().width * 0.6 + 10, 0)) pLayer:addChild(pSprite2) return pLayer @@ -289,54 +294,54 @@ end --BugTest899 local function BugTest899() - local pLayer = CCLayer:create() + local pLayer = cc.Layer:create() - local pBg = CCSprite:create("Images/bugs/RetinaDisplay.jpg") + local pBg = cc.Sprite:create("Images/bugs/RetinaDisplay.jpg") pLayer:addChild(pBg,0) - pBg:setAnchorPoint(CCPoint(0, 0)) + pBg:setAnchorPoint(cc.p(0, 0)) return pLayer end --BugTest914 local function BugTest914() - local pLayer = CCLayer:create() + local pLayer = cc.Layer:create() pLayer:setTouchEnabled(true); local pLayerColor = nil for i = 0, 4 do - pLayerColor = CCLayerColor:create(Color4B(i*20, i*20, i*20,255)) - pLayerColor:setContentSize(CCSize(i*100, i*100)); - pLayerColor:setPosition(CCPoint(Winsize.width/2, Winsize.height/2)) - pLayerColor:setAnchorPoint(CCPoint(0.5, 0.5)); + pLayerColor = cc.LayerColor:create(cc.c4b(i*20, i*20, i*20,255)) + pLayerColor:setContentSize(cc.size(i*100, i*100)); + pLayerColor:setPosition(cc.p(Winsize.width/2, Winsize.height/2)) + pLayerColor:setAnchorPoint(cc.p(0.5, 0.5)); pLayerColor:ignoreAnchorPointForPosition(false); pLayer:addChild(pLayerColor, -1-i); end --create and initialize a Label local function restart() - local pScene = CCScene:create() + local pScene = cc.Scene:create() local pLayer = BugTest914() CreateBugsTestBackMenuItem(pLayer) pScene:addChild(pLayer); - CCDirector:getInstance():replaceScene(pScene) + cc.Director:getInstance():replaceScene(pScene) end - local label = CCLabelTTF:create("Hello World", "Marker Felt", 64) + local label = cc.LabelTTF:create("Hello World", "Marker Felt", 64) --position the label on the center of the screen - label:setPosition(CCPoint( Winsize.width /2 , Winsize.height/2 )); + label:setPosition(cc.p( Winsize.width /2 , Winsize.height/2 )); pLayer:addChild(label); - local item1 = CCMenuItemFont:create("restart") + local item1 = cc.MenuItemFont:create("restart") item1:registerScriptTapHandler(restart) --Bug914Layer::restart)); - local menu = CCMenu:create() + local menu = cc.Menu:create() menu:addChild(item1) menu:alignItemsVertically() - menu:setPosition(CCPoint(Winsize.width/2, 100)) + menu:setPosition(cc.p(Winsize.width/2, 100)) pLayer:addChild(menu) -- handling touch events @@ -363,44 +368,45 @@ end --BugTest1159 local function BugTest1159() - local pLayer = CCLayer:create() + local pLayer = cc.Layer:create() - CCDirector:getInstance():setDepthTest(true) + cc.Director:getInstance():setDepthTest(true) - local background = CCLayerColor:create(Color4B(255, 0, 255, 255)) + local background = cc.LayerColor:create(cc.c4b(255, 0, 255, 255)) pLayer:addChild(background) - local sprite_a = CCLayerColor:create(Color4B(255, 0, 0, 255), 700, 700) - sprite_a:setAnchorPoint(CCPoint(0.5, 0.5)) + local sprite_a = cc.LayerColor:create(cc.c4b(255, 0, 0, 255), 700, 700) + sprite_a:setAnchorPoint(cc.p(0.5, 0.5)) sprite_a:ignoreAnchorPointForPosition(false) - sprite_a:setPosition(CCPoint(0.0, Winsize.height/2)) + sprite_a:setPosition(cc.p(0.0, Winsize.height/2)) pLayer:addChild(sprite_a) +--[[ + local arr = cc.Array:create() + arr:addObject(cc.MoveTo:create(1.0, cc.p(1024.0, 384.0))) + arr:addObject(cc.MoveTo:create(1.0, cc.p(0.0, 384.0))) + ]]-- + local seq = cc.Sequence:create(cc.MoveTo:create(1.0, cc.p(1024.0, 384.0)), cc.MoveTo:create(1.0, cc.p(0.0, 384.0))) + sprite_a:runAction(cc.RepeatForever:create(seq)) - local arr = CCArray:create() - arr:addObject(CCMoveTo:create(1.0, CCPoint(1024.0, 384.0))) - arr:addObject(CCMoveTo:create(1.0, CCPoint(0.0, 384.0))) - local seq = CCSequence:create(arr) - sprite_a:runAction(CCRepeatForever:create(seq)) - - local sprite_b = CCLayerColor:create(Color4B(0, 0, 255, 255), 400, 400); - sprite_b:setAnchorPoint(CCPoint(0.5, 0.5)) + local sprite_b = cc.LayerColor:create(cc.c4b(0, 0, 255, 255), 400, 400); + sprite_b:setAnchorPoint(cc.p(0.5, 0.5)) sprite_b:ignoreAnchorPointForPosition(false); - sprite_b:setPosition(CCPoint(Winsize.width/2, Winsize.height/2)); + sprite_b:setPosition(cc.p(Winsize.width/2, Winsize.height/2)); pLayer:addChild(sprite_b); local function menuCallback() - local pScene = CCScene:create() + local pScene = cc.Scene:create() local pLayer = BugTest1159() CreateBugsTestBackMenuItem(pLayer) pScene:addChild(pLayer); - CCDirector:getInstance():replaceScene(CCTransitionPageTurn:create(1.0, pScene, false)) + cc.Director:getInstance():replaceScene(cc.TransitionPageTurn:create(1.0, pScene, false)) end - local label = CCMenuItemLabel:create(CCLabelTTF:create("Flip Me", "Helvetica", 24)); + local label = cc.MenuItemLabel:create(cc.LabelTTF:create("Flip Me", "Helvetica", 24)); label:registerScriptTapHandler(menuCallback) - local menu = CCMenu:create(); + local menu = cc.Menu:create(); menu:addChild(label) - menu:setPosition(CCPoint(Winsize.width - 200.0, 50.0)); + menu:setPosition(cc.p(Winsize.width - 200.0, 50.0)); pLayer:addChild(menu); local function onNodeEvent(event) @@ -410,7 +416,7 @@ local function BugTest1159() scheduler:unscheduleScriptEntry(schedulerEntry) end ]]-- - CCDirector:getInstance():setDepthTest(false) + cc.Director:getInstance():setDepthTest(false) end end @@ -421,19 +427,19 @@ end --BugTest1174 local function BugTest1174() - local pLayer = CCLayer:create() + local pLayer = cc.Layer:create() local function check_for_error(p1,p2,p3,p4,s,t) - local p4_p3 = CCPoint.__sub(p4,p3) - local p4_p3_t = CCPoint.__mul(p4_p3,t) - local hitPoint1 = CCPoint.__add(p3,p4_p3_t) + local p4_p3 = cc.p.__sub(p4,p3) + local p4_p3_t = cc.p.__mul(p4_p3,t) + local hitp1 = cc.p.__add(p3,p4_p3_t) - local p2_p1 = CCPoint.__sub(p2,p1) - local p2_p1_s = CCPoint.__mul(p2_p1,s) - local hitPoint2 = CCPoint.__add(p1,p2_p1_s) + local p2_p1 = cc.p.__sub(p2,p1) + local p2_p1_s = cc.p.__mul(p2_p1,s) + local hitp2 = cc.p.__add(p1,p2_p1_s) - if math.abs(hitPoint1.x - hitPoint2.x ) > 0.1 or math.abs(hitPoint1.y - hitPoint2.y) > 0.1 then - local strErr = "ERROR: ("..hitPoint1.x..","..hitPoint1.y..") != ("..hitPoint2.x..","..hitPoint2.y..")" + if math.abs(hitp1.x - hitp2.x ) > 0.1 or math.abs(hitp1.y - hitp2.y) > 0.1 then + local strErr = "ERROR: ("..hitp1.x..","..hitp1.y..") != ("..hitp2.x..","..hitp2.y..")" print(strErr) return 1 end @@ -480,12 +486,12 @@ local function BugTest1174() local cx = math.random() * -5000 local cy = math.random() * -5000 - A = CCPoint(ax,ay) - B = CCPoint(bx,by) - C = CCPoint(cx,cy) - D = CCPoint(dx,dy) + A = cc.p(ax,ay) + B = cc.p(bx,by) + C = cc.p(cx,cy) + D = cc.p(dx,dy) - bRet,s,t = CCPoint:isLineIntersect( A, D, B, C, s, t) + bRet,s,t = cc.p:isLineIntersect( A, D, B, C, s, t) if true == bRet then if 1 == check_for_error(A,D,B,C,s,t) then err = err + 1 @@ -501,13 +507,13 @@ local function BugTest1174() -------- print("Test2 - Start") - p1 = CCPoint(220,480); - p2 = CCPoint(304,325); - p3 = CCPoint(264,416); - p4 = CCPoint(186,416); + p1 = cc.p(220,480); + p2 = cc.p(304,325); + p3 = cc.p(264,416); + p4 = cc.p(186,416); s = 0.0; t = 0.0; - bRet,s,t = CCPoint:isLineIntersect( p1, p2, p3, p4, s, t) + bRet,s,t = cc.p:isLineIntersect( p1, p2, p3, p4, s, t) if true == bRet then check_for_error(p1, p2, p3, p4, s, t) end @@ -526,13 +532,13 @@ local function BugTest1174() -- c | d local ax = math.random() * -500 local ay = math.random() * 500 - p1 = CCPoint(ax,ay); + p1 = cc.p(ax,ay); -- a | b -- ----- -- c | D local dx = math.random() * 500 local dy = math.random() * -500 - p2 = CCPoint(dx,dy) + p2 = cc.p(dx,dy) ------- @@ -542,17 +548,17 @@ local function BugTest1174() -- ----- -- C | d local cx = math.random() * -500 - p3 = CCPoint(cx,y) + p3 = cc.p(cx,y) -- a | B -- ----- -- c | d local bx = math.random() * 500 - p4 = CCPoint(bx,y) + p4 = cc.p(bx,y) s = 0.0 t = 0.0 - bRet,s,t = CCPoint:isLineIntersect(p1, p2, p3, p4, s, t) + bRet,s,t = cc.p:isLineIntersect(p1, p2, p3, p4, s, t) if true == bRet then if 1 == check_for_error(p1, p2, p3, p4, s,t ) then err = err + 1 @@ -580,41 +586,41 @@ local CreateBugsTestTable = { } local function CreateBugsTestScene(nBugNo) - local pNewscene = CCScene:create() + local pNewscene = cc.Scene:create() local pLayer = CreateBugsTestTable[nBugNo]() CreateBugsTestBackMenuItem(pLayer) pNewscene:addChild(pLayer) - CCDirector:getInstance():replaceScene(pNewscene) + cc.Director:getInstance():replaceScene(pNewscene) --pLayer:autorelease() end local function BugsTestMainLayer() - local ret = CCLayer:create(); + local ret = cc.Layer:create(); --menu callback local function menuCallback(tag, pMenuItem) local nIdx = pMenuItem:getZOrder() - kItemTagBasic local BugTestScene = CreateBugsTestScene(nIdx) if nil ~= testScene then - CCDirector:getInstance():replaceScene(testScene) + cc.Director:getInstance():replaceScene(testScene) end end -- add menu items for tests - local pItemMenu = CCMenu:create(); + local pItemMenu = cc.Menu:create(); local nTestCount = table.getn(testNames); local i = 1 for i = 1, nTestCount do - local label = CCLabelTTF:create(testNames[i], "Arial", 24) - local pMenuItem = CCMenuItemLabel:create(label) + local label = cc.LabelTTF:create(testNames[i], "Arial", 24) + local pMenuItem = cc.MenuItemLabel:create(label) pMenuItem:registerScriptTapHandler(menuCallback) pItemMenu:addChild(pMenuItem, i + kItemTagBasic) - pMenuItem:setPosition( CCPoint( VisibleRect:center().x, (VisibleRect:top().y - i * LINE_SPACE) )) + pMenuItem:setPosition( cc.p( VisibleRect:center().x, (VisibleRect:top().y - i * LINE_SPACE) )) end - pItemMenu:setPosition(CCPoint(0, 0)) + pItemMenu:setPosition(cc.p(0, 0)) ret:addChild(pItemMenu) ret:setTouchEnabled(true) @@ -623,13 +629,14 @@ local function BugsTestMainLayer() local ptCurPos = {x = 0, y = 0} local function onTouchBegan(x, y) ptBeginPos = {x = x, y = y} - -- CCTOUCHBEGAN event must return true + -- cc.TOUCHBEGAN event must return true return true end local function onTouchMoved(x, y) local nMoveY = y - ptBeginPos.y - local curPosx, curPosy = pItemMenu:getPosition() + local curPos = pItemMenu:getPosition() + local curPosx, curPosy = curPos.x,curPos.y local nextPosy = curPosy + nMoveY if nextPosy < 0 then pItemMenu:setPosition(0, 0) @@ -660,7 +667,7 @@ local function BugsTestMainLayer() end function BugsTestMain() cclog("BugsTestMain"); - local scene = CCScene:create(); + local scene = cc.Scene:create(); scene:addChild(BugsTestMainLayer()); scene:addChild(CreateBackMenuItem()); return scene; diff --git a/samples/Lua/TestLua/Resources/luaScript/ClickAndMoveTest/ClickAndMoveTest.lua b/samples/Lua/TestLua/Resources/luaScript/ClickAndMoveTest/ClickAndMoveTest.lua index c17adf676d..8bd2dd4250 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ClickAndMoveTest/ClickAndMoveTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ClickAndMoveTest/ClickAndMoveTest.lua @@ -1,27 +1,28 @@ -local size = CCDirector:getInstance():getWinSize() +local size = cc.Director:getInstance():getWinSize() local layer = nil local kTagSprite = 1 local function initWithLayer() - local sprite = CCSprite:create(s_pPathGrossini) + local sprite = cc.Sprite:create(s_pPathGrossini) - local bgLayer = CCLayerColor:create(Color4B(255,255,0,255)) + local bgLayer = cc.LayerColor:create(cc.c4b(255,255,0,255)) layer:addChild(bgLayer, -1) layer:addChild(sprite, 0, kTagSprite) - sprite:setPosition(CCPoint(20,150)) + sprite:setPosition(cc.p(20,150)) - sprite:runAction(CCJumpTo:create(4, CCPoint(300,48), 100, 4)) + sprite:runAction(cc.JumpTo:create(4, cc.p(300,48), 100, 4)) - bgLayer:runAction(CCRepeatForever:create(CCSequence:createWithTwoActions( - CCFadeIn:create(1), - CCFadeOut:create(1)))) + bgLayer:runAction(cc.RepeatForever:create(cc.Sequence:create( + cc.FadeIn:create(1), + cc.FadeOut:create(1)))) local function onTouchEnded(x, y) local s = layer:getChildByTag(kTagSprite) s:stopAllActions() - s:runAction(CCMoveTo:create(1, CCPoint(x, y))) - local posX, posY = s:getPosition() + s:runAction(cc.MoveTo:create(1, cc.p(x, y))) + local pos = s:getPosition() + local posX, posY = pos.x,pos.y local o = x - posX local a = y - posY local at = math.atan(o / a) / math.pi * 180.0 @@ -33,7 +34,7 @@ local function initWithLayer() at = 180 - math.abs(at) end end - s:runAction(CCRotateTo:create(1, at)) + s:runAction(cc.RotateTo:create(1, at)) end local function onTouch(eventType, x, y) @@ -55,8 +56,8 @@ end -------------------------------- function ClickAndMoveTest() cclog("ClickAndMoveTest") - local scene = CCScene:create() - layer = CCLayer:create() + local scene = cc.Scene:create() + layer = cc.Layer:create() initWithLayer() diff --git a/samples/Lua/TestLua/Resources/luaScript/CocosDenshionTest/CocosDenshionTest.lua b/samples/Lua/TestLua/Resources/luaScript/CocosDenshionTest/CocosDenshionTest.lua index 156771af21..ef25bb978b 100644 --- a/samples/Lua/TestLua/Resources/luaScript/CocosDenshionTest/CocosDenshionTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/CocosDenshionTest/CocosDenshionTest.lua @@ -5,9 +5,9 @@ local MUSIC_FILE = "background.mp3" local LINE_SPACE = 40 local function CocosDenshionTest() - local ret = CCLayer:create() + local ret = cc.Layer:create() local m_pItmeMenu = nil - local m_tBeginPos = CCPoint(0, 0) + local m_tBeginPos = cc.p(0, 0) local m_nSoundId = 0 local testItems = { @@ -93,20 +93,20 @@ local function CocosDenshionTest() end end -- add menu items for tests - m_pItmeMenu = CCMenu:create() + m_pItmeMenu = cc.Menu:create() m_nTestCount = table.getn(testItems) local i = 1 for i = 1, m_nTestCount do - local label = CCLabelTTF:create(testItems[i], "Arial", 24) - local pMenuItem = CCMenuItemLabel:create(label) + local label = cc.LabelTTF:create(testItems[i], "Arial", 24) + local pMenuItem = cc.MenuItemLabel:create(label) pMenuItem:registerScriptTapHandler(menuCallback) m_pItmeMenu:addChild(pMenuItem, i + 10000 -1) - pMenuItem:setPosition( CCPoint( VisibleRect:center().x, (VisibleRect:top().y - i * LINE_SPACE) )) + pMenuItem:setPosition( cc.p( VisibleRect:center().x, (VisibleRect:top().y - i * LINE_SPACE) )) end - m_pItmeMenu:setContentSize(CCSize(VisibleRect:getVisibleRect().size.width, (m_nTestCount + 1) * LINE_SPACE)) - m_pItmeMenu:setPosition(CCPoint(0, 0)) + m_pItmeMenu:setContentSize(cc.size(VisibleRect:getVisibleRect().width, (m_nTestCount + 1) * LINE_SPACE)) + m_pItmeMenu:setPosition(cc.p(0, 0)) ret:addChild(m_pItmeMenu) ret:setTouchEnabled(true) @@ -133,21 +133,22 @@ local function CocosDenshionTest() if eventType == "began" then prev.x = x prev.y = y - m_tBeginPos = CCPoint(x, y) + m_tBeginPos = cc.p(x, y) return true elseif eventType == "moved" then - local touchLocation = CCPoint(x, y) + local touchLocation = cc.p(x, y) local nMoveY = touchLocation.y - m_tBeginPos.y - local curPosX, curPosY = m_pItmeMenu:getPosition() - local curPos = CCPoint(curPosX, curPosY) - local nextPos = CCPoint(curPos.x, curPos.y + nMoveY) + local curPos = m_pItmeMenu:getPosition() + local curPosX, curPosY = curPos.x,curPos.y + local curPos = cc.p(curPosX, curPosY) + local nextPos = cc.p(curPos.x, curPos.y + nMoveY) if nextPos.y < 0.0 then - m_pItmeMenu:setPosition(CCPoint(0, 0)) + m_pItmeMenu:setPosition(cc.p(0, 0)) end - if nextPos.y > ((m_nTestCount + 1)* LINE_SPACE - VisibleRect:getVisibleRect().size.height) then - m_pItmeMenu:setPosition(CCPoint(0, ((m_nTestCount + 1)* LINE_SPACE - VisibleRect:getVisibleRect().size.height))) + if nextPos.y > ((m_nTestCount + 1)* LINE_SPACE - VisibleRect:getVisibleRect().height) then + m_pItmeMenu:setPosition(cc.p(0, ((m_nTestCount + 1)* LINE_SPACE - VisibleRect:getVisibleRect().height))) end m_pItmeMenu:setPosition(nextPos) @@ -165,7 +166,7 @@ end function CocosDenshionTestMain() cclog("CocosDenshionTestMain") - local scene = CCScene:create() + local scene = cc.Scene:create() scene:addChild(CocosDenshionTest()) scene:addChild(CreateBackMenuItem()) return scene diff --git a/samples/Lua/TestLua/Resources/luaScript/CurrentLanguageTest/CurrentLanguageTest.lua b/samples/Lua/TestLua/Resources/luaScript/CurrentLanguageTest/CurrentLanguageTest.lua index d1bda7abc1..53812a5108 100644 --- a/samples/Lua/TestLua/Resources/luaScript/CurrentLanguageTest/CurrentLanguageTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/CurrentLanguageTest/CurrentLanguageTest.lua @@ -1,13 +1,13 @@ local function CurrentLanguageTest() - local ret = CCLayer:create() - local label = CCLabelTTF:create("Current language Test", "Arial", 28) + local ret = cc.Layer:create() + local label = cc.LabelTTF:create("Current language Test", "Arial", 28) ret:addChild(label, 0) - label:setPosition( CCPoint(VisibleRect:center().x, VisibleRect:top().y-50) ) + label:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y-50) ) - local labelLanguage = CCLabelTTF:create("", "Arial", 20) + local labelLanguage = cc.LabelTTF:create("", "Arial", 20) labelLanguage:setPosition(VisibleRect:center()) - local currentLanguageType = CCApplication:getInstance():getCurrentLanguage() + local currentLanguageType = cc.Application:getInstance():getCurrentLanguage() if currentLanguageType == kLanguageEnglish then labelLanguage:setString("current language is English") @@ -39,7 +39,7 @@ local function CurrentLanguageTest() end function CurrentLanguageTestMain() - local scene = CCScene:create() + local scene = cc.Scene:create() local pLayer = CurrentLanguageTest() scene:addChild(pLayer) scene:addChild(CreateBackMenuItem()) diff --git a/samples/Lua/TestLua/Resources/luaScript/DrawPrimitivesTest/DrawPrimitivesTest.lua b/samples/Lua/TestLua/Resources/luaScript/DrawPrimitivesTest/DrawPrimitivesTest.lua index dbd1d6a235..168f462432 100644 --- a/samples/Lua/TestLua/Resources/luaScript/DrawPrimitivesTest/DrawPrimitivesTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/DrawPrimitivesTest/DrawPrimitivesTest.lua @@ -5,7 +5,7 @@ local function drawPrimitivesMainLayer() local testCount = 2 local maxCases = testCount local curCase = 0 - local size = CCDirector:getInstance():getWinSize() + local size = cc.Director:getInstance():getWinSize() local curLayer = nil local function orderCallbackMenu() @@ -27,23 +27,23 @@ local function drawPrimitivesMainLayer() showCurrentTest() end - local ordercallbackmenu = CCMenu:create() - local size = CCDirector:getInstance():getWinSize() - local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2) + local ordercallbackmenu = cc.Menu:create() + local size = cc.Director:getInstance():getWinSize() + local item1 = cc.MenuItemImage:create(s_pPathB1, s_pPathB2) item1:registerScriptTapHandler(backCallback) ordercallbackmenu:addChild(item1,kItemTagBasic) - local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2) + local item2 = cc.MenuItemImage:create(s_pPathR1, s_pPathR2) item2:registerScriptTapHandler(restartCallback) ordercallbackmenu:addChild(item2,kItemTagBasic) - local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2) + local item3 = cc.MenuItemImage:create(s_pPathF1, s_pPathF2) ordercallbackmenu:addChild(item3,kItemTagBasic) item3:registerScriptTapHandler(nextCallback) - item1:setPosition(CCPoint(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) - item2:setPosition(CCPoint(size.width / 2, item2:getContentSize().height / 2)) - item3:setPosition(CCPoint(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + item1:setPosition(cc.p(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + item2:setPosition(cc.p(size.width / 2, item2:getContentSize().height / 2)) + item3:setPosition(cc.p(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) - ordercallbackmenu:setPosition(CCPoint(0, 0)) + ordercallbackmenu:setPosition(cc.p(0, 0)) return ordercallbackmenu end @@ -66,89 +66,90 @@ local function drawPrimitivesMainLayer() local function InitTitle(layer) --Title - local lableTitle = CCLabelTTF:create(GetTitle(), "Arial", 40) + local lableTitle = cc.LabelTTF:create(GetTitle(), "Arial", 40) layer:addChild(lableTitle, 15) - lableTitle:setPosition(CCPoint(size.width / 2, size.height - 32)) - lableTitle:setColor(Color3B(255, 255, 40)) + lableTitle:setPosition(cc.p(size.width / 2, size.height - 32)) + lableTitle:setColor(cc.c3b(255, 255, 40)) --SubTitle - local subLabelTitle = CCLabelTTF:create(GetSubTitle(), "Thonburi", 16) + local subLabelTitle = cc.LabelTTF:create(GetSubTitle(), "Thonburi", 16) layer:addChild(subLabelTitle, 15) - subLabelTitle:setPosition(CCPoint(size.width / 2, size.height - 80)) + subLabelTitle:setPosition(cc.p(size.width / 2, size.height - 80)) end local function createDrawPrimitivesEffect() - local layer = CCLayer:create() + local layer = cc.Layer:create() InitTitle(layer) local glNode = gl.glNodeCreate() - glNode:setContentSize(CCSize(size.width, size.height)) - glNode:setAnchorPoint(CCPoint(0.5, 0.5)) + glNode:setContentSize(cc.size(size.width, size.height)) + glNode:setAnchorPoint(cc.p(0.5, 0.5)) local function primitivesDraw() - CCDrawPrimitives.ccDrawLine(VisibleRect:leftBottom(), VisibleRect:rightTop() ) + gl.DrawPrimitives.ccDrawLine(VisibleRect:leftBottom(), VisibleRect:rightTop() ) gl.lineWidth( 5.0 ) - CCDrawPrimitives.ccDrawColor4B(255,0,0,255) - CCDrawPrimitives.ccDrawLine( VisibleRect:leftTop(), VisibleRect:rightBottom() ) + gl.DrawPrimitives.ccDrawColor4B(255,0,0,255) + gl.DrawPrimitives.ccDrawLine( VisibleRect:leftTop(), VisibleRect:rightBottom() ) - CCDrawPrimitives.ccPointSize(64) - CCDrawPrimitives.ccDrawColor4B(0, 0, 255, 128) - CCDrawPrimitives.ccDrawPoint(VisibleRect:center()) + gl.DrawPrimitives.ccPointSize(64) + gl.DrawPrimitives.ccDrawColor4B(0, 0, 255, 128) + gl.DrawPrimitives.ccDrawPoint(VisibleRect:center()) - local points = {CCPoint(60,60), CCPoint(70,70), CCPoint(60,70), CCPoint(70,60) } - CCDrawPrimitives.ccPointSize(4) - CCDrawPrimitives.ccDrawColor4B(0,255,255,255) - CCDrawPrimitives.ccDrawPoints(points,4) + local points = {cc.p(60,60), cc.p(70,70), cc.p(60,70), cc.p(70,60) } + gl.DrawPrimitives.ccPointSize(4) + gl.DrawPrimitives.ccDrawColor4B(0,255,255,255) + gl.DrawPrimitives.ccDrawPoints(points,4) gl.lineWidth(16) - CCDrawPrimitives.ccDrawColor4B(0, 255, 0, 255) - CCDrawPrimitives.ccDrawCircle( VisibleRect:center(), 100, 0, 10, false) + gl.DrawPrimitives.ccDrawColor4B(0, 255, 0, 255) + gl.DrawPrimitives.ccDrawCircle( VisibleRect:center(), 100, 0, 10, false) gl.lineWidth(2) - CCDrawPrimitives.ccDrawColor4B(0, 255, 255, 255) - CCDrawPrimitives.ccDrawCircle( VisibleRect:center(), 50, math.pi / 2, 50, true) + gl.DrawPrimitives.ccDrawColor4B(0, 255, 255, 255) + gl.DrawPrimitives.ccDrawCircle( VisibleRect:center(), 50, math.pi / 2, 50, true) gl.lineWidth(2) - CCDrawPrimitives.ccDrawColor4B(255, 0, 255, 255) - CCDrawPrimitives.ccDrawSolidCircle( VisibleRect:center() + CCPoint(140,0), 40, math.rad(90), 50, 1.0, 1.0) + gl.DrawPrimitives.ccDrawColor4B(255, 0, 255, 255) + gl.DrawPrimitives.ccDrawSolidCircle( cc.p(VisibleRect:center().x + 140 ,VisibleRect:center().y), 40, math.rad(90), 50, 1.0, 1.0) gl.lineWidth(10) - CCDrawPrimitives.ccDrawColor4B(255, 255, 0, 255) - local yellowPoints = { CCPoint(0,0), CCPoint(50,50), CCPoint(100,50), CCPoint(100,100), CCPoint(50,100)} - CCDrawPrimitives.ccDrawPoly( yellowPoints, 5, false) + gl.DrawPrimitives.ccDrawColor4B(255, 255, 0, 255) + local yellowPoints = { cc.p(0,0), cc.p(50,50), cc.p(100,50), cc.p(100,100), cc.p(50,100)} + gl.DrawPrimitives.ccDrawPoly( yellowPoints, 5, false) gl.lineWidth(1) - local filledVertices = { CCPoint(0,120), CCPoint(50,120), CCPoint(50,170), CCPoint(25,200), CCPoint(0,170) } - CCDrawPrimitives.ccDrawSolidPoly(filledVertices, 5, Color4F(0.5, 0.5, 1, 1)) + local filledVertices = { cc.p(0,120), cc.p(50,120), cc.p(50,170), cc.p(25,200), cc.p(0,170) } + gl.DrawPrimitives.ccDrawSolidPoly(filledVertices, 5, cc.c4f(0.5, 0.5, 1, 1)) gl.lineWidth(2) - CCDrawPrimitives.ccDrawColor4B(255, 0, 255, 255) - local closePoints= { CCPoint(30,130), CCPoint(30,230), CCPoint(50,200) } - CCDrawPrimitives.ccDrawPoly( closePoints, 3, true) + gl.DrawPrimitives.ccDrawColor4B(255, 0, 255, 255) + local closePoints= { cc.p(30,130), cc.p(30,230), cc.p(50,200) } + gl.DrawPrimitives.ccDrawPoly( closePoints, 3, true) - CCDrawPrimitives.ccDrawQuadBezier(VisibleRect:leftTop(), VisibleRect:center(), VisibleRect:rightTop(), 50) + gl.DrawPrimitives.ccDrawQuadBezier(VisibleRect:leftTop(), VisibleRect:center(), VisibleRect:rightTop(), 50) - CCDrawPrimitives.ccDrawCubicBezier(VisibleRect:center(), CCPoint(VisibleRect:center().x + 30, VisibleRect:center().y + 50), CCPoint(VisibleRect:center().x + 60,VisibleRect:center().y - 50), VisibleRect:right(), 100) + gl.DrawPrimitives.ccDrawCubicBezier(VisibleRect:center(), cc.p(VisibleRect:center().x + 30, VisibleRect:center().y + 50), cc.p(VisibleRect:center().x + 60,VisibleRect:center().y - 50), VisibleRect:right(), 100) - local solidvertices = {CCPoint(60,160), CCPoint(70,190), CCPoint(100,190), CCPoint(90,160)} - CCDrawPrimitives.ccDrawSolidPoly( solidvertices, 4, Color4F(1, 1, 0, 1) ) + local solidvertices = {cc.p(60,160), cc.p(70,190), cc.p(100,190), cc.p(90,160)} + gl.DrawPrimitives.ccDrawSolidPoly( solidvertices, 4, cc.c4f(1, 1, 0, 1) ) - local array = CCPointArray:create(20) - array:addControlPoint(CCPoint(0, 0)) - array:addControlPoint(CCPoint(size.width / 2 - 30, 0)) - array:addControlPoint(CCPoint(size.width / 2 - 30, size.height - 80)) - array:addControlPoint(CCPoint(0, size.height - 80)) - array:addControlPoint(CCPoint(0, 0)) - CCDrawPrimitives.ccDrawCatmullRom( array, 5) + local array = { + cc.p(0, 0), + cc.p(size.width / 2 - 30, 0), + cc.p(size.width / 2 - 30, size.height - 80), + cc.p(0, size.height - 80), + cc.p(0, 0), + } + gl.DrawPrimitives.ccDrawCatmullRom( array, 5) - CCDrawPrimitives.ccDrawCardinalSpline( array, 0,100) + gl.DrawPrimitives.ccDrawCardinalSpline( array, 0,100) gl.lineWidth(1) - CCDrawPrimitives.ccDrawColor4B(255,255,255,255) - CCDrawPrimitives.ccPointSize(1) + gl.DrawPrimitives.ccDrawColor4B(255,255,255,255) + gl.DrawPrimitives.ccPointSize(1) end glNode:registerScriptDrawHandler(primitivesDraw) @@ -159,44 +160,44 @@ local function drawPrimitivesMainLayer() end local function createDrawNodeTest() - local layer = CCLayer:create() + local layer = cc.Layer:create() InitTitle(layer) - local draw = CCDrawNode:create() + local draw = cc.DrawNode:create() layer:addChild(draw, 10) --Draw 10 circles for i=1, 10 do - draw:drawDot(CCPoint(size.width/2, size.height/2), 10*(10-i), Color4F(math.random(0,1), math.random(0,1), math.random(0,1), 1)) + draw:drawDot(cc.p(size.width/2, size.height/2), 10*(10-i), cc.c4f(math.random(0,1), math.random(0,1), math.random(0,1), 1)) end --Draw polygons - points = { CCPoint(size.height/4, 0), CCPoint(size.width, size.height / 5), CCPoint(size.width / 3 * 2, size.height) } - draw:drawPolygon(points, table.getn(points), Color4F(1,0,0,0.5), 4, Color4F(0,0,1,1)) + points = { cc.p(size.height/4, 0), cc.p(size.width, size.height / 5), cc.p(size.width / 3 * 2, size.height) } + draw:drawPolygon(points, table.getn(points), cc.c4f(1,0,0,0.5), 4, cc.c4f(0,0,1,1)) local o = 80 local w = 20 local h = 50 - local star1 = { CCPoint( o + w, o - h), CCPoint(o + w * 2, o), CCPoint(o + w * 2 + h, o + w), CCPoint(o + w * 2, o + w * 2) } + local star1 = { cc.p( o + w, o - h), cc.p(o + w * 2, o), cc.p(o + w * 2 + h, o + w), cc.p(o + w * 2, o + w * 2) } - draw:drawPolygon(star1, table.getn(star1), Color4F(1,0,0,0.5), 1, Color4F(0,0,1,1)) + draw:drawPolygon(star1, table.getn(star1), cc.c4f(1,0,0,0.5), 1, cc.c4f(0,0,1,1)) o = 180 w = 20 h = 50 local star2 = { - CCPoint(o, o), CCPoint(o + w, o - h), CCPoint(o + w * 2, o), --lower spike - CCPoint(o + w * 2 + h, o + w ), CCPoint(o + w * 2, o + w * 2), --right spike - CCPoint(o + w, o + w * 2 + h), CCPoint(o, o + w * 2), --top spike - CCPoint(o - h, o + w), --left spike + cc.p(o, o), cc.p(o + w, o - h), cc.p(o + w * 2, o), --lower spike + cc.p(o + w * 2 + h, o + w ), cc.p(o + w * 2, o + w * 2), --right spike + cc.p(o + w, o + w * 2 + h), cc.p(o, o + w * 2), --top spike + cc.p(o - h, o + w), --left spike }; - draw:drawPolygon(star2, table.getn(star2), Color4F(1,0,0,0.5), 1, Color4F(0,0,1,1)) + draw:drawPolygon(star2, table.getn(star2), cc.c4f(1,0,0,0.5), 1, cc.c4f(0,0,1,1)) - draw:drawSegment(CCPoint(20,size.height), CCPoint(20,size.height/2), 10, Color4F(0, 1, 0, 1)) + draw:drawSegment(cc.p(20,size.height), cc.p(20,size.height/2), 10, cc.c4f(0, 1, 0, 1)) - draw:drawSegment(CCPoint(10,size.height/2), CCPoint(size.width/2, size.height/2), 40, Color4F(1, 0, 1, 0.5)) + draw:drawSegment(cc.p(10,size.height/2), cc.p(size.width/2, size.height/2), 40, cc.c4f(1, 0, 1, 0.5)) return layer end @@ -210,14 +211,14 @@ local function drawPrimitivesMainLayer() end function showCurrentTest() - local curScene = CCScene:create() + local curScene = cc.Scene:create() if nil ~= curScene then curLayer = createLayerByCurCase(curCase) if nil ~= curLayer then curScene:addChild(curLayer) curLayer:addChild(orderCallbackMenu(),15) curScene:addChild(CreateBackMenuItem()) - CCDirector:getInstance():replaceScene(curScene) + cc.Director:getInstance():replaceScene(curScene) end end end @@ -228,7 +229,7 @@ local function drawPrimitivesMainLayer() end function DrawPrimitivesTest() - local scene = CCScene:create() + local scene = cc.Scene:create() scene:addChild(drawPrimitivesMainLayer()) scene:addChild(CreateBackMenuItem()) return scene diff --git a/samples/Lua/TestLua/Resources/luaScript/EffectsAdvancedTest/EffectsAdvancedTest.lua b/samples/Lua/TestLua/Resources/luaScript/EffectsAdvancedTest/EffectsAdvancedTest.lua index e742be019d..4e44e63518 100644 --- a/samples/Lua/TestLua/Resources/luaScript/EffectsAdvancedTest/EffectsAdvancedTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/EffectsAdvancedTest/EffectsAdvancedTest.lua @@ -8,29 +8,23 @@ local originCreateLayer = createTestLayer local function createTestLayer(title, subtitle) local ret = originCreateLayer(title, subtitle) - local bg = CCSprite:create("Images/background3.png") + local bg = cc.Sprite:create("Images/background3.png") ret:addChild(bg, 0, kTagBackground) bg:setPosition( VisibleRect:center() ) - local grossini = CCSprite:create("Images/grossinis_sister2.png") + local grossini = cc.Sprite:create("Images/grossinis_sister2.png") bg:addChild(grossini, 1, kTagSprite1) - grossini:setPosition( CCPoint(VisibleRect:left().x+VisibleRect:getVisibleRect().size.width/3.0, VisibleRect:bottom().y+ 200) ) - local sc = CCScaleBy:create(2, 5) + grossini:setPosition( cc.p(VisibleRect:left().x+VisibleRect:getVisibleRect().width/3.0, VisibleRect:bottom().y+ 200) ) + local sc = cc.ScaleBy:create(2, 5) local sc_back = sc:reverse() - local arr = CCArray:create() - arr:addObject(sc) - arr:addObject(sc_back) - grossini:runAction( CCRepeatForever:create(CCSequence:create(arr))) + grossini:runAction( cc.RepeatForever:create(cc.Sequence:create(sc, sc_back))) - local tamara = CCSprite:create("Images/grossinis_sister1.png") + local tamara = cc.Sprite:create("Images/grossinis_sister1.png") bg:addChild(tamara, 1, kTagSprite2) - tamara:setPosition( CCPoint(VisibleRect:left().x+2*VisibleRect:getVisibleRect().size.width/3.0,VisibleRect:bottom().y+200) ) - local sc2 = CCScaleBy:create(2, 5) + tamara:setPosition( cc.p(VisibleRect:left().x+2*VisibleRect:getVisibleRect().width/3.0,VisibleRect:bottom().y+200) ) + local sc2 = cc.ScaleBy:create(2, 5) local sc2_back = sc2:reverse() - arr = CCArray:create() - arr:addObject(sc2) - arr:addObject(sc2_back) - tamara:runAction( CCRepeatForever:create(CCSequence:create(arr))) + tamara:runAction( cc.RepeatForever:create(cc.Sequence:create(sc2, sc2_back))) return ret end @@ -50,25 +44,17 @@ local function Effect1() -- Lens3D is Grid3D and it's size is (15,10) -- Waves3D is Grid3D and it's size is (15,10) - local size = CCDirector:getInstance():getWinSize() - local lens = CCLens3D:create(0.0, CCSize(15,10), CCPoint(size.width/2,size.height/2), 240) - local waves = CCWaves3D:create(10, CCSize(15,10), 18, 15) + local size = cc.Director:getInstance():getWinSize() + local lens = cc.Lens3D:create(0.0, cc.size(15,10), cc.p(size.width/2,size.height/2), 240) + local waves = cc.Waves3D:create(10, cc.size(15,10), 18, 15) - local reuse = CCReuseGrid:create(1) - local delay = CCDelayTime:create(8) + local reuse = cc.ReuseGrid:create(1) + local delay = cc.DelayTime:create(8) - local orbit = CCOrbitCamera:create(5, 1, 2, 0, 180, 0, -90) + local orbit = cc.OrbitCamera:create(5, 1, 2, 0, 180, 0, -90) local orbit_back = orbit:reverse() - local arr = CCArray:create() - arr:addObject(orbit) - arr:addObject(orbit_back) - target:runAction( CCRepeatForever:create( CCSequence:create(arr))) - arr = CCArray:create() - arr:addObject(lens) - arr:addObject(delay) - arr:addObject(reuse) - arr:addObject(waves) - target:runAction( CCSequence:create(arr)) + target:runAction( cc.RepeatForever:create( cc.Sequence:create(orbit, orbit_back))) + target:runAction( cc.Sequence:create(lens, delay, reuse, waves)) return ret end @@ -86,28 +72,20 @@ local function Effect2() -- ShakyTiles is TiledGrid3D and it's size is (15,10) -- Shuffletiles is TiledGrid3D and it's size is (15,10) -- TurnOfftiles is TiledGrid3D and it's size is (15,10) - local shaky = CCShakyTiles3D:create(5, CCSize(15,10), 4, false) - local shuffle = CCShuffleTiles:create(0, CCSize(15,10), 3) - local turnoff = CCTurnOffTiles:create(0, CCSize(15,10), 3) + local shaky = cc.ShakyTiles3D:create(5, cc.size(15,10), 4, false) + local shuffle = cc.ShuffleTiles:create(0, cc.size(15,10), 3) + local turnoff = cc.TurnOffTiles:create(0, cc.size(15,10), 3) local turnon = turnoff:reverse() -- reuse 2 times: -- 1 for shuffle -- 2 for turn off -- turnon tiles will use a new grid - local reuse = CCReuseGrid:create(2) + local reuse = cc.ReuseGrid:create(2) - local delay = CCDelayTime:create(1) + local delay = cc.DelayTime:create(1) - local arr = CCArray:create() - arr:addObject(shaky) - arr:addObject(delay) - arr:addObject(reuse) - arr:addObject(shuffle) - arr:addObject(tolua.cast(delay:clone(), "CCAction")) - arr:addObject(turnoff) - arr:addObject(turnon) - target:runAction(CCSequence:create(arr)) + target:runAction(cc.Sequence:create(shaky, delay ,reuse, shuffle, tolua.cast(delay:clone(), "Action"), turnoff, turnon)) return ret end @@ -122,18 +100,15 @@ local function Effect3() local target1 = bg:getChildByTag(kTagSprite1) local target2 = bg:getChildByTag(kTagSprite2) - local waves = CCWaves:create(5, CCSize(15,10), 5, 20, true, false) - local shaky = CCShaky3D:create(5, CCSize(15,10), 4, false) + local waves = cc.Waves:create(5, cc.size(15,10), 5, 20, true, false) + local shaky = cc.Shaky3D:create(5, cc.size(15,10), 4, false) - target1:runAction( CCRepeatForever:create( waves ) ) - target2:runAction( CCRepeatForever:create( shaky ) ) + target1:runAction( cc.RepeatForever:create( waves ) ) + target2:runAction( cc.RepeatForever:create( shaky ) ) -- moving background. Testing issue #244 - local move = CCMoveBy:create(3, CCPoint(200,0) ) - local arr = CCArray:create() - arr:addObject(move) - arr:addObject(move:reverse()) - bg:runAction(CCRepeatForever:create( CCSequence:create(arr))) + local move = cc.MoveBy:create(3, cc.p(200,0) ) + bg:runAction(cc.RepeatForever:create( cc.Sequence:create(move, move:reverse()))) return ret end @@ -143,20 +118,20 @@ end -- -------------------------------------------------------------------- --- class Lens3DTarget : public CCNode +-- class Lens3DTarget : public cc.Node -- public: --- virtual void setPosition(const CCPoint& var) +-- virtual void setPosition(const cc.p& var) -- m_pLens3D:setPosition(var) -- end --- virtual const CCPoint& getPosition() +-- virtual const cc.p& getPosition() -- return m_pLens3D:getPosition() -- end --- static Lens3DTarget* create(CCLens3D* pAction) +-- static Lens3DTarget* create(cc.Lens3D* pAction) -- Lens3DTarget* pRet = new Lens3DTarget() -- pRet:m_pLens3D = pAction @@ -169,25 +144,22 @@ end -- : m_pLens3D(NULL) -- {} --- CCLens3D* m_pLens3D +-- cc.Lens3D* m_pLens3D -- end local function Effect4() local ret = createTestLayer("Jumpy Lens3D") - local lens = CCLens3D:create(10, CCSize(32,24), CCPoint(100,180), 150) - local move = CCJumpBy:create(5, CCPoint(380,0), 100, 4) + local lens = cc.Lens3D:create(10, cc.size(32,24), cc.p(100,180), 150) + local move = cc.JumpBy:create(5, cc.p(380,0), 100, 4) local move_back = move:reverse() - local arr = CCArray:create() - arr:addObject(move) - arr:addObject(move_back) - local seq = CCSequence:create( arr) + local seq = cc.Sequence:create( move, move_back) - -- /* In cocos2d-iphone, the type of action's target is 'id', so it supports using the instance of 'CCLens3D' as its target. - -- While in cocos2d-x, the target of action only supports CCNode or its subclass, - -- so we make an encapsulation for CCLens3D to achieve that. + -- /* In cocos2d-iphone, the type of action's target is 'id', so it supports using the instance of 'cc.Lens3D' as its target. + -- While in cocos2d-x, the target of action only supports cc.Node or its subclass, + -- so we make an encapsulation for cc.Lens3D to achieve that. -- */ - local director = CCDirector:getInstance() + local director = cc.Director:getInstance() -- local pTarget = Lens3DTarget:create(lens) -- -- Please make sure the target been added to its parent. -- ret:addChild(pTarget) @@ -205,18 +177,14 @@ end local function Effect5() local ret = createTestLayer("Test Stop-Copy-Restar") - local effect = CCLiquid:create(2, CCSize(32,24), 1, 20) - local arr = CCArray:create() - arr:addObject(effect) - arr:addObject(CCDelayTime:create(2)) - arr:addObject(CCStopGrid:create()) + local effect = cc.Liquid:create(2, cc.size(32,24), 1, 20) - local stopEffect = CCSequence:create(arr) + local stopEffect = cc.Sequence:create(effect, cc.DelayTime:create(2), cc.StopGrid:create()) local bg = ret:getChildByTag(kTagBackground) bg:runAction(stopEffect) local function onNodeEvent(event) if event == "exit" then - CCDirector:getInstance():setProjection(kCCDirectorProjection3D) + cc.Director:getInstance():setProjection(cc.DIRECTOR_PROJECTION_3D) end end @@ -233,35 +201,33 @@ end local function Issue631() local ret = createTestLayer("Testing Opacity", "Effect image should be 100% opaque. Testing issue #631") - local arr = CCArray:create() - arr:addObject(CCDelayTime:create(2.0)) - arr:addObject(CCShaky3D:create(5.0, CCSize(5, 5), 16, false)) - local effect = CCSequence:create(arr) + + local effect = cc.Sequence:create(cc.DelayTime:create(2.0),cc.Shaky3D:create(5.0, cc.size(5, 5), 16, false)) -- cleanup local bg = ret:getChildByTag(kTagBackground) ret:removeChild(bg, true) -- background - local layer = CCLayerColor:create( Color4B(255,0,0,255) ) + local layer = cc.LayerColor:create( cc.c4b(255,0,0,255) ) ret:addChild(layer, -10) - local sprite = CCSprite:create("Images/grossini.png") - sprite:setPosition( CCPoint(50,80) ) + local sprite = cc.Sprite:create("Images/grossini.png") + sprite:setPosition( cc.p(50,80) ) layer:addChild(sprite, 10) -- foreground - local layer2 = CCLayerColor:create(Color4B( 0, 255,0,255 ) ) - local fog = CCSprite:create("Images/Fog.png") + local layer2 = cc.LayerColor:create(cc.c4b( 0, 255,0,255 ) ) + local fog = cc.Sprite:create("Images/Fog.png") - local bf = BlendFunc() - bf.src = GL_SRC_ALPHA - bf.dst = GL_ONE_MINUS_SRC_ALPHA + --local bf = BlendFunc() + --bf.src = GL_SRC_ALPHA + --bf.dst = GL_ONE_MINUS_SRC_ALPHA - fog:setBlendFunc(bf) + fog:setBlendFunc(gl.SRC_ALPHA , gl.ONE_MINUS_SRC_ALPHA ) layer2:addChild(fog, 1) ret:addChild(layer2, 1) - layer2:runAction( CCRepeatForever:create(effect) ) + layer2:runAction( cc.RepeatForever:create(effect) ) return ret end @@ -269,7 +235,7 @@ function EffectAdvancedTestMain() cclog("EffectAdvancedTestMain") Helper.index = 1 - local scene = CCScene:create() + local scene = cc.Scene:create() Helper.createFunctionTable = { Effect3, Effect2, diff --git a/samples/Lua/TestLua/Resources/luaScript/EffectsTest/EffectsTest.lua b/samples/Lua/TestLua/Resources/luaScript/EffectsTest/EffectsTest.lua index 71da8fb91f..34e4b7cd05 100644 --- a/samples/Lua/TestLua/Resources/luaScript/EffectsTest/EffectsTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/EffectsTest/EffectsTest.lua @@ -2,7 +2,7 @@ require "luaScript/EffectsTest/EffectsName" local ActionIdx = -1 -local size = CCDirector:getInstance():getWinSize() +local size = cc.Director:getInstance():getWinSize() local kTagTextLayer = 1 local kTagBackground = 1 local kTagLabel = 2 @@ -26,7 +26,7 @@ local function checkAnim(dt) end local function onEnterOrExit(tag) - local scheduler = CCDirector:getInstance():getScheduler() + local scheduler = cc.Director:getInstance():getScheduler() if tag == "enter" then entry = scheduler:scheduleScriptFunc(checkAnim, 0, false) elseif tag == "exit" then @@ -55,256 +55,224 @@ local function nextAction() end local function backCallback(sender) - local scene = CCScene:create() + local scene = cc.Scene:create() scene:addChild(backAction()) scene:addChild(CreateBackMenuItem()) - CCDirector:getInstance():replaceScene(scene) + cc.Director:getInstance():replaceScene(scene) end local function restartCallback(sender) - local scene = CCScene:create() + local scene = cc.Scene:create() scene:addChild(restartAction()) scene:addChild(CreateBackMenuItem()) - CCDirector:getInstance():replaceScene(scene) + cc.Director:getInstance():replaceScene(scene) end local function nextCallback(sender) - local scene = CCScene:create() + local scene = cc.Scene:create() scene:addChild(nextAction()) scene:addChild(CreateBackMenuItem()) - CCDirector:getInstance():replaceScene(scene) + cc.Director:getInstance():replaceScene(scene) end -------------------------------------- -- Shaky3DDemo -------------------------------------- local function Shaky3DDemo(t) - return CCShaky3D:create(t, CCSize(15,10), 5, false); + return cc.Shaky3D:create(t, cc.size(15,10), 5, false); end -------------------------------------- -- Waves3DDemo -------------------------------------- local function Waves3DDemo(t) - return CCWaves3D:create(t, CCSize(15,10), 5, 40); + return cc.Waves3D:create(t, cc.size(15,10), 5, 40); end -------------------------------------- -- FlipX3DDemo -------------------------------------- local function FlipX3DDemo(t) - local flipx = CCFlipX3D:create(t) + local flipx = cc.FlipX3D:create(t) local flipx_back = flipx:reverse() - local delay = CCDelayTime:create(2) + local delay = cc.DelayTime:create(2) - local array = CCArray:create() - array:addObject(flipx) - array:addObject(flipx_back) - array:addObject(delay) - return CCSequence:create(array) + return cc.Sequence:create(flipx, flipx_back, delay) end -------------------------------------- -- FlipY3DDemo -------------------------------------- local function FlipY3DDemo(t) - local flipy = CCFlipY3D:create(t) + local flipy = cc.FlipY3D:create(t) local flipy_back = flipy:reverse() - local delay = CCDelayTime:create(2) + local delay = cc.DelayTime:create(2) - local array = CCArray:create() - array:addObject(flipy) - array:addObject(flipy_back) - array:addObject(delay) - return CCSequence:create(array) + return cc.Sequence:create(flipy, flipy_back, delay) end -------------------------------------- -- Lens3DDemo -------------------------------------- local function Lens3DDemo(t) - return CCLens3D:create(t, CCSize(15,10), CCPoint(size.width/2,size.height/2), 240); + return cc.Lens3D:create(t, cc.size(15,10), cc.p(size.width/2,size.height/2), 240); end -------------------------------------- -- Ripple3DDemo -------------------------------------- local function Ripple3DDemo(t) - return CCRipple3D:create(t, CCSize(32,24), CCPoint(size.width/2,size.height/2), 240, 4, 160); + return cc.Ripple3D:create(t, cc.size(32,24), cc.p(size.width/2,size.height/2), 240, 4, 160); end -------------------------------------- -- LiquidDemo -------------------------------------- local function LiquidDemo(t) - return CCLiquid:create(t, CCSize(16,12), 4, 20); + return cc.Liquid:create(t, cc.size(16,12), 4, 20); end -------------------------------------- -- WavesDemo -------------------------------------- local function WavesDemo(t) - return CCWaves:create(t, CCSize(16,12), 4, 20, true, true); + return cc.Waves:create(t, cc.size(16,12), 4, 20, true, true); end -------------------------------------- -- TwirlDemo -------------------------------------- local function TwirlDemo(t) - return CCTwirl:create(t, CCSize(12,8), CCPoint(size.width/2, size.height/2), 1, 2.5); + return cc.Twirl:create(t, cc.size(12,8), cc.p(size.width/2, size.height/2), 1, 2.5); end -------------------------------------- -- ShakyTiles3DDemo -------------------------------------- local function ShakyTiles3DDemo(t) - return CCShakyTiles3D:create(t, CCSize(16,12), 5, false); + return cc.ShakyTiles3D:create(t, cc.size(16,12), 5, false); end -------------------------------------- -- ShatteredTiles3DDemo -------------------------------------- local function ShatteredTiles3DDemo(t) - return CCShatteredTiles3D:create(t, CCSize(16,12), 5, false); + return cc.ShatteredTiles3D:create(t, cc.size(16,12), 5, false); end -------------------------------------- -- ShuffleTilesDemo -------------------------------------- local function ShuffleTilesDemo(t) - local shuffle = CCShuffleTiles:create(t, CCSize(16,12), 25); + local shuffle = cc.ShuffleTiles:create(t, cc.size(16,12), 25); local shuffle_back = shuffle:reverse() - local delay = CCDelayTime:create(2) + local delay = cc.DelayTime:create(2) - local array = CCArray:create() - array:addObject(shuffle) - array:addObject(shuffle_back) - array:addObject(delay) - return CCSequence:create(array) + return cc.Sequence:create(shuffle, shuffle_back, delay) end -------------------------------------- -- FadeOutTRTilesDemo -------------------------------------- local function FadeOutTRTilesDemo(t) - local fadeout = CCFadeOutTRTiles:create(t, CCSize(16,12)); + local fadeout = cc.FadeOutTRTiles:create(t, cc.size(16,12)); local back = fadeout:reverse() - local delay = CCDelayTime:create(0.5) + local delay = cc.DelayTime:create(0.5) - local array = CCArray:create() - array:addObject(fadeout) - array:addObject(back) - array:addObject(delay) - return CCSequence:create(array) + return cc.Sequence:create(fadeout, back, delay) end -------------------------------------- -- FadeOutBLTilesDemo -------------------------------------- local function FadeOutBLTilesDemo(t) - local fadeout = CCFadeOutBLTiles:create(t, CCSize(16,12)); + local fadeout = cc.FadeOutBLTiles:create(t, cc.size(16,12)); local back = fadeout:reverse() - local delay = CCDelayTime:create(0.5) + local delay = cc.DelayTime:create(0.5) - local array = CCArray:create() - array:addObject(fadeout) - array:addObject(back) - array:addObject(delay) - return CCSequence:create(array) + return cc.Sequence:create(fadeout, back, delay) end -------------------------------------- -- FadeOutUpTilesDemo -------------------------------------- local function FadeOutUpTilesDemo(t) - local fadeout = CCFadeOutUpTiles:create(t, CCSize(16,12)); + local fadeout = cc.FadeOutUpTiles:create(t, cc.size(16,12)); local back = fadeout:reverse() - local delay = CCDelayTime:create(0.5) + local delay = cc.DelayTime:create(0.5) - local array = CCArray:create() - array:addObject(fadeout) - array:addObject(back) - array:addObject(delay) - return CCSequence:create(array) + return cc.Sequence:create(fadeout, back, delay) end -------------------------------------- -- FadeOutDownTilesDemo -------------------------------------- local function FadeOutDownTilesDemo(t) - local fadeout = CCFadeOutDownTiles:create(t, CCSize(16,12)); + local fadeout = cc.FadeOutDownTiles:create(t, cc.size(16,12)); local back = fadeout:reverse() - local delay = CCDelayTime:create(0.5) + local delay = cc.DelayTime:create(0.5) - local array = CCArray:create() - array:addObject(fadeout) - array:addObject(back) - array:addObject(delay) - return CCSequence:create(array) + return cc.Sequence:create(fadeout, back, delay) end -------------------------------------- -- TurnOffTilesDemo -------------------------------------- local function TurnOffTilesDemo(t) - local fadeout = CCTurnOffTiles:create(t, CCSize(48,32), 25); + local fadeout = cc.TurnOffTiles:create(t, cc.size(48,32), 25); local back = fadeout:reverse() - local delay = CCDelayTime:create(0.5) + local delay = cc.DelayTime:create(0.5) - local array = CCArray:create() - array:addObject(fadeout) - array:addObject(back) - array:addObject(delay) - return CCSequence:create(array) + return cc.Sequence:create(fadeout, back, delay) end -------------------------------------- -- WavesTiles3DDemo -------------------------------------- local function WavesTiles3DDemo(t) - return CCWavesTiles3D:create(t, CCSize(15,10), 4, 120); + return cc.WavesTiles3D:create(t, cc.size(15,10), 4, 120); end -------------------------------------- -- JumpTiles3DDemo -------------------------------------- local function JumpTiles3DDemo(t) - return CCJumpTiles3D:create(t, CCSize(15,10), 2, 30); + return cc.JumpTiles3D:create(t, cc.size(15,10), 2, 30); end -------------------------------------- -- SplitRowsDemo -------------------------------------- local function SplitRowsDemo(t) - return CCSplitRows:create(t, 9); + return cc.SplitRows:create(t, 9); end -------------------------------------- -- SplitColsDemo -------------------------------------- local function SplitColsDemo(t) - return CCSplitCols:create(t, 9); + return cc.SplitCols:create(t, 9); end -------------------------------------- -- PageTurn3DDemo -------------------------------------- local function PageTurn3DDemo(t) - CCDirector:getInstance():setDepthTest(true) - return CCPageTurn3D:create(t, CCSize(15,10)); + cc.Director:getInstance():setDepthTest(true) + return cc.PageTurn3D:create(t, cc.size(15,10)); end -------------------------------------- -- Effects Test -------------------------------------- local function createEffect(idx, t) - CCDirector:getInstance():setDepthTest(false) + cc.Director:getInstance():setDepthTest(false) local action = nil if idx == 0 then @@ -357,54 +325,54 @@ local function createEffect(idx, t) end function CreateEffectsTestLayer() - testLayer = CCLayerColor:create(Color4B(32,128,32,255)) + testLayer = cc.LayerColor:create(cc.c4b(32,128,32,255)) local x, y = size.width, size.height - local node = CCNode:create() + local node = cc.Node:create() local effect = createEffect(ActionIdx, 3) node:runAction(effect) testLayer:addChild(node, 0, kTagBackground) - local bg = CCSprite:create(s_back3) + local bg = cc.Sprite:create(s_back3) node:addChild(bg, 0) - bg:setPosition(CCPoint(size.width / 2, size.height / 2)) + bg:setPosition(cc.p(size.width / 2, size.height / 2)) - local grossini = CCSprite:create(s_pPathSister2) + local grossini = cc.Sprite:create(s_pPathSister2) node:addChild(grossini, 1) - grossini:setPosition( CCPoint(x / 3, y / 2) ) - local sc = CCScaleBy:create(2, 5) + grossini:setPosition( cc.p(x / 3, y / 2) ) + local sc = cc.ScaleBy:create(2, 5) local sc_back = sc:reverse() - grossini:runAction(CCRepeatForever:create(CCSequence:createWithTwoActions(sc, sc_back))) + grossini:runAction(cc.RepeatForever:create(cc.Sequence:create(sc, sc_back))) - local tamara = CCSprite:create(s_pPathSister1) + local tamara = cc.Sprite:create(s_pPathSister1) node:addChild(tamara, 1) - tamara:setPosition(CCPoint(2 * x / 3, y / 2)) - local sc2 = CCScaleBy:create(2, 5) + tamara:setPosition(cc.p(2 * x / 3, y / 2)) + local sc2 = cc.ScaleBy:create(2, 5) local sc2_back = sc2:reverse() - tamara:runAction(CCRepeatForever:create(CCSequence:createWithTwoActions(sc2, sc2_back))) + tamara:runAction(cc.RepeatForever:create(cc.Sequence:create(sc2, sc2_back))) - titleLabel = CCLabelTTF:create(EffectsList[ActionIdx], "Marker Felt", 32) + titleLabel = cc.LabelTTF:create(EffectsList[ActionIdx], "Marker Felt", 32) titleLabel:setPosition(x / 2, y - 80) testLayer:addChild(titleLabel) titleLabel:setTag(kTagLabel) - local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2) - local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2) - local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2) + local item1 = cc.MenuItemImage:create(s_pPathB1, s_pPathB2) + local item2 = cc.MenuItemImage:create(s_pPathR1, s_pPathR2) + local item3 = cc.MenuItemImage:create(s_pPathF1, s_pPathF2) item1:registerScriptTapHandler(backCallback) item2:registerScriptTapHandler(restartCallback) item3:registerScriptTapHandler(nextCallback) - local menu = CCMenu:create() + local menu = cc.Menu:create() menu:addChild(item1) menu:addChild(item2) menu:addChild(item3) - menu:setPosition(CCPoint(0, 0)) - item1:setPosition(CCPoint(size.width/2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) - item2:setPosition(CCPoint(size.width/2, item2:getContentSize().height / 2)) - item3:setPosition(CCPoint(size.width/2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + menu:setPosition(cc.p(0, 0)) + item1:setPosition(cc.p(size.width/2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + item2:setPosition(cc.p(size.width/2, item2:getContentSize().height / 2)) + item3:setPosition(cc.p(size.width/2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) testLayer:addChild(menu, 1) @@ -414,7 +382,7 @@ function CreateEffectsTestLayer() end function EffectsTest() - local scene = CCScene:create() + local scene = cc.Scene:create() ActionIdx = -1 scene:addChild(nextAction()) diff --git a/samples/Lua/TestLua/Resources/luaScript/VisibleRect.lua b/samples/Lua/TestLua/Resources/luaScript/VisibleRect.lua index 523c061e08..7d00240f8a 100644 --- a/samples/Lua/TestLua/Resources/luaScript/VisibleRect.lua +++ b/samples/Lua/TestLua/Resources/luaScript/VisibleRect.lua @@ -23,7 +23,7 @@ end function VisibleRect:getVisibleRect() self:lazyInit() - return cc.Rect(self.s_visibleRect.x, self.s_visibleRect.y, self.s_visibleRect.width, self.s_visibleRect.height) + return cc.rect(self.s_visibleRect.x, self.s_visibleRect.y, self.s_visibleRect.width, self.s_visibleRect.height) end function VisibleRect:left() diff --git a/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua b/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua index b62b0528f0..1099f5635e 100644 --- a/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua +++ b/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua @@ -6,20 +6,25 @@ require "Opengl" require "OpenglConstants" require "luaScript/helper" require "luaScript/testResource" +require "luaScript/VisibleRect" require "luaScript/ActionManagerTest/ActionManagerTest" require "luaScript/ActionsEaseTest/ActionsEaseTest" require "luaScript/ActionsProgressTest/ActionsProgressTest" require "luaScript/ActionsTest/ActionsTest" +require "luaScript/BugsTest/BugsTest" +require "luaScript/ClickAndMoveTest/ClickAndMoveTest" +require "luaScript/CocosDenshionTest/CocosDenshionTest" +require "luaScript/CurrentLanguageTest/CurrentLanguageTest" +require "luaScript/DrawPrimitivesTest/DrawPrimitivesTest" +require "luaScript/EffectsTest/EffectsTest" +require "luaScript/EffectsAdvancedTest/EffectsAdvancedTest" --[[ require "luaScript/TransitionsTest/TransitionsTest" -require "luaScript/EffectsTest/EffectsTest" -require "luaScript/ClickAndMoveTest/ClickAndMoveTest" require "luaScript/RotateWorldTest/RotateWorldTest" require "luaScript/ParticleTest/ParticleTest" require "luaScript/MotionStreakTest/MotionStreakTest" -require "luaScript/DrawPrimitivesTest/DrawPrimitivesTest" require "luaScript/NodeTest/NodeTest" require "luaScript/TouchesTest/TouchesTest" require "luaScript/SpriteTest/SpriteTest" @@ -36,11 +41,7 @@ require "luaScript/Texture2dTest/Texture2dTest" require "luaScript/RenderTextureTest/RenderTextureTest" require "luaScript/ZwoptexTest/ZwoptexTest" require "luaScript/FontTest/FontTest" -require "luaScript/CocosDenshionTest/CocosDenshionTest" -require "luaScript/EffectsAdvancedTest/EffectsAdvancedTest" require "luaScript/UserDefaultTest/UserDefaultTest" -require "luaScript/CurrentLanguageTest/CurrentLanguageTest" -require "luaScript/BugsTest/BugsTest" require "luaScript/ExtensionTest/ExtensionTest" require "luaScript/AccelerometerTest/AccelerometerTest" require "luaScript/KeypadTest/KeypadTest" diff --git a/scripting/lua/cocos2dx_support/LuaOpengl.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/LuaOpengl.cpp.REMOVED.git-id index 937b18fb64..d3e9b8256b 100644 --- a/scripting/lua/cocos2dx_support/LuaOpengl.cpp.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/LuaOpengl.cpp.REMOVED.git-id @@ -1 +1 @@ -b3460818609e566b063e1c9b7404650048c81121 \ No newline at end of file +faeffa101e0d6ba77fa19f3bd83b12a267209994 \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id index 09c6c03fa3..9b5885cf90 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id @@ -1 +1 @@ -aa5612e5aef2fe92c3fed272d4de8a072dc1682f \ No newline at end of file +fe22a58a97c6532a0d8b5c326cd683e108407b1e \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.hpp b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.hpp index e7613ff89a..0bf4dbb702 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.hpp +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.hpp @@ -1,5 +1,5 @@ -#ifndef __cocos2dx_lua_cocos2dx_support_auto_h__ -#define __cocos2dx_lua_cocos2dx_support_auto_h__ +#ifndef __cocos2dx_h__ +#define __cocos2dx_h__ #ifdef __cplusplus extern "C" { @@ -1790,4 +1790,216 @@ int register_all_cocos2dx(lua_State* tolua_S); -#endif // #ifndef __cocos2dx_lua_cocos2dx_support_auto_h__ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +#endif // __cocos2dx_h__ diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id index a8d76d6a7f..b43bd36ea1 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id @@ -1 +1 @@ -63d07a801569560e761eb49303c77fdb54e6d57e \ No newline at end of file +1df451e47e5e21c6430adcd93e76253dac5dcb14 \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id index cb866f3625..5d9c096a15 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id @@ -1 +1 @@ -19d626318d010f941ff497bb509888c194056b85 \ No newline at end of file +55f9aed3fc28a46be61e0ddaa629a9503b54a1ac \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.hpp b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.hpp index e474109b14..021fd1c6bf 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.hpp +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.hpp @@ -1,5 +1,5 @@ -#ifndef __cocos2dx_extension_lua_cocos2dx_support_auto_h__ -#define __cocos2dx_extension_lua_cocos2dx_support_auto_h__ +#ifndef __cocos2dx_extension_h__ +#define __cocos2dx_extension_h__ #ifdef __cplusplus extern "C" { @@ -257,4 +257,12 @@ int register_all_cocos2dx_extension(lua_State* tolua_S); -#endif // #ifndef __cocos2dx_extension_lua_cocos2dx_support_auto_h__ + + + + + + + + +#endif // __cocos2dx_extension_h__ diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto_api.js b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto_api.js index 7da2e75f17..a6cffbd414 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto_api.js +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto_api.js @@ -431,7 +431,7 @@ setTitleLabelForState : function () {}, * @method ccTouchBegan * @return A value converted from C/C++ "bool" * @param {cocos2d::Touch*} - * @param {Event*} + * @param {cocos2d::Event*} */ ccTouchBegan : function () {}, @@ -444,7 +444,7 @@ setAdjustBackgroundImage : function () {}, /** * @method ccTouchEnded * @param {cocos2d::Touch*} - * @param {Event*} + * @param {cocos2d::Event*} */ ccTouchEnded : function () {}, @@ -552,7 +552,7 @@ setTitleLabel : function () {}, /** * @method ccTouchMoved * @param {cocos2d::Touch*} - * @param {Event*} + * @param {cocos2d::Event*} */ ccTouchMoved : function () {}, @@ -720,7 +720,7 @@ getTitleLabel : function () {}, /** * @method ccTouchCancelled * @param {cocos2d::Touch*} - * @param {Event*} + * @param {cocos2d::Event*} */ ccTouchCancelled : function () {}, @@ -1168,12 +1168,6 @@ getRootNode : function () {}, */ addDocumentOutletNode : function () {}, -/** - * @method setDelegate - * @param {cocos2d::extension::CCBAnimationManagerDelegate*} - */ -setDelegate : function () {}, - /** * @method addDocumentCallbackNode * @param {cocos2d::Node*} @@ -1187,12 +1181,6 @@ addDocumentCallbackNode : function () {}, */ setCallFunc : function () {}, -/** - * @method getDelegate - * @return A value converted from C/C++ "cocos2d::extension::CCBAnimationManagerDelegate*" - */ -getDelegate : function () {}, - /** * @method runAnimationsForSequenceNamed * @param {const char*} diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_manual.cpp b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_manual.cpp index bf2ff83e2c..0453bdb773 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_manual.cpp +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_manual.cpp @@ -87,7 +87,7 @@ static int tolua_cocos2d_MenuItemImage_create(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Follow_initWithTarget'.\n",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'tolua_cocos2d_MenuItemImage_create'.\n",&tolua_err); #endif return 0; @@ -123,6 +123,103 @@ static int tolua_cocos2d_MenuItemLabel_create(lua_State* tolua_S) return 1; } + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2d_MenuItemFont_create(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertable(tolua_S,1,"MenuItemFont",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + if(1 == argc) + { + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isstring(tolua_S, 2, 0, &tolua_err)) + { + goto tolua_lerror; + } +#endif + const char* value = ((const char*) tolua_tostring(tolua_S,2,0)); + MenuItemFont* tolua_ret = (MenuItemFont*) MenuItemFont::create(value); + 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,"MenuItemFont"); + return 1; + } + + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2d_MenuItemSprite_create(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertable(tolua_S,1,"MenuItemSprite",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if(argc >= 2 && argc <= 3) + { + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,2,"Node",0,&tolua_err) || + !tolua_isusertype(tolua_S,3,"Node",0,&tolua_err) ) + { + goto tolua_lerror; + } + + if (3 == argc && !tolua_isusertype(tolua_S,4,"Node",0,&tolua_err)) + { + goto tolua_lerror; + } +#endif + + Node* normalSprite = ((Node*) tolua_tousertype(tolua_S,2,0)); + Node* selectedSprite = ((Node*) tolua_tousertype(tolua_S,3,0)); + Node* disabledSprite = NULL; + if (3 == argc) + { + disabledSprite = (Node*) tolua_tousertype(tolua_S,4,0); + } + MenuItemSprite* tolua_ret = (MenuItemSprite*) MenuItemSprite::create(normalSprite,selectedSprite,disabledSprite); + 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,"MenuItemSprite"); + return 1; + } + + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 3); + return 0; + #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); @@ -154,7 +251,7 @@ static int tolua_cocos2d_Menu_create(lua_State* tolua_S) uint32_t i = 1; while (i <= argc) { - if (!tolua_isusertype(tolua_S, 1 + i, "Object", 0, &tolua_err)) + if (!tolua_isusertype(tolua_S, 1 + i, "MenuItem", 0, &tolua_err)) { goto tolua_lerror; return 0; @@ -180,7 +277,7 @@ static int tolua_cocos2d_Menu_create(lua_State* tolua_S) cocos2d::Menu* tolua_ret = cocos2d::Menu::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,"MenuItemImage"); + toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"Menu"); return 1; } @@ -189,7 +286,7 @@ static int tolua_cocos2d_Menu_create(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Follow_initWithTarget'.\n",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'tolua_cocos2d_Menu_create'.\n",&tolua_err); #endif return 0; } @@ -208,7 +305,7 @@ static int tolua_cocos2d_MenuItem_registerScriptTapHandler(lua_State* tolua_S) cobj = static_cast(tolua_tousertype(tolua_S,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'tolua_cocos2d_MenuItem_registerScriptTapHandler00'\n", NULL); + tolua_error(tolua_S,"invalid 'cobj' in function 'tolua_cocos2d_MenuItem_registerScriptTapHandler'\n", NULL); return 0; } #endif @@ -252,7 +349,7 @@ static int tolua_cocos2d_MenuItem_unregisterScriptTapHandler(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (nullptr == cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'tolua_cocos2d_MenuItem_unregisterScriptTapHandler00'\n", NULL); + tolua_error(tolua_S,"invalid 'cobj' in function 'tolua_cocos2d_MenuItem_unregisterScriptTapHandler'\n", NULL); return 0; } #endif @@ -397,6 +494,91 @@ tolua_lerror: #endif } +int tolua_cocos2d_Layer_registerScriptAccelerateHandler(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + Layer* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"Layer",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(tolua_S,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Layer_registerScriptAccelerateHandler'\n", NULL); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (1 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err)) { + goto tolua_lerror; + } +#endif + LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0)); + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, ScriptHandlerMgr::kAccelerometerHandler); + return 0; + } + + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1); + return 0; +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'registerScriptAccelerateHandler'.",&tolua_err); + return 0; +#endif +} + +int tolua_cocos2d_Layer_unregisterScriptAccelerateHandler(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + Layer* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"Layer",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(tolua_S,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Layer_unregisterScriptAccelerateHandler'\n", NULL); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (0 == argc) + { + ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)self, ScriptHandlerMgr::kAccelerometerHandler); + return 0; + } + + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'unregisterScriptAccelerateHandler'.",&tolua_err); + return 0; +#endif +} + static int tolua_cocos2d_Scheduler_scheduleScriptFunc(lua_State* tolua_S) { @@ -1036,10 +1218,148 @@ tolua_lerror: return 0; #endif } -//void lua_extend_cocos2dx_MenuItem -//{ -// -//} + +static int tolua_cocos2d_DrawNode_drawPolygon(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + DrawNode* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"DrawNode",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(tolua_S,1,0)); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_DrawNode_drawPolygon'\n", NULL); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + if (5 == argc) + { +#if COCOS2D_DEBUG >= 1 + if( + !tolua_istable(tolua_S, 2, 0, &tolua_err) || + !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || + !tolua_istable(tolua_S, 4, 0,&tolua_err) || + !tolua_isnumber(tolua_S, 5, 0, &tolua_err) || + !tolua_istable(tolua_S,6, 0,&tolua_err) ) + { + goto tolua_lerror; + } +#endif + size_t size = lua_tonumber(tolua_S, 3); + if ( size > 0 ) + { + Point* points = new Point[size]; + if (NULL == points) + return 0; + + for (int i = 0; i < size; i++) + { + lua_pushnumber(tolua_S,i + 1); + lua_gettable(tolua_S,2); + if (!tolua_istable(tolua_S,-1, 0, &tolua_err)) + { + CC_SAFE_DELETE_ARRAY(points); + goto tolua_lerror; + } + + if(!luaval_to_point(tolua_S, lua_gettop(tolua_S), &points[i])) + { + lua_pop(tolua_S, 1); + CC_SAFE_DELETE_ARRAY(points); + return 0; + } + lua_pop(tolua_S, 1); + } + + Color4F fillColor; + if (!luaval_to_color4f(tolua_S, 4, &fillColor)) + { + CC_SAFE_DELETE_ARRAY(points); + return 0; + } + + float borderWidth = (float)tolua_tonumber(tolua_S, 5, 0); + + Color4F borderColor; + if (!luaval_to_color4f(tolua_S, 6, &borderColor)) + { + CC_SAFE_DELETE_ARRAY(points); + return 0; + } + + self->drawPolygon(points, size, fillColor, borderWidth, borderColor); + CC_SAFE_DELETE_ARRAY(points); + return 0; + } + } + + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 5); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'drawPolygon'.",&tolua_err); + return 0; +#endif +} + +// setBlendFunc +template +static int tolua_cocos2dx_setBlendFunc(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + T* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +// if (!tolua_isusertype(tolua_S,1,typeid(T).name(),0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(tolua_S,1,0)); + + argc = lua_gettop(tolua_S) - 1; + if (2 == argc) + { + GLenum src, dst; + if (!luaval_to_int32(tolua_S, 2, (int32_t*)&src)) + return 0; + + if (!luaval_to_int32(tolua_S, 3, (int32_t*)&dst)) + return 0; + + BlendFunc blendFunc = {src, dst}; + self->setBlendFunc(blendFunc); + return 0; + } + + + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 2); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'setBlendFunc'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2dx_Sprite_setBlendFunc(lua_State* tolua_S) +{ + return tolua_cocos2dx_setBlendFunc(tolua_S); +} + int register_all_cocos2dx_manual(lua_State* tolua_S) { @@ -1076,6 +1396,24 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) lua_rawset(tolua_S,-3); } + lua_pushstring(tolua_S, "MenuItemFont"); + lua_rawget(tolua_S,LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"create"); + lua_pushcfunction(tolua_S,tolua_cocos2d_MenuItemFont_create); + lua_rawset(tolua_S,-3); + } + + lua_pushstring(tolua_S, "MenuItemSprite"); + lua_rawget(tolua_S,LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"create"); + lua_pushcfunction(tolua_S,tolua_cocos2d_MenuItemSprite_create); + lua_rawset(tolua_S,-3); + } + lua_pushstring(tolua_S, "Menu"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S, -1)) @@ -1105,7 +1443,7 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) lua_pushcfunction(tolua_S,tolua_cocos2d_Layer_registerScriptTouchHandler); lua_rawset(tolua_S,-3); lua_pushstring(tolua_S, "unregisterScriptTouchHandler"); - lua_pushcfunction(tolua_S,tolua_Cocos2d_unregisterScriptTouchHandler00); + lua_pushcfunction(tolua_S,tolua_cocos2d_Layer_unregisterScriptTouchHandler); lua_rawset(tolua_S, -3); // lua_pushstring(lua_S, "registerScriptKeypadHandler"); // lua_pushcfunction(lua_S, tolua_Cocos2d_registerScriptKeypadHandler00); @@ -1113,12 +1451,12 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) // lua_pushstring(lua_S, "unregisterScriptKeypadHandler"); // lua_pushcfunction(lua_S, tolua_Cocos2d_unregisterScriptKeypadHandler00); // lua_rawset(lua_S, -3); -// lua_pushstring(lua_S, "registerScriptAccelerateHandler"); -// lua_pushcfunction(lua_S, tolua_Cocos2d_registerScriptAccelerateHandler00); -// lua_rawset(lua_S, -3); -// lua_pushstring(lua_S, "unregisterScriptAccelerateHandler"); -// lua_pushcfunction(lua_S, tolua_Cocos2d_unregisterScriptAccelerateHandler00); -// lua_rawset(lua_S, -3); + lua_pushstring(tolua_S, "registerScriptAccelerateHandler"); + lua_pushcfunction(tolua_S, tolua_cocos2d_Layer_registerScriptAccelerateHandler); + lua_rawset(tolua_S, -3); + lua_pushstring(tolua_S, "unregisterScriptAccelerateHandler"); + lua_pushcfunction(tolua_S, tolua_cocos2d_Layer_unregisterScriptAccelerateHandler); + lua_rawset(tolua_S, -3); } lua_pushstring(tolua_S,"Scheduler"); @@ -1205,7 +1543,23 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) lua_rawset(tolua_S,-3); } + lua_pushstring(tolua_S,"DrawNode"); + lua_rawget(tolua_S,LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"drawPolygon"); + lua_pushcfunction(tolua_S,tolua_cocos2d_DrawNode_drawPolygon); + lua_rawset(tolua_S,-3); + } + + lua_pushstring(tolua_S,"Sprite"); + lua_rawget(tolua_S,LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"setBlendFunc"); + lua_pushcfunction(tolua_S,tolua_cocos2dx_Sprite_setBlendFunc); + lua_rawset(tolua_S,-3); + } - return 0; } \ No newline at end of file diff --git a/scripting/lua/script/AudioEngine.lua b/scripting/lua/script/AudioEngine.lua index 07bcccfb3a..cc5d20a8ee 100644 --- a/scripting/lua/script/AudioEngine.lua +++ b/scripting/lua/script/AudioEngine.lua @@ -1,17 +1,17 @@ --Encapsulate SimpleAudioEngine to AudioEngine,Play music and sound effects. local M = {} -local audioEngineInstance = SimpleAudioEngine:getInstance() +local audioEngineInstance = cc.SimpleAudioEngine:getInstance() function M.stopAllEffects() audioEngineInstance:stopAllEffects() end function M.getMusicVolume() - return audioEngineInstance:getBackgroundMusicVolume() + return audioEngineInstance:getMusicVolume() end function M.isMusicPlaying() - return audioEngineInstance:isBackgroundMusicPlaying() + return audioEngineInstance:isMusicPlaying() end function M.getEffectsVolume() @@ -19,7 +19,7 @@ function M.getEffectsVolume() end function M.setMusicVolume(volume) - audioEngineInstance:setBackgroundMusicVolume(volume) + audioEngineInstance:setMusicVolume(volume) end function M.stopEffect(handle) @@ -31,7 +31,7 @@ function M.stopMusic(isReleaseData) if nil ~= isReleaseData then releaseDataValue = isReleaseData end - audioEngineInstance:stopBackgroundMusic(releaseDataValue) + audioEngineInstance:stopMusic(releaseDataValue) end function M.playMusic(filename, isLoop) @@ -39,7 +39,7 @@ function M.playMusic(filename, isLoop) if nil ~= isLoop then loopValue = isLoop end - audioEngineInstance:playBackgroundMusic(filename, loopValue) + audioEngineInstance:playMusic(filename, loopValue) end function M.pauseAllEffects() @@ -47,11 +47,11 @@ function M.pauseAllEffects() end function M.preloadMusic(filename) - audioEngineInstance:preloadBackgroundMusic(filename) + audioEngineInstance:preloadMusic(filename) end function M.resumeMusic() - audioEngineInstance:resumeBackgroundMusic() + audioEngineInstance:resumeMusic() end function M.playEffect(filename, isLoop) @@ -63,11 +63,11 @@ function M.playEffect(filename, isLoop) end function M.rewindMusic() - audioEngineInstance:rewindBackgroundMusic() + audioEngineInstance:rewindMusic() end function M.willPlayMusic() - return audioEngineInstance:willPlayBackgroundMusic() + return audioEngineInstance:willPlayMusic() end function M.unloadEffect(filename) @@ -91,7 +91,7 @@ function M.resumeAllEffects(handle) end function M.pauseMusic() - audioEngineInstance:pauseBackgroundMusic() + audioEngineInstance:pauseMusic() end function M.resumeEffect(handle) diff --git a/scripting/lua/script/Cocos2d.lua b/scripting/lua/script/Cocos2d.lua index 98c1b8e5f8..ef62ea8274 100644 --- a/scripting/lua/script/Cocos2d.lua +++ b/scripting/lua/script/Cocos2d.lua @@ -1,5 +1,8 @@ cc = cc or {} +cc.DIRECTOR_PROJECTION_2D = 0 +cc.DIRECTOR_PROJECTION_3D = 1 + --Point function cc.p(_x,_y) return { x = _x, y = _y } @@ -25,4 +28,9 @@ function cc.c4b( _r,_g,_b,_a ) return { r = _r, g = _g, b = _b, a = _a } end +--Color4F +function cc.c4f( _r,_g,_b,_a ) + return { r = _r, g = _g, b = _b, a = _a } +end + diff --git a/tools/bindings-generator b/tools/bindings-generator index 93cd250dd0..cb7f610eae 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit 93cd250dd0cc9b3c0c20df12b7e76330895c9db3 +Subproject commit cb7f610eae8f638d1c2929c3e2fdecd29e506dad diff --git a/tools/tolua/cocos2dx.ini b/tools/tolua/cocos2dx.ini index 9c45b05008..1582f8ed0e 100644 --- a/tools/tolua/cocos2dx.ini +++ b/tools/tolua/cocos2dx.ini @@ -35,7 +35,7 @@ classes = Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* # will apply to all class names. This is a convenience wildcard to be able to skip similar named # functions from all classes. -skip = Node::[getGrid setGLServerState description getUserObject .*UserData getGLServerState .*schedule], +skip = Node::[setGLServerState description getUserObject .*UserData getGLServerState .*schedule], Sprite::[getQuad displayFrame getBlendFunc ^setPosition$ setBlendFunc setSpriteBatchNode getSpriteBatchNode], SpriteBatchNode::[getBlendFunc setBlendFunc], MotionStreak::[getBlendFunc setBlendFunc draw update], From 2d5482a0ab38b7f8cc46ac6221b7b04e7cb47149 Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Thu, 15 Aug 2013 16:14:14 +0800 Subject: [PATCH 020/126] issue #2433:Modify cocos2d.ini --- .../generated/lua_cocos2dx_auto.cpp.REMOVED.git-id | 2 +- .../lua_cocos2dx_extension_auto.cpp.REMOVED.git-id | 2 +- .../cocos2dx_support/generated/lua_cocos2dx_manual.cpp | 8 ++++---- tools/tolua/cocos2dx.ini | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id index 9b5885cf90..452cf41355 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id @@ -1 +1 @@ -fe22a58a97c6532a0d8b5c326cd683e108407b1e \ No newline at end of file +8115474f6f2838b3226e1075c612086088005bbd \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id index 5d9c096a15..170076ab1a 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id @@ -1 +1 @@ -55f9aed3fc28a46be61e0ddaa629a9503b54a1ac \ No newline at end of file +9febc607103481a54085d37c4779c1d04bcf457c \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_manual.cpp b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_manual.cpp index 0453bdb773..a56053b9d1 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_manual.cpp +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_manual.cpp @@ -1314,9 +1314,9 @@ tolua_lerror: // setBlendFunc template -static int tolua_cocos2dx_setBlendFunc(lua_State* tolua_S) +static int tolua_cocos2dx_setBlendFunc(lua_State* tolua_S,const char* className) { - if (NULL == tolua_S) + if (NULL == tolua_S || NULL == className || strlen(className) == 0) return 0; int argc = 0; @@ -1324,7 +1324,7 @@ static int tolua_cocos2dx_setBlendFunc(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; -// if (!tolua_isusertype(tolua_S,1,typeid(T).name(),0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,className,0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); @@ -1357,7 +1357,7 @@ tolua_lerror: static int tolua_cocos2dx_Sprite_setBlendFunc(lua_State* tolua_S) { - return tolua_cocos2dx_setBlendFunc(tolua_S); + return tolua_cocos2dx_setBlendFunc(tolua_S,"Sprite"); } diff --git a/tools/tolua/cocos2dx.ini b/tools/tolua/cocos2dx.ini index 1582f8ed0e..2200bd45c0 100644 --- a/tools/tolua/cocos2dx.ini +++ b/tools/tolua/cocos2dx.ini @@ -132,7 +132,7 @@ rename_classes = ParticleSystemQuad::ParticleSystem, remove_prefix = # classes for which there will be no "parent" lookup -classes_have_no_parents = Node Director SimpleAudioEngine FileUtils TMXMapInfo Application +classes_have_no_parents = Director SimpleAudioEngine FileUtils TMXMapInfo Application # base classes which will be skipped when their sub-classes found them. base_classes_to_skip = Clonable From 871ed24620ab0200c0ba2005dc44106583921416 Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Thu, 15 Aug 2013 16:51:09 +0800 Subject: [PATCH 021/126] issue #2433:Update submodule and project --- cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id | 2 +- tools/bindings-generator | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id b/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id index 9e007ea849..9b74a0f672 100644 --- a/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -1feddf59d7fbc2b063a496bbf4a4770d0ac4435e \ No newline at end of file +b00ee6aa7325a6bf73212ea843692e7a905e53e4 \ No newline at end of file diff --git a/tools/bindings-generator b/tools/bindings-generator index cb7f610eae..2a8d5c63d3 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit cb7f610eae8f638d1c2929c3e2fdecd29e506dad +Subproject commit 2a8d5c63d31a823ad2c2d4b7486117b4bb3ae86a From de3335a4a9bbee37c826b901afe8656d17573aec Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Fri, 16 Aug 2013 10:12:46 +0800 Subject: [PATCH 022/126] issue #2433:Update lua manual binding and modify some samples --- .../Resources/luaScript/FontTest/FontTest.lua | 54 +- .../luaScript/IntervalTest/IntervalTest.lua | 61 +- .../luaScript/KeypadTest/KeypadTest.lua | 14 +- .../luaScript/LabelTest/LabelTest.lua | 659 +++++++++--------- .../luaScript/LayerTest/LayerTest.lua | 492 ++++++------- .../TestLua/Resources/luaScript/mainMenu.lua | 11 +- .../lua_cocos2dx_auto.cpp.REMOVED.git-id | 2 +- .../generated/lua_cocos2dx_auto.hpp | 1 + .../lua_cocos2dx_auto_api.js.REMOVED.git-id | 2 +- ...cocos2dx_extension_auto.cpp.REMOVED.git-id | 2 +- .../generated/lua_cocos2dx_extension_auto.hpp | 2 + .../lua_cocos2dx_extension_auto_api.js | 14 + .../generated/lua_cocos2dx_manual.cpp | 279 +++++++- scripting/lua/script/Cocos2d.lua | 24 + 14 files changed, 913 insertions(+), 704 deletions(-) diff --git a/samples/Lua/TestLua/Resources/luaScript/FontTest/FontTest.lua b/samples/Lua/TestLua/Resources/luaScript/FontTest/FontTest.lua index 9628577d25..7ec20ed132 100644 --- a/samples/Lua/TestLua/Resources/luaScript/FontTest/FontTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/FontTest/FontTest.lua @@ -17,9 +17,9 @@ cclog("font count = "..fontCount) local vAlignIdx = 1 local verticalAlignment = { - kCCVerticalTextAlignmentTop, - kCCVerticalTextAlignmentCenter, - kCCVerticalTextAlignmentBottom, + cc.VERTICAL_TEXT_ALIGNMENT_TOP, + cc.VERTICAL_TEXT_ALIGNMENT_CENTER, + cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM, } local vAlignCount = table.getn(verticalAlignment) @@ -27,9 +27,9 @@ local vAlignCount = table.getn(verticalAlignment) local function showFont(ret, pFont) cclog("vAlignIdx="..vAlignIdx) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local blockSize = CCSize(s.width/3, 200) + local blockSize = cc.size(s.width/3, 200) local fontSize = 26 ret:removeChildByTag(kTagLabel1, true) @@ -37,36 +37,36 @@ local function showFont(ret, pFont) ret:removeChildByTag(kTagLabel3, true) ret:removeChildByTag(kTagLabel4, true) - local top = CCLabelTTF:create(pFont, pFont, 24) - local left = CCLabelTTF:create("alignment left", pFont, fontSize, - blockSize, kCCTextAlignmentLeft, verticalAlignment[vAlignIdx]) - local center = CCLabelTTF:create("alignment center", pFont, fontSize, - blockSize, kCCTextAlignmentCenter, verticalAlignment[vAlignIdx]) - local right = CCLabelTTF:create("alignment right", pFont, fontSize, - blockSize, kCCTextAlignmentRight, verticalAlignment[vAlignIdx]) + local top = cc.LabelTTF:create(pFont, pFont, 24) + local left = cc.LabelTTF:create("alignment left", pFont, fontSize, + blockSize, cc.TEXT_ALIGNMENT_LEFT, verticalAlignment[vAlignIdx]) + local center = cc.LabelTTF:create("alignment center", pFont, fontSize, + blockSize, cc.TEXT_ALIGNMENT_CENTER, verticalAlignment[vAlignIdx]) + local right = cc.LabelTTF:create("alignment right", pFont, fontSize, + blockSize, cc.TEXT_ALIGNMENT_RIGHT, verticalAlignment[vAlignIdx]) - local leftColor = CCLayerColor:create(Color4B(100, 100, 100, 255), blockSize.width, blockSize.height) - local centerColor = CCLayerColor:create(Color4B(200, 100, 100, 255), blockSize.width, blockSize.height) - local rightColor = CCLayerColor:create(Color4B(100, 100, 200, 255), blockSize.width, blockSize.height) + local leftColor = cc.LayerColor:create(cc.c4b(100, 100, 100, 255), blockSize.width, blockSize.height) + local centerColor = cc.LayerColor:create(cc.c4b(200, 100, 100, 255), blockSize.width, blockSize.height) + local rightColor = cc.LayerColor:create(cc.c4b(100, 100, 200, 255), blockSize.width, blockSize.height) leftColor:ignoreAnchorPointForPosition(false) centerColor:ignoreAnchorPointForPosition(false) rightColor:ignoreAnchorPointForPosition(false) - top:setAnchorPoint(CCPoint(0.5, 1)) - left:setAnchorPoint(CCPoint(0,0.5)) - leftColor:setAnchorPoint(CCPoint(0,0.5)) - center:setAnchorPoint(CCPoint(0,0.5)) - centerColor:setAnchorPoint(CCPoint(0,0.5)) - right:setAnchorPoint(CCPoint(0,0.5)) - rightColor:setAnchorPoint(CCPoint(0,0.5)) + top:setAnchorPoint(cc.p(0.5, 1)) + left:setAnchorPoint(cc.p(0,0.5)) + leftColor:setAnchorPoint(cc.p(0,0.5)) + center:setAnchorPoint(cc.p(0,0.5)) + centerColor:setAnchorPoint(cc.p(0,0.5)) + right:setAnchorPoint(cc.p(0,0.5)) + rightColor:setAnchorPoint(cc.p(0,0.5)) - top:setPosition(CCPoint(s.width/2,s.height-20)) - left:setPosition(CCPoint(0,s.height/2)) + top:setPosition(cc.p(s.width/2,s.height-20)) + left:setPosition(cc.p(0,s.height/2)) leftColor:setPosition(left:getPosition()) - center:setPosition(CCPoint(blockSize.width, s.height/2)) + center:setPosition(cc.p(blockSize.width, s.height/2)) centerColor:setPosition(center:getPosition()) - right:setPosition(CCPoint(blockSize.width*2, s.height/2)) + right:setPosition(cc.p(blockSize.width*2, s.height/2)) rightColor:setPosition(right:getPosition()) ret:addChild(leftColor, -1) @@ -98,7 +98,7 @@ function FontTestMain() cclog("FontTestMain") Helper.index = 1 vAlignIdx = 1 - local scene = CCScene:create() + local scene = cc.Scene:create() Helper.createFunctionTable = { createTestLayer, createTestLayer, diff --git a/samples/Lua/TestLua/Resources/luaScript/IntervalTest/IntervalTest.lua b/samples/Lua/TestLua/Resources/luaScript/IntervalTest/IntervalTest.lua index 1011f0da0c..37fa74c9f3 100644 --- a/samples/Lua/TestLua/Resources/luaScript/IntervalTest/IntervalTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/IntervalTest/IntervalTest.lua @@ -1,33 +1,33 @@ -local scheduler = CCDirector:getInstance():getScheduler() +local scheduler = cc.Director:getInstance():getScheduler() local SID_STEP1 = 100 local SID_STEP2 = 101 local SID_STEP3 = 102 local IDC_PAUSE = 200 local function IntervalLayer() - local ret = CCLayer:create() + local ret = cc.Layer:create() local m_time0 = 0 local m_time1 = 0 local m_time2 = 0 local m_time3 = 0 local m_time4 = 0 - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() -- sun - local sun = CCParticleSun:create() - sun:setTexture(CCTextureCache:getInstance():addImage("Images/fire.png")) - sun:setPosition( CCPoint(VisibleRect:rightTop().x-32,VisibleRect:rightTop().y-32) ) + local sun = cc.ParticleSun:create() + sun:setTexture(cc.TextureCache:getInstance():addImage("Images/fire.png")) + sun:setPosition( cc.p(VisibleRect:rightTop().x-32,VisibleRect:rightTop().y-32) ) sun:setTotalParticles(130) sun:setLife(0.6) ret:addChild(sun) -- timers - m_label0 = CCLabelBMFont:create("0", "fonts/bitmapFontTest4.fnt") - m_label1 = CCLabelBMFont:create("0", "fonts/bitmapFontTest4.fnt") - m_label2 = CCLabelBMFont:create("0", "fonts/bitmapFontTest4.fnt") - m_label3 = CCLabelBMFont:create("0", "fonts/bitmapFontTest4.fnt") - m_label4 = CCLabelBMFont:create("0", "fonts/bitmapFontTest4.fnt") + m_label0 = cc.LabelBMFont:create("0", "fonts/bitmapFontTest4.fnt") + m_label1 = cc.LabelBMFont:create("0", "fonts/bitmapFontTest4.fnt") + m_label2 = cc.LabelBMFont:create("0", "fonts/bitmapFontTest4.fnt") + m_label3 = cc.LabelBMFont:create("0", "fonts/bitmapFontTest4.fnt") + m_label4 = cc.LabelBMFont:create("0", "fonts/bitmapFontTest4.fnt") local function update(dt) m_time0 = m_time0 + dt @@ -77,8 +77,8 @@ local function IntervalLayer() scheduler:unscheduleScriptEntry(schedulerEntry2) scheduler:unscheduleScriptEntry(schedulerEntry3) scheduler:unscheduleScriptEntry(schedulerEntry4) - if CCDirector:getInstance():isPaused() then - CCDirector:getInstance():resume() + if cc.Director:getInstance():isPaused() then + cc.Director:getInstance():resume() end end end @@ -86,11 +86,11 @@ local function IntervalLayer() ret:registerScriptHandler(onNodeEvent) - m_label0:setPosition(CCPoint(s.width*1/6, s.height/2)) - m_label1:setPosition(CCPoint(s.width*2/6, s.height/2)) - m_label2:setPosition(CCPoint(s.width*3/6, s.height/2)) - m_label3:setPosition(CCPoint(s.width*4/6, s.height/2)) - m_label4:setPosition(CCPoint(s.width*5/6, s.height/2)) + m_label0:setPosition(cc.p(s.width*1/6, s.height/2)) + m_label1:setPosition(cc.p(s.width*2/6, s.height/2)) + m_label2:setPosition(cc.p(s.width*3/6, s.height/2)) + m_label3:setPosition(cc.p(s.width*4/6, s.height/2)) + m_label4:setPosition(cc.p(s.width*5/6, s.height/2)) ret:addChild(m_label0) ret:addChild(m_label1) @@ -99,29 +99,26 @@ local function IntervalLayer() ret:addChild(m_label4) -- Sprite - local sprite = CCSprite:create(s_pPathGrossini) - sprite:setPosition( CCPoint(VisibleRect:left().x + 40, VisibleRect:bottom().y + 50) ) + local sprite = cc.Sprite:create(s_pPathGrossini) + sprite:setPosition( cc.p(VisibleRect:left().x + 40, VisibleRect:bottom().y + 50) ) - local jump = CCJumpBy:create(3, CCPoint(s.width-80,0), 50, 4) + local jump = cc.JumpBy:create(3, cc.p(s.width-80,0), 50, 4) ret:addChild(sprite) - local arr = CCArray:create() - arr:addObject(jump) - arr:addObject(jump:reverse()) - sprite:runAction( CCRepeatForever:create(CCSequence:create(arr))) + sprite:runAction( cc.RepeatForever:create(cc.Sequence:create(jump, jump:reverse()))) -- pause button - local item1 = CCMenuItemFont:create("Pause") + local item1 = cc.MenuItemFont:create("Pause") local function onPause(tag, pSender) - if CCDirector:getInstance():isPaused() then - CCDirector:getInstance():resume() + if cc.Director:getInstance():isPaused() then + cc.Director:getInstance():resume() else - CCDirector:getInstance():pause() + cc.Director:getInstance():pause() end end item1:registerScriptTapHandler(onPause) - local menu = CCMenu:createWithItem(item1) - menu:setPosition( CCPoint(s.width/2, s.height-50) ) + local menu = cc.Menu:create(item1) + menu:setPosition( cc.p(s.width/2, s.height-50) ) ret:addChild( menu ) @@ -131,7 +128,7 @@ end function IntervalTestMain() cclog("IntervalTestMain") - local scene = CCScene:create() + local scene = cc.Scene:create() local layer = IntervalLayer() scene:addChild(layer, 0) scene:addChild(CreateBackMenuItem()) diff --git a/samples/Lua/TestLua/Resources/luaScript/KeypadTest/KeypadTest.lua b/samples/Lua/TestLua/Resources/luaScript/KeypadTest/KeypadTest.lua index 64ad3cf358..9771efe28e 100644 --- a/samples/Lua/TestLua/Resources/luaScript/KeypadTest/KeypadTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/KeypadTest/KeypadTest.lua @@ -1,16 +1,16 @@ local function KeypadMainLayer() - local pLayer = CCLayer:create() + local pLayer = cc.Layer:create() - local s = CCDirector:getInstance():getWinSize() - local label = CCLabelTTF:create("Keypad Test", "Arial", 28) + local s = cc.Director:getInstance():getWinSize() + local label = cc.LabelTTF:create("Keypad Test", "Arial", 28) pLayer:addChild(label, 0) - label:setPosition( CCPoint(s.width/2, s.height-50) ) + label:setPosition( cc.p(s.width/2, s.height-50) ) pLayer:setKeypadEnabled(true) -- create a label to display the tip string - local pLabelTip = CCLabelTTF:create("Please press any key...", "Arial", 22) - pLabelTip:setPosition(CCPoint(s.width / 2, s.height / 2)) + local pLabelTip = cc.LabelTTF:create("Please press any key...", "Arial", 22) + pLabelTip:setPosition(cc.p(s.width / 2, s.height / 2)) pLayer:addChild(pLabelTip, 0) pLabelTip:retain() @@ -31,7 +31,7 @@ end function KeypadTestMain() cclog("KeypadTestMain") - local scene = CCScene:create() + local scene = cc.Scene:create() scene:addChild(KeypadMainLayer()) scene:addChild(CreateBackMenuItem()) return scene diff --git a/samples/Lua/TestLua/Resources/luaScript/LabelTest/LabelTest.lua b/samples/Lua/TestLua/Resources/luaScript/LabelTest/LabelTest.lua index 63707baeb8..21a54ec163 100644 --- a/samples/Lua/TestLua/Resources/luaScript/LabelTest/LabelTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/LabelTest/LabelTest.lua @@ -1,5 +1,5 @@ -local size = CCDirector:getInstance():getWinSize() -local scheduler = CCDirector:getInstance():getScheduler() +local size = cc.Director:getInstance():getWinSize() +local scheduler = cc.Director:getInstance():getScheduler() local kTagTileMap = 1 local kTagSpriteManager = 1 @@ -32,11 +32,11 @@ function LabelAtlasTest.step(dt) local string = string.format("%2.2f Test", m_time) local label1_origin = LabelAtlasTest.layer:getChildByTag(kTagSprite1) - local label1 = tolua.cast(label1_origin, "CCLabelAtlas") + local label1 = tolua.cast(label1_origin, "LabelAtlas") label1:setString(string) -- local label2_origin = LabelAtlasTest.layer:getChildByTag(kTagSprite2) - local label2 = tolua.cast(label2_origin, "CCLabelAtlas") + local label2 = tolua.cast(label2_origin, "LabelAtlas") string = string.format("%d", m_time) label2:setString(string) @@ -50,18 +50,18 @@ end function LabelAtlasTest.create() m_time = 0 - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) LabelAtlasTest.layer = layer - local label1 = CCLabelAtlas:create("123 Test", "fonts/tuffy_bold_italic-charmap.plist") + local label1 = cc.LabelAtlas:_create("123 Test", "fonts/tuffy_bold_italic-charmap.plist") layer:addChild(label1, 0, kTagSprite1) - label1:setPosition( CCPoint(10,100) ) + label1:setPosition( cc.p(10,100) ) label1:setOpacity( 200 ) - local label2 = CCLabelAtlas:create("0123456789", "fonts/tuffy_bold_italic-charmap.plist") + local label2 = cc.LabelAtlas:_create("0123456789", "fonts/tuffy_bold_italic-charmap.plist") layer:addChild(label2, 0, kTagSprite2) - label2:setPosition( CCPoint(10,200) ) + label2:setPosition( cc.p(10,200) ) label2:setOpacity( 32 ) layer:scheduleUpdateWithPriorityLua(LabelAtlasTest.step, 0) @@ -88,11 +88,11 @@ function LabelAtlasColorTest.step(dt) m_time = m_time + dt local string = string.format("%2.2f Test", m_time) local label1_origin = LabelAtlasColorTest.layer:getChildByTag(kTagSprite1) - local label1 = tolua.cast(label1_origin, "CCLabelAtlas") + local label1 = tolua.cast(label1_origin, "LabelAtlas") label1:setString(string) local label2_origin = LabelAtlasColorTest.layer:getChildByTag(kTagSprite2) - local label2 = tolua.cast(label2_origin, "CCLabelAtlas") + local label2 = tolua.cast(label2_origin, "LabelAtlas") string = string.format("%d", m_time) label2:setString(string) @@ -111,31 +111,27 @@ end function LabelAtlasColorTest.create() m_time = 0 - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) LabelAtlasColorTest.layer = layer - local label1 = CCLabelAtlas:create("123 Test", "fonts/tuffy_bold_italic-charmap.plist") + local label1 = cc.LabelAtlas:_create("123 Test", "fonts/tuffy_bold_italic-charmap.plist") layer:addChild(label1, 0, kTagSprite1) - label1:setPosition( CCPoint(10,100) ) + label1:setPosition( cc.p(10,100) ) label1:setOpacity( 200 ) - local label2 = CCLabelAtlas:create("0123456789", "fonts/tuffy_bold_italic-charmap.plist") + local label2 = cc.LabelAtlas:_create("0123456789", "fonts/tuffy_bold_italic-charmap.plist") layer:addChild(label2, 0, kTagSprite2) - label2:setPosition( CCPoint(10,200) ) - label2:setColor(Color3B(255, 0, 0)) + label2:setPosition( cc.p(10,200) ) + label2:setColor(cc.c3b(255, 0, 0)) - local fade = CCFadeOut:create(1.0) + local fade = cc.FadeOut:create(1.0) local fade_in = fade:reverse() - local cb = CCCallFunc:create(LabelAtlasColorTest.actionFinishCallback) - local actionArr = CCArray:create() - actionArr:addObject(fade) - actionArr:addObject(fade_in) - actionArr:addObject(cb) + local cb = cc.CallFunc:create(LabelAtlasColorTest.actionFinishCallback) - local seq = CCSequence:create(actionArr) - local repeatAction = CCRepeatForever:create( seq ) + local seq = cc.Sequence:create(fade, fade_in, cb) + local repeatAction = cc.RepeatForever:create( seq ) label2:runAction( repeatAction ) layer:registerScriptHandler(LabelAtlasColorTest.onNodeEvent) @@ -170,47 +166,44 @@ end function Atlas3.create() cclog("Atlas3.create") - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) Atlas3.layer = layer m_time = 0 - local col = CCLayerColor:create( Color4B(128,128,128,255) ) + local col = cc.LayerColor:create( cc.c4b(128,128,128,255) ) layer:addChild(col, -10) - local label1 = CCLabelBMFont:create("Test", "fonts/bitmapFontTest2.fnt") + local label1 = cc.LabelBMFont:create("Test", "fonts/bitmapFontTest2.fnt") -- testing anchors - label1:setAnchorPoint( CCPoint(0,0) ) + label1:setAnchorPoint( cc.p(0,0) ) layer:addChild(label1, 0, kTagBitmapAtlas1) - local fade = CCFadeOut:create(1.0) + local fade = cc.FadeOut:create(1.0) local fade_in = fade:reverse() - local actionArr = CCArray:create() - actionArr:addObject(fade) - actionArr:addObject(fade_in) - local seq = CCSequence:create(actionArr) - local repeatAction = CCRepeatForever:create(seq) + local seq = cc.Sequence:create(fade,fade_in) + local repeatAction = cc.RepeatForever:create(seq) label1:runAction(repeatAction) --VERY IMPORTANT --color and opacity work OK because bitmapFontAltas2 loads a BMP image (not a PNG image) --If you want to use both opacity and color, it is recommended to use NON premultiplied images like BMP images --Of course, you can also tell XCode not to compress PNG images, but I think it doesn't work as expected - local label2 = CCLabelBMFont:create("Test", "fonts/bitmapFontTest2.fnt") + local label2 = cc.LabelBMFont:create("Test", "fonts/bitmapFontTest2.fnt") -- testing anchors - label2:setAnchorPoint( CCPoint(0.5, 0.5) ) - label2:setColor(Color3B(255, 0, 0 )) + label2:setAnchorPoint( cc.p(0.5, 0.5) ) + label2:setColor(cc.c3b(255, 0, 0 )) layer:addChild(label2, 0, kTagBitmapAtlas2) - label2:runAction( tolua.cast(repeatAction:clone(), "CCAction") ) + label2:runAction( tolua.cast(repeatAction:clone(), "Action") ) - local label3 = CCLabelBMFont:create("Test", "fonts/bitmapFontTest2.fnt") + local label3 = cc.LabelBMFont:create("Test", "fonts/bitmapFontTest2.fnt") -- testing anchors - label3:setAnchorPoint( CCPoint(1,1) ) + label3:setAnchorPoint( cc.p(1,1) ) layer:addChild(label3, 0, kTagBitmapAtlas3) label1:setPosition( VisibleRect:leftBottom() ) @@ -220,7 +213,7 @@ function Atlas3.create() layer:registerScriptHandler(Atlas3.onNodeEvent) layer:scheduleUpdateWithPriorityLua(Atlas3.step, 0) - Helper.titleLabel:setString( "CCLabelBMFont" ) + Helper.titleLabel:setString( "LabelBMFont" ) Helper.subtitleLabel:setString( "Testing alignment. Testing opacity + tint" ) return layer @@ -230,13 +223,13 @@ function Atlas3.step(dt) m_time = m_time + dt local string = string.format("%2.2f Test j", m_time) - local label1 = tolua.cast(Atlas3.layer:getChildByTag(kTagBitmapAtlas1), "CCLabelBMFont") + local label1 = tolua.cast(Atlas3.layer:getChildByTag(kTagBitmapAtlas1), "LabelBMFont") label1:setString(string) - local label2 = tolua.cast(Atlas3.layer:getChildByTag(kTagBitmapAtlas2), "CCLabelBMFont") + local label2 = tolua.cast(Atlas3.layer:getChildByTag(kTagBitmapAtlas2), "LabelBMFont") label2:setString(string) - local label3 = tolua.cast(Atlas3.layer:getChildByTag(kTagBitmapAtlas3), "CCLabelBMFont") + local label3 = tolua.cast(Atlas3.layer:getChildByTag(kTagBitmapAtlas3), "LabelBMFont") label3:setString(string) end @@ -267,18 +260,18 @@ end function Atlas4.create() cclog("Atlas4.create") m_time = 0 - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) Atlas4.layer = layer -- Upper Label - local label = CCLabelBMFont:create("Bitmap Font Atlas", "fonts/bitmapFontTest.fnt") + local label = cc.LabelBMFont:create("Bitmap Font Atlas", "fonts/bitmapFontTest.fnt") layer:addChild(label) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - label:setPosition( CCPoint(s.width/2, s.height/2) ) - label:setAnchorPoint( CCPoint(0.5, 0.5) ) + label:setPosition( cc.p(s.width/2, s.height/2) ) + label:setAnchorPoint( cc.p(0.5, 0.5) ) local BChar = label:getChildByTag(0) @@ -286,29 +279,23 @@ function Atlas4.create() local AChar = label:getChildByTag(12) - local rotate = CCRotateBy:create(2, 360) - local rot_4ever = CCRepeatForever:create(rotate) + local rotate = cc.RotateBy:create(2, 360) + local rot_4ever = cc.RepeatForever:create(rotate) - local scale = CCScaleBy:create(2, 1.5) + local scale = cc.ScaleBy:create(2, 1.5) local scale_back = scale:reverse() - local action_arr = CCArray:create() - action_arr:addObject(scale) - action_arr:addObject(scale_back) - local scale_seq = CCSequence:create(action_arr) - local scale_4ever = CCRepeatForever:create(scale_seq) + local scale_seq = cc.Sequence:create(scale, scale_back) + local scale_4ever = cc.RepeatForever:create(scale_seq) - local jump = CCJumpBy:create(0.5, CCPoint(0, 0), 60, 1) - local jump_4ever = CCRepeatForever:create(jump) + local jump = cc.JumpBy:create(0.5, cc.p(0, 0), 60, 1) + local jump_4ever = cc.RepeatForever:create(jump) - local fade_out = CCFadeOut:create(1) - local fade_in = CCFadeIn:create(1) + local fade_out = cc.FadeOut:create(1) + local fade_in = cc.FadeIn:create(1) - local action_arr2 = CCArray:create() - action_arr2:addObject(fade_out) - action_arr2:addObject(fade_in) - local seq = CCSequence:create(action_arr2) - local fade_4ever = CCRepeatForever:create(seq) + local seq = cc.Sequence:create(fade_out, fade_in) + local fade_4ever = cc.RepeatForever:create(seq) BChar:runAction(rot_4ever) BChar:runAction(scale_4ever) @@ -317,24 +304,24 @@ function Atlas4.create() -- Bottom Label - local label2 = CCLabelBMFont:create("00.0", "fonts/bitmapFontTest.fnt") + local label2 = cc.LabelBMFont:create("00.0", "fonts/bitmapFontTest.fnt") layer:addChild(label2, 0, kTagBitmapAtlas2) - label2:setPosition( CCPoint(s.width/2.0, 80) ) + label2:setPosition( cc.p(s.width/2.0, 80) ) local lastChar = label2:getChildByTag(3) - lastChar:runAction(tolua.cast( rot_4ever:clone(), "CCAction" )) + lastChar:runAction(tolua.cast( rot_4ever:clone(), "Action" )) layer:registerScriptHandler(Atlas4.onNodeEvent) - Helper.titleLabel:setString("CCLabelBMFont") - Helper.subtitleLabel:setString( "Using fonts as CCSprite objects. Some characters should rotate.") + Helper.titleLabel:setString("LabelBMFont") + Helper.subtitleLabel:setString( "Using fonts as cc.Sprite objects. Some characters should rotate.") return layer end function Atlas4.draw() - local s = CCDirector:getInstance():getWinSize() - CCDrawPrimitives.ccDrawLine( CCPoint(0, s.height/2), CCPoint(s.width, s.height/2) ) - CCDrawPrimitives.ccDrawLine( CCPoint(s.width/2, 0), CCPoint(s.width/2, s.height) ) + local s = cc.Director:getInstance():getWinSize() + cc.DrawPrimitives.ccDrawLine( cc.p(0, s.height/2), cc.p(s.width, s.height/2) ) + cc.DrawPrimitives.ccDrawLine( cc.p(s.width/2, 0), cc.p(s.width/2, s.height) ) end function Atlas4.step(dt) @@ -342,7 +329,7 @@ function Atlas4.step(dt) local string = string.format("%04.1f", m_time) - local label1 = tolua.cast(Atlas4.layer:getChildByTag(kTagBitmapAtlas2), "CCLabelBMFont") + local label1 = tolua.cast(Atlas4.layer:getChildByTag(kTagBitmapAtlas2), "LabelBMFont") label1:setString(string) end @@ -362,19 +349,19 @@ end local Atlas5 = {} Atlas5.layer = nil function Atlas5:create() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) Atlas5.layer = layer - local label = CCLabelBMFont:create("abcdefg", "fonts/bitmapFontTest4.fnt") + local label = cc.LabelBMFont:create("abcdefg", "fonts/bitmapFontTest4.fnt") layer:addChild(label) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - label:setPosition( CCPoint(s.width/2, s.height/2) ) - label:setAnchorPoint( CCPoint(0.5, 0.5) ) + label:setPosition( cc.p(s.width/2, s.height/2) ) + label:setAnchorPoint( cc.p(0.5, 0.5) ) - Helper.titleLabel:setString("CCLabelBMFont") + Helper.titleLabel:setString("LabelBMFont") Helper.subtitleLabel:setString("Testing padding") return layer end @@ -395,27 +382,27 @@ Atlas6.layer = nil function Atlas6:create() cclog("Atlas6:create") - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) Atlas6.layer = layer - local s = CCDirector:getInstance():getWinSize() - local label = CCLabelBMFont:create("FaFeFiFoFu", "fonts/bitmapFontTest5.fnt") + local s = cc.Director:getInstance():getWinSize() + local label = cc.LabelBMFont:create("FaFeFiFoFu", "fonts/bitmapFontTest5.fnt") layer:addChild(label) - label:setPosition( CCPoint(s.width/2, s.height/2+50) ) - label:setAnchorPoint( CCPoint(0.5, 0.5) ) + label:setPosition( cc.p(s.width/2, s.height/2+50) ) + label:setAnchorPoint( cc.p(0.5, 0.5) ) - label = CCLabelBMFont:create("fafefifofu", "fonts/bitmapFontTest5.fnt") + label = cc.LabelBMFont:create("fafefifofu", "fonts/bitmapFontTest5.fnt") layer:addChild(label) - label:setPosition( CCPoint(s.width/2, s.height/2) ) - label:setAnchorPoint( CCPoint(0.5, 0.5) ) + label:setPosition( cc.p(s.width/2, s.height/2) ) + label:setAnchorPoint( cc.p(0.5, 0.5) ) - label = CCLabelBMFont:create("aeiou", "fonts/bitmapFontTest5.fnt") + label = cc.LabelBMFont:create("aeiou", "fonts/bitmapFontTest5.fnt") layer:addChild(label) - label:setPosition( CCPoint(s.width/2, s.height/2-50) ) - label:setAnchorPoint( CCPoint(0.5, 0.5) ) + label:setPosition( cc.p(s.width/2, s.height/2-50) ) + label:setAnchorPoint( cc.p(0.5, 0.5) ) - Helper.titleLabel:setString("CCLabelBMFont") + Helper.titleLabel:setString("LabelBMFont") Helper.subtitleLabel:setString("Rendering should be OK. Testing offset") return layer end @@ -433,32 +420,32 @@ end -------------------------------------------------------------------- local AtlasBitmapColor = { layer= nil } function AtlasBitmapColor:create() - local layer = CCLayer:create() + local layer = cc.Layer:create() AtlasBitmapColor.layer = layer Helper.initWithLayer(layer) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local label = CCLabelBMFont:create("Blue", "fonts/bitmapFontTest5.fnt") - label:setColor( Color3B(0, 0, 255 )) + local label = cc.LabelBMFont:create("Blue", "fonts/bitmapFontTest5.fnt") + label:setColor( cc.c3b(0, 0, 255 )) layer:addChild(label) - label:setPosition( CCPoint(s.width/2, s.height/4) ) - label:setAnchorPoint( CCPoint(0.5, 0.5) ) + label:setPosition( cc.p(s.width/2, s.height/4) ) + label:setAnchorPoint( cc.p(0.5, 0.5) ) - label = CCLabelBMFont:create("Red", "fonts/bitmapFontTest5.fnt") + label = cc.LabelBMFont:create("Red", "fonts/bitmapFontTest5.fnt") layer:addChild(label) - label:setPosition( CCPoint(s.width/2, 2*s.height/4) ) - label:setAnchorPoint( CCPoint(0.5, 0.5) ) - label:setColor( Color3B(255, 0, 0) ) + label:setPosition( cc.p(s.width/2, 2*s.height/4) ) + label:setAnchorPoint( cc.p(0.5, 0.5) ) + label:setColor( cc.c3b(255, 0, 0) ) - label = CCLabelBMFont:create("G", "fonts/bitmapFontTest5.fnt") + label = cc.LabelBMFont:create("G", "fonts/bitmapFontTest5.fnt") layer:addChild(label) - label:setPosition( CCPoint(s.width/2, 3*s.height/4) ) - label:setAnchorPoint( CCPoint(0.5, 0.5) ) - label:setColor( Color3B(0, 255, 0 )) + label:setPosition( cc.p(s.width/2, 3*s.height/4) ) + label:setAnchorPoint( cc.p(0.5, 0.5) ) + label:setColor( cc.c3b(0, 255, 0 )) label:setString("Green") - Helper.titleLabel:setString("CCLabelBMFont") + Helper.titleLabel:setString("LabelBMFont") Helper.subtitleLabel:setString("Testing color") return layer end @@ -477,7 +464,7 @@ end local AtlasFastBitmap = { layer = nil } function AtlasFastBitmap:create() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) AtlasFastBitmap.layer = layer @@ -486,18 +473,18 @@ function AtlasFastBitmap:create() local i = 0 for i = 0, 100, 1 do local str = string.format("-%d-", i) - local label = CCLabelBMFont:create(str, "fonts/bitmapFontTest.fnt") + local label = cc.LabelBMFont:create(str, "fonts/bitmapFontTest.fnt") layer:addChild(label) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local p = CCPoint( math.random() * s.width, math.random() * s.height) + local p = cc.p( math.random() * s.width, math.random() * s.height) label:setPosition( p ) - label:setAnchorPoint(CCPoint(0.5, 0.5)) + label:setAnchorPoint(cc.p(0.5, 0.5)) end - Helper.titleLabel:setString("CCLabelBMFont") - Helper.subtitleLabel:setString("Creating several CCLabelBMFont with the same .fnt file should be fast") + Helper.titleLabel:setString("LabelBMFont") + Helper.subtitleLabel:setString("Creating several cc.LabelBMFont with the same .fnt file should be fast") return layer end @@ -515,13 +502,13 @@ end local BitmapFontMultiLine = {} function BitmapFontMultiLine:create() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) local s = nil -- Left - local label1 = CCLabelBMFont:create(" Multi line\nLeft", "fonts/bitmapFontTest3.fnt") - label1:setAnchorPoint(CCPoint(0,0)) + local label1 = cc.LabelBMFont:create(" Multi line\nLeft", "fonts/bitmapFontTest3.fnt") + label1:setAnchorPoint(cc.p(0,0)) layer:addChild(label1, 0, kTagBitmapAtlas1) s = label1:getContentSize() @@ -529,16 +516,16 @@ function BitmapFontMultiLine:create() -- Center - local label2 = CCLabelBMFont:create("Multi line\nCenter", "fonts/bitmapFontTest3.fnt") - label2:setAnchorPoint(CCPoint(0.5, 0.5)) + local label2 = cc.LabelBMFont:create("Multi line\nCenter", "fonts/bitmapFontTest3.fnt") + label2:setAnchorPoint(cc.p(0.5, 0.5)) layer:addChild(label2, 0, kTagBitmapAtlas2) s= label2:getContentSize() cclog("content size: %.2fx%.2f", s.width, s.height) -- right - local label3 = CCLabelBMFont:create("Multi line\nRight\nThree lines Three", "fonts/bitmapFontTest3.fnt") - label3:setAnchorPoint(CCPoint(1, 1)) + local label3 = cc.LabelBMFont:create("Multi line\nRight\nThree lines Three", "fonts/bitmapFontTest3.fnt") + label3:setAnchorPoint(cc.p(1, 1)) layer:addChild(label3, 0, kTagBitmapAtlas3) s = label3:getContentSize() @@ -547,7 +534,7 @@ function BitmapFontMultiLine:create() label1:setPosition(VisibleRect:leftBottom()) label2:setPosition(VisibleRect:center()) label3:setPosition(VisibleRect:rightTop()) - Helper.titleLabel:setString("CCLabelBMFont") + Helper.titleLabel:setString("LabelBMFont") Helper.subtitleLabel:setString("Multiline + anchor point") return layer end @@ -575,26 +562,26 @@ end function LabelsEmpty.create() cclog("LabelsEmpty.create") - local layer = CCLayer:create() + local layer = cc.Layer:create() LabelsEmpty.layer = layer Helper.initWithLayer(layer) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - -- CCLabelBMFont - local label1 = CCLabelBMFont:create("", "fonts/bitmapFontTest3.fnt") + -- cc.LabelBMFont + local label1 = cc.LabelBMFont:create("", "fonts/bitmapFontTest3.fnt") layer:addChild(label1, 0, kTagBitmapAtlas1) - label1:setPosition(CCPoint(s.width/2, s.height-100)) + label1:setPosition(cc.p(s.width/2, s.height-100)) - -- CCLabelTTF - local label2 = CCLabelTTF:create("", "Arial", 24) + -- cc.LabelTTF + local label2 = cc.LabelTTF:create("", "Arial", 24) layer:addChild(label2, 0, kTagBitmapAtlas2) - label2:setPosition(CCPoint(s.width/2, s.height/2)) + label2:setPosition(cc.p(s.width/2, s.height/2)) - -- CCLabelAtlas - local label3 = CCLabelAtlas:create("", "fonts/tuffy_bold_italic-charmap.png", 48, 64, string.byte(" ")) + -- cc.LabelAtlas + local label3 = cc.LabelAtlas:_create("", "fonts/tuffy_bold_italic-charmap.png", 48, 64, string.byte(" ")) layer:addChild(label3, 0, kTagBitmapAtlas3) - label3:setPosition(CCPoint(s.width/2, 0+100)) + label3:setPosition(cc.p(s.width/2, 0+100)) layer:registerScriptHandler(LabelsEmpty.onNodeEvent) @@ -605,9 +592,9 @@ function LabelsEmpty.create() end function LabelsEmpty.updateStrings(dt) - local label1 = tolua.cast(LabelsEmpty.layer:getChildByTag(kTagBitmapAtlas1), "CCLabelBMFont") - local label2 = tolua.cast(LabelsEmpty.layer:getChildByTag(kTagBitmapAtlas2), "CCLabelTTF") - local label3 = tolua.cast(LabelsEmpty.layer:getChildByTag(kTagBitmapAtlas3), "CCLabelAtlas") + local label1 = tolua.cast(LabelsEmpty.layer:getChildByTag(kTagBitmapAtlas1), "LabelBMFont") + local label2 = tolua.cast(LabelsEmpty.layer:getChildByTag(kTagBitmapAtlas2), "LabelTTF") + local label3 = tolua.cast(LabelsEmpty.layer:getChildByTag(kTagBitmapAtlas3), "LabelAtlas") if( LabelsEmpty.setEmpty == false) then label1:setString("not empty") @@ -632,15 +619,15 @@ local LabelBMFontHD = { } function LabelBMFontHD.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - -- CCLabelBMFont - local label1 = CCLabelBMFont:create("TESTING RETINA DISPLAY", "fonts/konqa32.fnt") + -- cc.LabelBMFont + local label1 = cc.LabelBMFont:create("TESTING RETINA DISPLAY", "fonts/konqa32.fnt") layer:addChild(label1) - label1:setPosition(CCPoint(s.width/2, s.height/2)) + label1:setPosition(cc.p(s.width/2, s.height/2)) Helper.titleLabel:setString("Testing Retina Display BMFont") Helper.subtitleLabel:setString("loading arista16 or arista16-hd") @@ -654,17 +641,17 @@ end -------------------------------------------------------------------- local LabelAtlasHD = {} function LabelAtlasHD.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - -- CCLabelBMFont - local label1 = CCLabelAtlas:create("TESTING RETINA DISPLAY", "fonts/larabie-16.plist") - label1:setAnchorPoint(CCPoint(0.5, 0.5)) + -- cc.LabelBMFont + local label1 = cc.LabelAtlas:_create("TESTING RETINA DISPLAY", "fonts/larabie-16.plist") + label1:setAnchorPoint(cc.p(0.5, 0.5)) layer:addChild(label1) - label1:setPosition(CCPoint(s.width/2, s.height/2)) + label1:setPosition(cc.p(s.width/2, s.height/2)) Helper.titleLabel:setString("LabelAtlas with Retina Display") Helper.subtitleLabel:setString("loading larabie-16 / larabie-16-hd") @@ -679,18 +666,18 @@ end local LabelGlyphDesigner = {} function LabelGlyphDesigner.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local colorlayer = CCLayerColor:create(Color4B(128,128,128,255)) + local colorlayer = cc.LayerColor:create(cc.c4b(128,128,128,255)) layer:addChild(colorlayer, -10) - -- CCLabelBMFont - local label1 = CCLabelBMFont:create("Testing Glyph Designer", "fonts/futura-48.fnt") + -- cc.LabelBMFont + local label1 = cc.LabelBMFont:create("Testing Glyph Designer", "fonts/futura-48.fnt") layer:addChild(label1) - label1:setPosition(CCPoint(s.width/2, s.height/2)) + label1:setPosition(cc.p(s.width/2, s.height/2)) Helper.titleLabel:setString("Testing Glyph Designer") Helper.subtitleLabel:setString("You should see a font with shawdows and outline") @@ -706,50 +693,50 @@ end local LabelTTFTest = { _layer = nil, _plabel = nil, - _eHorizAlign = kCCTextAlignmentLeft, - _eVertAlign = kCCVerticalTextAlignmentTop + _eHorizAlign = cc.TEXT_ALIGNMENT_LEFT, + _eVertAlign = cc.VERTICAL_TEXT_ALIGNMENT_TOP } function LabelTTFTest.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) LabelTTFTest._layer = layer LabelTTFTest._plabel = nil - LabelTTFTest._eHorizAlign = kCCTextAlignmentLeft - LabelTTFTest._eVertAlign = kCCVerticalTextAlignmentTop + LabelTTFTest._eHorizAlign = cc.TEXT_ALIGNMENT_LEFT + LabelTTFTest._eVertAlign = cc.VERTICAL_TEXT_ALIGNMENT_TOP - local blockSize = CCSize(200, 160) - local s = CCDirector:getInstance():getWinSize() + local blockSize = cc.size(200, 160) + local s = cc.Director:getInstance():getWinSize() - local colorLayer = CCLayerColor:create(Color4B(100, 100, 100, 255), blockSize.width, blockSize.height) - colorLayer:setAnchorPoint(CCPoint(0,0)) - colorLayer:setPosition(CCPoint((s.width - blockSize.width) / 2, (s.height - blockSize.height) / 2)) + local colorLayer = cc.LayerColor:create(cc.c4b(100, 100, 100, 255), blockSize.width, blockSize.height) + colorLayer:setAnchorPoint(cc.p(0,0)) + colorLayer:setPosition(cc.p((s.width - blockSize.width) / 2, (s.height - blockSize.height) / 2)) layer:addChild(colorLayer) - CCMenuItemFont:setFontSize(30) - local item1 = CCMenuItemFont:create("Left") + cc.MenuItemFont:setFontSize(30) + local item1 = cc.MenuItemFont:create("Left") item1:registerScriptTapHandler(LabelTTFTest.setAlignmentLeft) - local item2 = CCMenuItemFont:create("Center") + local item2 = cc.MenuItemFont:create("Center") item2:registerScriptTapHandler(LabelTTFTest.setAlignmentCenter) - local item3 = CCMenuItemFont:create("Right") + local item3 = cc.MenuItemFont:create("Right") item3:registerScriptTapHandler(LabelTTFTest.setAlignmentRight) - local menu = CCMenu:create() + local menu = cc.Menu:create() menu:addChild(item1) menu:addChild(item2) menu:addChild(item3) menu:alignItemsVerticallyWithPadding(4) - menu:setPosition(CCPoint(50, s.height / 2 - 20)) + menu:setPosition(cc.p(50, s.height / 2 - 20)) layer:addChild(menu) - menu = CCMenu:create() + menu = cc.Menu:create() - item1 = CCMenuItemFont:create("Top") + item1 = cc.MenuItemFont:create("Top") item1:registerScriptTapHandler(LabelTTFTest.setAlignmentTop) - item2 = CCMenuItemFont:create("Middle") + item2 = cc.MenuItemFont:create("Middle") item2:registerScriptTapHandler(LabelTTFTest.setAlignmentMiddle) - item3 = CCMenuItemFont:create("Bottom") + item3 = cc.MenuItemFont:create("Bottom") item3:registerScriptTapHandler(LabelTTFTest.setAlignmentBottom) menu:addChild(item1) @@ -757,14 +744,14 @@ function LabelTTFTest.create() menu:addChild(item3) menu:alignItemsVerticallyWithPadding(4) - menu:setPosition(CCPoint(s.width - 50, s.height / 2 - 20)) + menu:setPosition(cc.p(s.width - 50, s.height / 2 - 20)) layer:addChild(menu) LabelTTFTest.updateAlignment() layer:registerScriptHandler(LabelTTFTest.onNodeEvent) - Helper.titleLabel:setString("Testing CCLabelTTF") + Helper.titleLabel:setString("Testing cc.LabelTTF") Helper.subtitleLabel:setString("Select the buttons on the sides to change alignment") return layer @@ -779,70 +766,70 @@ function LabelTTFTest.onNodeEvent(tag) end function LabelTTFTest.updateAlignment() - local blockSize = CCSize(200, 160) - local s = CCDirector:getInstance():getWinSize() + local blockSize = cc.size(200, 160) + local s = cc.Director:getInstance():getWinSize() if LabelTTFTest._plabel ~= nil then - LabelTTFTest._plabel:removeFromParentAndCleanup(true) + LabelTTFTest._plabel:removeFromParent(true) LabelTTFTest._plabel:release() end - LabelTTFTest._plabel = CCLabelTTF:create(LabelTTFTest.getCurrentAlignment(), "Marker Felt", 32, + LabelTTFTest._plabel = cc.LabelTTF:create(LabelTTFTest.getCurrentAlignment(), "Marker Felt", 32, blockSize, LabelTTFTest._eHorizAlign, LabelTTFTest._eVertAlign) LabelTTFTest._plabel:retain() - LabelTTFTest._plabel:setAnchorPoint(CCPoint(0,0)) - LabelTTFTest._plabel:setPosition(CCPoint((s.width - blockSize.width) / 2, (s.height - blockSize.height)/2 )) + LabelTTFTest._plabel:setAnchorPoint(cc.p(0,0)) + LabelTTFTest._plabel:setPosition(cc.p((s.width - blockSize.width) / 2, (s.height - blockSize.height)/2 )) LabelTTFTest._layer:addChild(LabelTTFTest._plabel) end function LabelTTFTest.setAlignmentLeft(pSender) - LabelTTFTest._eHorizAlign = kCCTextAlignmentLeft + LabelTTFTest._eHorizAlign = cc.TEXT_ALIGNMENT_LEFT LabelTTFTest.updateAlignment() end function LabelTTFTest.setAlignmentCenter(pSender) - LabelTTFTest._eHorizAlign = kCCTextAlignmentCenter + LabelTTFTest._eHorizAlign = cc.TEXT_ALIGNMENT_CENTER LabelTTFTest.updateAlignment() end function LabelTTFTest.setAlignmentRight(pSender) - LabelTTFTest._eHorizAlign = kCCTextAlignmentRight + LabelTTFTest._eHorizAlign = cc.TEXT_ALIGNMENT_RIGHT LabelTTFTest.updateAlignment() end function LabelTTFTest.setAlignmentTop(pSender) - LabelTTFTest._eVertAlign = kCCVerticalTextAlignmentTop + LabelTTFTest._eVertAlign = cc.VERTICAL_TEXT_ALIGNMENT_TOP LabelTTFTest.updateAlignment() end function LabelTTFTest.setAlignmentMiddle(pSender) - LabelTTFTest._eVertAlign = kCCVerticalTextAlignmentCenter + LabelTTFTest._eVertAlign = cc.VERTICAL_TEXT_ALIGNMENT_CENTER LabelTTFTest.updateAlignment() end function LabelTTFTest.setAlignmentBottom(pSender) - LabelTTFTest._eVertAlign = kCCVerticalTextAlignmentBottom + LabelTTFTest._eVertAlign = cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM LabelTTFTest.updateAlignment() end function LabelTTFTest.getCurrentAlignment() local vertical = nil local horizontal = nil - if LabelTTFTest._eVertAlign == kCCVerticalTextAlignmentTop then + if LabelTTFTest._eVertAlign == cc.VERTICAL_TEXT_ALIGNMENT_TOP then vertical = "Top" - elseif LabelTTFTest._eVertAlign == kCCVerticalTextAlignmentCenter then + elseif LabelTTFTest._eVertAlign == cc.VERTICAL_TEXT_ALIGNMENT_CENTER then vertical = "Middle" - elseif LabelTTFTest._eVertAlign == kCCVerticalTextAlignmentBottom then + elseif LabelTTFTest._eVertAlign == cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM then vertical = "Bottom" end - if LabelTTFTest._eHorizAlign == kCCTextAlignmentLeft then + if LabelTTFTest._eHorizAlign == cc.TEXT_ALIGNMENT_LEFT then horizontal = "Left" - elseif LabelTTFTest._eHorizAlign == kCCTextAlignmentCenter then + elseif LabelTTFTest._eHorizAlign == cc.TEXT_ALIGNMENT_CENTER then horizontal = "Center" - elseif LabelTTFTest._eHorizAlign == kCCTextAlignmentRight then + elseif LabelTTFTest._eHorizAlign == cc.TEXT_ALIGNMENT_RIGHT then horizontal = "Right" end @@ -856,9 +843,9 @@ end -------------------------------------------------------------------- --Atlas1:Atlas1() --{ --- m_textureAtlas = CCTextureAtlas:create(s_AtlasTest, 3); m_textureAtlas:retain(); +-- m_textureAtlas = cc.TextureAtlas:create(s_AtlasTest, 3); m_textureAtlas:retain(); -- --- CCSize s = CCDirector:getInstance():getWinSize(); +-- cc.size s = cc.Director:getInstance():getWinSize(); -- -- -- -- -- Notice: u,v tex coordinates are inverted @@ -866,23 +853,23 @@ end -- V3F_C4B_T2F_Quad quads[] = -- { -- { --- {{0,0,0},Color4B(0,0,255,255),{0.0f,1.0f},}, -- bottom left --- {{s.width,0,0},Color4B(0,0,255,0),{1.0f,1.0f},}, -- bottom right --- {{0,s.height,0},Color4B(0,0,255,0),{0.0f,0.0f},}, -- top left +-- {{0,0,0},cc.c4b(0,0,255,255),{0.0f,1.0f},}, -- bottom left +-- {{s.width,0,0},cc.c4b(0,0,255,0),{1.0f,1.0f},}, -- bottom right +-- {{0,s.height,0},cc.c4b(0,0,255,0),{0.0f,0.0f},}, -- top left -- {{s.width,s.height,0},{0,0,255,255},{1.0f,0.0f},}, -- top right -- }, -- { --- {{40,40,0},Color4B(255,255,255,255),{0.0f,0.2f},}, -- bottom left --- {{120,80,0},Color4B(255,0,0,255),{0.5f,0.2f},}, -- bottom right --- {{40,160,0},Color4B(255,255,255,255),{0.0f,0.0f},}, -- top left --- {{160,160,0},Color4B(0,255,0,255),{0.5f,0.0f},}, -- top right +-- {{40,40,0},cc.c4b(255,255,255,255),{0.0f,0.2f},}, -- bottom left +-- {{120,80,0},cc.c4b(255,0,0,255),{0.5f,0.2f},}, -- bottom right +-- {{40,160,0},cc.c4b(255,255,255,255),{0.0f,0.0f},}, -- top left +-- {{160,160,0},cc.c4b(0,255,0,255),{0.5f,0.0f},}, -- top right -- }, -- -- { --- {{s.width/2,40,0},Color4B(255,0,0,255),{0.0f,1.0f},}, -- bottom left --- {{s.width,40,0},Color4B(0,255,0,255),{1.0f,1.0f},}, -- bottom right --- {{s.width/2-50,200,0},Color4B(0,0,255,255),{0.0f,0.0f},}, -- top left --- {{s.width,100,0},Color4B(255,255,0,255),{1.0f,0.0f},}, -- top right +-- {{s.width/2,40,0},cc.c4b(255,0,0,255),{0.0f,1.0f},}, -- bottom left +-- {{s.width,40,0},cc.c4b(0,255,0,255),{1.0f,1.0f},}, -- bottom right +-- {{s.width/2-50,200,0},cc.c4b(0,0,255,255),{0.0f,0.0f},}, -- top left +-- {{s.width,100,0},cc.c4b(255,255,0,255),{1.0f,0.0f},}, -- top right -- }, -- -- }; @@ -912,12 +899,12 @@ end -- --std:string Atlas1:title() --{ --- return "CCTextureAtlas"; +-- return "TextureAtlas"; --} -- --std:string Atlas1:subtitle() --{ --- return "Manual creation of CCTextureAtlas"; +-- return "Manual creation of cc.TextureAtlas"; --} local LabelTTFMultiline = { @@ -925,23 +912,23 @@ local LabelTTFMultiline = { } function LabelTTFMultiline.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local center = CCLabelTTF:create("word wrap \"testing\" (bla0) bla1 'bla2' [bla3] (bla4) {bla5} {bla6} [bla7] (bla8) [bla9] 'bla0' \"bla1\"", + local center = cc.LabelTTF:create("word wrap \"testing\" (bla0) bla1 'bla2' [bla3] (bla4) {bla5} {bla6} [bla7] (bla8) [bla9] 'bla0' \"bla1\"", "Paint Boy", 32, - CCSize(s.width/2,200), - kCCTextAlignmentCenter, - kCCVerticalTextAlignmentTop) + cc.size(s.width/2,200), + cc.TEXT_ALIGNMENT_CENTER, + cc.VERTICAL_TEXT_ALIGNMENT_TOP) - center:setPosition(CCPoint(s.width / 2, 150)) + center:setPosition(cc.p(s.width / 2, 150)) layer:addChild(center) - Helper.titleLabel:setString("Testing CCLabelTTF Word Wrap") - Helper.subtitleLabel:setString("Word wrap using CCLabelTTF and a custom TTF font") + Helper.titleLabel:setString("Testing cc.LabelTTF Word Wrap") + Helper.subtitleLabel:setString("Word wrap using cc.LabelTTF and a custom TTF font") return layer end @@ -949,27 +936,27 @@ end local LabelTTFChinese = {} function LabelTTFChinese.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) - local size = CCDirector:getInstance():getWinSize() - local pLable = CCLabelTTF:create("中国", "Marker Felt", 30) - pLable:setPosition(CCPoint(size.width / 2, size.height /2)) + local size = cc.Director:getInstance():getWinSize() + local pLable = cc.LabelTTF:create("中国", "Marker Felt", 30) + pLable:setPosition(cc.p(size.width / 2, size.height /2)) layer:addChild(pLable) - Helper.titleLabel:setString("Testing CCLabelTTF with Chinese character") + Helper.titleLabel:setString("Testing cc.LabelTTF with Chinese character") return layer end local LabelBMFontChinese = {} function LabelBMFontChinese.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) - local size = CCDirector:getInstance():getWinSize() - local pLable = CCLabelBMFont:create("中国", "fonts/bitmapFontChinese.fnt") - pLable:setPosition(CCPoint(size.width / 2, size.height /2)) + local size = cc.Director:getInstance():getWinSize() + local pLable = cc.LabelBMFont:create("中国", "fonts/bitmapFontChinese.fnt") + pLable:setPosition(cc.p(size.width / 2, size.height /2)) layer:addChild(pLable) - Helper.titleLabel:setString("Testing CCLabelBMFont with Chinese character") + Helper.titleLabel:setString("Testing cc.LabelBMFont with Chinese character") return layer end @@ -1002,67 +989,67 @@ local BitmapFontMultiLineAlignment = { } function BitmapFontMultiLineAlignment.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) layer:setTouchEnabled(true) -- ask director the the window size - local size = CCDirector:getInstance():getWinSize() + local size = cc.Director:getInstance():getWinSize() -- create and initialize a Label - BitmapFontMultiLineAlignment._pLabelShouldRetain = CCLabelBMFont:create(LongSentencesExample, "fonts/markerFelt.fnt", size.width/1.5, kCCTextAlignmentCenter) + BitmapFontMultiLineAlignment._pLabelShouldRetain = cc.LabelBMFont:create(LongSentencesExample, "fonts/markerFelt.fnt", size.width/1.5, cc.TEXT_ALIGNMENT_CENTER) BitmapFontMultiLineAlignment._pLabelShouldRetain:retain() - BitmapFontMultiLineAlignment._pArrowsBarShouldRetain = CCSprite:create("Images/arrowsBar.png") + BitmapFontMultiLineAlignment._pArrowsBarShouldRetain = cc.Sprite:create("Images/arrowsBar.png") BitmapFontMultiLineAlignment._pArrowsBarShouldRetain:retain() - BitmapFontMultiLineAlignment._pArrowsShouldRetain = CCSprite:create("Images/arrows.png") + BitmapFontMultiLineAlignment._pArrowsShouldRetain = cc.Sprite:create("Images/arrows.png") BitmapFontMultiLineAlignment._pArrowsShouldRetain:retain() - CCMenuItemFont:setFontSize(20) - local longSentences = CCMenuItemFont:create("Long Flowing Sentences") + cc.MenuItemFont:setFontSize(20) + local longSentences = cc.MenuItemFont:create("Long Flowing Sentences") longSentences:registerScriptTapHandler(BitmapFontMultiLineAlignment.stringChanged) - local lineBreaks = CCMenuItemFont:create("Short Sentences With Intentional Line Breaks") + local lineBreaks = cc.MenuItemFont:create("Short Sentences With Intentional Line Breaks") lineBreaks:registerScriptTapHandler(BitmapFontMultiLineAlignment.stringChanged) - local mixed = CCMenuItemFont:create("Long Sentences Mixed With Intentional Line Breaks") + local mixed = cc.MenuItemFont:create("Long Sentences Mixed With Intentional Line Breaks") mixed:registerScriptTapHandler(BitmapFontMultiLineAlignment.stringChanged) - local stringMenu = CCMenu:create() + local stringMenu = cc.Menu:create() stringMenu:addChild(longSentences) stringMenu:addChild(lineBreaks) stringMenu:addChild(mixed) stringMenu:alignItemsVertically() - longSentences:setColor(Color3B(255, 0, 0)) + longSentences:setColor(cc.c3b(255, 0, 0)) BitmapFontMultiLineAlignment._pLastSentenceItem = longSentences longSentences:setTag(LongSentences) lineBreaks:setTag(LineBreaks) mixed:setTag(Mixed) - CCMenuItemFont:setFontSize(30) + cc.MenuItemFont:setFontSize(30) - local left = CCMenuItemFont:create("Left") + local left = cc.MenuItemFont:create("Left") left:registerScriptTapHandler(BitmapFontMultiLineAlignment.alignmentChanged) - local center = CCMenuItemFont:create("Center") + local center = cc.MenuItemFont:create("Center") center:registerScriptTapHandler(BitmapFontMultiLineAlignment.alignmentChanged) - local right = CCMenuItemFont:create("Right") + local right = cc.MenuItemFont:create("Right") right:registerScriptTapHandler(BitmapFontMultiLineAlignment.alignmentChanged) - local alignmentMenu = CCMenu:create() + local alignmentMenu = cc.Menu:create() alignmentMenu:addChild(left) alignmentMenu:addChild(center) alignmentMenu:addChild(right) alignmentMenu:alignItemsHorizontallyWithPadding(alignmentItemPadding) - center:setColor(Color3B(255, 0, 0)) + center:setColor(cc.c3b(255, 0, 0)) BitmapFontMultiLineAlignment._pLastAlignmentItem = center left:setTag(LeftAlign) center:setTag(CenterAlign) right:setTag(RightAlign) -- position the label on the center of the screen - BitmapFontMultiLineAlignment._pLabelShouldRetain:setPosition(CCPoint(size.width/2, size.height/2)) + BitmapFontMultiLineAlignment._pLabelShouldRetain:setPosition(cc.p(size.width/2, size.height/2)) BitmapFontMultiLineAlignment._pArrowsBarShouldRetain:setVisible(false) @@ -1072,8 +1059,8 @@ function BitmapFontMultiLineAlignment.create() BitmapFontMultiLineAlignment.snapArrowsToEdge() - stringMenu:setPosition(CCPoint(size.width/2, size.height - menuItemPaddingCenter)) - alignmentMenu:setPosition(CCPoint(size.width/2, menuItemPaddingCenter+15)) + stringMenu:setPosition(cc.p(size.width/2, size.height - menuItemPaddingCenter)) + alignmentMenu:setPosition(cc.p(size.width/2, menuItemPaddingCenter+15)) layer:addChild(BitmapFontMultiLineAlignment._pLabelShouldRetain) layer:addChild(BitmapFontMultiLineAlignment._pArrowsBarShouldRetain) @@ -1096,9 +1083,9 @@ end function BitmapFontMultiLineAlignment.stringChanged(tag, sender) - local item = tolua.cast(sender, "CCMenuItemFont") - item:setColor(Color3B(255, 0, 0)) - BitmapFontMultiLineAlignment._pLastAlignmentItem:setColor(Color3B(255, 255, 255)) + local item = tolua.cast(sender, "MenuItemFont") + item:setColor(cc.c3b(255, 0, 0)) + BitmapFontMultiLineAlignment._pLastAlignmentItem:setColor(cc.c3b(255, 255, 255)) BitmapFontMultiLineAlignment._pLastAlignmentItem = item if item:getTag() == LongSentences then @@ -1114,18 +1101,18 @@ end function BitmapFontMultiLineAlignment.alignmentChanged(tag, sender) -- cclog("BitmapFontMultiLineAlignment.alignmentChanged, tag:"..tag) - local item = tolua.cast(sender, "CCMenuItemFont") - item:setColor(Color3B(255, 0, 0)) - BitmapFontMultiLineAlignment._pLastAlignmentItem:setColor(Color3B(255, 255, 255)) + local item = tolua.cast(sender, "MenuItemFont") + item:setColor(cc.c3b(255, 0, 0)) + BitmapFontMultiLineAlignment._pLastAlignmentItem:setColor(cc.c3b(255, 255, 255)) BitmapFontMultiLineAlignment._pLastAlignmentItem = item if tag == LeftAlign then cclog("LeftAlign") - BitmapFontMultiLineAlignment._pLabelShouldRetain:setAlignment(kCCTextAlignmentLeft) + BitmapFontMultiLineAlignment._pLabelShouldRetain:setAlignment(cc.TEXT_ALIGNMENT_LEFT) elseif tag == CenterAlign then - BitmapFontMultiLineAlignment._pLabelShouldRetain:setAlignment(kCCTextAlignmentCenter) + BitmapFontMultiLineAlignment._pLabelShouldRetain:setAlignment(cc.TEXT_ALIGNMENT_CENTER) elseif tag == RightAlign then - BitmapFontMultiLineAlignment._pLabelShouldRetain:setAlignment(kCCTextAlignmentRight) + BitmapFontMultiLineAlignment._pLabelShouldRetain:setAlignment(cc.TEXT_ALIGNMENT_RIGHT) end BitmapFontMultiLineAlignment.snapArrowsToEdge() @@ -1134,7 +1121,7 @@ end function BitmapFontMultiLineAlignment.onTouchEvent(eventType, x, y) -- cclog("type:"..eventType.."["..x..","..y.."]") if eventType == "began" then - if BitmapFontMultiLineAlignment._pArrowsShouldRetain:getBoundingBox():containsPoint(CCPoint(x, y)) then + if cc.rectContainsPoint(BitmapFontMultiLineAlignment._pArrowsShouldRetain:getBoundingBox(), cc.p(x, y)) then BitmapFontMultiLineAlignment._drag = true BitmapFontMultiLineAlignment._pArrowsBarShouldRetain:setVisible(true) return true @@ -1148,7 +1135,7 @@ function BitmapFontMultiLineAlignment.onTouchEvent(eventType, x, y) return end - local winSize = CCDirector:getInstance():getWinSize() + local winSize = cc.Director:getInstance():getWinSize() BitmapFontMultiLineAlignment._pArrowsShouldRetain:setPosition( math.max(math.min(x, ArrowsMax*winSize.width), ArrowsMin*winSize.width), BitmapFontMultiLineAlignment._pArrowsShouldRetain:getPositionY()) @@ -1171,28 +1158,25 @@ end local LabelTTFA8Test = {} function LabelTTFA8Test.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local colorlayer = CCLayerColor:create(Color4B(128, 128, 128, 255)) + local colorlayer = cc.LayerColor:create(cc.c4b(128, 128, 128, 255)) layer:addChild(colorlayer, -10) - -- CCLabelBMFont - local label1 = CCLabelTTF:create("Testing A8 Format", "Marker Felt", 48) + -- cc.LabelBMFont + local label1 = cc.LabelTTF:create("Testing A8 Format", "Marker Felt", 48) layer:addChild(label1) - label1:setColor(Color3B(255, 0, 0)) - label1:setPosition(CCPoint(s.width/2, s.height/2)) + label1:setColor(cc.c3b(255, 0, 0)) + label1:setPosition(cc.p(s.width/2, s.height/2)) - local fadeOut = CCFadeOut:create(2) - local fadeIn = CCFadeIn:create(2) - local arr = CCArray:create() - arr:addObject(fadeOut) - arr:addObject(fadeIn) + local fadeOut = cc.FadeOut:create(2) + local fadeIn = cc.FadeIn:create(2) - local seq = CCSequence:create(arr) - local forever = CCRepeatForever:create(seq) + local seq = cc.Sequence:create(fadeOut, fadeIn) + local forever = cc.RepeatForever:create(seq) label1:runAction(forever) Helper.titleLabel:setString("Testing A8 Format") @@ -1203,19 +1187,19 @@ end --/ BMFontOneAtlas local BMFontOneAtlas = {} function BMFontOneAtlas.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local label1 = CCLabelBMFont:create("This is Helvetica", "fonts/helvetica-32.fnt", kCCLabelAutomaticWidth, kCCTextAlignmentLeft, CCPoint(0, 0)) + local label1 = cc.LabelBMFont:create("This is Helvetica", "fonts/helvetica-32.fnt", cc.LABEL_AUTOMATIC_WIDTH, cc.TEXT_ALIGNMENT_LEFT, cc.p(0, 0)) layer:addChild(label1) - label1:setPosition(CCPoint(s.width/2, s.height/3*2)) + label1:setPosition(cc.p(s.width/2, s.height/3*2)) - local label2 = CCLabelBMFont:create("And this is Geneva", "fonts/geneva-32.fnt", kCCLabelAutomaticWidth, kCCTextAlignmentLeft, CCPoint(0, 128)) + local label2 = cc.LabelBMFont:create("And this is Geneva", "fonts/geneva-32.fnt", cc.LABEL_AUTOMATIC_WIDTH, cc.TEXT_ALIGNMENT_LEFT, cc.p(0, 128)) layer:addChild(label2) - label2:setPosition(CCPoint(s.width/2, s.height/3*1)) - Helper.titleLabel:setString("CCLabelBMFont with one texture") + label2:setPosition(cc.p(s.width/2, s.height/3*1)) + Helper.titleLabel:setString("LabelBMFont with one texture") Helper.subtitleLabel:setString("Using 2 .fnt definitions that share the same texture atlas.") return layer end @@ -1223,24 +1207,24 @@ end --/ BMFontUnicode local BMFontUnicode = {} function BMFontUnicode.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) - Helper.titleLabel:setString("CCLabelBMFont with Unicode support") + Helper.titleLabel:setString("LabelBMFont with Unicode support") Helper.subtitleLabel:setString("You should see 3 differnt labels: In Spanish, Chinese and Korean") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local label1 = CCLabelBMFont:create("Buen día", "fonts/arial-unicode-26.fnt", 200, kCCTextAlignmentLeft) + local label1 = cc.LabelBMFont:create("Buen día", "fonts/arial-unicode-26.fnt", 200, cc.TEXT_ALIGNMENT_LEFT) layer:addChild(label1) - label1:setPosition(CCPoint(s.width/2, s.height/4*3)) + label1:setPosition(cc.p(s.width/2, s.height/4*3)) - local label2 = CCLabelBMFont:create("美好的一天", "fonts/arial-unicode-26.fnt") + local label2 = cc.LabelBMFont:create("美好的一天", "fonts/arial-unicode-26.fnt") layer:addChild(label2) - label2:setPosition(CCPoint(s.width/2, s.height/4*2)) + label2:setPosition(cc.p(s.width/2, s.height/4*2)) - local label3 = CCLabelBMFont:create("良ã„一日を", "fonts/arial-unicode-26.fnt") + local label3 = cc.LabelBMFont:create("良ã„一日を", "fonts/arial-unicode-26.fnt") layer:addChild(label3) - label3:setPosition(CCPoint(s.width/2, s.height/4*1)) + label3:setPosition(cc.p(s.width/2, s.height/4*1)) return layer end @@ -1249,21 +1233,18 @@ end local BMFontInit = {} function BMFontInit.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) - Helper.titleLabel:setString("CCLabelBMFont init") + Helper.titleLabel:setString("LabelBMFont init") Helper.subtitleLabel:setString("Test for support of init method without parameters.") - local s = CCDirector:getInstance():getWinSize() - - local bmFont = CCLabelBMFont:new() - bmFont:init() - bmFont:autorelease() - --CCLabelBMFont* bmFont = [CCLabelBMFont create:@"Foo" fntFile:@"arial-unicode-26.fnt"] + local s = cc.Director:getInstance():getWinSize() + local bmFont = cc.LabelBMFont:create() + --cc.LabelBMFont* bmFont = [cc.LabelBMFont create:@"Foo" fntFile:@"arial-unicode-26.fnt"] bmFont:setFntFile("fonts/helvetica-32.fnt") bmFont:setString("It is working!") layer:addChild(bmFont) - bmFont:setPosition(CCPoint(s.width/2,s.height/4*2)) + bmFont:setPosition(cc.p(s.width/2,s.height/4*2)) return layer end @@ -1272,21 +1253,19 @@ end local TTFFontInit = {} function TTFFontInit.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) - Helper.titleLabel:setString("CCLabelTTF init") + Helper.titleLabel:setString("LabelTTF init") Helper.subtitleLabel:setString("Test for support of init method without parameters.") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local font = CCLabelTTF:new() - font:init() - font:autorelease() + local font = cc.LabelTTF:create() font:setFontName("Marker Felt") font:setFontSize(48) font:setString("It is working!") layer:addChild(font) - font:setPosition(CCPoint(s.width/2,s.height/4*2)) + font:setPosition(cc.p(s.width/2,s.height/4*2)) return layer end @@ -1294,60 +1273,58 @@ end local Issue1343 = {} function Issue1343.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) Helper.titleLabel:setString("Issue 1343") Helper.subtitleLabel:setString("You should see: ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz.,'") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local bmFont = CCLabelBMFont:new() - bmFont:init() + local bmFont = cc.LabelBMFont:create() bmFont:setFntFile("fonts/font-issue1343.fnt") bmFont:setString("ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz.,'") layer:addChild(bmFont) - bmFont:release() bmFont:setScale(0.3) - bmFont:setPosition(CCPoint(s.width/2,s.height/4*2)) + bmFont:setPosition(cc.p(s.width/2,s.height/4*2)) return layer end local LabelBMFontBounds = {} function LabelBMFontBounds.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) Helper.titleLabel:setString("Testing LabelBMFont Bounds") Helper.subtitleLabel:setString("You should see string enclosed by a box") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local colorlayer = CCLayerColor:create(Color4B(128,128,128,255)) + local colorlayer = cc.LayerColor:create(cc.c4b(128,128,128,255)) layer:addChild(colorlayer, -10) - -- CCLabelBMFont - local label1 = CCLabelBMFont:create("Testing Glyph Designer", "fonts/boundsTestFont.fnt") + -- cc.LabelBMFont + local label1 = cc.LabelBMFont:create("Testing Glyph Designer", "fonts/boundsTestFont.fnt") layer:addChild(label1) - label1:setPosition(CCPoint(s.width/2, s.height/2)) + label1:setPosition(cc.p(s.width/2, s.height/2)) return layer end function LabelBMFontBounds.draw() - -- CCSize labelSize = label1:getContentSize() - -- CCSize origin = CCDirector:getInstance():getWinSize() + -- cc.size labelSize = label1:getContentSize() + -- cc.size origin = cc.Director:getInstance():getWinSize() -- origin.width = origin.width / 2 - (labelSize.width / 2) -- origin.height = origin.height / 2 - (labelSize.height / 2) - -- CCPoint vertices[4]= + -- cc.p vertices[4]= - -- CCPoint(origin.width, origin.height), - -- CCPoint(labelSize.width + origin.width, origin.height), - -- CCPoint(labelSize.width + origin.width, labelSize.height + origin.height), - -- CCPoint(origin.width, labelSize.height + origin.height) + -- cc.p(origin.width, origin.height), + -- cc.p(labelSize.width + origin.width, origin.height), + -- cc.p(labelSize.width + origin.width, labelSize.height + origin.height), + -- cc.p(origin.width, labelSize.height + origin.height) -- end -- ccDrawPoly(vertices, 4, true) end @@ -1359,29 +1336,29 @@ end -------------------------------------------------------------------- local LabelTTFAlignment = {} function LabelTTFAlignment.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) - Helper.titleLabel:setString("CCLabelTTF alignment") + Helper.titleLabel:setString("LabelTTF alignment") Helper.subtitleLabel:setString("Tests alignment values") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local ttf0 = CCLabelTTF:create("Alignment 0\nnew line", "Helvetica", 12, - CCSize(256, 32), kCCTextAlignmentLeft) - ttf0:setPosition(CCPoint(s.width/2,(s.height/6)*2)) - ttf0:setAnchorPoint(CCPoint(0.5,0.5)) + local ttf0 = cc.LabelTTF:create("Alignment 0\nnew line", "Helvetica", 12, + cc.size(256, 32), cc.TEXT_ALIGNMENT_LEFT) + ttf0:setPosition(cc.p(s.width/2,(s.height/6)*2)) + ttf0:setAnchorPoint(cc.p(0.5,0.5)) layer:addChild(ttf0) - local ttf1 = CCLabelTTF:create("Alignment 1\nnew line", "Helvetica", 12, - CCSize(245, 32), kCCTextAlignmentCenter) - ttf1:setPosition(CCPoint(s.width/2,(s.height/6)*3)) - ttf1:setAnchorPoint(CCPoint(0.5,0.5)) + local ttf1 = cc.LabelTTF:create("Alignment 1\nnew line", "Helvetica", 12, + cc.size(245, 32), cc.TEXT_ALIGNMENT_CENTER) + ttf1:setPosition(cc.p(s.width/2,(s.height/6)*3)) + ttf1:setAnchorPoint(cc.p(0.5,0.5)) layer:addChild(ttf1) - local ttf2 = CCLabelTTF:create("Alignment 2\nnew line", "Helvetica", 12, - CCSize(245, 32), kCCTextAlignmentRight) - ttf2:setPosition(CCPoint(s.width/2,(s.height/6)*4)) - ttf2:setAnchorPoint(CCPoint(0.5,0.5)) + local ttf2 = cc.LabelTTF:create("Alignment 2\nnew line", "Helvetica", 12, + cc.size(245, 32), cc.TEXT_ALIGNMENT_RIGHT) + ttf2:setPosition(cc.p(s.width/2,(s.height/6)*4)) + ttf2:setAnchorPoint(cc.p(0.5,0.5)) layer:addChild(ttf2) return layer end @@ -1389,7 +1366,7 @@ end function LabelTest() cclog("LabelTest") m_time = 0 - local scene = CCScene:create() + local scene = cc.Scene:create() Helper.createFunctionTable = { LabelAtlasTest.create, diff --git a/samples/Lua/TestLua/Resources/luaScript/LayerTest/LayerTest.lua b/samples/Lua/TestLua/Resources/luaScript/LayerTest/LayerTest.lua index c8560484dd..5314142ab4 100644 --- a/samples/Lua/TestLua/Resources/luaScript/LayerTest/LayerTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/LayerTest/LayerTest.lua @@ -1,8 +1,8 @@ -local scheduler = CCDirector:getInstance():getScheduler() +local scheduler = cc.Director:getInstance():getScheduler() local kTagLayer = 1 local function createLayerDemoLayer(title, subtitle) - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) local titleStr = title == nil and "No title" or title local subTitleStr = subtitle == nil and "" or subtitle @@ -22,7 +22,7 @@ local function createLayerDemoLayer(title, subtitle) -- local diffX = x - prev.x -- local diffY = y - prev.y - -- node:setPosition( CCPoint.__add(CCPoint(newX, newY), CCPoint(diffX, diffY)) ) + -- node:setPosition( cc.p.__add(cc.p(newX, newY), cc.p(diffX, diffY)) ) -- prev.x = x -- prev.y = y -- end @@ -53,9 +53,9 @@ local function setEnableRecursiveCascading(node, enable) end local i = 0 - local len = children:count() + local len = table.getn(children) for i = 0, len-1, 1 do - local child = tolua.cast(children:objectAtIndex(i), "CCNode") + local child = tolua.cast(children[i + 1], "Node") setEnableRecursiveCascading(child, enable) end end @@ -63,35 +63,34 @@ end -- LayerTestCascadingOpacityA local function LayerTestCascadingOpacityA() local ret = createLayerDemoLayer("LayerRGBA: cascading opacity") - local s = CCDirector:getInstance():getWinSize() - local layer1 = CCLayerRGBA:create() + local s = cc.Director:getInstance():getWinSize() + local layer1 = cc.LayerRGBA:create() - local sister1 = CCSprite:create("Images/grossinis_sister1.png") - local sister2 = CCSprite:create("Images/grossinis_sister2.png") - local label = CCLabelBMFont:create("Test", "fonts/bitmapFontTest.fnt") + local sister1 = cc.Sprite:create("Images/grossinis_sister1.png") + local sister2 = cc.Sprite:create("Images/grossinis_sister2.png") + local label = cc.LabelBMFont:create("Test", "fonts/bitmapFontTest.fnt") layer1:addChild(sister1) layer1:addChild(sister2) layer1:addChild(label) ret:addChild( layer1, 0, kTagLayer) - sister1:setPosition( CCPoint( s.width*1/3, s.height/2)) - sister2:setPosition( CCPoint( s.width*2/3, s.height/2)) - label:setPosition( CCPoint( s.width/2, s.height/2)) + sister1:setPosition( cc.p( s.width*1/3, s.height/2)) + sister2:setPosition( cc.p( s.width*2/3, s.height/2)) + label:setPosition( cc.p( s.width/2, s.height/2)) - local arr = CCArray:create() - arr:addObject(CCFadeTo:create(4, 0)) - arr:addObject(CCFadeTo:create(4, 255)) - arr:addObject(CCDelayTime:create(1)) - layer1:runAction(CCRepeatForever:create(CCSequence:create(arr))) + layer1:runAction(cc.RepeatForever:create(cc.Sequence:create(cc.FadeTo:create(4, 0), + cc.FadeTo:create(4, 255), + cc.DelayTime:create(1) + ))) - arr = CCArray:create() - arr:addObject(CCFadeTo:create(2, 0)) - arr:addObject(CCFadeTo:create(2, 255)) - arr:addObject(CCFadeTo:create(2, 0)) - arr:addObject(CCFadeTo:create(2, 255)) - arr:addObject(CCDelayTime:create(1)) - sister1:runAction(CCRepeatForever:create(CCSequence:create(arr))) + + sister1:runAction(cc.RepeatForever:create(cc.Sequence:create(cc.FadeTo:create(2, 0), + cc.FadeTo:create(2, 255), + cc.FadeTo:create(2, 0), + cc.FadeTo:create(2, 255), + cc.DelayTime:create(1) + ))) -- Enable cascading in scene setEnableRecursiveCascading(ret, true) @@ -102,40 +101,28 @@ end local function LayerTestCascadingOpacityB() local ret = createLayerDemoLayer("CCLayerColor: cascading opacity") - local s = CCDirector:getInstance():getWinSize() - local layer1 = CCLayerColor:create(Color4B(192, 0, 0, 255), s.width, s.height/2) + local s = cc.Director:getInstance():getWinSize() + local layer1 = cc.LayerColor:create(cc.c4b(192, 0, 0, 255), s.width, s.height/2) layer1:setCascadeColorEnabled(false) - layer1:setPosition( CCPoint(0, s.height/2)) + layer1:setPosition( cc.p(0, s.height/2)) - local sister1 = CCSprite:create("Images/grossinis_sister1.png") - local sister2 = CCSprite:create("Images/grossinis_sister2.png") - local label = CCLabelBMFont:create("Test", "fonts/bitmapFontTest.fnt") + local sister1 = cc.Sprite:create("Images/grossinis_sister1.png") + local sister2 = cc.Sprite:create("Images/grossinis_sister2.png") + local label = cc.LabelBMFont:create("Test", "fonts/bitmapFontTest.fnt") layer1:addChild(sister1) layer1:addChild(sister2) layer1:addChild(label) ret:addChild( layer1, 0, kTagLayer) - sister1:setPosition( CCPoint( s.width*1/3, 0)) - sister2:setPosition( CCPoint( s.width*2/3, 0)) - label:setPosition( CCPoint( s.width/2, 0)) + sister1:setPosition( cc.p( s.width*1/3, 0)) + sister2:setPosition( cc.p( s.width*2/3, 0)) + label:setPosition( cc.p( s.width/2, 0)) - local arr = CCArray:create() - arr:addObject(CCFadeTo:create(4, 0)) - arr:addObject(CCFadeTo:create(4, 255)) - arr:addObject(CCDelayTime:create(1)) + layer1:runAction(cc.RepeatForever:create(cc.Sequence:create(cc.FadeTo:create(4, 0),cc.FadeTo:create(4, 255),cc.DelayTime:create(1)))) - layer1:runAction(CCRepeatForever:create(CCSequence:create(arr))) - - arr = CCArray:create() - arr:addObject(CCFadeTo:create(2, 0)) - arr:addObject(CCFadeTo:create(2, 255)) - arr:addObject(CCFadeTo:create(2, 0)) - arr:addObject(CCFadeTo:create(2, 255)) - arr:addObject(CCDelayTime:create(1)) - - sister1:runAction(CCRepeatForever:create(CCSequence:create(arr))) + sister1:runAction(cc.RepeatForever:create(cc.Sequence:create(cc.FadeTo:create(2, 0),cc.FadeTo:create(2, 255),cc.FadeTo:create(2, 0),cc.FadeTo:create(2, 255),cc.DelayTime:create(1)))) -- Enable cascading in scene setEnableRecursiveCascading(ret, true) @@ -144,48 +131,33 @@ end -- LayerTestCascadingOpacityC local function LayerTestCascadingOpacityC() - local ret = createLayerDemoLayer("CCLayerColor: non-cascading opacity") + local ret = createLayerDemoLayer("LayerColor: non-cascading opacity") - local s = CCDirector:getInstance():getWinSize() - local layer1 = CCLayerColor:create(Color4B(192, 0, 0, 255), s.width, s.height/2) + local s = cc.Director:getInstance():getWinSize() + local layer1 = cc.LayerColor:create(cc.c4b(192, 0, 0, 255), s.width, s.height/2) layer1:setCascadeColorEnabled(false) layer1:setCascadeOpacityEnabled(false) - layer1:setPosition( CCPoint(0, s.height/2)) + layer1:setPosition( cc.p(0, s.height/2)) - local sister1 = CCSprite:create("Images/grossinis_sister1.png") - local sister2 = CCSprite:create("Images/grossinis_sister2.png") - local label = CCLabelBMFont:create("Test", "fonts/bitmapFontTest.fnt") + local sister1 = cc.Sprite:create("Images/grossinis_sister1.png") + local sister2 = cc.Sprite:create("Images/grossinis_sister2.png") + local label = cc.LabelBMFont:create("Test", "fonts/bitmapFontTest.fnt") layer1:addChild(sister1) layer1:addChild(sister2) layer1:addChild(label) ret:addChild( layer1, 0, kTagLayer) - sister1:setPosition( CCPoint( s.width*1/3, 0)) - sister2:setPosition( CCPoint( s.width*2/3, 0)) - label:setPosition( CCPoint( s.width/2, 0)) + sister1:setPosition( cc.p( s.width*1/3, 0)) + sister2:setPosition( cc.p( s.width*2/3, 0)) + label:setPosition( cc.p( s.width/2, 0)) - local arr = CCArray:create() - arr:addObject(CCFadeTo:create(4, 0)) - arr:addObject(CCFadeTo:create(4, 255)) - arr:addObject(CCDelayTime:create(1)) + layer1:runAction(cc.RepeatForever:create(cc.Sequence:create(cc.FadeTo:create(4, 0), + cc.FadeTo:create(4, 255),cc.DelayTime:create(1)))) - layer1:runAction( - CCRepeatForever:create( - CCSequence:create(arr - ))) - - arr = CCArray:create() - arr:addObject(CCFadeTo:create(2, 0)) - arr:addObject(CCFadeTo:create(2, 255)) - arr:addObject(CCFadeTo:create(2, 0)) - arr:addObject(CCFadeTo:create(2, 255)) - arr:addObject(CCDelayTime:create(1)) - - sister1:runAction( - CCRepeatForever:create( - CCSequence:create(arr))) + sister1:runAction(cc.RepeatForever:create(cc.Sequence:create(cc.FadeTo:create(2, 0),cc.FadeTo:create(2, 255), + cc.FadeTo:create(2, 0),cc.FadeTo:create(2, 255),cc.DelayTime:create(1)))) return ret end @@ -195,45 +167,40 @@ end local function LayerTestCascadingColorA() local ret = createLayerDemoLayer("LayerRGBA: cascading color") - local s = CCDirector:getInstance():getWinSize() - local layer1 = CCLayerRGBA:create() + local s = cc.Director:getInstance():getWinSize() + local layer1 = cc.LayerRGBA:create() - local sister1 = CCSprite:create("Images/grossinis_sister1.png") - local sister2 = CCSprite:create("Images/grossinis_sister2.png") - local label = CCLabelBMFont:create("Test", "fonts/bitmapFontTest.fnt") + local sister1 = cc.Sprite:create("Images/grossinis_sister1.png") + local sister2 = cc.Sprite:create("Images/grossinis_sister2.png") + local label = cc.LabelBMFont:create("Test", "fonts/bitmapFontTest.fnt") layer1:addChild(sister1) layer1:addChild(sister2) layer1:addChild(label) ret:addChild( layer1, 0, kTagLayer) - sister1:setPosition( CCPoint( s.width*1/3, s.height/2)) - sister2:setPosition( CCPoint( s.width*2/3, s.height/2)) - label:setPosition( CCPoint( s.width/2, s.height/2)) - - local arr = CCArray:create() - arr:addObject(CCTintTo:create(6, 255, 0, 255)) - arr:addObject(CCTintTo:create(6, 255, 255, 255)) - arr:addObject(CCDelayTime:create(1)) + sister1:setPosition( cc.p( s.width*1/3, s.height/2)) + sister2:setPosition( cc.p( s.width*2/3, s.height/2)) + label:setPosition( cc.p( s.width/2, s.height/2)) layer1:runAction( - CCRepeatForever:create( - CCSequence:create(arr + cc.RepeatForever:create( + cc.Sequence:create(cc.TintTo:create(6, 255, 0, 255), + cc.TintTo:create(6, 255, 255, 255), + cc.DelayTime:create(1) ))) - arr = CCArray:create() - arr:addObject(CCTintTo:create(2, 255, 255, 0)) - arr:addObject(CCTintTo:create(2, 255, 255, 255)) - arr:addObject(CCTintTo:create(2, 0, 255, 255)) - arr:addObject(CCTintTo:create(2, 255, 255, 255)) - arr:addObject(CCTintTo:create(2, 255, 0, 255)) - arr:addObject(CCTintTo:create(2, 255, 255, 255)) - arr:addObject(CCDelayTime:create(1)) sister1:runAction( - CCRepeatForever:create( - CCSequence:create( - arr))) + cc.RepeatForever:create( + cc.Sequence:create(cc.TintTo:create(2, 255, 255, 0), + cc.TintTo:create(2, 255, 255, 255), + cc.TintTo:create(2, 0, 255, 255), + cc.TintTo:create(2, 255, 255, 255), + cc.TintTo:create(2, 255, 0, 255), + cc.TintTo:create(2, 255, 255, 255), + cc.DelayTime:create(1) + ))) -- Enable cascading in scene setEnableRecursiveCascading(ret, true) @@ -242,49 +209,43 @@ end -- LayerTestCascadingColorB local function LayerTestCascadingColorB() - local ret = createLayerDemoLayer("CCLayerColor: cascading color") + local ret = createLayerDemoLayer("LayerColor: cascading color") - local s = CCDirector:getInstance():getWinSize() - local layer1 = CCLayerColor:create(Color4B(255, 255, 255, 255), s.width, s.height/2) + local s = cc.Director:getInstance():getWinSize() + local layer1 = cc.LayerColor:create(cc.c4b(255, 255, 255, 255), s.width, s.height/2) - layer1:setPosition( CCPoint(0, s.height/2)) + layer1:setPosition( cc.p(0, s.height/2)) - local sister1 = CCSprite:create("Images/grossinis_sister1.png") - local sister2 = CCSprite:create("Images/grossinis_sister2.png") - local label = CCLabelBMFont:create("Test", "fonts/bitmapFontTest.fnt") + local sister1 = cc.Sprite:create("Images/grossinis_sister1.png") + local sister2 = cc.Sprite:create("Images/grossinis_sister2.png") + local label = cc.LabelBMFont:create("Test", "fonts/bitmapFontTest.fnt") layer1:addChild(sister1) layer1:addChild(sister2) layer1:addChild(label) ret:addChild( layer1, 0, kTagLayer) - sister1:setPosition( CCPoint( s.width*1/3, 0)) - sister2:setPosition( CCPoint( s.width*2/3, 0)) - label:setPosition( CCPoint( s.width/2, 0)) - - local arr = CCArray:create() - arr:addObject(CCTintTo:create(6, 255, 0, 255)) - arr:addObject(CCTintTo:create(6, 255, 255, 255)) - arr:addObject(CCDelayTime:create(1)) + sister1:setPosition( cc.p( s.width*1/3, 0)) + sister2:setPosition( cc.p( s.width*2/3, 0)) + label:setPosition( cc.p( s.width/2, 0)) layer1:runAction( - CCRepeatForever:create( - CCSequence:create( - arr))) - - arr = CCArray:create() - arr:addObject(CCTintTo:create(2, 255, 255, 0)) - arr:addObject(CCTintTo:create(2, 255, 255, 255)) - arr:addObject(CCTintTo:create(2, 0, 255, 255)) - arr:addObject(CCTintTo:create(2, 255, 255, 255)) - arr:addObject(CCTintTo:create(2, 255, 0, 255)) - arr:addObject(CCTintTo:create(2, 255, 255, 255)) - arr:addObject(CCDelayTime:create(1)) + cc.RepeatForever:create( + cc.Sequence:create(cc.TintTo:create(6, 255, 0, 255), + cc.TintTo:create(6, 255, 255, 255), + cc.DelayTime:create(1) + ))) sister1:runAction( - CCRepeatForever:create( - CCSequence:create( - arr))) + cc.RepeatForever:create( + cc.Sequence:create(cc.TintTo:create(2, 255, 255, 0), + cc.TintTo:create(2, 255, 255, 255), + cc.TintTo:create(2, 0, 255, 255), + cc.TintTo:create(2, 255, 255, 255), + cc.TintTo:create(2, 255, 0, 255), + cc.TintTo:create(2, 255, 255, 255), + cc.DelayTime:create(1) + ))) -- Enable cascading in scene setEnableRecursiveCascading(ret, true) @@ -293,49 +254,43 @@ end -- LayerTestCascadingColorC local function LayerTestCascadingColorC() - local ret = createLayerDemoLayer("CCLayerColor: non-cascading color") + local ret = createLayerDemoLayer("LayerColor: non-cascading color") - local s = CCDirector:getInstance():getWinSize() - local layer1 = CCLayerColor:create(Color4B(255, 255, 255, 255), s.width, s.height/2) + local s = cc.Director:getInstance():getWinSize() + local layer1 = cc.LayerColor:create(cc.c4b(255, 255, 255, 255), s.width, s.height/2) layer1:setCascadeColorEnabled(false) - layer1:setPosition( CCPoint(0, s.height/2)) + layer1:setPosition( cc.p(0, s.height/2)) - local sister1 = CCSprite:create("Images/grossinis_sister1.png") - local sister2 = CCSprite:create("Images/grossinis_sister2.png") - local label = CCLabelBMFont:create("Test", "fonts/bitmapFontTest.fnt") + local sister1 = cc.Sprite:create("Images/grossinis_sister1.png") + local sister2 = cc.Sprite:create("Images/grossinis_sister2.png") + local label = cc.LabelBMFont:create("Test", "fonts/bitmapFontTest.fnt") layer1:addChild(sister1) layer1:addChild(sister2) layer1:addChild(label) ret:addChild( layer1, 0, kTagLayer) - sister1:setPosition( CCPoint( s.width*1/3, 0)) - sister2:setPosition( CCPoint( s.width*2/3, 0)) - label:setPosition( CCPoint( s.width/2, 0)) - - local arr = CCArray:create() - arr:addObject(CCTintTo:create(6, 255, 0, 255)) - arr:addObject(CCTintTo:create(6, 255, 255, 255)) - arr:addObject(CCDelayTime:create(1)) + sister1:setPosition( cc.p( s.width*1/3, 0)) + sister2:setPosition( cc.p( s.width*2/3, 0)) + label:setPosition( cc.p( s.width/2, 0)) layer1:runAction( - CCRepeatForever:create( - CCSequence:create( - arr))) - - arr = CCArray:create() - arr:addObject(CCTintTo:create(2, 255, 255, 0)) - arr:addObject(CCTintTo:create(2, 255, 255, 255)) - arr:addObject(CCTintTo:create(2, 0, 255, 255)) - arr:addObject(CCTintTo:create(2, 255, 255, 255)) - arr:addObject(CCTintTo:create(2, 255, 0, 255)) - arr:addObject(CCTintTo:create(2, 255, 255, 255)) - arr:addObject(CCDelayTime:create(1)) + cc.RepeatForever:create( + cc.Sequence:create(cc.TintTo:create(6, 255, 0, 255), + cc.TintTo:create(6, 255, 255, 255), + cc.DelayTime:create(1) + ))) sister1:runAction( - CCRepeatForever:create( - CCSequence:create( - arr))) + cc.RepeatForever:create( + cc.Sequence:create(cc.TintTo:create(2, 255, 255, 0), + cc.TintTo:create(2, 255, 255, 255), + cc.TintTo:create(2, 0, 255, 255), + cc.TintTo:create(2, 255, 255, 255), + cc.TintTo:create(2, 255, 0, 255), + cc.TintTo:create(2, 255, 255, 255), + cc.DelayTime:create(1) + ))) return ret end @@ -349,19 +304,19 @@ local function LayerTest1() ret:setTouchEnabled(true) - local s = CCDirector:getInstance():getWinSize() - local layer = CCLayerColor:create( Color4B(0xFF, 0x00, 0x00, 0x80), 200, 200) + local s = cc.Director:getInstance():getWinSize() + local layer = cc.LayerColor:create( cc.c4b(0xFF, 0x00, 0x00, 0x80), 200, 200) layer:ignoreAnchorPointForPosition(false) - layer:setPosition( CCPoint(s.width/2, s.height/2) ) + layer:setPosition( cc.p(s.width/2, s.height/2) ) ret:addChild(layer, 1, kTagLayer) local function updateSize(x, y) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local newSize = CCSize( math.abs(x - s.width/2)*2, math.abs(y - s.height/2)*2) + local newSize = cc.size( math.abs(x - s.width/2)*2, math.abs(y - s.height/2)*2) - local l = tolua.cast(ret:getChildByTag(kTagLayer), "CCLayerColor") + local l = tolua.cast(ret:getChildByTag(kTagLayer), "LayerColor") l:setContentSize( newSize ) end @@ -386,31 +341,25 @@ end local function LayerTest2() local ret = createLayerDemoLayer("ColorLayer: fade and tint") - local s = CCDirector:getInstance():getWinSize() - local layer1 = CCLayerColor:create( Color4B(255, 255, 0, 80), 100, 300) - layer1:setPosition(CCPoint(s.width/3, s.height/2)) + local s = cc.Director:getInstance():getWinSize() + local layer1 = cc.LayerColor:create( cc.c4b(255, 255, 0, 80), 100, 300) + layer1:setPosition(cc.p(s.width/3, s.height/2)) layer1:ignoreAnchorPointForPosition(false) ret:addChild(layer1, 1) - local layer2 = CCLayerColor:create( Color4B(0, 0, 255, 255), 100, 300) - layer2:setPosition(CCPoint((s.width/3)*2, s.height/2)) + local layer2 = cc.LayerColor:create( cc.c4b(0, 0, 255, 255), 100, 300) + layer2:setPosition(cc.p((s.width/3)*2, s.height/2)) layer2:ignoreAnchorPointForPosition(false) ret:addChild(layer2, 1) - local actionTint = CCTintBy:create(2, -255, -127, 0) + local actionTint = cc.TintBy:create(2, -255, -127, 0) local actionTintBack = actionTint:reverse() - local arr = CCArray:create() - arr:addObject(actionTint) - arr:addObject(actionTintBack) - local seq1 = CCSequence:create(arr) + local seq1 = cc.Sequence:create(actionTint,actionTintBack) layer1:runAction(seq1) - local actionFade = CCFadeOut:create(2.0) + local actionFade = cc.FadeOut:create(2.0) local actionFadeBack = actionFade:reverse() - arr = CCArray:create() - arr:addObject(actionFade) - arr:addObject(actionFadeBack) - local seq2 = CCSequence:create(arr) + local seq2 = cc.Sequence:create(actionFade,actionFadeBack) layer2:runAction(seq2) return ret @@ -424,37 +373,37 @@ end local function LayerTestBlend() local ret = createLayerDemoLayer("ColorLayer: blend") - local s = CCDirector:getInstance():getWinSize() - local layer1 = CCLayerColor:create( Color4B(255, 255, 255, 80) ) + local s = cc.Director:getInstance():getWinSize() + local layer1 = cc.LayerColor:create( cc.c4b(255, 255, 255, 80) ) - local sister1 = CCSprite:create(s_pPathSister1) - local sister2 = CCSprite:create(s_pPathSister2) + local sister1 = cc.Sprite:create(s_pPathSister1) + local sister2 = cc.Sprite:create(s_pPathSister2) ret:addChild(sister1) ret:addChild(sister2) ret:addChild(layer1, 100, kTagLayer) - sister1:setPosition( CCPoint( s.width*1/3, s.height/2) ) - sister2:setPosition( CCPoint( s.width*2/3, s.height/2) ) + sister1:setPosition( cc.p( s.width*1/3, s.height/2) ) + sister2:setPosition( cc.p( s.width*2/3, s.height/2) ) + + local blend = true local function newBlend(dt) - local layer = tolua.cast(ret:getChildByTag(kTagLayer), "CCLayerColor") + local layer = tolua.cast(ret:getChildByTag(kTagLayer), "LayerColor") local src = 0 local dst = 0 - if layer:getBlendFunc().dst == GL_ZERO then - src = GL_SRC_ALPHA - dst = GL_ONE_MINUS_SRC_ALPHA + if blend then + src = gl.SRC_ALPHA + dst = gl.ONE_MINUS_SRC_ALPHA else - src = GL_ONE_MINUS_DST_COLOR - dst = GL_ZERO + src = gl.ONE_MINUS_DST_COLOR + dst = gl.ZERO end - local bf = BlendFunc() - bf.src = src - bf.dst = dst - layer:setBlendFunc( bf ) + layer:setBlendFunc(src, dst) + blend = not blend end @@ -478,42 +427,42 @@ end -------------------------------------------------------------------- local function LayerGradient() local ret = createLayerDemoLayer("LayerGradient", "Touch the screen and move your finger") - local layer1 = CCLayerGradient:create(Color4B(255,0,0,255), Color4B(0,255,0,255), CCPoint(0.9, 0.9)) + local layer1 = cc.LayerGradient:create(cc.c4b(255,0,0,255), cc.c4b(0,255,0,255), cc.p(0.9, 0.9)) ret:addChild(layer1, 0, kTagLayer) ret:setTouchEnabled(true) - local label1 = CCLabelTTF:create("Compressed Interpolation: Enabled", "Marker Felt", 26) - local label2 = CCLabelTTF:create("Compressed Interpolation: Disabled", "Marker Felt", 26) - local item1 = CCMenuItemLabel:create(label1) - local item2 = CCMenuItemLabel:create(label2) - local item = CCMenuItemToggle:create(item1) + local label1 = cc.LabelTTF:create("Compressed Interpolation: Enabled", "Marker Felt", 26) + local label2 = cc.LabelTTF:create("Compressed Interpolation: Disabled", "Marker Felt", 26) + local item1 = cc.MenuItemLabel:create(label1) + local item2 = cc.MenuItemLabel:create(label2) + local item = cc.MenuItemToggle:create(item1) item:addSubItem(item2) local function toggleItem(sender) -- cclog("toggleItem") - local gradient = tolua.cast(ret:getChildByTag(kTagLayer), "CCLayerGradient") + local gradient = tolua.cast(ret:getChildByTag(kTagLayer), "LayerGradient") gradient:setCompressedInterpolation(not gradient:isCompressedInterpolation()) end item:registerScriptTapHandler(toggleItem) - local menu = CCMenu:createWithItem(item) + local menu = cc.Menu:create(item) ret:addChild(menu) - local s = CCDirector:getInstance():getWinSize() - menu:setPosition(CCPoint(s.width / 2, 100)) + local s = cc.Director:getInstance():getWinSize() + menu:setPosition(cc.p(s.width / 2, 100)) local function onTouchEvent(eventType, x, y) if eventType == "began" then return true elseif eventType == "moved" then - local s = CCDirector:getInstance():getWinSize() - local start = CCPoint(x, y) + local s = cc.Director:getInstance():getWinSize() + local start = cc.p(x, y) + local movingPos = cc.p(s.width/2,s.height/2) + local diff = cc.p(movingPos.x - start.x, movingPos.y - start.y) + diff = cc.pNormalize(diff) - local diff = CCPoint.__sub( CCPoint(s.width/2,s.height/2), start) - diff = diff:normalize() - - local gradient = tolua.cast(ret:getChildByTag(1), "CCLayerGradient") + local gradient = tolua.cast(ret:getChildByTag(1), "LayerGradient") gradient:setVector(diff) end end @@ -530,26 +479,23 @@ local kLayerIgnoreAnchorPoint = 1000 local function LayerIgnoreAnchorPointPos() local ret = createLayerDemoLayer("IgnoreAnchorPoint - Position", "Ignoring Anchor Point for position") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local l = CCLayerColor:create(Color4B(255, 0, 0, 255), 150, 150) + local l = cc.LayerColor:create(cc.c4b(255, 0, 0, 255), 150, 150) - l:setAnchorPoint(CCPoint(0.5, 0.5)) - l:setPosition(CCPoint( s.width/2, s.height/2)) + l:setAnchorPoint(cc.p(0.5, 0.5)) + l:setPosition(cc.p( s.width/2, s.height/2)) - local move = CCMoveBy:create(2, CCPoint(100,2)) - local back = tolua.cast(move:reverse(), "CCMoveBy") - local arr = CCArray:create() - arr:addObject(move) - arr:addObject(back) - local seq = CCSequence:create(arr) - l:runAction(CCRepeatForever:create(seq)) + local move = cc.MoveBy:create(2, cc.p(100,2)) + local back = tolua.cast(move:reverse(), "MoveBy") + local seq = cc.Sequence:create(move, back) + l:runAction(cc.RepeatForever:create(seq)) ret:addChild(l, 0, kLayerIgnoreAnchorPoint) - local child = CCSprite:create("Images/grossini.png") + local child = cc.Sprite:create("Images/grossini.png") l:addChild(child) local lsize = l:getContentSize() - child:setPosition(CCPoint(lsize.width/2, lsize.height/2)) + child:setPosition(cc.p(lsize.width/2, lsize.height/2)) local function onToggle(pObject) local pLayer = ret:getChildByTag(kLayerIgnoreAnchorPoint) @@ -557,13 +503,13 @@ local function LayerIgnoreAnchorPointPos() pLayer:ignoreAnchorPointForPosition(not ignore) end - local item = CCMenuItemFont:create("Toggle ignore anchor point") + local item = cc.MenuItemFont:create("Toggle ignore anchor point") item:registerScriptTapHandler(onToggle) - local menu = CCMenu:createWithItem(item) + local menu = cc.Menu:create(item) ret:addChild(menu) - menu:setPosition(CCPoint(s.width/2, s.height/2)) + menu:setPosition(cc.p(s.width/2, s.height/2)) return ret end @@ -572,23 +518,23 @@ end local function LayerIgnoreAnchorPointRot() local ret = createLayerDemoLayer("IgnoreAnchorPoint - Rotation", "Ignoring Anchor Point for rotations") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local l = CCLayerColor:create(Color4B(255, 0, 0, 255), 200, 200) + local l = cc.LayerColor:create(cc.c4b(255, 0, 0, 255), 200, 200) - l:setAnchorPoint(CCPoint(0.5, 0.5)) - l:setPosition(CCPoint( s.width/2, s.height/2)) + l:setAnchorPoint(cc.p(0.5, 0.5)) + l:setPosition(cc.p( s.width/2, s.height/2)) ret:addChild(l, 0, kLayerIgnoreAnchorPoint) - local rot = CCRotateBy:create(2, 360) - l:runAction(CCRepeatForever:create(rot)) + local rot = cc.RotateBy:create(2, 360) + l:runAction(cc.RepeatForever:create(rot)) - local child = CCSprite:create("Images/grossini.png") + local child = cc.Sprite:create("Images/grossini.png") l:addChild(child) local lsize = l:getContentSize() - child:setPosition(CCPoint(lsize.width/2, lsize.height/2)) + child:setPosition(cc.p(lsize.width/2, lsize.height/2)) local function onToggle(pObject) local pLayer = ret:getChildByTag(kLayerIgnoreAnchorPoint) @@ -596,42 +542,39 @@ local function LayerIgnoreAnchorPointRot() pLayer:ignoreAnchorPointForPosition(not ignore) end - local item = CCMenuItemFont:create("Toogle ignore anchor point") + local item = cc.MenuItemFont:create("Toogle ignore anchor point") item:registerScriptTapHandler(onToggle) - local menu = CCMenu:createWithItem(item) + local menu = cc.Menu:create(item) ret:addChild(menu) - menu:setPosition(CCPoint(s.width/2, s.height/2)) + menu:setPosition(cc.p(s.width/2, s.height/2)) return ret end -- LayerIgnoreAnchorPointScale local function LayerIgnoreAnchorPointScale() local ret = createLayerDemoLayer("IgnoreAnchorPoint - Scale", "Ignoring Anchor Point for scale") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local l = CCLayerColor:create(Color4B(255, 0, 0, 255), 200, 200) + local l = cc.LayerColor:create(cc.c4b(255, 0, 0, 255), 200, 200) - l:setAnchorPoint(CCPoint(0.5, 1.0)) - l:setPosition(CCPoint( s.width/2, s.height/2)) + l:setAnchorPoint(cc.p(0.5, 1.0)) + l:setPosition(cc.p( s.width/2, s.height/2)) - local scale = CCScaleBy:create(2, 2) - local back = tolua.cast(scale:reverse(), "CCScaleBy") - local arr = CCArray:create() - arr:addObject(scale) - arr:addObject(back) - local seq = CCSequence:create(arr) + local scale = cc.ScaleBy:create(2, 2) + local back = tolua.cast(scale:reverse(), "ScaleBy") + local seq = cc.Sequence:create(scale, back) - l:runAction(CCRepeatForever:create(seq)) + l:runAction(cc.RepeatForever:create(seq)) ret:addChild(l, 0, kLayerIgnoreAnchorPoint) - local child = CCSprite:create("Images/grossini.png") + local child = cc.Sprite:create("Images/grossini.png") l:addChild(child) local lsize = l:getContentSize() - child:setPosition(CCPoint(lsize.width/2, lsize.height/2)) + child:setPosition(cc.p(lsize.width/2, lsize.height/2)) local function onToggle(pObject) local pLayer = ret:getChildByTag(kLayerIgnoreAnchorPoint) @@ -640,40 +583,37 @@ local function LayerIgnoreAnchorPointScale() return ret end - local item = CCMenuItemFont:create("Toogle ignore anchor point") + local item = cc.MenuItemFont:create("Toogle ignore anchor point") item:registerScriptTapHandler(onToggle) - local menu = CCMenu:createWithItem(item) + local menu = cc.Menu:create(item) ret:addChild(menu) - menu:setPosition(CCPoint(s.width/2, s.height/2)) + menu:setPosition(cc.p(s.width/2, s.height/2)) return ret end local function LayerExtendedBlendOpacityTest() local ret = createLayerDemoLayer("Extended Blend & Opacity", "You should see 3 layers") - local layer1 = CCLayerGradient:create(Color4B(255, 0, 0, 255), Color4B(255, 0, 255, 255)) - layer1:setContentSize(CCSize(80, 80)) - layer1:setPosition(CCPoint(50,50)) + local layer1 = cc.LayerGradient:create(cc.c4b(255, 0, 0, 255), cc.c4b(255, 0, 255, 255)) + layer1:setContentSize(cc.size(80, 80)) + layer1:setPosition(cc.p(50,50)) ret:addChild(layer1) - local layer2 = CCLayerGradient:create(Color4B(0, 0, 0, 127), Color4B(255, 255, 255, 127)) - layer2:setContentSize(CCSize(80, 80)) - layer2:setPosition(CCPoint(100,90)) + local layer2 = cc.LayerGradient:create(cc.c4b(0, 0, 0, 127), cc.c4b(255, 255, 255, 127)) + layer2:setContentSize(cc.size(80, 80)) + layer2:setPosition(cc.p(100,90)) ret:addChild(layer2) - local layer3 = CCLayerGradient:create() - layer3:setContentSize(CCSize(80, 80)) - layer3:setPosition(CCPoint(150,140)) - layer3:setStartColor(Color3B(255, 0, 0)) - layer3:setEndColor(Color3B(255, 0, 255)) + local layer3 = cc.LayerGradient:create() + layer3:setContentSize(cc.size(80, 80)) + layer3:setPosition(cc.p(150,140)) + layer3:setStartColor(cc.c3b(255, 0, 0)) + layer3:setEndColor(cc.c3b(255, 0, 255)) layer3:setStartOpacity(255) layer3:setEndOpacity(255) - local blend = BlendFunc() - blend.src = GL_SRC_ALPHA - blend.dst = GL_ONE_MINUS_SRC_ALPHA - layer3:setBlendFunc(blend) + layer3:setBlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA) ret:addChild(layer3) return ret end @@ -681,8 +621,8 @@ end function LayerTestMain() cclog("LayerTestMain") Helper.index = 1 - CCDirector:getInstance():setDepthTest(true) - local scene = CCScene:create() + cc.Director:getInstance():setDepthTest(true) + local scene = cc.Scene:create() Helper.createFunctionTable = { LayerTestCascadingOpacityA, diff --git a/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua b/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua index 1099f5635e..a68bb24f2c 100644 --- a/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua +++ b/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua @@ -19,6 +19,11 @@ require "luaScript/CurrentLanguageTest/CurrentLanguageTest" require "luaScript/DrawPrimitivesTest/DrawPrimitivesTest" require "luaScript/EffectsTest/EffectsTest" require "luaScript/EffectsAdvancedTest/EffectsAdvancedTest" +require "luaScript/FontTest/FontTest" +require "luaScript/IntervalTest/IntervalTest" +require "luaScript/KeypadTest/KeypadTest" +require "luaScript/LabelTest/LabelTest" +require "luaScript/LayerTest/LayerTest" --[[ require "luaScript/TransitionsTest/TransitionsTest" @@ -28,23 +33,19 @@ require "luaScript/MotionStreakTest/MotionStreakTest" require "luaScript/NodeTest/NodeTest" require "luaScript/TouchesTest/TouchesTest" require "luaScript/SpriteTest/SpriteTest" -require "luaScript/LayerTest/LayerTest" + require "luaScript/PerformanceTest/PerformanceTest" -require "luaScript/LabelTest/LabelTest" require "luaScript/ParallaxTest/ParallaxTest" require "luaScript/TileMapTest/TileMapTest" require "luaScript/MenuTest/MenuTest" -require "luaScript/IntervalTest/IntervalTest" require "luaScript/SceneTest/SceneTest" require "luaScript/Texture2dTest/Texture2dTest" require "luaScript/RenderTextureTest/RenderTextureTest" require "luaScript/ZwoptexTest/ZwoptexTest" -require "luaScript/FontTest/FontTest" require "luaScript/UserDefaultTest/UserDefaultTest" require "luaScript/ExtensionTest/ExtensionTest" require "luaScript/AccelerometerTest/AccelerometerTest" -require "luaScript/KeypadTest/KeypadTest" require "luaScript/OpenGLTest/OpenGLTest" ]]-- diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id index 452cf41355..3199a451d6 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id @@ -1 +1 @@ -8115474f6f2838b3226e1075c612086088005bbd \ No newline at end of file +2a962b5abd27e8a47e73534fe2e521e181cc64be \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.hpp b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.hpp index 0bf4dbb702..69abad2a2d 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.hpp +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.hpp @@ -2000,6 +2000,7 @@ int register_all_cocos2dx(lua_State* tolua_S); + #endif // __cocos2dx_h__ diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id index b43bd36ea1..1ac1962780 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id @@ -1 +1 @@ -1df451e47e5e21c6430adcd93e76253dac5dcb14 \ No newline at end of file +4b98d069e4cc8f6af4dc2c64c6ec3fa2590bd927 \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id index 170076ab1a..f01619e02a 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id @@ -1 +1 @@ -9febc607103481a54085d37c4779c1d04bcf457c \ No newline at end of file +a63246415c81d091a2eb88c4ba396b6d3c80c027 \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.hpp b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.hpp index 021fd1c6bf..a2f3e2a6d3 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.hpp +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.hpp @@ -262,6 +262,8 @@ int register_all_cocos2dx_extension(lua_State* tolua_S); + + diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto_api.js b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto_api.js index a6cffbd414..da9e2d08bd 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto_api.js +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto_api.js @@ -1168,6 +1168,13 @@ getRootNode : function () {}, */ addDocumentOutletNode : function () {}, +/** + * @method getSequenceDuration + * @return A value converted from C/C++ "float" + * @param {const char*} + */ +getSequenceDuration : function () {}, + /** * @method addDocumentCallbackNode * @param {cocos2d::Node*} @@ -1187,6 +1194,13 @@ setCallFunc : function () {}, */ runAnimationsForSequenceNamed : function () {}, +/** + * @method getSequenceId + * @return A value converted from C/C++ "int" + * @param {const char*} + */ +getSequenceId : function () {}, + /** * @method getDocumentCallbackNodes * @return A value converted from C/C++ "cocos2d::Array*" diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_manual.cpp b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_manual.cpp index a56053b9d1..372407218f 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_manual.cpp +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_manual.cpp @@ -290,7 +290,47 @@ tolua_lerror: #endif return 0; } -//tolua_cocos2d_Menu_create + +static int tolua_cocos2d_MenuItemToggle_create(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertable(tolua_S,1,"MenuItemToggle",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + if(1 == argc) + { + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,2,"MenuItem",0,&tolua_err) ) + { + goto tolua_lerror; + } +#endif + MenuItem* item = (MenuItem*) tolua_tousertype(tolua_S,2,0); + MenuItemToggle* tolua_ret = (MenuItemToggle*) MenuItemToggle::create(item); + 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,"MenuItemToggle"); + return 1; + } + + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); + return 0; +#endif +} + static int tolua_cocos2d_MenuItem_registerScriptTapHandler(lua_State* tolua_S) { if (NULL == tolua_S) @@ -494,6 +534,90 @@ tolua_lerror: #endif } +int tolua_cocos2d_Layer_registerScriptKeypadHandler(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + Layer* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"Layer",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(tolua_S,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) + { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Layer_registerScriptKeypadHandler'\n", NULL); + return 0; + } +#endif + + if (1 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err)) { + goto tolua_lerror; + } +#endif + LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0)); + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, ScriptHandlerMgr::kKeypadHandler); + return 0; + } + + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'registerScriptKeypadHandler'.",&tolua_err); + return 0; +#endif +} + +int tolua_cocos2d_Layer_unregisterScriptKeypadHandler(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + Layer* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"Layer",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(tolua_S,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) + { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Layer_unregisterScriptKeypadHandler'\n", NULL); + return 0; + } +#endif + + if (0 == argc) + { + ScriptHandlerMgr::getInstance()->removeObjectHandler(self, ScriptHandlerMgr::kKeypadHandler); + return 0; + } + + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'unregisterScriptKeypadHandler'.",&tolua_err); + return 0; +#endif +} + int tolua_cocos2d_Layer_registerScriptAccelerateHandler(lua_State* tolua_S) { if (NULL == tolua_S) @@ -778,14 +902,20 @@ static int tolua_cocos2d_Node_registerScriptHandler(lua_State* tolua_S) return 0; int argc = 0; - Node* node = nullptr; + Node* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"Node",0,&tolua_err)) goto tolua_lerror; #endif - node = static_cast(tolua_tousertype(tolua_S,1,0)); + self = static_cast(tolua_tousertype(tolua_S,1,0)); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Node_registerScriptHandler'\n", NULL); + return 0; + } +#endif argc = lua_gettop(tolua_S) - 1; @@ -797,7 +927,7 @@ static int tolua_cocos2d_Node_registerScriptHandler(lua_State* tolua_S) #endif LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0)); - ScriptHandlerMgr::getInstance()->addObjectHandler((void*)node, handler, ScriptHandlerMgr::kNodeHandler); + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, ScriptHandlerMgr::kNodeHandler); return 0; } @@ -818,20 +948,26 @@ static int tolua_cocos2d_Node_unregisterScriptHandler(lua_State* tolua_S) return 0; int argc = 0; - Node* node = nullptr; + Node* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"Node",0,&tolua_err)) goto tolua_lerror; #endif - node = static_cast(tolua_tousertype(tolua_S,1,0)); + self = static_cast(tolua_tousertype(tolua_S,1,0)); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Node_unregisterScriptHandler'\n", NULL); + return 0; + } +#endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { - ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)node, ScriptHandlerMgr::kNodeHandler); + ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)self, ScriptHandlerMgr::kNodeHandler); return 0; } @@ -845,6 +981,95 @@ tolua_lerror: #endif } + +static int tolua_Cocos2d_Node_scheduleUpdateWithPriorityLua(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + Node* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"Node",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(tolua_S,1,0)); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_Cocos2d_Node_scheduleUpdateWithPriorityLua'\n", NULL); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 2) + { +#if COCOS2D_DEBUG >= 1 + if(!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err)) + goto tolua_lerror; +#endif + + LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0)); + int priority = 0; + if (luaval_to_int32(tolua_S, 3, &priority)) + { + self->scheduleUpdateWithPriorityLua(handler,priority); + } + return 0; + } + + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 2); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'scheduleUpdateWithPriorityLua'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2d_Node_unscheduleUpdate(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + Node* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"Node",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(tolua_S,1,0)); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Node_unscheduleUpdate'\n", NULL); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (0 == argc) + { + self->unscheduleUpdate(); + return 0; + } + + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'unscheduleUpdate'.",&tolua_err); + return 0; +#endif +} + static int tolua_cocos2d_Spawn_create(lua_State* tolua_S) { if (NULL == tolua_S) @@ -1360,6 +1585,10 @@ static int tolua_cocos2dx_Sprite_setBlendFunc(lua_State* tolua_S) return tolua_cocos2dx_setBlendFunc(tolua_S,"Sprite"); } +static int tolua_cocos2dx_LayerColor_setBlendFunc(lua_State* tolua_S) +{ + return tolua_cocos2dx_setBlendFunc(tolua_S,"LayerColor"); +} int register_all_cocos2dx_manual(lua_State* tolua_S) { @@ -1413,6 +1642,15 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) lua_pushcfunction(tolua_S,tolua_cocos2d_MenuItemSprite_create); lua_rawset(tolua_S,-3); } + + lua_pushstring(tolua_S, "MenuItemToggle"); + lua_rawget(tolua_S,LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"create"); + lua_pushcfunction(tolua_S,tolua_cocos2d_MenuItemToggle_create); + lua_rawset(tolua_S,-3); + } lua_pushstring(tolua_S, "Menu"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); @@ -1433,6 +1671,12 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) lua_pushstring(tolua_S,"unregisterScriptHandler"); lua_pushcfunction(tolua_S,tolua_cocos2d_Node_unregisterScriptHandler); lua_rawset(tolua_S, -3); + lua_pushstring(tolua_S,"scheduleUpdateWithPriorityLua"); + lua_pushcfunction(tolua_S,tolua_Cocos2d_Node_scheduleUpdateWithPriorityLua); + lua_rawset(tolua_S, -3); + lua_pushstring(tolua_S,"unscheduleUpdate"); + lua_pushcfunction(tolua_S,tolua_cocos2d_Node_unscheduleUpdate); + lua_rawset(tolua_S, -3); } lua_pushstring(tolua_S,"Layer"); @@ -1445,12 +1689,12 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) lua_pushstring(tolua_S, "unregisterScriptTouchHandler"); lua_pushcfunction(tolua_S,tolua_cocos2d_Layer_unregisterScriptTouchHandler); lua_rawset(tolua_S, -3); -// lua_pushstring(lua_S, "registerScriptKeypadHandler"); -// lua_pushcfunction(lua_S, tolua_Cocos2d_registerScriptKeypadHandler00); -// lua_rawset(lua_S, -3); -// lua_pushstring(lua_S, "unregisterScriptKeypadHandler"); -// lua_pushcfunction(lua_S, tolua_Cocos2d_unregisterScriptKeypadHandler00); -// lua_rawset(lua_S, -3); + lua_pushstring(tolua_S, "registerScriptKeypadHandler"); + lua_pushcfunction(tolua_S, tolua_cocos2d_Layer_registerScriptKeypadHandler); + lua_rawset(tolua_S, -3); + lua_pushstring(tolua_S, "unregisterScriptKeypadHandler"); + lua_pushcfunction(tolua_S, tolua_cocos2d_Layer_unregisterScriptKeypadHandler); + lua_rawset(tolua_S, -3); lua_pushstring(tolua_S, "registerScriptAccelerateHandler"); lua_pushcfunction(tolua_S, tolua_cocos2d_Layer_registerScriptAccelerateHandler); lua_rawset(tolua_S, -3); @@ -1561,5 +1805,14 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) lua_rawset(tolua_S,-3); } + lua_pushstring(tolua_S,"LayerColor"); + lua_rawget(tolua_S,LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"setBlendFunc"); + lua_pushcfunction(tolua_S,tolua_cocos2dx_LayerColor_setBlendFunc); + lua_rawset(tolua_S,-3); + } + return 0; } \ No newline at end of file diff --git a/scripting/lua/script/Cocos2d.lua b/scripting/lua/script/Cocos2d.lua index ef62ea8274..fff43e987d 100644 --- a/scripting/lua/script/Cocos2d.lua +++ b/scripting/lua/script/Cocos2d.lua @@ -8,6 +8,19 @@ function cc.p(_x,_y) return { x = _x, y = _y } end +function cc.getPLength(pt) + return math.sqrt( pt.x * pt.x + pt.y * pt.y ); +end + +function cc.pNormalize(pt) + local length = cc.getPointLength(pt) + if 0 == length then + return { x = 1.0,y = 0.0 } + end + + return { x = pt.x / length, y = pt.y / length } +end + --Size function cc.size( _width,_height ) return { width = _width, height = _height } @@ -33,4 +46,15 @@ function cc.c4f( _r,_g,_b,_a ) return { r = _r, g = _g, b = _b, a = _a } end +function cc.rectContainsPoint( rect, point ) + local ret = false + + if (point.x >= rect.x) and (point.x <= rect.x + rect.width) and + (point.y >= rect.y) and (point.y <= rect.y + rect.height) then + ret = true + end + + return ret; +end + From e8809b2b150fe76bf5c49519c837361f2566a6eb Mon Sep 17 00:00:00 2001 From: godyZ Date: Fri, 16 Aug 2013 11:02:44 +0800 Subject: [PATCH 023/126] issue #2533:add ATITC compressed texture support soft decode test in Win32, ios, Mac. device decode test in HTC G14 Adreno 220 GPU. --- .../project.pbxproj.REMOVED.git-id | 2 +- cocos2dx/Android.mk | 7 +- cocos2dx/CCConfiguration.cpp | 11 +- cocos2dx/CCConfiguration.h | 6 +- cocos2dx/platform/CCImage.h | 6 +- cocos2dx/platform/CCImageCommon_cpp.h | 184 ++++++++++++++++- .../third_party/common/atitc/atitc.cpp | 195 ++++++++++++++++++ .../platform/third_party/common/atitc/atitc.h | 48 +++++ cocos2dx/proj.linux/Makefile | 2 + cocos2dx/proj.win32/cocos2d.vcxproj | 2 + cocos2dx/proj.win32/cocos2d.vcxproj.filters | 6 + cocos2dx/textures/CCTexture2D.cpp | 21 +- cocos2dx/textures/CCTexture2D.h | 7 +- cocos2dx/textures/CCTextureCache.cpp | 2 +- .../Classes/Texture2dTest/Texture2dTest.cpp | 66 +++++- .../Classes/Texture2dTest/Texture2dTest.h | 33 +++ 16 files changed, 581 insertions(+), 17 deletions(-) create mode 100644 cocos2dx/platform/third_party/common/atitc/atitc.cpp create mode 100644 cocos2dx/platform/third_party/common/atitc/atitc.h diff --git a/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id b/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id index 9e007ea849..f42d9c3506 100644 --- a/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -1feddf59d7fbc2b063a496bbf4a4770d0ac4435e \ No newline at end of file +846fbc5706592dfcb9b01212873d1f438558e992 \ No newline at end of file diff --git a/cocos2dx/Android.mk b/cocos2dx/Android.mk index f2f22e0231..736416a345 100644 --- a/cocos2dx/Android.mk +++ b/cocos2dx/Android.mk @@ -131,6 +131,7 @@ textures/CCTextureAtlas.cpp \ textures/CCTextureCache.cpp \ platform/third_party/common/etc/etc1.cpp\ platform/third_party/common/s3tc/s3tc.cpp\ +platform/third_party/common/atitc/atitc.cpp\ tilemap_parallax_nodes/CCParallaxNode.cpp \ tilemap_parallax_nodes/CCTMXLayer.cpp \ tilemap_parallax_nodes/CCTMXObjectGroup.cpp \ @@ -146,14 +147,16 @@ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) \ $(LOCAL_PATH)/kazmath/include \ $(LOCAL_PATH)/platform/android \ $(LOCAL_PATH)/platform/third_party/common/etc\ - $(LOCAL_PATH)/platform/third_party/common/s3tc + $(LOCAL_PATH)/platform/third_party/common/s3tc\ + $(LOCAL_PATH)/platform/third_party/common/atitc LOCAL_C_INCLUDES := $(LOCAL_PATH) \ $(LOCAL_PATH)/include \ $(LOCAL_PATH)/kazmath/include \ $(LOCAL_PATH)/platform/android \ $(LOCAL_PATH)/platform/third_party/common/etc\ - $(LOCAL_PATH)/platform/third_party/common/s3tc + $(LOCAL_PATH)/platform/third_party/common/s3tc\ + $(LOCAL_PATH)/platform/third_party/common/atitc LOCAL_LDLIBS := -lGLESv2 \ diff --git a/cocos2dx/CCConfiguration.cpp b/cocos2dx/CCConfiguration.cpp index 29f797983d..024b09b552 100644 --- a/cocos2dx/CCConfiguration.cpp +++ b/cocos2dx/CCConfiguration.cpp @@ -46,6 +46,7 @@ Configuration::Configuration() , _supportsPVRTC(false) , _supportsETC(false) , _supportsS3TC(false) +, _supportsATITC(false) , _supportsNPOT(false) , _supportsBGRA8888(false) , _supportsDiscardFramebuffer(false) @@ -131,7 +132,10 @@ void Configuration::gatherGPUInfo() _valueDict->setObject(Bool::create(_supportsETC), "gl.supports_ETC"); _supportsS3TC = checkForGLExtension("GL_EXT_texture_compression_s3tc"); - _valueDict->setObject( Bool::create(_supportsS3TC), "gl.supports_S3TC"); + _valueDict->setObject(Bool::create(_supportsS3TC), "gl.supports_S3TC"); + + _supportsATITC = checkForGLExtension("GL_AMD_compressed_ATC_texture"); + _valueDict->setObject(Bool::create(_supportsATITC), "gl.supports_ATITC"); _supportsPVRTC = checkForGLExtension("GL_IMG_texture_compression_pvrtc"); _valueDict->setObject(Bool::create(_supportsPVRTC), "gl.supports_PVRTC"); @@ -238,6 +242,11 @@ bool Configuration::supportsS3TC() const return _supportsS3TC; } +bool Configuration::supportsATITC() const +{ + return _supportsATITC; +} + bool Configuration::supportsBGRA8888() const { return _supportsBGRA8888; diff --git a/cocos2dx/CCConfiguration.h b/cocos2dx/CCConfiguration.h index 4c7f4de33c..eecfc34d62 100644 --- a/cocos2dx/CCConfiguration.h +++ b/cocos2dx/CCConfiguration.h @@ -88,7 +88,10 @@ public: bool supportsETC() const; /** Whether or not S3TC Texture Compressed is supported */ - bool supportsS3TC(void ) const; + bool supportsS3TC() const; + + /** Whether or not ATITC Texture Compressed is supported */ + bool supportsATITC() const; /** Whether or not BGRA8888 textures are supported. @since v0.99.2 @@ -148,6 +151,7 @@ protected: bool _supportsPVRTC; bool _supportsETC; bool _supportsS3TC; + bool _supportsATITC; bool _supportsNPOT; bool _supportsBGRA8888; bool _supportsDiscardFramebuffer; diff --git a/cocos2dx/platform/CCImage.h b/cocos2dx/platform/CCImage.h index 03d275a61a..d3e5a26044 100644 --- a/cocos2dx/platform/CCImage.h +++ b/cocos2dx/platform/CCImage.h @@ -77,6 +77,8 @@ public: ETC, //! S3TC S3TC, + //! ATITC + ATITC, //! Raw Data RAW_DATA, //! Unknown format @@ -194,6 +196,7 @@ protected: bool initWithPVRv3Data(const void *data, int dataLen); bool initWithETCData(const void *data, int dataLen); bool initWithS3TCData(const void *data, int dataLen); + bool initWithATITCData(const void *data, int dataLen); bool saveImageToPNG(const char *filePath, bool isToRGB = true); bool saveImageToJPG(const char *filePath); @@ -238,7 +241,8 @@ private: bool isWebp(const void *data, int dataLen); bool isPvr(const void *data, int dataLen); bool isEtc(const void *data, int dataLen); - bool isS3TC(const void *data,int dataLen); + bool isS3TC(const void *data, int dataLen); + bool isATITC(const void *data, int dataLen); }; diff --git a/cocos2dx/platform/CCImageCommon_cpp.h b/cocos2dx/platform/CCImageCommon_cpp.h index efd0dc4d46..0d1cfaa5ae 100644 --- a/cocos2dx/platform/CCImageCommon_cpp.h +++ b/cocos2dx/platform/CCImageCommon_cpp.h @@ -41,6 +41,7 @@ extern "C" #include "jpeglib.h" } #include "third_party/common/s3tc/s3tc.h" +#include "third_party/common/atitc/atitc.h" #if defined(__native_client__) || defined(EMSCRIPTEN) // TODO(sbc): I'm pretty sure all platforms should be including // webph headers in this way. @@ -56,6 +57,7 @@ extern "C" #include "CCConfiguration.h" #include "support/ccUtils.h" #include "support/zip_support/ZipUtils.h" +#include "CCGL.h" #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) #include "platform/android/CCFileUtilsAndroid.h" #endif @@ -313,7 +315,33 @@ namespace } //s3tc struct end -///////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////// + +//struct and data for atitc(ktx) struct +namespace +{ + struct ATITCTexHeader + { + //HEADER + char identifier[12]; + uint32_t endianness; + uint32_t glType; + uint32_t glTypeSize; + uint32_t glFormat; + uint32_t glInternalFormat; + uint32_t glBaseInternalFormat; + uint32_t pixelWidth; + uint32_t pixelHeight; + uint32_t pixelDepth; + uint32_t numberOfArrayElements; + uint32_t numberOfFaces; + uint32_t numberOfMipmapLevels; + uint32_t bytesOfKeyValueData; + }; +} +//atittc struct end + +////////////////////////////////////////////////////////////////////////// namespace { @@ -457,6 +485,8 @@ bool Image::initWithImageData(const void * data, int dataLen) return initWithETCData(data, dataLen); case Format::S3TC: return initWithS3TCData(data, dataLen); + case Format::ATITC: + return initWithATITCData(data, dataLen); default: CCAssert(false, "unsupport image format!"); @@ -491,7 +521,7 @@ bool Image::isS3TC(const void *data, int dataLen) S3TCTexHeader *header = (S3TCTexHeader *)data; - if (strncmp(header->fileCode, "DDS", 3)!= 0) + if (strncmp(header->fileCode, "DDS", 3) != 0) { CCLOG("cocos2d: the file is not a dds file!"); return false; @@ -499,6 +529,18 @@ bool Image::isS3TC(const void *data, int dataLen) return true; } +bool Image::isATITC(const void *data, int dataLen) +{ + ATITCTexHeader *header = (ATITCTexHeader *)data; + + if (strncmp(&header->identifier[1], "KTX", 3) != 0) + { + CCLOG("cocos3d: the file is not a ktx file!"); + return false; + } + return true; +} + bool Image::isJpg(const void *data, int dataLen) { if (dataLen <= 4) @@ -576,6 +618,9 @@ Image::Format Image::detectFormat(const void* data, int dataLen) }else if (isS3TC(data, dataLen)) { return Format::S3TC; + }else if (isATITC(data, dataLen)) + { + return Format::ATITC; } else { @@ -1412,7 +1457,7 @@ bool Image::initWithS3TCData(const void *data, int dataLen) _width = header->ddsd.width; _height = header->ddsd.height; _numberOfMipmaps = header->ddsd.DUMMYUNIONNAMEN2.mipMapCount; - _dataLen = 0; + _dataLen = 0; int blockSize = (FOURCC_DXT1 == header->ddsd.DUMMYUNIONNAMEN4.ddpfPixelFormat.fourCC) ? 8 : 16; /* caculate the dataLen */ @@ -1513,6 +1558,139 @@ bool Image::initWithS3TCData(const void *data, int dataLen) return true; } + +//----------------------------------------------------------------------------------------------- +#define GL_ATC_RGB_AMD 0x8C92 +#define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD 0x8C93 +#define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE + +bool Image::initWithATITCData(const void *data, int dataLen) +{ + /* load the .ktx file */ + ATITCTexHeader *header = (ATITCTexHeader *)data; + _width = header->pixelWidth; + _height = header->pixelHeight; + _numberOfMipmaps = header->numberOfMipmapLevels; + + int blockSize = 0; + switch (header->glInternalFormat) + { + case GL_ATC_RGB_AMD: + blockSize = 8; + break; + case GL_ATC_RGBA_EXPLICIT_ALPHA_AMD: + blockSize = 16; + break; + case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: + blockSize = 16; + break; + default: + break; + } + + /* pixelData point to the compressed data address */ + unsigned char *pixelData = (unsigned char *)data + sizeof(ATITCTexHeader) + header->bytesOfKeyValueData + 4; + + /* caculate the dataLen */ + int width = _width; + int height = _height; + + if (Configuration::getInstance()->supportsATITC()) //compressed data length + { + _dataLen = dataLen - sizeof(ATITCTexHeader) - header->bytesOfKeyValueData - 4; + _data = new unsigned char [_dataLen]; + memcpy((void *)_data,(void *)pixelData , _dataLen); + } + else //decompressed data length + { + for (unsigned int i = 0; i < _numberOfMipmaps && (width || height); ++i) + { + if (width == 0) width = 1; + if (height == 0) height = 1; + + _dataLen += (height * width *4); + + width >>= 1; + height >>= 1; + } + _data = new unsigned char [_dataLen]; + } + + /* load the mipmaps */ + int encodeOffset = 0; + int decodeOffset = 0; + width = _width; height = _height; + + for (unsigned int i = 0; i < _numberOfMipmaps && (width || height); ++i) + { + if (width == 0) width = 1; + if (height == 0) height = 1; + + int size = ((width+3)/4)*((height+3)/4)*blockSize; + + if (Configuration::getInstance()->supportsATITC()) + { + /* decode texture throught hardware */ + + CCLOG("this is atitc H decode"); + + switch (header->glInternalFormat) + { + case GL_ATC_RGB_AMD: + _renderFormat = Texture2D::PixelFormat::ATC_RGB; + break; + case GL_ATC_RGBA_EXPLICIT_ALPHA_AMD: + _renderFormat = Texture2D::PixelFormat::ATC_EXPLICIT_ALPHA; + break; + case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: + _renderFormat = Texture2D::PixelFormat::ATC_INTERPOLATED_ALPHA; + break; + default: + break; + } + + _mipmaps[i].address = (unsigned char *)_data + encodeOffset; + _mipmaps[i].len = size; + } + else + { + /* if it is not gles or device do not support ATITC, decode texture by software */ + + int bytePerPixel = 4; + unsigned int stride = width * bytePerPixel; + _renderFormat = Texture2D::PixelFormat::RGBA8888; + + std::vector decodeImageData(stride * height); + switch (header->glInternalFormat) + { + case GL_ATC_RGB_AMD: + atitc_decode(pixelData + encodeOffset, &decodeImageData[0], width, height, ATITCDecodeFlag::ATC_RGB); + break; + case GL_ATC_RGBA_EXPLICIT_ALPHA_AMD: + atitc_decode(pixelData + encodeOffset, &decodeImageData[0], width, height, ATITCDecodeFlag::ATC_EXPLICIT_ALPHA); + break; + case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: + atitc_decode(pixelData + encodeOffset, &decodeImageData[0], width, height, ATITCDecodeFlag::ATC_INTERPOLATED_ALPHA); + break; + default: + break; + } + + _mipmaps[i].address = (unsigned char *)_data + decodeOffset; + _mipmaps[i].len = (stride * height); + memcpy((void *)_mipmaps[i].address, (void *)&decodeImageData[0], _mipmaps[i].len); + decodeOffset += stride * height; + } + + encodeOffset += (size + 4); + width >>= 1; + height >>= 1; + } + /* end load the mipmaps */ + + return true; +} + bool Image::initWithPVRData(const void *data, int dataLen) { return initWithPVRv2Data(data, dataLen) || initWithPVRv3Data(data, dataLen); diff --git a/cocos2dx/platform/third_party/common/atitc/atitc.cpp b/cocos2dx/platform/third_party/common/atitc/atitc.cpp new file mode 100644 index 0000000000..75774e4748 --- /dev/null +++ b/cocos2dx/platform/third_party/common/atitc/atitc.cpp @@ -0,0 +1,195 @@ +/**************************************************************************** + Copyright (c) 2010 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "atitc.h" + +//Decode ATITC encode block to 4x4 RGB32 pixels +static void atitc_decode_block(uint8_t **blockData, + uint32_t *decodeBlockData, + unsigned int stride, + bool oneBitAlphaFlag, + uint64_t alpha, + ATITCDecodeFlag decodeFlag) +{ + unsigned int colorValue0 = 0 , colorValue1 = 0, initAlpha = (!oneBitAlphaFlag * 255u) << 24; + unsigned int rb0 = 0, rb1 = 0, rb2 = 0, rb3 = 0, g0 = 0, g1 = 0, g2 = 0, g3 = 0; + bool msb = 0; + + uint32_t colors[4], pixelsIndex = 0; + + /* load the two color values*/ + memcpy((void *)&colorValue0, *blockData, 2); + (*blockData) += 2; + + memcpy((void *)&colorValue1, *blockData, 2); + (*blockData) += 2; + + //extract the msb flag + msb = (colorValue0 & 0x8000); + + /* the channel is r5g6b5 , 16 bits */ + rb0 = (colorValue0 << 3 | colorValue0 << 9) & 0xf800f8; + rb1 = (colorValue1 << 3 | colorValue1 << 8) & 0xf800f8; + g0 = (colorValue0 << 6) & 0x00fc00; + g1 = (colorValue1 << 5) & 0x00fc00; + g0 += (g0 >> 6) & 0x000300; + g1 += (g1 >> 6) & 0x000300; + + /* interpolate the other two color values */ + if (!msb) + { + colors[0] = rb0 + g0 + initAlpha; + colors[3] = rb1 + g1 + initAlpha; + + rb2 = (((2*rb0 + rb1) * 21) >> 6) & 0xff00ff; + rb3 = (((2*rb1 + rb0) * 21) >> 6) & 0xff00ff; + g2 = (((2*g0 + g1 ) * 21) >> 6) & 0x00ff00; + g3 = (((2*g1 + g0 ) * 21) >> 6) & 0x00ff00; + + colors[2] = rb3 + g3 + initAlpha; + colors[1] = rb2 + g2 + initAlpha; + } + else + { + colors[2] = rb0 + g0 + initAlpha; + colors[3] = rb1 + g1 + initAlpha; + + rb2 = (rb0 - (rb1 >> 2)) & 0xff00ff; + g2 = (g0 - (g1 >> 2)) & 0x00ff00; + colors[0] = 0 ; + + colors[1] = rb2 + g2 + initAlpha; + } + + /*read the pixelsIndex , 2bits per pixel, 4 bytes */ + memcpy((void*)&pixelsIndex, *blockData, 4); + (*blockData) += 4; + + if (ATITCDecodeFlag::ATC_INTERPOLATED_ALPHA == decodeFlag) + { + // atitc_interpolated_alpha use interpolate alpha + // 8-Alpha block: derive the other six alphas. + // Bit code 000 = alpha0, 001 = alpha1, other are interpolated. + + unsigned int alphaArray[8]; + + alphaArray[0] = (alpha ) & 0xff ; + alphaArray[1] = (alpha >> 8) & 0xff ; + + if (alphaArray[0] >= alphaArray[1]) + { + alphaArray[2] = (alphaArray[0]*6 + alphaArray[1]*1) / 7; + alphaArray[3] = (alphaArray[0]*5 + alphaArray[1]*2) / 7; + alphaArray[4] = (alphaArray[0]*4 + alphaArray[1]*3) / 7; + alphaArray[5] = (alphaArray[0]*3 + alphaArray[1]*4) / 7; + alphaArray[6] = (alphaArray[0]*2 + alphaArray[1]*5) / 7; + alphaArray[7] = (alphaArray[0]*1 + alphaArray[1]*6) / 7; + } + else if (alphaArray[0] < alphaArray[1]) + { + alphaArray[2] = (alphaArray[0]*4 + alphaArray[1]*1) / 5; + alphaArray[3] = (alphaArray[0]*3 + alphaArray[1]*2) / 5; + alphaArray[4] = (alphaArray[0]*2 + alphaArray[1]*3) / 5; + alphaArray[5] = (alphaArray[0]*1 + alphaArray[1]*4) / 5; + alphaArray[6] = 0; + alphaArray[7] = 255; + } + + // read the flowing 48bit indices (16*3) + alpha >>= 16; + + for (int y = 0; y < 4; ++y) + { + for (int x = 0; x < 4; ++x) + { + decodeBlockData[x] = (alphaArray[alpha & 5] << 24) + colors[pixelsIndex & 3]; + pixelsIndex >>= 2; + alpha >>= 3; + } + decodeBlockData += stride; + } + } //if (atc_interpolated_alpha == comFlag) + else + { + /* atc_rgb atc_explicit_alpha use explicit alpha */ + + for (int y = 0; y < 4; ++y) + { + for (int x = 0; x < 4; ++x) + { + initAlpha = (alpha & 0x0f) << 28; + initAlpha += initAlpha >> 4; + decodeBlockData[x] = initAlpha + colors[pixelsIndex & 3]; + pixelsIndex >>= 2; + alpha >>= 4; + } + decodeBlockData += stride; + } + } +} + +//Decode ATITC encode data to RGB32 +void atitc_decode(uint8_t *encodeData, //in_data + uint8_t *decodeData, //out_data + const unsigned int pixelsWidth, + const unsigned int pixelsHeight, + ATITCDecodeFlag decodeFlag) +{ + uint32_t *decodeBlockData = (uint32_t *)decodeData; + + for (int block_y = 0; block_y < pixelsHeight / 4; ++block_y, decodeBlockData += 3 * pixelsWidth) //stride = 3*width + { + for (int block_x = 0; block_x < pixelsWidth / 4; ++block_x, decodeBlockData += 4) //skip 4 pixels + { + uint64_t blockAlpha = 0; + + switch (decodeFlag) + { + case ATITCDecodeFlag::ATC_RGB: + { + atitc_decode_block(&encodeData, decodeBlockData, pixelsWidth, 0, 0LL, ATITCDecodeFlag::ATC_RGB); + } + break; + case ATITCDecodeFlag::ATC_EXPLICIT_ALPHA: + { + memcpy((void *)&blockAlpha, encodeData, 8); + encodeData += 8; + atitc_decode_block(&encodeData, decodeBlockData, pixelsWidth, 1, blockAlpha, ATITCDecodeFlag::ATC_EXPLICIT_ALPHA); + } + break; + case ATITCDecodeFlag::ATC_INTERPOLATED_ALPHA: + { + memcpy((void *)&blockAlpha, encodeData, 8); + encodeData += 8; + atitc_decode_block(&encodeData, decodeBlockData, pixelsWidth, 1, blockAlpha, ATITCDecodeFlag::ATC_INTERPOLATED_ALPHA); + } + break; + default: + break; + }//switch + }//for block_x + }//for block_y +} + + diff --git a/cocos2dx/platform/third_party/common/atitc/atitc.h b/cocos2dx/platform/third_party/common/atitc/atitc.h new file mode 100644 index 0000000000..fff8927695 --- /dev/null +++ b/cocos2dx/platform/third_party/common/atitc/atitc.h @@ -0,0 +1,48 @@ +/**************************************************************************** + Copyright (c) 2010 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + + +#ifndef COCOS2DX_PLATFORM_THIRDPARTY_ATITC_ +#define COCOS2DX_PLATFORM_THIRDPARTY_ATITC_ + +#include "CCStdC.h" + +enum class ATITCDecodeFlag +{ + ATC_RGB = 1, + ATC_EXPLICIT_ALPHA = 3, + ATC_INTERPOLATED_ALPHA = 5, +}; + +//Decode ATITC encode data to RGB32 +void atitc_decode(uint8_t *encode_data, + uint8_t *decode_data, + const unsigned int pixelsWidth, + const unsigned int pixelsHeight, + ATITCDecodeFlag decodeFlag + ); + + +#endif /* defined(COCOS2DX_PLATFORM_THIRDPARTY_ATITC_) */ + diff --git a/cocos2dx/proj.linux/Makefile b/cocos2dx/proj.linux/Makefile index 04c127cc94..d9d41dbcc0 100644 --- a/cocos2dx/proj.linux/Makefile +++ b/cocos2dx/proj.linux/Makefile @@ -4,6 +4,7 @@ INCLUDES += \ -I../platform/third_party/linux/libfreetype2 \ -I../platform/third_party/common/etc \ -I../platform/third_party/common/s3tc \ + -I../platform/third_party/common/atitc \ -I../../extensions \ -I../../extensions/CCBReader \ -I../../extensions/GUI/CCControlExtension \ @@ -90,6 +91,7 @@ SOURCES = ../actions/CCAction.cpp \ ../platform/linux/CCDevice.cpp \ ../platform/third_party/common/etc/etc1.cpp \ ../platform/third_party/common/s3tc/s3tc.cpp\ +../platform/third_party/common/atitc/atitc.cpp\ ../script_support/CCScriptSupport.cpp \ ../sprite_nodes/CCAnimation.cpp \ ../sprite_nodes/CCAnimationCache.cpp \ diff --git a/cocos2dx/proj.win32/cocos2d.vcxproj b/cocos2dx/proj.win32/cocos2d.vcxproj index 5f5a799554..53557732f2 100644 --- a/cocos2dx/proj.win32/cocos2d.vcxproj +++ b/cocos2dx/proj.win32/cocos2d.vcxproj @@ -210,6 +210,7 @@ xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir + @@ -372,6 +373,7 @@ xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir + diff --git a/cocos2dx/proj.win32/cocos2d.vcxproj.filters b/cocos2dx/proj.win32/cocos2d.vcxproj.filters index 260f7c51f4..00a9b262b6 100644 --- a/cocos2dx/proj.win32/cocos2d.vcxproj.filters +++ b/cocos2dx/proj.win32/cocos2d.vcxproj.filters @@ -518,6 +518,9 @@ platform + + platform + @@ -1045,5 +1048,8 @@ platform + + platform + \ No newline at end of file diff --git a/cocos2dx/textures/CCTexture2D.cpp b/cocos2dx/textures/CCTexture2D.cpp index 827fcfdf64..438b08cb47 100644 --- a/cocos2dx/textures/CCTexture2D.cpp +++ b/cocos2dx/textures/CCTexture2D.cpp @@ -85,7 +85,21 @@ namespace { #ifdef GL_COMPRESSED_RGBA_S3TC_DXT5_EXT PixelFormatInfoMapValue(Texture2D::PixelFormat::S3TC_DXT5, Texture2D::PixelFormatInfo(GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, 0xFFFFFFFF, 0xFFFFFFFF, 8, true, false)), #endif - + +#ifdef GL_ATC_RGB_AMD + PixelFormatInfoMapValue(Texture2D::PixelFormat::ATC_RGB, Texture2D::PixelFormatInfo(GL_ATC_RGB_AMD, + 0xFFFFFFFF, 0xFFFFFFFF, 4, true, false)), +#endif + +#ifdef GL_ATC_RGBA_EXPLICIT_ALPHA_AMD + PixelFormatInfoMapValue(Texture2D::PixelFormat::ATC_EXPLICIT_ALPHA, Texture2D::PixelFormatInfo(GL_ATC_RGBA_EXPLICIT_ALPHA_AMD, + 0xFFFFFFFF, 0xFFFFFFFF, 8, true, false)), +#endif + +#ifdef GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD + PixelFormatInfoMapValue(Texture2D::PixelFormat::ATC_INTERPOLATED_ALPHA, Texture2D::PixelFormatInfo(GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD, + 0xFFFFFFFF, 0xFFFFFFFF, 8, true, false)), +#endif }; } @@ -552,7 +566,8 @@ bool Texture2D::initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, PixelFormat if (info.compressed && !Configuration::getInstance()->supportsPVRTC() && !Configuration::getInstance()->supportsETC() - && !Configuration::getInstance()->supportsS3TC()) + && !Configuration::getInstance()->supportsS3TC() + && !Configuration::getInstance()->supportsATITC()) { CCLOG("cocos2d: WARNING: PVRTC/ETC images are not supported"); return false; @@ -606,6 +621,7 @@ bool Texture2D::initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, PixelFormat // Specify OpenGL texture image int width = pixelsWide; int height = pixelsHigh; + for (int i = 0; i < mipmapsNum; ++i) { unsigned char *data = mipmaps[i].address; @@ -634,7 +650,6 @@ bool Texture2D::initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, PixelFormat width = MAX(width >> 1, 1); height = MAX(height >> 1, 1); - } _contentSize = Size((float)pixelsWide, (float)pixelsHigh); diff --git a/cocos2dx/textures/CCTexture2D.h b/cocos2dx/textures/CCTexture2D.h index 8874913330..cd4e870979 100644 --- a/cocos2dx/textures/CCTexture2D.h +++ b/cocos2dx/textures/CCTexture2D.h @@ -105,7 +105,12 @@ public: S3TC_DXT3, //! S3TC-compressed texture: S3TC_Dxt5 S3TC_DXT5, - + //! ATITC-compressed texture: ATC_RGB + ATC_RGB, + //! ATITC-compressed texture: ATC_EXPLICIT_ALPHA + ATC_EXPLICIT_ALPHA, + //! ATITC-compresed texture: ATC_INTERPOLATED_ALPHA + ATC_INTERPOLATED_ALPHA, //! Default texture format: AUTO DEFAULT = AUTO, diff --git a/cocos2dx/textures/CCTextureCache.cpp b/cocos2dx/textures/CCTextureCache.cpp index f034997930..99a4230a10 100644 --- a/cocos2dx/textures/CCTextureCache.cpp +++ b/cocos2dx/textures/CCTextureCache.cpp @@ -387,7 +387,7 @@ Texture2D* TextureCache::addUIImage(Image *image, const char *key) } } while (0); - + #if CC_ENABLE_CACHE_TEXTURE_DATA VolatileTexture::addImage(texture, image); #endif diff --git a/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp b/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp index 745ce80598..b1bd75cfc4 100644 --- a/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp +++ b/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp @@ -69,6 +69,10 @@ static std::function createFunctions[] = CL(TextureS3TCDxt3), CL(TextureS3TCDxt5), + CL(TextureATITCRGB), + CL(TextureATITCExplicit), + CL(TextureATITCInterpolated), + CL(TextureConvertRGB888), CL(TextureConvertRGBA8888), CL(TextureConvertI8), @@ -2026,6 +2030,7 @@ std::string TextureS3TCDxt1::subtitle() { return "S3TC dxt1 decode,one bit for Alpha"; } + //Implement of S3TC Dxt3 TextureS3TCDxt3::TextureS3TCDxt3() { @@ -2044,7 +2049,8 @@ std::string TextureS3TCDxt3::subtitle() { return "S3TC dxt3 decode"; } -//Implement fo S3TC Dxt5 + +//Implement of S3TC Dxt5 TextureS3TCDxt5::TextureS3TCDxt5() { Sprite *sprite = Sprite::create("Images/test_256x256_s3tc_dxt5_mipmaps.dds"); @@ -2060,8 +2066,62 @@ std::string TextureS3TCDxt5::title() } std::string TextureS3TCDxt5::subtitle() { - return "S3TC dxt5 decode"; + return "S3TC dxt5 decode"; +} + +//Implement of ATITC +TextureATITCRGB::TextureATITCRGB() +{ + Sprite *sprite = Sprite::create("Images/test_256x256_ATC_RGB_mipmaps.ktx"); + Size size = Director::getInstance()->getWinSize(); + sprite->setPosition(Point(size.width / 2, size.height / 2)); + + addChild(sprite); +} +std::string TextureATITCRGB::title() +{ + return "ATITC texture (*.ktx file) test#1"; +} +std::string TextureATITCRGB::subtitle() +{ + return "ATITC RGB (no Alpha channel) compressed texture test"; +} + +TextureATITCExplicit::TextureATITCExplicit() +{ + Sprite *sprite = Sprite::create("Images/test_256x256_ATC_RGBA_Explicit_mipmaps.ktx"); + + Size size = Director::getInstance()->getWinSize(); + sprite->setPosition(Point(size.width / 2, size.height / 2)); + + addChild(sprite); +} +std::string TextureATITCExplicit::title() +{ + return "ATITC texture (*.ktx file) test#2"; +} +std::string TextureATITCExplicit::subtitle() +{ + return "ATITC RGBA explicit Alpha compressed texture test"; +} + +TextureATITCInterpolated::TextureATITCInterpolated() +{ + Sprite *sprite = Sprite::create("Images/test_256x256_ATC_RGBA_Interpolated_mipmaps.ktx"); + + Size size = Director::getInstance()->getWinSize(); + sprite->setPosition(Point(size.width / 2, size.height /2)); + + addChild(sprite); +} +std::string TextureATITCInterpolated::title() +{ + return "ATITC texture (*.ktx file) test#3"; +} +std::string TextureATITCInterpolated::subtitle() +{ + return "ATITC RGBA Interpolated Alpha comrpessed texture test"; } static void addImageToDemo(TextureDemo& demo, float x, float y, const char* path, Texture2D::PixelFormat format) @@ -2071,7 +2131,7 @@ static void addImageToDemo(TextureDemo& demo, float x, float y, const char* path sprite->setPosition(Point(x, y)); demo.addChild(sprite, 0); - // remove texture from texture manager + //remove texture from texture manager TextureCache::getInstance()->removeTexture(sprite->getTexture()); } diff --git a/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.h b/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.h index c4bd187925..e590f25bef 100644 --- a/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.h +++ b/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.h @@ -462,6 +462,7 @@ public: virtual std::string title(); virtual std::string subtitle(); }; + // S3TC Dxt3 texture format test class TextureS3TCDxt3 : public TextureDemo { @@ -471,6 +472,7 @@ public: virtual std::string title(); virtual std::string subtitle(); }; + // S3TC Dxt5 texture format test class TextureS3TCDxt5 : public TextureDemo { @@ -481,6 +483,37 @@ public: virtual std::string subtitle(); }; +// ATITC RGB texture format test +class TextureATITCRGB : public TextureDemo +{ +public: + TextureATITCRGB(); + + virtual std::string title(); + virtual std::string subtitle(); +}; + +//ATITC RGBA Explicit texture format test +class TextureATITCExplicit : public TextureDemo +{ +public: + TextureATITCExplicit(); + + virtual std::string title(); + virtual std::string subtitle(); +}; + +//ATITC RGBA Interpolated texture format test +class TextureATITCInterpolated : public TextureDemo +{ +public: + TextureATITCInterpolated(); + + virtual std::string title(); + virtual std::string subtitle(); +}; + + // RGB888 texture convert test class TextureConvertRGB888 : public TextureDemo { From 9e07ac967fd695b7ac63b3c0dd5200b33924eac8 Mon Sep 17 00:00:00 2001 From: godyZ Date: Fri, 16 Aug 2013 14:03:30 +0800 Subject: [PATCH 024/126] issue #2533: updating some GL macro definition --- cocos2dx/platform/CCImageCommon_cpp.h | 30 +++++++++++++-------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/cocos2dx/platform/CCImageCommon_cpp.h b/cocos2dx/platform/CCImageCommon_cpp.h index 0d1cfaa5ae..4d04c4f32a 100644 --- a/cocos2dx/platform/CCImageCommon_cpp.h +++ b/cocos2dx/platform/CCImageCommon_cpp.h @@ -57,11 +57,15 @@ extern "C" #include "CCConfiguration.h" #include "support/ccUtils.h" #include "support/zip_support/ZipUtils.h" -#include "CCGL.h" #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) #include "platform/android/CCFileUtilsAndroid.h" #endif +#define CC_GL_ATC_RGB_AMD 0x8C92 +#define CC_GL_ATC_RGBA_EXPLICIT_ALPHA_AMD 0x8C93 +#define CC_GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE + + NS_CC_BEGIN ////////////////////////////////////////////////////////////////////////// @@ -1558,12 +1562,6 @@ bool Image::initWithS3TCData(const void *data, int dataLen) return true; } - -//----------------------------------------------------------------------------------------------- -#define GL_ATC_RGB_AMD 0x8C92 -#define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD 0x8C93 -#define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE - bool Image::initWithATITCData(const void *data, int dataLen) { /* load the .ktx file */ @@ -1575,13 +1573,13 @@ bool Image::initWithATITCData(const void *data, int dataLen) int blockSize = 0; switch (header->glInternalFormat) { - case GL_ATC_RGB_AMD: + case CC_GL_ATC_RGB_AMD: blockSize = 8; break; - case GL_ATC_RGBA_EXPLICIT_ALPHA_AMD: + case CC_GL_ATC_RGBA_EXPLICIT_ALPHA_AMD: blockSize = 16; break; - case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: + case CC_GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: blockSize = 16; break; default: @@ -1636,13 +1634,13 @@ bool Image::initWithATITCData(const void *data, int dataLen) switch (header->glInternalFormat) { - case GL_ATC_RGB_AMD: + case CC_GL_ATC_RGB_AMD: _renderFormat = Texture2D::PixelFormat::ATC_RGB; break; - case GL_ATC_RGBA_EXPLICIT_ALPHA_AMD: + case CC_GL_ATC_RGBA_EXPLICIT_ALPHA_AMD: _renderFormat = Texture2D::PixelFormat::ATC_EXPLICIT_ALPHA; break; - case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: + case CC_GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: _renderFormat = Texture2D::PixelFormat::ATC_INTERPOLATED_ALPHA; break; default: @@ -1663,13 +1661,13 @@ bool Image::initWithATITCData(const void *data, int dataLen) std::vector decodeImageData(stride * height); switch (header->glInternalFormat) { - case GL_ATC_RGB_AMD: + case CC_GL_ATC_RGB_AMD: atitc_decode(pixelData + encodeOffset, &decodeImageData[0], width, height, ATITCDecodeFlag::ATC_RGB); break; - case GL_ATC_RGBA_EXPLICIT_ALPHA_AMD: + case CC_GL_ATC_RGBA_EXPLICIT_ALPHA_AMD: atitc_decode(pixelData + encodeOffset, &decodeImageData[0], width, height, ATITCDecodeFlag::ATC_EXPLICIT_ALPHA); break; - case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: + case CC_GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: atitc_decode(pixelData + encodeOffset, &decodeImageData[0], width, height, ATITCDecodeFlag::ATC_INTERPOLATED_ALPHA); break; default: From b5af9eb4c81b2a792ad6a31b3443cea97487a57b Mon Sep 17 00:00:00 2001 From: godyZ Date: Fri, 16 Aug 2013 14:36:35 +0800 Subject: [PATCH 025/126] closed #2533:fix some wrong indent --- cocos2dx/platform/CCImageCommon_cpp.h | 1 - 1 file changed, 1 deletion(-) diff --git a/cocos2dx/platform/CCImageCommon_cpp.h b/cocos2dx/platform/CCImageCommon_cpp.h index 33c5fe08bd..fb4a67abe7 100644 --- a/cocos2dx/platform/CCImageCommon_cpp.h +++ b/cocos2dx/platform/CCImageCommon_cpp.h @@ -65,7 +65,6 @@ extern "C" #define CC_GL_ATC_RGBA_EXPLICIT_ALPHA_AMD 0x8C93 #define CC_GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE - NS_CC_BEGIN ////////////////////////////////////////////////////////////////////////// From 28656598efc26ebb4db013cbce12669245d383d6 Mon Sep 17 00:00:00 2001 From: godyZ Date: Fri, 16 Aug 2013 15:01:22 +0800 Subject: [PATCH 026/126] closed #2533:updating new file copyrights --- cocos2dx/platform/third_party/common/atitc/atitc.cpp | 2 +- cocos2dx/platform/third_party/common/atitc/atitc.h | 2 +- cocos2dx/platform/third_party/common/s3tc/s3tc.cpp | 2 +- cocos2dx/platform/third_party/common/s3tc/s3tc.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cocos2dx/platform/third_party/common/atitc/atitc.cpp b/cocos2dx/platform/third_party/common/atitc/atitc.cpp index 75774e4748..233944a8a3 100644 --- a/cocos2dx/platform/third_party/common/atitc/atitc.cpp +++ b/cocos2dx/platform/third_party/common/atitc/atitc.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2010 cocos2d-x.org + Copyright (c) 2013 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos2dx/platform/third_party/common/atitc/atitc.h b/cocos2dx/platform/third_party/common/atitc/atitc.h index fff8927695..5e31ff057e 100644 --- a/cocos2dx/platform/third_party/common/atitc/atitc.h +++ b/cocos2dx/platform/third_party/common/atitc/atitc.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2010 cocos2d-x.org + Copyright (c) 2013 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos2dx/platform/third_party/common/s3tc/s3tc.cpp b/cocos2dx/platform/third_party/common/s3tc/s3tc.cpp index 9008505d4e..ee4ef91c1e 100644 --- a/cocos2dx/platform/third_party/common/s3tc/s3tc.cpp +++ b/cocos2dx/platform/third_party/common/s3tc/s3tc.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2010 cocos2d-x.org + Copyright (c) 2013 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos2dx/platform/third_party/common/s3tc/s3tc.h b/cocos2dx/platform/third_party/common/s3tc/s3tc.h index 283bc5343b..898df30ab5 100644 --- a/cocos2dx/platform/third_party/common/s3tc/s3tc.h +++ b/cocos2dx/platform/third_party/common/s3tc/s3tc.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2010 cocos2d-x.org + Copyright (c) 2013 cocos2d-x.org http://www.cocos2d-x.org From 0823bb144f7b4c8cf54dff3d620e7dd563b0ccc1 Mon Sep 17 00:00:00 2001 From: boyu0 Date: Fri, 16 Aug 2013 15:35:27 +0800 Subject: [PATCH 027/126] issue #2517: add the LocalVarToAuto.py script --- tools/localvartoauto/LocalVarToAuto.py | 274 +++++++++++++++++++++++++ 1 file changed, 274 insertions(+) create mode 100755 tools/localvartoauto/LocalVarToAuto.py diff --git a/tools/localvartoauto/LocalVarToAuto.py b/tools/localvartoauto/LocalVarToAuto.py new file mode 100755 index 0000000000..fa8eddfeee --- /dev/null +++ b/tools/localvartoauto/LocalVarToAuto.py @@ -0,0 +1,274 @@ +#!/usr/bin/python +# LocalVarToAuto.py +# Change the class name in local variable assignment to auto +# Copyright (c) 2013 cocos2d-x.org +# Author: YuBo + +# This script is used for change the class name in local variable assignment to auto. +# Right now there is some poblems you might want notice: +# To start we will assume we has a class A. +# +# 1. If you have classes like this: +# class B : public A{}; +# class C : public A{}; +# And you write code like this: +# A* b = a_bclass_ptr; +# C* c = new C(); +# ... +# b = c; +# We will change it to: +# auto b = a_bclass_ptr; +# auto c = new C(); +# It will cause a compile error because you assign pointer with type C to different pointer +# with type B. You must edit it manually. +# +# 2. If your function has default params with class A, we will change it to auto you might +# unexpected. For example: +# void f(A* a = new A()){} or void f(A a = A()){} +# +# 3. If you have define macro like this: +# #define ANOTHER_A_NAME A +# and use it like this: +# ANOTHER_A_NAME* a = new A(); +# We will not convert it to auto for you. + +import os.path +import re +import types +import fileinput +import cStringIO + +# The cocos root entry. We will aspect it as parent dictionary, all other file or dictionary +# relative path are base on this. +COCOS_ROOT = "../../" +# The class declaration dictionaries, we will search the class declaration with .h files in it. +H_DIR = ("cocos2dx", "CocosDenshion", "extensions") +# The src files you want to edit, we will search the .cpp and .mm files in it. +CXX_DIR = ("Samples",) +# The dictionaries and files with class declaration you don't want to search, you can exclude some third party +# dictionaries in here +EXCLUDE = ("cocos2dx/platform/third_party/",) +# The extra dictionaries and files with class declaration. You can add some extra .h files in it +INCLUDE = () +# The macroes use with declare class, like "class CC_DLL A{}" +MACROES_WITH_CLASS = ("CC_DLL",) +# The strings represent the null pointer, because you set a point to null, we will not change that +# variable to auto. +NULL_PTR = ("0", "NULL", "nullptr") + +# normalize the path +COCOS_ROOT = os.path.abspath(COCOS_ROOT) + +def check_file_match_rep(repString, filePath): + '''Check the file with filepath is match the repstring or not. + Return True if match, return False if not. + NOTE: it will check the EXCLUDE files and directories, if the file is in the EXCLUDE directories + or is a EXCLUDE file, it will return False.''' + + #normalize the path + realFilePath = os.path.abspath(filePath) + + if not os.path.isfile(realFilePath): + return False + + rep = re.compile(repString) + curDir, fileName = os.path.split(realFilePath) + + # check dir is exclude or not + for dir in EXCLUDE: + dir = os.path.abspath(os.path.join(COCOS_ROOT, dir)) + if os.path.isdir(dir) and os.path.isdir(curDir[:len(dir)]): + if os.path.samefile(dir, curDir[:len(dir)]): + return False + + if rep.match(fileName): + # check file is exclude or not + for file in EXCLUDE: + if os.path.isfile(os.path.join(COCOS_ROOT, file)): + if os.path.samefile(realFilePath, os.path.join(COCOS_ROOT, file)): + return False + + return True + + return False + +def walk_collect_h_files(lst, dirname, names): + "collect *.h files and insert into lst" + + for name in names: + if check_file_match_rep(".*\.h$", os.path.join(dirname, name)): + if type(lst) is types.ListType: + lst += [os.path.relpath(os.path.abspath(os.path.join(dirname, name)), COCOS_ROOT)] + +def walk_collect_cxx_files(lst, dirname, names): + "collect *.cpp and *.mm files and insert into lst" + + for name in names: + if check_file_match_rep(".*\.(?:cpp)|(?:mm)$", os.path.join(dirname, name)): + if type(lst) is types.ListType: + lst += [os.path.relpath(os.path.abspath(os.path.join(dirname, name)), COCOS_ROOT)] + +def collect_class_name(filename, st): + "collect all class name appear in the file" + + #generate the rep + if not hasattr(collect_class_name, "rep"): + repString = cStringIO.StringIO() + repString.write("(?:\s+|^)class\s+") + for word in MACROES_WITH_CLASS: + repString.write(word + "\s+") + repString.write("(?P\w+)") + + collect_class_name.rep = re.compile(repString.getvalue()) + repString.close() + + f = open(os.path.join(COCOS_ROOT, filename)) + try: + for line in f: + res = collect_class_name.rep.match(line) + if res: + if type(st) == type(set()): + st.add(res.group("cls_name")) + finally: + f.close() + +def change_local_classvarname_to_auto(filename, rep, change): + "change all local class variable name to auto" + f = open(filename) + + content = None + changed = False + # read the file, change it, and save it to content + try: + content = cStringIO.StringIO() + changed = False + + for line in f: + i = 0 + #start to replace + while True: + result = rep.match(line, i) + # founded + if result: + changed = True + #find the matched string where to start + startIndex = line.index(result.group(0)) + #replace the change part + line = line.replace(result.group(change), "auto ", startIndex) + i += 1 + else: + break + #write the result to content + content.write(line) + finally: + f.close() + if changed: + f = open(filename, "w") + f.write(content.getvalue()) + f.close() + content.close() + +def main(): + + print ".......VARIABLES......." + print "COCOS_ROOT:", + print COCOS_ROOT + print "H_DIR:", + print H_DIR + print "CXX_DIR:", + print CXX_DIR + print "EXCLUDE:", + print EXCLUDE + print "INCLUDE:", + print INCLUDE + print ".......VARIABLES END......" + + # save the .h file for search + hfiles = [] + # save the .cpp and .mm file for search + cxxfiles = [] + + print "search .h files..." + for dir in H_DIR: + os.path.walk(os.path.join(COCOS_ROOT, dir), walk_collect_h_files, hfiles) + + for dir in INCLUDE: + if os.path.isdir(os.path.join(COCOS_ROOT, dir)): + os.path.walk(os.path.join(COCOS_ROOT, dir), walk_collect_h_files, hfiles) + else: + hfiles += [dir] + print "search end" + + print "search .cxx files..." + for dir in CXX_DIR: + os.path.walk(os.path.join(COCOS_ROOT, dir), walk_collect_cxx_files, cxxfiles) + print "search end" + + print "search class declarations" + # the class set, ignore the namespace + classes = set() + for file in hfiles: + collect_class_name(file, classes) + print "search end" + + # generate example rep: + # (\W+|^)(?P\S*(?:Class1|Class2|class3)\s*(?:\*+|\s+)\s*)\w+\s*=(?!\s*(?:0|NULL|nullptr)\s*\W) + # examples: + # Class1* c = new Class1() ; //match + # Class1* c; //not match + # Class1* c = nullptr; //not match + # Class1* c = nullptrabc; //match + # Class1 c; //not match + # Class1 c = Class1(); //match + def gen_rep(keyWord): + s = cStringIO.StringIO() + s.write("(?:\W+|^)(?P<") + s.write(keyWord) + s.write(">\S*(?:") + + # add classes want to match + first = True + for cls in classes: + if first: + first = False + else: + s.write("|") + + s.write(cls) + + s.write(")\s*(?:\*+|\s+)\s*)\w+\s*=(?!\s*(?:") + + # let nullptr assignment not to convert + first = True + for nullptr in NULL_PTR: + if first: + first = False + else: + s.write("|") + + s.write(nullptr) + + s.write(")\s*\W)") + + result = s.getvalue() + s.close() + + print "generated regular expression is:" + print result + return re.compile(result) + + repWord = "change" + rep = gen_rep(repWord) + + + print "scan and edit the .cxx files..." + # scan the cxx files + for file in cxxfiles: + change_local_classvarname_to_auto(os.path.join(COCOS_ROOT, file), rep, repWord) + + print "success!" + + +if __name__ == "__main__": + main() + From 70df1a6061d3c804150e8f47e7b21b5385db39c7 Mon Sep 17 00:00:00 2001 From: boyu0 Date: Fri, 16 Aug 2013 16:05:27 +0800 Subject: [PATCH 028/126] closed #2517: Use LocalVarToAuto.py to change Samples src file --- .../AssetsManagerTest/Classes/AppDelegate.cpp | 12 +- .../Cpp/AssetsManagerTest/proj.win32/main.cpp | 2 +- samples/Cpp/HelloCpp/Classes/AppDelegate.cpp | 8 +- .../Cpp/HelloCpp/Classes/HelloWorldScene.cpp | 14 +- samples/Cpp/HelloCpp/proj.linux/main.cpp | 2 +- samples/Cpp/HelloCpp/proj.qt5/main.cpp | 2 +- .../HelloCpp/proj.tizen/src/HelloCppEntry.cpp | 2 +- samples/Cpp/HelloCpp/proj.win32/main.cpp | 2 +- .../Cpp/SimpleGame/Classes/AppDelegate.cpp | 8 +- .../Cpp/SimpleGame/Classes/GameOverScene.cpp | 2 +- .../SimpleGame/Classes/HelloWorldScene.cpp | 30 +- samples/Cpp/SimpleGame/proj.linux/main.cpp | 2 +- samples/Cpp/SimpleGame/proj.qt5/main.cpp | 2 +- .../proj.tizen/src/SimpleGameEntry.cpp | 2 +- .../AccelerometerTest/AccelerometerTest.cpp | 16 +- .../ActionManagerTest/ActionManagerTest.cpp | 52 +-- .../ActionsEaseTest/ActionsEaseTest.cpp | 268 ++++++++-------- .../ActionsProgressTest.cpp | 82 ++--- .../Classes/ActionsTest/ActionsTest.cpp | 56 ++-- samples/Cpp/TestCpp/Classes/AppDelegate.cpp | 10 +- samples/Cpp/TestCpp/Classes/BaseTest.cpp | 12 +- .../TestCpp/Classes/Box2DTest/Box2dTest.cpp | 26 +- .../Classes/Box2DTestBed/Box2dView.cpp | 50 +-- .../Cpp/TestCpp/Classes/Box2DTestBed/Test.cpp | 4 +- .../Cpp/TestCpp/Classes/BugsTest/Bug-1159.cpp | 16 +- .../Cpp/TestCpp/Classes/BugsTest/Bug-1174.cpp | 12 +- .../Cpp/TestCpp/Classes/BugsTest/Bug-350.cpp | 4 +- .../Cpp/TestCpp/Classes/BugsTest/Bug-422.cpp | 10 +- .../Classes/BugsTest/Bug-458/Bug-458.cpp | 16 +- .../Bug-458/QuestionContainerSprite.cpp | 22 +- .../Cpp/TestCpp/Classes/BugsTest/Bug-624.cpp | 12 +- .../Cpp/TestCpp/Classes/BugsTest/Bug-886.cpp | 6 +- .../Cpp/TestCpp/Classes/BugsTest/Bug-899.cpp | 2 +- .../Cpp/TestCpp/Classes/BugsTest/Bug-914.cpp | 12 +- .../Cpp/TestCpp/Classes/BugsTest/BugsTest.cpp | 24 +- .../Classes/ChipmunkTest/ChipmunkTest.cpp | 34 +- .../ClickAndMoveTest/ClickAndMoveTest.cpp | 12 +- .../ClippingNodeTest/ClippingNodeTest.cpp | 92 +++--- .../CocosDenshionTest/CocosDenshionTest.cpp | 6 +- .../ConfigurationTest/ConfigurationTest.cpp | 12 +- .../Cpp/TestCpp/Classes/CurlTest/CurlTest.cpp | 4 +- .../CurrentLanguageTest.cpp | 6 +- .../DataVisitorTest/DataVisitorTest.cpp | 20 +- .../DrawPrimitivesTest/DrawPrimitivesTest.cpp | 18 +- .../EffectsAdvancedTest.cpp | 100 +++--- .../Classes/EffectsTest/EffectsTest.cpp | 84 ++--- .../ArmatureTest/ArmatureScene.cpp | 8 +- .../CocosBuilderTest/CocosBuilderTest.cpp | 6 +- .../HelloCocosBuilderLayer.cpp | 12 +- .../ComponentsTest/ComponentsTestScene.cpp | 18 +- .../ComponentsTest/EnemyController.cpp | 4 +- .../ComponentsTest/GameOverScene.cpp | 8 +- .../ComponentsTest/ProjectileController.cpp | 30 +- .../ComponentsTest/SceneController.cpp | 4 +- .../CCControlButtonTest.cpp | 38 +-- .../CCControlColourPickerTest.cpp | 6 +- .../CCControlPotentiometerTest.cpp | 6 +- .../ControlExtensionTest/CCControlScene.cpp | 18 +- .../CCControlSliderTest.cpp | 2 +- .../CCControlStepperTest.cpp | 10 +- .../CCControlSwitchTest.cpp | 6 +- .../EditBoxTest/EditBoxTest.cpp | 16 +- .../Classes/ExtensionsTest/ExtensionsTest.cpp | 22 +- .../NetworkTest/HttpClientTest.cpp | 34 +- .../NetworkTest/SocketIOTest.cpp | 44 +-- .../NetworkTest/WebSocketTest.cpp | 24 +- .../NotificationCenterTest.cpp | 38 +-- .../Scale9SpriteTest/Scale9SpriteTest.cpp | 46 +-- .../TableViewTest/CustomTableViewCell.cpp | 4 +- .../TableViewTest/TableViewTestScene.cpp | 8 +- .../Classes/FileUtilsTest/FileUtilsTest.cpp | 58 ++-- .../Cpp/TestCpp/Classes/FontTest/FontTest.cpp | 20 +- .../Classes/IntervalTest/IntervalTest.cpp | 14 +- .../Classes/KeyboardTest/KeyboardTest.cpp | 6 +- .../TestCpp/Classes/KeypadTest/KeypadTest.cpp | 6 +- .../TestCpp/Classes/LabelTest/LabelTest.cpp | 220 ++++++------- .../Classes/LabelTest/LabelTestNew.cpp | 160 +++++----- .../TestCpp/Classes/LayerTest/LayerTest.cpp | 216 ++++++------- .../Cpp/TestCpp/Classes/MenuTest/MenuTest.cpp | 170 +++++----- .../MotionStreakTest/MotionStreakTest.cpp | 38 +-- .../Classes/MutiTouchTest/MutiTouchTest.cpp | 20 +- .../Cpp/TestCpp/Classes/NodeTest/NodeTest.cpp | 156 ++++----- .../Classes/ParallaxTest/ParallaxTest.cpp | 48 +-- .../Classes/ParticleTest/ParticleTest.cpp | 152 ++++----- .../PerformanceNodeChildrenTest.cpp | 48 +-- .../PerformanceParticleTest.cpp | 48 +-- .../PerformanceTest/PerformanceSpriteTest.cpp | 60 ++-- .../PerformanceTest/PerformanceTest.cpp | 20 +- .../PerformanceTextureTest.cpp | 14 +- .../PerformanceTouchesTest.cpp | 14 +- .../RenderTextureTest/RenderTextureTest.cpp | 96 +++--- .../RotateWorldTest/RotateWorldTest.cpp | 38 +-- .../TestCpp/Classes/SceneTest/SceneTest.cpp | 70 ++-- .../Classes/SchedulerTest/SchedulerTest.cpp | 112 +++---- .../TestCpp/Classes/ShaderTest/ShaderTest.cpp | 68 ++-- .../TestCpp/Classes/SpineTest/SpineTest.cpp | 2 +- .../SpriteTest/SpriteTest.cpp.REMOVED.git-id | 2 +- .../Classes/TextInputTest/TextInputTest.cpp | 50 +-- .../Classes/Texture2dTest/Texture2dTest.cpp | 300 +++++++++--------- .../TextureCacheTest/TextureCacheTest.cpp | 38 +-- .../TextureAtlasEncryptionTest.cpp | 16 +- .../Classes/TileMapTest/TileMapTest.cpp | 280 ++++++++-------- .../Cpp/TestCpp/Classes/TouchesTest/Ball.cpp | 2 +- .../TestCpp/Classes/TouchesTest/Paddle.cpp | 8 +- .../Classes/TouchesTest/TouchesTest.cpp | 6 +- .../TransitionsTest/TransitionsTest.cpp | 70 ++-- .../UserDefaultTest/UserDefaultTest.cpp | 6 +- samples/Cpp/TestCpp/Classes/VisibleRect.cpp | 2 +- .../Classes/ZwoptexTest/ZwoptexTest.cpp | 22 +- samples/Cpp/TestCpp/Classes/controller.cpp | 24 +- samples/Cpp/TestCpp/Classes/testBasic.cpp | 14 +- .../TestCpp/proj.android/project.properties | 2 +- samples/Cpp/TestCpp/proj.linux/main.cpp | 2 +- samples/Cpp/TestCpp/proj.qt5/main.cpp | 2 +- .../TestCpp/proj.tizen/src/TestCppEntry.cpp | 2 +- samples/Cpp/TestCpp/proj.win32/main.cpp | 2 +- .../CocosDragonJS/Classes/AppDelegate.cpp | 12 +- .../CocosDragonJS/proj.win32/main.cpp | 2 +- .../CrystalCraze/Classes/AppDelegate.cpp | 12 +- .../CrystalCraze/proj.win32/main.cpp | 2 +- .../MoonWarriors/Classes/AppDelegate.cpp | 6 +- .../MoonWarriors/proj.win32/main.cpp | 2 +- .../TestJavascript/Classes/AppDelegate.cpp | 6 +- .../TestJavascript/proj.win32/main.cpp | 2 +- .../WatermelonWithMe/Classes/AppDelegate.cpp | 6 +- .../WatermelonWithMe/proj.win32/main.cpp | 2 +- samples/Lua/HelloLua/Classes/AppDelegate.cpp | 2 +- samples/Lua/HelloLua/proj.emscripten/main.cpp | 2 +- samples/Lua/HelloLua/proj.linux/main.cpp | 2 +- .../HelloLua/proj.tizen/src/HelloLuaEntry.cpp | 2 +- samples/Lua/HelloLua/proj.win32/main.cpp | 2 +- samples/Lua/TestLua/Classes/AppDelegate.cpp | 10 +- samples/Lua/TestLua/proj.emscripten/main.cpp | 2 +- samples/Lua/TestLua/proj.linux/main.cpp | 2 +- .../TestLua/proj.tizen/src/TestLuaEntry.cpp | 2 +- samples/Lua/TestLua/proj.win32/main.cpp | 2 +- 136 files changed, 2203 insertions(+), 2203 deletions(-) diff --git a/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.cpp b/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.cpp index bcb045c351..3e222e6bf6 100644 --- a/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.cpp +++ b/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.cpp @@ -32,7 +32,7 @@ AppDelegate::~AppDelegate() bool AppDelegate::applicationDidFinishLaunching() { // initialize director - Director *director = Director::getInstance(); + auto director = Director::getInstance(); director->setOpenGLView(EGLView::getInstance()); // turn on display FPS @@ -47,8 +47,8 @@ bool AppDelegate::applicationDidFinishLaunching() sc->start(); - Scene *scene = Scene::create(); - UpdateLayer *updateLayer = new UpdateLayer(); + auto scene = Scene::create(); + auto updateLayer = new UpdateLayer(); scene->addChild(updateLayer); updateLayer->release(); @@ -132,7 +132,7 @@ void UpdateLayer::enter(cocos2d::Object *pSender) FileUtils::getInstance()->setSearchPaths(searchPaths); } - ScriptEngineProtocol *pEngine = ScriptingCore::getInstance(); + auto pEngine = ScriptingCore::getInstance(); ScriptEngineManager::getInstance()->setScriptEngine(pEngine); ScriptingCore::getInstance()->runScript("main.js"); } @@ -143,7 +143,7 @@ bool UpdateLayer::init() createDownloadedDir(); - Size size = Director::getInstance()->getWinSize(); + auto size = Director::getInstance()->getWinSize(); pItemReset = MenuItemFont::create("reset", CC_CALLBACK_1(UpdateLayer::reset,this)); pItemEnter = MenuItemFont::create("enter", CC_CALLBACK_1(UpdateLayer::enter, this)); @@ -153,7 +153,7 @@ bool UpdateLayer::init() pItemReset->setPosition(Point(size.width/2, size.height/2)); pItemUpdate->setPosition(Point(size.width/2, size.height/2 - 50)); - Menu *menu = Menu::create(pItemUpdate, pItemEnter, pItemReset, NULL); + auto menu = Menu::create(pItemUpdate, pItemEnter, pItemReset, NULL); menu->setPosition(Point(0,0)); addChild(menu); diff --git a/samples/Cpp/AssetsManagerTest/proj.win32/main.cpp b/samples/Cpp/AssetsManagerTest/proj.win32/main.cpp index d5e06d0c80..945ca41a77 100644 --- a/samples/Cpp/AssetsManagerTest/proj.win32/main.cpp +++ b/samples/Cpp/AssetsManagerTest/proj.win32/main.cpp @@ -24,7 +24,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, // create the application instance AppDelegate app; - EGLView* eglView = EGLView::getInstance(); + auto eglView = EGLView::getInstance(); eglView->setViewName("AssetsManagerTest"); eglView->setFrameSize(800, 450); diff --git a/samples/Cpp/HelloCpp/Classes/AppDelegate.cpp b/samples/Cpp/HelloCpp/Classes/AppDelegate.cpp index 0be3f40794..54019ceb53 100644 --- a/samples/Cpp/HelloCpp/Classes/AppDelegate.cpp +++ b/samples/Cpp/HelloCpp/Classes/AppDelegate.cpp @@ -19,12 +19,12 @@ AppDelegate::~AppDelegate() bool AppDelegate::applicationDidFinishLaunching() { // initialize director - Director* director = Director::getInstance(); - EGLView* glView = EGLView::getInstance(); + auto director = Director::getInstance(); + auto glView = EGLView::getInstance(); director->setOpenGLView(glView); - Size size = director->getWinSize(); + auto size = director->getWinSize(); // Set the design resolution glView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, ResolutionPolicy::NO_BORDER); @@ -70,7 +70,7 @@ bool AppDelegate::applicationDidFinishLaunching() { director->setAnimationInterval(1.0 / 60); // create a scene. it's an autorelease object - Scene *scene = HelloWorld::scene(); + auto scene = HelloWorld::scene(); // run director->runWithScene(scene); diff --git a/samples/Cpp/HelloCpp/Classes/HelloWorldScene.cpp b/samples/Cpp/HelloCpp/Classes/HelloWorldScene.cpp index 90d1aa3266..6d1cb73fe4 100644 --- a/samples/Cpp/HelloCpp/Classes/HelloWorldScene.cpp +++ b/samples/Cpp/HelloCpp/Classes/HelloWorldScene.cpp @@ -6,7 +6,7 @@ USING_NS_CC; Scene* HelloWorld::scene() { // 'scene' is an autorelease object - Scene *scene = Scene::create(); + auto scene = Scene::create(); // 'layer' is an autorelease object HelloWorld *layer = HelloWorld::create(); @@ -28,15 +28,15 @@ bool HelloWorld::init() return false; } - Size visibleSize = Director::getInstance()->getVisibleSize(); - Point origin = Director::getInstance()->getVisibleOrigin(); + auto visibleSize = Director::getInstance()->getVisibleSize(); + auto origin = Director::getInstance()->getVisibleOrigin(); ///////////////////////////// // 2. add a menu item with "X" image, which is clicked to quit the program // you may modify it. // add a "close" icon to exit the progress. it's an autorelease object - MenuItemImage *closeItem = MenuItemImage::create( + auto closeItem = MenuItemImage::create( "CloseNormal.png", "CloseSelected.png", CC_CALLBACK_1(HelloWorld::menuCloseCallback,this)); @@ -44,7 +44,7 @@ bool HelloWorld::init() closeItem->setPosition(origin + Point(visibleSize) - Point(closeItem->getContentSize() / 2)); // create menu, it's an autorelease object - Menu* menu = Menu::create(closeItem, NULL); + auto menu = Menu::create(closeItem, NULL); menu->setPosition(Point::ZERO); this->addChild(menu, 1); @@ -54,7 +54,7 @@ bool HelloWorld::init() // add a label shows "Hello World" // create and initialize a label - LabelTTF* label = LabelTTF::create("Hello World", "Arial", TITLE_FONT_SIZE); + auto label = LabelTTF::create("Hello World", "Arial", TITLE_FONT_SIZE); // position the label on the center of the screen label->setPosition(Point(origin.x + visibleSize.width/2, @@ -64,7 +64,7 @@ bool HelloWorld::init() this->addChild(label, 1); // add "HelloWorld" splash screen" - Sprite* sprite = Sprite::create("HelloWorld.png"); + auto sprite = Sprite::create("HelloWorld.png"); // position the sprite on the center of the screen sprite->setPosition(Point(visibleSize / 2) + origin); diff --git a/samples/Cpp/HelloCpp/proj.linux/main.cpp b/samples/Cpp/HelloCpp/proj.linux/main.cpp index cad76a0ea8..ff814922d7 100644 --- a/samples/Cpp/HelloCpp/proj.linux/main.cpp +++ b/samples/Cpp/HelloCpp/proj.linux/main.cpp @@ -13,7 +13,7 @@ int main(int argc, char **argv) // create the application instance AppDelegate app; - EGLView* eglView = EGLView::getInstance(); + auto eglView = EGLView::getInstance(); eglView->setFrameSize(800, 480); return Application::getInstance()->run(); diff --git a/samples/Cpp/HelloCpp/proj.qt5/main.cpp b/samples/Cpp/HelloCpp/proj.qt5/main.cpp index f48c450399..1c7e442bc4 100644 --- a/samples/Cpp/HelloCpp/proj.qt5/main.cpp +++ b/samples/Cpp/HelloCpp/proj.qt5/main.cpp @@ -14,7 +14,7 @@ int main(int argc, char **argv) // create the application instance AppDelegate app; - CCEGLView* eglView = CCEGLView::sharedOpenGLView(); + auto eglView = CCEGLView::sharedOpenGLView(); eglView->setFrameSize(800, 480); return CCApplication::sharedApplication()->run(); diff --git a/samples/Cpp/HelloCpp/proj.tizen/src/HelloCppEntry.cpp b/samples/Cpp/HelloCpp/proj.tizen/src/HelloCppEntry.cpp index d88c269706..8b447bfc41 100644 --- a/samples/Cpp/HelloCpp/proj.tizen/src/HelloCppEntry.cpp +++ b/samples/Cpp/HelloCpp/proj.tizen/src/HelloCppEntry.cpp @@ -44,7 +44,7 @@ ApplicationInitialized(void) { AppDelegate* pAppDelegate = new AppDelegate; - EGLView* eglView = EGLView::getInstance(); + auto eglView = EGLView::getInstance(); eglView->setFrameSize(1280, 720); Application::getInstance()->run(); diff --git a/samples/Cpp/HelloCpp/proj.win32/main.cpp b/samples/Cpp/HelloCpp/proj.win32/main.cpp index a6b3152563..d88e9d1805 100644 --- a/samples/Cpp/HelloCpp/proj.win32/main.cpp +++ b/samples/Cpp/HelloCpp/proj.win32/main.cpp @@ -14,7 +14,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, // create the application instance AppDelegate app; - EGLView* eglView = EGLView::getInstance(); + auto eglView = EGLView::getInstance(); eglView->setViewName("HelloCpp"); eglView->setFrameSize(2048, 1536); // The resolution of ipad3 is very large. In general, PC's resolution is smaller than it. diff --git a/samples/Cpp/SimpleGame/Classes/AppDelegate.cpp b/samples/Cpp/SimpleGame/Classes/AppDelegate.cpp index c1f7b09f90..03b9b81ae4 100644 --- a/samples/Cpp/SimpleGame/Classes/AppDelegate.cpp +++ b/samples/Cpp/SimpleGame/Classes/AppDelegate.cpp @@ -14,12 +14,12 @@ AppDelegate::~AppDelegate() bool AppDelegate::applicationDidFinishLaunching() { // initialize director - Director *director = Director::getInstance(); + auto director = Director::getInstance(); director->setOpenGLView(EGLView::getInstance()); - Size screenSize = EGLView::getInstance()->getFrameSize(); - Size designSize = Size(480, 320); + auto screenSize = EGLView::getInstance()->getFrameSize(); + auto designSize = Size(480, 320); std::vector searchPaths; if (screenSize.height > 320) @@ -45,7 +45,7 @@ bool AppDelegate::applicationDidFinishLaunching() { director->setAnimationInterval(1.0 / 60); // create a scene. it's an autorelease object - Scene *scene = HelloWorld::scene(); + auto scene = HelloWorld::scene(); // run director->runWithScene(scene); diff --git a/samples/Cpp/SimpleGame/Classes/GameOverScene.cpp b/samples/Cpp/SimpleGame/Classes/GameOverScene.cpp index cc3ffe25c0..a20a885bbf 100644 --- a/samples/Cpp/SimpleGame/Classes/GameOverScene.cpp +++ b/samples/Cpp/SimpleGame/Classes/GameOverScene.cpp @@ -58,7 +58,7 @@ bool GameOverLayer::init() { if ( LayerColor::initWithColor( Color4B(255,255,255,255) ) ) { - Size winSize = Director::getInstance()->getWinSize(); + auto winSize = Director::getInstance()->getWinSize(); this->_label = LabelTTF::create("","Artial", 32); _label->retain(); _label->setColor( Color3B(0, 0, 0) ); diff --git a/samples/Cpp/SimpleGame/Classes/HelloWorldScene.cpp b/samples/Cpp/SimpleGame/Classes/HelloWorldScene.cpp index 9b7cc00c3a..65ce917c6f 100644 --- a/samples/Cpp/SimpleGame/Classes/HelloWorldScene.cpp +++ b/samples/Cpp/SimpleGame/Classes/HelloWorldScene.cpp @@ -69,21 +69,21 @@ bool HelloWorld::init() // 1. Add a menu item with "X" image, which is clicked to quit the program. // Create a "close" menu item with close icon, it's an auto release object. - MenuItemImage *closeItem = MenuItemImage::create( + auto closeItem = MenuItemImage::create( "CloseNormal.png", "CloseSelected.png", CC_CALLBACK_1(HelloWorld::menuCloseCallback,this)); CC_BREAK_IF(! closeItem); // Place the menu item bottom-right conner. - Size visibleSize = Director::getInstance()->getVisibleSize(); - Point origin = Director::getInstance()->getVisibleOrigin(); + auto visibleSize = Director::getInstance()->getVisibleSize(); + auto origin = Director::getInstance()->getVisibleOrigin(); closeItem->setPosition(Point(origin.x + visibleSize.width - closeItem->getContentSize().width/2, origin.y + closeItem->getContentSize().height/2)); // Create a menu with the "close" menu item, it's an auto release object. - Menu* menu = Menu::create(closeItem, NULL); + auto menu = Menu::create(closeItem, NULL); menu->setPosition(Point::ZERO); CC_BREAK_IF(! menu); @@ -92,7 +92,7 @@ bool HelloWorld::init() ///////////////////////////// // 2. add your codes below... - Sprite *player = Sprite::create("Player.png", Rect(0, 0, 27, 40) ); + auto player = Sprite::create("Player.png", Rect(0, 0, 27, 40) ); player->setPosition( Point(origin.x + player->getContentSize().width/2, origin.y + visibleSize.height/2) ); @@ -170,7 +170,7 @@ void HelloWorld::spriteMoveFinished(Node* sender) { _targets->removeObject(sprite); - GameOverScene *gameOverScene = GameOverScene::create(); + auto gameOverScene = GameOverScene::create(); gameOverScene->getLayer()->getLabel()->setString("You Lose :["); Director::getInstance()->replaceScene(gameOverScene); @@ -197,7 +197,7 @@ void HelloWorld::ccTouchesEnded(Set* touches, Event* event) // Set up initial location of projectile Size winSize = Director::getInstance()->getVisibleSize(); - Point origin = Director::getInstance()->getVisibleOrigin(); + auto origin = Director::getInstance()->getVisibleOrigin(); Sprite *projectile = Sprite::create("Projectile.png", Rect(0, 0, 20, 20)); projectile->setPosition( Point(origin.x+20, origin.y+winSize.height/2) ); @@ -246,20 +246,20 @@ void HelloWorld::updateGame(float dt) // for (it = _projectiles->begin(); it != _projectiles->end(); it++) CCARRAY_FOREACH(_projectiles, it) { - Sprite *projectile = dynamic_cast(it); - Rect projectileRect = Rect( + auto projectile = dynamic_cast(it); + auto projectileRect = Rect( projectile->getPosition().x - (projectile->getContentSize().width/2), projectile->getPosition().y - (projectile->getContentSize().height/2), projectile->getContentSize().width, projectile->getContentSize().height); - Array* targetsToDelete =new Array; + auto targetsToDelete =new Array; // for (jt = _targets->begin(); jt != _targets->end(); jt++) CCARRAY_FOREACH(_targets, jt) { - Sprite *target = dynamic_cast(jt); - Rect targetRect = Rect( + auto target = dynamic_cast(jt); + auto targetRect = Rect( target->getPosition().x - (target->getContentSize().width/2), target->getPosition().y - (target->getContentSize().height/2), target->getContentSize().width, @@ -275,14 +275,14 @@ void HelloWorld::updateGame(float dt) // for (jt = targetsToDelete->begin(); jt != targetsToDelete->end(); jt++) CCARRAY_FOREACH(targetsToDelete, jt) { - Sprite *target = dynamic_cast(jt); + auto target = dynamic_cast(jt); _targets->removeObject(target); this->removeChild(target, true); _projectilesDestroyed++; if (_projectilesDestroyed >= 5) { - GameOverScene *gameOverScene = GameOverScene::create(); + auto gameOverScene = GameOverScene::create(); gameOverScene->getLayer()->getLabel()->setString("You Win!"); Director::getInstance()->replaceScene(gameOverScene); } @@ -298,7 +298,7 @@ void HelloWorld::updateGame(float dt) // for (it = projectilesToDelete->begin(); it != projectilesToDelete->end(); it++) CCARRAY_FOREACH(projectilesToDelete, it) { - Sprite* projectile = dynamic_cast(it); + auto projectile = dynamic_cast(it); _projectiles->removeObject(projectile); this->removeChild(projectile, true); } diff --git a/samples/Cpp/SimpleGame/proj.linux/main.cpp b/samples/Cpp/SimpleGame/proj.linux/main.cpp index ebfbfb9522..db61a89dca 100644 --- a/samples/Cpp/SimpleGame/proj.linux/main.cpp +++ b/samples/Cpp/SimpleGame/proj.linux/main.cpp @@ -13,7 +13,7 @@ int main(int argc, char **argv) // create the application instance AppDelegate app; - EGLView* eglView = EGLView::getInstance(); + auto eglView = EGLView::getInstance(); eglView->setFrameSize(800, 480); return Application::getInstance()->run(); diff --git a/samples/Cpp/SimpleGame/proj.qt5/main.cpp b/samples/Cpp/SimpleGame/proj.qt5/main.cpp index fbaeec114b..e7baa657b6 100644 --- a/samples/Cpp/SimpleGame/proj.qt5/main.cpp +++ b/samples/Cpp/SimpleGame/proj.qt5/main.cpp @@ -13,7 +13,7 @@ int main(int argc, char **argv) // create the application instance AppDelegate app; - CCEGLView* eglView = CCEGLView::sharedOpenGLView(); + auto eglView = CCEGLView::sharedOpenGLView(); eglView->setFrameSize(800, 480); return CCApplication::sharedApplication()->run(); diff --git a/samples/Cpp/SimpleGame/proj.tizen/src/SimpleGameEntry.cpp b/samples/Cpp/SimpleGame/proj.tizen/src/SimpleGameEntry.cpp index 08a5c64324..0c18462c6f 100644 --- a/samples/Cpp/SimpleGame/proj.tizen/src/SimpleGameEntry.cpp +++ b/samples/Cpp/SimpleGame/proj.tizen/src/SimpleGameEntry.cpp @@ -44,7 +44,7 @@ ApplicationInitialized(void) { AppDelegate* pAppDelegate = new AppDelegate; - EGLView* eglView = EGLView::getInstance(); + auto eglView = EGLView::getInstance(); eglView->setFrameSize(720, 1280); Application::getInstance()->run(); diff --git a/samples/Cpp/TestCpp/Classes/AccelerometerTest/AccelerometerTest.cpp b/samples/Cpp/TestCpp/Classes/AccelerometerTest/AccelerometerTest.cpp index 4ffb54a8f8..c5717ab95a 100644 --- a/samples/Cpp/TestCpp/Classes/AccelerometerTest/AccelerometerTest.cpp +++ b/samples/Cpp/TestCpp/Classes/AccelerometerTest/AccelerometerTest.cpp @@ -35,7 +35,7 @@ void AccelerometerTest::onEnter() setAccelerometerEnabled(true); - LabelTTF* label = LabelTTF::create(title().c_str(), "Arial", 32); + auto label = LabelTTF::create(title().c_str(), "Arial", 32); addChild(label, 1); label->setPosition( Point(VisibleRect::center().x, VisibleRect::top().y-50) ); @@ -52,27 +52,27 @@ void AccelerometerTest::didAccelerate(Acceleration* pAccelerationValue) // // if (_lastTime > 0.0) // { -// Point ptNow = convertToUI +// auto ptNow = convertToUI // } // // _lastTime = fNow; - Director* pDir = Director::getInstance(); + auto pDir = Director::getInstance(); /*FIXME: Testing on the Nexus S sometimes _ball is NULL */ if ( _ball == NULL ) { return; } - Size ballSize = _ball->getContentSize(); + auto ballSize = _ball->getContentSize(); - Point ptNow = _ball->getPosition(); - Point ptTemp = pDir->convertToUI(ptNow); + auto ptNow = _ball->getPosition(); + auto ptTemp = pDir->convertToUI(ptNow); ptTemp.x += pAccelerationValue->x * 9.81f; ptTemp.y -= pAccelerationValue->y * 9.81f; - Point ptNext = pDir->convertToGL(ptTemp); + auto ptNext = pDir->convertToGL(ptTemp); FIX_POS(ptNext.x, (VisibleRect::left().x+ballSize.width / 2.0), (VisibleRect::right().x - ballSize.width / 2.0)); FIX_POS(ptNext.y, (VisibleRect::bottom().y+ballSize.height / 2.0), (VisibleRect::top().y - ballSize.height / 2.0)); _ball->setPosition(ptNext); @@ -85,7 +85,7 @@ void AccelerometerTest::didAccelerate(Acceleration* pAccelerationValue) //------------------------------------------------------------------ void AccelerometerTestScene::runThisTest() { - Layer* layer = new AccelerometerTest(); + auto layer = new AccelerometerTest(); addChild(layer); layer->release(); diff --git a/samples/Cpp/TestCpp/Classes/ActionManagerTest/ActionManagerTest.cpp b/samples/Cpp/TestCpp/Classes/ActionManagerTest/ActionManagerTest.cpp index 66cb282165..7633322c70 100644 --- a/samples/Cpp/TestCpp/Classes/ActionManagerTest/ActionManagerTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ActionManagerTest/ActionManagerTest.cpp @@ -36,7 +36,7 @@ Layer* nextActionManagerAction() sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - Layer* layer = createActionManagerLayer(sceneIdx); + auto layer = createActionManagerLayer(sceneIdx); layer->autorelease(); return layer; @@ -49,7 +49,7 @@ Layer* backActionManagerAction() if( sceneIdx < 0 ) sceneIdx += total; - Layer* layer = createActionManagerLayer(sceneIdx); + auto layer = createActionManagerLayer(sceneIdx); layer->autorelease(); return layer; @@ -57,7 +57,7 @@ Layer* backActionManagerAction() Layer* restartActionManagerAction() { - Layer* layer = createActionManagerLayer(sceneIdx); + auto layer = createActionManagerLayer(sceneIdx); layer->autorelease(); return layer; @@ -84,7 +84,7 @@ std::string ActionManagerTest::title() void ActionManagerTest::restartCallback(Object* sender) { - Scene* s = new ActionManagerTestScene(); + auto s = new ActionManagerTestScene(); s->addChild(restartActionManagerAction()); Director::getInstance()->replaceScene(s); @@ -93,7 +93,7 @@ void ActionManagerTest::restartCallback(Object* sender) void ActionManagerTest::nextCallback(Object* sender) { - Scene* s = new ActionManagerTestScene(); + auto s = new ActionManagerTestScene(); s->addChild( nextActionManagerAction() ); Director::getInstance()->replaceScene(s); s->release(); @@ -101,7 +101,7 @@ void ActionManagerTest::nextCallback(Object* sender) void ActionManagerTest::backCallback(Object* sender) { - Scene* s = new ActionManagerTestScene(); + auto s = new ActionManagerTestScene(); s->addChild( backActionManagerAction() ); Director::getInstance()->replaceScene(s); s->release(); @@ -117,7 +117,7 @@ void CrashTest::onEnter() { ActionManagerTest::onEnter(); - Sprite* child = Sprite::create(s_pathGrossini); + auto child = Sprite::create(s_pathGrossini); child->setPosition( VisibleRect::center() ); addChild(child, 1); @@ -158,7 +158,7 @@ void LogicTest::onEnter() { ActionManagerTest::onEnter(); - Sprite* grossini = Sprite::create(s_pathGrossini); + auto grossini = Sprite::create(s_pathGrossini); addChild(grossini, 0, 2); grossini->setPosition(VisibleRect::center()); @@ -195,7 +195,7 @@ void PauseTest::onEnter() ActionManagerTest::onEnter(); - LabelTTF* l = LabelTTF::create("After 5 seconds grossini should move", "Thonburi", 16); + auto l = LabelTTF::create("After 5 seconds grossini should move", "Thonburi", 16); addChild(l); l->setPosition( Point(VisibleRect::center().x, VisibleRect::top().y-75) ); @@ -203,13 +203,13 @@ void PauseTest::onEnter() // // Also, this test MUST be done, after [super onEnter] // - Sprite* grossini = Sprite::create(s_pathGrossini); + auto grossini = Sprite::create(s_pathGrossini); addChild(grossini, 0, kTagGrossini); grossini->setPosition(VisibleRect::center() ); - Action* action = MoveBy::create(1, Point(150,0)); + auto action = MoveBy::create(1, Point(150,0)); - Director* director = Director::getInstance(); + auto director = Director::getInstance(); director->getActionManager()->addAction(action, grossini, true); schedule( schedule_selector(PauseTest::unpause), 3); @@ -218,8 +218,8 @@ void PauseTest::onEnter() void PauseTest::unpause(float dt) { unschedule( schedule_selector(PauseTest::unpause) ); - Node* node = getChildByTag( kTagGrossini ); - Director* director = Director::getInstance(); + auto node = getChildByTag( kTagGrossini ); + auto director = Director::getInstance(); director->getActionManager()->resumeTarget(node); } @@ -237,16 +237,16 @@ void RemoveTest::onEnter() { ActionManagerTest::onEnter(); - LabelTTF* l = LabelTTF::create("Should not crash", "Thonburi", 16); + auto l = LabelTTF::create("Should not crash", "Thonburi", 16); addChild(l); l->setPosition( Point(VisibleRect::center().x, VisibleRect::top().y - 75) ); - MoveBy* pMove = MoveBy::create(2, Point(200, 0)); - CallFunc* pCallback = CallFunc::create(CC_CALLBACK_0(RemoveTest::stopAction,this)); - ActionInterval* pSequence = Sequence::create(pMove, pCallback, NULL); + auto pMove = MoveBy::create(2, Point(200, 0)); + auto pCallback = CallFunc::create(CC_CALLBACK_0(RemoveTest::stopAction,this)); + auto pSequence = Sequence::create(pMove, pCallback, NULL); pSequence->setTag(kTagSequence); - Sprite* pChild = Sprite::create(s_pathGrossini); + auto pChild = Sprite::create(s_pathGrossini); pChild->setPosition( VisibleRect::center() ); addChild(pChild, 1, kTagGrossini); @@ -255,7 +255,7 @@ void RemoveTest::onEnter() void RemoveTest::stopAction() { - Node* sprite = getChildByTag(kTagGrossini); + auto sprite = getChildByTag(kTagGrossini); sprite->stopActionByTag(kTagSequence); } @@ -278,17 +278,17 @@ void ResumeTest::onEnter() { ActionManagerTest::onEnter(); - LabelTTF* l = LabelTTF::create("Grossini only rotate/scale in 3 seconds", "Thonburi", 16); + auto l = LabelTTF::create("Grossini only rotate/scale in 3 seconds", "Thonburi", 16); addChild(l); l->setPosition( Point(VisibleRect::center().x, VisibleRect::top().y - 75)); - Sprite* pGrossini = Sprite::create(s_pathGrossini); + auto pGrossini = Sprite::create(s_pathGrossini); addChild(pGrossini, 0, kTagGrossini); pGrossini->setPosition(VisibleRect::center()); pGrossini->runAction(ScaleBy::create(2, 2)); - Director* director = Director::getInstance(); + auto director = Director::getInstance(); director->getActionManager()->pauseTarget(pGrossini); pGrossini->runAction(RotateBy::create(2, 360)); @@ -299,8 +299,8 @@ void ResumeTest::resumeGrossini(float time) { this->unschedule(schedule_selector(ResumeTest::resumeGrossini)); - Node* pGrossini = getChildByTag(kTagGrossini); - Director* director = Director::getInstance(); + auto pGrossini = getChildByTag(kTagGrossini); + auto director = Director::getInstance(); director->getActionManager()->resumeTarget(pGrossini); } @@ -311,7 +311,7 @@ void ResumeTest::resumeGrossini(float time) //------------------------------------------------------------------ void ActionManagerTestScene::runThisTest() { - Layer* layer = nextActionManagerAction(); + auto layer = nextActionManagerAction(); addChild(layer); Director::getInstance()->replaceScene(this); diff --git a/samples/Cpp/TestCpp/Classes/ActionsEaseTest/ActionsEaseTest.cpp b/samples/Cpp/TestCpp/Classes/ActionsEaseTest/ActionsEaseTest.cpp index b9c6e14145..f2b67b2830 100644 --- a/samples/Cpp/TestCpp/Classes/ActionsEaseTest/ActionsEaseTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ActionsEaseTest/ActionsEaseTest.cpp @@ -21,29 +21,29 @@ void SpriteEase::onEnter() { EaseSpriteDemo::onEnter(); - ActionInterval* move = MoveBy::create(3, Point(VisibleRect::right().x-130,0)); - ActionInterval* move_back = move->reverse(); + auto move = MoveBy::create(3, Point(VisibleRect::right().x-130,0)); + auto move_back = move->reverse(); - ActionInterval* move_ease_in = EaseIn::create(move->clone(), 2.5f); - ActionInterval* move_ease_in_back = move_ease_in->reverse(); + auto move_ease_in = EaseIn::create(move->clone(), 2.5f); + auto move_ease_in_back = move_ease_in->reverse(); - ActionInterval* move_ease_out = EaseOut::create(move->clone(), 2.5f); - ActionInterval* move_ease_out_back = move_ease_out->reverse(); + auto move_ease_out = EaseOut::create(move->clone(), 2.5f); + auto move_ease_out_back = move_ease_out->reverse(); - DelayTime *delay = DelayTime::create(0.25f); + auto delay = DelayTime::create(0.25f); - Sequence* seq1 = Sequence::create(move, delay, move_back, delay->clone(), NULL); - Sequence* seq2 = Sequence::create(move_ease_in, delay->clone(), move_ease_in_back, delay->clone(), NULL); - Sequence* seq3 = Sequence::create(move_ease_out, delay->clone(), move_ease_out_back, delay->clone(), NULL); + auto seq1 = Sequence::create(move, delay, move_back, delay->clone(), NULL); + auto seq2 = Sequence::create(move_ease_in, delay->clone(), move_ease_in_back, delay->clone(), NULL); + auto seq3 = Sequence::create(move_ease_out, delay->clone(), move_ease_out_back, delay->clone(), NULL); - Action *a2 = _grossini->runAction(RepeatForever::create(seq1)); + auto a2 = _grossini->runAction(RepeatForever::create(seq1)); a2->setTag(1); - Action *a1 = _tamara->runAction(RepeatForever::create(seq2)); + auto a1 = _tamara->runAction(RepeatForever::create(seq2)); a1->setTag(1); - Action *a = _kathia->runAction(RepeatForever::create(seq3)); + auto a = _kathia->runAction(RepeatForever::create(seq3)); a->setTag(1); schedule(schedule_selector(SpriteEase::testStopAction), 6.25f); @@ -73,23 +73,23 @@ void SpriteEaseInOut::onEnter() { EaseSpriteDemo::onEnter(); - ActionInterval* move = MoveBy::create(3, Point(VisibleRect::right().x-130,0)); + auto move = MoveBy::create(3, Point(VisibleRect::right().x-130,0)); // id move_back = move->reverse(); - ActionInterval* move_ease_inout1 = EaseInOut::create(move->clone(), 0.65f); - ActionInterval* move_ease_inout_back1 = move_ease_inout1->reverse(); + auto move_ease_inout1 = EaseInOut::create(move->clone(), 0.65f); + auto move_ease_inout_back1 = move_ease_inout1->reverse(); - ActionInterval* move_ease_inout2 = EaseInOut::create(move->clone(), 1.35f); - ActionInterval* move_ease_inout_back2 = move_ease_inout2->reverse(); + auto move_ease_inout2 = EaseInOut::create(move->clone(), 1.35f); + auto move_ease_inout_back2 = move_ease_inout2->reverse(); - ActionInterval* move_ease_inout3 = EaseInOut::create(move->clone(), 1.0f); - ActionInterval* move_ease_inout_back3 = move_ease_inout3->reverse(); + auto move_ease_inout3 = EaseInOut::create(move->clone(), 1.0f); + auto move_ease_inout_back3 = move_ease_inout3->reverse(); - DelayTime *delay = DelayTime::create(0.25f); + auto delay = DelayTime::create(0.25f); - Sequence* seq1 = Sequence::create( move_ease_inout1, delay, move_ease_inout_back1, delay->clone(), NULL); - Sequence* seq2 = Sequence::create( move_ease_inout2, delay->clone(), move_ease_inout_back2, delay->clone(), NULL); - Sequence* seq3 = Sequence::create( move_ease_inout3, delay->clone(), move_ease_inout_back3, delay->clone(), NULL); + auto seq1 = Sequence::create( move_ease_inout1, delay, move_ease_inout_back1, delay->clone(), NULL); + auto seq2 = Sequence::create( move_ease_inout2, delay->clone(), move_ease_inout_back2, delay->clone(), NULL); + auto seq3 = Sequence::create( move_ease_inout3, delay->clone(), move_ease_inout_back3, delay->clone(), NULL); _tamara->runAction(RepeatForever::create(seq1)); _kathia->runAction(RepeatForever::create(seq2)); @@ -112,20 +112,20 @@ void SpriteEaseExponential::onEnter() { EaseSpriteDemo::onEnter(); - ActionInterval* move = MoveBy::create(3, Point(VisibleRect::right().x-130,0)); - ActionInterval* move_back = move->reverse(); + auto move = MoveBy::create(3, Point(VisibleRect::right().x-130,0)); + auto move_back = move->reverse(); - ActionInterval* move_ease_in = EaseExponentialIn::create(move->clone()); - ActionInterval* move_ease_in_back = move_ease_in->reverse(); + auto move_ease_in = EaseExponentialIn::create(move->clone()); + auto move_ease_in_back = move_ease_in->reverse(); - ActionInterval* move_ease_out = EaseExponentialOut::create(move->clone()); - ActionInterval* move_ease_out_back = move_ease_out->reverse(); + auto move_ease_out = EaseExponentialOut::create(move->clone()); + auto move_ease_out_back = move_ease_out->reverse(); - DelayTime *delay = DelayTime::create(0.25f); + auto delay = DelayTime::create(0.25f); - Sequence* seq1 = Sequence::create(move, delay, move_back, delay->clone(), NULL); - Sequence* seq2 = Sequence::create(move_ease_in, delay->clone(), move_ease_in_back, delay->clone(), NULL); - Sequence* seq3 = Sequence::create(move_ease_out, delay->clone(), move_ease_out_back, delay->clone(), NULL); + auto seq1 = Sequence::create(move, delay, move_back, delay->clone(), NULL); + auto seq2 = Sequence::create(move_ease_in, delay->clone(), move_ease_in_back, delay->clone(), NULL); + auto seq3 = Sequence::create(move_ease_out, delay->clone(), move_ease_out_back, delay->clone(), NULL); _grossini->runAction( RepeatForever::create(seq1)); @@ -148,16 +148,16 @@ void SpriteEaseExponentialInOut::onEnter() { EaseSpriteDemo::onEnter(); - ActionInterval* move = MoveBy::create(3, Point(VisibleRect::right().x-130, 0)); - ActionInterval* move_back = move->reverse(); + auto move = MoveBy::create(3, Point(VisibleRect::right().x-130, 0)); + auto move_back = move->reverse(); - ActionInterval* move_ease = EaseExponentialInOut::create(move->clone() ); - ActionInterval* move_ease_back = move_ease->reverse(); //--> reverse() + auto move_ease = EaseExponentialInOut::create(move->clone() ); + auto move_ease_back = move_ease->reverse(); //--> reverse() - DelayTime *delay = DelayTime::create(0.25f); + auto delay = DelayTime::create(0.25f); - Sequence* seq1 = Sequence::create( move, delay, move_back, delay->clone(), NULL); - Sequence* seq2 = Sequence::create( move_ease, delay, move_ease_back, delay->clone(), NULL); + auto seq1 = Sequence::create( move, delay, move_back, delay->clone(), NULL); + auto seq2 = Sequence::create( move_ease, delay, move_ease_back, delay->clone(), NULL); this->positionForTwo(); @@ -181,20 +181,20 @@ void SpriteEaseSine::onEnter() { EaseSpriteDemo::onEnter(); - ActionInterval* move = MoveBy::create(3, Point(VisibleRect::right().x-130, 0)); - ActionInterval* move_back = move->reverse(); + auto move = MoveBy::create(3, Point(VisibleRect::right().x-130, 0)); + auto move_back = move->reverse(); - ActionInterval* move_ease_in = EaseSineIn::create(move->clone() ); - ActionInterval* move_ease_in_back = move_ease_in->reverse(); + auto move_ease_in = EaseSineIn::create(move->clone() ); + auto move_ease_in_back = move_ease_in->reverse(); - ActionInterval* move_ease_out = EaseSineOut::create(move->clone() ); - ActionInterval* move_ease_out_back = move_ease_out->reverse(); + auto move_ease_out = EaseSineOut::create(move->clone() ); + auto move_ease_out_back = move_ease_out->reverse(); - DelayTime *delay = DelayTime::create(0.25f); + auto delay = DelayTime::create(0.25f); - Sequence* seq1 = Sequence::create(move, delay, move_back, delay->clone(), NULL); - Sequence* seq2 = Sequence::create(move_ease_in, delay->clone(), move_ease_in_back, delay->clone(), NULL); - Sequence* seq3 = Sequence::create(move_ease_out, delay->clone(), move_ease_out_back, delay->clone(), NULL); + auto seq1 = Sequence::create(move, delay, move_back, delay->clone(), NULL); + auto seq2 = Sequence::create(move_ease_in, delay->clone(), move_ease_in_back, delay->clone(), NULL); + auto seq3 = Sequence::create(move_ease_out, delay->clone(), move_ease_out_back, delay->clone(), NULL); _grossini->runAction( RepeatForever::create(seq1)); @@ -218,16 +218,16 @@ void SpriteEaseSineInOut::onEnter() { EaseSpriteDemo::onEnter(); - ActionInterval* move = MoveBy::create(3, Point(VisibleRect::right().x-130,0)); - ActionInterval* move_back = move->reverse(); + auto move = MoveBy::create(3, Point(VisibleRect::right().x-130,0)); + auto move_back = move->reverse(); - ActionInterval* move_ease = EaseSineInOut::create(move->clone() ); - ActionInterval* move_ease_back = move_ease->reverse(); + auto move_ease = EaseSineInOut::create(move->clone() ); + auto move_ease_back = move_ease->reverse(); - DelayTime *delay = DelayTime::create(0.25f); + auto delay = DelayTime::create(0.25f); - Sequence* seq1 = Sequence::create(move, delay, move_back, delay->clone(), NULL); - Sequence* seq2 = Sequence::create(move_ease, delay->clone(), move_ease_back, delay->clone(), NULL); + auto seq1 = Sequence::create(move, delay, move_back, delay->clone(), NULL); + auto seq2 = Sequence::create(move_ease, delay->clone(), move_ease_back, delay->clone(), NULL); this->positionForTwo(); @@ -250,20 +250,20 @@ void SpriteEaseElastic::onEnter() { EaseSpriteDemo::onEnter(); - ActionInterval* move = MoveBy::create(3, Point(VisibleRect::right().x-130, 0)); - ActionInterval* move_back = move->reverse(); + auto move = MoveBy::create(3, Point(VisibleRect::right().x-130, 0)); + auto move_back = move->reverse(); - ActionInterval* move_ease_in = EaseElasticIn::create(move->clone() ); - ActionInterval* move_ease_in_back = move_ease_in->reverse(); + auto move_ease_in = EaseElasticIn::create(move->clone() ); + auto move_ease_in_back = move_ease_in->reverse(); - ActionInterval* move_ease_out = EaseElasticOut::create(move->clone() ); - ActionInterval* move_ease_out_back = move_ease_out->reverse(); + auto move_ease_out = EaseElasticOut::create(move->clone() ); + auto move_ease_out_back = move_ease_out->reverse(); - DelayTime *delay = DelayTime::create(0.25f); + auto delay = DelayTime::create(0.25f); - Sequence* seq1 = Sequence::create(move, delay, move_back, delay->clone(), NULL); - Sequence* seq2 = Sequence::create(move_ease_in, delay->clone(), move_ease_in_back, delay->clone(), NULL); - Sequence* seq3 = Sequence::create(move_ease_out, delay->clone(), move_ease_out_back, delay->clone(), NULL); + auto seq1 = Sequence::create(move, delay, move_back, delay->clone(), NULL); + auto seq2 = Sequence::create(move_ease_in, delay->clone(), move_ease_in_back, delay->clone(), NULL); + auto seq3 = Sequence::create(move_ease_out, delay->clone(), move_ease_out_back, delay->clone(), NULL); _grossini->runAction( RepeatForever::create(seq1)); _tamara->runAction( RepeatForever::create(seq2)); @@ -286,22 +286,22 @@ void SpriteEaseElasticInOut::onEnter() { EaseSpriteDemo::onEnter(); - ActionInterval* move = MoveBy::create(3, Point(VisibleRect::right().x-130, 0)); + auto move = MoveBy::create(3, Point(VisibleRect::right().x-130, 0)); - ActionInterval* move_ease_inout1 = EaseElasticInOut::create(move->clone(), 0.3f); - ActionInterval* move_ease_inout_back1 = move_ease_inout1->reverse(); + auto move_ease_inout1 = EaseElasticInOut::create(move->clone(), 0.3f); + auto move_ease_inout_back1 = move_ease_inout1->reverse(); - ActionInterval* move_ease_inout2 = EaseElasticInOut::create(move->clone(), 0.45f); - ActionInterval* move_ease_inout_back2 = move_ease_inout2->reverse(); + auto move_ease_inout2 = EaseElasticInOut::create(move->clone(), 0.45f); + auto move_ease_inout_back2 = move_ease_inout2->reverse(); - ActionInterval* move_ease_inout3 = EaseElasticInOut::create(move->clone(), 0.6f); - ActionInterval* move_ease_inout_back3 = move_ease_inout3->reverse(); + auto move_ease_inout3 = EaseElasticInOut::create(move->clone(), 0.6f); + auto move_ease_inout_back3 = move_ease_inout3->reverse(); - DelayTime *delay = DelayTime::create(0.25f); + auto delay = DelayTime::create(0.25f); - Sequence* seq1 = Sequence::create(move_ease_inout1, delay, move_ease_inout_back1, delay->clone(), NULL); - Sequence* seq2 = Sequence::create(move_ease_inout2, delay->clone(), move_ease_inout_back2, delay->clone(), NULL); - Sequence* seq3 = Sequence::create(move_ease_inout3, delay->clone(), move_ease_inout_back3, delay->clone(), NULL); + auto seq1 = Sequence::create(move_ease_inout1, delay, move_ease_inout_back1, delay->clone(), NULL); + auto seq2 = Sequence::create(move_ease_inout2, delay->clone(), move_ease_inout_back2, delay->clone(), NULL); + auto seq3 = Sequence::create(move_ease_inout3, delay->clone(), move_ease_inout_back3, delay->clone(), NULL); _tamara->runAction( RepeatForever::create(seq1)); _kathia->runAction( RepeatForever::create(seq2)); @@ -325,20 +325,20 @@ void SpriteEaseBounce::onEnter() { EaseSpriteDemo::onEnter(); - ActionInterval* move = MoveBy::create(3, Point(VisibleRect::right().x-130, 0)); - ActionInterval* move_back = move->reverse(); + auto move = MoveBy::create(3, Point(VisibleRect::right().x-130, 0)); + auto move_back = move->reverse(); - ActionInterval* move_ease_in = EaseBounceIn::create(move->clone() ); - ActionInterval* move_ease_in_back = move_ease_in->reverse(); + auto move_ease_in = EaseBounceIn::create(move->clone() ); + auto move_ease_in_back = move_ease_in->reverse(); - ActionInterval* move_ease_out = EaseBounceOut::create(move->clone() ); - ActionInterval* move_ease_out_back = move_ease_out->reverse(); + auto move_ease_out = EaseBounceOut::create(move->clone() ); + auto move_ease_out_back = move_ease_out->reverse(); - DelayTime *delay = DelayTime::create(0.25f); + auto delay = DelayTime::create(0.25f); - Sequence* seq1 = Sequence::create(move, delay, move_back, delay->clone(), NULL); - Sequence* seq2 = Sequence::create(move_ease_in, delay->clone(), move_ease_in_back, delay->clone(), NULL); - Sequence* seq3 = Sequence::create(move_ease_out, delay->clone(), move_ease_out_back, delay->clone(), NULL); + auto seq1 = Sequence::create(move, delay, move_back, delay->clone(), NULL); + auto seq2 = Sequence::create(move_ease_in, delay->clone(), move_ease_in_back, delay->clone(), NULL); + auto seq3 = Sequence::create(move_ease_out, delay->clone(), move_ease_out_back, delay->clone(), NULL); _grossini->runAction( RepeatForever::create(seq1)); _tamara->runAction( RepeatForever::create(seq2)); @@ -362,16 +362,16 @@ void SpriteEaseBounceInOut::onEnter() { EaseSpriteDemo::onEnter(); - ActionInterval* move = MoveBy::create(3, Point(VisibleRect::right().x-130, 0)); - ActionInterval* move_back = move->reverse(); + auto move = MoveBy::create(3, Point(VisibleRect::right().x-130, 0)); + auto move_back = move->reverse(); - ActionInterval* move_ease = EaseBounceInOut::create(move->clone() ); - ActionInterval* move_ease_back = move_ease->reverse(); + auto move_ease = EaseBounceInOut::create(move->clone() ); + auto move_ease_back = move_ease->reverse(); - DelayTime *delay = DelayTime::create(0.25f); + auto delay = DelayTime::create(0.25f); - Sequence* seq1 = Sequence::create(move, delay, move_back, delay->clone(), NULL); - Sequence* seq2 = Sequence::create(move_ease, delay->clone(), move_ease_back, delay->clone(), NULL); + auto seq1 = Sequence::create(move, delay, move_back, delay->clone(), NULL); + auto seq2 = Sequence::create(move_ease, delay->clone(), move_ease_back, delay->clone(), NULL); this->positionForTwo(); @@ -395,20 +395,20 @@ void SpriteEaseBack::onEnter() { EaseSpriteDemo::onEnter(); - ActionInterval* move = MoveBy::create(3, Point(VisibleRect::right().x-130, 0)); - ActionInterval* move_back = move->reverse(); + auto move = MoveBy::create(3, Point(VisibleRect::right().x-130, 0)); + auto move_back = move->reverse(); - ActionInterval* move_ease_in = EaseBackIn::create(move->clone()); - ActionInterval* move_ease_in_back = move_ease_in->reverse(); + auto move_ease_in = EaseBackIn::create(move->clone()); + auto move_ease_in_back = move_ease_in->reverse(); - ActionInterval* move_ease_out = EaseBackOut::create( move->clone()); - ActionInterval* move_ease_out_back = move_ease_out->reverse(); + auto move_ease_out = EaseBackOut::create( move->clone()); + auto move_ease_out_back = move_ease_out->reverse(); - DelayTime *delay = DelayTime::create(0.25f); + auto delay = DelayTime::create(0.25f); - Sequence* seq1 = Sequence::create(move, delay, move_back, delay->clone(), NULL); - Sequence* seq2 = Sequence::create(move_ease_in, delay->clone(), move_ease_in_back, delay->clone(), NULL); - Sequence* seq3 = Sequence::create(move_ease_out, delay->clone(), move_ease_out_back, delay->clone(), NULL); + auto seq1 = Sequence::create(move, delay, move_back, delay->clone(), NULL); + auto seq2 = Sequence::create(move_ease_in, delay->clone(), move_ease_in_back, delay->clone(), NULL); + auto seq3 = Sequence::create(move_ease_out, delay->clone(), move_ease_out_back, delay->clone(), NULL); _grossini->runAction(RepeatForever::create(seq1)); _tamara->runAction(RepeatForever::create(seq2)); @@ -431,16 +431,16 @@ void SpriteEaseBackInOut::onEnter() { EaseSpriteDemo::onEnter(); - ActionInterval* move = MoveBy::create(3, Point(VisibleRect::right().x-130, 0)); - ActionInterval* move_back = move->reverse(); + auto move = MoveBy::create(3, Point(VisibleRect::right().x-130, 0)); + auto move_back = move->reverse(); - ActionInterval* move_ease = EaseBackInOut::create(move->clone() ); - ActionInterval* move_ease_back = move_ease->reverse(); + auto move_ease = EaseBackInOut::create(move->clone() ); + auto move_ease_back = move_ease->reverse(); - DelayTime *delay = DelayTime::create(0.25f); + auto delay = DelayTime::create(0.25f); - Sequence* seq1 = Sequence::create(move, delay, move_back, delay->clone(), NULL); - Sequence* seq2 = Sequence::create(move_ease, delay->clone(), move_ease_back, delay->clone(), NULL); + auto seq1 = Sequence::create(move, delay, move_back, delay->clone(), NULL); + auto seq2 = Sequence::create(move_ease, delay->clone(), move_ease_back, delay->clone(), NULL); this->positionForTwo(); @@ -464,22 +464,22 @@ void SpeedTest::onEnter() { EaseSpriteDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); // rotate and jump - ActionInterval *jump1 = JumpBy::create(4, Point(-s.width+80, 0), 100, 4); - ActionInterval *jump2 = jump1->reverse(); - ActionInterval *rot1 = RotateBy::create(4, 360*2); - ActionInterval *rot2 = rot1->reverse(); + auto jump1 = JumpBy::create(4, Point(-s.width+80, 0), 100, 4); + auto jump2 = jump1->reverse(); + auto rot1 = RotateBy::create(4, 360*2); + auto rot2 = rot1->reverse(); - Sequence* seq3_1 = Sequence::create(jump2, jump1, NULL); - Sequence* seq3_2 = Sequence::create( rot1, rot2, NULL); - Spawn* spawn = Spawn::create(seq3_1, seq3_2, NULL); - Speed* action = Speed::create(RepeatForever::create(spawn), 1.0f); + auto seq3_1 = Sequence::create(jump2, jump1, NULL); + auto seq3_2 = Sequence::create( rot1, rot2, NULL); + auto spawn = Spawn::create(seq3_1, seq3_2, NULL); + auto action = Speed::create(RepeatForever::create(spawn), 1.0f); action->setTag(kTagAction1); - Action* action2 = action->clone(); - Action* action3 = action->clone(); + auto action2 = action->clone(); + auto action3 = action->clone(); action2->setTag(kTagAction1); action3->setTag(kTagAction1); @@ -493,9 +493,9 @@ void SpeedTest::onEnter() void SpeedTest::altertime(float dt) { - Speed* action1 = static_cast(_grossini->getActionByTag(kTagAction1)); - Speed* action2 = static_cast(_tamara->getActionByTag(kTagAction1)); - Speed* action3 = static_cast(_kathia->getActionByTag(kTagAction1)); + auto action1 = static_cast(_grossini->getActionByTag(kTagAction1)); + auto action2 = static_cast(_tamara->getActionByTag(kTagAction1)); + auto action3 = static_cast(_kathia->getActionByTag(kTagAction1)); action1->setSpeed( CCRANDOM_MINUS1_1() * 2 ); action2->setSpeed( CCRANDOM_MINUS1_1() * 2 ); @@ -552,7 +552,7 @@ Layer* nextEaseAction() sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - Layer* layer = createEaseLayer(sceneIdx); + auto layer = createEaseLayer(sceneIdx); layer->autorelease(); return layer; @@ -565,7 +565,7 @@ Layer* backEaseAction() if( sceneIdx < 0 ) sceneIdx += total; - Layer* layer = createEaseLayer(sceneIdx); + auto layer = createEaseLayer(sceneIdx); layer->autorelease(); return layer; @@ -573,7 +573,7 @@ Layer* backEaseAction() Layer* restartEaseAction() { - Layer* layer = createEaseLayer(sceneIdx); + auto layer = createEaseLayer(sceneIdx); layer->autorelease(); return layer; @@ -624,7 +624,7 @@ void EaseSpriteDemo::onEnter() void EaseSpriteDemo::restartCallback(Object* sender) { - Scene* s = new ActionsEaseTestScene();//CCScene::create(); + auto s = new ActionsEaseTestScene();//CCScene::create(); s->addChild(restartEaseAction()); Director::getInstance()->replaceScene(s); @@ -633,7 +633,7 @@ void EaseSpriteDemo::restartCallback(Object* sender) void EaseSpriteDemo::nextCallback(Object* sender) { - Scene* s = new ActionsEaseTestScene();//CCScene::create(); + auto s = new ActionsEaseTestScene();//CCScene::create(); s->addChild( nextEaseAction() ); Director::getInstance()->replaceScene(s); s->release(); @@ -641,7 +641,7 @@ void EaseSpriteDemo::nextCallback(Object* sender) void EaseSpriteDemo::backCallback(Object* sender) { - Scene* s = new ActionsEaseTestScene();//CCScene::create(); + auto s = new ActionsEaseTestScene();//CCScene::create(); s->addChild( backEaseAction() ); Director::getInstance()->replaceScene(s); s->release(); @@ -649,7 +649,7 @@ void EaseSpriteDemo::backCallback(Object* sender) void ActionsEaseTestScene::runThisTest() { - Layer* layer = nextEaseAction(); + auto layer = nextEaseAction(); addChild(layer); Director::getInstance()->replaceScene(this); diff --git a/samples/Cpp/TestCpp/Classes/ActionsProgressTest/ActionsProgressTest.cpp b/samples/Cpp/TestCpp/Classes/ActionsProgressTest/ActionsProgressTest.cpp index 5f904e8f7b..33ecdd7fc3 100644 --- a/samples/Cpp/TestCpp/Classes/ActionsProgressTest/ActionsProgressTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ActionsProgressTest/ActionsProgressTest.cpp @@ -30,7 +30,7 @@ Layer* nextAction() sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - Layer* layer = createLayer(sceneIdx); + auto layer = createLayer(sceneIdx); layer->autorelease(); return layer; @@ -43,7 +43,7 @@ Layer* backAction() if( sceneIdx < 0 ) sceneIdx += total; - Layer* layer = createLayer(sceneIdx); + auto layer = createLayer(sceneIdx); layer->autorelease(); return layer; @@ -51,7 +51,7 @@ Layer* backAction() Layer* restartAction() { - Layer* layer = createLayer(sceneIdx); + auto layer = createLayer(sceneIdx); layer->autorelease(); return layer; @@ -92,13 +92,13 @@ void SpriteDemo::onEnter() { BaseTest::onEnter(); - LayerColor *background = LayerColor::create(Color4B(255,0,0,255)); + auto background = LayerColor::create(Color4B(255,0,0,255)); addChild(background, -10); } void SpriteDemo::restartCallback(Object* sender) { - Scene* s = new ProgressActionsTestScene(); + auto s = new ProgressActionsTestScene(); s->addChild(restartAction()); Director::getInstance()->replaceScene(s); @@ -107,7 +107,7 @@ void SpriteDemo::restartCallback(Object* sender) void SpriteDemo::nextCallback(Object* sender) { - Scene* s = new ProgressActionsTestScene(); + auto s = new ProgressActionsTestScene(); s->addChild( nextAction() ); Director::getInstance()->replaceScene(s); s->release(); @@ -115,7 +115,7 @@ void SpriteDemo::nextCallback(Object* sender) void SpriteDemo::backCallback(Object* sender) { - Scene* s = new ProgressActionsTestScene(); + auto s = new ProgressActionsTestScene(); s->addChild( backAction() ); Director::getInstance()->replaceScene(s); s->release(); @@ -130,18 +130,18 @@ void SpriteProgressToRadial::onEnter() { SpriteDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - ProgressTo *to1 = ProgressTo::create(2, 100); - ProgressTo *to2 = ProgressTo::create(2, 100); + auto to1 = ProgressTo::create(2, 100); + auto to2 = ProgressTo::create(2, 100); - ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathSister1)); + auto left = ProgressTimer::create(Sprite::create(s_pathSister1)); left->setType( ProgressTimer::Type::RADIAL ); addChild(left); left->setPosition(Point(100, s.height/2)); left->runAction( RepeatForever::create(to1)); - ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathBlock)); + auto right = ProgressTimer::create(Sprite::create(s_pathBlock)); right->setType(ProgressTimer::Type::RADIAL); // Makes the ridial CCW right->setReverseProgress(true); @@ -165,12 +165,12 @@ void SpriteProgressToHorizontal::onEnter() { SpriteDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - ProgressTo *to1 = ProgressTo::create(2, 100); - ProgressTo *to2 = ProgressTo::create(2, 100); + auto to1 = ProgressTo::create(2, 100); + auto to2 = ProgressTo::create(2, 100); - ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathSister1)); + auto left = ProgressTimer::create(Sprite::create(s_pathSister1)); left->setType(ProgressTimer::Type::BAR); // Setup for a bar starting from the left since the midpoint is 0 for the x left->setMidpoint(Point(0,0)); @@ -180,7 +180,7 @@ void SpriteProgressToHorizontal::onEnter() left->setPosition(Point(100, s.height/2)); left->runAction( RepeatForever::create(to1)); - ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathSister2)); + auto right = ProgressTimer::create(Sprite::create(s_pathSister2)); right->setType(ProgressTimer::Type::BAR); // Setup for a bar starting from the left since the midpoint is 1 for the x right->setMidpoint(Point(1, 0)); @@ -205,12 +205,12 @@ void SpriteProgressToVertical::onEnter() { SpriteDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - ProgressTo *to1 = ProgressTo::create(2, 100); - ProgressTo *to2 = ProgressTo::create(2, 100); + auto to1 = ProgressTo::create(2, 100); + auto to2 = ProgressTo::create(2, 100); - ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathSister1)); + auto left = ProgressTimer::create(Sprite::create(s_pathSister1)); left->setType(ProgressTimer::Type::BAR); // Setup for a bar starting from the bottom since the midpoint is 0 for the y @@ -221,7 +221,7 @@ void SpriteProgressToVertical::onEnter() left->setPosition(Point(100, s.height/2)); left->runAction( RepeatForever::create(to1)); - ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathSister2)); + auto right = ProgressTimer::create(Sprite::create(s_pathSister2)); right->setType(ProgressTimer::Type::BAR); // Setup for a bar starting from the bottom since the midpoint is 0 for the y right->setMidpoint(Point(0, 1)); @@ -246,14 +246,14 @@ void SpriteProgressToRadialMidpointChanged::onEnter() { SpriteDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - ProgressTo *action = ProgressTo::create(2, 100); + auto action = ProgressTo::create(2, 100); /** * Our image on the left should be a radial progress indicator, clockwise */ - ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathBlock)); + auto left = ProgressTimer::create(Sprite::create(s_pathBlock)); left->setType(ProgressTimer::Type::RADIAL); addChild(left); left->setMidpoint(Point(0.25f, 0.75f)); @@ -263,7 +263,7 @@ void SpriteProgressToRadialMidpointChanged::onEnter() /** * Our image on the left should be a radial progress indicator, counter clockwise */ - ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathBlock)); + auto right = ProgressTimer::create(Sprite::create(s_pathBlock)); right->setType(ProgressTimer::Type::RADIAL); right->setMidpoint(Point(0.75f, 0.25f)); @@ -290,11 +290,11 @@ void SpriteProgressBarVarious::onEnter() { SpriteDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - ProgressTo *to = ProgressTo::create(2, 100); + auto to = ProgressTo::create(2, 100); - ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathSister1)); + auto left = ProgressTimer::create(Sprite::create(s_pathSister1)); left->setType(ProgressTimer::Type::BAR); // Setup for a bar starting from the bottom since the midpoint is 0 for the y @@ -305,7 +305,7 @@ void SpriteProgressBarVarious::onEnter() left->setPosition(Point(100, s.height/2)); left->runAction(RepeatForever::create(to->clone())); - ProgressTimer *middle = ProgressTimer::create(Sprite::create(s_pathSister2)); + auto middle = ProgressTimer::create(Sprite::create(s_pathSister2)); middle->setType(ProgressTimer::Type::BAR); // Setup for a bar starting from the bottom since the midpoint is 0 for the y middle->setMidpoint(Point(0.5f, 0.5f)); @@ -315,7 +315,7 @@ void SpriteProgressBarVarious::onEnter() middle->setPosition(Point(s.width/2, s.height/2)); middle->runAction(RepeatForever::create(to->clone())); - ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathSister2)); + auto right = ProgressTimer::create(Sprite::create(s_pathSister2)); right->setType(ProgressTimer::Type::BAR); // Setup for a bar starting from the bottom since the midpoint is 0 for the y right->setMidpoint(Point(0.5f, 0.5f)); @@ -340,9 +340,9 @@ void SpriteProgressBarTintAndFade::onEnter() { SpriteDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - ProgressTo *to = ProgressTo::create(6, 100); + auto to = ProgressTo::create(6, 100); auto tint = Sequence::create(TintTo::create(1, 255, 0, 0), TintTo::create(1, 0, 255, 0), TintTo::create(1, 0, 0, 255), @@ -351,7 +351,7 @@ void SpriteProgressBarTintAndFade::onEnter() FadeTo::create(1.0f, 255), NULL); - ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathSister1)); + auto left = ProgressTimer::create(Sprite::create(s_pathSister1)); left->setType(ProgressTimer::Type::BAR); // Setup for a bar starting from the bottom since the midpoint is 0 for the y @@ -365,7 +365,7 @@ void SpriteProgressBarTintAndFade::onEnter() left->addChild(LabelTTF::create("Tint", "Marker Felt", 20.0f)); - ProgressTimer *middle = ProgressTimer::create(Sprite::create(s_pathSister2)); + auto middle = ProgressTimer::create(Sprite::create(s_pathSister2)); middle->setType(ProgressTimer::Type::BAR); // Setup for a bar starting from the bottom since the midpoint is 0 for the y middle->setMidpoint(Point(0.5f, 0.5f)); @@ -378,7 +378,7 @@ void SpriteProgressBarTintAndFade::onEnter() middle->addChild(LabelTTF::create("Fade", "Marker Felt", 20.0f)); - ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathSister2)); + auto right = ProgressTimer::create(Sprite::create(s_pathSister2)); right->setType(ProgressTimer::Type::BAR); // Setup for a bar starting from the bottom since the midpoint is 0 for the y right->setMidpoint(Point(0.5f, 0.5f)); @@ -407,13 +407,13 @@ void SpriteProgressWithSpriteFrame::onEnter() { SpriteDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - ProgressTo *to = ProgressTo::create(6, 100); + auto to = ProgressTo::create(6, 100); SpriteFrameCache::getInstance()->addSpriteFramesWithFile("zwoptex/grossini.plist"); - ProgressTimer *left = ProgressTimer::create(Sprite::createWithSpriteFrameName("grossini_dance_01.png")); + auto left = ProgressTimer::create(Sprite::createWithSpriteFrameName("grossini_dance_01.png")); left->setType(ProgressTimer::Type::BAR); // Setup for a bar starting from the bottom since the midpoint is 0 for the y left->setMidpoint(Point(0.5f, 0.5f)); @@ -423,7 +423,7 @@ void SpriteProgressWithSpriteFrame::onEnter() left->setPosition(Point(100, s.height/2)); left->runAction(RepeatForever::create(to->clone())); - ProgressTimer *middle = ProgressTimer::create(Sprite::createWithSpriteFrameName("grossini_dance_02.png")); + auto middle = ProgressTimer::create(Sprite::createWithSpriteFrameName("grossini_dance_02.png")); middle->setType(ProgressTimer::Type::BAR); // Setup for a bar starting from the bottom since the midpoint is 0 for the y middle->setMidpoint(Point(0.5f, 0.5f)); @@ -433,7 +433,7 @@ void SpriteProgressWithSpriteFrame::onEnter() middle->setPosition(Point(s.width/2, s.height/2)); middle->runAction(RepeatForever::create(to->clone())); - ProgressTimer *right = ProgressTimer::create(Sprite::createWithSpriteFrameName("grossini_dance_03.png")); + auto right = ProgressTimer::create(Sprite::createWithSpriteFrameName("grossini_dance_03.png")); right->setType(ProgressTimer::Type::RADIAL); // Setup for a bar starting from the bottom since the midpoint is 0 for the y right->setMidpoint(Point(0.5f, 0.5f)); diff --git a/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.cpp b/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.cpp index 23a6ba6791..0dfd18a316 100644 --- a/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.cpp @@ -62,7 +62,7 @@ static Layer* nextAction() sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - Layer* layer = (createFunctions[sceneIdx])(); + auto layer = (createFunctions[sceneIdx])(); layer->init(); layer->autorelease(); @@ -76,7 +76,7 @@ static Layer* backAction() if( sceneIdx < 0 ) sceneIdx += total; - Layer* layer = (createFunctions[sceneIdx])(); + auto layer = (createFunctions[sceneIdx])(); layer->init(); layer->autorelease(); @@ -85,7 +85,7 @@ static Layer* backAction() static Layer* restartAction() { - Layer* layer = (createFunctions[sceneIdx])(); + auto layer = (createFunctions[sceneIdx])(); layer->init(); layer->autorelease(); @@ -145,7 +145,7 @@ void ActionsDemo::onExit() void ActionsDemo::restartCallback(Object* sender) { - Scene* s = new ActionsTestScene(); + auto s = new ActionsTestScene(); s->addChild( restartAction() ); Director::getInstance()->replaceScene(s); s->release(); @@ -153,7 +153,7 @@ void ActionsDemo::restartCallback(Object* sender) void ActionsDemo::nextCallback(Object* sender) { - Scene* s = new ActionsTestScene(); + auto s = new ActionsTestScene(); s->addChild( nextAction() ); Director::getInstance()->replaceScene(s); s->release(); @@ -161,7 +161,7 @@ void ActionsDemo::nextCallback(Object* sender) void ActionsDemo::backCallback(Object* sender) { - Scene* s = new ActionsTestScene(); + auto s = new ActionsTestScene(); s->addChild( backAction() ); Director::getInstance()->replaceScene(s); s->release(); @@ -647,7 +647,7 @@ void ActionAnimate::onEnter() // // Manual animation // - Animation* animation = Animation::create(); + auto animation = Animation::create(); for( int i=1;i<15;i++) { char szName[100] = {0}; @@ -658,24 +658,24 @@ void ActionAnimate::onEnter() animation->setDelayPerUnit(2.8f / 14.0f); animation->setRestoreOriginalFrame(true); - Animate* action = Animate::create(animation); + auto action = Animate::create(animation); _grossini->runAction(Sequence::create(action, action->reverse(), NULL)); // // File animation // // With 2 loops and reverse - AnimationCache *cache = AnimationCache::getInstance(); + auto cache = AnimationCache::getInstance(); cache->addAnimationsWithFile("animations/animations-2.plist"); - Animation *animation2 = cache->animationByName("dance_1"); + auto animation2 = cache->animationByName("dance_1"); - Animate* action2 = Animate::create(animation2); + auto action2 = Animate::create(animation2); _tamara->runAction(Sequence::create(action2, action2->reverse(), NULL)); // TODO: // observer_ = [[NSNotificationCenter defaultCenter] addObserverForName:AnimationFrameDisplayedNotification object:nil queue:nil usingBlock:^(NSNotification* notification) { // -// NSDictionary *userInfo = [notification userInfo); +// auto userInfo = [notification userInfo); // NSLog(@"object %@ with data %@", [notification object), userInfo ); // }); @@ -684,11 +684,11 @@ void ActionAnimate::onEnter() // File animation // // with 4 loops - Animation *animation3 = animation2->clone(); + auto animation3 = animation2->clone(); animation3->setLoops(4); - Animate* action3 = Animate::create(animation3); + auto action3 = Animate::create(animation3); _kathia->runAction(action3); } @@ -1388,7 +1388,7 @@ void ActionStacked::addNewSpriteWithCoords(Point p) int y = (idx/5) * 121; - Sprite *sprite = Sprite::create("Images/grossini_dance_atlas.png", Rect(x,y,85,121)); + auto sprite = Sprite::create("Images/grossini_dance_atlas.png", Rect(x,y,85,121)); sprite->setPosition(p); this->addChild(sprite); @@ -1407,7 +1407,7 @@ void ActionStacked::ccTouchesEnded(Set* touches, Event* event) const Touch *touch = static_cast(item); - Point location = touch->getLocation(); + auto location = touch->getLocation(); addNewSpriteWithCoords( location ); } } @@ -1434,8 +1434,8 @@ void ActionMoveStacked::runActionsInSprite(Sprite *sprite) MoveBy::create(0.05f, Point(-10,-10)), NULL))); - MoveBy* action = MoveBy::create(2.0f, Point(400,0)); - MoveBy* action_back = action->reverse(); + auto action = MoveBy::create(2.0f, Point(400,0)); + auto action_back = action->reverse(); sprite->runAction( RepeatForever::create( @@ -1486,10 +1486,10 @@ void ActionMoveBezierStacked::runActionsInSprite(Sprite *sprite) bezier.controlPoint_2 = Point(300, -s.height/2); bezier.endPosition = Point(300,100); - BezierBy* bezierForward = BezierBy::create(3, bezier); - BezierBy* bezierBack = bezierForward->reverse(); + auto bezierForward = BezierBy::create(3, bezier); + auto bezierBack = bezierForward->reverse(); auto seq = Sequence::create(bezierForward, bezierBack, NULL); - RepeatForever* rep = RepeatForever::create(seq); + auto rep = RepeatForever::create(seq); sprite->runAction(rep); sprite->runAction( @@ -1838,14 +1838,14 @@ void Issue1288::onEnter() ActionsDemo::onEnter(); centerSprites(0); - Sprite *spr = Sprite::create("Images/grossini.png"); + auto spr = Sprite::create("Images/grossini.png"); spr->setPosition(Point(100, 100)); addChild(spr); - MoveBy* act1 = MoveBy::create(0.5, Point(100, 0)); - MoveBy* act2 = act1->reverse(); + auto act1 = MoveBy::create(0.5, Point(100, 0)); + auto act2 = act1->reverse(); auto act3 = Sequence::create(act1, act2, NULL); - Repeat* act4 = Repeat::create(act3, 2); + auto act4 = Repeat::create(act3, 2); spr->runAction(act4); } @@ -2098,7 +2098,7 @@ void ActionCardinalSpline::onEnter() // Spline with high tension (tension==1) // - CardinalSplineBy *action2 = CardinalSplineBy::create(3, array, 1); + auto action2 = CardinalSplineBy::create(3, array, 1); auto reverse2 = action2->reverse(); auto seq2 = Sequence::create(action2, reverse2, NULL); @@ -2184,7 +2184,7 @@ string PauseResumeActions::subtitle() void PauseResumeActions::pause(float dt) { log("Pausing"); - Director *director = Director::getInstance(); + auto director = Director::getInstance(); CC_SAFE_RELEASE(_pausedTargets); _pausedTargets = director->getActionManager()->pauseAllRunningActions(); @@ -2194,7 +2194,7 @@ void PauseResumeActions::pause(float dt) void PauseResumeActions::resume(float dt) { log("Resuming"); - Director *director = Director::getInstance(); + auto director = Director::getInstance(); director->getActionManager()->resumeTargets(_pausedTargets); } diff --git a/samples/Cpp/TestCpp/Classes/AppDelegate.cpp b/samples/Cpp/TestCpp/Classes/AppDelegate.cpp index 6755e7af84..44c236d682 100644 --- a/samples/Cpp/TestCpp/Classes/AppDelegate.cpp +++ b/samples/Cpp/TestCpp/Classes/AppDelegate.cpp @@ -27,21 +27,21 @@ bool AppDelegate::applicationDidFinishLaunching() Configuration::getInstance()->loadConfigFile("configs/config-example.plist"); // initialize director - Director *director = Director::getInstance(); + auto director = Director::getInstance(); director->setOpenGLView(EGLView::getInstance()); director->setDisplayStats(true); director->setAnimationInterval(1.0 / 60); - Size screenSize = EGLView::getInstance()->getFrameSize(); + auto screenSize = EGLView::getInstance()->getFrameSize(); - Size designSize = Size(480, 320); + auto designSize = Size(480, 320); - FileUtils* pFileUtils = FileUtils::getInstance(); + auto pFileUtils = FileUtils::getInstance(); if (screenSize.height > 320) { - Size resourceSize = Size(960, 640); + auto resourceSize = Size(960, 640); std::vector searchPaths; searchPaths.push_back("hd"); pFileUtils->setSearchPaths(searchPaths); diff --git a/samples/Cpp/TestCpp/Classes/BaseTest.cpp b/samples/Cpp/TestCpp/Classes/BaseTest.cpp index 5660d4baaa..8feb977c4e 100644 --- a/samples/Cpp/TestCpp/Classes/BaseTest.cpp +++ b/samples/Cpp/TestCpp/Classes/BaseTest.cpp @@ -20,25 +20,25 @@ void BaseTest::onEnter() // add title and subtitle std::string str = title(); const char * pTitle = str.c_str(); - LabelTTF* label = LabelTTF::create(pTitle, "Arial", 32); + auto label = LabelTTF::create(pTitle, "Arial", 32); addChild(label, 9999); label->setPosition( Point(VisibleRect::center().x, VisibleRect::top().y - 30) ); std::string strSubtitle = subtitle(); if( ! strSubtitle.empty() ) { - LabelTTF* l = LabelTTF::create(strSubtitle.c_str(), "Thonburi", 16); + auto l = LabelTTF::create(strSubtitle.c_str(), "Thonburi", 16); addChild(l, 9999); l->setPosition( Point(VisibleRect::center().x, VisibleRect::top().y - 60) ); } // add menu // CC_CALLBACK_1 == std::bind( function_ptr, instance, std::placeholders::_1, ...) - MenuItemImage *item1 = MenuItemImage::create(s_pathB1, s_pathB2, CC_CALLBACK_1(BaseTest::backCallback, this) ); - MenuItemImage *item2 = MenuItemImage::create(s_pathR1, s_pathR2, CC_CALLBACK_1(BaseTest::restartCallback, this) ); - MenuItemImage *item3 = MenuItemImage::create(s_pathF1, s_pathF2, CC_CALLBACK_1(BaseTest::nextCallback, this) ); + auto item1 = MenuItemImage::create(s_pathB1, s_pathB2, CC_CALLBACK_1(BaseTest::backCallback, this) ); + auto item2 = MenuItemImage::create(s_pathR1, s_pathR2, CC_CALLBACK_1(BaseTest::restartCallback, this) ); + auto item3 = MenuItemImage::create(s_pathF1, s_pathF2, CC_CALLBACK_1(BaseTest::nextCallback, this) ); - Menu *menu = Menu::create(item1, item2, item3, NULL); + auto menu = Menu::create(item1, item2, item3, NULL); menu->setPosition(Point::ZERO); item1->setPosition(Point(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2)); diff --git a/samples/Cpp/TestCpp/Classes/Box2DTest/Box2dTest.cpp b/samples/Cpp/TestCpp/Classes/Box2DTest/Box2dTest.cpp index 73c09022b0..c3f0517ab8 100644 --- a/samples/Cpp/TestCpp/Classes/Box2DTest/Box2dTest.cpp +++ b/samples/Cpp/TestCpp/Classes/Box2DTest/Box2dTest.cpp @@ -25,29 +25,29 @@ Box2DTestLayer::Box2DTestLayer() //Set up sprite #if 1 // Use batch node. Faster - SpriteBatchNode *parent = SpriteBatchNode::create("Images/blocks.png", 100); + auto parent = SpriteBatchNode::create("Images/blocks.png", 100); _spriteTexture = parent->getTexture(); #else // doesn't use batch node. Slower _spriteTexture = TextureCache::getInstance()->addImage("Images/blocks.png"); - Node *parent = Node::create(); + auto parent = Node::create(); #endif addChild(parent, 0, kTagParentNode); addNewSpriteAtPosition(VisibleRect::center()); - LabelTTF *label = LabelTTF::create("Tap screen", "Marker Felt", 32); + auto label = LabelTTF::create("Tap screen", "Marker Felt", 32); addChild(label, 0); label->setColor(Color3B(0,0,255)); label->setPosition(Point( VisibleRect::center().x, VisibleRect::top().y-50)); scheduleUpdate(); #else - LabelTTF *label = LabelTTF::create("Should define CC_ENABLE_BOX2D_INTEGRATION=1\n to run this test case", + auto label = LabelTTF::create("Should define CC_ENABLE_BOX2D_INTEGRATION=1\n to run this test case", "Arial", 18); - Size size = Director::getInstance()->getWinSize(); + auto size = Director::getInstance()->getWinSize(); label->setPosition(Point(size.width/2, size.height/2)); addChild(label); @@ -115,16 +115,16 @@ void Box2DTestLayer::initPhysics() void Box2DTestLayer::createResetButton() { - MenuItemImage *reset = MenuItemImage::create("Images/r1.png", "Images/r2.png", [](Object *sender) { - Scene* s = new Box2DTestScene(); - Box2DTestLayer* child = new Box2DTestLayer(); + auto reset = MenuItemImage::create("Images/r1.png", "Images/r2.png", [](Object *sender) { + auto s = new Box2DTestScene(); + auto child = new Box2DTestLayer(); s->addChild(child); child->release(); Director::getInstance()->replaceScene(s); s->release(); }); - Menu *menu = Menu::create(reset, NULL); + auto menu = Menu::create(reset, NULL); menu->setPosition(Point(VisibleRect::bottom().x, VisibleRect::bottom().y + 30)); this->addChild(menu, -1); @@ -175,13 +175,13 @@ void Box2DTestLayer::addNewSpriteAtPosition(Point p) body->CreateFixture(&fixtureDef); #if CC_ENABLE_BOX2D_INTEGRATION - Node *parent = this->getChildByTag(kTagParentNode); + auto parent = this->getChildByTag(kTagParentNode); //We have a 64x64 sprite sheet with 4 different 32x32 images. The following code is //just randomly picking one of the images int idx = (CCRANDOM_0_1() > .5 ? 0:1); int idy = (CCRANDOM_0_1() > .5 ? 0:1); - PhysicsSprite *sprite = PhysicsSprite::createWithTexture(_spriteTexture,Rect(32 * idx,32 * idy,32,32)); + auto sprite = PhysicsSprite::createWithTexture(_spriteTexture,Rect(32 * idx,32 * idy,32,32)); parent->addChild(sprite); sprite->setB2Body(body); sprite->setPTMRatio(PTM_RATIO); @@ -218,7 +218,7 @@ void Box2DTestLayer::ccTouchesEnded(Set* touches, Event* event) if(!touch) break; - Point location = touch->getLocation(); + auto location = touch->getLocation(); addNewSpriteAtPosition( location ); } @@ -248,7 +248,7 @@ void Box2DTestLayer::accelerometer(UIAccelerometer* accelerometer, Acceleration* void Box2DTestScene::runThisTest() { - Layer* layer = new Box2DTestLayer(); + auto layer = new Box2DTestLayer(); addChild(layer); layer->release(); diff --git a/samples/Cpp/TestCpp/Classes/Box2DTestBed/Box2dView.cpp b/samples/Cpp/TestCpp/Classes/Box2DTestBed/Box2dView.cpp index aae885e2e4..da4ea0c557 100644 --- a/samples/Cpp/TestCpp/Classes/Box2DTestBed/Box2dView.cpp +++ b/samples/Cpp/TestCpp/Classes/Box2DTestBed/Box2dView.cpp @@ -37,7 +37,7 @@ MenuLayer::~MenuLayer(void) MenuLayer* MenuLayer::menuWithEntryID(int entryId) { - MenuLayer* layer = new MenuLayer(); + auto layer = new MenuLayer(); layer->initWithEntryID(entryId); layer->autorelease(); @@ -46,7 +46,7 @@ MenuLayer* MenuLayer::menuWithEntryID(int entryId) bool MenuLayer::initWithEntryID(int entryId) { - Director* director = Director::getInstance(); + auto director = Director::getInstance(); Point visibleOrigin = director->getVisibleOrigin(); Size visibleSize = director->getVisibleSize(); @@ -60,18 +60,18 @@ bool MenuLayer::initWithEntryID(int entryId) view->setAnchorPoint( Point(0,0) ); view->setPosition( Point(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/3) ); //#if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE) -// LabelBMFont* label = LabelBMFont::create(view->title().c_str(), "fonts/arial16.fnt"); +// auto label = LabelBMFont::create(view->title().c_str(), "fonts/arial16.fnt"); //#else - LabelTTF* label = LabelTTF::create(view->title().c_str(), "Arial", 28); + auto label = LabelTTF::create(view->title().c_str(), "Arial", 28); //#endif addChild(label, 1); label->setPosition( Point(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height-50) ); - MenuItemImage *item1 = MenuItemImage::create("Images/b1.png", "Images/b2.png", CC_CALLBACK_1(MenuLayer::backCallback, this) ); - MenuItemImage *item2 = MenuItemImage::create("Images/r1.png","Images/r2.png", CC_CALLBACK_1( MenuLayer::restartCallback, this) ); - MenuItemImage *item3 = MenuItemImage::create("Images/f1.png", "Images/f2.png", CC_CALLBACK_1(MenuLayer::nextCallback, this) ); + auto item1 = MenuItemImage::create("Images/b1.png", "Images/b2.png", CC_CALLBACK_1(MenuLayer::backCallback, this) ); + auto item2 = MenuItemImage::create("Images/r1.png","Images/r2.png", CC_CALLBACK_1( MenuLayer::restartCallback, this) ); + auto item3 = MenuItemImage::create("Images/f1.png", "Images/f2.png", CC_CALLBACK_1(MenuLayer::nextCallback, this) ); - Menu *menu = Menu::create(item1, item2, item3, NULL); + auto menu = Menu::create(item1, item2, item3, NULL); menu->setPosition( Point::ZERO ); item1->setPosition(Point(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2)); @@ -85,8 +85,8 @@ bool MenuLayer::initWithEntryID(int entryId) void MenuLayer::restartCallback(Object* sender) { - Scene* s = new Box2dTestBedScene(); - MenuLayer* box = MenuLayer::menuWithEntryID(m_entryID); + auto s = new Box2dTestBedScene(); + auto box = MenuLayer::menuWithEntryID(m_entryID); s->addChild( box ); Director::getInstance()->replaceScene( s ); s->release(); @@ -94,11 +94,11 @@ void MenuLayer::restartCallback(Object* sender) void MenuLayer::nextCallback(Object* sender) { - Scene* s = new Box2dTestBedScene(); + auto s = new Box2dTestBedScene(); int next = m_entryID + 1; if( next >= g_totalEntries) next = 0; - MenuLayer* box = MenuLayer::menuWithEntryID(next); + auto box = MenuLayer::menuWithEntryID(next); s->addChild( box ); Director::getInstance()->replaceScene( s ); s->release(); @@ -106,13 +106,13 @@ void MenuLayer::nextCallback(Object* sender) void MenuLayer::backCallback(Object* sender) { - Scene* s = new Box2dTestBedScene(); + auto s = new Box2dTestBedScene(); int next = m_entryID - 1; if( next < 0 ) { next = g_totalEntries - 1; } - MenuLayer* box = MenuLayer::menuWithEntryID(next); + auto box = MenuLayer::menuWithEntryID(next); s->addChild( box ); Director::getInstance()->replaceScene( s ); @@ -121,7 +121,7 @@ void MenuLayer::backCallback(Object* sender) void MenuLayer::registerWithTouchDispatcher() { - Director* director = Director::getInstance(); + auto director = Director::getInstance(); director->getTouchDispatcher()->addTargetedDelegate(this, 0, true); } @@ -140,9 +140,9 @@ bool MenuLayer::ccTouchBegan(Touch* touch, Event* event) void MenuLayer::ccTouchMoved(Touch* touch, Event* event) { - Point diff = touch->getDelta(); - Node *node = getChildByTag( kTagBox2DNode ); - Point currentPos = node->getPosition(); + auto diff = touch->getDelta(); + auto node = getChildByTag( kTagBox2DNode ); + auto currentPos = node->getPosition(); node->setPosition(currentPos + diff); } @@ -210,15 +210,15 @@ Box2DView::~Box2DView() void Box2DView::registerWithTouchDispatcher() { // higher priority than dragging - Director* director = Director::getInstance(); + auto director = Director::getInstance(); director->getTouchDispatcher()->addTargetedDelegate(this, -10, true); } bool Box2DView::ccTouchBegan(Touch* touch, Event* event) { - Point touchLocation = touch->getLocation(); + auto touchLocation = touch->getLocation(); - Point nodePosition = convertToNodeSpace( touchLocation ); + auto nodePosition = convertToNodeSpace( touchLocation ); // NSLog(@"pos: %f,%f -> %f,%f", touchLocation.x, touchLocation.y, nodePosition.x, nodePosition.y); return m_test->MouseDown(b2Vec2(nodePosition.x,nodePosition.y)); @@ -226,16 +226,16 @@ bool Box2DView::ccTouchBegan(Touch* touch, Event* event) void Box2DView::ccTouchMoved(Touch* touch, Event* event) { - Point touchLocation = touch->getLocation(); - Point nodePosition = convertToNodeSpace( touchLocation ); + auto touchLocation = touch->getLocation(); + auto nodePosition = convertToNodeSpace( touchLocation ); m_test->MouseMove(b2Vec2(nodePosition.x,nodePosition.y)); } void Box2DView::ccTouchEnded(Touch* touch, Event* event) { - Point touchLocation = touch->getLocation(); - Point nodePosition = convertToNodeSpace( touchLocation ); + auto touchLocation = touch->getLocation(); + auto nodePosition = convertToNodeSpace( touchLocation ); m_test->MouseUp(b2Vec2(nodePosition.x,nodePosition.y)); } diff --git a/samples/Cpp/TestCpp/Classes/Box2DTestBed/Test.cpp b/samples/Cpp/TestCpp/Classes/Box2DTestBed/Test.cpp index 5d49f96e63..cd2ee06547 100644 --- a/samples/Cpp/TestCpp/Classes/Box2DTestBed/Test.cpp +++ b/samples/Cpp/TestCpp/Classes/Box2DTestBed/Test.cpp @@ -86,7 +86,7 @@ void Test::PreSolve(b2Contact* contact, const b2Manifold* oldManifold) for (int32 i = 0; i < manifold->pointCount && m_pointCount < k_maxContactPoints; ++i) { - ContactPoint* cp = m_points + m_pointCount; + auto cp = m_points + m_pointCount; cp->fixtureA = fixtureA; cp->fixtureB = fixtureB; cp->position = worldManifold.points[i]; @@ -412,7 +412,7 @@ void Test::Step(Settings* settings) for (int32 i = 0; i < m_pointCount; ++i) { - ContactPoint* point = m_points + i; + auto point = m_points + i; if (point->state == b2_addState) { diff --git a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-1159.cpp b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-1159.cpp index d14bb1ab45..5aa471f144 100644 --- a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-1159.cpp +++ b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-1159.cpp @@ -11,8 +11,8 @@ Scene* Bug1159Layer::scene() { - Scene *scene = Scene::create(); - Bug1159Layer* layer = Bug1159Layer::create(); + auto scene = Scene::create(); + auto layer = Bug1159Layer::create(); scene->addChild(layer); return scene; @@ -23,12 +23,12 @@ bool Bug1159Layer::init() if (BugsTestBaseLayer::init()) { Director::getInstance()->setDepthTest(true); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - LayerColor *background = LayerColor::create(Color4B(255, 0, 255, 255)); + auto background = LayerColor::create(Color4B(255, 0, 255, 255)); addChild(background); - LayerColor *sprite_a = LayerColor::create(Color4B(255, 0, 0, 255), 700, 700); + auto sprite_a = LayerColor::create(Color4B(255, 0, 0, 255), 700, 700); sprite_a->setAnchorPoint(Point(0.5f, 0.5f)); sprite_a->ignoreAnchorPointForPosition(false); sprite_a->setPosition(Point(0.0f, s.height/2)); @@ -39,14 +39,14 @@ bool Bug1159Layer::init() MoveTo::create(1.0f, Point(0.0f, 384.0f)), NULL))); - LayerColor *sprite_b = LayerColor::create(Color4B(0, 0, 255, 255), 400, 400); + auto sprite_b = LayerColor::create(Color4B(0, 0, 255, 255), 400, 400); sprite_b->setAnchorPoint(Point(0.5f, 0.5f)); sprite_b->ignoreAnchorPointForPosition(false); sprite_b->setPosition(Point(s.width/2, s.height/2)); addChild(sprite_b); - MenuItemLabel *label = MenuItemLabel::create(LabelTTF::create("Flip Me", "Helvetica", 24), CC_CALLBACK_1(Bug1159Layer::callBack, this) ); - Menu *menu = Menu::create(label, NULL); + auto label = MenuItemLabel::create(LabelTTF::create("Flip Me", "Helvetica", 24), CC_CALLBACK_1(Bug1159Layer::callBack, this) ); + auto menu = Menu::create(label, NULL); menu->setPosition(Point(s.width - 200.0f, 50.0f)); addChild(menu); diff --git a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-1174.cpp b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-1174.cpp index 6e1221a26b..3b9a334fe5 100644 --- a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-1174.cpp +++ b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-1174.cpp @@ -12,13 +12,13 @@ int check_for_error( Point p1, Point p2, Point p3, Point p4, float s, float t ) // the hit point is p3 + t * (p4 - p3); // the hit point also is p1 + s * (p2 - p1); - Point p4_p3 = p4 - p3; - Point p4_p3_t = p4_p3 * t; - Point hitPoint1 = p3 + p4_p3_t; + auto p4_p3 = p4 - p3; + auto p4_p3_t = p4_p3 * t; + auto hitPoint1 = p3 + p4_p3_t; - Point p2_p1 = p2 - p1; - Point p2_p1_s = p2_p1 * s; - Point hitPoint2 = p1 + p2_p1_s; + auto p2_p1 = p2 - p1; + auto p2_p1_s = p2_p1 * s; + auto hitPoint2 = p1 + p2_p1_s; // Since float has rounding errors, only check if diff is < 0.05 if( (fabs( hitPoint1.x - hitPoint2.x) > 0.1f) || ( fabs(hitPoint1.y - hitPoint2.y) > 0.1f) ) diff --git a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-350.cpp b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-350.cpp index 8eb0f487d5..37ab14890a 100644 --- a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-350.cpp +++ b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-350.cpp @@ -9,8 +9,8 @@ bool Bug350Layer::init() { if (BugsTestBaseLayer::init()) { - Size size = Director::getInstance()->getWinSize(); - Sprite *background = Sprite::create("Hello.png"); + auto size = Director::getInstance()->getWinSize(); + auto background = Sprite::create("Hello.png"); background->setPosition(Point(size.width/2, size.height/2)); addChild(background); return true; diff --git a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-422.cpp b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-422.cpp index 1cdf836a89..4ce9ce9190 100644 --- a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-422.cpp +++ b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-422.cpp @@ -26,15 +26,15 @@ void Bug422Layer::reset() // The menu will be removed, but the instance will be alive // and then a new node will be allocated occupying the memory. // => CRASH BOOM BANG - Node *node = getChildByTag(localtag-1); + auto node = getChildByTag(localtag-1); log("Menu: %p", node); removeChild(node, false); // [self removeChildByTag:localtag-1 cleanup:NO]; - MenuItem *item1 = MenuItemFont::create("One", CC_CALLBACK_1(Bug422Layer::menuCallback, this) ); + auto item1 = MenuItemFont::create("One", CC_CALLBACK_1(Bug422Layer::menuCallback, this) ); log("MenuItemFont: %p", item1); MenuItem *item2 = MenuItemFont::create("Two", CC_CALLBACK_1(Bug422Layer::menuCallback, this) ); - Menu *menu = Menu::create(item1, item2, NULL); + auto menu = Menu::create(item1, item2, NULL); menu->alignItemsVertically(); float x = CCRANDOM_0_1() * 50; @@ -47,12 +47,12 @@ void Bug422Layer::reset() void Bug422Layer::check(Node* t) { - Array *array = t->getChildren(); + auto array = t->getChildren(); Object* pChild = NULL; CCARRAY_FOREACH(array, pChild) { CC_BREAK_IF(! pChild); - Node* node = static_cast(pChild); + auto node = static_cast(pChild); log("%p, rc: %d", node, node->retainCount()); check(node); } diff --git a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-458/Bug-458.cpp b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-458/Bug-458.cpp index 060ca63515..65bd0b6f01 100644 --- a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-458/Bug-458.cpp +++ b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-458/Bug-458.cpp @@ -11,24 +11,24 @@ bool Bug458Layer::init() if(BugsTestBaseLayer::init()) { // ask director the the window size - Size size = Director::getInstance()->getWinSize(); + auto size = Director::getInstance()->getWinSize(); - QuestionContainerSprite* question = new QuestionContainerSprite(); - QuestionContainerSprite* question2 = new QuestionContainerSprite(); + auto question = new QuestionContainerSprite(); + auto question2 = new QuestionContainerSprite(); question->init(); question2->init(); // [question setContentSize:CGSizeMake(50,50)]; // [question2 setContentSize:CGSizeMake(50,50)]; - MenuItemSprite* sprite = MenuItemSprite::create(question2, question, CC_CALLBACK_1(Bug458Layer::selectAnswer, this) ); - LayerColor* layer = LayerColor::create(Color4B(0,0,255,255), 100, 100); + auto sprite = MenuItemSprite::create(question2, question, CC_CALLBACK_1(Bug458Layer::selectAnswer, this) ); + auto layer = LayerColor::create(Color4B(0,0,255,255), 100, 100); question->release(); question2->release(); - LayerColor* layer2 = LayerColor::create(Color4B(255,0,0,255), 100, 100); - MenuItemSprite* sprite2 = MenuItemSprite::create(layer, layer2, CC_CALLBACK_1(Bug458Layer::selectAnswer, this) ); - Menu* menu = Menu::create(sprite, sprite2, NULL); + auto layer2 = LayerColor::create(Color4B(255,0,0,255), 100, 100); + auto sprite2 = MenuItemSprite::create(layer, layer2, CC_CALLBACK_1(Bug458Layer::selectAnswer, this) ); + auto menu = Menu::create(sprite, sprite2, NULL); menu->alignItemsVerticallyWithPadding(100); menu->setPosition(Point(size.width / 2, size.height / 2)); diff --git a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-458/QuestionContainerSprite.cpp b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-458/QuestionContainerSprite.cpp index 69fc37ebbd..cdf2a0aa55 100644 --- a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-458/QuestionContainerSprite.cpp +++ b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-458/QuestionContainerSprite.cpp @@ -9,16 +9,16 @@ bool QuestionContainerSprite::init() if (Sprite::init()) { //Add label - LabelTTF* label = LabelTTF::create("Answer 1", "Arial", 12); + auto label = LabelTTF::create("Answer 1", "Arial", 12); label->setTag(100); //Add the background - Size size = Director::getInstance()->getWinSize(); - Sprite* corner = Sprite::create("Images/bugs/corner.png"); + auto size = Director::getInstance()->getWinSize(); + auto corner = Sprite::create("Images/bugs/corner.png"); int width = size.width * 0.9f - (corner->getContentSize().width * 2); int height = size.height * 0.15f - (corner->getContentSize().height * 2); - LayerColor* layer = LayerColor::create(Color4B(255, 255, 255, 255 * .75), width, height); + auto layer = LayerColor::create(Color4B(255, 255, 255, 255 * .75), width, height); layer->setPosition(Point(-width / 2, -height / 2)); //First button is blue, @@ -39,40 +39,40 @@ bool QuestionContainerSprite::init() corner->setPosition(Point(-(width / 2 + corner->getContentSize().width / 2), -(height / 2 + corner->getContentSize().height / 2))); addChild(corner); - Sprite* corner2 = Sprite::create("Images/bugs/corner.png"); + auto corner2 = Sprite::create("Images/bugs/corner.png"); corner2->setPosition(Point(-corner->getPosition().x, corner->getPosition().y)); corner2->setFlipX(true); addChild(corner2); - Sprite* corner3 = Sprite::create("Images/bugs/corner.png"); + auto corner3 = Sprite::create("Images/bugs/corner.png"); corner3->setPosition(Point(corner->getPosition().x, -corner->getPosition().y)); corner3->setFlipY(true); addChild(corner3); - Sprite* corner4 = Sprite::create("Images/bugs/corner.png"); + auto corner4 = Sprite::create("Images/bugs/corner.png"); corner4->setPosition(Point(corner2->getPosition().x, -corner2->getPosition().y)); corner4->setFlipX(true); corner4->setFlipY(true); addChild(corner4); - Sprite* edge = Sprite::create("Images/bugs/edge.png"); + auto edge = Sprite::create("Images/bugs/edge.png"); edge->setScaleX(width); edge->setPosition(Point(corner->getPosition().x + (corner->getContentSize().width / 2) + (width / 2), corner->getPosition().y)); addChild(edge); - Sprite* edge2 = Sprite::create("Images/bugs/edge.png"); + auto edge2 = Sprite::create("Images/bugs/edge.png"); edge2->setScaleX(width); edge2->setPosition(Point(corner->getPosition().x + (corner->getContentSize().width / 2) + (width / 2), -corner->getPosition().y)); edge2->setFlipY(true); addChild(edge2); - Sprite* edge3 = Sprite::create("Images/bugs/edge.png"); + auto edge3 = Sprite::create("Images/bugs/edge.png"); edge3->setRotation(90); edge3->setScaleX(height); edge3->setPosition(Point(corner->getPosition().x, corner->getPosition().y + (corner->getContentSize().height / 2) + (height / 2))); addChild(edge3); - Sprite* edge4 = Sprite::create("Images/bugs/edge.png"); + auto edge4 = Sprite::create("Images/bugs/edge.png"); edge4->setRotation(270); edge4->setScaleX(height); edge4->setPosition(Point(-corner->getPosition().x, corner->getPosition().y + (corner->getContentSize().height / 2) + (height / 2))); diff --git a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-624.cpp b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-624.cpp index 977dc14fd1..544867f562 100644 --- a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-624.cpp +++ b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-624.cpp @@ -14,8 +14,8 @@ bool Bug624Layer::init() { if(BugsTestBaseLayer::init()) { - Size size = Director::getInstance()->getWinSize(); - LabelTTF *label = LabelTTF::create("Layer1", "Marker Felt", 36); + auto size = Director::getInstance()->getWinSize(); + auto label = LabelTTF::create("Layer1", "Marker Felt", 36); label->setPosition(Point(size.width/2, size.height/2)); addChild(label); @@ -32,7 +32,7 @@ void Bug624Layer::switchLayer(float dt) { unschedule(schedule_selector(Bug624Layer::switchLayer)); - Scene *scene = Scene::create(); + auto scene = Scene::create(); scene->addChild(Bug624Layer2::create(), 0); Director::getInstance()->replaceScene(TransitionFade::create(2.0f, scene, Color3B::WHITE)); } @@ -51,8 +51,8 @@ bool Bug624Layer2::init() { if(BugsTestBaseLayer::init()) { - Size size = Director::getInstance()->getWinSize(); - LabelTTF *label = LabelTTF::create("Layer2", "Marker Felt", 36); + auto size = Director::getInstance()->getWinSize(); + auto label = LabelTTF::create("Layer2", "Marker Felt", 36); label->setPosition(Point(size.width/2, size.height/2)); addChild(label); @@ -69,7 +69,7 @@ void Bug624Layer2::switchLayer(float dt) { unschedule(schedule_selector(Bug624Layer::switchLayer)); - Scene *scene = Scene::create(); + auto scene = Scene::create(); scene->addChild(Bug624Layer::create(), 0); Director::getInstance()->replaceScene(TransitionFade::create(2.0f, scene, Color3B::RED)); } diff --git a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-886.cpp b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-886.cpp index 4d9de06f8d..e7842b0d62 100644 --- a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-886.cpp +++ b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-886.cpp @@ -10,15 +10,15 @@ bool Bug886Layer::init() if(BugsTestBaseLayer::init()) { // ask director the the window size - // CGSize size = [[Director sharedDirector] winSize]; + // auto size = [[Director sharedDirector] winSize]; - Sprite* sprite = Sprite::create("Images/bugs/bug886.jpg"); + auto sprite = Sprite::create("Images/bugs/bug886.jpg"); sprite->setAnchorPoint(Point::ZERO); sprite->setPosition(Point::ZERO); sprite->setScaleX(0.6f); addChild(sprite); - Sprite* sprite2 = Sprite::create("Images/bugs/bug886.png"); + auto sprite2 = Sprite::create("Images/bugs/bug886.png"); sprite2->setAnchorPoint(Point::ZERO); sprite2->setScaleX(0.6f); sprite2->setPosition(Point(sprite->getContentSize().width * 0.6f + 10, 0)); diff --git a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-899.cpp b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-899.cpp index 9eb0ccebb4..bbbcf066e3 100644 --- a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-899.cpp +++ b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-899.cpp @@ -12,7 +12,7 @@ bool Bug899Layer::init() // Director::getInstance()->enableRetinaDisplay(true); if (BugsTestBaseLayer::init()) { - Sprite *bg = Sprite::create("Images/bugs/RetinaDisplay.jpg"); + auto bg = Sprite::create("Images/bugs/RetinaDisplay.jpg"); addChild(bg, 0); bg->setAnchorPoint(Point::ZERO); diff --git a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-914.cpp b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-914.cpp index 73f43f0d3e..fcfe8176f4 100644 --- a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-914.cpp +++ b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-914.cpp @@ -12,9 +12,9 @@ Scene* Bug914Layer::scene() { // 'scene' is an autorelease object. - Scene *scene = Scene::create(); + auto scene = Scene::create(); // 'layer' is an autorelease object. - Bug914Layer* layer = Bug914Layer::create(); + auto layer = Bug914Layer::create(); // add layer as a child to scene scene->addChild(layer); @@ -32,7 +32,7 @@ bool Bug914Layer::init() { setTouchEnabled(true); // ask director the the window size - Size size = Director::getInstance()->getWinSize(); + auto size = Director::getInstance()->getWinSize(); LayerColor *layer; for( int i=0;i < 5;i++) { @@ -45,10 +45,10 @@ bool Bug914Layer::init() } // create and initialize a Label - LabelTTF *label = LabelTTF::create("Hello World", "Marker Felt", 64); - MenuItem *item1 = MenuItemFont::create("restart", CC_CALLBACK_1(Bug914Layer::restart, this)); + auto label = LabelTTF::create("Hello World", "Marker Felt", 64); + auto item1 = MenuItemFont::create("restart", CC_CALLBACK_1(Bug914Layer::restart, this)); - Menu *menu = Menu::create(item1, NULL); + auto menu = Menu::create(item1, NULL); menu->alignItemsVertically(); menu->setPosition(Point(size.width/2, 100)); addChild(menu); diff --git a/samples/Cpp/TestCpp/Classes/BugsTest/BugsTest.cpp b/samples/Cpp/TestCpp/Classes/BugsTest/BugsTest.cpp index 4c1afe8585..c15a63c087 100644 --- a/samples/Cpp/TestCpp/Classes/BugsTest/BugsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/BugsTest/BugsTest.cpp @@ -54,13 +54,13 @@ void BugsTestMainLayer::onEnter() { Layer::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); _itmeMenu = Menu::create(); MenuItemFont::setFontName("Arial"); MenuItemFont::setFontSize(24); for (int i = 0; i < g_maxitems; ++i) { - MenuItemFont* pItem = MenuItemFont::create(g_bugs[i].test_name, g_bugs[i].callback); + auto pItem = MenuItemFont::create(g_bugs[i].test_name, g_bugs[i].callback); pItem->setPosition(Point(s.width / 2, s.height - (i + 1) * LINE_SPACE)); _itmeMenu->addChild(pItem, kItemTagBasic + i); } @@ -72,21 +72,21 @@ void BugsTestMainLayer::onEnter() void BugsTestMainLayer::ccTouchesBegan(Set *touches, Event *event) { - Touch* touch = static_cast( touches->anyObject() ); + auto touch = static_cast( touches->anyObject() ); _beginPos = touch->getLocation(); } void BugsTestMainLayer::ccTouchesMoved(Set *touches, Event *event) { - Touch* touch = static_cast( touches->anyObject() ); + auto touch = static_cast( touches->anyObject() ); - Point touchLocation = touch->getLocation(); + auto touchLocation = touch->getLocation(); float nMoveY = touchLocation.y - _beginPos.y; - Point curPos = _itmeMenu->getPosition(); - Point nextPos = Point(curPos.x, curPos.y + nMoveY); - Size winSize = Director::getInstance()->getWinSize(); + auto curPos = _itmeMenu->getPosition(); + auto nextPos = Point(curPos.x, curPos.y + nMoveY); + auto winSize = Director::getInstance()->getWinSize(); if (nextPos.y < 0.0f) { _itmeMenu->setPosition(Point::ZERO); @@ -115,9 +115,9 @@ void BugsTestBaseLayer::onEnter() MenuItemFont::setFontName("Arial"); MenuItemFont::setFontSize(24); - MenuItemFont* pMainItem = MenuItemFont::create("Back", CC_CALLBACK_1(BugsTestBaseLayer::backCallback, this)); + auto pMainItem = MenuItemFont::create("Back", CC_CALLBACK_1(BugsTestBaseLayer::backCallback, this)); pMainItem->setPosition(Point(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25)); - Menu* menu = Menu::create(pMainItem, NULL); + auto menu = Menu::create(pMainItem, NULL); menu->setPosition( Point::ZERO ); addChild(menu); } @@ -125,7 +125,7 @@ void BugsTestBaseLayer::onEnter() void BugsTestBaseLayer::backCallback(Object* sender) { // Director::getInstance()->enableRetinaDisplay(false); - BugsTestScene* scene = new BugsTestScene(); + auto scene = new BugsTestScene(); scene->runThisTest(); scene->autorelease(); } @@ -137,7 +137,7 @@ void BugsTestBaseLayer::backCallback(Object* sender) //////////////////////////////////////////////////////// void BugsTestScene::runThisTest() { - Layer* layer = new BugsTestMainLayer(); + auto layer = new BugsTestMainLayer(); addChild(layer); layer->release(); diff --git a/samples/Cpp/TestCpp/Classes/ChipmunkTest/ChipmunkTest.cpp b/samples/Cpp/TestCpp/Classes/ChipmunkTest/ChipmunkTest.cpp index a7b450da09..f3166c0ebe 100644 --- a/samples/Cpp/TestCpp/Classes/ChipmunkTest/ChipmunkTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ChipmunkTest/ChipmunkTest.cpp @@ -25,7 +25,7 @@ ChipmunkTestLayer::ChipmunkTestLayer() setAccelerometerEnabled(true); // title - LabelTTF *label = LabelTTF::create("Multi touch the screen", "Marker Felt", 36); + auto label = LabelTTF::create("Multi touch the screen", "Marker Felt", 36); label->setPosition(Point( VisibleRect::center().x, VisibleRect::top().y - 30)); this->addChild(label, -1); @@ -37,12 +37,12 @@ ChipmunkTestLayer::ChipmunkTestLayer() #if 1 // Use batch node. Faster - SpriteBatchNode *parent = SpriteBatchNode::create("Images/grossini_dance_atlas.png", 100); + auto parent = SpriteBatchNode::create("Images/grossini_dance_atlas.png", 100); _spriteTexture = parent->getTexture(); #else // doesn't use batch node. Slower _spriteTexture = TextureCache::getInstance()->addImage("Images/grossini_dance_atlas.png"); - Node *parent = Node::create(); + auto parent = Node::create(); #endif addChild(parent, 0, kTagParentNode); @@ -50,18 +50,18 @@ ChipmunkTestLayer::ChipmunkTestLayer() // menu for debug layer MenuItemFont::setFontSize(18); - MenuItemFont *item = MenuItemFont::create("Toggle debug", CC_CALLBACK_1(ChipmunkTestLayer::toggleDebugCallback, this)); + auto item = MenuItemFont::create("Toggle debug", CC_CALLBACK_1(ChipmunkTestLayer::toggleDebugCallback, this)); - Menu *menu = Menu::create(item, NULL); + auto menu = Menu::create(item, NULL); this->addChild(menu); menu->setPosition(Point(VisibleRect::right().x-100, VisibleRect::top().y-60)); scheduleUpdate(); #else - LabelTTF *label = LabelTTF::create("Should define CC_ENABLE_CHIPMUNK_INTEGRATION=1\n to run this test case", + auto label = LabelTTF::create("Should define CC_ENABLE_CHIPMUNK_INTEGRATION=1\n to run this test case", "Arial", 18); - Size size = Director::getInstance()->getWinSize(); + auto size = Director::getInstance()->getWinSize(); label->setPosition(Point(size.width/2, size.height/2)); addChild(label); @@ -147,9 +147,9 @@ void ChipmunkTestLayer::update(float delta) void ChipmunkTestLayer::createResetButton() { - MenuItemImage *reset = MenuItemImage::create("Images/r1.png", "Images/r2.png", CC_CALLBACK_1(ChipmunkTestLayer::reset, this)); + auto reset = MenuItemImage::create("Images/r1.png", "Images/r2.png", CC_CALLBACK_1(ChipmunkTestLayer::reset, this)); - Menu *menu = Menu::create(reset, NULL); + auto menu = Menu::create(reset, NULL); menu->setPosition(Point(VisibleRect::center().x, VisibleRect::bottom().y + 30)); this->addChild(menu, -1); @@ -157,8 +157,8 @@ void ChipmunkTestLayer::createResetButton() void ChipmunkTestLayer::reset(Object* sender) { - Scene* s = new ChipmunkAccelTouchTestScene(); - ChipmunkTestLayer* child = new ChipmunkTestLayer(); + auto s = new ChipmunkAccelTouchTestScene(); + auto child = new ChipmunkTestLayer(); s->addChild(child); child->release(); Director::getInstance()->replaceScene(s); @@ -170,7 +170,7 @@ void ChipmunkTestLayer::addNewSpriteAtPosition(Point pos) #if CC_ENABLE_CHIPMUNK_INTEGRATION int posx, posy; - Node *parent = getChildByTag(kTagParentNode); + auto parent = getChildByTag(kTagParentNode); posx = CCRANDOM_0_1() * 200.0f; posy = CCRANDOM_0_1() * 200.0f; @@ -196,7 +196,7 @@ void ChipmunkTestLayer::addNewSpriteAtPosition(Point pos) shape->e = 0.5f; shape->u = 0.5f; cpSpaceAddShape(_space, shape); - PhysicsSprite *sprite = PhysicsSprite::createWithTexture(_spriteTexture, Rect(posx, posy, 85, 121)); + auto sprite = PhysicsSprite::createWithTexture(_spriteTexture, Rect(posx, posy, 85, 121)); parent->addChild(sprite); sprite->setCPBody(body); @@ -215,9 +215,9 @@ void ChipmunkTestLayer::ccTouchesEnded(Set* touches, Event* event) for( auto &item: *touches) { - Touch* touch = static_cast(item); + auto touch = static_cast(item); - Point location = touch->getLocation(); + auto location = touch->getLocation(); addNewSpriteAtPosition( location ); } @@ -235,14 +235,14 @@ void ChipmunkTestLayer::didAccelerate(Acceleration* pAccelerationValue) prevX = accelX; prevY = accelY; - Point v = Point( accelX, accelY); + auto v = Point( accelX, accelY); v = v * 200; _space->gravity = cpv(v.x, v.y); } void ChipmunkAccelTouchTestScene::runThisTest() { - Layer* layer = new ChipmunkTestLayer(); + auto layer = new ChipmunkTestLayer(); addChild(layer); layer->release(); diff --git a/samples/Cpp/TestCpp/Classes/ClickAndMoveTest/ClickAndMoveTest.cpp b/samples/Cpp/TestCpp/Classes/ClickAndMoveTest/ClickAndMoveTest.cpp index 01cef08321..9dc9578242 100644 --- a/samples/Cpp/TestCpp/Classes/ClickAndMoveTest/ClickAndMoveTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ClickAndMoveTest/ClickAndMoveTest.cpp @@ -8,7 +8,7 @@ enum void ClickAndMoveTestScene::runThisTest() { - Layer* layer = new MainLayer(); + auto layer = new MainLayer(); layer->autorelease(); addChild(layer); @@ -19,9 +19,9 @@ MainLayer::MainLayer() { setTouchEnabled(true); - Sprite* sprite = Sprite::create(s_pathGrossini); + auto sprite = Sprite::create(s_pathGrossini); - Layer* layer = LayerColor::create(Color4B(255,255,0,255)); + auto layer = LayerColor::create(Color4B(255,255,0,255)); addChild(layer, -1); addChild(sprite, 0, kTagSprite); @@ -39,11 +39,11 @@ MainLayer::MainLayer() void MainLayer::ccTouchesEnded(Set *touches, Event *event) { - Touch* touch = static_cast( touches->anyObject() ); + auto touch = static_cast( touches->anyObject() ); - Point location = touch->getLocation(); + auto location = touch->getLocation(); - Node* s = getChildByTag(kTagSprite); + auto s = getChildByTag(kTagSprite); s->stopAllActions(); s->runAction( MoveTo::create(1, Point(location.x, location.y) ) ); float o = location.x - s->getPosition().x; diff --git a/samples/Cpp/TestCpp/Classes/ClippingNodeTest/ClippingNodeTest.cpp b/samples/Cpp/TestCpp/Classes/ClippingNodeTest/ClippingNodeTest.cpp index 970dbbe058..777b855300 100644 --- a/samples/Cpp/TestCpp/Classes/ClippingNodeTest/ClippingNodeTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ClippingNodeTest/ClippingNodeTest.cpp @@ -56,7 +56,7 @@ static Layer* nextAction() sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - Layer* layer = (createFunctions[sceneIdx])(); + auto layer = (createFunctions[sceneIdx])(); layer->init(); layer->autorelease(); @@ -70,7 +70,7 @@ static Layer* backAction() if( sceneIdx < 0 ) sceneIdx += total; - Layer* layer = (createFunctions[sceneIdx])(); + auto layer = (createFunctions[sceneIdx])(); layer->init(); layer->autorelease(); @@ -79,7 +79,7 @@ static Layer* backAction() static Layer* restartAction() { - Layer* layer = (createFunctions[sceneIdx])(); + auto layer = (createFunctions[sceneIdx])(); layer->init(); layer->autorelease(); @@ -94,7 +94,7 @@ bool BaseClippingNodeTest::init() { if (BaseTest::init()) { - Sprite *background = Sprite::create(s_back3); + auto background = Sprite::create(s_back3); background->setAnchorPoint( Point::ZERO ); background->setPosition( Point::ZERO ); this->addChild(background, -1); @@ -164,20 +164,20 @@ std::string BasicTest::subtitle() void BasicTest::setup() { - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Node *stencil = this->stencil(); + auto stencil = this->stencil(); stencil->setTag( kTagStencilNode ); stencil->setPosition( Point(50, 50) ); - ClippingNode *clipper = this->clipper(); + auto clipper = this->clipper(); clipper->setTag( kTagClipperNode ); clipper->setAnchorPoint(Point(0.5, 0.5)); clipper->setPosition( Point(s.width / 2 - 50, s.height / 2 - 50) ); clipper->setStencil(stencil); this->addChild(clipper); - Node *content = this->content(); + auto content = this->content(); content->setPosition( Point(50, 50) ); clipper->addChild(content); } @@ -189,13 +189,13 @@ Action* BasicTest::actionRotate() Action* BasicTest::actionScale() { - ScaleBy *scale = ScaleBy::create(1.33f, 1.5f); + auto scale = ScaleBy::create(1.33f, 1.5f); return RepeatForever::create(Sequence::create(scale, scale->reverse(), NULL)); } DrawNode* BasicTest::shape() { - DrawNode *shape = DrawNode::create(); + auto shape = DrawNode::create(); static Point triangle[3]; triangle[0] = Point(-100, -100); triangle[1] = Point(100, -100); @@ -208,7 +208,7 @@ DrawNode* BasicTest::shape() Sprite* BasicTest::grossini() { - Sprite *grossini = Sprite::create(s_pathGrossini); + auto grossini = Sprite::create(s_pathGrossini); grossini->setScale( 1.5 ); return grossini; } @@ -243,14 +243,14 @@ std::string ShapeTest::subtitle() Node* ShapeTest::stencil() { - Node *node = this->shape(); + auto node = this->shape(); node->runAction(this->actionRotate()); return node; } Node* ShapeTest::content() { - Node *node = this->grossini(); + auto node = this->grossini(); node->runAction(this->actionScale()); return node; } @@ -270,7 +270,7 @@ std::string ShapeInvertedTest::subtitle() ClippingNode* ShapeInvertedTest::clipper() { - ClippingNode *clipper = ShapeTest::clipper(); + auto clipper = ShapeTest::clipper(); clipper->setInverted(true); return clipper; } @@ -289,21 +289,21 @@ std::string SpriteTest::subtitle() Node* SpriteTest::stencil() { - Node *node = this->grossini(); + auto node = this->grossini(); node->runAction(this->actionRotate()); return node; } ClippingNode* SpriteTest::clipper() { - ClippingNode *clipper = BasicTest::clipper(); + auto clipper = BasicTest::clipper(); clipper->setAlphaThreshold(0.05f); return clipper; } Node* SpriteTest::content() { - Node *node = this->shape(); + auto node = this->shape(); node->runAction(this->actionScale()); return node; } @@ -322,7 +322,7 @@ std::string SpriteNoAlphaTest::subtitle() ClippingNode* SpriteNoAlphaTest::clipper() { - ClippingNode *clipper = SpriteTest::clipper(); + auto clipper = SpriteTest::clipper(); clipper->setAlphaThreshold(1); return clipper; } @@ -341,7 +341,7 @@ std::string SpriteInvertedTest::subtitle() ClippingNode* SpriteInvertedTest::clipper() { - ClippingNode *clipper = SpriteTest::clipper(); + auto clipper = SpriteTest::clipper(); clipper->setAlphaThreshold(0.05f); clipper->setInverted(true); return clipper; @@ -363,13 +363,13 @@ void NestedTest::setup() { static int depth = 9; - Node *parent = this; + Node* parent = this; for (int i = 0; i < depth; i++) { int size = 225 - i * (225 / (depth * 2)); - ClippingNode *clipper = ClippingNode::create(); + auto clipper = ClippingNode::create(); clipper->setContentSize(Size(size, size)); clipper->setAnchorPoint(Point(0.5, 0.5)); clipper->setPosition( Point(parent->getContentSize().width / 2, parent->getContentSize().height / 2) ); @@ -377,7 +377,7 @@ void NestedTest::setup() clipper->runAction(RepeatForever::create(RotateBy::create(i % 3 ? 1.33 : 1.66, i % 2 ? 90 : -90))); parent->addChild(clipper); - Node *stencil = Sprite::create(s_pathGrossini); + auto stencil = Sprite::create(s_pathGrossini); stencil->setScale( 2.5 - (i * (2.5 / depth)) ); stencil->setAnchorPoint( Point(0.5, 0.5) ); stencil->setPosition( Point(clipper->getContentSize().width / 2, clipper->getContentSize().height / 2) ); @@ -413,7 +413,7 @@ std::string HoleDemo::subtitle() void HoleDemo::setup() { - Sprite *target = Sprite::create(s_pathBlock); + auto target = Sprite::create(s_pathBlock); target->setAnchorPoint(Point::ZERO); target->setScale(3); @@ -429,7 +429,7 @@ void HoleDemo::setup() _outerClipper->setStencil( target ); - ClippingNode *holesClipper = ClippingNode::create(); + auto holesClipper = ClippingNode::create(); holesClipper->setInverted(true); holesClipper->setAlphaThreshold( 0.05f ); @@ -457,14 +457,14 @@ void HoleDemo::pokeHoleAtPoint(Point point) float scale = CCRANDOM_0_1() * 0.2 + 0.9; float rotation = CCRANDOM_0_1() * 360; - Sprite *hole = Sprite::create("Images/hole_effect.png"); + auto hole = Sprite::create("Images/hole_effect.png"); hole->setPosition( point ); hole->setRotation( rotation ); hole->setScale( scale ); _holes->addChild(hole); - Sprite *holeStencil = Sprite::create("Images/hole_stencil.png"); + auto holeStencil = Sprite::create("Images/hole_stencil.png"); holeStencil->setPosition( point ); holeStencil->setRotation( rotation ); holeStencil->setScale( scale ); @@ -480,7 +480,7 @@ void HoleDemo::ccTouchesBegan(Set* touches, Event* event) { Touch *touch = (Touch *)touches->anyObject(); Point point = _outerClipper->convertToNodeSpace(Director::getInstance()->convertToGL(touch->getLocationInView())); - Rect rect = Rect(0, 0, _outerClipper->getContentSize().width, _outerClipper->getContentSize().height); + auto rect = Rect(0, 0, _outerClipper->getContentSize().width, _outerClipper->getContentSize().height); if (!rect.containsPoint(point)) return; this->pokeHoleAtPoint(point); } @@ -499,7 +499,7 @@ std::string ScrollViewDemo::subtitle() void ScrollViewDemo::setup() { - ClippingNode *clipper = ClippingNode::create(); + auto clipper = ClippingNode::create(); clipper->setTag( kTagClipperNode ); clipper->setContentSize( Size(200, 200) ); clipper->setAnchorPoint( Point(0.5, 0.5) ); @@ -507,7 +507,7 @@ void ScrollViewDemo::setup() clipper->runAction(RepeatForever::create(RotateBy::create(1, 45))); this->addChild(clipper); - DrawNode *stencil = DrawNode::create(); + auto stencil = DrawNode::create(); Point rectangle[4]; rectangle[0] = Point(0, 0); rectangle[1] = Point(clipper->getContentSize().width, 0); @@ -518,7 +518,7 @@ void ScrollViewDemo::setup() stencil->drawPolygon(rectangle, 4, white, 1, white); clipper->setStencil(stencil); - Sprite *content = Sprite::create(s_back2); + auto content = Sprite::create(s_back2); content->setTag( kTagContentNode ); content->setAnchorPoint( Point(0.5, 0.5) ); content->setPosition( Point(clipper->getContentSize().width / 2, clipper->getContentSize().height / 2) ); @@ -532,9 +532,9 @@ void ScrollViewDemo::setup() void ScrollViewDemo::ccTouchesBegan(Set *touches, Event *event) { Touch *touch = static_cast(touches->anyObject()); - Node *clipper = this->getChildByTag(kTagClipperNode); + auto clipper = this->getChildByTag(kTagClipperNode); Point point = clipper->convertToNodeSpace(Director::getInstance()->convertToGL(touch->getLocationInView())); - Rect rect = Rect(0, 0, clipper->getContentSize().width, clipper->getContentSize().height); + auto rect = Rect(0, 0, clipper->getContentSize().width, clipper->getContentSize().height); _scrolling = rect.containsPoint(point); _lastPoint = point; } @@ -543,10 +543,10 @@ void ScrollViewDemo::ccTouchesMoved(Set *touches, Event *event) { if (!_scrolling) return; Touch *touch = static_cast(touches->anyObject()); - Node *clipper = this->getChildByTag(kTagClipperNode); - Point point = clipper->convertToNodeSpace(Director::getInstance()->convertToGL(touch->getLocationInView())); + auto clipper = this->getChildByTag(kTagClipperNode); + auto point = clipper->convertToNodeSpace(Director::getInstance()->convertToGL(touch->getLocationInView())); Point diff = point - _lastPoint; - Node *content = clipper->getChildByTag(kTagContentNode); + auto content = clipper->getChildByTag(kTagContentNode); content->setPosition(content->getPosition() + diff); _lastPoint = point; } @@ -607,19 +607,19 @@ void RawStencilBufferTest::setup() void RawStencilBufferTest::draw() { - Point winPoint = Point(Director::getInstance()->getWinSize()); + auto winPoint = Point(Director::getInstance()->getWinSize()); - Point planeSize = winPoint * (1.0 / _planeCount); + auto planeSize = winPoint * (1.0 / _planeCount); glEnable(GL_STENCIL_TEST); CHECK_GL_ERROR_DEBUG(); for (int i = 0; i < _planeCount; i++) { - Point stencilPoint = planeSize * (_planeCount - i); + auto stencilPoint = planeSize * (_planeCount - i); stencilPoint.x = winPoint.x; - Point spritePoint = planeSize * i; + auto spritePoint = planeSize * i; spritePoint.x += planeSize.x / 2; spritePoint.y = 0; _sprite->setPosition( spritePoint ); @@ -723,7 +723,7 @@ void RawStencilBufferTest4::setupStencilForClippingOnPlane(GLint plane) glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, _alphaThreshold); #else - GLProgram *program = ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST); + auto program = ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST); GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE); program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold); _sprite->setShaderProgram(program ); @@ -756,7 +756,7 @@ void RawStencilBufferTest5::setupStencilForClippingOnPlane(GLint plane) glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, _alphaThreshold); #else - GLProgram *program = ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST); + auto program = ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST); GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE); program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold); _sprite->setShaderProgram( program ); @@ -783,7 +783,7 @@ std::string RawStencilBufferTest6::subtitle() void RawStencilBufferTest6::setup() { #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) - Point winPoint = Point(Director::getInstance()->getWinSize()); + auto winPoint = Point(Director::getInstance()->getWinSize()); //by default, glReadPixels will pack data with 4 bytes allignment unsigned char bits[4] = {0,0,0,0}; glStencilMask(~0); @@ -791,7 +791,7 @@ void RawStencilBufferTest6::setup() glClear(GL_STENCIL_BUFFER_BIT); glFlush(); glReadPixels(0, 0, 1, 1, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, &bits); - LabelTTF *clearToZeroLabel = LabelTTF::create(String::createWithFormat("00=%02x", bits[0])->getCString(), "Arial", 20); + auto clearToZeroLabel = LabelTTF::create(String::createWithFormat("00=%02x", bits[0])->getCString(), "Arial", 20); clearToZeroLabel->setPosition( Point((winPoint.x / 3) * 1, winPoint.y - 10) ); this->addChild(clearToZeroLabel); glStencilMask(0x0F); @@ -799,7 +799,7 @@ void RawStencilBufferTest6::setup() glClear(GL_STENCIL_BUFFER_BIT); glFlush(); glReadPixels(0, 0, 1, 1, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, &bits); - LabelTTF *clearToMaskLabel = LabelTTF::create(String::createWithFormat("0a=%02x", bits[0])->getCString(), "Arial", 20); + auto clearToMaskLabel = LabelTTF::create(String::createWithFormat("0a=%02x", bits[0])->getCString(), "Arial", 20); clearToMaskLabel->setPosition( Point((winPoint.x / 3) * 2, winPoint.y - 10) ); this->addChild(clearToMaskLabel); #endif @@ -822,7 +822,7 @@ void RawStencilBufferTest6::setupStencilForClippingOnPlane(GLint plane) glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, _alphaThreshold); #else - GLProgram *program = ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST); + auto program = ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST); GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE); program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold); _sprite->setShaderProgram(program); @@ -845,7 +845,7 @@ void RawStencilBufferTest6::setupStencilForDrawingOnPlane(GLint plane) void ClippingNodeTestScene::runThisTest() { - Layer* layer = nextAction(); + auto layer = nextAction(); addChild(layer); Director::getInstance()->replaceScene(this); } diff --git a/samples/Cpp/TestCpp/Classes/CocosDenshionTest/CocosDenshionTest.cpp b/samples/Cpp/TestCpp/Classes/CocosDenshionTest/CocosDenshionTest.cpp index 3aae4594f7..bd9b14f8cd 100644 --- a/samples/Cpp/TestCpp/Classes/CocosDenshionTest/CocosDenshionTest.cpp +++ b/samples/Cpp/TestCpp/Classes/CocosDenshionTest/CocosDenshionTest.cpp @@ -251,7 +251,7 @@ void CocosDenshionTest::onExit() void CocosDenshionTest::addButtons() { - LabelTTF *lblMusic = LabelTTF::create("Control Music", "Arial", 24); + auto lblMusic = LabelTTF::create("Control Music", "Arial", 24); addChildAt(lblMusic, 0.25f, 0.9f); Button *btnPlay = Button::createWithText("play"); @@ -293,7 +293,7 @@ void CocosDenshionTest::addButtons() }); addChildAt(btnIsPlayingMusic, 0.4f, 0.65f); - LabelTTF *lblSound = LabelTTF::create("Control Effects", "Arial", 24); + auto lblSound = LabelTTF::create("Control Effects", "Arial", 24); addChildAt(lblSound, 0.75f, 0.9f); Button *btnPlayEffect = Button::createWithText("play"); @@ -414,7 +414,7 @@ void CocosDenshionTest::updateVolumes(float) void CocosDenshionTestScene::runThisTest() { - Layer* layer = new CocosDenshionTest(); + auto layer = new CocosDenshionTest(); addChild(layer); layer->autorelease(); diff --git a/samples/Cpp/TestCpp/Classes/ConfigurationTest/ConfigurationTest.cpp b/samples/Cpp/TestCpp/Classes/ConfigurationTest/ConfigurationTest.cpp index 064bfa29fb..9ff65566a1 100644 --- a/samples/Cpp/TestCpp/Classes/ConfigurationTest/ConfigurationTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ConfigurationTest/ConfigurationTest.cpp @@ -25,7 +25,7 @@ static Layer* nextAction() sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - Layer* layer = (createFunctions[sceneIdx])(); + auto layer = (createFunctions[sceneIdx])(); layer->init(); layer->autorelease(); @@ -39,7 +39,7 @@ static Layer* backAction() if( sceneIdx < 0 ) sceneIdx += total; - Layer* layer = (createFunctions[sceneIdx])(); + auto layer = (createFunctions[sceneIdx])(); layer->init(); layer->autorelease(); @@ -48,7 +48,7 @@ static Layer* backAction() static Layer* restartAction() { - Layer* layer = (createFunctions[sceneIdx])(); + auto layer = (createFunctions[sceneIdx])(); layer->init(); layer->autorelease(); @@ -86,7 +86,7 @@ void ConfigurationBase::onExit() void ConfigurationBase::restartCallback(Object* sender) { - Scene* s = new ConfigurationTestScene(); + auto s = new ConfigurationTestScene(); s->addChild( restartAction() ); Director::getInstance()->replaceScene(s); s->release(); @@ -94,7 +94,7 @@ void ConfigurationBase::restartCallback(Object* sender) void ConfigurationBase::nextCallback(Object* sender) { - Scene* s = new ConfigurationTestScene(); + auto s = new ConfigurationTestScene(); s->addChild( nextAction() ); Director::getInstance()->replaceScene(s); s->release(); @@ -102,7 +102,7 @@ void ConfigurationBase::nextCallback(Object* sender) void ConfigurationBase::backCallback(Object* sender) { - Scene* s = new ConfigurationTestScene(); + auto s = new ConfigurationTestScene(); s->addChild( backAction() ); Director::getInstance()->replaceScene(s); s->release(); diff --git a/samples/Cpp/TestCpp/Classes/CurlTest/CurlTest.cpp b/samples/Cpp/TestCpp/Classes/CurlTest/CurlTest.cpp index 215d7f4e33..12caf48d00 100644 --- a/samples/Cpp/TestCpp/Classes/CurlTest/CurlTest.cpp +++ b/samples/Cpp/TestCpp/Classes/CurlTest/CurlTest.cpp @@ -5,7 +5,7 @@ CurlTest::CurlTest() { - LabelTTF* label = LabelTTF::create("Curl Test", "Arial", 28); + auto label = LabelTTF::create("Curl Test", "Arial", 28); addChild(label, 0); label->setPosition( Point(VisibleRect::center().x, VisibleRect::top().y-50) ); @@ -58,7 +58,7 @@ CurlTest::~CurlTest() void CurlTestScene::runThisTest() { - Layer* layer = new CurlTest(); + auto layer = new CurlTest(); addChild(layer); Director::getInstance()->replaceScene(this); diff --git a/samples/Cpp/TestCpp/Classes/CurrentLanguageTest/CurrentLanguageTest.cpp b/samples/Cpp/TestCpp/Classes/CurrentLanguageTest/CurrentLanguageTest.cpp index 6cb43bfb67..a952a4225b 100644 --- a/samples/Cpp/TestCpp/Classes/CurrentLanguageTest/CurrentLanguageTest.cpp +++ b/samples/Cpp/TestCpp/Classes/CurrentLanguageTest/CurrentLanguageTest.cpp @@ -2,11 +2,11 @@ CurrentLanguageTest::CurrentLanguageTest() { - LabelTTF* label = LabelTTF::create("Current language Test", "Arial", 28); + auto label = LabelTTF::create("Current language Test", "Arial", 28); addChild(label, 0); label->setPosition( Point(VisibleRect::center().x, VisibleRect::top().y-50) ); - LabelTTF *labelLanguage = LabelTTF::create("", "Arial", 20); + auto labelLanguage = LabelTTF::create("", "Arial", 20); labelLanguage->setPosition(VisibleRect::center()); LanguageType currentLanguageType = Application::getInstance()->getCurrentLanguage(); @@ -61,7 +61,7 @@ CurrentLanguageTest::CurrentLanguageTest() void CurrentLanguageTestScene::runThisTest() { - Layer* layer = new CurrentLanguageTest(); + auto layer = new CurrentLanguageTest(); addChild(layer); Director::getInstance()->replaceScene(this); diff --git a/samples/Cpp/TestCpp/Classes/DataVisitorTest/DataVisitorTest.cpp b/samples/Cpp/TestCpp/Classes/DataVisitorTest/DataVisitorTest.cpp index 12eeed1ce7..476a126ad4 100644 --- a/samples/Cpp/TestCpp/Classes/DataVisitorTest/DataVisitorTest.cpp +++ b/samples/Cpp/TestCpp/Classes/DataVisitorTest/DataVisitorTest.cpp @@ -15,11 +15,11 @@ void PrettyPrinterDemo::addSprite() { // create sprites - Sprite *s1 = Sprite::create("Images/grossini.png"); - Sprite *s2 = Sprite::create("Images/grossini_dance_01.png"); - Sprite *s3 = Sprite::create("Images/grossini_dance_02.png"); - Sprite *s4 = Sprite::create("Images/grossini_dance_03.png"); - Sprite *s5 = Sprite::create("Images/grossini_dance_04.png"); + auto s1 = Sprite::create("Images/grossini.png"); + auto s2 = Sprite::create("Images/grossini_dance_01.png"); + auto s3 = Sprite::create("Images/grossini_dance_02.png"); + auto s4 = Sprite::create("Images/grossini_dance_03.png"); + auto s5 = Sprite::create("Images/grossini_dance_04.png"); s1->setPosition(Point(50, 50)); s2->setPosition(Point(60, 50)); @@ -37,16 +37,16 @@ void PrettyPrinterDemo::addSprite() void PrettyPrinterDemo::onEnter() { Layer::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - LabelTTF* label = LabelTTF::create(title().c_str(), "Arial", 28); + auto label = LabelTTF::create(title().c_str(), "Arial", 28); label->setPosition( Point(s.width/2, s.height * 4/5) ); this->addChild(label, 1); std::string strSubtitle = subtitle(); if(strSubtitle.empty() == false) { - LabelTTF* subLabel = LabelTTF::create(strSubtitle.c_str(), "Thonburi", 16); + auto subLabel = LabelTTF::create(strSubtitle.c_str(), "Thonburi", 16); subLabel->setPosition( Point(s.width/2, s.height * 3/5) ); this->addChild(subLabel, 1); } @@ -55,7 +55,7 @@ void PrettyPrinterDemo::onEnter() PrettyPrinter vistor; // print dictionary - Dictionary* dict = Dictionary::createWithContentsOfFile("animations/animations.plist"); + auto dict = Dictionary::createWithContentsOfFile("animations/animations.plist"); dict->acceptVisitor(vistor); log("%s", vistor.getResult().c_str()); log("-------------------------------"); @@ -78,7 +78,7 @@ void PrettyPrinterDemo::onEnter() void DataVisitorTestScene::runThisTest() { - Layer *layer = new PrettyPrinterDemo(); + auto layer = new PrettyPrinterDemo(); layer->autorelease(); addChild(layer); diff --git a/samples/Cpp/TestCpp/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp b/samples/Cpp/TestCpp/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp index 114ed7090d..ca4f1f2be5 100644 --- a/samples/Cpp/TestCpp/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp +++ b/samples/Cpp/TestCpp/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp @@ -30,7 +30,7 @@ static Layer* nextAction() sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - Layer* layer = (createFunctions[sceneIdx])(); + auto layer = (createFunctions[sceneIdx])(); layer->autorelease(); return layer; @@ -43,7 +43,7 @@ static Layer* backAction() if( sceneIdx < 0 ) sceneIdx += total; - Layer* layer = (createFunctions[sceneIdx])(); + auto layer = (createFunctions[sceneIdx])(); layer->autorelease(); return layer; @@ -51,7 +51,7 @@ static Layer* backAction() static Layer* restartAction() { - Layer* layer = (createFunctions[sceneIdx])(); + auto layer = (createFunctions[sceneIdx])(); layer->autorelease(); return layer; @@ -71,7 +71,7 @@ void BaseLayer::onEnter() void BaseLayer::restartCallback(cocos2d::Object *pSender) { - Scene *s = new DrawPrimitivesTestScene(); + auto s = new DrawPrimitivesTestScene(); s->addChild(restartAction()); Director::getInstance()->replaceScene(s); @@ -80,7 +80,7 @@ void BaseLayer::restartCallback(cocos2d::Object *pSender) void BaseLayer::nextCallback(cocos2d::Object *pSender) { - Scene *s = new DrawPrimitivesTestScene();; + auto s = new DrawPrimitivesTestScene();; s->addChild(nextAction()); Director::getInstance()->replaceScene(s); @@ -89,7 +89,7 @@ void BaseLayer::nextCallback(cocos2d::Object *pSender) void BaseLayer::backCallback(cocos2d::Object *pSender) { - Scene *s = new DrawPrimitivesTestScene(); + auto s = new DrawPrimitivesTestScene(); s->addChild(backAction()); Director::getInstance()->replaceScene(s); @@ -236,9 +236,9 @@ string DrawPrimitivesTest::subtitle() // DrawNodeTest DrawNodeTest::DrawNodeTest() { - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - DrawNode *draw = DrawNode::create(); + auto draw = DrawNode::create(); addChild(draw, 10); // Draw 10 circles @@ -300,7 +300,7 @@ string DrawNodeTest::subtitle() void DrawPrimitivesTestScene::runThisTest() { - Layer* layer = nextAction(); + auto layer = nextAction(); addChild(layer); Director::getInstance()->replaceScene(this); diff --git a/samples/Cpp/TestCpp/Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp b/samples/Cpp/TestCpp/Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp index 910033e094..d0d7f7c593 100644 --- a/samples/Cpp/TestCpp/Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp +++ b/samples/Cpp/TestCpp/Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp @@ -20,22 +20,22 @@ void Effect1::onEnter() { EffectAdvanceTextLayer::onEnter(); - Node* target = getChildByTag(kTagBackground); + auto target = getChildByTag(kTagBackground); // To reuse a grid the grid size and the grid type must be the same. // in this case: // Lens3D is Grid3D and it's size is (15,10) // Waves3D is Grid3D and it's size is (15,10) - Size size = Director::getInstance()->getWinSize(); - ActionInterval* lens = Lens3D::create(0.0f, Size(15,10), Point(size.width/2,size.height/2), 240); - ActionInterval* waves = Waves3D::create(10, Size(15,10), 18, 15); + auto size = Director::getInstance()->getWinSize(); + auto lens = Lens3D::create(0.0f, Size(15,10), Point(size.width/2,size.height/2), 240); + auto waves = Waves3D::create(10, Size(15,10), 18, 15); - FiniteTimeAction* reuse = ReuseGrid::create(1); - ActionInterval* delay = DelayTime::create(8); + auto reuse = ReuseGrid::create(1); + auto delay = DelayTime::create(8); - ActionInterval* orbit = OrbitCamera::create(5, 1, 2, 0, 180, 0, -90); - ActionInterval* orbit_back = orbit->reverse(); + auto orbit = OrbitCamera::create(5, 1, 2, 0, 180, 0, -90); + auto orbit_back = orbit->reverse(); target->runAction( RepeatForever::create( Sequence::create( orbit, orbit_back, NULL) ) ); target->runAction( Sequence::create(lens, delay, reuse, waves, NULL) ); @@ -55,25 +55,25 @@ void Effect2::onEnter() { EffectAdvanceTextLayer::onEnter(); - Node* target = getChildByTag(kTagBackground); + auto target = getChildByTag(kTagBackground); // To reuse a grid the grid size and the grid type must be the same. // in this case: // ShakyTiles is TiledGrid3D and it's size is (15,10) // Shuffletiles is TiledGrid3D and it's size is (15,10) // TurnOfftiles is TiledGrid3D and it's size is (15,10) - ActionInterval* shaky = ShakyTiles3D::create(5, Size(15,10), 4, false); - ActionInterval* shuffle = ShuffleTiles::create(0, Size(15,10), 3); - ActionInterval* turnoff = TurnOffTiles::create(0, Size(15,10), 3); - ActionInterval* turnon = turnoff->reverse(); + auto shaky = ShakyTiles3D::create(5, Size(15,10), 4, false); + auto shuffle = ShuffleTiles::create(0, Size(15,10), 3); + auto turnoff = TurnOffTiles::create(0, Size(15,10), 3); + auto turnon = turnoff->reverse(); // reuse 2 times: // 1 for shuffle // 2 for turn off // turnon tiles will use a new grid - FiniteTimeAction* reuse = ReuseGrid::create(2); + auto reuse = ReuseGrid::create(2); - ActionInterval* delay = DelayTime::create(1); + auto delay = DelayTime::create(1); // id orbit = [OrbitCamera::create:5 radius:1 deltaRadius:2 angleZ:0 deltaAngleZ:180 angleX:0 deltaAngleX:-90]; // id orbit_back = [orbit reverse]; @@ -97,18 +97,18 @@ void Effect3::onEnter() { EffectAdvanceTextLayer::onEnter(); - Node* bg = getChildByTag(kTagBackground); - Node* target1 = bg->getChildByTag(kTagSprite1); - Node* target2 = bg->getChildByTag(kTagSprite2); + auto bg = getChildByTag(kTagBackground); + auto target1 = bg->getChildByTag(kTagSprite1); + auto target2 = bg->getChildByTag(kTagSprite2); - ActionInterval* waves = Waves::create(5, Size(15,10), 5, 20, true, false); - ActionInterval* shaky = Shaky3D::create(5, Size(15,10), 4, false); + auto waves = Waves::create(5, Size(15,10), 5, 20, true, false); + auto shaky = Shaky3D::create(5, Size(15,10), 4, false); target1->runAction( RepeatForever::create( waves ) ); target2->runAction( RepeatForever::create( shaky ) ); // moving background. Testing issue #244 - ActionInterval* move = MoveBy::create(3, Point(200,0) ); + auto move = MoveBy::create(3, Point(200,0) ); bg->runAction(RepeatForever::create( Sequence::create(move, move->reverse(), NULL) )); } @@ -157,18 +157,18 @@ void Effect4::onEnter() { EffectAdvanceTextLayer::onEnter(); - Lens3D* lens = Lens3D::create(10, Size(32,24), Point(100,180), 150); - ActionInterval* move = JumpBy::create(5, Point(380,0), 100, 4); - ActionInterval* move_back = move->reverse(); - ActionInterval* seq = Sequence::create( move, move_back, NULL); + auto lens = Lens3D::create(10, Size(32,24), Point(100,180), 150); + auto move = JumpBy::create(5, Point(380,0), 100, 4); + auto move_back = move->reverse(); + auto seq = Sequence::create( move, move_back, NULL); /* In cocos2d-iphone, the type of action's target is 'id', so it supports using the instance of 'Lens3D' as its target. While in cocos2d-x, the target of action only supports Node or its subclass, so we make an encapsulation for Lens3D to achieve that. */ - Director* director = Director::getInstance(); - Node* pTarget = Lens3DTarget::create(lens); + auto director = Director::getInstance(); + auto pTarget = Lens3DTarget::create(lens); // Please make sure the target been added to its parent. this->addChild(pTarget); @@ -192,9 +192,9 @@ void Effect5::onEnter() //CCDirector::getInstance()->setProjection(DirectorProjection2D); - ActionInterval* effect = Liquid::create(2, Size(32,24), 1, 20); + auto effect = Liquid::create(2, Size(32,24), 1, 20); - ActionInterval* stopEffect = Sequence::create( + auto stopEffect = Sequence::create( effect, DelayTime::create(2), StopGrid::create(), @@ -202,7 +202,7 @@ void Effect5::onEnter() // [[effect copy] autorelease], NULL); - Node* bg = getChildByTag(kTagBackground); + auto bg = getChildByTag(kTagBackground); bg->runAction(stopEffect); } @@ -227,22 +227,22 @@ void Issue631::onEnter() { EffectAdvanceTextLayer::onEnter(); - ActionInterval* effect = Sequence::create( DelayTime::create(2.0f), Shaky3D::create(5.0f, Size(5, 5), 16, false), NULL); + auto effect = Sequence::create( DelayTime::create(2.0f), Shaky3D::create(5.0f, Size(5, 5), 16, false), NULL); // cleanup - Node* bg = getChildByTag(kTagBackground); + auto bg = getChildByTag(kTagBackground); removeChild(bg, true); // background - LayerColor* layer = LayerColor::create( Color4B(255,0,0,255) ); + auto layer = LayerColor::create( Color4B(255,0,0,255) ); addChild(layer, -10); - Sprite* sprite = Sprite::create("Images/grossini.png"); + auto sprite = Sprite::create("Images/grossini.png"); sprite->setPosition( Point(50,80) ); layer->addChild(sprite, 10); // foreground - LayerColor* layer2 = LayerColor::create(Color4B( 0, 255,0,255 ) ); - Sprite* fog = Sprite::create("Images/Fog.png"); + auto layer2 = LayerColor::create(Color4B( 0, 255,0,255 ) ); + auto fog = Sprite::create("Images/Fog.png"); BlendFunc bf = {GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA}; fog->setBlendFunc(bf); @@ -303,7 +303,7 @@ Layer* nextEffectAdvanceAction() sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - Layer* layer = createEffectAdvanceLayer(sceneIdx); + auto layer = createEffectAdvanceLayer(sceneIdx); layer->autorelease(); return layer; @@ -316,7 +316,7 @@ Layer* backEffectAdvanceAction() if( sceneIdx < 0 ) sceneIdx += total; - Layer* layer = createEffectAdvanceLayer(sceneIdx); + auto layer = createEffectAdvanceLayer(sceneIdx); layer->autorelease(); return layer; @@ -324,7 +324,7 @@ Layer* backEffectAdvanceAction() Layer* restartEffectAdvanceAction() { - Layer* layer = createEffectAdvanceLayer(sceneIdx); + auto layer = createEffectAdvanceLayer(sceneIdx); layer->autorelease(); return layer; @@ -335,22 +335,22 @@ void EffectAdvanceTextLayer::onEnter(void) { BaseTest::onEnter(); - Sprite *bg = Sprite::create("Images/background3.png"); + auto bg = Sprite::create("Images/background3.png"); addChild(bg, 0, kTagBackground); bg->setPosition( VisibleRect::center() ); - Sprite* grossini = Sprite::create("Images/grossinis_sister2.png"); + auto grossini = Sprite::create("Images/grossinis_sister2.png"); bg->addChild(grossini, 1, kTagSprite1); grossini->setPosition( Point(VisibleRect::left().x+VisibleRect::getVisibleRect().size.width/3.0f, VisibleRect::bottom().y+ 200) ); - ActionInterval* sc = ScaleBy::create(2, 5); - ActionInterval* sc_back = sc->reverse(); + auto sc = ScaleBy::create(2, 5); + auto sc_back = sc->reverse(); grossini->runAction( RepeatForever::create(Sequence::create(sc, sc_back, NULL) ) ); - Sprite* tamara = Sprite::create("Images/grossinis_sister1.png"); + auto tamara = Sprite::create("Images/grossinis_sister1.png"); bg->addChild(tamara, 1, kTagSprite2); tamara->setPosition( Point(VisibleRect::left().x+2*VisibleRect::getVisibleRect().size.width/3.0f,VisibleRect::bottom().y+200) ); - ActionInterval* sc2 = ScaleBy::create(2, 5); - ActionInterval* sc2_back = sc2->reverse(); + auto sc2 = ScaleBy::create(2, 5); + auto sc2_back = sc2->reverse(); tamara->runAction( RepeatForever::create(Sequence::create(sc2, sc2_back, NULL) ) ); } @@ -370,7 +370,7 @@ std::string EffectAdvanceTextLayer::subtitle() void EffectAdvanceTextLayer::restartCallback(Object* sender) { - Scene* s = new EffectAdvanceScene(); + auto s = new EffectAdvanceScene(); s->addChild(restartEffectAdvanceAction()); Director::getInstance()->replaceScene(s); @@ -379,7 +379,7 @@ void EffectAdvanceTextLayer::restartCallback(Object* sender) void EffectAdvanceTextLayer::nextCallback(Object* sender) { - Scene* s = new EffectAdvanceScene(); + auto s = new EffectAdvanceScene(); s->addChild( nextEffectAdvanceAction() ); Director::getInstance()->replaceScene(s); @@ -388,7 +388,7 @@ void EffectAdvanceTextLayer::nextCallback(Object* sender) void EffectAdvanceTextLayer::backCallback(Object* sender) { - Scene* s = new EffectAdvanceScene(); + auto s = new EffectAdvanceScene(); s->addChild( backEffectAdvanceAction() ); Director::getInstance()->replaceScene(s); s->release(); @@ -396,7 +396,7 @@ void EffectAdvanceTextLayer::backCallback(Object* sender) void EffectAdvanceScene::runThisTest() { - Layer* layer = nextEffectAdvanceAction(); + auto layer = nextEffectAdvanceAction(); addChild(layer); Director::getInstance()->replaceScene(this); diff --git a/samples/Cpp/TestCpp/Classes/EffectsTest/EffectsTest.cpp b/samples/Cpp/TestCpp/Classes/EffectsTest/EffectsTest.cpp index 655f063324..bc08aa37b4 100644 --- a/samples/Cpp/TestCpp/Classes/EffectsTest/EffectsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/EffectsTest/EffectsTest.cpp @@ -59,9 +59,9 @@ class FlipX3DDemo : public FlipX3D public: static ActionInterval* create(float t) { - FlipX3D* flipx = FlipX3D::create(t); - ActionInterval* flipx_back = flipx->reverse(); - DelayTime* delay = DelayTime::create(2); + auto flipx = FlipX3D::create(t); + auto flipx_back = flipx->reverse(); + auto delay = DelayTime::create(2); return Sequence::create(flipx, delay, flipx_back, NULL); } @@ -72,9 +72,9 @@ class FlipY3DDemo : public FlipY3D public: static ActionInterval* create(float t) { - FlipY3D* flipy = FlipY3D::create(t); - ActionInterval* flipy_back = flipy->reverse(); - DelayTime* delay = DelayTime::create(2); + auto flipy = FlipY3D::create(t); + auto flipy_back = flipy->reverse(); + auto delay = DelayTime::create(2); return Sequence::create(flipy, delay, flipy_back, NULL); } @@ -85,7 +85,7 @@ class Lens3DDemo : public Lens3D public: static ActionInterval* create(float t) { - Size size = Director::getInstance()->getWinSize(); + auto size = Director::getInstance()->getWinSize(); return Lens3D::create(t, Size(15,10), Point(size.width/2,size.height/2), 240); } }; @@ -96,7 +96,7 @@ class Ripple3DDemo : public Ripple3D public: static ActionInterval* create(float t) { - Size size = Director::getInstance()->getWinSize(); + auto size = Director::getInstance()->getWinSize(); return Ripple3D::create(t, Size(32,24), Point(size.width/2,size.height/2), 240, 4, 160); } }; @@ -127,7 +127,7 @@ class TwirlDemo : public Twirl public: static ActionInterval* create(float t) { - Size size = Director::getInstance()->getWinSize(); + auto size = Director::getInstance()->getWinSize(); return Twirl::create(t, Size(12,8), Point(size.width/2, size.height/2), 1, 2.5f); } }; @@ -158,9 +158,9 @@ class ShuffleTilesDemo : public ShuffleTiles public: static ActionInterval* create(float t) { - ShuffleTiles* shuffle = ShuffleTiles::create(t, Size(16,12), 25); - ActionInterval* shuffle_back = shuffle->reverse(); - DelayTime* delay = DelayTime::create(2); + auto shuffle = ShuffleTiles::create(t, Size(16,12), 25); + auto shuffle_back = shuffle->reverse(); + auto delay = DelayTime::create(2); return Sequence::create(shuffle, delay, shuffle_back, NULL); } @@ -172,9 +172,9 @@ class FadeOutTRTilesDemo : public FadeOutTRTiles public: static ActionInterval* create(float t) { - FadeOutTRTiles* fadeout = FadeOutTRTiles::create(t, Size(16,12)); - ActionInterval* back = fadeout->reverse(); - DelayTime* delay = DelayTime::create(0.5f); + auto fadeout = FadeOutTRTiles::create(t, Size(16,12)); + auto back = fadeout->reverse(); + auto delay = DelayTime::create(0.5f); return Sequence::create(fadeout, delay, back, NULL); } @@ -186,9 +186,9 @@ class FadeOutBLTilesDemo : public FadeOutBLTiles public: static ActionInterval* create(float t) { - FadeOutBLTiles* fadeout = FadeOutBLTiles::create(t, Size(16,12)); - ActionInterval* back = fadeout->reverse(); - DelayTime* delay = DelayTime::create(0.5f); + auto fadeout = FadeOutBLTiles::create(t, Size(16,12)); + auto back = fadeout->reverse(); + auto delay = DelayTime::create(0.5f); return Sequence::create(fadeout, delay, back, NULL); } @@ -200,9 +200,9 @@ class FadeOutUpTilesDemo : public FadeOutUpTiles public: static ActionInterval* create(float t) { - FadeOutUpTiles* fadeout = FadeOutUpTiles::create(t, Size(16,12)); - ActionInterval* back = fadeout->reverse(); - DelayTime* delay = DelayTime::create(0.5f); + auto fadeout = FadeOutUpTiles::create(t, Size(16,12)); + auto back = fadeout->reverse(); + auto delay = DelayTime::create(0.5f); return Sequence::create(fadeout, delay, back, NULL); } @@ -213,9 +213,9 @@ class FadeOutDownTilesDemo : public FadeOutDownTiles public: static ActionInterval* create(float t) { - FadeOutDownTiles* fadeout = FadeOutDownTiles::create(t, Size(16,12)); - ActionInterval* back = fadeout->reverse(); - DelayTime* delay = DelayTime::create(0.5f); + auto fadeout = FadeOutDownTiles::create(t, Size(16,12)); + auto back = fadeout->reverse(); + auto delay = DelayTime::create(0.5f); return Sequence::create(fadeout, delay, back, NULL); } @@ -226,9 +226,9 @@ class TurnOffTilesDemo : public TurnOffTiles public: static ActionInterval* create(float t) { - TurnOffTiles* fadeout = TurnOffTiles::create(t, Size(48,32), 25); - ActionInterval* back = fadeout->reverse(); - DelayTime* delay = DelayTime::create(0.5f); + auto fadeout = TurnOffTiles::create(t, Size(48,32), 25); + auto back = fadeout->reverse(); + auto delay = DelayTime::create(0.5f); return Sequence::create(fadeout, delay, back, NULL); } @@ -323,7 +323,7 @@ ActionInterval* createEffect(int nIndex, float t) ActionInterval* getAction() { - ActionInterval* pEffect = createEffect(actionIdx, 3); + auto pEffect = createEffect(actionIdx, 3); return pEffect; } @@ -342,31 +342,31 @@ TextLayer::TextLayer(void) LayerColor *background = LayerColor::create( Color4B(32,128,32,255) ); this->addChild(background,-20); - Node* node = Node::create(); - ActionInterval* effect = getAction(); + auto node = Node::create(); + auto effect = getAction(); node->runAction(effect); addChild(node, 0, kTagBackground); - Sprite *bg = Sprite::create(s_back3); + auto bg = Sprite::create(s_back3); node->addChild(bg, 0); // bg->setAnchorPoint( Point::ZERO ); bg->setPosition(VisibleRect::center()); - Sprite* grossini = Sprite::create(s_pathSister2); + auto grossini = Sprite::create(s_pathSister2); node->addChild(grossini, 1); grossini->setPosition( Point(VisibleRect::left().x+VisibleRect::getVisibleRect().size.width/3,VisibleRect::center().y) ); - ActionInterval* sc = ScaleBy::create(2, 5); - ActionInterval* sc_back = sc->reverse(); + auto sc = ScaleBy::create(2, 5); + auto sc_back = sc->reverse(); grossini->runAction( RepeatForever::create(Sequence::create(sc, sc_back, NULL) ) ); - Sprite* tamara = Sprite::create(s_pathSister1); + auto tamara = Sprite::create(s_pathSister1); node->addChild(tamara, 1); tamara->setPosition( Point(VisibleRect::left().x+2*VisibleRect::getVisibleRect().size.width/3,VisibleRect::center().y) ); - ActionInterval* sc2 = ScaleBy::create(2, 5); - ActionInterval* sc2_back = sc2->reverse(); + auto sc2 = ScaleBy::create(2, 5); + auto sc2_back = sc2->reverse(); tamara->runAction( RepeatForever::create(Sequence::create(sc2, sc2_back, NULL)) ); - LabelTTF* label = LabelTTF::create((effectsList[actionIdx]).c_str(), "Marker Felt", 32); + auto label = LabelTTF::create((effectsList[actionIdx]).c_str(), "Marker Felt", 32); label->setPosition( Point(VisibleRect::center().x,VisibleRect::top().y-80) ); addChild(label); @@ -377,7 +377,7 @@ TextLayer::TextLayer(void) void TextLayer::checkAnim(float dt) { - Node* s2 = getChildByTag(kTagBackground); + auto s2 = getChildByTag(kTagBackground); if ( s2->getNumberOfRunningActions() == 0 && s2->getGrid() != NULL) s2->setGrid(NULL);; } @@ -394,7 +394,7 @@ TextLayer::~TextLayer(void) TextLayer* TextLayer::create() { - TextLayer* layer = new TextLayer(); + auto layer = new TextLayer(); layer->autorelease(); return layer; @@ -407,8 +407,8 @@ void TextLayer::onEnter() void TextLayer::newScene() { - Scene* s = new EffectTestScene(); - Node* child = TextLayer::create(); + auto s = new EffectTestScene(); + auto child = TextLayer::create(); s->addChild(child); Director::getInstance()->replaceScene(s); s->release(); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ArmatureTest/ArmatureScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ArmatureTest/ArmatureScene.cpp index 6ca1144601..d70d0a7e5d 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ArmatureTest/ArmatureScene.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ArmatureTest/ArmatureScene.cpp @@ -134,7 +134,7 @@ void ArmatureTestLayer::onEnter() std::string strSubtitle = subtitle(); if( ! strSubtitle.empty() ) { - LabelTTF* l = LabelTTF::create(strSubtitle.c_str(), "Arial", 18); + auto l = LabelTTF::create(strSubtitle.c_str(), "Arial", 18); l->setColor(Color3B(0, 0, 0)); addChild(l, 1, 10001); l->setPosition( Point(VisibleRect::center().x, VisibleRect::top().y - 60) ); @@ -299,7 +299,7 @@ void TestPerformance::update(float delta) char pszCount[255]; sprintf(pszCount, "%s %i", subtitle().c_str(), armatureCount); - LabelTTF *label = (LabelTTF*)getChildByTag(10001); + auto label = (LabelTTF*)getChildByTag(10001); label->setString(pszCount); } } @@ -382,14 +382,14 @@ void TestAnimationEvent::animationEvent(Armature *armature, MovementEventType mo { if (id.compare("Fire") == 0) { - ActionInterval *actionToRight = MoveTo::create(2, Point(VisibleRect::right().x - 50, VisibleRect::right().y)); + auto actionToRight = MoveTo::create(2, Point(VisibleRect::right().x - 50, VisibleRect::right().y)); armature->stopAllActions(); armature->runAction(Sequence::create(actionToRight, CallFunc::create(CC_CALLBACK_0(TestAnimationEvent::callback1,this)), NULL)); armature->getAnimation()->play("Walk"); } else if (id.compare("FireMax") == 0) { - ActionInterval *actionToLeft = MoveTo::create(2, Point(VisibleRect::left().x + 50, VisibleRect::left().y)); + auto actionToLeft = MoveTo::create(2, Point(VisibleRect::left().x + 50, VisibleRect::left().y)); armature->stopAllActions(); armature->runAction(Sequence::create(actionToLeft, CallFunc::create(CC_CALLBACK_0(TestAnimationEvent::callback2,this)), NULL)); armature->getAnimation()->play("Walk"); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp index e016a587ea..7efbe7c920 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp @@ -39,7 +39,7 @@ void CocosBuilderTestScene::runThisTest() { cocos2d::extension::CCBReader * ccbReader = new cocos2d::extension::CCBReader(ccNodeLoaderLibrary); /* Read a ccbi file. */ - Node * node = ccbReader->readNodeGraphFromFile("ccb/HelloCocosBuilder.ccbi", this); + auto node = ccbReader->readNodeGraphFromFile("ccb/HelloCocosBuilder.ccbi", this); ccbReader->release(); @@ -52,7 +52,7 @@ void CocosBuilderTestScene::runThisTest() { //void CocosBuilderTestScene::runThisTest() { -// CCBIReaderLayer * ccbiReaderLayer = CCBIReaderLayer::node(); +// auto ccbiReaderLayer = CCBIReaderLayer::node(); // // /* Create an autorelease NodeLoaderLibrary. */ // NodeLoaderLibrary * ccNodeLoaderLibrary = NodeLoaderLibrary::newDefaultNodeLoaderLibrary(); @@ -62,7 +62,7 @@ void CocosBuilderTestScene::runThisTest() { // ccbReader->autorelease(); // // /* Read a ccbi file. */ -// Node * node = ccbReader->readNodeGraphFromFile("ccb/simple/pub/", "ccb/test.ccbi", ccbiReaderLayer); +// auto node = ccbReader->readNodeGraphFromFile("ccb/simple/pub/", "ccb/test.ccbi", ccbiReaderLayer); // // if(node != NULL) { // ccbiReaderLayer->addChild(node); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp index 25e7895237..90deb8a29e 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp @@ -42,11 +42,11 @@ void HelloCocosBuilderLayer::openTest(const char * pCCBFileName, const char * no // the owner will cause lblTestTitle to be set by the CCBReader. // lblTestTitle is in the TestHeader.ccbi, which is referenced // from each of the test scenes. - Node * node = ccbReader->readNodeGraphFromFile(pCCBFileName, this); + auto node = ccbReader->readNodeGraphFromFile(pCCBFileName, this); this->mTestTitleLabelTTF->setString(pCCBFileName); - Scene * scene = Scene::create(); + auto scene = Scene::create(); if(node != NULL) { scene->addChild(node); } @@ -62,8 +62,8 @@ void HelloCocosBuilderLayer::openTest(const char * pCCBFileName, const char * no void HelloCocosBuilderLayer::onNodeLoaded(cocos2d::Node * node, cocos2d::extension::NodeLoader * nodeLoader) { - RotateBy * ccRotateBy = RotateBy::create(20.0f, 360); - RepeatForever * ccRepeatForever = RepeatForever::create(ccRotateBy); + auto ccRotateBy = RotateBy::create(20.0f, 360); + auto ccRepeatForever = RepeatForever::create(ccRotateBy); this->mBurstSprite->runAction(ccRepeatForever); } @@ -156,13 +156,13 @@ void HelloCocosBuilderLayer::onAnimationsTestClicked(Object * sender, cocos2d::e // the owner will cause lblTestTitle to be set by the CCBReader. // lblTestTitle is in the TestHeader.ccbi, which is referenced // from each of the test scenes. - Node *animationsTest = ccbReader->readNodeGraphFromFile("ccb/ccb/TestAnimations.ccbi", this); + auto animationsTest = ccbReader->readNodeGraphFromFile("ccb/ccb/TestAnimations.ccbi", this); // Load node graph (TestAnimations is a sub class of Layer) and retrieve the ccb action manager ((AnimationsTestLayer*)animationsTest)->setAnimationManager(ccbReader->getAnimationManager()); this->mTestTitleLabelTTF->setString("TestAnimations.ccbi"); - Scene * scene = Scene::create(); + auto scene = Scene::create(); if(animationsTest != NULL) { scene->addChild(animationsTest); } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/ComponentsTestScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/ComponentsTestScene.cpp index 1c9c71bd81..fa7494e6a3 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/ComponentsTestScene.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/ComponentsTestScene.cpp @@ -26,7 +26,7 @@ Scene* ComponentsTestLayer::scene() CC_BREAK_IF(! scene); // 'layer' is an autorelease object - ComponentsTestLayer *layer = ComponentsTestLayer::create(); + auto layer = ComponentsTestLayer::create(); CC_BREAK_IF(! layer); // add layer as a child to scene @@ -45,7 +45,7 @@ bool ComponentsTestLayer::init() { CC_BREAK_IF(! LayerColor::initWithColor( Color4B(255,255,255,255) ) ); - Node *root = createGameScene(); + auto root = createGameScene(); CC_BREAK_IF(!root); this->addChild(root, 0, 1); @@ -67,11 +67,11 @@ cocos2d::Node* ComponentsTestLayer::createGameScene() Node *root = NULL; do { - Size visibleSize = Director::getInstance()->getVisibleSize(); - Point origin = Director::getInstance()->getVisibleOrigin(); + auto visibleSize = Director::getInstance()->getVisibleSize(); + auto origin = Director::getInstance()->getVisibleOrigin(); - Sprite *player = Sprite::create("components/Player.png", Rect(0, 0, 27, 40) ); + auto player = Sprite::create("components/Player.png", Rect(0, 0, 27, 40) ); player->setPosition( Point(origin.x + player->getContentSize().width/2, origin.y + visibleSize.height/2) ); @@ -80,15 +80,15 @@ cocos2d::Node* ComponentsTestLayer::createGameScene() root->addChild(player, 1, 1); - MenuItemFont *itemBack = MenuItemFont::create("Back", [](Object* sender){ - ExtensionsTestScene *scene = new ExtensionsTestScene(); + auto itemBack = MenuItemFont::create("Back", [](Object* sender){ + auto scene = new ExtensionsTestScene(); scene->runThisTest(); scene->release(); }); itemBack->setColor(Color3B(0, 0, 0)); itemBack->setPosition(Point(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25)); - Menu *menuBack = Menu::create(itemBack, NULL); + auto menuBack = Menu::create(itemBack, NULL); menuBack->setPosition(Point::ZERO); addChild(menuBack); @@ -99,6 +99,6 @@ cocos2d::Node* ComponentsTestLayer::createGameScene() void runComponentsTestLayerTest() { - Scene *scene = ComponentsTestLayer::scene(); + auto scene = ComponentsTestLayer::scene(); Director::getInstance()->replaceScene(scene); } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/EnemyController.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/EnemyController.cpp index 2c62142516..690de6c8ff 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/EnemyController.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/EnemyController.cpp @@ -75,8 +75,8 @@ EnemyController* EnemyController::create(void) void EnemyController::die() { - Component *com = _owner->getParent()->getComponent("SceneController"); - cocos2d::Array *_targets = ((SceneController*)com)->getTargets(); + auto com = _owner->getParent()->getComponent("SceneController"); + auto _targets = ((SceneController*)com)->getTargets(); _targets->removeObject(_owner); _owner->removeFromParentAndCleanup(true); ((SceneController*)com)->increaseKillCount(); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/GameOverScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/GameOverScene.cpp index 9d5f482bc1..dc0fbea33b 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/GameOverScene.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/GameOverScene.cpp @@ -59,7 +59,7 @@ bool GameOverLayer::init() { if ( LayerColor::initWithColor( Color4B(255,255,255,255) ) ) { - Size winSize = Director::getInstance()->getWinSize(); + auto winSize = Director::getInstance()->getWinSize(); this->_label = LabelTTF::create("","Artial", 32); _label->retain(); _label->setColor( Color3B(0, 0, 0) ); @@ -72,15 +72,15 @@ bool GameOverLayer::init() NULL)); - MenuItemFont *itemBack = MenuItemFont::create("Back", [](Object* sender){ - ExtensionsTestScene *scene = new ExtensionsTestScene(); + auto itemBack = MenuItemFont::create("Back", [](Object* sender){ + auto scene = new ExtensionsTestScene(); scene->runThisTest(); scene->release(); }); itemBack->setColor(Color3B(0, 0, 0)); itemBack->setPosition(Point(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25)); - Menu *menuBack = Menu::create(itemBack, NULL); + auto menuBack = Menu::create(itemBack, NULL); menuBack->setPosition(Point::ZERO); addChild(menuBack); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/ProjectileController.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/ProjectileController.cpp index 61fe94b312..12eec899ec 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/ProjectileController.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/ProjectileController.cpp @@ -20,11 +20,11 @@ bool ProjectileController::init() void ProjectileController::onEnter() { - Size winSize = Director::getInstance()->getVisibleSize(); - Point origin = Director::getInstance()->getVisibleOrigin(); + auto winSize = Director::getInstance()->getVisibleSize(); + auto origin = Director::getInstance()->getVisibleOrigin(); _owner->setPosition( Point(origin.x+20, origin.y+winSize.height/2) ); _owner->setTag(3); - Component *com = _owner->getParent()->getComponent("SceneController"); + auto com = _owner->getParent()->getComponent("SceneController"); ((SceneController*)com)->getProjectiles()->addObject(_owner); } @@ -35,22 +35,22 @@ void ProjectileController::onExit() void ProjectileController::update(float delta) { - Component *com = _owner->getParent()->getComponent("SceneController"); - cocos2d::Array *_targets = ((SceneController*)com)->getTargets(); + auto com = _owner->getParent()->getComponent("SceneController"); + auto _targets = ((SceneController*)com)->getTargets(); - Sprite *projectile = dynamic_cast(_owner); - Rect projectileRect = Rect( + auto projectile = dynamic_cast(_owner); + auto projectileRect = Rect( projectile->getPosition().x - (projectile->getContentSize().width/2), projectile->getPosition().y - (projectile->getContentSize().height/2), projectile->getContentSize().width, projectile->getContentSize().height); - Array* targetsToDelete =new Array; + auto targetsToDelete =new Array; Object* jt = NULL; CCARRAY_FOREACH(_targets, jt) { - Sprite *target = dynamic_cast(jt); - Rect targetRect = Rect( + auto target = dynamic_cast(jt); + auto targetRect = Rect( target->getPosition().x - (target->getContentSize().width/2), target->getPosition().y - (target->getContentSize().height/2), target->getContentSize().width, @@ -65,7 +65,7 @@ void ProjectileController::update(float delta) CCARRAY_FOREACH(targetsToDelete, jt) { - Sprite *target = dynamic_cast(jt); + auto target = dynamic_cast(jt); static_cast(target->getComponent("EnemyController"))->die(); } @@ -100,8 +100,8 @@ void freeFunction( Node *ignore ) void ProjectileController::move(float flocationX, float flocationY) { - Size winSize = Director::getInstance()->getVisibleSize(); - Point origin = Director::getInstance()->getVisibleOrigin(); + auto winSize = Director::getInstance()->getVisibleSize(); + auto origin = Director::getInstance()->getVisibleOrigin(); // Determinie offset of location to projectile float offX = flocationX - _owner->getPosition().x; float offY = flocationY - _owner->getPosition().y; @@ -142,8 +142,8 @@ void ProjectileController::move(float flocationX, float flocationY) void ProjectileController::die() { - Component *com = _owner->getParent()->getComponent("SceneController"); - cocos2d::Array *_projectiles = static_cast(com)->getProjectiles(); + auto com = _owner->getParent()->getComponent("SceneController"); + auto _projectiles = static_cast(com)->getProjectiles(); _projectiles->removeObject(_owner); _owner->removeFromParentAndCleanup(true); } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/SceneController.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/SceneController.cpp index db8333a784..c4d0bf7ef4 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/SceneController.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/SceneController.cpp @@ -96,7 +96,7 @@ void SceneController::spriteMoveFinished(Node* sender) if (sprite->getTag() == 2) // target { _targets->removeObject(sprite); - GameOverScene *gameOverScene = GameOverScene::create(); + auto gameOverScene = GameOverScene::create(); gameOverScene->getLayer()->getLabel()->setString("You Lose :["); Director::getInstance()->replaceScene(gameOverScene); } @@ -116,7 +116,7 @@ void SceneController::increaseKillCount() if (nProjectilesDestroyed >= 5) { - GameOverScene *gameOverScene = GameOverScene::create(); + auto gameOverScene = GameOverScene::create(); gameOverScene->getLayer()->getLabel()->setString("You Win!"); Director::getInstance()->replaceScene(gameOverScene); } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp index 82c1b93b22..a7fe134383 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp @@ -29,17 +29,17 @@ bool ControlButtonTest_HelloVariableSize::init() { if (ControlScene::init()) { - Size screenSize = Director::getInstance()->getWinSize(); + auto screenSize = Director::getInstance()->getWinSize(); // Defines an array of title to create buttons dynamically - Array *stringArray = Array::create( + auto stringArray = Array::create( ccs("Hello"), ccs("Variable"), ccs("Size"), ccs("!"), NULL); - Node *layer = Node::create(); + auto layer = Node::create(); addChild(layer, 1); double total_width = 0, height = 0; @@ -49,7 +49,7 @@ bool ControlButtonTest_HelloVariableSize::init() int i = 0; CCARRAY_FOREACH(stringArray, pObj) { - String* title = static_cast(pObj); + auto title = static_cast(pObj); // Creates a button with this string as title ControlButton *button = standardButtonWithTitle(title->getCString()); if (i == 0) @@ -82,7 +82,7 @@ bool ControlButtonTest_HelloVariableSize::init() layer->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 2.0f)); // Add the black background - Scale9Sprite *background = Scale9Sprite::create("extensions/buttonBackground.png"); + auto background = Scale9Sprite::create("extensions/buttonBackground.png"); background->setContentSize(Size(total_width + 14, height + 14)); background->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 2.0f)); addChild(background); @@ -94,10 +94,10 @@ bool ControlButtonTest_HelloVariableSize::init() ControlButton *ControlButtonTest_HelloVariableSize::standardButtonWithTitle(const char * title) { /** Creates and return a button with a default background and title color. */ - Scale9Sprite *backgroundButton = Scale9Sprite::create("extensions/button.png"); - Scale9Sprite *backgroundHighlightedButton = Scale9Sprite::create("extensions/buttonHighlighted.png"); + auto backgroundButton = Scale9Sprite::create("extensions/button.png"); + auto backgroundHighlightedButton = Scale9Sprite::create("extensions/buttonHighlighted.png"); - LabelTTF *titleButton = LabelTTF::create(title, "Marker Felt", 30); + auto titleButton = LabelTTF::create(title, "Marker Felt", 30); titleButton->setColor(Color3B(159, 168, 176)); @@ -123,7 +123,7 @@ bool ControlButtonTest_Event::init() { if (ControlScene::init()) { - Size screenSize = Director::getInstance()->getWinSize(); + auto screenSize = Director::getInstance()->getWinSize(); // Add a label in which the button events will be displayed setDisplayValueLabel(LabelTTF::create("No Event", "Marker Felt", 32)); @@ -132,10 +132,10 @@ bool ControlButtonTest_Event::init() addChild(_displayValueLabel, 1); // Add the button - Scale9Sprite *backgroundButton = Scale9Sprite::create("extensions/button.png"); - Scale9Sprite *backgroundHighlightedButton = Scale9Sprite::create("extensions/buttonHighlighted.png"); + auto backgroundButton = Scale9Sprite::create("extensions/button.png"); + auto backgroundHighlightedButton = Scale9Sprite::create("extensions/buttonHighlighted.png"); - LabelTTF *titleButton = LabelTTF::create("Touch Me!", "Marker Felt", 30); + auto titleButton = LabelTTF::create("Touch Me!", "Marker Felt", 30); titleButton->setColor(Color3B(159, 168, 176)); @@ -148,7 +148,7 @@ bool ControlButtonTest_Event::init() addChild(controlButton, 1); // Add the black background - Scale9Sprite *background = Scale9Sprite::create("extensions/buttonBackground.png"); + auto background = Scale9Sprite::create("extensions/buttonBackground.png"); background->setContentSize(Size(300, 170)); background->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 2.0f)); addChild(background); @@ -214,9 +214,9 @@ bool ControlButtonTest_Styling::init() { if (ControlScene::init()) { - Size screenSize = Director::getInstance()->getWinSize(); + auto screenSize = Director::getInstance()->getWinSize(); - Node *layer = Node::create(); + auto layer = Node::create(); addChild(layer, 1); int space = 10; // px @@ -244,7 +244,7 @@ bool ControlButtonTest_Styling::init() layer->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 2.0f)); // Add the black background - Scale9Sprite *backgroundButton = Scale9Sprite::create("extensions/buttonBackground.png"); + auto backgroundButton = Scale9Sprite::create("extensions/buttonBackground.png"); backgroundButton->setContentSize(Size(max_w + 14, max_h + 14)); backgroundButton->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 2.0f)); addChild(backgroundButton); @@ -259,12 +259,12 @@ bool ControlButtonTest_Styling::init() ControlButton *ControlButtonTest_Styling::standardButtonWithTitle(const char *title) { /** Creates and return a button with a default background and title color. */ - Scale9Sprite *backgroundButton = Scale9Sprite::create("extensions/button.png"); + auto backgroundButton = Scale9Sprite::create("extensions/button.png"); backgroundButton->setPreferredSize(Size(45, 45)); // Set the prefered size - Scale9Sprite *backgroundHighlightedButton = Scale9Sprite::create("extensions/buttonHighlighted.png"); + auto backgroundHighlightedButton = Scale9Sprite::create("extensions/buttonHighlighted.png"); backgroundHighlightedButton->setPreferredSize(Size(45, 45)); // Set the prefered size - LabelTTF *titleButton = LabelTTF::create(title, "Marker Felt", 30); + auto titleButton = LabelTTF::create(title, "Marker Felt", 30); titleButton->setColor(Color3B(159, 168, 176)); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp index 71980db644..c0614bcff2 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp @@ -36,9 +36,9 @@ bool ControlColourPickerTest::init() { if (ControlScene::init()) { - Size screenSize = Director::getInstance()->getWinSize(); + auto screenSize = Director::getInstance()->getWinSize(); - Node *layer = Node::create(); + auto layer = Node::create(); layer->setPosition(Point (screenSize.width / 2, screenSize.height / 2)); addChild(layer, 1); @@ -59,7 +59,7 @@ bool ControlColourPickerTest::init() layer_width += colourPicker->getContentSize().width; // Add the black background for the text - Scale9Sprite *background = Scale9Sprite::create("extensions/buttonBackground.png"); + auto background = Scale9Sprite::create("extensions/buttonBackground.png"); background->setContentSize(Size(150, 50)); background->setPosition(Point(layer_width + background->getContentSize().width / 2.0f, 0)); layer->addChild(background); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.cpp index 4ecd88e929..709dc6a81a 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.cpp @@ -39,16 +39,16 @@ bool ControlPotentiometerTest::init() { if (ControlScene::init()) { - Size screenSize = Director::getInstance()->getWinSize(); + auto screenSize = Director::getInstance()->getWinSize(); - Node *layer = Node::create(); + auto layer = Node::create(); layer->setPosition(Point(screenSize.width / 2, screenSize.height / 2)); this->addChild(layer, 1); double layer_width = 0; // Add the black background for the text - Scale9Sprite *background = Scale9Sprite::create("extensions/buttonBackground.png"); + auto background = Scale9Sprite::create("extensions/buttonBackground.png"); background->setContentSize(Size(80, 50)); background->setPosition(Point(layer_width + background->getContentSize().width / 2.0f, 0)); layer->addChild(background); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlScene.cpp index d69c754be6..bb7e82f159 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlScene.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlScene.cpp @@ -42,19 +42,19 @@ bool ControlScene::init() { if (Layer::init()) { - MenuItemFont* pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(ControlScene::toExtensionsMainLayer, this)); + auto pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(ControlScene::toExtensionsMainLayer, this)); pBackItem->setPosition(Point(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25)); - Menu* pBackMenu = Menu::create(pBackItem, NULL); + auto pBackMenu = Menu::create(pBackItem, NULL); pBackMenu->setPosition( Point::ZERO ); addChild(pBackMenu, 10); // Add the generated background - Sprite *background = Sprite::create("extensions/background.png"); + auto background = Sprite::create("extensions/background.png"); background->setPosition(VisibleRect::center()); addChild(background); // Add the ribbon - Scale9Sprite *ribbon = Scale9Sprite::create("extensions/ribbon.png", Rect(1, 1, 48, 55)); + auto ribbon = Scale9Sprite::create("extensions/ribbon.png", Rect(1, 1, 48, 55)); ribbon->setContentSize(Size(VisibleRect::getVisibleRect().size.width, 57)); ribbon->setPosition(Point(VisibleRect::center().x, VisibleRect::top().y - ribbon->getContentSize().height / 2.0f)); addChild(ribbon); @@ -65,11 +65,11 @@ bool ControlScene::init() addChild(_sceneTitleLabel, 1); // Add the menu - MenuItemImage *item1 = MenuItemImage::create("Images/b1.png", "Images/b2.png", CC_CALLBACK_1(ControlScene::previousCallback, this)); - MenuItemImage *item2 = MenuItemImage::create("Images/r1.png", "Images/r2.png", CC_CALLBACK_1(ControlScene::restartCallback, this)); - MenuItemImage *item3 = MenuItemImage::create("Images/f1.png", "Images/f2.png", CC_CALLBACK_1(ControlScene::nextCallback, this)); + auto item1 = MenuItemImage::create("Images/b1.png", "Images/b2.png", CC_CALLBACK_1(ControlScene::previousCallback, this)); + auto item2 = MenuItemImage::create("Images/r1.png", "Images/r2.png", CC_CALLBACK_1(ControlScene::restartCallback, this)); + auto item3 = MenuItemImage::create("Images/f1.png", "Images/f2.png", CC_CALLBACK_1(ControlScene::nextCallback, this)); - Menu *menu = Menu::create(item1, item3, item2, NULL); + auto menu = Menu::create(item1, item3, item2, NULL); menu->setPosition(Point::ZERO); item1->setPosition(Point(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2)); item2->setPosition(Point(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2)); @@ -84,7 +84,7 @@ bool ControlScene::init() void ControlScene::toExtensionsMainLayer(Object* sender) { - ExtensionsTestScene* scene = new ExtensionsTestScene(); + auto scene = new ExtensionsTestScene(); scene->runThisTest(); scene->release(); } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp index 8c1ea2c778..67312e3084 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp @@ -40,7 +40,7 @@ bool ControlSliderTest::init() { if (ControlScene::init()) { - Size screenSize = Director::getInstance()->getWinSize(); + auto screenSize = Director::getInstance()->getWinSize(); // Add a label in which the slider value will be displayed _displayValueLabel = LabelTTF::create("Move the slider thumb!\nThe lower slider is restricted." ,"Marker Felt", 32); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.cpp index 1ba0bb1552..d0f2e25662 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.cpp @@ -40,16 +40,16 @@ bool ControlStepperTest::init() { if (ControlScene::init()) { - Size screenSize = Director::getInstance()->getWinSize(); + auto screenSize = Director::getInstance()->getWinSize(); - Node *layer = Node::create(); + auto layer = Node::create(); layer->setPosition(Point (screenSize.width / 2, screenSize.height / 2)); this->addChild(layer, 1); double layer_width = 0; // Add the black background for the text - Scale9Sprite *background = Scale9Sprite::create("extensions/buttonBackground.png"); + auto background = Scale9Sprite::create("extensions/buttonBackground.png"); background->setContentSize(Size(100, 50)); background->setPosition(Point(layer_width + background->getContentSize().width / 2.0f, 0)); layer->addChild(background); @@ -81,8 +81,8 @@ bool ControlStepperTest::init() ControlStepper *ControlStepperTest::makeControlStepper() { - Sprite *minusSprite = Sprite::create("extensions/stepper-minus.png"); - Sprite *plusSprite = Sprite::create("extensions/stepper-plus.png"); + auto minusSprite = Sprite::create("extensions/stepper-minus.png"); + auto plusSprite = Sprite::create("extensions/stepper-plus.png"); return ControlStepper::create(minusSprite, plusSprite); } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp index 411fc38be3..8902e70aa0 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp @@ -35,16 +35,16 @@ bool ControlSwitchTest::init() { if (ControlScene::init()) { - Size screenSize = Director::getInstance()->getWinSize(); + auto screenSize = Director::getInstance()->getWinSize(); - Node *layer = Node::create(); + auto layer = Node::create(); layer->setPosition(Point(screenSize.width / 2, screenSize.height / 2)); addChild(layer, 1); double layer_width = 0; // Add the black background for the text - Scale9Sprite *background = Scale9Sprite::create("extensions/buttonBackground.png"); + auto background = Scale9Sprite::create("extensions/buttonBackground.png"); background->setContentSize(Size(80, 50)); background->setPosition(Point(layer_width + background->getContentSize().width / 2.0f, 0)); layer->addChild(background); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/EditBoxTest/EditBoxTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/EditBoxTest/EditBoxTest.cpp index bfc10dab2d..961f9f8e2d 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/EditBoxTest/EditBoxTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/EditBoxTest/EditBoxTest.cpp @@ -15,10 +15,10 @@ USING_NS_CC_EXT; EditBoxTest::EditBoxTest() { - Point visibleOrigin = EGLView::getInstance()->getVisibleOrigin(); - Size visibleSize = EGLView::getInstance()->getVisibleSize(); + auto visibleOrigin = EGLView::getInstance()->getVisibleOrigin(); + auto visibleSize = EGLView::getInstance()->getVisibleSize(); - Sprite* pBg = Sprite::create("Images/HelloWorld.png"); + auto pBg = Sprite::create("Images/HelloWorld.png"); pBg->setPosition(Point(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/2)); addChild(pBg); @@ -27,13 +27,13 @@ EditBoxTest::EditBoxTest() addChild(_TTFShowEditReturn); // Back Menu - MenuItemFont *itemBack = MenuItemFont::create("Back", CC_CALLBACK_1(EditBoxTest::toExtensionsMainLayer, this)); + auto itemBack = MenuItemFont::create("Back", CC_CALLBACK_1(EditBoxTest::toExtensionsMainLayer, this)); itemBack->setPosition(Point(visibleOrigin.x+visibleSize.width - 50, visibleOrigin.y+25)); - Menu *menuBack = Menu::create(itemBack, NULL); + auto menuBack = Menu::create(itemBack, NULL); menuBack->setPosition(Point::ZERO); addChild(menuBack); - Size editBoxSize = Size(visibleSize.width - 100, 60); + auto editBoxSize = Size(visibleSize.width - 100, 60); // top _editName = EditBox::create(editBoxSize, Scale9Sprite::create("extensions/green_edit.png")); @@ -87,7 +87,7 @@ EditBoxTest::~EditBoxTest() void EditBoxTest::toExtensionsMainLayer(cocos2d::Object *sender) { - ExtensionsTestScene *scene = new ExtensionsTestScene(); + auto scene = new ExtensionsTestScene(); scene->runThisTest(); scene->release(); } @@ -127,7 +127,7 @@ void EditBoxTest::editBoxReturn(EditBox* editBox) void runEditBoxTest() { - Scene *scene = Scene::create(); + auto scene = Scene::create(); EditBoxTest *layer = new EditBoxTest(); scene->addChild(layer); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ExtensionsTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ExtensionsTest.cpp index 514b672c27..8e5f514da6 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ExtensionsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ExtensionsTest.cpp @@ -34,7 +34,7 @@ static struct { { "NotificationCenterTest", [](Object* sender) { runNotificationCenterTest(); } }, { "Scale9SpriteTest", [](Object* sender) { - S9SpriteTestScene* scene = new S9SpriteTestScene(); + auto scene = new S9SpriteTestScene(); if (scene) { scene->runThisTest(); @@ -44,11 +44,11 @@ static struct { }, { "CCControlButtonTest", [](Object *sender){ ControlSceneManager* pManager = ControlSceneManager::sharedControlSceneManager(); - Scene* scene = pManager->currentControlScene(); + auto scene = pManager->currentControlScene(); Director::getInstance()->replaceScene(scene); }}, { "CocosBuilderTest", [](Object *sender) { - TestScene* scene = new CocosBuilderTestScene(); + auto scene = new CocosBuilderTestScene(); if (scene) { scene->runThisTest(); @@ -93,7 +93,7 @@ void ExtensionsMainLayer::onEnter() { Layer::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); _itemMenu = Menu::create(); _itemMenu->setPosition( Point::ZERO ); @@ -101,7 +101,7 @@ void ExtensionsMainLayer::onEnter() MenuItemFont::setFontSize(24); for (int i = 0; i < g_maxTests; ++i) { - MenuItemFont* pItem = MenuItemFont::create(g_extensionsTests[i].name, g_extensionsTests[i].callback); + auto pItem = MenuItemFont::create(g_extensionsTests[i].name, g_extensionsTests[i].callback); pItem->setPosition(Point(s.width / 2, s.height - (i + 1) * LINE_SPACE)); _itemMenu->addChild(pItem, kItemTagBasic + i); } @@ -113,20 +113,20 @@ void ExtensionsMainLayer::onEnter() void ExtensionsMainLayer::ccTouchesBegan(Set *touches, Event *event) { - Touch* touch = static_cast(touches->anyObject()); + auto touch = static_cast(touches->anyObject()); _beginPos = touch->getLocation(); } void ExtensionsMainLayer::ccTouchesMoved(Set *touches, Event *event) { - Touch* touch = static_cast(touches->anyObject()); + auto touch = static_cast(touches->anyObject()); - Point touchLocation = touch->getLocation(); + auto touchLocation = touch->getLocation(); float nMoveY = touchLocation.y - _beginPos.y; - Point curPos = _itemMenu->getPosition(); - Point nextPos = Point(curPos.x, curPos.y + nMoveY); + auto curPos = _itemMenu->getPosition(); + auto nextPos = Point(curPos.x, curPos.y + nMoveY); if (nextPos.y < 0.0f) { @@ -153,7 +153,7 @@ void ExtensionsMainLayer::ccTouchesMoved(Set *touches, Event *event) void ExtensionsTestScene::runThisTest() { - Layer* layer = new ExtensionsMainLayer(); + auto layer = new ExtensionsMainLayer(); addChild(layer); layer->release(); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp index 76c2df61ec..2242198904 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp @@ -8,46 +8,46 @@ USING_NS_CC_EXT; HttpClientTest::HttpClientTest() : _labelStatusCode(NULL) { - Size winSize = Director::getInstance()->getWinSize(); + auto winSize = Director::getInstance()->getWinSize(); const int MARGIN = 40; const int SPACE = 35; - LabelTTF *label = LabelTTF::create("Http Request Test", "Arial", 28); + auto label = LabelTTF::create("Http Request Test", "Arial", 28); label->setPosition(Point(winSize.width / 2, winSize.height - MARGIN)); addChild(label, 0); - Menu *menuRequest = Menu::create(); + auto menuRequest = Menu::create(); menuRequest->setPosition(Point::ZERO); addChild(menuRequest); // Get - LabelTTF *labelGet = LabelTTF::create("Test Get", "Arial", 22); - MenuItemLabel *itemGet = MenuItemLabel::create(labelGet, CC_CALLBACK_1(HttpClientTest::onMenuGetTestClicked, this)); + auto labelGet = LabelTTF::create("Test Get", "Arial", 22); + auto itemGet = MenuItemLabel::create(labelGet, CC_CALLBACK_1(HttpClientTest::onMenuGetTestClicked, this)); itemGet->setPosition(Point(winSize.width / 2, winSize.height - MARGIN - SPACE)); menuRequest->addChild(itemGet); // Post - LabelTTF *labelPost = LabelTTF::create("Test Post", "Arial", 22); - MenuItemLabel *itemPost = MenuItemLabel::create(labelPost, CC_CALLBACK_1(HttpClientTest::onMenuPostTestClicked, this)); + auto labelPost = LabelTTF::create("Test Post", "Arial", 22); + auto itemPost = MenuItemLabel::create(labelPost, CC_CALLBACK_1(HttpClientTest::onMenuPostTestClicked, this)); itemPost->setPosition(Point(winSize.width / 2, winSize.height - MARGIN - 2 * SPACE)); menuRequest->addChild(itemPost); // Post Binary - LabelTTF *labelPostBinary = LabelTTF::create("Test Post Binary", "Arial", 22); - MenuItemLabel *itemPostBinary = MenuItemLabel::create(labelPostBinary, CC_CALLBACK_1(HttpClientTest::onMenuPostBinaryTestClicked, this)); + auto labelPostBinary = LabelTTF::create("Test Post Binary", "Arial", 22); + auto itemPostBinary = MenuItemLabel::create(labelPostBinary, CC_CALLBACK_1(HttpClientTest::onMenuPostBinaryTestClicked, this)); itemPostBinary->setPosition(Point(winSize.width / 2, winSize.height - MARGIN - 3 * SPACE)); menuRequest->addChild(itemPostBinary); // Put - LabelTTF *labelPut = LabelTTF::create("Test Put", "Arial", 22); - MenuItemLabel *itemPut = MenuItemLabel::create(labelPut, CC_CALLBACK_1(HttpClientTest::onMenuPutTestClicked, this)); + auto labelPut = LabelTTF::create("Test Put", "Arial", 22); + auto itemPut = MenuItemLabel::create(labelPut, CC_CALLBACK_1(HttpClientTest::onMenuPutTestClicked, this)); itemPut->setPosition(Point(winSize.width / 2, winSize.height - MARGIN - 4 * SPACE)); menuRequest->addChild(itemPut); // Delete - LabelTTF *labelDelete = LabelTTF::create("Test Delete", "Arial", 22); - MenuItemLabel *itemDelete = MenuItemLabel::create(labelDelete, CC_CALLBACK_1(HttpClientTest::onMenuDeleteTestClicked, this)); + auto labelDelete = LabelTTF::create("Test Delete", "Arial", 22); + auto itemDelete = MenuItemLabel::create(labelDelete, CC_CALLBACK_1(HttpClientTest::onMenuDeleteTestClicked, this)); itemDelete->setPosition(Point(winSize.width / 2, winSize.height - MARGIN - 5 * SPACE)); menuRequest->addChild(itemDelete); @@ -57,9 +57,9 @@ HttpClientTest::HttpClientTest() addChild(_labelStatusCode); // Back Menu - MenuItemFont *itemBack = MenuItemFont::create("Back", CC_CALLBACK_1(HttpClientTest::toExtensionsMainLayer, this)); + auto itemBack = MenuItemFont::create("Back", CC_CALLBACK_1(HttpClientTest::toExtensionsMainLayer, this)); itemBack->setPosition(Point(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25)); - Menu *menuBack = Menu::create(itemBack, NULL); + auto menuBack = Menu::create(itemBack, NULL); menuBack->setPosition(Point::ZERO); addChild(menuBack); } @@ -283,14 +283,14 @@ void HttpClientTest::onHttpRequestCompleted(HttpClient *sender, HttpResponse *re void HttpClientTest::toExtensionsMainLayer(cocos2d::Object *sender) { - ExtensionsTestScene *scene = new ExtensionsTestScene(); + auto scene = new ExtensionsTestScene(); scene->runThisTest(); scene->release(); } void runHttpClientTest() { - Scene *scene = Scene::create(); + auto scene = Scene::create(); HttpClientTest *layer = new HttpClientTest(); scene->addChild(layer); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/SocketIOTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/SocketIOTest.cpp index 33f15ccd1e..0fea620718 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/SocketIOTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/SocketIOTest.cpp @@ -24,59 +24,59 @@ SocketIOTestLayer::SocketIOTestLayer(void) const int MARGIN = 40; const int SPACE = 35; - LabelTTF *label = LabelTTF::create("SocketIO Extension Test", "Arial", 28); + auto label = LabelTTF::create("SocketIO Extension Test", "Arial", 28); label->setPosition(Point(winSize.width / 2, winSize.height - MARGIN)); addChild(label, 0); - Menu *menuRequest = Menu::create(); + auto menuRequest = Menu::create(); menuRequest->setPosition(Point::ZERO); addChild(menuRequest); // Test to create basic client in the default namespace - LabelTTF *labelSIOClient = LabelTTF::create("Open SocketIO Client", "Arial", 22); - MenuItemLabel *itemSIOClient = MenuItemLabel::create(labelSIOClient, CC_CALLBACK_1(SocketIOTestLayer::onMenuSIOClientClicked, this)); + auto labelSIOClient = LabelTTF::create("Open SocketIO Client", "Arial", 22); + auto itemSIOClient = MenuItemLabel::create(labelSIOClient, CC_CALLBACK_1(SocketIOTestLayer::onMenuSIOClientClicked, this)); itemSIOClient->setPosition(Point(VisibleRect::left().x + labelSIOClient->getContentSize().width / 2 + 5, winSize.height - MARGIN - SPACE)); menuRequest->addChild(itemSIOClient); // Test to create a client at the endpoint '/testpoint' - LabelTTF *labelSIOEndpoint = LabelTTF::create("Open SocketIO Endpoint", "Arial", 22); - MenuItemLabel *itemSIOEndpoint = MenuItemLabel::create(labelSIOEndpoint, CC_CALLBACK_1(SocketIOTestLayer::onMenuSIOEndpointClicked, this)); + auto labelSIOEndpoint = LabelTTF::create("Open SocketIO Endpoint", "Arial", 22); + auto itemSIOEndpoint = MenuItemLabel::create(labelSIOEndpoint, CC_CALLBACK_1(SocketIOTestLayer::onMenuSIOEndpointClicked, this)); itemSIOEndpoint->setPosition(Point(VisibleRect::right().x - labelSIOEndpoint->getContentSize().width / 2 - 5, winSize.height - MARGIN - SPACE)); menuRequest->addChild(itemSIOEndpoint); // Test sending message to default namespace - LabelTTF *labelTestMessage = LabelTTF::create("Send Test Message", "Arial", 22); - MenuItemLabel *itemTestMessage = MenuItemLabel::create(labelTestMessage, CC_CALLBACK_1(SocketIOTestLayer::onMenuTestMessageClicked, this)); + auto labelTestMessage = LabelTTF::create("Send Test Message", "Arial", 22); + auto itemTestMessage = MenuItemLabel::create(labelTestMessage, CC_CALLBACK_1(SocketIOTestLayer::onMenuTestMessageClicked, this)); itemTestMessage->setPosition(Point(VisibleRect::left().x + labelTestMessage->getContentSize().width / 2 + 5, winSize.height - MARGIN - 2 * SPACE)); menuRequest->addChild(itemTestMessage); // Test sending message to the endpoint '/testpoint' - LabelTTF *labelTestMessageEndpoint = LabelTTF::create("Test Endpoint Message", "Arial", 22); - MenuItemLabel *itemTestMessageEndpoint = MenuItemLabel::create(labelTestMessageEndpoint, CC_CALLBACK_1(SocketIOTestLayer::onMenuTestMessageEndpointClicked, this)); + auto labelTestMessageEndpoint = LabelTTF::create("Test Endpoint Message", "Arial", 22); + auto itemTestMessageEndpoint = MenuItemLabel::create(labelTestMessageEndpoint, CC_CALLBACK_1(SocketIOTestLayer::onMenuTestMessageEndpointClicked, this)); itemTestMessageEndpoint->setPosition(Point(VisibleRect::right().x - labelTestMessageEndpoint->getContentSize().width / 2 - 5, winSize.height - MARGIN - 2 * SPACE)); menuRequest->addChild(itemTestMessageEndpoint); // Test sending event 'echotest' to default namespace - LabelTTF *labelTestEvent = LabelTTF::create("Send Test Event", "Arial", 22); - MenuItemLabel *itemTestEvent = MenuItemLabel::create(labelTestEvent, CC_CALLBACK_1(SocketIOTestLayer::onMenuTestEventClicked, this)); + auto labelTestEvent = LabelTTF::create("Send Test Event", "Arial", 22); + auto itemTestEvent = MenuItemLabel::create(labelTestEvent, CC_CALLBACK_1(SocketIOTestLayer::onMenuTestEventClicked, this)); itemTestEvent->setPosition(Point(VisibleRect::left().x + labelTestEvent->getContentSize().width / 2 + 5, winSize.height - MARGIN - 3 * SPACE)); menuRequest->addChild(itemTestEvent); // Test sending event 'echotest' to the endpoint '/testpoint' - LabelTTF *labelTestEventEndpoint = LabelTTF::create("Test Endpoint Event", "Arial", 22); - MenuItemLabel *itemTestEventEndpoint = MenuItemLabel::create(labelTestEventEndpoint, CC_CALLBACK_1(SocketIOTestLayer::onMenuTestEventEndpointClicked, this)); + auto labelTestEventEndpoint = LabelTTF::create("Test Endpoint Event", "Arial", 22); + auto itemTestEventEndpoint = MenuItemLabel::create(labelTestEventEndpoint, CC_CALLBACK_1(SocketIOTestLayer::onMenuTestEventEndpointClicked, this)); itemTestEventEndpoint->setPosition(Point(VisibleRect::right().x - labelTestEventEndpoint->getContentSize().width / 2 - 5, winSize.height - MARGIN - 3 * SPACE)); menuRequest->addChild(itemTestEventEndpoint); // Test disconnecting basic client - LabelTTF *labelTestClientDisconnect = LabelTTF::create("Disconnect Socket", "Arial", 22); - MenuItemLabel *itemClientDisconnect = MenuItemLabel::create(labelTestClientDisconnect, CC_CALLBACK_1(SocketIOTestLayer::onMenuTestClientDisconnectClicked, this)); + auto labelTestClientDisconnect = LabelTTF::create("Disconnect Socket", "Arial", 22); + auto itemClientDisconnect = MenuItemLabel::create(labelTestClientDisconnect, CC_CALLBACK_1(SocketIOTestLayer::onMenuTestClientDisconnectClicked, this)); itemClientDisconnect->setPosition(Point(VisibleRect::left().x + labelTestClientDisconnect->getContentSize().width / 2 + 5, winSize.height - MARGIN - 4 * SPACE)); menuRequest->addChild(itemClientDisconnect); // Test disconnecting the endpoint '/testpoint' - LabelTTF *labelTestEndpointDisconnect = LabelTTF::create("Disconnect Endpoint", "Arial", 22); - MenuItemLabel *itemTestEndpointDisconnect = MenuItemLabel::create(labelTestEndpointDisconnect, CC_CALLBACK_1(SocketIOTestLayer::onMenuTestEndpointDisconnectClicked, this)); + auto labelTestEndpointDisconnect = LabelTTF::create("Disconnect Endpoint", "Arial", 22); + auto itemTestEndpointDisconnect = MenuItemLabel::create(labelTestEndpointDisconnect, CC_CALLBACK_1(SocketIOTestLayer::onMenuTestEndpointDisconnectClicked, this)); itemTestEndpointDisconnect->setPosition(Point(VisibleRect::right().x - labelTestEndpointDisconnect->getContentSize().width / 2 - 5, winSize.height - MARGIN - 4 * SPACE)); menuRequest->addChild(itemTestEndpointDisconnect); @@ -87,9 +87,9 @@ SocketIOTestLayer::SocketIOTestLayer(void) this->addChild(_sioClientStatus); // Back Menu - MenuItemFont *itemBack = MenuItemFont::create("Back", CC_CALLBACK_1(SocketIOTestLayer::toExtensionsMainLayer, this)); + auto itemBack = MenuItemFont::create("Back", CC_CALLBACK_1(SocketIOTestLayer::toExtensionsMainLayer, this)); itemBack->setPosition(Point(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25)); - Menu *menuBack = Menu::create(itemBack, NULL); + auto menuBack = Menu::create(itemBack, NULL); menuBack->setPosition(Point::ZERO); addChild(menuBack); @@ -259,8 +259,8 @@ void SocketIOTestLayer::onError(cocos2d::extension::SIOClient* client, const std void runSocketIOTest() { - Scene *scene = Scene::create(); - SocketIOTestLayer *layer = new SocketIOTestLayer(); + auto scene = Scene::create(); + auto layer = new SocketIOTestLayer(); scene->addChild(layer); Director::getInstance()->replaceScene(scene); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/WebSocketTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/WebSocketTest.cpp index b56ec8852d..be60e5405d 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/WebSocketTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/WebSocketTest.cpp @@ -22,28 +22,28 @@ WebSocketTestLayer::WebSocketTestLayer() , _sendTextTimes(0) , _sendBinaryTimes(0) { - Size winSize = Director::getInstance()->getWinSize(); + auto winSize = Director::getInstance()->getWinSize(); const int MARGIN = 40; const int SPACE = 35; - LabelTTF *label = LabelTTF::create("WebSocket Test", "Arial", 28); + auto label = LabelTTF::create("WebSocket Test", "Arial", 28); label->setPosition(Point(winSize.width / 2, winSize.height - MARGIN)); addChild(label, 0); - Menu *menuRequest = Menu::create(); + auto menuRequest = Menu::create(); menuRequest->setPosition(Point::ZERO); addChild(menuRequest); // Send Text - LabelTTF *labelSendText = LabelTTF::create("Send Text", "Arial", 22); - MenuItemLabel *itemSendText = MenuItemLabel::create(labelSendText, CC_CALLBACK_1(WebSocketTestLayer::onMenuSendTextClicked, this)); + auto labelSendText = LabelTTF::create("Send Text", "Arial", 22); + auto itemSendText = MenuItemLabel::create(labelSendText, CC_CALLBACK_1(WebSocketTestLayer::onMenuSendTextClicked, this)); itemSendText->setPosition(Point(winSize.width / 2, winSize.height - MARGIN - SPACE)); menuRequest->addChild(itemSendText); // Send Binary - LabelTTF *labelSendBinary = LabelTTF::create("Send Binary", "Arial", 22); - MenuItemLabel *itemSendBinary = MenuItemLabel::create(labelSendBinary, CC_CALLBACK_1(WebSocketTestLayer::onMenuSendBinaryClicked, this)); + auto labelSendBinary = LabelTTF::create("Send Binary", "Arial", 22); + auto itemSendBinary = MenuItemLabel::create(labelSendBinary, CC_CALLBACK_1(WebSocketTestLayer::onMenuSendBinaryClicked, this)); itemSendBinary->setPosition(Point(winSize.width / 2, winSize.height - MARGIN - 2 * SPACE)); menuRequest->addChild(itemSendBinary); @@ -67,9 +67,9 @@ WebSocketTestLayer::WebSocketTestLayer() this->addChild(_errorStatus); // Back Menu - MenuItemFont *itemBack = MenuItemFont::create("Back", CC_CALLBACK_1(WebSocketTestLayer::toExtensionsMainLayer, this)); + auto itemBack = MenuItemFont::create("Back", CC_CALLBACK_1(WebSocketTestLayer::toExtensionsMainLayer, this)); itemBack->setPosition(Point(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25)); - Menu *menuBack = Menu::create(itemBack, NULL); + auto menuBack = Menu::create(itemBack, NULL); menuBack->setPosition(Point::ZERO); addChild(menuBack); @@ -193,7 +193,7 @@ void WebSocketTestLayer::onError(cocos2d::extension::WebSocket* ws, const cocos2 void WebSocketTestLayer::toExtensionsMainLayer(cocos2d::Object *sender) { - ExtensionsTestScene *scene = new ExtensionsTestScene(); + auto scene = new ExtensionsTestScene(); scene->runThisTest(); scene->release(); } @@ -232,8 +232,8 @@ void WebSocketTestLayer::onMenuSendBinaryClicked(cocos2d::Object *sender) void runWebSocketTest() { - Scene *scene = Scene::create(); - WebSocketTestLayer *layer = new WebSocketTestLayer(); + auto scene = Scene::create(); + auto layer = new WebSocketTestLayer(); scene->addChild(layer); Director::getInstance()->replaceScene(scene); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.cpp index fbeea9af12..784b548fa9 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.cpp @@ -80,26 +80,26 @@ void Light::updateLightState() NotificationCenterTest::NotificationCenterTest() : _showImage(false) { - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - MenuItemFont* pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(NotificationCenterTest::toExtensionsMainLayer, this)); + auto pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(NotificationCenterTest::toExtensionsMainLayer, this)); pBackItem->setPosition(Point(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25)); - Menu* pBackMenu = Menu::create(pBackItem, NULL); + auto pBackMenu = Menu::create(pBackItem, NULL); pBackMenu->setPosition( Point::ZERO ); addChild(pBackMenu); - LabelTTF *label1 = LabelTTF::create("switch off", "Marker Felt", 26); - LabelTTF *label2 = LabelTTF::create("switch on", "Marker Felt", 26); - MenuItemLabel *item1 = MenuItemLabel::create(label1); - MenuItemLabel *item2 = MenuItemLabel::create(label2); - MenuItemToggle *item = MenuItemToggle::createWithCallback( CC_CALLBACK_1(NotificationCenterTest::toggleSwitch, this), item1, item2, NULL); + auto label1 = LabelTTF::create("switch off", "Marker Felt", 26); + auto label2 = LabelTTF::create("switch on", "Marker Felt", 26); + auto item1 = MenuItemLabel::create(label1); + auto item2 = MenuItemLabel::create(label2); + auto item = MenuItemToggle::createWithCallback( CC_CALLBACK_1(NotificationCenterTest::toggleSwitch, this), item1, item2, NULL); // turn on item->setSelectedIndex(1); - Menu *menu = Menu::create(item, NULL); + auto menu = Menu::create(item, NULL); menu->setPosition(Point(s.width/2+100, s.height/2)); addChild(menu); - Menu *menuConnect = Menu::create(); + auto menuConnect = Menu::create(); menuConnect->setPosition(Point::ZERO); addChild(menuConnect); @@ -110,11 +110,11 @@ NotificationCenterTest::NotificationCenterTest() light->setPosition(Point(100, s.height/4*i)); addChild(light); - LabelTTF *label1 = LabelTTF::create("not connected", "Marker Felt", 26); - LabelTTF *label2 = LabelTTF::create("connected", "Marker Felt", 26); - MenuItemLabel *item1 = MenuItemLabel::create(label1); - MenuItemLabel *item2 = MenuItemLabel::create(label2); - MenuItemToggle *item = MenuItemToggle::createWithCallback( CC_CALLBACK_1(NotificationCenterTest::connectToSwitch, this), item1, item2, NULL); + auto label1 = LabelTTF::create("not connected", "Marker Felt", 26); + auto label2 = LabelTTF::create("connected", "Marker Felt", 26); + auto item1 = MenuItemLabel::create(label1); + auto item2 = MenuItemLabel::create(label2); + auto item = MenuItemToggle::createWithCallback( CC_CALLBACK_1(NotificationCenterTest::connectToSwitch, this), item1, item2, NULL); item->setTag(kTagConnect+i); item->setPosition(Point(light->getPosition().x, light->getPosition().y+50)); menuConnect->addChild(item, 0); @@ -140,21 +140,21 @@ void NotificationCenterTest::toExtensionsMainLayer(cocos2d::Object* sender) int CC_UNUSED numObserversRemoved = NotificationCenter::getInstance()->removeAllObservers(this); CCASSERT(numObserversRemoved >= 3, "All observers were not removed!"); - ExtensionsTestScene* scene = new ExtensionsTestScene(); + auto scene = new ExtensionsTestScene(); scene->runThisTest(); scene->release(); } void NotificationCenterTest::toggleSwitch(Object *sender) { - MenuItemToggle* item = (MenuItemToggle*)sender; + auto item = (MenuItemToggle*)sender; int index = item->getSelectedIndex(); NotificationCenter::getInstance()->postNotification(MSG_SWITCH_STATE, (Object*)(intptr_t)index); } void NotificationCenterTest::connectToSwitch(Object *sender) { - MenuItemToggle* item = (MenuItemToggle*)sender; + auto item = (MenuItemToggle*)sender; bool bConnected = item->getSelectedIndex() == 0 ? false : true; Light* pLight = (Light*)this->getChildByTag(item->getTag()-kTagConnect+kTagLight); pLight->setIsConnectToSwitch(bConnected); @@ -167,7 +167,7 @@ void NotificationCenterTest::doNothing(cocos2d::Object *sender) void runNotificationCenterTest() { - Scene* scene = Scene::create(); + auto scene = Scene::create(); NotificationCenterTest* layer = new NotificationCenterTest(); scene->addChild(layer); Director::getInstance()->replaceScene(scene); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp index d01a167d96..c5674a1443 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp @@ -57,7 +57,7 @@ static Layer* nextAction() sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - Layer* layer = (createFunctions[sceneIdx])(); + auto layer = (createFunctions[sceneIdx])(); layer->init(); layer->autorelease(); @@ -71,7 +71,7 @@ static Layer* backAction() if( sceneIdx < 0 ) sceneIdx += total; - Layer* layer = (createFunctions[sceneIdx])(); + auto layer = (createFunctions[sceneIdx])(); layer->init(); layer->autorelease(); @@ -80,7 +80,7 @@ static Layer* backAction() static Layer* restartAction() { - Layer* layer = (createFunctions[sceneIdx])(); + auto layer = (createFunctions[sceneIdx])(); layer->init(); layer->autorelease(); @@ -110,7 +110,7 @@ void S9SpriteTestDemo::onEnter() void S9SpriteTestDemo::restartCallback(Object* sender) { - Scene* s = new S9SpriteTestScene(); + auto s = new S9SpriteTestScene(); s->addChild( restartAction() ); Director::getInstance()->replaceScene(s); s->release(); @@ -118,7 +118,7 @@ void S9SpriteTestDemo::restartCallback(Object* sender) void S9SpriteTestDemo::nextCallback(Object* sender) { - Scene* s = new S9SpriteTestScene(); + auto s = new S9SpriteTestScene(); s->addChild( nextAction() ); Director::getInstance()->replaceScene(s); s->release(); @@ -126,7 +126,7 @@ void S9SpriteTestDemo::nextCallback(Object* sender) void S9SpriteTestDemo::backCallback(Object* sender) { - Scene* s = new S9SpriteTestScene(); + auto s = new S9SpriteTestScene(); s->addChild( backAction() ); Director::getInstance()->replaceScene(s); s->release(); @@ -138,7 +138,7 @@ void S9SpriteTestDemo::backCallback(Object* sender) void S9BatchNodeBasic::onEnter() { S9SpriteTestDemo::onEnter(); - Size winSize = Director::getInstance()->getWinSize(); + auto winSize = Director::getInstance()->getWinSize(); float x = winSize.width / 2; float y = 0 + (winSize.height / 2); @@ -178,7 +178,7 @@ std::string S9BatchNodeBasic::subtitle() void S9FrameNameSpriteSheet::onEnter() { S9SpriteTestDemo::onEnter(); - Size winSize = Director::getInstance()->getWinSize(); + auto winSize = Director::getInstance()->getWinSize(); float x = winSize.width / 2; float y = 0 + (winSize.height / 2); @@ -212,7 +212,7 @@ std::string S9FrameNameSpriteSheet::subtitle() void S9FrameNameSpriteSheetRotated::onEnter() { S9SpriteTestDemo::onEnter(); - Size winSize = Director::getInstance()->getWinSize(); + auto winSize = Director::getInstance()->getWinSize(); float x = winSize.width / 2; float y = 0 + (winSize.height / 2); @@ -247,7 +247,7 @@ std::string S9FrameNameSpriteSheetRotated::subtitle() void S9BatchNodeScaledNoInsets::onEnter() { S9SpriteTestDemo::onEnter(); - Size winSize = Director::getInstance()->getWinSize(); + auto winSize = Director::getInstance()->getWinSize(); float x = winSize.width / 2; float y = 0 + (winSize.height / 2); @@ -291,7 +291,7 @@ std::string S9BatchNodeScaledNoInsets::subtitle() void S9FrameNameSpriteSheetScaledNoInsets::onEnter() { S9SpriteTestDemo::onEnter(); - Size winSize = Director::getInstance()->getWinSize(); + auto winSize = Director::getInstance()->getWinSize(); float x = winSize.width / 2; float y = 0 + (winSize.height / 2); @@ -330,7 +330,7 @@ std::string S9FrameNameSpriteSheetScaledNoInsets::subtitle() void S9FrameNameSpriteSheetRotatedScaledNoInsets::onEnter() { S9SpriteTestDemo::onEnter(); - Size winSize = Director::getInstance()->getWinSize(); + auto winSize = Director::getInstance()->getWinSize(); float x = winSize.width / 2; float y = 0 + (winSize.height / 2); @@ -369,7 +369,7 @@ std::string S9FrameNameSpriteSheetRotatedScaledNoInsets::subtitle() void S9BatchNodeScaleWithCapInsets::onEnter() { S9SpriteTestDemo::onEnter(); - Size winSize = Director::getInstance()->getWinSize(); + auto winSize = Director::getInstance()->getWinSize(); float x = winSize.width / 2; float y = 0 + (winSize.height / 2); @@ -413,7 +413,7 @@ std::string S9BatchNodeScaleWithCapInsets::subtitle() void S9FrameNameSpriteSheetInsets::onEnter() { S9SpriteTestDemo::onEnter(); - Size winSize = Director::getInstance()->getWinSize(); + auto winSize = Director::getInstance()->getWinSize(); float x = winSize.width / 2; float y = 0 + (winSize.height / 2); @@ -447,7 +447,7 @@ std::string S9FrameNameSpriteSheetInsets::subtitle() void S9FrameNameSpriteSheetInsetsScaled::onEnter() { S9SpriteTestDemo::onEnter(); - Size winSize = Director::getInstance()->getWinSize(); + auto winSize = Director::getInstance()->getWinSize(); float x = winSize.width / 2; float y = 0 + (winSize.height / 2); @@ -484,7 +484,7 @@ std::string S9FrameNameSpriteSheetInsetsScaled::subtitle() void S9FrameNameSpriteSheetRotatedInsets::onEnter() { S9SpriteTestDemo::onEnter(); - Size winSize = Director::getInstance()->getWinSize(); + auto winSize = Director::getInstance()->getWinSize(); float x = winSize.width / 2; float y = 0 + (winSize.height / 2); @@ -519,7 +519,7 @@ std::string S9FrameNameSpriteSheetRotatedInsets::subtitle() void S9_TexturePacker::onEnter() { S9SpriteTestDemo::onEnter(); - Size winSize = Director::getInstance()->getWinSize(); + auto winSize = Director::getInstance()->getWinSize(); SpriteFrameCache::getInstance()->addSpriteFramesWithFile(s_s9s_ui_plist); float x = winSize.width / 4; @@ -573,7 +573,7 @@ std::string S9_TexturePacker::subtitle() void S9FrameNameSpriteSheetRotatedInsetsScaled::onEnter() { S9SpriteTestDemo::onEnter(); - Size winSize = Director::getInstance()->getWinSize(); + auto winSize = Director::getInstance()->getWinSize(); float x = winSize.width / 2; float y = 0 + (winSize.height / 2); @@ -611,7 +611,7 @@ std::string S9FrameNameSpriteSheetRotatedInsetsScaled::subtitle() void S9FrameNameSpriteSheetRotatedSetCapInsetLater::onEnter() { S9SpriteTestDemo::onEnter(); - Size winSize = Director::getInstance()->getWinSize(); + auto winSize = Director::getInstance()->getWinSize(); float x = winSize.width / 2; float y = 0 + (winSize.height / 2); @@ -650,10 +650,10 @@ std::string S9FrameNameSpriteSheetRotatedSetCapInsetLater::subtitle() void S9CascadeOpacityAndColor::onEnter() { S9SpriteTestDemo::onEnter(); - Size winSize = Director::getInstance()->getWinSize(); + auto winSize = Director::getInstance()->getWinSize(); float x = winSize.width / 2; float y = 0 + (winSize.height / 2); - LayerRGBA* rgba = LayerRGBA::create(); + auto rgba = LayerRGBA::create(); rgba->setCascadeColorEnabled(true); rgba->setCascadeOpacityEnabled(true); this->addChild(rgba); @@ -667,12 +667,12 @@ void S9CascadeOpacityAndColor::onEnter() log("... setPosition"); rgba->addChild(blocks_scaled_with_insets); - Sequence* actions = Sequence::create(FadeIn::create(1), + auto actions = Sequence::create(FadeIn::create(1), TintTo::create(1, 0, 255, 0), TintTo::create(1, 255, 255, 255), FadeOut::create(1), NULL); - RepeatForever* repeat = RepeatForever::create(actions); + auto repeat = RepeatForever::create(actions); rgba->runAction(repeat); log("this->addChild"); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.cpp index c12f388ce3..caad90a6fa 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.cpp @@ -6,8 +6,8 @@ void CustomTableViewCell::draw() { TableViewCell::draw(); // draw bounding box -// Point pos = getPosition(); -// Size size = Size(178, 200); +// auto pos = getPosition(); +// auto size = Size(178, 200); // Point vertices[4]={ // Point(pos.x+1, pos.y+1), // Point(pos.x+size.width-1, pos.y+1), diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/TableViewTest/TableViewTestScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/TableViewTest/TableViewTestScene.cpp index d6fc59f514..1019db8763 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/TableViewTest/TableViewTestScene.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/TableViewTest/TableViewTestScene.cpp @@ -70,17 +70,17 @@ Size TableViewTestLayer::tableCellSizeForIndex(TableView *table, unsigned int id TableViewCell* TableViewTestLayer::tableCellAtIndex(TableView *table, unsigned int idx) { - String *string = String::createWithFormat("%d", idx); + auto string = String::createWithFormat("%d", idx); TableViewCell *cell = table->dequeueCell(); if (!cell) { cell = new CustomTableViewCell(); cell->autorelease(); - Sprite *sprite = Sprite::create("Images/Icon.png"); + auto sprite = Sprite::create("Images/Icon.png"); sprite->setAnchorPoint(Point::ZERO); sprite->setPosition(Point(0, 0)); cell->addChild(sprite); - LabelTTF *label = LabelTTF::create(string->getCString(), "Helvetica", 20.0); + auto label = LabelTTF::create(string->getCString(), "Helvetica", 20.0); label->setPosition(Point::ZERO); label->setAnchorPoint(Point::ZERO); label->setTag(123); @@ -88,7 +88,7 @@ TableViewCell* TableViewTestLayer::tableCellAtIndex(TableView *table, unsigned i } else { - LabelTTF *label = (LabelTTF*)cell->getChildByTag(123); + auto label = (LabelTTF*)cell->getChildByTag(123); label->setString(string->getCString()); } diff --git a/samples/Cpp/TestCpp/Classes/FileUtilsTest/FileUtilsTest.cpp b/samples/Cpp/TestCpp/Classes/FileUtilsTest/FileUtilsTest.cpp index b05cae1fa0..4211828903 100644 --- a/samples/Cpp/TestCpp/Classes/FileUtilsTest/FileUtilsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/FileUtilsTest/FileUtilsTest.cpp @@ -23,7 +23,7 @@ static Layer* nextAction() sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - Layer* layer = (createFunctions[sceneIdx])(); + auto layer = (createFunctions[sceneIdx])(); layer->init(); layer->autorelease(); @@ -37,7 +37,7 @@ static Layer* backAction() if( sceneIdx < 0 ) sceneIdx += total; - Layer* layer = (createFunctions[sceneIdx])(); + auto layer = (createFunctions[sceneIdx])(); layer->init(); layer->autorelease(); @@ -46,7 +46,7 @@ static Layer* backAction() static Layer* restartAction() { - Layer* layer = (createFunctions[sceneIdx])(); + auto layer = (createFunctions[sceneIdx])(); layer->init(); layer->autorelease(); @@ -55,7 +55,7 @@ static Layer* restartAction() void FileUtilsTestScene::runThisTest() { - Layer* layer = nextAction(); + auto layer = nextAction(); addChild(layer); Director::getInstance()->replaceScene(this); @@ -70,8 +70,8 @@ void FileUtilsDemo::onEnter() void FileUtilsDemo::backCallback(Object* sender) { - Scene* scene = new FileUtilsTestScene(); - Layer* layer = backAction(); + auto scene = new FileUtilsTestScene(); + auto layer = backAction(); scene->addChild(layer); Director::getInstance()->replaceScene(scene); @@ -80,8 +80,8 @@ void FileUtilsDemo::backCallback(Object* sender) void FileUtilsDemo::nextCallback(Object* sender) { - Scene* scene = new FileUtilsTestScene(); - Layer* layer = nextAction(); + auto scene = new FileUtilsTestScene(); + auto layer = nextAction(); scene->addChild(layer); Director::getInstance()->replaceScene(scene); @@ -90,8 +90,8 @@ void FileUtilsDemo::nextCallback(Object* sender) void FileUtilsDemo::restartCallback(Object* sender) { - Scene* scene = new FileUtilsTestScene(); - Layer* layer = restartAction(); + auto scene = new FileUtilsTestScene(); + auto layer = restartAction(); scene->addChild(layer); Director::getInstance()->replaceScene(scene); @@ -113,7 +113,7 @@ string FileUtilsDemo::subtitle() void TestResolutionDirectories::onEnter() { FileUtilsDemo::onEnter(); - FileUtils *sharedFileUtils = FileUtils::getInstance(); + auto sharedFileUtils = FileUtils::getInstance(); string ret; @@ -136,7 +136,7 @@ void TestResolutionDirectories::onEnter() sharedFileUtils->setSearchResolutionsOrder(resolutionsOrder); for( int i=1; i<7; i++) { - String *filename = String::createWithFormat("test%d.txt", i); + auto filename = String::createWithFormat("test%d.txt", i); ret = sharedFileUtils->fullPathForFilename(filename->getCString()); log("%s -> %s", filename->getCString(), ret.c_str()); } @@ -144,7 +144,7 @@ void TestResolutionDirectories::onEnter() void TestResolutionDirectories::onExit() { - FileUtils *sharedFileUtils = FileUtils::getInstance(); + auto sharedFileUtils = FileUtils::getInstance(); // reset search path sharedFileUtils->setSearchPaths(_defaultSearchPathArray); @@ -167,7 +167,7 @@ string TestResolutionDirectories::subtitle() void TestSearchPath::onEnter() { FileUtilsDemo::onEnter(); - FileUtils *sharedFileUtils = FileUtils::getInstance(); + auto sharedFileUtils = FileUtils::getInstance(); string ret; @@ -199,7 +199,7 @@ void TestSearchPath::onEnter() sharedFileUtils->setSearchResolutionsOrder(resolutionsOrder); for( int i=1; i<3; i++) { - String *filename = String::createWithFormat("file%d.txt", i); + auto filename = String::createWithFormat("file%d.txt", i); ret = sharedFileUtils->fullPathForFilename(filename->getCString()); log("%s -> %s", filename->getCString(), ret.c_str()); } @@ -247,9 +247,9 @@ void TestFilenameLookup::onEnter() { FileUtilsDemo::onEnter(); - FileUtils *sharedFileUtils = FileUtils::getInstance(); + auto sharedFileUtils = FileUtils::getInstance(); - Dictionary *dict = Dictionary::create(); + auto dict = Dictionary::create(); dict->setObject(String::create("Images/grossini.png"), "grossini.bmp"); dict->setObject(String::create("Images/grossini.png"), "grossini.xcf"); @@ -257,10 +257,10 @@ void TestFilenameLookup::onEnter() // Instead of loading carlitos.xcf, it will load grossini.png - Sprite *sprite = Sprite::create("grossini.xcf"); + auto sprite = Sprite::create("grossini.xcf"); this->addChild(sprite); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); sprite->setPosition(Point(s.width/2, s.height/2)); } @@ -290,8 +290,8 @@ string TestFilenameLookup::subtitle() void TestIsFileExist::onEnter() { FileUtilsDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); - FileUtils *sharedFileUtils = FileUtils::getInstance(); + auto s = Director::getInstance()->getWinSize(); + auto sharedFileUtils = FileUtils::getInstance(); LabelTTF* pTTF = NULL; bool isExist = false; @@ -334,27 +334,27 @@ string TestIsFileExist::subtitle() void TextWritePlist::onEnter() { FileUtilsDemo::onEnter(); - Dictionary *root = Dictionary::create(); - String *string = String::create("string element value"); + auto root = Dictionary::create(); + auto string = String::create("string element value"); root->setObject(string, "string element key"); - Array *array = Array::create(); + auto array = Array::create(); - Dictionary *dictInArray = Dictionary::create(); + auto dictInArray = Dictionary::create(); dictInArray->setObject(String::create("string in dictInArray value 0"), "string in dictInArray key 0"); dictInArray->setObject(String::create("string in dictInArray value 1"), "string in dictInArray key 1"); array->addObject(dictInArray); array->addObject(String::create("string in array")); - Array *arrayInArray = Array::create(); + auto arrayInArray = Array::create(); arrayInArray->addObject(String::create("string 0 in arrayInArray")); arrayInArray->addObject(String::create("string 1 in arrayInArray")); array->addObject(arrayInArray); root->setObject(array, "array"); - Dictionary *dictInDict = Dictionary::create(); + auto dictInDict = Dictionary::create(); dictInDict->setObject(String::create("string in dictInDict value"), "string in dictInDict key"); root->setObject(dictInDict, "dictInDict"); @@ -367,9 +367,9 @@ void TextWritePlist::onEnter() else log("write plist file failed"); - LabelTTF *label = LabelTTF::create(fullPath.c_str(), "Thonburi", 6); + auto label = LabelTTF::create(fullPath.c_str(), "Thonburi", 6); this->addChild(label); - Size winSize = Director::getInstance()->getWinSize(); + auto winSize = Director::getInstance()->getWinSize(); label->setPosition(Point(winSize.width/2, winSize.height/3)); } diff --git a/samples/Cpp/TestCpp/Classes/FontTest/FontTest.cpp b/samples/Cpp/TestCpp/Classes/FontTest/FontTest.cpp index 3976c7259d..8359a33418 100644 --- a/samples/Cpp/TestCpp/Classes/FontTest/FontTest.cpp +++ b/samples/Cpp/TestCpp/Classes/FontTest/FontTest.cpp @@ -84,9 +84,9 @@ FontTest::FontTest() void FontTest::showFont(const char *pFont) { - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Size blockSize = Size(s.width/3, 200); + auto blockSize = Size(s.width/3, 200); float fontSize = 26; removeChildByTag(kTagLabel1, true); @@ -97,17 +97,17 @@ void FontTest::showFont(const char *pFont) removeChildByTag(kTagColor2, true); removeChildByTag(kTagColor3, true); - LabelTTF *top = LabelTTF::create(pFont, pFont, 24); - LabelTTF *left = LabelTTF::create("alignment left", pFont, fontSize, + auto top = LabelTTF::create(pFont, pFont, 24); + auto left = LabelTTF::create("alignment left", pFont, fontSize, blockSize, TextHAlignment::LEFT, verticalAlignment[vAlignIdx]); - LabelTTF *center = LabelTTF::create("alignment center", pFont, fontSize, + auto center = LabelTTF::create("alignment center", pFont, fontSize, blockSize, TextHAlignment::CENTER, verticalAlignment[vAlignIdx]); - LabelTTF *right = LabelTTF::create("alignment right", pFont, fontSize, + auto right = LabelTTF::create("alignment right", pFont, fontSize, blockSize, TextHAlignment::RIGHT, verticalAlignment[vAlignIdx]); - LayerColor *leftColor = LayerColor::create(Color4B(100, 100, 100, 255), blockSize.width, blockSize.height); - LayerColor *centerColor = LayerColor::create(Color4B(200, 100, 100, 255), blockSize.width, blockSize.height); - LayerColor *rightColor = LayerColor::create(Color4B(100, 100, 200, 255), blockSize.width, blockSize.height); + auto leftColor = LayerColor::create(Color4B(100, 100, 100, 255), blockSize.width, blockSize.height); + auto centerColor = LayerColor::create(Color4B(200, 100, 100, 255), blockSize.width, blockSize.height); + auto rightColor = LayerColor::create(Color4B(100, 100, 200, 255), blockSize.width, blockSize.height); leftColor->ignoreAnchorPointForPosition(false); centerColor->ignoreAnchorPointForPosition(false); @@ -166,7 +166,7 @@ void FontTest::restartCallback(Object* sender) ///--------------------------------------- void FontTestScene::runThisTest() { - Layer* layer = FontTest::create(); + auto layer = FontTest::create(); addChild(layer); Director::getInstance()->replaceScene(this); diff --git a/samples/Cpp/TestCpp/Classes/IntervalTest/IntervalTest.cpp b/samples/Cpp/TestCpp/Classes/IntervalTest/IntervalTest.cpp index ed1955ad3f..da9fefdca9 100644 --- a/samples/Cpp/TestCpp/Classes/IntervalTest/IntervalTest.cpp +++ b/samples/Cpp/TestCpp/Classes/IntervalTest/IntervalTest.cpp @@ -13,9 +13,9 @@ IntervalLayer::IntervalLayer() { _time0 = _time1 = _time2 = _time3 = _time4 = 0.0f; - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); // sun - ParticleSystem* sun = ParticleSun::create(); + auto sun = ParticleSun::create(); sun->setTexture(TextureCache::getInstance()->addImage("Images/fire.png")); sun->setPosition( Point(VisibleRect::rightTop().x-32,VisibleRect::rightTop().y-32) ); @@ -49,21 +49,21 @@ IntervalLayer::IntervalLayer() addChild(_label4); // Sprite - Sprite* sprite = Sprite::create(s_pathGrossini); + auto sprite = Sprite::create(s_pathGrossini); sprite->setPosition( Point(VisibleRect::left().x + 40, VisibleRect::bottom().y + 50) ); - JumpBy* jump = JumpBy::create(3, Point(s.width-80,0), 50, 4); + auto jump = JumpBy::create(3, Point(s.width-80,0), 50, 4); addChild(sprite); sprite->runAction( RepeatForever::create(Sequence::create(jump, jump->reverse(), NULL) )); // pause button - MenuItem* item1 = MenuItemFont::create("Pause", [&](Object* sender) { + auto item1 = MenuItemFont::create("Pause", [&](Object* sender) { if(Director::getInstance()->isPaused()) Director::getInstance()->resume(); else Director::getInstance()->pause(); }); - Menu* menu = Menu::create(item1, NULL); + auto menu = Menu::create(item1, NULL); menu->setPosition( Point(s.width/2, s.height-50) ); addChild( menu ); @@ -123,7 +123,7 @@ void IntervalLayer::step4(float dt) void IntervalTestScene::runThisTest() { - Layer* layer = new IntervalLayer(); + auto layer = new IntervalLayer(); addChild(layer); layer->release(); diff --git a/samples/Cpp/TestCpp/Classes/KeyboardTest/KeyboardTest.cpp b/samples/Cpp/TestCpp/Classes/KeyboardTest/KeyboardTest.cpp index eeb5b3b3e1..6672e7d455 100644 --- a/samples/Cpp/TestCpp/Classes/KeyboardTest/KeyboardTest.cpp +++ b/samples/Cpp/TestCpp/Classes/KeyboardTest/KeyboardTest.cpp @@ -4,8 +4,8 @@ KeyboardTest::KeyboardTest() { - Size s = Director::getInstance()->getWinSize(); - LabelTTF* label = LabelTTF::create("Keyboard Test", "Arial", 28); + auto s = Director::getInstance()->getWinSize(); + auto label = LabelTTF::create("Keyboard Test", "Arial", 28); addChild(label, 0); label->setPosition( Point(s.width/2, s.height-50) ); @@ -36,7 +36,7 @@ void KeyboardTest::keyReleased(int keyCode) void KeyboardTestScene::runThisTest() { - Layer* layer = new KeyboardTest(); + auto layer = new KeyboardTest(); addChild(layer); Director::getInstance()->replaceScene(this); diff --git a/samples/Cpp/TestCpp/Classes/KeypadTest/KeypadTest.cpp b/samples/Cpp/TestCpp/Classes/KeypadTest/KeypadTest.cpp index 7076e59e9d..9837569522 100644 --- a/samples/Cpp/TestCpp/Classes/KeypadTest/KeypadTest.cpp +++ b/samples/Cpp/TestCpp/Classes/KeypadTest/KeypadTest.cpp @@ -2,8 +2,8 @@ KeypadTest::KeypadTest() { - Size s = Director::getInstance()->getWinSize(); - LabelTTF* label = LabelTTF::create("Keypad Test", "Arial", 28); + auto s = Director::getInstance()->getWinSize(); + auto label = LabelTTF::create("Keypad Test", "Arial", 28); addChild(label, 0); label->setPosition( Point(s.width/2, s.height-50) ); @@ -34,7 +34,7 @@ void KeypadTest::keyMenuClicked() void KeypadTestScene::runThisTest() { - Layer* layer = new KeypadTest(); + auto layer = new KeypadTest(); addChild(layer); Director::getInstance()->replaceScene(this); diff --git a/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.cpp b/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.cpp index 0e0599b0fa..ba22f3ced0 100644 --- a/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.cpp +++ b/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.cpp @@ -80,7 +80,7 @@ Layer* nextAtlasAction() sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - Layer* layer = (createFunctions[sceneIdx])(); + auto layer = (createFunctions[sceneIdx])(); layer->autorelease(); return layer; @@ -93,7 +93,7 @@ Layer* backAtlasAction() if( sceneIdx < 0 ) sceneIdx += total; - Layer* layer = (createFunctions[sceneIdx])(); + auto layer = (createFunctions[sceneIdx])(); layer->autorelease(); return layer; @@ -101,7 +101,7 @@ Layer* backAtlasAction() Layer* restartAtlasAction() { - Layer* layer = (createFunctions[sceneIdx])(); + auto layer = (createFunctions[sceneIdx])(); layer->autorelease(); return layer; @@ -133,7 +133,7 @@ void AtlasDemo::onEnter() void AtlasDemo::restartCallback(Object* sender) { - Scene* s = new AtlasTestScene(); + auto s = new AtlasTestScene(); s->addChild(restartAtlasAction()); Director::getInstance()->replaceScene(s); @@ -142,7 +142,7 @@ void AtlasDemo::restartCallback(Object* sender) void AtlasDemo::nextCallback(Object* sender) { - Scene* s = new AtlasTestScene(); + auto s = new AtlasTestScene(); s->addChild( nextAtlasAction() ); Director::getInstance()->replaceScene(s); s->release(); @@ -150,7 +150,7 @@ void AtlasDemo::nextCallback(Object* sender) void AtlasDemo::backCallback(Object* sender) { - Scene* s = new AtlasTestScene(); + auto s = new AtlasTestScene(); s->addChild( backAtlasAction() ); Director::getInstance()->replaceScene(s); s->release(); @@ -166,7 +166,7 @@ Atlas1::Atlas1() { _textureAtlas = TextureAtlas::create(s_AtlasTest, 3); _textureAtlas->retain(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); // // Notice: u,v tex coordinates are inverted @@ -238,12 +238,12 @@ LabelAtlasTest::LabelAtlasTest() { _time = 0; - LabelAtlas* label1 = LabelAtlas::create("123 Test", "fonts/tuffy_bold_italic-charmap.plist"); + auto label1 = LabelAtlas::create("123 Test", "fonts/tuffy_bold_italic-charmap.plist"); addChild(label1, 0, kTagSprite1); label1->setPosition( Point(10,100) ); label1->setOpacity( 200 ); - LabelAtlas *label2 = LabelAtlas::create("0123456789", "fonts/tuffy_bold_italic-charmap.plist"); + auto label2 = LabelAtlas::create("0123456789", "fonts/tuffy_bold_italic-charmap.plist"); addChild(label2, 0, kTagSprite2); label2->setPosition( Point(10,200) ); label2->setOpacity( 32 ); @@ -259,10 +259,10 @@ void LabelAtlasTest::step(float dt) sprintf(string, "%2.2f Test", _time); //string.format("%2.2f Test", _time); - LabelAtlas* label1 = (LabelAtlas*)getChildByTag(kTagSprite1); + auto label1 = (LabelAtlas*)getChildByTag(kTagSprite1); label1->setString(string); - LabelAtlas*label2 = (LabelAtlas*)getChildByTag(kTagSprite2); + auto label2 = (LabelAtlas*)getChildByTag(kTagSprite2); sprintf(string, "%d", (int)_time); //string.format("%d", (int)_time); label2->setString(string); @@ -285,21 +285,21 @@ std::string LabelAtlasTest::subtitle() //------------------------------------------------------------------ LabelAtlasColorTest::LabelAtlasColorTest() { - LabelAtlas* label1 = LabelAtlas::create("123 Test", "fonts/tuffy_bold_italic-charmap.png", 48, 64, ' '); + auto label1 = LabelAtlas::create("123 Test", "fonts/tuffy_bold_italic-charmap.png", 48, 64, ' '); addChild(label1, 0, kTagSprite1); label1->setPosition( Point(10,100) ); label1->setOpacity( 200 ); - LabelAtlas* label2 = LabelAtlas::create("0123456789", "fonts/tuffy_bold_italic-charmap.png", 48, 64, ' '); + auto label2 = LabelAtlas::create("0123456789", "fonts/tuffy_bold_italic-charmap.png", 48, 64, ' '); addChild(label2, 0, kTagSprite2); label2->setPosition( Point(10,200) ); label2->setColor( Color3B::RED ); - ActionInterval* fade = FadeOut::create(1.0f); - ActionInterval* fade_in = fade->reverse(); - CallFunc* cb = CallFunc::create(CC_CALLBACK_0(LabelAtlasColorTest::actionFinishCallback, this)); - Sequence* seq = Sequence::create(fade, fade_in, cb, NULL); - Action* repeat = RepeatForever::create( seq ); + auto fade = FadeOut::create(1.0f); + auto fade_in = fade->reverse(); + auto cb = CallFunc::create(CC_CALLBACK_0(LabelAtlasColorTest::actionFinishCallback, this)); + auto seq = Sequence::create(fade, fade_in, cb, NULL); + auto repeat = RepeatForever::create( seq ); label2->runAction( repeat ); _time = 0; @@ -318,10 +318,10 @@ void LabelAtlasColorTest::step(float dt) char string[12] = {0}; sprintf(string, "%2.2f Test", _time); //std::string string = std::string::createWithFormat("%2.2f Test", _time); - LabelAtlas* label1 = (LabelAtlas*)getChildByTag(kTagSprite1); + auto label1 = (LabelAtlas*)getChildByTag(kTagSprite1); label1->setString(string); - LabelAtlas* label2 = (LabelAtlas*)getChildByTag(kTagSprite2); + auto label2 = (LabelAtlas*)getChildByTag(kTagSprite2); sprintf(string, "%d", (int)_time); label2->setString( string ); } @@ -344,22 +344,22 @@ std::string LabelAtlasColorTest::subtitle() //------------------------------------------------------------------ LabelTTFAlignment::LabelTTFAlignment() { - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - LabelTTF* ttf0 = LabelTTF::create("Alignment 0\nnew line", "Helvetica", 12, + auto ttf0 = LabelTTF::create("Alignment 0\nnew line", "Helvetica", 12, Size(256, 32), TextHAlignment::LEFT); ttf0->setPosition(Point(s.width/2,(s.height/6)*2)); ttf0->setAnchorPoint(Point(0.5f,0.5f)); this->addChild(ttf0); - LabelTTF* ttf1 = LabelTTF::create("Alignment 1\nnew line", "Helvetica", 12, + auto ttf1 = LabelTTF::create("Alignment 1\nnew line", "Helvetica", 12, Size(245, 32), TextHAlignment::CENTER); ttf1->setPosition(Point(s.width/2,(s.height/6)*3)); ttf1->setAnchorPoint(Point(0.5f,0.5f)); this->addChild(ttf1); - LabelTTF* ttf2 = LabelTTF::create("Alignment 2\nnew line", "Helvetica", 12, + auto ttf2 = LabelTTF::create("Alignment 2\nnew line", "Helvetica", 12, Size(245, 32), TextHAlignment::RIGHT); ttf2->setPosition(Point(s.width/2,(s.height/6)*4)); ttf2->setAnchorPoint(Point(0.5f,0.5f)); @@ -390,18 +390,18 @@ Atlas3::Atlas3() { _time = 0; - LayerColor* col = LayerColor::create( Color4B(128,128,128,255) ); + auto col = LayerColor::create( Color4B(128,128,128,255) ); addChild(col, -10); - LabelBMFont* label1 = LabelBMFont::create("Test", "fonts/bitmapFontTest2.fnt"); + auto label1 = LabelBMFont::create("Test", "fonts/bitmapFontTest2.fnt"); // testing anchors label1->setAnchorPoint( Point(0,0) ); addChild(label1, 0, kTagBitmapAtlas1); - ActionInterval* fade = FadeOut::create(1.0f); - ActionInterval* fade_in = fade->reverse(); - Sequence* seq = Sequence::create(fade, fade_in, NULL); - Action* repeat = RepeatForever::create(seq); + auto fade = FadeOut::create(1.0f); + auto fade_in = fade->reverse(); + auto seq = Sequence::create(fade, fade_in, NULL); + auto repeat = RepeatForever::create(seq); label1->runAction(repeat); @@ -409,14 +409,14 @@ Atlas3::Atlas3() // color and opacity work OK because bitmapFontAltas2 loads a BMP image (not a PNG image) // If you want to use both opacity and color, it is recommended to use NON premultiplied images like BMP images // Of course, you can also tell XCode not to compress PNG images, but I think it doesn't work as expected - LabelBMFont *label2 = LabelBMFont::create("Test", "fonts/bitmapFontTest2.fnt"); + auto label2 = LabelBMFont::create("Test", "fonts/bitmapFontTest2.fnt"); // testing anchors label2->setAnchorPoint( Point(0.5f, 0.5f) ); label2->setColor( Color3B::RED ); addChild(label2, 0, kTagBitmapAtlas2); label2->runAction( repeat->clone() ); - LabelBMFont* label3 = LabelBMFont::create("Test", "fonts/bitmapFontTest2.fnt"); + auto label3 = LabelBMFont::create("Test", "fonts/bitmapFontTest2.fnt"); // testing anchors label3->setAnchorPoint( Point(1,1) ); addChild(label3, 0, kTagBitmapAtlas3); @@ -436,13 +436,13 @@ void Atlas3::step(float dt) sprintf(string, "%2.2f Test j", _time); //string.format("%2.2f Test j", _time); - LabelBMFont *label1 = (LabelBMFont*) getChildByTag(kTagBitmapAtlas1); + auto label1 = (LabelBMFont*) getChildByTag(kTagBitmapAtlas1); label1->setString(string); - LabelBMFont *label2 = (LabelBMFont*) getChildByTag(kTagBitmapAtlas2); + auto label2 = (LabelBMFont*) getChildByTag(kTagBitmapAtlas2); label2->setString(string); - LabelBMFont *label3 = (LabelBMFont*) getChildByTag(kTagBitmapAtlas3); + auto label3 = (LabelBMFont*) getChildByTag(kTagBitmapAtlas3); label3->setString(string); } @@ -472,35 +472,35 @@ Atlas4::Atlas4() _time = 0; // Upper Label - LabelBMFont *label = LabelBMFont::create("Bitmap Font Atlas", "fonts/bitmapFontTest.fnt"); + auto label = LabelBMFont::create("Bitmap Font Atlas", "fonts/bitmapFontTest.fnt"); addChild(label); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); label->setPosition( Point(s.width/2, s.height/2) ); label->setAnchorPoint( Point(0.5f, 0.5f) ); - Sprite* BChar = (Sprite*) label->getChildByTag(0); - Sprite* FChar = (Sprite*) label->getChildByTag(7); - Sprite* AChar = (Sprite*) label->getChildByTag(12); + auto BChar = (Sprite*) label->getChildByTag(0); + auto FChar = (Sprite*) label->getChildByTag(7); + auto AChar = (Sprite*) label->getChildByTag(12); - ActionInterval* rotate = RotateBy::create(2, 360); - Action* rot_4ever = RepeatForever::create(rotate); + auto rotate = RotateBy::create(2, 360); + auto rot_4ever = RepeatForever::create(rotate); - ActionInterval* scale = ScaleBy::create(2, 1.5f); - ActionInterval* scale_back = scale->reverse(); - Sequence* scale_seq = Sequence::create(scale, scale_back,NULL); - Action* scale_4ever = RepeatForever::create(scale_seq); + auto scale = ScaleBy::create(2, 1.5f); + auto scale_back = scale->reverse(); + auto scale_seq = Sequence::create(scale, scale_back,NULL); + auto scale_4ever = RepeatForever::create(scale_seq); - ActionInterval* jump = JumpBy::create(0.5f, Point::ZERO, 60, 1); - Action* jump_4ever = RepeatForever::create(jump); + auto jump = JumpBy::create(0.5f, Point::ZERO, 60, 1); + auto jump_4ever = RepeatForever::create(jump); - ActionInterval* fade_out = FadeOut::create(1); - ActionInterval* fade_in = FadeIn::create(1); - Sequence* seq = Sequence::create(fade_out, fade_in, NULL); - Action* fade_4ever = RepeatForever::create(seq); + auto fade_out = FadeOut::create(1); + auto fade_in = FadeIn::create(1); + auto seq = Sequence::create(fade_out, fade_in, NULL); + auto fade_4ever = RepeatForever::create(seq); BChar->runAction(rot_4ever); BChar->runAction(scale_4ever); @@ -509,11 +509,11 @@ Atlas4::Atlas4() // Bottom Label - LabelBMFont *label2 = LabelBMFont::create("00.0", "fonts/bitmapFontTest.fnt"); + auto label2 = LabelBMFont::create("00.0", "fonts/bitmapFontTest.fnt"); addChild(label2, 0, kTagBitmapAtlas2); label2->setPosition( Point(s.width/2.0f, 80) ); - Sprite* lastChar = (Sprite*) label2->getChildByTag(3); + auto lastChar = (Sprite*) label2->getChildByTag(3); lastChar->runAction( rot_4ever->clone() ); schedule( schedule_selector(Atlas4::step), 0.1f); @@ -521,7 +521,7 @@ Atlas4::Atlas4() void Atlas4::draw() { - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); DrawPrimitives::drawLine( Point(0, s.height/2), Point(s.width, s.height/2) ); DrawPrimitives::drawLine( Point(s.width/2, 0), Point(s.width/2, s.height) ); } @@ -534,7 +534,7 @@ void Atlas4::step(float dt) // std::string string; // string.format("%04.1f", _time); - LabelBMFont* label1 = (LabelBMFont*) getChildByTag(kTagBitmapAtlas2); + auto label1 = (LabelBMFont*) getChildByTag(kTagBitmapAtlas2); label1->setString(string); } @@ -562,10 +562,10 @@ std::string Atlas4::subtitle() Atlas5::Atlas5() { - LabelBMFont *label = LabelBMFont::create("abcdefg", "fonts/bitmapFontTest4.fnt"); + auto label = LabelBMFont::create("abcdefg", "fonts/bitmapFontTest4.fnt"); addChild(label); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); label->setPosition( Point(s.width/2, s.height/2) ); label->setAnchorPoint( Point(0.5f, 0.5f) ); @@ -594,7 +594,7 @@ std::string Atlas5::subtitle() Atlas6::Atlas6() { - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); LabelBMFont* label = NULL; label = LabelBMFont::create("FaFeFiFoFu", "fonts/bitmapFontTest5.fnt"); @@ -636,7 +636,7 @@ std::string Atlas6::subtitle() //------------------------------------------------------------------ AtlasBitmapColor::AtlasBitmapColor() { - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); LabelBMFont* label = NULL; label = LabelBMFont::create("Blue", "fonts/bitmapFontTest5.fnt"); @@ -688,12 +688,12 @@ AtlasFastBitmap::AtlasFastBitmap() { char str[6] = {0}; sprintf(str, "-%d-", i); - LabelBMFont* label = LabelBMFont::create(str, "fonts/bitmapFontTest.fnt"); + auto label = LabelBMFont::create(str, "fonts/bitmapFontTest.fnt"); addChild(label); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Point p = Point( CCRANDOM_0_1() * s.width, CCRANDOM_0_1() * s.height); + auto p = Point( CCRANDOM_0_1() * s.width, CCRANDOM_0_1() * s.height); label->setPosition( p ); label->setAnchorPoint(Point(0.5f, 0.5f)); } @@ -725,7 +725,7 @@ BitmapFontMultiLine::BitmapFontMultiLine() Size s; // Left - LabelBMFont *label1 = LabelBMFont::create(" Multi line\nLeft", "fonts/bitmapFontTest3.fnt"); + auto label1 = LabelBMFont::create(" Multi line\nLeft", "fonts/bitmapFontTest3.fnt"); label1->setAnchorPoint(Point(0,0)); addChild(label1, 0, kTagBitmapAtlas1); @@ -734,7 +734,7 @@ BitmapFontMultiLine::BitmapFontMultiLine() // Center - LabelBMFont *label2 = LabelBMFont::create("Multi line\nCenter", "fonts/bitmapFontTest3.fnt"); + auto label2 = LabelBMFont::create("Multi line\nCenter", "fonts/bitmapFontTest3.fnt"); label2->setAnchorPoint(Point(0.5f, 0.5f)); addChild(label2, 0, kTagBitmapAtlas2); @@ -742,7 +742,7 @@ BitmapFontMultiLine::BitmapFontMultiLine() CCLOG("content size: %.2fx%.2f", s.width, s.height); // right - LabelBMFont *label3 = LabelBMFont::create("Multi line\nRight\nThree lines Three", "fonts/bitmapFontTest3.fnt"); + auto label3 = LabelBMFont::create("Multi line\nRight\nThree lines Three", "fonts/bitmapFontTest3.fnt"); label3->setAnchorPoint(Point(1, 1)); addChild(label3, 0, kTagBitmapAtlas3); @@ -771,20 +771,20 @@ std::string BitmapFontMultiLine::subtitle() //------------------------------------------------------------------ LabelsEmpty::LabelsEmpty() { - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); // LabelBMFont - LabelBMFont *label1 = LabelBMFont::create("", "fonts/bitmapFontTest3.fnt"); + auto label1 = LabelBMFont::create("", "fonts/bitmapFontTest3.fnt"); addChild(label1, 0, kTagBitmapAtlas1); label1->setPosition(Point(s.width/2, s.height-100)); // LabelTTF - LabelTTF* label2 = LabelTTF::create("", "Arial", 24); + auto label2 = LabelTTF::create("", "Arial", 24); addChild(label2, 0, kTagBitmapAtlas2); label2->setPosition(Point(s.width/2, s.height/2)); // LabelAtlas - LabelAtlas *label3 = LabelAtlas::create("", "fonts/tuffy_bold_italic-charmap.png", 48, 64, ' '); + auto label3 = LabelAtlas::create("", "fonts/tuffy_bold_italic-charmap.png", 48, 64, ' '); addChild(label3, 0, kTagBitmapAtlas3); label3->setPosition(Point(s.width/2, 0+100)); @@ -834,7 +834,7 @@ std::string LabelsEmpty::subtitle() //------------------------------------------------------------------ LabelBMFontHD::LabelBMFontHD() { - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); // LabelBMFont auto label1 = LabelBMFont::create("TESTING RETINA DISPLAY", "fonts/konqa32.fnt"); @@ -859,7 +859,7 @@ std::string LabelBMFontHD::subtitle() //------------------------------------------------------------------ LabelAtlasHD::LabelAtlasHD() { - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); // LabelBMFont auto label1 = LabelAtlas::create("TESTING RETINA DISPLAY", "fonts/larabie-16.plist"); @@ -886,7 +886,7 @@ std::string LabelAtlasHD::subtitle() //------------------------------------------------------------------ LabelGlyphDesigner::LabelGlyphDesigner() { - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); auto layer = LayerColor::create(Color4B(128,128,128,255)); addChild(layer, -10); @@ -910,7 +910,7 @@ std::string LabelGlyphDesigner::subtitle() void AtlasTestScene::runThisTest() { sceneIdx = -1; - Layer* layer = nextAtlasAction(); + auto layer = nextAtlasAction(); addChild(layer); Director::getInstance()->replaceScene(this); @@ -923,8 +923,8 @@ void AtlasTestScene::runThisTest() //------------------------------------------------------------------ LabelTTFTest::LabelTTFTest() { - Size blockSize = Size(200, 160); - Size s = Director::getInstance()->getWinSize(); + auto blockSize = Size(200, 160); + auto s = Director::getInstance()->getWinSize(); auto colorLayer = LayerColor::create(Color4B(100, 100, 100, 255), blockSize.width, blockSize.height); colorLayer->setAnchorPoint(Point(0,0)); @@ -933,7 +933,7 @@ LabelTTFTest::LabelTTFTest() this->addChild(colorLayer); MenuItemFont::setFontSize(30); - Menu *menu = Menu::create( + auto menu = Menu::create( MenuItemFont::create("Left", CC_CALLBACK_1(LabelTTFTest::setAlignmentLeft, this)), MenuItemFont::create("Center", CC_CALLBACK_1(LabelTTFTest::setAlignmentCenter, this)), MenuItemFont::create("Right", CC_CALLBACK_1(LabelTTFTest::setAlignmentRight, this)), @@ -965,8 +965,8 @@ LabelTTFTest::~LabelTTFTest() void LabelTTFTest::updateAlignment() { - Size blockSize = Size(200, 160); - Size s = Director::getInstance()->getWinSize(); + auto blockSize = Size(200, 160); + auto s = Director::getInstance()->getWinSize(); if (_plabel) { @@ -1063,9 +1063,9 @@ string LabelTTFTest::subtitle() LabelTTFMultiline::LabelTTFMultiline() { - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - LabelTTF *center = LabelTTF::create("word wrap \"testing\" (bla0) bla1 'bla2' [bla3] (bla4) {bla5} {bla6} [bla7] (bla8) [bla9] 'bla0' \"bla1\"", + auto center = LabelTTF::create("word wrap \"testing\" (bla0) bla1 'bla2' [bla3] (bla4) {bla5} {bla6} [bla7] (bla8) [bla9] 'bla0' \"bla1\"", "Paint Boy", 32, Size(s.width/2,200), @@ -1137,7 +1137,7 @@ BitmapFontMultiLineAlignment::BitmapFontMultiLineAlignment() this->setTouchEnabled(true); // ask director the the window size - Size size = Director::getInstance()->getWinSize(); + auto size = Director::getInstance()->getWinSize(); // create and initialize a Label this->_labelShouldRetain = LabelBMFont::create(LongSentencesExample, "fonts/markerFelt.fnt", size.width/1.5, TextHAlignment::CENTER); @@ -1215,7 +1215,7 @@ std::string BitmapFontMultiLineAlignment::subtitle() void BitmapFontMultiLineAlignment::stringChanged(cocos2d::Object *sender) { - MenuItemFont *item = (MenuItemFont*)sender; + auto item = (MenuItemFont*)sender; item->setColor(Color3B::RED); this->_lastAlignmentItem->setColor(Color3B::WHITE); this->_lastAlignmentItem = item; @@ -1241,7 +1241,7 @@ void BitmapFontMultiLineAlignment::stringChanged(cocos2d::Object *sender) void BitmapFontMultiLineAlignment::alignmentChanged(cocos2d::Object *sender) { - MenuItemFont *item = static_cast(sender); + auto item = static_cast(sender); item->setColor(Color3B::RED); this->_lastAlignmentItem->setColor(Color3B::WHITE); this->_lastAlignmentItem = item; @@ -1267,8 +1267,8 @@ void BitmapFontMultiLineAlignment::alignmentChanged(cocos2d::Object *sender) void BitmapFontMultiLineAlignment::ccTouchesBegan(cocos2d::Set *touches, cocos2d::Event *event) { - Touch *touch = (Touch *)touches->anyObject(); - Point location = touch->getLocationInView(); + auto touch = (Touch *)touches->anyObject(); + auto location = touch->getLocationInView(); if (this->_arrowsShouldRetain->getBoundingBox().containsPoint(location)) { @@ -1292,10 +1292,10 @@ void BitmapFontMultiLineAlignment::ccTouchesMoved(cocos2d::Set *touches, cocos2 return; } - Touch *touch = (Touch *)touches->anyObject(); - Point location = touch->getLocationInView(); + auto touch = (Touch *)touches->anyObject(); + auto location = touch->getLocationInView(); - Size winSize = Director::getInstance()->getWinSize(); + auto winSize = Director::getInstance()->getWinSize(); this->_arrowsShouldRetain->setPosition(Point(MAX(MIN(location.x, ArrowsMax*winSize.width), ArrowsMin*winSize.width), this->_arrowsShouldRetain->getPosition().y)); @@ -1314,13 +1314,13 @@ void BitmapFontMultiLineAlignment::snapArrowsToEdge() /// LabelTTFA8Test LabelTTFA8Test::LabelTTFA8Test() { - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - LayerColor *layer = LayerColor::create(Color4B(128, 128, 128, 255)); + auto layer = LayerColor::create(Color4B(128, 128, 128, 255)); addChild(layer, -10); // LabelBMFont - LabelTTF *label1 = LabelTTF::create("Testing A8 Format", "Marker Felt", 48); + auto label1 = LabelTTF::create("Testing A8 Format", "Marker Felt", 48); addChild(label1); label1->setColor(Color3B::RED); label1->setPosition(Point(s.width/2, s.height/2)); @@ -1345,7 +1345,7 @@ std::string LabelTTFA8Test::subtitle() /// BMFontOneAtlas BMFontOneAtlas::BMFontOneAtlas() { - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); auto label1 = LabelBMFont::create("This is Helvetica", "fonts/helvetica-32.fnt", kLabelAutomaticWidth, TextHAlignment::LEFT, Point::ZERO); addChild(label1); @@ -1369,14 +1369,14 @@ std::string BMFontOneAtlas::subtitle() /// BMFontUnicode BMFontUnicode::BMFontUnicode() { - Dictionary *strings = Dictionary::createWithContentsOfFile("fonts/strings.xml"); + auto strings = Dictionary::createWithContentsOfFile("fonts/strings.xml"); const char *chinese = static_cast(strings->objectForKey("chinese1"))->_string.c_str(); const char *japanese = static_cast(strings->objectForKey("japanese"))->_string.c_str(); const char *russian = static_cast(strings->objectForKey("russian"))->_string.c_str(); const char *spanish = static_cast(strings->objectForKey("spanish"))->_string.c_str(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); auto label1 = LabelBMFont::create(spanish, "fonts/arial-unicode-26.fnt", 200, TextHAlignment::LEFT); addChild(label1); @@ -1409,9 +1409,9 @@ std::string BMFontUnicode::subtitle() BMFontInit::BMFontInit() { - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - LabelBMFont* bmFont = LabelBMFont::create(); + auto bmFont = LabelBMFont::create(); bmFont->setFntFile("fonts/helvetica-32.fnt"); bmFont->setString("It is working!"); @@ -1433,9 +1433,9 @@ std::string BMFontInit::subtitle() TTFFontInit::TTFFontInit() { - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - LabelTTF* font = LabelTTF::create(); + auto font = LabelTTF::create(); font->setFontName("Marker Felt"); font->setFontSize(48); @@ -1456,10 +1456,10 @@ std::string TTFFontInit::subtitle() TTFFontShadowAndStroke::TTFFontShadowAndStroke() { - LayerColor *layer = LayerColor::create(Color4B(0,190,0,255)); + auto layer = LayerColor::create(Color4B(0,190,0,255)); addChild(layer, -10); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); Color3B tintColorRed( 255, 0, 0 ); Color3B tintColorYellow( 255, 255, 0 ); @@ -1480,7 +1480,7 @@ TTFFontShadowAndStroke::TTFFontShadowAndStroke() shadowTextDef._fontFillColor = tintColorRed; // shadow only label - LabelTTF* fontShadow = LabelTTF::createWithFontDefinition("Shadow Only Red Text", shadowTextDef); + auto fontShadow = LabelTTF::createWithFontDefinition("Shadow Only Red Text", shadowTextDef); // add label to the scene this->addChild(fontShadow); @@ -1499,7 +1499,7 @@ TTFFontShadowAndStroke::TTFFontShadowAndStroke() strokeTextDef._fontFillColor = tintColorYellow; // stroke only label - LabelTTF* fontStroke = LabelTTF::createWithFontDefinition("Stroke Only Yellow Text", strokeTextDef); + auto fontStroke = LabelTTF::createWithFontDefinition("Stroke Only Yellow Text", strokeTextDef); // add label to the scene this->addChild(fontStroke); @@ -1525,7 +1525,7 @@ TTFFontShadowAndStroke::TTFFontShadowAndStroke() strokeShaodwTextDef._fontFillColor = tintColorBlue; // shadow + stroke label - LabelTTF* fontStrokeAndShadow = LabelTTF::createWithFontDefinition("Stroke & Shadow Blue Text", strokeShaodwTextDef); + auto fontStrokeAndShadow = LabelTTF::createWithFontDefinition("Stroke & Shadow Blue Text", strokeShaodwTextDef); // add label to the scene this->addChild(fontStrokeAndShadow); @@ -1547,9 +1547,9 @@ std::string TTFFontShadowAndStroke::subtitle() Issue1343::Issue1343() { - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - LabelBMFont* bmFont = LabelBMFont::create(); + auto bmFont = LabelBMFont::create(); bmFont->setFntFile("fonts/font-issue1343.fnt"); bmFont->setString("ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz.,'"); @@ -1572,9 +1572,9 @@ std::string Issue1343::subtitle() LabelBMFontBounds::LabelBMFontBounds() { - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - LayerColor *layer = LayerColor::create(Color4B(128,128,128,255)); + auto layer = LayerColor::create(Color4B(128,128,128,255)); addChild(layer, -10); // LabelBMFont @@ -1596,8 +1596,8 @@ string LabelBMFontBounds::subtitle() void LabelBMFontBounds::draw() { - Size labelSize = label1->getContentSize(); - Size origin = Director::getInstance()->getWinSize(); + auto labelSize = label1->getContentSize(); + auto origin = Director::getInstance()->getWinSize(); origin.width = origin.width / 2 - (labelSize.width / 2); origin.height = origin.height / 2 - (labelSize.height / 2); diff --git a/samples/Cpp/TestCpp/Classes/LabelTest/LabelTestNew.cpp b/samples/Cpp/TestCpp/Classes/LabelTest/LabelTestNew.cpp index efcd45e149..3c05d928d7 100644 --- a/samples/Cpp/TestCpp/Classes/LabelTest/LabelTestNew.cpp +++ b/samples/Cpp/TestCpp/Classes/LabelTest/LabelTestNew.cpp @@ -73,7 +73,7 @@ Layer* nextAtlasActionNew() sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - Layer* layer = (createFunctions[sceneIdx])(); + auto layer = (createFunctions[sceneIdx])(); layer->autorelease(); return layer; @@ -86,7 +86,7 @@ Layer* backAtlasActionNew() if( sceneIdx < 0 ) sceneIdx += total; - Layer* layer = (createFunctions[sceneIdx])(); + auto layer = (createFunctions[sceneIdx])(); layer->autorelease(); return layer; @@ -94,7 +94,7 @@ Layer* backAtlasActionNew() Layer* restartAtlasActionNew() { - Layer* layer = (createFunctions[sceneIdx])(); + auto layer = (createFunctions[sceneIdx])(); layer->autorelease(); return layer; @@ -103,7 +103,7 @@ Layer* restartAtlasActionNew() void AtlasTestSceneNew::runThisTest() { sceneIdx = -1; - Layer* layer = nextAtlasActionNew(); + auto layer = nextAtlasActionNew(); addChild(layer); Director::getInstance()->replaceScene(this); @@ -134,7 +134,7 @@ void AtlasDemoNew::onEnter() void AtlasDemoNew::restartCallback(Object* sender) { - Scene* s = new AtlasTestSceneNew(); + auto s = new AtlasTestSceneNew(); s->addChild(restartAtlasActionNew()); Director::getInstance()->replaceScene(s); @@ -143,7 +143,7 @@ void AtlasDemoNew::restartCallback(Object* sender) void AtlasDemoNew::nextCallback(Object* sender) { - Scene* s = new AtlasTestSceneNew(); + auto s = new AtlasTestSceneNew(); s->addChild( nextAtlasActionNew() ); Director::getInstance()->replaceScene(s); s->release(); @@ -151,7 +151,7 @@ void AtlasDemoNew::nextCallback(Object* sender) void AtlasDemoNew::backCallback(Object* sender) { - Scene* s = new AtlasTestSceneNew(); + auto s = new AtlasTestSceneNew(); s->addChild( backAtlasActionNew() ); Director::getInstance()->replaceScene(s); s->release(); @@ -159,21 +159,21 @@ void AtlasDemoNew::backCallback(Object* sender) LabelTTFAlignmentNew::LabelTTFAlignmentNew() { - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Label* ttf0 = Label::createWithTTF("Alignment 0\nnew line", "fonts/tahoma.ttf", 32); + auto ttf0 = Label::createWithTTF("Alignment 0\nnew line", "fonts/tahoma.ttf", 32); ttf0->setAlignment(TextHAlignment::LEFT); ttf0->setPosition(Point(s.width/2,(s.height/6)*2 - 30)); ttf0->setAnchorPoint(Point(0.5f,0.5f)); this->addChild(ttf0); - Label* ttf1 = Label::createWithTTF("Alignment 1\nnew line", "fonts/tahoma.ttf", 32); + auto ttf1 = Label::createWithTTF("Alignment 1\nnew line", "fonts/tahoma.ttf", 32); ttf1->setAlignment(TextHAlignment::CENTER); ttf1->setPosition(Point(s.width/2,(s.height/6)*3 - 30)); ttf1->setAnchorPoint(Point(0.5f,0.5f)); this->addChild(ttf1); - Label* ttf2 = Label::createWithTTF("Alignment 2\nnew line", "fonts/tahoma.ttf", 32); + auto ttf2 = Label::createWithTTF("Alignment 2\nnew line", "fonts/tahoma.ttf", 32); ttf1->setAlignment(TextHAlignment::RIGHT); ttf2->setPosition(Point(s.width/2,(s.height/6)*4 - 30)); ttf2->setAnchorPoint(Point(0.5f,0.5f)); @@ -194,26 +194,26 @@ LabelFNTColorAndOpacity::LabelFNTColorAndOpacity() { _time = 0; - LayerColor* col = LayerColor::create( Color4B(128,128,128,255) ); + auto col = LayerColor::create( Color4B(128,128,128,255) ); addChild(col, -10); - Label * label1 = Label::createWithBMFont("Test", "fonts/bitmapFontTest2.fnt"); + auto label1 = Label::createWithBMFont("Test", "fonts/bitmapFontTest2.fnt"); label1->setAnchorPoint( Point(0,0) ); addChild(label1, 0, kTagBitmapAtlas1); - ActionInterval* fade = FadeOut::create(1.0f); - ActionInterval* fade_in = fade->reverse(); - Sequence* seq = Sequence::create(fade, fade_in, NULL); - Action* repeat = RepeatForever::create(seq); + auto fade = FadeOut::create(1.0f); + auto fade_in = fade->reverse(); + auto seq = Sequence::create(fade, fade_in, NULL); + auto repeat = RepeatForever::create(seq); label1->runAction(repeat); - Label *label2 = Label::createWithBMFont("Test", "fonts/bitmapFontTest2.fnt"); + auto label2 = Label::createWithBMFont("Test", "fonts/bitmapFontTest2.fnt"); label2->setAnchorPoint( Point(0.5f, 0.5f) ); label2->setColor( Color3B::RED ); addChild(label2, 0, kTagBitmapAtlas2); label2->runAction( repeat->clone() ); - Label* label3 = Label::createWithBMFont("Test", "fonts/bitmapFontTest2.fnt"); + auto label3 = Label::createWithBMFont("Test", "fonts/bitmapFontTest2.fnt"); label3->setAnchorPoint( Point(1,1) ); addChild(label3, 0, kTagBitmapAtlas3); @@ -230,13 +230,13 @@ void LabelFNTColorAndOpacity::step(float dt) char string[15] = {0}; sprintf(string, "%2.2f Test j", _time); - Label *label1 = (Label*) getChildByTag(kTagBitmapAtlas1); + auto label1 = (Label*) getChildByTag(kTagBitmapAtlas1); label1->setString(string); - Label *label2 = (Label*) getChildByTag(kTagBitmapAtlas2); + auto label2 = (Label*) getChildByTag(kTagBitmapAtlas2); label2->setString(string); - Label *label3 = (Label*) getChildByTag(kTagBitmapAtlas3); + auto label3 = (Label*) getChildByTag(kTagBitmapAtlas3); label3->setString(string); } @@ -255,35 +255,35 @@ LabelFNTSpriteActions::LabelFNTSpriteActions() _time = 0; // Upper Label - Label *label = Label::createWithBMFont("Bitmap Font Atlas", "fonts/bitmapFontTest.fnt"); + auto label = Label::createWithBMFont("Bitmap Font Atlas", "fonts/bitmapFontTest.fnt"); addChild(label); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); label->setPosition( Point(s.width/2, s.height/2) ); label->setAnchorPoint( Point(0.5f, 0.5f) ); - Sprite* BChar = (Sprite*) label->getChildByTag(0); - Sprite* FChar = (Sprite*) label->getChildByTag(7); - Sprite* AChar = (Sprite*) label->getChildByTag(12); + auto BChar = (Sprite*) label->getChildByTag(0); + auto FChar = (Sprite*) label->getChildByTag(7); + auto AChar = (Sprite*) label->getChildByTag(12); - ActionInterval* rotate = RotateBy::create(2, 360); - Action* rot_4ever = RepeatForever::create(rotate); + auto rotate = RotateBy::create(2, 360); + auto rot_4ever = RepeatForever::create(rotate); - ActionInterval* scale = ScaleBy::create(2, 1.5f); - ActionInterval* scale_back = scale->reverse(); - Sequence* scale_seq = Sequence::create(scale, scale_back,NULL); - Action* scale_4ever = RepeatForever::create(scale_seq); + auto scale = ScaleBy::create(2, 1.5f); + auto scale_back = scale->reverse(); + auto scale_seq = Sequence::create(scale, scale_back,NULL); + auto scale_4ever = RepeatForever::create(scale_seq); - ActionInterval* jump = JumpBy::create(0.5f, Point::ZERO, 60, 1); - Action* jump_4ever = RepeatForever::create(jump); + auto jump = JumpBy::create(0.5f, Point::ZERO, 60, 1); + auto jump_4ever = RepeatForever::create(jump); - ActionInterval* fade_out = FadeOut::create(1); - ActionInterval* fade_in = FadeIn::create(1); - Sequence* seq = Sequence::create(fade_out, fade_in, NULL); - Action* fade_4ever = RepeatForever::create(seq); + auto fade_out = FadeOut::create(1); + auto fade_in = FadeIn::create(1); + auto seq = Sequence::create(fade_out, fade_in, NULL); + auto fade_4ever = RepeatForever::create(seq); BChar->runAction(rot_4ever); BChar->runAction(scale_4ever); @@ -292,11 +292,11 @@ LabelFNTSpriteActions::LabelFNTSpriteActions() // Bottom Label - Label *label2 = Label::createWithBMFont("00.0", "fonts/bitmapFontTest.fnt"); + auto label2 = Label::createWithBMFont("00.0", "fonts/bitmapFontTest.fnt"); addChild(label2, 0, kTagBitmapAtlas2); label2->setPosition( Point(s.width/2.0f, 80) ); - Sprite* lastChar = (Sprite*) label2->getChildByTag(1); + auto lastChar = (Sprite*) label2->getChildByTag(1); lastChar->runAction( rot_4ever->clone() ); schedule( schedule_selector(LabelFNTSpriteActions::step), 0.1f); @@ -304,7 +304,7 @@ LabelFNTSpriteActions::LabelFNTSpriteActions() void LabelFNTSpriteActions::draw() { - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); DrawPrimitives::drawLine( Point(0, s.height/2), Point(s.width, s.height/2) ); DrawPrimitives::drawLine( Point(s.width/2, 0), Point(s.width/2, s.height) ); } @@ -314,7 +314,7 @@ void LabelFNTSpriteActions::step(float dt) _time += dt; char string[10] = {0}; sprintf(string, "%04.1f", _time); - Label* label1 = (Label*) getChildByTag(kTagBitmapAtlas2); + auto label1 = (Label*) getChildByTag(kTagBitmapAtlas2); label1->setString(string); } @@ -330,10 +330,10 @@ std::string LabelFNTSpriteActions::subtitle() LabelFNTPadding::LabelFNTPadding() { - Label *label = Label::createWithBMFont("abcdefg", "fonts/bitmapFontTest4.fnt"); + auto label = Label::createWithBMFont("abcdefg", "fonts/bitmapFontTest4.fnt"); addChild(label); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); label->setPosition( Point(s.width/2, s.height/2) ); label->setAnchorPoint( Point(0.5f, 0.5f) ); @@ -351,7 +351,7 @@ std::string LabelFNTPadding::subtitle() LabelFNTOffset::LabelFNTOffset() { - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); Label* label = NULL; label = Label::createWithBMFont("FaFeFiFoFu", "fonts/bitmapFontTest5.fnt"); @@ -382,7 +382,7 @@ std::string LabelFNTOffset::subtitle() LabelFNTColor::LabelFNTColor() { - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); Label* label = NULL; label = Label::createWithBMFont("Blue", "fonts/bitmapFontTest5.fnt"); @@ -422,12 +422,12 @@ LabelFNTHundredLabels::LabelFNTHundredLabels() { char str[6] = {0}; sprintf(str, "-%d-", i); - Label* label = Label::createWithBMFont(str, "fonts/bitmapFontTest.fnt"); + auto label = Label::createWithBMFont(str, "fonts/bitmapFontTest.fnt"); addChild(label); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Point p = Point( CCRANDOM_0_1() * s.width, CCRANDOM_0_1() * s.height); + auto p = Point( CCRANDOM_0_1() * s.width, CCRANDOM_0_1() * s.height); label->setPosition( p ); label->setAnchorPoint(Point(0.5f, 0.5f)); } @@ -448,7 +448,7 @@ LabelFNTMultiLine::LabelFNTMultiLine() Size s; // Left - Label* label1 = Label::createWithBMFont(" Multi line\nLeft", "fonts/bitmapFontTest3.fnt"); + auto label1 = Label::createWithBMFont(" Multi line\nLeft", "fonts/bitmapFontTest3.fnt"); label1->setAnchorPoint(Point(0,0)); addChild(label1, 0, kTagBitmapAtlas1); @@ -457,7 +457,7 @@ LabelFNTMultiLine::LabelFNTMultiLine() // Center - Label* label2 = Label::createWithBMFont("Multi line\nCenter", "fonts/bitmapFontTest3.fnt"); + auto label2 = Label::createWithBMFont("Multi line\nCenter", "fonts/bitmapFontTest3.fnt"); label2->setAnchorPoint(Point(0.5f, 0.5f)); addChild(label2, 0, kTagBitmapAtlas2); @@ -465,7 +465,7 @@ LabelFNTMultiLine::LabelFNTMultiLine() CCLOG("content size: %.2fx%.2f", s.width, s.height); // right - Label *label3 = Label::createWithBMFont("Multi line\nRight\nThree lines Three", "fonts/bitmapFontTest3.fnt"); + auto label3 = Label::createWithBMFont("Multi line\nRight\nThree lines Three", "fonts/bitmapFontTest3.fnt"); label3->setAnchorPoint(Point(1, 1)); addChild(label3, 0, kTagBitmapAtlas3); @@ -489,17 +489,17 @@ std::string LabelFNTMultiLine::subtitle() LabelFNTandTTFEmpty::LabelFNTandTTFEmpty() { - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); float delta = s.height/4; // LabelBMFont - Label *label1 = Label::createWithBMFont("", "fonts/bitmapFontTest3.fnt", TextHAlignment::CENTER, s.width); + auto label1 = Label::createWithBMFont("", "fonts/bitmapFontTest3.fnt", TextHAlignment::CENTER, s.width); addChild(label1, 0, kTagBitmapAtlas1); label1->setAnchorPoint(Point(0.5f, 0.5f)); label1->setPosition(Point(s.width/2, delta)); // LabelTTF - Label* label2 = Label::createWithTTF("", "fonts/arial.ttf", 48, s.width, TextHAlignment::CENTER,GlyphCollection::NEHE); + auto label2 = Label::createWithTTF("", "fonts/arial.ttf", 48, s.width, TextHAlignment::CENTER,GlyphCollection::NEHE); addChild(label2, 0, kTagBitmapAtlas2); label2->setAnchorPoint(Point(0.5f, 0.5f)); label2->setPosition(Point(s.width/2, delta * 2)); @@ -544,7 +544,7 @@ std::string LabelFNTandTTFEmpty::subtitle() LabelFNTRetina::LabelFNTRetina() { - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); // LabelBMFont auto label1 = Label::createWithBMFont("TESTING RETINA DISPLAY", "fonts/konqa32.fnt"); @@ -565,7 +565,7 @@ std::string LabelFNTRetina::subtitle() LabelFNTGlyphDesigner::LabelFNTGlyphDesigner() { - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); auto layer = LayerColor::create(Color4B(128,128,128,255)); addChild(layer, -10); @@ -653,7 +653,7 @@ LabelFNTMultiLineAlignment::LabelFNTMultiLineAlignment() this->setTouchEnabled(true); // ask director the the window size - Size size = Director::getInstance()->getWinSize(); + auto size = Director::getInstance()->getWinSize(); // create and initialize a Label this->_labelShouldRetain = Label::createWithBMFont(LongSentencesExample, "fonts/markerFelt.fnt", TextHAlignment::CENTER, size.width/1.5); @@ -733,7 +733,7 @@ std::string LabelFNTMultiLineAlignment::subtitle() void LabelFNTMultiLineAlignment::stringChanged(cocos2d::Object *sender) { - MenuItemFont *item = (MenuItemFont*)sender; + auto item = (MenuItemFont*)sender; item->setColor(Color3B::RED); this->_lastAlignmentItem->setColor(Color3B::WHITE); this->_lastAlignmentItem = item; @@ -759,7 +759,7 @@ void LabelFNTMultiLineAlignment::stringChanged(cocos2d::Object *sender) void LabelFNTMultiLineAlignment::alignmentChanged(cocos2d::Object *sender) { - MenuItemFont *item = static_cast(sender); + auto item = static_cast(sender); item->setColor(Color3B::RED); this->_lastAlignmentItem->setColor(Color3B::WHITE); this->_lastAlignmentItem = item; @@ -785,8 +785,8 @@ void LabelFNTMultiLineAlignment::alignmentChanged(cocos2d::Object *sender) void LabelFNTMultiLineAlignment::ccTouchesBegan(cocos2d::Set *touches, cocos2d::Event *event) { - Touch *touch = (Touch *)touches->anyObject(); - Point location = touch->getLocationInView(); + auto touch = (Touch *)touches->anyObject(); + auto location = touch->getLocationInView(); if (this->_arrowsShouldRetain->getBoundingBox().containsPoint(location)) { @@ -810,10 +810,10 @@ void LabelFNTMultiLineAlignment::ccTouchesMoved(cocos2d::Set *touches, cocos2d: return; } - Touch *touch = (Touch *)touches->anyObject(); - Point location = touch->getLocationInView(); + auto touch = (Touch *)touches->anyObject(); + auto location = touch->getLocationInView(); - Size winSize = Director::getInstance()->getWinSize(); + auto winSize = Director::getInstance()->getWinSize(); this->_arrowsShouldRetain->setPosition(Point(MAX(MIN(location.x, ArrowsMax*winSize.width), ArrowsMin*winSize.width), this->_arrowsShouldRetain->getPosition().y)); @@ -832,14 +832,14 @@ void LabelFNTMultiLineAlignment::snapArrowsToEdge() /// BMFontUnicodeNew LabelFNTUNICODELanguages::LabelFNTUNICODELanguages() { - Dictionary *strings = Dictionary::createWithContentsOfFile("fonts/strings.xml"); + auto strings = Dictionary::createWithContentsOfFile("fonts/strings.xml"); const char *chinese = static_cast(strings->objectForKey("chinese1"))->_string.c_str(); const char *japanese = static_cast(strings->objectForKey("japanese"))->_string.c_str(); const char *russian = static_cast(strings->objectForKey("russian"))->_string.c_str(); const char *spanish = static_cast(strings->objectForKey("spanish"))->_string.c_str(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); auto label1 = Label::createWithBMFont(spanish, "fonts/arial-unicode-26.fnt", TextHAlignment::CENTER, 200); addChild(label1); @@ -874,9 +874,9 @@ std::string LabelFNTUNICODELanguages::subtitle() LabelFNTBounds::LabelFNTBounds() { - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - LayerColor *layer = LayerColor::create(Color4B(128,128,128,255)); + auto layer = LayerColor::create(Color4B(128,128,128,255)); addChild(layer, -10); // LabelBMFont @@ -898,8 +898,8 @@ string LabelFNTBounds::subtitle() void LabelFNTBounds::draw() { - Size labelSize = label1->getContentSize(); - Size origin = Director::getInstance()->getWinSize(); + auto labelSize = label1->getContentSize(); + auto origin = Director::getInstance()->getWinSize(); origin.width = origin.width / 2 - (labelSize.width / 2); origin.height = origin.height / 2 - (labelSize.height / 2); @@ -916,7 +916,7 @@ void LabelFNTBounds::draw() LabelTTFLongLineWrapping::LabelTTFLongLineWrapping() { - Size size = Director::getInstance()->getWinSize(); + auto size = Director::getInstance()->getWinSize(); // Long sentence auto label1 = Label::createWithTTF(LongSentencesExample, "fonts/arial.ttf", 28, size.width, TextHAlignment::CENTER, GlyphCollection::NEHE); @@ -937,7 +937,7 @@ std::string LabelTTFLongLineWrapping::subtitle() LabelTTFColor::LabelTTFColor() { - Size size = Director::getInstance()->getWinSize(); + auto size = Director::getInstance()->getWinSize(); // Green auto label1 = Label::createWithTTF("Green", "fonts/arial.ttf", 35, size.width, TextHAlignment::CENTER, GlyphCollection::NEHE); @@ -973,7 +973,7 @@ std::string LabelTTFColor::subtitle() LabelTTFDynamicAlignment::LabelTTFDynamicAlignment() { - Size size = Director::getInstance()->getWinSize(); + auto size = Director::getInstance()->getWinSize(); _label = Label::createWithTTF(LongSentencesExample, "fonts/arial.ttf", 45, size.width, TextHAlignment::CENTER, GlyphCollection::NEHE); _label->setPosition( Point(size.width/2, size.height/2) ); @@ -981,7 +981,7 @@ LabelTTFDynamicAlignment::LabelTTFDynamicAlignment() - Menu *menu = Menu::create( + auto menu = Menu::create( MenuItemFont::create("Left", CC_CALLBACK_1(LabelTTFDynamicAlignment::setAlignmentLeft, this)), MenuItemFont::create("Center", CC_CALLBACK_1(LabelTTFDynamicAlignment::setAlignmentCenter, this)), MenuItemFont::create("Right", CC_CALLBACK_1(LabelTTFDynamicAlignment::setAlignmentRight, this)), @@ -1035,14 +1035,14 @@ std::string LabelTTFDynamicAlignment::subtitle() // LabelTTFUnicodeNew::LabelTTFUnicodeNew() { - Dictionary *strings = Dictionary::createWithContentsOfFile("fonts/strings.xml"); + auto strings = Dictionary::createWithContentsOfFile("fonts/strings.xml"); const char *chinese = static_cast(strings->objectForKey("chinese1"))->_string.c_str(); //const char *russian = static_cast(strings->objectForKey("russian"))->_string.c_str(); //const char *spanish = static_cast(strings->objectForKey("spanish"))->_string.c_str(); //const char *japanese = static_cast(strings->objectForKey("japanese"))->_string.c_str(); - Size size = Director::getInstance()->getWinSize(); + auto size = Director::getInstance()->getWinSize(); float vStep = size.height/9; float vSize = size.height; @@ -1090,7 +1090,7 @@ LabelTTFFontsTestNew::LabelTTFFontsTestNew() }; #define arraysize(ar) (sizeof(ar) / sizeof(ar[0])) - Size size = Director::getInstance()->getWinSize(); + auto size = Director::getInstance()->getWinSize(); for(int i=0;i < arraysize(ttfpaths); ++i) { auto label = Label::createWithTTF( ttfpaths[i], ttfpaths[i], 40, 0, TextHAlignment::CENTER, GlyphCollection::NEHE); @@ -1118,7 +1118,7 @@ std::string LabelTTFFontsTestNew::subtitle() LabelBMFontTestNew::LabelBMFontTestNew() { - Size size = Director::getInstance()->getWinSize(); + auto size = Director::getInstance()->getWinSize(); auto label1 = Label::createWithBMFont("Hello World, this is testing the new Label using fnt file", "fonts/bitmapFontTest2.fnt", TextHAlignment::CENTER, size.width); label1->setPosition( Point(size.width/2, size.height/2) ); diff --git a/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.cpp b/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.cpp index ea266cc6b7..bafa537063 100644 --- a/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.cpp +++ b/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.cpp @@ -33,7 +33,7 @@ static Layer* nextAction() sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - Layer* layer = (createFunctions[sceneIdx])(); + auto layer = (createFunctions[sceneIdx])(); layer->autorelease(); return layer; @@ -46,7 +46,7 @@ static Layer* backAction() if( sceneIdx < 0 ) sceneIdx += total; - Layer* layer = (createFunctions[sceneIdx])(); + auto layer = (createFunctions[sceneIdx])(); layer->autorelease(); return layer; @@ -54,7 +54,7 @@ static Layer* backAction() static Layer* restartAction() { - Layer* layer = (createFunctions[sceneIdx])(); + auto layer = (createFunctions[sceneIdx])(); layer->autorelease(); return layer; @@ -91,7 +91,7 @@ void LayerTest::onEnter() void LayerTest::restartCallback(Object* sender) { - Scene* s = new LayerTestScene(); + auto s = new LayerTestScene(); s->addChild(restartAction()); Director::getInstance()->replaceScene(s); @@ -100,7 +100,7 @@ void LayerTest::restartCallback(Object* sender) void LayerTest::nextCallback(Object* sender) { - Scene* s = new LayerTestScene(); + auto s = new LayerTestScene(); s->addChild( nextAction() ); Director::getInstance()->replaceScene(s); s->release(); @@ -108,7 +108,7 @@ void LayerTest::nextCallback(Object* sender) void LayerTest::backCallback(Object* sender) { - Scene* s = new LayerTestScene(); + auto s = new LayerTestScene(); s->addChild( backAction() ); Director::getInstance()->replaceScene(s); s->release(); @@ -118,7 +118,7 @@ void LayerTest::backCallback(Object* sender) static void setEnableRecursiveCascading(Node* node, bool enable) { - RGBAProtocol* rgba = dynamic_cast(node); + auto rgba = dynamic_cast(node); if (rgba) { rgba->setCascadeColorEnabled(enable); @@ -126,10 +126,10 @@ static void setEnableRecursiveCascading(Node* node, bool enable) } Object* obj; - Array* children = node->getChildren(); + auto children = node->getChildren(); CCARRAY_FOREACH(children, obj) { - Node* child = static_cast(obj); + auto child = static_cast(obj); setEnableRecursiveCascading(child, enable); } } @@ -139,12 +139,12 @@ void LayerTestCascadingOpacityA::onEnter() { LayerTest::onEnter(); - Size s = Director::getInstance()->getWinSize(); - LayerRGBA* layer1 = LayerRGBA::create(); + auto s = Director::getInstance()->getWinSize(); + auto layer1 = LayerRGBA::create(); - Sprite *sister1 = Sprite::create("Images/grossinis_sister1.png"); - Sprite *sister2 = Sprite::create("Images/grossinis_sister2.png"); - LabelBMFont *label = LabelBMFont::create("Test", "fonts/bitmapFontTest.fnt"); + auto sister1 = Sprite::create("Images/grossinis_sister1.png"); + auto sister2 = Sprite::create("Images/grossinis_sister2.png"); + auto label = LabelBMFont::create("Test", "fonts/bitmapFontTest.fnt"); layer1->addChild(sister1); layer1->addChild(sister2); @@ -189,15 +189,15 @@ void LayerTestCascadingOpacityB::onEnter() { LayerTest::onEnter(); - Size s = Director::getInstance()->getWinSize(); - LayerColor* layer1 = LayerColor::create(Color4B(192, 0, 0, 255), s.width, s.height/2); + auto s = Director::getInstance()->getWinSize(); + auto layer1 = LayerColor::create(Color4B(192, 0, 0, 255), s.width, s.height/2); layer1->setCascadeColorEnabled(false); layer1->setPosition( Point(0, s.height/2)); - Sprite *sister1 = Sprite::create("Images/grossinis_sister1.png"); - Sprite *sister2 = Sprite::create("Images/grossinis_sister2.png"); - LabelBMFont *label = LabelBMFont::create("Test", "fonts/bitmapFontTest.fnt"); + auto sister1 = Sprite::create("Images/grossinis_sister1.png"); + auto sister2 = Sprite::create("Images/grossinis_sister2.png"); + auto label = LabelBMFont::create("Test", "fonts/bitmapFontTest.fnt"); layer1->addChild(sister1); layer1->addChild(sister2); @@ -241,16 +241,16 @@ void LayerTestCascadingOpacityC::onEnter() { LayerTest::onEnter(); - Size s = Director::getInstance()->getWinSize(); - LayerColor* layer1 = LayerColor::create(Color4B(192, 0, 0, 255), s.width, s.height/2); + auto s = Director::getInstance()->getWinSize(); + auto layer1 = LayerColor::create(Color4B(192, 0, 0, 255), s.width, s.height/2); layer1->setCascadeColorEnabled(false); layer1->setCascadeOpacityEnabled(false); layer1->setPosition( Point(0, s.height/2)); - Sprite *sister1 = Sprite::create("Images/grossinis_sister1.png"); - Sprite *sister2 = Sprite::create("Images/grossinis_sister2.png"); - LabelBMFont *label = LabelBMFont::create("Test", "fonts/bitmapFontTest.fnt"); + auto sister1 = Sprite::create("Images/grossinis_sister1.png"); + auto sister2 = Sprite::create("Images/grossinis_sister2.png"); + auto label = LabelBMFont::create("Test", "fonts/bitmapFontTest.fnt"); layer1->addChild(sister1); layer1->addChild(sister2); @@ -293,12 +293,12 @@ void LayerTestCascadingColorA::onEnter() { LayerTest::onEnter(); - Size s = Director::getInstance()->getWinSize(); - LayerRGBA* layer1 = LayerRGBA::create(); + auto s = Director::getInstance()->getWinSize(); + auto layer1 = LayerRGBA::create(); - Sprite *sister1 = Sprite::create("Images/grossinis_sister1.png"); - Sprite *sister2 = Sprite::create("Images/grossinis_sister2.png"); - LabelBMFont *label = LabelBMFont::create("Test", "fonts/bitmapFontTest.fnt"); + auto sister1 = Sprite::create("Images/grossinis_sister1.png"); + auto sister2 = Sprite::create("Images/grossinis_sister2.png"); + auto label = LabelBMFont::create("Test", "fonts/bitmapFontTest.fnt"); layer1->addChild(sister1); layer1->addChild(sister2); @@ -344,14 +344,14 @@ std::string LayerTestCascadingColorA::title() void LayerTestCascadingColorB::onEnter() { LayerTest::onEnter(); - Size s = Director::getInstance()->getWinSize(); - LayerColor* layer1 = LayerColor::create(Color4B(255, 255, 255, 255), s.width, s.height/2); + auto s = Director::getInstance()->getWinSize(); + auto layer1 = LayerColor::create(Color4B(255, 255, 255, 255), s.width, s.height/2); layer1->setPosition( Point(0, s.height/2)); - Sprite *sister1 = Sprite::create("Images/grossinis_sister1.png"); - Sprite *sister2 = Sprite::create("Images/grossinis_sister2.png"); - LabelBMFont *label = LabelBMFont::create("Test", "fonts/bitmapFontTest.fnt"); + auto sister1 = Sprite::create("Images/grossinis_sister1.png"); + auto sister2 = Sprite::create("Images/grossinis_sister2.png"); + auto label = LabelBMFont::create("Test", "fonts/bitmapFontTest.fnt"); layer1->addChild(sister1); layer1->addChild(sister2); @@ -396,14 +396,14 @@ std::string LayerTestCascadingColorB::title() void LayerTestCascadingColorC::onEnter() { LayerTest::onEnter(); - Size s = Director::getInstance()->getWinSize(); - LayerColor* layer1 = LayerColor::create(Color4B(255, 255, 255, 255), s.width, s.height/2); + auto s = Director::getInstance()->getWinSize(); + auto layer1 = LayerColor::create(Color4B(255, 255, 255, 255), s.width, s.height/2); layer1->setCascadeColorEnabled(false); layer1->setPosition( Point(0, s.height/2)); - Sprite *sister1 = Sprite::create("Images/grossinis_sister1.png"); - Sprite *sister2 = Sprite::create("Images/grossinis_sister2.png"); - LabelBMFont *label = LabelBMFont::create("Test", "fonts/bitmapFontTest.fnt"); + auto sister1 = Sprite::create("Images/grossinis_sister1.png"); + auto sister2 = Sprite::create("Images/grossinis_sister2.png"); + auto label = LabelBMFont::create("Test", "fonts/bitmapFontTest.fnt"); layer1->addChild(sister1); layer1->addChild(sister2); @@ -451,8 +451,8 @@ void LayerTest1::onEnter() setTouchEnabled(true); - Size s = Director::getInstance()->getWinSize(); - LayerColor* layer = LayerColor::create( Color4B(0xFF, 0x00, 0x00, 0x80), 200, 200); + auto s = Director::getInstance()->getWinSize(); + auto layer = LayerColor::create( Color4B(0xFF, 0x00, 0x00, 0x80), 200, 200); layer->ignoreAnchorPointForPosition(false); layer->setPosition( Point(s.width/2, s.height/2) ); @@ -461,11 +461,11 @@ void LayerTest1::onEnter() void LayerTest1::updateSize(Point &touchLocation) { - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Size newSize = Size( fabs(touchLocation.x - s.width/2)*2, fabs(touchLocation.y - s.height/2)*2); + auto newSize = Size( fabs(touchLocation.x - s.width/2)*2, fabs(touchLocation.y - s.height/2)*2); - LayerColor* l = (LayerColor*) getChildByTag(kTagLayer); + auto l = (LayerColor*) getChildByTag(kTagLayer); l->setContentSize( newSize ); } @@ -477,8 +477,8 @@ void LayerTest1::ccTouchesBegan(Set *touches, Event *event) void LayerTest1::ccTouchesMoved(Set *touches, Event *event) { - Touch *touch = static_cast(touches->anyObject()); - Point touchLocation = touch->getLocation(); + auto touch = static_cast(touches->anyObject()); + auto touchLocation = touch->getLocation(); updateSize(touchLocation); } @@ -502,25 +502,25 @@ void LayerTest2::onEnter() { LayerTest::onEnter(); - Size s = Director::getInstance()->getWinSize(); - LayerColor* layer1 = LayerColor::create( Color4B(255, 255, 0, 80), 100, 300); + auto s = Director::getInstance()->getWinSize(); + auto layer1 = LayerColor::create( Color4B(255, 255, 0, 80), 100, 300); layer1->setPosition(Point(s.width/3, s.height/2)); layer1->ignoreAnchorPointForPosition(false); addChild(layer1, 1); - LayerColor* layer2 = LayerColor::create( Color4B(0, 0, 255, 255), 100, 300); + auto layer2 = LayerColor::create( Color4B(0, 0, 255, 255), 100, 300); layer2->setPosition(Point((s.width/3)*2, s.height/2)); layer2->ignoreAnchorPointForPosition(false); addChild(layer2, 1); - ActionInterval* actionTint = TintBy::create(2, -255, -127, 0); - ActionInterval* actionTintBack = actionTint->reverse(); - ActionInterval* seq1 = Sequence::create( actionTint, actionTintBack, NULL); + auto actionTint = TintBy::create(2, -255, -127, 0); + auto actionTintBack = actionTint->reverse(); + auto seq1 = Sequence::create( actionTint, actionTintBack, NULL); layer1->runAction(seq1); - ActionInterval* actionFade = FadeOut::create(2.0f); - ActionInterval* actionFadeBack = actionFade->reverse(); - ActionInterval* seq2 = Sequence::create(actionFade, actionFadeBack, NULL); + auto actionFade = FadeOut::create(2.0f); + auto actionFadeBack = actionFade->reverse(); + auto seq2 = Sequence::create(actionFade, actionFadeBack, NULL); layer2->runAction(seq2); } @@ -537,11 +537,11 @@ std::string LayerTest2::title() LayerTestBlend::LayerTestBlend() { - Size s = Director::getInstance()->getWinSize(); - LayerColor* layer1 = LayerColor::create( Color4B(255, 255, 255, 80) ); + auto s = Director::getInstance()->getWinSize(); + auto layer1 = LayerColor::create( Color4B(255, 255, 255, 80) ); - Sprite* sister1 = Sprite::create(s_pathSister1); - Sprite* sister2 = Sprite::create(s_pathSister2); + auto sister1 = Sprite::create(s_pathSister1); + auto sister2 = Sprite::create(s_pathSister2); addChild(sister1); addChild(sister2); @@ -555,7 +555,7 @@ LayerTestBlend::LayerTestBlend() void LayerTestBlend::newBlend(float dt) { - LayerColor *layer = (LayerColor*)getChildByTag(kTagLayer); + auto layer = (LayerColor*)getChildByTag(kTagLayer); GLenum src; GLenum dst; @@ -588,40 +588,40 @@ std::string LayerTestBlend::title() //------------------------------------------------------------------ LayerGradientTest::LayerGradientTest() { - LayerGradient* layer1 = LayerGradient::create(Color4B(255,0,0,255), Color4B(0,255,0,255), Point(0.9f, 0.9f)); + auto layer1 = LayerGradient::create(Color4B(255,0,0,255), Color4B(0,255,0,255), Point(0.9f, 0.9f)); addChild(layer1, 0, kTagLayer); setTouchEnabled(true); - LabelTTF *label1 = LabelTTF::create("Compressed Interpolation: Enabled", "Marker Felt", 26); - LabelTTF *label2 = LabelTTF::create("Compressed Interpolation: Disabled", "Marker Felt", 26); - MenuItemLabel *item1 = MenuItemLabel::create(label1); - MenuItemLabel *item2 = MenuItemLabel::create(label2); - MenuItemToggle *item = MenuItemToggle::createWithCallback( CC_CALLBACK_1(LayerGradientTest::toggleItem, this), item1, item2, NULL); + auto label1 = LabelTTF::create("Compressed Interpolation: Enabled", "Marker Felt", 26); + auto label2 = LabelTTF::create("Compressed Interpolation: Disabled", "Marker Felt", 26); + auto item1 = MenuItemLabel::create(label1); + auto item2 = MenuItemLabel::create(label2); + auto item = MenuItemToggle::createWithCallback( CC_CALLBACK_1(LayerGradientTest::toggleItem, this), item1, item2, NULL); - Menu *menu = Menu::create(item, NULL); + auto menu = Menu::create(item, NULL); addChild(menu); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); menu->setPosition(Point(s.width / 2, 100)); } void LayerGradientTest::toggleItem(Object *sender) { - LayerGradient *gradient = static_cast( getChildByTag(kTagLayer) ); + auto gradient = static_cast( getChildByTag(kTagLayer) ); gradient->setCompressedInterpolation(! gradient->isCompressedInterpolation()); } void LayerGradientTest::ccTouchesMoved(Set * touches, Event *event) { - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Touch* touch = static_cast( touches->anyObject() ); - Point start = touch->getLocation(); + auto touch = static_cast( touches->anyObject() ); + auto start = touch->getLocation(); - Point diff = Point(s.width/2,s.height/2) - start; + auto diff = Point(s.width/2,s.height/2) - start; diff = diff.normalize(); - LayerGradient *gradient = static_cast( getChildByTag(1) ); + auto gradient = static_cast( getChildByTag(1) ); gradient->setVector(diff); } @@ -642,7 +642,7 @@ string LayerGradientTest::subtitle() //------------------------------------------------------------------ LayerGradientTest2::LayerGradientTest2() { - LayerGradient* layer = new LayerGradient; + auto layer = new LayerGradient; layer->initWithColor(Color4B(255,0,0,255), Color4B(255,255,0,255)); layer->autorelease(); addChild(layer); @@ -666,7 +666,7 @@ string LayerGradientTest2::subtitle() //------------------------------------------------------------------ LayerGradientTest3::LayerGradientTest3() { - LayerGradient* layer1 = LayerGradient::create(Color4B(255,0,0,255), Color4B(255,255,0,255)); + auto layer1 = LayerGradient::create(Color4B(255,0,0,255), Color4B(255,255,0,255)); addChild(layer1); } @@ -688,27 +688,27 @@ void LayerIgnoreAnchorPointPos::onEnter() { LayerTest::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - LayerColor *l = LayerColor::create(Color4B(255, 0, 0, 255), 150, 150); + auto l = LayerColor::create(Color4B(255, 0, 0, 255), 150, 150); l->setAnchorPoint(Point(0.5f, 0.5f)); l->setPosition(Point( s.width/2, s.height/2)); - MoveBy *move = MoveBy::create(2, Point(100,2)); - MoveBy * back = (MoveBy *)move->reverse(); - Sequence *seq = Sequence::create(move, back, NULL); + auto move = MoveBy::create(2, Point(100,2)); + auto back = (MoveBy *)move->reverse(); + auto seq = Sequence::create(move, back, NULL); l->runAction(RepeatForever::create(seq)); this->addChild(l, 0, kLayerIgnoreAnchorPoint); - Sprite *child = Sprite::create("Images/grossini.png"); + auto child = Sprite::create("Images/grossini.png"); l->addChild(child); - Size lsize = l->getContentSize(); + auto lsize = l->getContentSize(); child->setPosition(Point(lsize.width/2, lsize.height/2)); - MenuItemFont *item = MenuItemFont::create("Toggle ignore anchor point", CC_CALLBACK_1(LayerIgnoreAnchorPointPos::onToggle, this)); + auto item = MenuItemFont::create("Toggle ignore anchor point", CC_CALLBACK_1(LayerIgnoreAnchorPointPos::onToggle, this)); - Menu *menu = Menu::create(item, NULL); + auto menu = Menu::create(item, NULL); this->addChild(menu); menu->setPosition(Point(s.width/2, s.height/2)); @@ -716,7 +716,7 @@ void LayerIgnoreAnchorPointPos::onEnter() void LayerIgnoreAnchorPointPos::onToggle(Object* pObject) { - Node* layer = this->getChildByTag(kLayerIgnoreAnchorPoint); + auto layer = this->getChildByTag(kLayerIgnoreAnchorPoint); bool ignore = layer->isIgnoreAnchorPointForPosition(); layer->ignoreAnchorPointForPosition(! ignore); } @@ -736,27 +736,27 @@ std::string LayerIgnoreAnchorPointPos::subtitle() void LayerIgnoreAnchorPointRot::onEnter() { LayerTest::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - LayerColor *l = LayerColor::create(Color4B(255, 0, 0, 255), 200, 200); + auto l = LayerColor::create(Color4B(255, 0, 0, 255), 200, 200); l->setAnchorPoint(Point(0.5f, 0.5f)); l->setPosition(Point( s.width/2, s.height/2)); this->addChild(l, 0, kLayerIgnoreAnchorPoint); - RotateBy *rot = RotateBy::create(2, 360); + auto rot = RotateBy::create(2, 360); l->runAction(RepeatForever::create(rot)); - Sprite *child = Sprite::create("Images/grossini.png"); + auto child = Sprite::create("Images/grossini.png"); l->addChild(child); - Size lsize = l->getContentSize(); + auto lsize = l->getContentSize(); child->setPosition(Point(lsize.width/2, lsize.height/2)); - MenuItemFont *item = MenuItemFont::create("Toogle ignore anchor point", CC_CALLBACK_1(LayerIgnoreAnchorPointRot::onToggle, this)); + auto item = MenuItemFont::create("Toogle ignore anchor point", CC_CALLBACK_1(LayerIgnoreAnchorPointRot::onToggle, this)); - Menu *menu = Menu::create(item, NULL); + auto menu = Menu::create(item, NULL); this->addChild(menu); menu->setPosition(Point(s.width/2, s.height/2)); @@ -764,7 +764,7 @@ void LayerIgnoreAnchorPointRot::onEnter() void LayerIgnoreAnchorPointRot::onToggle(Object* pObject) { - Node* layer = this->getChildByTag(kLayerIgnoreAnchorPoint); + auto layer = this->getChildByTag(kLayerIgnoreAnchorPoint); bool ignore = layer->isIgnoreAnchorPointForPosition(); layer->ignoreAnchorPointForPosition(! ignore); } @@ -784,30 +784,30 @@ void LayerIgnoreAnchorPointScale::onEnter() { LayerTest::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - LayerColor *l = LayerColor::create(Color4B(255, 0, 0, 255), 200, 200); + auto l = LayerColor::create(Color4B(255, 0, 0, 255), 200, 200); l->setAnchorPoint(Point(0.5f, 1.0f)); l->setPosition(Point( s.width/2, s.height/2)); - ScaleBy *scale = ScaleBy::create(2, 2); - ScaleBy* back = (ScaleBy*)scale->reverse(); - Sequence *seq = Sequence::create(scale, back, NULL); + auto scale = ScaleBy::create(2, 2); + auto back = (ScaleBy*)scale->reverse(); + auto seq = Sequence::create(scale, back, NULL); l->runAction(RepeatForever::create(seq)); this->addChild(l, 0, kLayerIgnoreAnchorPoint); - Sprite *child = Sprite::create("Images/grossini.png"); + auto child = Sprite::create("Images/grossini.png"); l->addChild(child); - Size lsize = l->getContentSize(); + auto lsize = l->getContentSize(); child->setPosition(Point(lsize.width/2, lsize.height/2)); - MenuItemFont *item = MenuItemFont::create("Toogle ignore anchor point", CC_CALLBACK_1(LayerIgnoreAnchorPointScale::onToggle, this)); + auto item = MenuItemFont::create("Toogle ignore anchor point", CC_CALLBACK_1(LayerIgnoreAnchorPointScale::onToggle, this)); - Menu *menu = Menu::create(item, NULL); + auto menu = Menu::create(item, NULL); this->addChild(menu); menu->setPosition(Point(s.width/2, s.height/2)); @@ -815,7 +815,7 @@ void LayerIgnoreAnchorPointScale::onEnter() void LayerIgnoreAnchorPointScale::onToggle(Object* pObject) { - Node* layer = this->getChildByTag(kLayerIgnoreAnchorPoint); + auto layer = this->getChildByTag(kLayerIgnoreAnchorPoint); bool ignore = layer->isIgnoreAnchorPointForPosition(); layer->ignoreAnchorPointForPosition(! ignore); } @@ -833,7 +833,7 @@ std::string LayerIgnoreAnchorPointScale::subtitle() void LayerTestScene::runThisTest() { sceneIdx = -1; - Layer* layer = nextAction(); + auto layer = nextAction(); addChild(layer); Director::getInstance()->replaceScene(this); @@ -841,17 +841,17 @@ void LayerTestScene::runThisTest() LayerExtendedBlendOpacityTest::LayerExtendedBlendOpacityTest() { - LayerGradient* layer1 = LayerGradient::create(Color4B(255, 0, 0, 255), Color4B(255, 0, 255, 255)); + auto layer1 = LayerGradient::create(Color4B(255, 0, 0, 255), Color4B(255, 0, 255, 255)); layer1->setContentSize(Size(80, 80)); layer1->setPosition(Point(50,50)); addChild(layer1); - LayerGradient* layer2 = LayerGradient::create(Color4B(0, 0, 0, 127), Color4B(255, 255, 255, 127)); + auto layer2 = LayerGradient::create(Color4B(0, 0, 0, 127), Color4B(255, 255, 255, 127)); layer2->setContentSize(Size(80, 80)); layer2->setPosition(Point(100,90)); addChild(layer2); - LayerGradient* layer3 = LayerGradient::create(); + auto layer3 = LayerGradient::create(); layer3->setContentSize(Size(80, 80)); layer3->setPosition(Point(150,140)); layer3->setStartColor(Color3B(255, 0, 0)); diff --git a/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.cpp b/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.cpp index 444ced5b9e..d451df8bbb 100644 --- a/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.cpp +++ b/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.cpp @@ -30,23 +30,23 @@ MenuLayerMainMenu::MenuLayerMainMenu() setTouchMode(Touch::DispatchMode::ONE_BY_ONE); // Font Item - Sprite* spriteNormal = Sprite::create(s_MenuItem, Rect(0,23*2,115,23)); - Sprite* spriteSelected = Sprite::create(s_MenuItem, Rect(0,23*1,115,23)); - Sprite* spriteDisabled = Sprite::create(s_MenuItem, Rect(0,23*0,115,23)); + auto spriteNormal = Sprite::create(s_MenuItem, Rect(0,23*2,115,23)); + auto spriteSelected = Sprite::create(s_MenuItem, Rect(0,23*1,115,23)); + auto spriteDisabled = Sprite::create(s_MenuItem, Rect(0,23*0,115,23)); - MenuItemSprite* item1 = MenuItemSprite::create(spriteNormal, spriteSelected, spriteDisabled, CC_CALLBACK_1(MenuLayerMainMenu::menuCallback, this) ); + auto item1 = MenuItemSprite::create(spriteNormal, spriteSelected, spriteDisabled, CC_CALLBACK_1(MenuLayerMainMenu::menuCallback, this) ); // Image Item - MenuItem* item2 = MenuItemImage::create(s_SendScore, s_PressSendScore, CC_CALLBACK_1(MenuLayerMainMenu::menuCallback2, this) ); + auto item2 = MenuItemImage::create(s_SendScore, s_PressSendScore, CC_CALLBACK_1(MenuLayerMainMenu::menuCallback2, this) ); // Label Item (LabelAtlas) - LabelAtlas* labelAtlas = LabelAtlas::create("0123456789", "fonts/labelatlas.png", 16, 24, '.'); - MenuItemLabel* item3 = MenuItemLabel::create(labelAtlas, CC_CALLBACK_1(MenuLayerMainMenu::menuCallbackDisabled, this) ); + auto labelAtlas = LabelAtlas::create("0123456789", "fonts/labelatlas.png", 16, 24, '.'); + auto item3 = MenuItemLabel::create(labelAtlas, CC_CALLBACK_1(MenuLayerMainMenu::menuCallbackDisabled, this) ); item3->setDisabledColor( Color3B(32,32,64) ); item3->setColor( Color3B(200,200,255) ); // Font Item - MenuItemFont *item4 = MenuItemFont::create("I toggle enable items", [&](Object *sender) { + auto item4 = MenuItemFont::create("I toggle enable items", [&](Object *sender) { _disabledItem->setEnabled(! _disabledItem->isEnabled() ); }); @@ -54,39 +54,39 @@ MenuLayerMainMenu::MenuLayerMainMenu() item4->setFontName("Marker Felt"); // Label Item (LabelBMFont) - LabelBMFont* label = LabelBMFont::create("configuration", "fonts/bitmapFontTest3.fnt"); - MenuItemLabel* item5 = MenuItemLabel::create(label, CC_CALLBACK_1(MenuLayerMainMenu::menuCallbackConfig, this)); + auto label = LabelBMFont::create("configuration", "fonts/bitmapFontTest3.fnt"); + auto item5 = MenuItemLabel::create(label, CC_CALLBACK_1(MenuLayerMainMenu::menuCallbackConfig, this)); // Testing issue #500 item5->setScale( 0.8f ); // Events MenuItemFont::setFontName("Marker Felt"); - MenuItemFont *item6 = MenuItemFont::create("Priority Test", CC_CALLBACK_1(MenuLayerMainMenu::menuCallbackPriorityTest, this)); + auto item6 = MenuItemFont::create("Priority Test", CC_CALLBACK_1(MenuLayerMainMenu::menuCallbackPriorityTest, this)); // Bugs Item - MenuItemFont *item7 = MenuItemFont::create("Bugs", CC_CALLBACK_1(MenuLayerMainMenu::menuCallbackBugsTest, this)); + auto item7 = MenuItemFont::create("Bugs", CC_CALLBACK_1(MenuLayerMainMenu::menuCallbackBugsTest, this)); // Font Item - MenuItemFont* item8 = MenuItemFont::create("Quit", CC_CALLBACK_1(MenuLayerMainMenu::onQuit, this)); + auto item8 = MenuItemFont::create("Quit", CC_CALLBACK_1(MenuLayerMainMenu::onQuit, this)); - MenuItemFont* item9 = MenuItemFont::create("Remove menu item when moving", CC_CALLBACK_1(MenuLayerMainMenu::menuMovingCallback, this)); + auto item9 = MenuItemFont::create("Remove menu item when moving", CC_CALLBACK_1(MenuLayerMainMenu::menuMovingCallback, this)); - ActionInterval* color_action = TintBy::create(0.5f, 0, -255, -255); - ActionInterval* color_back = color_action->reverse(); - Sequence* seq = Sequence::create(color_action, color_back, NULL); + auto color_action = TintBy::create(0.5f, 0, -255, -255); + auto color_back = color_action->reverse(); + auto seq = Sequence::create(color_action, color_back, NULL); item8->runAction(RepeatForever::create(seq)); - Menu* menu = Menu::create( item1, item2, item3, item4, item5, item6, item7, item8, item9, NULL); + auto menu = Menu::create( item1, item2, item3, item4, item5, item6, item7, item8, item9, NULL); menu->alignItemsVertically(); // elastic effect - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); int i=0; Node* child; - Array * pArray = menu->getChildren(); + auto pArray = menu->getChildren(); Object* pObject = NULL; CCARRAY_FOREACH(pArray, pObject) { @@ -95,7 +95,7 @@ MenuLayerMainMenu::MenuLayerMainMenu() child = static_cast(pObject); - Point dstPoint = child->getPosition(); + auto dstPoint = child->getPosition(); int offset = (int) (s.width/2 + 50); if( i % 2 == 0) offset = -offset; @@ -148,7 +148,7 @@ void MenuLayerMainMenu::menuCallbackConfig(Object* sender) void MenuLayerMainMenu::allowTouches(float dt) { - Director* director = Director::getInstance(); + auto director = Director::getInstance(); director->getTouchDispatcher()->setPriority(Menu::HANDLER_PRIORITY+1, this); unscheduleAllSelectors(); log("TOUCHES ALLOWED AGAIN"); @@ -157,7 +157,7 @@ void MenuLayerMainMenu::allowTouches(float dt) void MenuLayerMainMenu::menuCallbackDisabled(Object* sender) { // hijack all touch events for 5 seconds - Director* director = Director::getInstance(); + auto director = Director::getInstance(); director->getTouchDispatcher()->setPriority(Menu::HANDLER_PRIORITY-1, this); schedule(schedule_selector(MenuLayerMainMenu::allowTouches), 5.0f); log("TOUCHES DISABLED FOR 5 SECONDS"); @@ -198,17 +198,17 @@ MenuLayer2::MenuLayer2() { for( int i=0;i < 2;i++ ) { - MenuItemImage* item1 = MenuItemImage::create(s_PlayNormal, s_PlaySelect, CC_CALLBACK_1(MenuLayer2::menuCallback, this)); - MenuItemImage* item2 = MenuItemImage::create(s_HighNormal, s_HighSelect, CC_CALLBACK_1(MenuLayer2::menuCallbackOpacity, this)); - MenuItemImage* item3 = MenuItemImage::create(s_AboutNormal, s_AboutSelect, CC_CALLBACK_1(MenuLayer2::menuCallbackAlign, this)); + auto item1 = MenuItemImage::create(s_PlayNormal, s_PlaySelect, CC_CALLBACK_1(MenuLayer2::menuCallback, this)); + auto item2 = MenuItemImage::create(s_HighNormal, s_HighSelect, CC_CALLBACK_1(MenuLayer2::menuCallbackOpacity, this)); + auto item3 = MenuItemImage::create(s_AboutNormal, s_AboutSelect, CC_CALLBACK_1(MenuLayer2::menuCallbackAlign, this)); item1->setScaleX( 1.5f ); item2->setScaleX( 0.5f ); item3->setScaleX( 0.5f ); - Menu* menu = Menu::create(item1, item2, item3, NULL); + auto menu = Menu::create(item1, item2, item3, NULL); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); menu->setPosition(Point(s.width/2, s.height/2)); menu->setTag( kTagMenu ); @@ -230,13 +230,13 @@ void MenuLayer2::alignMenusH() { for(int i=0;i<2;i++) { - Menu *menu = static_cast( getChildByTag(100+i) ); + auto menu = static_cast( getChildByTag(100+i) ); menu->setPosition( _centeredMenu ); if(i==0) { // TIP: if no padding, padding = 5 menu->alignItemsHorizontally(); - Point p = menu->getPosition(); + auto p = menu->getPosition(); menu->setPosition(p + Point(0,30)); } @@ -244,7 +244,7 @@ void MenuLayer2::alignMenusH() { // TIP: but padding is configurable menu->alignItemsHorizontallyWithPadding(40); - Point p = menu->getPosition(); + auto p = menu->getPosition(); menu->setPosition(p - Point(0,30)); } } @@ -254,20 +254,20 @@ void MenuLayer2::alignMenusV() { for(int i=0;i<2;i++) { - Menu *menu = static_cast( getChildByTag(100+i) ); + auto menu = static_cast( getChildByTag(100+i) ); menu->setPosition( _centeredMenu ); if(i==0) { // TIP: if no padding, padding = 5 menu->alignItemsVertically(); - Point p = menu->getPosition(); + auto p = menu->getPosition(); menu->setPosition(p + Point(100,0)); } else { // TIP: but padding is configurable menu->alignItemsVerticallyWithPadding(40); - Point p = menu->getPosition(); + auto p = menu->getPosition(); menu->setPosition(p - Point(100,0)); } } @@ -280,7 +280,7 @@ void MenuLayer2::menuCallback(Object* sender) void MenuLayer2::menuCallbackOpacity(Object* sender) { - Menu* menu = static_cast( static_cast(sender)->getParent() ); + auto menu = static_cast( static_cast(sender)->getParent() ); GLubyte opacity = menu->getOpacity(); if( opacity == 128 ) menu->setOpacity(255); @@ -308,42 +308,42 @@ MenuLayer3::MenuLayer3() MenuItemFont::setFontName("Marker Felt"); MenuItemFont::setFontSize(28); - LabelBMFont* label = LabelBMFont::create("Enable AtlasItem", "fonts/bitmapFontTest3.fnt"); - MenuItemLabel* item1 = MenuItemLabel::create(label, [&](Object *sender) { + auto label = LabelBMFont::create("Enable AtlasItem", "fonts/bitmapFontTest3.fnt"); + auto item1 = MenuItemLabel::create(label, [&](Object *sender) { //CCLOG("Label clicked. Toogling AtlasSprite"); _disabledItem->setEnabled( ! _disabledItem->isEnabled() ); _disabledItem->stopAllActions(); }); - MenuItemFont* item2 = MenuItemFont::create("--- Go Back ---", [&](Object *sender) { + auto item2 = MenuItemFont::create("--- Go Back ---", [&](Object *sender) { static_cast(_parent)->switchTo(0); }); - Sprite *spriteNormal = Sprite::create(s_MenuItem, Rect(0,23*2,115,23)); - Sprite *spriteSelected = Sprite::create(s_MenuItem, Rect(0,23*1,115,23)); - Sprite *spriteDisabled = Sprite::create(s_MenuItem, Rect(0,23*0,115,23)); + auto spriteNormal = Sprite::create(s_MenuItem, Rect(0,23*2,115,23)); + auto spriteSelected = Sprite::create(s_MenuItem, Rect(0,23*1,115,23)); + auto spriteDisabled = Sprite::create(s_MenuItem, Rect(0,23*0,115,23)); - MenuItemSprite* item3 = MenuItemSprite::create(spriteNormal, spriteSelected, spriteDisabled, [](Object *sender) { + auto item3 = MenuItemSprite::create(spriteNormal, spriteSelected, spriteDisabled, [](Object *sender) { log("sprite clicked!"); }); _disabledItem = item3; item3->retain(); _disabledItem->setEnabled( false ); - Menu *menu = Menu::create( item1, item2, item3, NULL); + auto menu = Menu::create( item1, item2, item3, NULL); menu->setPosition( Point(0,0) ); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); item1->setPosition( Point(s.width/2 - 150, s.height/2) ); item2->setPosition( Point(s.width/2 - 200, s.height/2) ); item3->setPosition( Point(s.width/2, s.height/2 - 100) ); - JumpBy* jump = JumpBy::create(3, Point(400,0), 50, 4); + auto jump = JumpBy::create(3, Point(400,0), 50, 4); item2->runAction( RepeatForever::create(Sequence::create( jump, jump->reverse(), NULL))); - ActionInterval* spin1 = RotateBy::create(3, 360); - ActionInterval* spin2 = spin1->clone(); - ActionInterval* spin3 = spin1->clone(); + auto spin1 = RotateBy::create(3, 360); + auto spin2 = spin1->clone(); + auto spin3 = spin1->clone(); item1->runAction( RepeatForever::create(spin1) ); item2->runAction( RepeatForever::create(spin2) ); @@ -368,48 +368,48 @@ MenuLayer4::MenuLayer4() { MenuItemFont::setFontName("American Typewriter"); MenuItemFont::setFontSize(18); - MenuItemFont*title1 = MenuItemFont::create("Sound"); + auto title1 = MenuItemFont::create("Sound"); title1->setEnabled(false); MenuItemFont::setFontName( "Marker Felt" ); MenuItemFont::setFontSize(34); - MenuItemToggle* item1 = MenuItemToggle::createWithCallback( CC_CALLBACK_1(MenuLayer4::menuCallback, this), + auto item1 = MenuItemToggle::createWithCallback( CC_CALLBACK_1(MenuLayer4::menuCallback, this), MenuItemFont::create( "On" ), MenuItemFont::create( "Off"), NULL ); MenuItemFont::setFontName( "American Typewriter" ); MenuItemFont::setFontSize(18); - MenuItemFont* title2 = MenuItemFont::create( "Music" ); + auto title2 = MenuItemFont::create( "Music" ); title2->setEnabled(false); MenuItemFont::setFontName( "Marker Felt" ); MenuItemFont::setFontSize(34); - MenuItemToggle *item2 = MenuItemToggle::createWithCallback(CC_CALLBACK_1(MenuLayer4::menuCallback, this), + auto item2 = MenuItemToggle::createWithCallback(CC_CALLBACK_1(MenuLayer4::menuCallback, this), MenuItemFont::create( "On" ), MenuItemFont::create( "Off"), NULL ); MenuItemFont::setFontName( "American Typewriter" ); MenuItemFont::setFontSize(18); - MenuItemFont* title3 = MenuItemFont::create( "Quality" ); + auto title3 = MenuItemFont::create( "Quality" ); title3->setEnabled( false ); MenuItemFont::setFontName( "Marker Felt" ); MenuItemFont::setFontSize(34); - MenuItemToggle *item3 = MenuItemToggle::createWithCallback(CC_CALLBACK_1(MenuLayer4::menuCallback, this), + auto item3 = MenuItemToggle::createWithCallback(CC_CALLBACK_1(MenuLayer4::menuCallback, this), MenuItemFont::create( "High" ), MenuItemFont::create( "Low" ), NULL ); MenuItemFont::setFontName( "American Typewriter" ); MenuItemFont::setFontSize(18); - MenuItemFont* title4 = MenuItemFont::create( "Orientation" ); + auto title4 = MenuItemFont::create( "Orientation" ); title4->setEnabled(false); MenuItemFont::setFontName( "Marker Felt" ); MenuItemFont::setFontSize(34); - MenuItemToggle *item4 = MenuItemToggle::createWithCallback(CC_CALLBACK_1(MenuLayer4::menuCallback, this), + auto item4 = MenuItemToggle::createWithCallback(CC_CALLBACK_1(MenuLayer4::menuCallback, this), MenuItemFont::create( "Off" ), NULL ); - //UxArray* more_items = UxArray::arrayWithObjects( + //auto more_items = UxArray::arrayWithObjects( // MenuItemFont::create( "33%" ), // MenuItemFont::create( "66%" ), // MenuItemFont::create( "100%" ), @@ -425,10 +425,10 @@ MenuLayer4::MenuLayer4() MenuItemFont::setFontName( "Marker Felt" ); MenuItemFont::setFontSize( 34 ); - LabelBMFont *label = LabelBMFont::create( "go back", "fonts/bitmapFontTest3.fnt" ); - MenuItemLabel* back = MenuItemLabel::create(label, CC_CALLBACK_1(MenuLayer4::backCallback, this) ); + auto label = LabelBMFont::create( "go back", "fonts/bitmapFontTest3.fnt" ); + auto back = MenuItemLabel::create(label, CC_CALLBACK_1(MenuLayer4::backCallback, this) ); - Menu *menu = Menu::create( + auto menu = Menu::create( title1, title2, item1, item2, title3, title4, @@ -439,7 +439,7 @@ MenuLayer4::MenuLayer4() addChild( menu ); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); menu->setPosition(Point(s.width/2, s.height/2)); } @@ -467,14 +467,14 @@ MenuLayerPriorityTest::MenuLayerPriorityTest() // Menu 1 MenuItemFont::setFontName("Marker Felt"); MenuItemFont::setFontSize(18); - MenuItemFont *item1 = MenuItemFont::create("Return to Main Menu", CC_CALLBACK_1(MenuLayerPriorityTest::menuCallback, this)); - MenuItemFont *item2 = MenuItemFont::create("Disable menu for 5 seconds", [&](Object *sender) { + auto item1 = MenuItemFont::create("Return to Main Menu", CC_CALLBACK_1(MenuLayerPriorityTest::menuCallback, this)); + auto item2 = MenuItemFont::create("Disable menu for 5 seconds", [&](Object *sender) { _menu1->setEnabled(false); - DelayTime *wait = DelayTime::create(5); - CallFunc *enable = CallFunc::create( [&]() { + auto wait = DelayTime::create(5); + auto enable = CallFunc::create( [&]() { _menu1->setEnabled(true); }); - Sequence* seq = Sequence::create(wait, enable, NULL); + auto seq = Sequence::create(wait, enable, NULL); _menu1->runAction(seq); }); @@ -518,21 +518,21 @@ void MenuLayerPriorityTest::menuCallback(Object* sender) // BugsTest BugsTest::BugsTest() { - MenuItemFont *issue1410 = MenuItemFont::create("Issue 1410", CC_CALLBACK_1(BugsTest::issue1410MenuCallback, this)); - MenuItemFont *issue1410_2 = MenuItemFont::create("Issue 1410 #2", CC_CALLBACK_1(BugsTest::issue1410v2MenuCallback, this)); - MenuItemFont *back = MenuItemFont::create("Back", CC_CALLBACK_1(BugsTest::backMenuCallback, this)); + auto issue1410 = MenuItemFont::create("Issue 1410", CC_CALLBACK_1(BugsTest::issue1410MenuCallback, this)); + auto issue1410_2 = MenuItemFont::create("Issue 1410 #2", CC_CALLBACK_1(BugsTest::issue1410v2MenuCallback, this)); + auto back = MenuItemFont::create("Back", CC_CALLBACK_1(BugsTest::backMenuCallback, this)); - Menu *menu = Menu::create(issue1410, issue1410_2, back, NULL); + auto menu = Menu::create(issue1410, issue1410_2, back, NULL); addChild(menu); menu->alignItemsVertically(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); menu->setPosition(Point(s.width/2, s.height/2)); } void BugsTest::issue1410MenuCallback(Object *sender) { - Menu *menu = static_cast( static_cast(sender)->getParent() ); + auto menu = static_cast( static_cast(sender)->getParent() ); menu->setTouchEnabled(false); menu->setTouchEnabled(true); @@ -541,7 +541,7 @@ void BugsTest::issue1410MenuCallback(Object *sender) void BugsTest::issue1410v2MenuCallback(cocos2d::Object *pSender) { - Menu *menu = static_cast( static_cast(pSender)->getParent() ); + auto menu = static_cast( static_cast(pSender)->getParent() ); menu->setTouchEnabled(true); menu->setTouchEnabled(false); @@ -555,18 +555,18 @@ void BugsTest::backMenuCallback(cocos2d::Object *pSender) RemoveMenuItemWhenMove::RemoveMenuItemWhenMove() { - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - LabelTTF* label = LabelTTF::create("click item and move, should not crash", "Arial", 20); + auto label = LabelTTF::create("click item and move, should not crash", "Arial", 20); label->setPosition(Point(s.width/2, s.height - 30)); addChild(label); item = MenuItemFont::create("item 1"); item->retain(); - MenuItemFont *back = MenuItemFont::create("go back", CC_CALLBACK_1(RemoveMenuItemWhenMove::goBack, this)); + auto back = MenuItemFont::create("go back", CC_CALLBACK_1(RemoveMenuItemWhenMove::goBack, this)); - Menu *menu = Menu::create(item, back, NULL); + auto menu = Menu::create(item, back, NULL); addChild(menu); menu->alignItemsVertically(); @@ -607,15 +607,15 @@ void RemoveMenuItemWhenMove::ccTouchMoved(Touch *touch, Event *event) void MenuTestScene::runThisTest() { - Layer* layer1 = new MenuLayerMainMenu(); - Layer* layer2 = new MenuLayer2(); - Layer* layer3 = new MenuLayer3(); - Layer* layer4 = new MenuLayer4(); - Layer* layer5 = new MenuLayerPriorityTest(); - Layer* layer6 = new BugsTest(); - Layer* layer7 = new RemoveMenuItemWhenMove(); + auto layer1 = new MenuLayerMainMenu(); + auto layer2 = new MenuLayer2(); + auto layer3 = new MenuLayer3(); + auto layer4 = new MenuLayer4(); + auto layer5 = new MenuLayerPriorityTest(); + auto layer6 = new BugsTest(); + auto layer7 = new RemoveMenuItemWhenMove(); - LayerMultiplex* layer = LayerMultiplex::create(layer1, layer2, layer3, layer4, layer5, layer6, layer7, NULL); + auto layer = LayerMultiplex::create(layer1, layer2, layer3, layer4, layer5, layer6, layer7, NULL); addChild(layer, 0); layer1->release(); diff --git a/samples/Cpp/TestCpp/Classes/MotionStreakTest/MotionStreakTest.cpp b/samples/Cpp/TestCpp/Classes/MotionStreakTest/MotionStreakTest.cpp index 54aaf4db86..fe19125ead 100644 --- a/samples/Cpp/TestCpp/Classes/MotionStreakTest/MotionStreakTest.cpp +++ b/samples/Cpp/TestCpp/Classes/MotionStreakTest/MotionStreakTest.cpp @@ -27,7 +27,7 @@ Layer* nextMotionAction() sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - Layer* layer = (createFunctions[sceneIdx])(); + auto layer = (createFunctions[sceneIdx])(); layer->autorelease(); return layer; @@ -40,7 +40,7 @@ Layer* backMotionAction() if( sceneIdx < 0 ) sceneIdx += total; - Layer* layer = (createFunctions[sceneIdx])(); + auto layer = (createFunctions[sceneIdx])(); layer->autorelease(); return layer; @@ -48,7 +48,7 @@ Layer* backMotionAction() Layer* restartMotionAction() { - Layer* layer = (createFunctions[sceneIdx])(); + auto layer = (createFunctions[sceneIdx])(); layer->autorelease(); return layer; @@ -63,7 +63,7 @@ void MotionStreakTest1::onEnter() { MotionStreakTest::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); // the root object just rotates around _root = Sprite::create(s_pathR1); @@ -81,14 +81,14 @@ void MotionStreakTest1::onEnter() // schedule an update on each frame so we can syncronize the streak with the target schedule(schedule_selector(MotionStreakTest1::onUpdate)); - ActionInterval* a1 = RotateBy::create(2, 360); + auto a1 = RotateBy::create(2, 360); - Action* action1 = RepeatForever::create(a1); - ActionInterval* motion = MoveBy::create(2, Point(100,0) ); + auto action1 = RepeatForever::create(a1); + auto motion = MoveBy::create(2, Point(100,0) ); _root->runAction( RepeatForever::create(Sequence::create(motion, motion->reverse(), NULL) ) ); _root->runAction( action1 ); - ActionInterval *colorAction = RepeatForever::create(Sequence::create( + auto colorAction = RepeatForever::create(Sequence::create( TintTo::create(0.2f, 255, 0, 0), TintTo::create(0.2f, 0, 255, 0), TintTo::create(0.2f, 0, 0, 255), @@ -123,7 +123,7 @@ void MotionStreakTest2::onEnter() setTouchEnabled(true); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); // create the streak object and add it to the scene streak = MotionStreak::create(3, 3, 64, Color3B::WHITE, s_streak ); @@ -134,9 +134,9 @@ void MotionStreakTest2::onEnter() void MotionStreakTest2::ccTouchesMoved(Set* touches, Event* event) { - Touch* touch = static_cast( touches->anyObject() ); + auto touch = static_cast( touches->anyObject() ); - Point touchLocation = touch->getLocation(); + auto touchLocation = touch->getLocation(); streak->setPosition( touchLocation ); } @@ -157,7 +157,7 @@ void Issue1358::onEnter() MotionStreakTest::onEnter(); // ask director the the window size - Size size = Director::getInstance()->getWinSize(); + auto size = Director::getInstance()->getWinSize(); streak = MotionStreak::create(2.0f, 1.0f, 50.0f, Color3B(255, 255, 0), "Images/Icon.png"); addChild(streak); @@ -215,14 +215,14 @@ void MotionStreakTest::onEnter() { BaseTest::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - MenuItemToggle *itemMode = MenuItemToggle::createWithCallback( CC_CALLBACK_1(MotionStreakTest::modeCallback, this), + auto itemMode = MenuItemToggle::createWithCallback( CC_CALLBACK_1(MotionStreakTest::modeCallback, this), MenuItemFont::create("Use High Quality Mode"), MenuItemFont::create("Use Fast Mode"), NULL); - Menu *menuMode = Menu::create(itemMode, NULL); + auto menuMode = Menu::create(itemMode, NULL); addChild(menuMode); menuMode->setPosition(Point(s.width/2, s.height/4)); @@ -236,7 +236,7 @@ void MotionStreakTest::modeCallback(Object *pSender) void MotionStreakTest::restartCallback(Object* sender) { - Scene* s = new MotionStreakTestScene();//CCScene::create(); + auto s = new MotionStreakTestScene();//CCScene::create(); s->addChild(restartMotionAction()); Director::getInstance()->replaceScene(s); @@ -245,7 +245,7 @@ void MotionStreakTest::restartCallback(Object* sender) void MotionStreakTest::nextCallback(Object* sender) { - Scene* s = new MotionStreakTestScene();//CCScene::create(); + auto s = new MotionStreakTestScene();//CCScene::create(); s->addChild( nextMotionAction() ); Director::getInstance()->replaceScene(s); s->release(); @@ -253,7 +253,7 @@ void MotionStreakTest::nextCallback(Object* sender) void MotionStreakTest::backCallback(Object* sender) { - Scene* s = new MotionStreakTestScene;//CCScene::create(); + auto s = new MotionStreakTestScene;//CCScene::create(); s->addChild( backMotionAction() ); Director::getInstance()->replaceScene(s); s->release(); @@ -261,7 +261,7 @@ void MotionStreakTest::backCallback(Object* sender) void MotionStreakTestScene::runThisTest() { - Layer* layer = nextMotionAction(); + auto layer = nextMotionAction(); addChild(layer); Director::getInstance()->replaceScene(this); diff --git a/samples/Cpp/TestCpp/Classes/MutiTouchTest/MutiTouchTest.cpp b/samples/Cpp/TestCpp/Classes/MutiTouchTest/MutiTouchTest.cpp index 1ebfc2d410..b11e790ad7 100644 --- a/samples/Cpp/TestCpp/Classes/MutiTouchTest/MutiTouchTest.cpp +++ b/samples/Cpp/TestCpp/Classes/MutiTouchTest/MutiTouchTest.cpp @@ -40,7 +40,7 @@ public: static TouchPoint* touchPointWithParent(Node* pParent) { - TouchPoint* pRet = new TouchPoint(); + auto pRet = new TouchPoint(); pRet->setContentSize(pParent->getContentSize()); pRet->setAnchorPoint(Point(0.0f, 0.0f)); pRet->autorelease(); @@ -74,9 +74,9 @@ void MutiTouchTestLayer::ccTouchesBegan(Set *touches, Event *event) for ( auto &item: *touches ) { - Touch* touch = static_cast(item); - TouchPoint* touchPoint = TouchPoint::touchPointWithParent(this); - Point location = touch->getLocation(); + auto touch = static_cast(item); + auto touchPoint = TouchPoint::touchPointWithParent(this); + auto location = touch->getLocation(); touchPoint->setTouchPos(location); touchPoint->setTouchColor(*s_TouchColors[touch->getID()]); @@ -92,9 +92,9 @@ void MutiTouchTestLayer::ccTouchesMoved(Set *touches, Event *event) { for( auto &item: *touches) { - Touch* touch = static_cast(item); - TouchPoint* pTP = static_cast(s_dic.objectForKey(touch->getID())); - Point location = touch->getLocation(); + auto touch = static_cast(item); + auto pTP = static_cast(s_dic.objectForKey(touch->getID())); + auto location = touch->getLocation(); pTP->setTouchPos(location); } } @@ -103,8 +103,8 @@ void MutiTouchTestLayer::ccTouchesEnded(Set *touches, Event *event) { for ( auto &item: *touches ) { - Touch* touch = static_cast(item); - TouchPoint* pTP = static_cast(s_dic.objectForKey(touch->getID())); + auto touch = static_cast(item); + auto pTP = static_cast(s_dic.objectForKey(touch->getID())); removeChild(pTP, true); s_dic.removeObjectForKey(touch->getID()); } @@ -117,7 +117,7 @@ void MutiTouchTestLayer::ccTouchesCancelled(Set *touches, Event *event) void MutiTouchTestScene::runThisTest() { - MutiTouchTestLayer* layer = MutiTouchTestLayer::create(); + auto layer = MutiTouchTestLayer::create(); addChild(layer, 0); diff --git a/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.cpp b/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.cpp index d48313c472..7cbb822c52 100644 --- a/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.cpp +++ b/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.cpp @@ -52,7 +52,7 @@ Layer* nextCocosNodeAction() sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - Layer* layer = createCocosNodeLayer(sceneIdx); + auto layer = createCocosNodeLayer(sceneIdx); layer->autorelease(); return layer; @@ -65,7 +65,7 @@ Layer* backCocosNodeAction() if( sceneIdx < 0 ) sceneIdx += total; - Layer* layer = createCocosNodeLayer(sceneIdx); + auto layer = createCocosNodeLayer(sceneIdx); layer->autorelease(); return layer; @@ -73,7 +73,7 @@ Layer* backCocosNodeAction() Layer* restartCocosNodeAction() { - Layer* layer = createCocosNodeLayer(sceneIdx); + auto layer = createCocosNodeLayer(sceneIdx); layer->autorelease(); return layer; @@ -105,7 +105,7 @@ void TestCocosNodeDemo::onEnter() void TestCocosNodeDemo::restartCallback(Object* sender) { - Scene* s = new CocosNodeTestScene();//CCScene::create(); + auto s = new CocosNodeTestScene();//CCScene::create(); s->addChild(restartCocosNodeAction()); Director::getInstance()->replaceScene(s); @@ -114,7 +114,7 @@ void TestCocosNodeDemo::restartCallback(Object* sender) void TestCocosNodeDemo::nextCallback(Object* sender) { - Scene* s = new CocosNodeTestScene();//CCScene::create(); + auto s = new CocosNodeTestScene();//CCScene::create(); s->addChild( nextCocosNodeAction() ); Director::getInstance()->replaceScene(s); s->release(); @@ -122,7 +122,7 @@ void TestCocosNodeDemo::nextCallback(Object* sender) void TestCocosNodeDemo::backCallback(Object* sender) { - Scene* s = new CocosNodeTestScene();//CCScene::create(); + auto s = new CocosNodeTestScene();//CCScene::create(); s->addChild( backCocosNodeAction() ); Director::getInstance()->replaceScene(s); s->release(); @@ -138,12 +138,12 @@ void Test2::onEnter() { TestCocosNodeDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *sp1 = Sprite::create(s_pathSister1); - Sprite *sp2 = Sprite::create(s_pathSister2); - Sprite *sp3 = Sprite::create(s_pathSister1); - Sprite *sp4 = Sprite::create(s_pathSister2); + auto sp1 = Sprite::create(s_pathSister1); + auto sp2 = Sprite::create(s_pathSister2); + auto sp3 = Sprite::create(s_pathSister1); + auto sp4 = Sprite::create(s_pathSister2); sp1->setPosition(Point(100, s.height /2 )); sp2->setPosition(Point(380, s.height /2 )); @@ -156,11 +156,11 @@ void Test2::onEnter() sp1->addChild(sp3); sp2->addChild(sp4); - ActionInterval* a1 = RotateBy::create(2, 360); - ActionInterval* a2 = ScaleBy::create(2, 2); + auto a1 = RotateBy::create(2, 360); + auto a2 = ScaleBy::create(2, 2); - Action* action1 = RepeatForever::create( Sequence::create(a1, a2, a2->reverse(), NULL) ); - Action* action2 = RepeatForever::create( Sequence::create( + auto action1 = RepeatForever::create( Sequence::create(a1, a2, a2->reverse(), NULL) ); + auto action2 = RepeatForever::create( Sequence::create( a1->clone(), a2->clone(), a2->reverse(), @@ -189,8 +189,8 @@ std::string Test2::title() Test4::Test4() { - Sprite *sp1 = Sprite::create(s_pathSister1); - Sprite *sp2 = Sprite::create(s_pathSister2); + auto sp1 = Sprite::create(s_pathSister1); + auto sp2 = Sprite::create(s_pathSister2); sp1->setPosition( Point(100,160) ); sp2->setPosition( Point(380,160) ); @@ -204,8 +204,8 @@ Test4::Test4() void Test4::delay2(float dt) { - Sprite* node = static_cast(getChildByTag(2)); - Action* action1 = RotateBy::create(1, 360); + auto node = static_cast(getChildByTag(2)); + auto action1 = RotateBy::create(1, 360); node->runAction(action1); } @@ -228,16 +228,16 @@ std::string Test4::title() //------------------------------------------------------------------ Test5::Test5() { - Sprite* sp1 = Sprite::create(s_pathSister1); - Sprite* sp2 = Sprite::create(s_pathSister2); + auto sp1 = Sprite::create(s_pathSister1); + auto sp2 = Sprite::create(s_pathSister2); sp1->setPosition(Point(100,160)); sp2->setPosition(Point(380,160)); - RotateBy* rot = RotateBy::create(2, 360); - ActionInterval* rot_back = rot->reverse(); - Action* forever = RepeatForever::create(Sequence::create(rot, rot_back, NULL)); - Action* forever2 = forever->clone(); + auto rot = RotateBy::create(2, 360); + auto rot_back = rot->reverse(); + auto forever = RepeatForever::create(Sequence::create(rot, rot_back, NULL)); + auto forever2 = forever->clone(); forever->setTag(101); forever2->setTag(102); @@ -252,8 +252,8 @@ Test5::Test5() void Test5::addAndRemove(float dt) { - Node* sp1 = getChildByTag(kTagSprite1); - Node* sp2 = getChildByTag(kTagSprite2); + auto sp1 = getChildByTag(kTagSprite1); + auto sp2 = getChildByTag(kTagSprite2); sp1->retain(); sp2->retain(); @@ -280,22 +280,22 @@ std::string Test5::title() //------------------------------------------------------------------ Test6::Test6() { - Sprite* sp1 = Sprite::create(s_pathSister1); - Sprite* sp11 = Sprite::create(s_pathSister1); + auto sp1 = Sprite::create(s_pathSister1); + auto sp11 = Sprite::create(s_pathSister1); - Sprite* sp2 = Sprite::create(s_pathSister2); - Sprite* sp21 = Sprite::create(s_pathSister2); + auto sp2 = Sprite::create(s_pathSister2); + auto sp21 = Sprite::create(s_pathSister2); sp1->setPosition(Point(100,160)); sp2->setPosition(Point(380,160)); - ActionInterval* rot = RotateBy::create(2, 360); - ActionInterval* rot_back = rot->reverse(); - Action* forever1 = RepeatForever::create(Sequence::create(rot, rot_back, NULL)); - Action* forever11 = forever1->clone(); + auto rot = RotateBy::create(2, 360); + auto rot_back = rot->reverse(); + auto forever1 = RepeatForever::create(Sequence::create(rot, rot_back, NULL)); + auto forever11 = forever1->clone(); - Action* forever2 = forever1->clone(); - Action* forever21 = forever1->clone(); + auto forever2 = forever1->clone(); + auto forever21 = forever1->clone(); addChild(sp1, 0, kTagSprite1); sp1->addChild(sp11); @@ -312,8 +312,8 @@ Test6::Test6() void Test6::addAndRemove(float dt) { - Node* sp1 = getChildByTag(kTagSprite1); - Node* sp2 = getChildByTag(kTagSprite2); + auto sp1 = getChildByTag(kTagSprite1); + auto sp2 = getChildByTag(kTagSprite2); sp1->retain(); sp2->retain(); @@ -341,9 +341,9 @@ std::string Test6::title() //------------------------------------------------------------------ StressTest1::StressTest1() { - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *sp1 = Sprite::create(s_pathSister1); + auto sp1 = Sprite::create(s_pathSister1); addChild(sp1, 0, kTagSprite1); sp1->setPosition( Point(s.width/2, s.height/2) ); @@ -355,14 +355,14 @@ void StressTest1::shouldNotCrash(float dt) { unschedule(schedule_selector(StressTest1::shouldNotCrash)); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); // if the node has timers, it crashes - ParticleSun* explosion = ParticleSun::create(); + auto explosion = ParticleSun::create(); explosion->setTexture(TextureCache::getInstance()->addImage("Images/fire.png")); // if it doesn't, it works Ok. -// CocosNode *explosion = [Sprite create:@"grossinis_sister2.png"); +// auto explosion = [Sprite create:@"grossinis_sister2.png"); explosion->setPosition( Point(s.width/2, s.height/2) ); @@ -394,25 +394,25 @@ std::string StressTest1::title() //------------------------------------------------------------------ StressTest2::StressTest2() { - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Layer* sublayer = Layer::create(); + auto sublayer = Layer::create(); - Sprite *sp1 = Sprite::create(s_pathSister1); + auto sp1 = Sprite::create(s_pathSister1); sp1->setPosition( Point(80, s.height/2) ); - ActionInterval* move = MoveBy::create(3, Point(350,0)); - ActionInterval* move_ease_inout3 = EaseInOut::create(move->clone(), 2.0f); - ActionInterval* move_ease_inout_back3 = move_ease_inout3->reverse(); - Sequence* seq3 = Sequence::create( move_ease_inout3, move_ease_inout_back3, NULL); + auto move = MoveBy::create(3, Point(350,0)); + auto move_ease_inout3 = EaseInOut::create(move->clone(), 2.0f); + auto move_ease_inout_back3 = move_ease_inout3->reverse(); + auto seq3 = Sequence::create( move_ease_inout3, move_ease_inout_back3, NULL); sp1->runAction( RepeatForever::create(seq3) ); sublayer->addChild(sp1, 1); - ParticleFire* fire = ParticleFire::create(); + auto fire = ParticleFire::create(); fire->setTexture(TextureCache::getInstance()->addImage("Images/fire.png")); fire->setPosition( Point(80, s.height/2-50) ); - ActionInterval* copy_seq3 = seq3->clone(); + auto copy_seq3 = seq3->clone(); fire->runAction( RepeatForever::create(copy_seq3) ); sublayer->addChild(fire, 2); @@ -425,7 +425,7 @@ StressTest2::StressTest2() void StressTest2::shouldNotLeak(float dt) { unschedule( schedule_selector(StressTest2::shouldNotLeak) ); - Layer* sublayer = static_cast( getChildByTag(kTagSprite1) ); + auto sublayer = static_cast( getChildByTag(kTagSprite1) ); sublayer->removeAllChildrenWithCleanup(true); } @@ -442,7 +442,7 @@ std::string StressTest2::title() //------------------------------------------------------------------ SchedulerTest1::SchedulerTest1() { - Layer*layer = Layer::create(); + auto layer = Layer::create(); //CCLOG("retain count after init is %d", layer->retainCount()); // 1 addChild(layer, 0); @@ -477,25 +477,25 @@ NodeToWorld::NodeToWorld() // - It tests different anchor Points // - It tests different children anchor points - Sprite *back = Sprite::create(s_back3); + auto back = Sprite::create(s_back3); addChild( back, -10); back->setAnchorPoint( Point(0,0) ); - Size backSize = back->getContentSize(); + auto backSize = back->getContentSize(); - MenuItem *item = MenuItemImage::create(s_PlayNormal, s_PlaySelect); - Menu *menu = Menu::create(item, NULL); + auto item = MenuItemImage::create(s_PlayNormal, s_PlaySelect); + auto menu = Menu::create(item, NULL); menu->alignItemsVertically(); menu->setPosition( Point(backSize.width/2, backSize.height/2)); back->addChild(menu); - ActionInterval* rot = RotateBy::create(5, 360); - Action* fe = RepeatForever::create( rot); + auto rot = RotateBy::create(5, 360); + auto fe = RepeatForever::create( rot); item->runAction( fe ); - ActionInterval* move = MoveBy::create(3, Point(200,0)); - ActionInterval* move_back = move->reverse(); - Sequence* seq = Sequence::create( move, move_back, NULL); - Action* fe2 = RepeatForever::create(seq); + auto move = MoveBy::create(3, Point(200,0)); + auto move_back = move->reverse(); + auto seq = Sequence::create( move, move_back, NULL); + auto fe2 = RepeatForever::create(seq); back->runAction(fe2); } @@ -523,9 +523,9 @@ void CameraOrbitTest::onExit() CameraOrbitTest::CameraOrbitTest() { - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *p = Sprite::create(s_back3); + auto p = Sprite::create(s_back3); addChild( p, 0); p->setPosition( Point(s.width/2, s.height/2) ); p->setOpacity( 128 ); @@ -595,7 +595,7 @@ void CameraZoomTest::onExit() CameraZoomTest::CameraZoomTest() { - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); Sprite *sprite; Camera *cam; @@ -650,7 +650,7 @@ std::string CameraZoomTest::title() //------------------------------------------------------------------ CameraCenterTest::CameraCenterTest() { - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); Sprite *sprite; OrbitCamera *orbit; @@ -724,16 +724,16 @@ std::string CameraCenterTest::subtitle() ConvertToNode::ConvertToNode() { setTouchEnabled(true); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - RotateBy* rotate = RotateBy::create(10, 360); - RepeatForever* action = RepeatForever::create(rotate); + auto rotate = RotateBy::create(10, 360); + auto action = RepeatForever::create(rotate); for(int i = 0; i < 3; i++) { - Sprite *sprite = Sprite::create("Images/grossini.png"); + auto sprite = Sprite::create("Images/grossini.png"); sprite->setPosition(Point( s.width/4*(i+1), s.height/2)); - Sprite *point = Sprite::create("Images/r1.png"); + auto point = Sprite::create("Images/r1.png"); point->setScale(0.25f); point->setPosition(sprite->getPosition()); addChild(point, 10, 100 + i); @@ -762,12 +762,12 @@ void ConvertToNode::ccTouchesEnded(Set* touches, Event *event) { for( SetIterator it = touches->begin(); it != touches->end(); ++it) { - Touch* touch = static_cast(*it); - Point location = touch->getLocation(); + auto touch = static_cast(*it); + auto location = touch->getLocation(); for( int i = 0; i < 3; i++) { - Node *node = getChildByTag(100+i); + auto node = getChildByTag(100+i); Point p1, p2; p1 = node->convertToNodeSpaceAR(location); @@ -840,7 +840,7 @@ std::string NodeNonOpaqueTest::subtitle() void CocosNodeTestScene::runThisTest() { - Layer* layer = nextCocosNodeAction(); + auto layer = nextCocosNodeAction(); addChild(layer); Director::getInstance()->replaceScene(this); diff --git a/samples/Cpp/TestCpp/Classes/ParallaxTest/ParallaxTest.cpp b/samples/Cpp/TestCpp/Classes/ParallaxTest/ParallaxTest.cpp index 31d9fca350..139d92a52a 100644 --- a/samples/Cpp/TestCpp/Classes/ParallaxTest/ParallaxTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ParallaxTest/ParallaxTest.cpp @@ -20,7 +20,7 @@ Layer* restartParallaxAction(); Parallax1::Parallax1() { // Top Layer, a simple image - Sprite* cocosImage = Sprite::create(s_Power); + auto cocosImage = Sprite::create(s_Power); // scale the image (optional) cocosImage->setScale( 2.5f ); // change the transform anchor point to 0,0 (optional) @@ -28,7 +28,7 @@ Parallax1::Parallax1() // Middle layer: a Tile map atlas - TileMapAtlas *tilemap = TileMapAtlas::create(s_TilesPng, s_LevelMapTga, 16, 16); + auto tilemap = TileMapAtlas::create(s_TilesPng, s_LevelMapTga, 16, 16); tilemap->releaseMap(); // change the transform anchor to 0,0 (optional) @@ -39,7 +39,7 @@ Parallax1::Parallax1() // background layer: another image - Sprite* background = Sprite::create(s_back); + auto background = Sprite::create(s_back); // scale the image (optional) background->setScale( 1.5f ); // change the transform anchor point (optional) @@ -47,7 +47,7 @@ Parallax1::Parallax1() // create a void node, a parent node - ParallaxNode* voidNode = ParallaxNode::create(); + auto voidNode = ParallaxNode::create(); // NOW add the 3 layers to the 'void' node @@ -64,11 +64,11 @@ Parallax1::Parallax1() // now create some actions that will move the 'void' node // and the children of the 'void' node will move at different // speed, thus, simulation the 3D environment - ActionInterval* goUp = MoveBy::create(4, Point(0,-500) ); - ActionInterval* goDown = goUp->reverse(); - ActionInterval* go = MoveBy::create(8, Point(-1000,0) ); - ActionInterval* goBack = go->reverse(); - Sequence* seq = Sequence::create(goUp, go, goDown, goBack, NULL); + auto goUp = MoveBy::create(4, Point(0,-500) ); + auto goDown = goUp->reverse(); + auto go = MoveBy::create(8, Point(-1000,0) ); + auto goBack = go->reverse(); + auto seq = Sequence::create(goUp, go, goDown, goBack, NULL); voidNode->runAction( (RepeatForever::create(seq) )); addChild( voidNode ); @@ -90,7 +90,7 @@ Parallax2::Parallax2() setTouchEnabled( true ); // Top Layer, a simple image - Sprite* cocosImage = Sprite::create(s_Power); + auto cocosImage = Sprite::create(s_Power); // scale the image (optional) cocosImage->setScale( 2.5f ); // change the transform anchor point to 0,0 (optional) @@ -98,7 +98,7 @@ Parallax2::Parallax2() // Middle layer: a Tile map atlas - TileMapAtlas* tilemap = TileMapAtlas::create(s_TilesPng, s_LevelMapTga, 16, 16); + auto tilemap = TileMapAtlas::create(s_TilesPng, s_LevelMapTga, 16, 16); tilemap->releaseMap(); // change the transform anchor to 0,0 (optional) @@ -109,7 +109,7 @@ Parallax2::Parallax2() // background layer: another image - Sprite* background = Sprite::create(s_back); + auto background = Sprite::create(s_back); // scale the image (optional) background->setScale( 1.5f ); // change the transform anchor point (optional) @@ -117,7 +117,7 @@ Parallax2::Parallax2() // create a void node, a parent node - ParallaxNode* voidNode = ParallaxNode::create(); + auto voidNode = ParallaxNode::create(); // NOW add the 3 layers to the 'void' node @@ -134,11 +134,11 @@ Parallax2::Parallax2() void Parallax2::ccTouchesMoved(Set *touches, Event *event) { - Touch *touch = static_cast(touches->anyObject()); - Point diff = touch->getDelta(); + auto touch = static_cast(touches->anyObject()); + auto diff = touch->getDelta(); - Node* node = getChildByTag(kTagNode); - Point currentPos = node->getPosition(); + auto node = getChildByTag(kTagNode); + auto currentPos = node->getPosition(); node->setPosition(currentPos + diff); } @@ -173,7 +173,7 @@ Layer* nextParallaxAction() sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - Layer* layer = createParallaxTestLayer(sceneIdx); + auto layer = createParallaxTestLayer(sceneIdx); layer->autorelease(); return layer; @@ -186,7 +186,7 @@ Layer* backParallaxAction() if( sceneIdx < 0 ) sceneIdx += total; - Layer* layer = createParallaxTestLayer(sceneIdx); + auto layer = createParallaxTestLayer(sceneIdx); layer->autorelease(); return layer; @@ -194,7 +194,7 @@ Layer* backParallaxAction() Layer* restartParallaxAction() { - Layer* layer = createParallaxTestLayer(sceneIdx); + auto layer = createParallaxTestLayer(sceneIdx); layer->autorelease(); return layer; @@ -221,7 +221,7 @@ void ParallaxDemo::onEnter() void ParallaxDemo::restartCallback(Object* sender) { - Scene* s = new ParallaxTestScene(); + auto s = new ParallaxTestScene(); s->addChild(restartParallaxAction()); Director::getInstance()->replaceScene(s); @@ -230,7 +230,7 @@ void ParallaxDemo::restartCallback(Object* sender) void ParallaxDemo::nextCallback(Object* sender) { - Scene* s = new ParallaxTestScene(); + auto s = new ParallaxTestScene(); s->addChild( nextParallaxAction() ); Director::getInstance()->replaceScene(s); s->release(); @@ -238,7 +238,7 @@ void ParallaxDemo::nextCallback(Object* sender) void ParallaxDemo::backCallback(Object* sender) { - Scene* s = new ParallaxTestScene(); + auto s = new ParallaxTestScene(); s->addChild( backParallaxAction() ); Director::getInstance()->replaceScene(s); s->release(); @@ -246,7 +246,7 @@ void ParallaxDemo::backCallback(Object* sender) void ParallaxTestScene::runThisTest() { - Layer* layer = nextParallaxAction(); + auto layer = nextParallaxAction(); addChild(layer); Director::getInstance()->replaceScene(this); diff --git a/samples/Cpp/TestCpp/Classes/ParticleTest/ParticleTest.cpp b/samples/Cpp/TestCpp/Classes/ParticleTest/ParticleTest.cpp index 7347ab5ce2..54589542f8 100644 --- a/samples/Cpp/TestCpp/Classes/ParticleTest/ParticleTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ParticleTest/ParticleTest.cpp @@ -47,7 +47,7 @@ void DemoFire::onEnter() _background->addChild(_emitter, 10); _emitter->setTexture( TextureCache::getInstance()->addImage(s_fire) );//.pvr"); - Point p = _emitter->getPosition(); + auto p = _emitter->getPosition(); _emitter->setPosition( Point(p.x, 100) ); setEmitterPosition(); @@ -380,7 +380,7 @@ void DemoSmoke::onEnter() _background->addChild(_emitter, 10); _emitter->setTexture( TextureCache::getInstance()->addImage(s_fire) ); - Point p = _emitter->getPosition(); + auto p = _emitter->getPosition(); _emitter->setPosition( Point( p.x, 100) ); setEmitterPosition(); @@ -404,7 +404,7 @@ void DemoSnow::onEnter() _emitter->retain(); _background->addChild(_emitter, 10); - Point p = _emitter->getPosition(); + auto p = _emitter->getPosition(); _emitter->setPosition( Point( p.x, p.y-110) ); _emitter->setLife(3); _emitter->setLifeVar(1); @@ -452,7 +452,7 @@ void DemoRain::onEnter() _emitter->retain(); _background->addChild(_emitter, 10); - Point p = _emitter->getPosition(); + auto p = _emitter->getPosition(); _emitter->setPosition( Point( p.x, p.y-100) ); _emitter->setLife(4); @@ -485,7 +485,7 @@ void DemoModernArt::onEnter() _background->addChild(_emitter, 10); ////_emitter->release(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); // duration _emitter->setDuration(-1); @@ -594,11 +594,11 @@ void ParallaxParticle::onEnter() _background->getParent()->removeChild(_background, true); _background = NULL; - ParallaxNode* p = ParallaxNode::create(); + auto p = ParallaxNode::create(); addChild(p, 5); - Sprite *p1 = Sprite::create(s_back3); - Sprite *p2 = Sprite::create(s_back3); + 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) ); @@ -610,13 +610,13 @@ void ParallaxParticle::onEnter() p1->addChild(_emitter, 10); _emitter->setPosition( Point(250,200) ); - ParticleSun* par = ParticleSun::create(); + auto par = ParticleSun::create(); p2->addChild(par, 10); par->setTexture( TextureCache::getInstance()->addImage(s_fire) ); - ActionInterval* move = MoveBy::create(4, Point(300,0)); - ActionInterval* move_back = move->reverse(); - Sequence* seq = Sequence::create( move, move_back, NULL); + 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)); } @@ -665,7 +665,7 @@ void RadiusMode1::onEnter() _emitter->setAngleVar(0); // emitter position - Size size = Director::getInstance()->getWinSize(); + auto size = Director::getInstance()->getWinSize(); _emitter->setPosition(Point(size.width/2, size.height/2)); _emitter->setPosVar(Point::ZERO); @@ -749,7 +749,7 @@ void RadiusMode2::onEnter() _emitter->setAngleVar(0); // emitter position - Size size = Director::getInstance()->getWinSize(); + auto size = Director::getInstance()->getWinSize(); _emitter->setPosition(Point(size.width/2, size.height/2)); _emitter->setPosVar(Point::ZERO); @@ -833,7 +833,7 @@ void Issue704::onEnter() _emitter->setAngleVar(0); // emitter position - Size size = Director::getInstance()->getWinSize(); + auto size = Director::getInstance()->getWinSize(); _emitter->setPosition(Point(size.width/2, size.height/2)); _emitter->setPosVar(Point::ZERO); @@ -871,7 +871,7 @@ void Issue704::onEnter() // additive _emitter->setBlendAdditive(false); - RotateBy* rot = RotateBy::create(16, 360); + auto rot = RotateBy::create(16, 360); _emitter->runAction(RepeatForever::create(rot)); } @@ -898,7 +898,7 @@ void Issue870::onEnter() removeChild(_background, true); _background = NULL; - ParticleSystemQuad *system = new ParticleSystemQuad(); + auto system = new ParticleSystemQuad(); system->initWithFile("Particles/SpinningPeas.plist"); system->setTextureWithRect(TextureCache::getInstance()->addImage("Images/particles.png"), Rect(0,0,32,32)); addChild(system, 10); @@ -911,8 +911,8 @@ void Issue870::onEnter() void Issue870::updateQuads(float dt) { _index = (_index + 1) % 4; - Rect rect = Rect(_index * 32, 0, 32, 32); - ParticleSystemQuad* system = (ParticleSystemQuad*)_emitter; + auto rect = Rect(_index * 32, 0, 32, 32); + auto system = (ParticleSystemQuad*)_emitter; system->setTextureWithRect(_emitter->getTexture(), rect); } @@ -1027,7 +1027,7 @@ Layer* nextParticleAction() sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - Layer* layer = createParticleLayer(sceneIdx); + auto layer = createParticleLayer(sceneIdx); layer->autorelease(); return layer; @@ -1040,7 +1040,7 @@ Layer* backParticleAction() if( sceneIdx < 0 ) sceneIdx += total; - Layer* layer = createParticleLayer(sceneIdx); + auto layer = createParticleLayer(sceneIdx); layer->autorelease(); return layer; @@ -1048,7 +1048,7 @@ Layer* backParticleAction() Layer* restartParticleAction() { - Layer* layer = createParticleLayer(sceneIdx); + auto layer = createParticleLayer(sceneIdx); layer->autorelease(); return layer; @@ -1070,15 +1070,15 @@ void ParticleDemo::onEnter(void) setTouchEnabled( true ); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - MenuItemToggle* item4 = MenuItemToggle::createWithCallback( CC_CALLBACK_1(ParticleDemo::toggleCallback, this), + auto item4 = MenuItemToggle::createWithCallback( CC_CALLBACK_1(ParticleDemo::toggleCallback, this), MenuItemFont::create( "Free Movement" ), MenuItemFont::create( "Relative Movement" ), MenuItemFont::create( "Grouped Movement" ), NULL ); - Menu *menu = Menu::create(item4, NULL); + auto menu = Menu::create(item4, NULL); menu->setPosition( Point::ZERO ); item4->setPosition( Point( VisibleRect::left().x, VisibleRect::bottom().y+ 100) ); @@ -1086,7 +1086,7 @@ void ParticleDemo::onEnter(void) addChild( menu, 100 ); - LabelAtlas* labelAtlas = LabelAtlas::create("0000", "fps_images.png", 12, 32, '.'); + auto labelAtlas = LabelAtlas::create("0000", "fps_images.png", 12, 32, '.'); addChild(labelAtlas, 100, kTagParticleCount); labelAtlas->setPosition(Point(s.width-66,50)); @@ -1095,9 +1095,9 @@ void ParticleDemo::onEnter(void) addChild(_background, 5); _background->setPosition( Point(s.width/2, s.height-180) ); - ActionInterval* move = MoveBy::create(4, Point(300,0) ); - ActionInterval* move_back = move->reverse(); - Sequence* seq = Sequence::create( move, move_back, NULL); + 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) ); @@ -1126,11 +1126,11 @@ void ParticleDemo::ccTouchesMoved(Set *touches, Event *event) void ParticleDemo::ccTouchesEnded(Set *touches, Event *event) { - Touch *touch = static_cast(touches->anyObject()); + auto touch = static_cast(touches->anyObject()); - Point location = touch->getLocation(); + auto location = touch->getLocation(); - Point pos = Point::ZERO; + auto pos = Point::ZERO; if (_background) { pos = _background->convertToWorldSpace(Point::ZERO); @@ -1146,7 +1146,7 @@ void ParticleDemo::update(float dt) { if (_emitter) { - LabelAtlas* atlas = (LabelAtlas*)getChildByTag(kTagParticleCount); + auto atlas = (LabelAtlas*)getChildByTag(kTagParticleCount); char str[5] = {0}; sprintf(str, "%04d", _emitter->getParticleCount()); atlas->setString(str); @@ -1176,7 +1176,7 @@ void ParticleDemo::restartCallback(Object* sender) void ParticleDemo::nextCallback(Object* sender) { - Scene* s = new ParticleTestScene(); + auto s = new ParticleTestScene(); s->addChild( nextParticleAction() ); Director::getInstance()->replaceScene(s); s->release(); @@ -1184,7 +1184,7 @@ void ParticleDemo::nextCallback(Object* sender) void ParticleDemo::backCallback(Object* sender) { - Scene* s = new ParticleTestScene(); + auto s = new ParticleTestScene(); s->addChild( backParticleAction() ); Director::getInstance()->replaceScene(s); s->release(); @@ -1192,7 +1192,7 @@ void ParticleDemo::backCallback(Object* sender) void ParticleDemo::setEmitterPosition() { - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); if (_emitter != NULL) { _emitter->setPosition( Point(s.width / 2, s.height / 2) ); @@ -1211,7 +1211,7 @@ void ParticleBatchHybrid::onEnter() _emitter = ParticleSystemQuad::create("Particles/LavaFlow.plist"); _emitter->retain(); - ParticleBatchNode *batch = ParticleBatchNode::createWithTexture(_emitter->getTexture()); + auto batch = ParticleBatchNode::createWithTexture(_emitter->getTexture()); batch->addChild(_emitter); @@ -1219,7 +1219,7 @@ void ParticleBatchHybrid::onEnter() schedule(schedule_selector(ParticleBatchHybrid::switchRender), 2.0f); - Node *node = Node::create(); + auto node = Node::create(); addChild(node); _parent1 = batch; @@ -1231,7 +1231,7 @@ void ParticleBatchHybrid::switchRender(float dt) bool usingBatch = ( _emitter->getBatchNode() != NULL ); _emitter->removeFromParentAndCleanup(false); - Node *newParent = (usingBatch ? _parent2 : _parent1 ); + auto newParent = (usingBatch ? _parent2 : _parent1 ); newParent->addChild(_emitter); log("Particle: Using new parent: %s", usingBatch ? "CCNode" : "CCParticleBatchNode"); @@ -1257,20 +1257,20 @@ void ParticleBatchMultipleEmitters::onEnter() removeChild(_background, true); _background = NULL; - ParticleSystemQuad *emitter1 = ParticleSystemQuad::create("Particles/LavaFlow.plist"); + auto emitter1 = ParticleSystemQuad::create("Particles/LavaFlow.plist"); emitter1->setStartColor(Color4F(1,0,0,1)); - ParticleSystemQuad *emitter2 = ParticleSystemQuad::create("Particles/LavaFlow.plist"); + auto emitter2 = ParticleSystemQuad::create("Particles/LavaFlow.plist"); emitter2->setStartColor(Color4F(0,1,0,1)); - ParticleSystemQuad *emitter3 = ParticleSystemQuad::create("Particles/LavaFlow.plist"); + auto emitter3 = ParticleSystemQuad::create("Particles/LavaFlow.plist"); emitter3->setStartColor(Color4F(0,0,1,1)); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); emitter1->setPosition(Point( s.width/1.25f, s.height/1.25f)); emitter2->setPosition(Point( s.width/2, s.height/2)); emitter3->setPosition(Point( s.width/4, s.height/4)); - ParticleBatchNode *batch = ParticleBatchNode::createWithTexture(emitter1->getTexture()); + auto batch = ParticleBatchNode::createWithTexture(emitter1->getTexture()); batch->addChild(emitter1, 0); batch->addChild(emitter2, 0); @@ -1300,26 +1300,26 @@ void ParticleReorder::onEnter() removeChild(_background, true); _background = NULL; - ParticleSystem* ignore = ParticleSystemQuad::create("Particles/SmallSun.plist"); - Node *parent1 = Node::create(); - Node *parent2 = ParticleBatchNode::createWithTexture(ignore->getTexture()); + auto ignore = ParticleSystemQuad::create("Particles/SmallSun.plist"); + auto parent1 = Node::create(); + auto parent2 = ParticleBatchNode::createWithTexture(ignore->getTexture()); ignore->unscheduleUpdate(); for( unsigned int i=0; i<2;i++) { - Node *parent = ( i==0 ? parent1 : parent2 ); + auto parent = ( i==0 ? parent1 : parent2 ); - ParticleSystemQuad *emitter1 = ParticleSystemQuad::create("Particles/SmallSun.plist"); + auto emitter1 = ParticleSystemQuad::create("Particles/SmallSun.plist"); emitter1->setStartColor(Color4F(1,0,0,1)); emitter1->setBlendAdditive(false); - ParticleSystemQuad *emitter2 = ParticleSystemQuad::create("Particles/SmallSun.plist"); + auto emitter2 = ParticleSystemQuad::create("Particles/SmallSun.plist"); emitter2->setStartColor(Color4F(0,1,0,1)); emitter2->setBlendAdditive(false); - ParticleSystemQuad *emitter3 = ParticleSystemQuad::create("Particles/SmallSun.plist"); + auto emitter3 = ParticleSystemQuad::create("Particles/SmallSun.plist"); emitter3->setStartColor(Color4F(0,0,1,1)); emitter3->setBlendAdditive(false); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); int neg = (i==0 ? 1 : -1 ); @@ -1350,11 +1350,11 @@ std::string ParticleReorder::subtitle() void ParticleReorder::reorderParticles(float dt) { for( int i=0; i<2;i++) { - Node *parent = getChildByTag(1000+i); + auto parent = getChildByTag(1000+i); - Node *child1 = parent->getChildByTag(1); - Node *child2 = parent->getChildByTag(2); - Node *child3 = parent->getChildByTag(3); + auto child1 = parent->getChildByTag(1); + auto child2 = parent->getChildByTag(2); + auto child3 = parent->getChildByTag(3); if( _order % 3 == 0 ) { parent->reorderChild(child1, 1); @@ -1419,7 +1419,7 @@ bool RainbowEffect::initWithTotalParticles(unsigned int numberOfParticles) setAngleVar(0); // emitter position - Size winSize = Director::getInstance()->getWinSize(); + auto winSize = Director::getInstance()->getWinSize(); setPosition(Point(winSize.width/2, winSize.height/2)); setPosVar(Point::ZERO); @@ -1475,7 +1475,7 @@ void Issue1201::onEnter() addChild(particle); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); particle->setPosition(Point(s.width/2, s.height/2)); @@ -1503,7 +1503,7 @@ void MultipleParticleSystems::onEnter() TextureCache::getInstance()->addImage("Images/particles.png"); for (int i = 0; i<5; i++) { - ParticleSystemQuad *particleSystem = ParticleSystemQuad::create("Particles/SpinningPeas.plist"); + auto particleSystem = ParticleSystemQuad::create("Particles/SpinningPeas.plist"); particleSystem->setPosition(Point(i*50 ,i*50)); @@ -1527,14 +1527,14 @@ std::string MultipleParticleSystems::subtitle() void MultipleParticleSystems::update(float dt) { - LabelAtlas *atlas = (LabelAtlas*) getChildByTag(kTagParticleCount); + auto atlas = (LabelAtlas*) getChildByTag(kTagParticleCount); unsigned int count = 0; Object* pObj = NULL; CCARRAY_FOREACH(getChildren(), pObj) { - ParticleSystem* item = dynamic_cast(pObj); + auto item = dynamic_cast(pObj); if (item != NULL) { count += item->getParticleCount(); @@ -1555,14 +1555,14 @@ void MultipleParticleSystemsBatched::onEnter() removeChild(_background, true); _background = NULL; - ParticleBatchNode *batchNode = new ParticleBatchNode(); + auto batchNode = new ParticleBatchNode(); batchNode->initWithTexture(NULL, 3000); addChild(batchNode, 1, 2); for (int i = 0; i<5; i++) { - ParticleSystemQuad *particleSystem = ParticleSystemQuad::create("Particles/SpinningPeas.plist"); + auto particleSystem = ParticleSystemQuad::create("Particles/SpinningPeas.plist"); particleSystem->setPositionType(ParticleSystem::PositionType::GROUPED); particleSystem->setPosition(Point(i*50 ,i*50)); @@ -1578,15 +1578,15 @@ void MultipleParticleSystemsBatched::onEnter() void MultipleParticleSystemsBatched::update(float dt) { - LabelAtlas *atlas = (LabelAtlas*) getChildByTag(kTagParticleCount); + auto atlas = (LabelAtlas*) getChildByTag(kTagParticleCount); unsigned count = 0; - Node* batchNode = getChildByTag(2); + auto batchNode = getChildByTag(2); Object* pObj = NULL; CCARRAY_FOREACH(batchNode->getChildren(), pObj) { - ParticleSystem* item = dynamic_cast(pObj); + auto item = dynamic_cast(pObj); if (item != NULL) { count += item->getParticleCount(); @@ -1624,7 +1624,7 @@ void AddAndDeleteParticleSystems::onEnter() for (int i = 0; i<6; i++) { - ParticleSystemQuad *particleSystem = ParticleSystemQuad::create("Particles/Spiral.plist"); + auto particleSystem = ParticleSystemQuad::create("Particles/Spiral.plist"); _batchNode->setTexture(particleSystem->getTexture()); particleSystem->setPositionType(ParticleSystem::PositionType::GROUPED); @@ -1651,7 +1651,7 @@ void AddAndDeleteParticleSystems::removeSystem(float dt) unsigned int uRand = rand() % (nChildrenCount - 1); _batchNode->removeChild((Node*)_batchNode->getChildren()->objectAtIndex(uRand), true); - ParticleSystemQuad *particleSystem = ParticleSystemQuad::create("Particles/Spiral.plist"); + auto particleSystem = ParticleSystemQuad::create("Particles/Spiral.plist"); //add new particleSystem->setPositionType(ParticleSystem::PositionType::GROUPED); @@ -1667,15 +1667,15 @@ void AddAndDeleteParticleSystems::removeSystem(float dt) void AddAndDeleteParticleSystems::update(float dt) { - LabelAtlas *atlas = (LabelAtlas*) getChildByTag(kTagParticleCount); + auto atlas = (LabelAtlas*) getChildByTag(kTagParticleCount); unsigned int count = 0; - Node* batchNode = getChildByTag(2); + auto batchNode = getChildByTag(2); Object* pObj = NULL; CCARRAY_FOREACH(batchNode->getChildren(), pObj) { - ParticleSystem* item = dynamic_cast(pObj); + auto item = dynamic_cast(pObj); if (item != NULL) { count += item->getParticleCount(); @@ -1713,7 +1713,7 @@ void ReorderParticleSystems::onEnter() for (int i = 0; i<3; i++) { - ParticleSystemQuad* particleSystem = new ParticleSystemQuad(); + auto particleSystem = new ParticleSystemQuad(); particleSystem->initWithTotalParticles(200); particleSystem->setTexture(_batchNode->getTexture()); @@ -1796,22 +1796,22 @@ void ReorderParticleSystems::onEnter() void ReorderParticleSystems::reorderSystem(float time) { - ParticleSystem* system = (ParticleSystem*)_batchNode->getChildren()->objectAtIndex(1); + auto system = (ParticleSystem*)_batchNode->getChildren()->objectAtIndex(1); _batchNode->reorderChild(system, system->getZOrder() - 1); } void ReorderParticleSystems::update(float dt) { - LabelAtlas *atlas = (LabelAtlas*) getChildByTag(kTagParticleCount); + auto atlas = (LabelAtlas*) getChildByTag(kTagParticleCount); unsigned int count = 0; - Node* batchNode = getChildByTag(2); + auto batchNode = getChildByTag(2); Object* pObj = NULL; CCARRAY_FOREACH(batchNode->getChildren(), pObj) { - ParticleSystem* item = dynamic_cast(pObj); + auto item = dynamic_cast(pObj); if (item != NULL) { count += item->getParticleCount(); diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp index c19375df07..90c28f9261 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp @@ -70,10 +70,10 @@ void NodeChildrenMenuLayer::showCurrentTest() void NodeChildrenMainScene::initWithQuantityOfNodes(unsigned int nNodes) { //srand(time()); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); // Title - LabelTTF *label = LabelTTF::create(title().c_str(), "Arial", 40); + auto label = LabelTTF::create(title().c_str(), "Arial", 40); addChild(label, 1); label->setPosition(Point(s.width/2, s.height-32)); label->setColor(Color3B(255,255,40)); @@ -82,7 +82,7 @@ void NodeChildrenMainScene::initWithQuantityOfNodes(unsigned int nNodes) std::string strSubTitle = subtitle(); if(strSubTitle.length()) { - LabelTTF *l = LabelTTF::create(strSubTitle.c_str(), "Thonburi", 16); + auto l = LabelTTF::create(strSubTitle.c_str(), "Thonburi", 16); addChild(l, 1); l->setPosition(Point(s.width/2, s.height-80)); } @@ -92,7 +92,7 @@ void NodeChildrenMainScene::initWithQuantityOfNodes(unsigned int nNodes) quantityOfNodes = nNodes; MenuItemFont::setFontSize(65); - MenuItemFont *decrease = MenuItemFont::create(" - ", [&](Object *sender) { + auto decrease = MenuItemFont::create(" - ", [&](Object *sender) { quantityOfNodes -= kNodesIncrease; if( quantityOfNodes < 0 ) quantityOfNodes = 0; @@ -101,7 +101,7 @@ void NodeChildrenMainScene::initWithQuantityOfNodes(unsigned int nNodes) updateQuantityOfNodes(); }); decrease->setColor(Color3B(0,200,20)); - MenuItemFont *increase = MenuItemFont::create(" + ", [&](Object *sender) { + auto increase = MenuItemFont::create(" + ", [&](Object *sender) { quantityOfNodes += kNodesIncrease; if( quantityOfNodes > kMaxNodes ) quantityOfNodes = kMaxNodes; @@ -111,17 +111,17 @@ void NodeChildrenMainScene::initWithQuantityOfNodes(unsigned int nNodes) }); increase->setColor(Color3B(0,200,20)); - Menu *menu = Menu::create(decrease, increase, NULL); + auto menu = Menu::create(decrease, increase, NULL); menu->alignItemsHorizontally(); menu->setPosition(Point(s.width/2, s.height/2+15)); addChild(menu, 1); - LabelTTF *infoLabel = LabelTTF::create("0 nodes", "Marker Felt", 30); + auto infoLabel = LabelTTF::create("0 nodes", "Marker Felt", 30); infoLabel->setColor(Color3B(0,200,20)); infoLabel->setPosition(Point(s.width/2, s.height/2-15)); addChild(infoLabel, 1, kTagInfoLayer); - NodeChildrenMenuLayer* menuLayer = new NodeChildrenMenuLayer(true, TEST_COUNT, s_nCurCase); + auto menuLayer = new NodeChildrenMenuLayer(true, TEST_COUNT, s_nCurCase); addChild(menuLayer); menuLayer->release(); @@ -143,7 +143,7 @@ void NodeChildrenMainScene::updateQuantityLabel() { if( quantityOfNodes != lastRenderedCount ) { - LabelTTF *infoLabel = (LabelTTF *) getChildByTag(kTagInfoLayer); + auto infoLabel = (LabelTTF *) getChildByTag(kTagInfoLayer); char str[20] = {0}; sprintf(str, "%u nodes", quantityOfNodes); infoLabel->setString(str); @@ -164,14 +164,14 @@ IterateSpriteSheet::~IterateSpriteSheet() void IterateSpriteSheet::updateQuantityOfNodes() { - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); // increase nodes if( currentQuantityOfNodes < quantityOfNodes ) { for(int i = 0; i < (quantityOfNodes-currentQuantityOfNodes); i++) { - Sprite *sprite = Sprite::createWithTexture(batchNode->getTexture(), Rect(0, 0, 32, 32)); + auto sprite = Sprite::createWithTexture(batchNode->getTexture(), Rect(0, 0, 32, 32)); batchNode->addChild(sprite); sprite->setPosition(Point( CCRANDOM_0_1()*s.width, CCRANDOM_0_1()*s.height)); } @@ -213,14 +213,14 @@ const char* IterateSpriteSheet::profilerName() void IterateSpriteSheetFastEnum::update(float dt) { // iterate using fast enumeration protocol - Array* pChildren = batchNode->getChildren(); + auto pChildren = batchNode->getChildren(); Object* pObject = NULL; CC_PROFILER_START_INSTANCE(this, this->profilerName()); CCARRAY_FOREACH(pChildren, pObject) { - Sprite* sprite = static_cast(pObject); + auto sprite = static_cast(pObject); sprite->setVisible(false); } @@ -250,14 +250,14 @@ const char* IterateSpriteSheetFastEnum::profilerName() void IterateSpriteSheetCArray::update(float dt) { // iterate using fast enumeration protocol - Array* pChildren = batchNode->getChildren(); + auto pChildren = batchNode->getChildren(); Object* pObject = NULL; CC_PROFILER_START(this->profilerName()); CCARRAY_FOREACH(pChildren, pObject) { - Sprite* sprite = static_cast(pObject); + auto sprite = static_cast(pObject); sprite->setVisible(false); } @@ -302,14 +302,14 @@ void AddRemoveSpriteSheet::initWithQuantityOfNodes(unsigned int nNodes) void AddRemoveSpriteSheet::updateQuantityOfNodes() { - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); // increase nodes if( currentQuantityOfNodes < quantityOfNodes ) { for (int i=0; i < (quantityOfNodes-currentQuantityOfNodes); i++) { - Sprite *sprite = Sprite::createWithTexture(batchNode->getTexture(), Rect(0, 0, 32, 32)); + auto sprite = Sprite::createWithTexture(batchNode->getTexture(), Rect(0, 0, 32, 32)); batchNode->addChild(sprite); sprite->setPosition(Point( CCRANDOM_0_1()*s.width, CCRANDOM_0_1()*s.height)); sprite->setVisible(false); @@ -348,13 +348,13 @@ void AddSpriteSheet::update(float dt) if( totalToAdd > 0 ) { - Array* sprites = Array::createWithCapacity(totalToAdd); + auto sprites = Array::createWithCapacity(totalToAdd); int *zs = new int[totalToAdd]; // Don't include the sprite creation time and random as part of the profiling for(int i=0; igetTexture(), Rect(0,0,32,32)); + auto sprite = Sprite::createWithTexture(batchNode->getTexture(), Rect(0,0,32,32)); sprites->addObject(sprite); zs[i] = CCRANDOM_MINUS1_1() * 50; } @@ -410,12 +410,12 @@ void RemoveSpriteSheet::update(float dt) if( totalToAdd > 0 ) { - Array* sprites = Array::createWithCapacity(totalToAdd); + auto sprites = Array::createWithCapacity(totalToAdd); // Don't include the sprite creation time as part of the profiling for(int i=0;igetTexture(), Rect(0,0,32,32)); + auto sprite = Sprite::createWithTexture(batchNode->getTexture(), Rect(0,0,32,32)); sprites->addObject(sprite); } @@ -466,12 +466,12 @@ void ReorderSpriteSheet::update(float dt) if( totalToAdd > 0 ) { - Array* sprites = Array::createWithCapacity(totalToAdd); + auto sprites = Array::createWithCapacity(totalToAdd); // Don't include the sprite creation time as part of the profiling for(int i=0; igetTexture(), Rect(0,0,32,32)); + auto sprite = Sprite::createWithTexture(batchNode->getTexture(), Rect(0,0,32,32)); sprites->addObject(sprite); } @@ -488,7 +488,7 @@ void ReorderSpriteSheet::update(float dt) for( int i=0;i < totalToAdd;i++) { - Node* node = (Node*) (batchNode->getChildren()->objectAtIndex(i)); + auto node = (Node*) (batchNode->getChildren()->objectAtIndex(i)); batchNode->reorderChild(node, CCRANDOM_MINUS1_1() * 50); } diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceParticleTest.cpp b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceParticleTest.cpp index d2670f69d6..b72ad00da5 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceParticleTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceParticleTest.cpp @@ -31,7 +31,7 @@ ParticleMenuLayer::ParticleMenuLayer(bool bControlMenuVisible, int nMaxCases, in void ParticleMenuLayer::showCurrentTest() { - ParticleMainScene* scene = (ParticleMainScene*)getParent(); + auto scene = (ParticleMainScene*)getParent(); int subTest = scene->getSubTestNum(); int parNum = scene->getParticlesNum(); @@ -73,13 +73,13 @@ void ParticleMainScene::initWithSubTest(int asubtest, int particles) //srandom(0); subtestNumber = asubtest; - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); lastRenderedCount = 0; quantityParticles = particles; MenuItemFont::setFontSize(65); - MenuItemFont *decrease = MenuItemFont::create(" - ", [&](Object *sender) { + auto decrease = MenuItemFont::create(" - ", [&](Object *sender) { quantityParticles -= kNodesIncrease; if( quantityParticles < 0 ) quantityParticles = 0; @@ -88,7 +88,7 @@ void ParticleMainScene::initWithSubTest(int asubtest, int particles) createParticleSystem(); }); decrease->setColor(Color3B(0,200,20)); - MenuItemFont *increase = MenuItemFont::create(" + ", [&](Object *sender) { + auto increase = MenuItemFont::create(" + ", [&](Object *sender) { quantityParticles += kNodesIncrease; if( quantityParticles > kMaxParticles ) quantityParticles = kMaxParticles; @@ -98,34 +98,34 @@ void ParticleMainScene::initWithSubTest(int asubtest, int particles) }); increase->setColor(Color3B(0,200,20)); - Menu *menu = Menu::create(decrease, increase, NULL); + auto menu = Menu::create(decrease, increase, NULL); menu->alignItemsHorizontally(); menu->setPosition(Point(s.width/2, s.height/2+15)); addChild(menu, 1); - LabelTTF *infoLabel = LabelTTF::create("0 nodes", "Marker Felt", 30); + auto infoLabel = LabelTTF::create("0 nodes", "Marker Felt", 30); infoLabel->setColor(Color3B(0,200,20)); infoLabel->setPosition(Point(s.width/2, s.height - 90)); addChild(infoLabel, 1, kTagInfoLayer); // particles on stage - LabelAtlas *labelAtlas = LabelAtlas::create("0000", "fps_images.png", 12, 32, '.'); + auto labelAtlas = LabelAtlas::create("0000", "fps_images.png", 12, 32, '.'); addChild(labelAtlas, 0, kTagLabelAtlas); labelAtlas->setPosition(Point(s.width-66,50)); // Next Prev Test - ParticleMenuLayer* menuLayer = new ParticleMenuLayer(true, TEST_COUNT, s_nParCurIdx); + auto menuLayer = new ParticleMenuLayer(true, TEST_COUNT, s_nParCurIdx); addChild(menuLayer, 1, kTagMenuLayer); menuLayer->release(); // Sub Tests MenuItemFont::setFontSize(40); - Menu* pSubMenu = Menu::create(); + auto pSubMenu = Menu::create(); for (int i = 1; i <= 6; ++i) { char str[10] = {0}; sprintf(str, "%d ", i); - MenuItemFont* itemFont = MenuItemFont::create(str, CC_CALLBACK_1(ParticleMainScene::testNCallback, this)); + auto itemFont = MenuItemFont::create(str, CC_CALLBACK_1(ParticleMainScene::testNCallback, this)); itemFont->setTag(i); pSubMenu->addChild(itemFont, 10); @@ -142,7 +142,7 @@ void ParticleMainScene::initWithSubTest(int asubtest, int particles) pSubMenu->setPosition(Point(s.width/2, 80)); addChild(pSubMenu, 2); - LabelTTF *label = LabelTTF::create(title().c_str(), "Arial", 40); + auto label = LabelTTF::create(title().c_str(), "Arial", 40); addChild(label, 1); label->setPosition(Point(s.width/2, s.height-32)); label->setColor(Color3B(255,255,40)); @@ -160,8 +160,8 @@ std::string ParticleMainScene::title() void ParticleMainScene::step(float dt) { - LabelAtlas *atlas = (LabelAtlas*) getChildByTag(kTagLabelAtlas); - ParticleSystem *emitter = (ParticleSystem*) getChildByTag(kTagParticleSystem); + auto atlas = (LabelAtlas*) getChildByTag(kTagLabelAtlas); + auto emitter = (ParticleSystem*) getChildByTag(kTagParticleSystem); char str[10] = {0}; sprintf(str, "%4d", emitter->getParticleCount()); @@ -187,7 +187,7 @@ void ParticleMainScene::createParticleSystem() removeChildByTag(kTagParticleSystem, true); // remove the "fire.png" from the TextureCache cache. - Texture2D *texture = TextureCache::getInstance()->addImage("Images/fire.png"); + auto texture = TextureCache::getInstance()->addImage("Images/fire.png"); TextureCache::getInstance()->removeTexture(texture); //TODO: if (subtestNumber <= 3) @@ -267,7 +267,7 @@ void ParticleMainScene::updateQuantityLabel() { if( quantityParticles != lastRenderedCount ) { - LabelTTF *infoLabel = (LabelTTF *) getChildByTag(kTagInfoLayer); + auto infoLabel = (LabelTTF *) getChildByTag(kTagInfoLayer); char str[20] = {0}; sprintf(str, "%u particles", quantityParticles); infoLabel->setString(str); @@ -291,8 +291,8 @@ std::string ParticlePerformTest1::title() void ParticlePerformTest1::doTest() { - Size s = Director::getInstance()->getWinSize(); - ParticleSystem *particleSystem = (ParticleSystem*)getChildByTag(kTagParticleSystem); + auto s = Director::getInstance()->getWinSize(); + auto particleSystem = (ParticleSystem*)getChildByTag(kTagParticleSystem); // duration particleSystem->setDuration(-1); @@ -361,8 +361,8 @@ std::string ParticlePerformTest2::title() void ParticlePerformTest2::doTest() { - Size s = Director::getInstance()->getWinSize(); - ParticleSystem *particleSystem = (ParticleSystem*) getChildByTag(kTagParticleSystem); + auto s = Director::getInstance()->getWinSize(); + auto particleSystem = (ParticleSystem*) getChildByTag(kTagParticleSystem); // duration particleSystem->setDuration(-1); @@ -431,8 +431,8 @@ std::string ParticlePerformTest3::title() void ParticlePerformTest3::doTest() { - Size s = Director::getInstance()->getWinSize(); - ParticleSystem *particleSystem = (ParticleSystem*)getChildByTag(kTagParticleSystem); + auto s = Director::getInstance()->getWinSize(); + auto particleSystem = (ParticleSystem*)getChildByTag(kTagParticleSystem); // duration particleSystem->setDuration(-1); @@ -501,8 +501,8 @@ std::string ParticlePerformTest4::title() void ParticlePerformTest4::doTest() { - Size s = Director::getInstance()->getWinSize(); - ParticleSystem *particleSystem = (ParticleSystem*) getChildByTag(kTagParticleSystem); + auto s = Director::getInstance()->getWinSize(); + auto particleSystem = (ParticleSystem*) getChildByTag(kTagParticleSystem); // duration particleSystem->setDuration(-1); @@ -559,7 +559,7 @@ void ParticlePerformTest4::doTest() void runParticleTest() { - ParticleMainScene* scene = new ParticlePerformTest1; + auto scene = new ParticlePerformTest1; scene->initWithSubTest(1, kNodesIncrease); Director::getInstance()->replaceScene(scene); diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceSpriteTest.cpp b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceSpriteTest.cpp index 8fc2774af8..76c423fb82 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceSpriteTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceSpriteTest.cpp @@ -53,7 +53,7 @@ void SubTest::initWithSubTest(int nSubTest, Node* p) */ // purge textures - TextureCache *mgr = TextureCache::getInstance(); + auto mgr = TextureCache::getInstance(); // [mgr removeAllTextures]; mgr->removeTexture(mgr->addImage("Images/grossinis_sister1.png")); mgr->removeTexture(mgr->addImage("Images/grossini_dance_atlas.png")); @@ -230,7 +230,7 @@ void SubTest::removeByTag(int tag) void SpriteMenuLayer::showCurrentTest() { SpriteMainScene* scene = NULL; - SpriteMainScene* pPreScene = (SpriteMainScene*) getParent(); + auto pPreScene = (SpriteMainScene*) getParent(); int nSubTest = pPreScene->getSubTestNum(); int nNodes = pPreScene->getNodesNum(); @@ -281,40 +281,40 @@ void SpriteMainScene::initWithSubTest(int asubtest, int nNodes) _subTest = new SubTest; _subTest->initWithSubTest(asubtest, this); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); lastRenderedCount = 0; quantityNodes = 0; MenuItemFont::setFontSize(65); - MenuItemFont *decrease = MenuItemFont::create(" - ", CC_CALLBACK_1(SpriteMainScene::onDecrease, this)); + auto decrease = MenuItemFont::create(" - ", CC_CALLBACK_1(SpriteMainScene::onDecrease, this)); decrease->setColor(Color3B(0,200,20)); - MenuItemFont *increase = MenuItemFont::create(" + ", CC_CALLBACK_1(SpriteMainScene::onIncrease, this)); + auto increase = MenuItemFont::create(" + ", CC_CALLBACK_1(SpriteMainScene::onIncrease, this)); increase->setColor(Color3B(0,200,20)); - Menu *menu = Menu::create(decrease, increase, NULL); + auto menu = Menu::create(decrease, increase, NULL); menu->alignItemsHorizontally(); menu->setPosition(Point(s.width/2, s.height-65)); addChild(menu, 1); - LabelTTF *infoLabel = LabelTTF::create("0 nodes", "Marker Felt", 30); + auto infoLabel = LabelTTF::create("0 nodes", "Marker Felt", 30); infoLabel->setColor(Color3B(0,200,20)); infoLabel->setPosition(Point(s.width/2, s.height-90)); addChild(infoLabel, 1, kTagInfoLayer); // add menu - SpriteMenuLayer* menuLayer = new SpriteMenuLayer(true, TEST_COUNT, s_nSpriteCurCase); + auto menuLayer = new SpriteMenuLayer(true, TEST_COUNT, s_nSpriteCurCase); addChild(menuLayer, 1, kTagMenuLayer); menuLayer->release(); // Sub Tests MenuItemFont::setFontSize(32); - Menu* subMenu = Menu::create(); + auto subMenu = Menu::create(); for (int i = 1; i <= 9; ++i) { char str[10] = {0}; sprintf(str, "%d ", i); - MenuItemFont* itemFont = MenuItemFont::create(str, CC_CALLBACK_1(SpriteMainScene::testNCallback, this)); + auto itemFont = MenuItemFont::create(str, CC_CALLBACK_1(SpriteMainScene::testNCallback, this)); itemFont->setTag(i); subMenu->addChild(itemFont, 10); @@ -331,7 +331,7 @@ void SpriteMainScene::initWithSubTest(int asubtest, int nNodes) addChild(subMenu, 2); // add title label - LabelTTF *label = LabelTTF::create(title().c_str(), "Arial", 40); + auto label = LabelTTF::create(title().c_str(), "Arial", 40); addChild(label, 1); label->setPosition(Point(s.width/2, s.height-32)); label->setColor(Color3B(255,255,40)); @@ -365,7 +365,7 @@ void SpriteMainScene::updateNodes() { if( quantityNodes != lastRenderedCount ) { - LabelTTF *infoLabel = (LabelTTF *) getChildByTag(kTagInfoLayer); + auto infoLabel = (LabelTTF *) getChildByTag(kTagInfoLayer); char str[16] = {0}; sprintf(str, "%u nodes", quantityNodes); infoLabel->setString(str); @@ -381,7 +381,7 @@ void SpriteMainScene::onIncrease(Object* sender) for( int i=0;i< kNodesIncrease;i++) { - Sprite *sprite = _subTest->createSpriteWithTag(quantityNodes); + auto sprite = _subTest->createSpriteWithTag(quantityNodes); doTest(sprite); quantityNodes++; } @@ -410,44 +410,44 @@ void SpriteMainScene::onDecrease(Object* sender) //////////////////////////////////////////////////////// void performanceActions(Sprite* sprite) { - Size size = Director::getInstance()->getWinSize(); + auto size = Director::getInstance()->getWinSize(); sprite->setPosition(Point((rand() % (int)size.width), (rand() % (int)size.height))); float period = 0.5f + (rand() % 1000) / 500.0f; - RotateBy* rot = RotateBy::create(period, 360.0f * CCRANDOM_0_1()); - ActionInterval* rot_back = rot->reverse(); - Action *permanentRotation = RepeatForever::create(Sequence::create(rot, rot_back, NULL)); + auto rot = RotateBy::create(period, 360.0f * CCRANDOM_0_1()); + auto rot_back = rot->reverse(); + auto permanentRotation = RepeatForever::create(Sequence::create(rot, rot_back, NULL)); sprite->runAction(permanentRotation); float growDuration = 0.5f + (rand() % 1000) / 500.0f; - ActionInterval *grow = ScaleBy::create(growDuration, 0.5f, 0.5f); - Action *permanentScaleLoop = RepeatForever::create(Sequence::create(grow, grow->reverse(), NULL)); + auto grow = ScaleBy::create(growDuration, 0.5f, 0.5f); + auto permanentScaleLoop = RepeatForever::create(Sequence::create(grow, grow->reverse(), NULL)); sprite->runAction(permanentScaleLoop); } void performanceActions20(Sprite* sprite) { - Size size = Director::getInstance()->getWinSize(); + auto size = Director::getInstance()->getWinSize(); if( CCRANDOM_0_1() < 0.2f ) sprite->setPosition(Point((rand() % (int)size.width), (rand() % (int)size.height))); else sprite->setPosition(Point( -1000, -1000)); float period = 0.5f + (rand() % 1000) / 500.0f; - RotateBy* rot = RotateBy::create(period, 360.0f * CCRANDOM_0_1()); - ActionInterval* rot_back = rot->reverse(); - Action *permanentRotation = RepeatForever::create(Sequence::create(rot, rot_back, NULL)); + auto rot = RotateBy::create(period, 360.0f * CCRANDOM_0_1()); + auto rot_back = rot->reverse(); + auto permanentRotation = RepeatForever::create(Sequence::create(rot, rot_back, NULL)); sprite->runAction(permanentRotation); float growDuration = 0.5f + (rand() % 1000) / 500.0f; - ActionInterval *grow = ScaleBy::create(growDuration, 0.5f, 0.5f); - Action *permanentScaleLoop = RepeatForever::create(Sequence::createWithTwoActions(grow, grow->reverse())); + auto grow = ScaleBy::create(growDuration, 0.5f, 0.5f); + auto permanentScaleLoop = RepeatForever::create(Sequence::createWithTwoActions(grow, grow->reverse())); sprite->runAction(permanentScaleLoop); } void performanceRotationScale(Sprite* sprite) { - Size size = Director::getInstance()->getWinSize(); + auto size = Director::getInstance()->getWinSize(); sprite->setPosition(Point((rand() % (int)size.width), (rand() % (int)size.height))); sprite->setRotation(CCRANDOM_0_1() * 360); sprite->setScale(CCRANDOM_0_1() * 2); @@ -455,13 +455,13 @@ void performanceRotationScale(Sprite* sprite) void performancePosition(Sprite* sprite) { - Size size = Director::getInstance()->getWinSize(); + auto size = Director::getInstance()->getWinSize(); sprite->setPosition(Point((rand() % (int)size.width), (rand() % (int)size.height))); } void performanceout20(Sprite* sprite) { - Size size = Director::getInstance()->getWinSize(); + auto size = Director::getInstance()->getWinSize(); if( CCRANDOM_0_1() < 0.2f ) sprite->setPosition(Point((rand() % (int)size.width), (rand() % (int)size.height))); @@ -476,7 +476,7 @@ void performanceOut100(Sprite* sprite) void performanceScale(Sprite* sprite) { - Size size = Director::getInstance()->getWinSize(); + auto size = Director::getInstance()->getWinSize(); sprite->setPosition(Point((rand() % (int)size.width), (rand() % (int)size.height))); sprite->setScale(CCRANDOM_0_1() * 100 / 50); } @@ -609,7 +609,7 @@ void SpritePerformTest7::doTest(Sprite* sprite) void runSpriteTest() { - SpriteMainScene* scene = new SpritePerformTest1; + auto scene = new SpritePerformTest1; scene->initWithSubTest(1, 50); Director::getInstance()->replaceScene(scene); scene->release(); diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceTest.cpp b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceTest.cpp index 6321671805..20bd0e4c86 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceTest.cpp @@ -35,15 +35,15 @@ void PerformanceMainLayer::onEnter() { Layer::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Menu* menu = Menu::create(); + auto menu = Menu::create(); menu->setPosition( Point::ZERO ); MenuItemFont::setFontName("Arial"); MenuItemFont::setFontSize(24); for (int i = 0; i < g_testMax; ++i) { - MenuItemFont* pItem = MenuItemFont::create(g_testsName[i].name, g_testsName[i].callback); + auto pItem = MenuItemFont::create(g_testsName[i].name, g_testsName[i].callback); pItem->setPosition(Point(s.width / 2, s.height - (i + 1) * LINE_SPACE)); menu->addChild(pItem, kItemTagBasic + i); } @@ -70,16 +70,16 @@ void PerformBasicLayer::onEnter() MenuItemFont::setFontName("Arial"); MenuItemFont::setFontSize(24); - MenuItemFont* pMainItem = MenuItemFont::create("Back", CC_CALLBACK_1(PerformBasicLayer::toMainLayer, this)); + auto pMainItem = MenuItemFont::create("Back", CC_CALLBACK_1(PerformBasicLayer::toMainLayer, this)); pMainItem->setPosition(Point(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25)); - Menu* menu = Menu::create(pMainItem, NULL); + auto menu = Menu::create(pMainItem, NULL); menu->setPosition( Point::ZERO ); if (_controlMenuVisible) { - MenuItemImage *item1 = MenuItemImage::create(s_pathB1, s_pathB2, CC_CALLBACK_1(PerformBasicLayer::backCallback, this)); - MenuItemImage *item2 = MenuItemImage::create(s_pathR1, s_pathR2, CC_CALLBACK_1(PerformBasicLayer::restartCallback, this)); - MenuItemImage *item3 = MenuItemImage::create(s_pathF1, s_pathF2, CC_CALLBACK_1(PerformBasicLayer::nextCallback, this)); + auto item1 = MenuItemImage::create(s_pathB1, s_pathB2, CC_CALLBACK_1(PerformBasicLayer::backCallback, this)); + auto item2 = MenuItemImage::create(s_pathR1, s_pathR2, CC_CALLBACK_1(PerformBasicLayer::restartCallback, this)); + auto item3 = MenuItemImage::create(s_pathF1, s_pathF2, CC_CALLBACK_1(PerformBasicLayer::nextCallback, this)); item1->setPosition(Point(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2)); item2->setPosition(Point(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2)); item3->setPosition(Point(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2)); @@ -93,7 +93,7 @@ void PerformBasicLayer::onEnter() void PerformBasicLayer::toMainLayer(Object* sender) { - PerformanceTestScene* scene = new PerformanceTestScene(); + auto scene = new PerformanceTestScene(); scene->runThisTest(); scene->release(); @@ -129,7 +129,7 @@ void PerformBasicLayer::backCallback(Object* sender) void PerformanceTestScene::runThisTest() { - Layer* layer = new PerformanceMainLayer(); + auto layer = new PerformanceMainLayer(); addChild(layer); layer->release(); diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceTextureTest.cpp b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceTextureTest.cpp index 6a0e7a6aee..bcbae20aa1 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceTextureTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceTextureTest.cpp @@ -45,10 +45,10 @@ void TextureMenuLayer::onEnter() { PerformBasicLayer::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); // Title - LabelTTF *label = LabelTTF::create(title().c_str(), "Arial", 40); + auto label = LabelTTF::create(title().c_str(), "Arial", 40); addChild(label, 1); label->setPosition(Point(s.width/2, s.height-32)); label->setColor(Color3B(255,255,40)); @@ -57,7 +57,7 @@ void TextureMenuLayer::onEnter() std::string strSubTitle = subtitle(); if(strSubTitle.length()) { - LabelTTF *l = LabelTTF::create(strSubTitle.c_str(), "Thonburi", 16); + auto l = LabelTTF::create(strSubTitle.c_str(), "Thonburi", 16); addChild(l, 1); l->setPosition(Point(s.width/2, s.height-80)); } @@ -84,7 +84,7 @@ void TextureTest::performTestsPNG(const char* filename) { struct timeval now; Texture2D *texture; - TextureCache *cache = TextureCache::getInstance(); + auto cache = TextureCache::getInstance(); log("RGBA 8888"); Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA8888); @@ -131,7 +131,7 @@ void TextureTest::performTests() { // Texture2D *texture; // struct timeval now; -// TextureCache *cache = TextureCache::getInstance(); +// auto cache = TextureCache::getInstance(); log("--------"); @@ -344,7 +344,7 @@ std::string TextureTest::subtitle() Scene* TextureTest::scene() { - Scene *scene = Scene::create(); + auto scene = Scene::create(); TextureTest *layer = new TextureTest(false, TEST_COUNT, s_nTexCurCase); scene->addChild(layer); layer->release(); @@ -355,6 +355,6 @@ Scene* TextureTest::scene() void runTextureTest() { s_nTexCurCase = 0; - Scene* scene = TextureTest::scene(); + auto scene = TextureTest::scene(); Director::getInstance()->replaceScene(scene); } diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceTouchesTest.cpp b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceTouchesTest.cpp index e4166b0ae5..92d242fb06 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceTouchesTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceTouchesTest.cpp @@ -28,7 +28,7 @@ void TouchesMainScene::showCurrentTest() if (layer) { - Scene* scene = Scene::create(); + auto scene = Scene::create(); scene->addChild(layer); layer->release(); @@ -40,10 +40,10 @@ void TouchesMainScene::onEnter() { PerformBasicLayer::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); // add title - LabelTTF *label = LabelTTF::create(title().c_str(), "Arial", 32); + auto label = LabelTTF::create(title().c_str(), "Arial", 32); addChild(label, 1); label->setPosition(Point(s.width/2, s.height-50)); @@ -99,7 +99,7 @@ std::string TouchesPerformTest1::title() void TouchesPerformTest1::registerWithTouchDispatcher() { - Director* director = Director::getInstance(); + auto director = Director::getInstance(); director->getTouchDispatcher()->addTargetedDelegate(this, 0, true); } @@ -142,7 +142,7 @@ std::string TouchesPerformTest2::title() void TouchesPerformTest2::registerWithTouchDispatcher() { - Director* director = Director::getInstance(); + auto director = Director::getInstance(); director->getTouchDispatcher()->addStandardDelegate(this, 0); } @@ -168,8 +168,8 @@ void TouchesPerformTest2::ccTouchesCancelled(Set* touches, Event* event) void runTouchesTest() { s_nTouchCurCase = 0; - Scene* scene = Scene::create(); - Layer* layer = new TouchesPerformTest1(true, TEST_COUNT, s_nTouchCurCase); + auto scene = Scene::create(); + auto layer = new TouchesPerformTest1(true, TEST_COUNT, s_nTouchCurCase); scene->addChild(layer); layer->release(); diff --git a/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp b/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp index 4ba33e79b1..03431c852e 100644 --- a/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp +++ b/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp @@ -23,7 +23,7 @@ static Layer* nextTestCase() sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - Layer* layer = (createFunctions[sceneIdx])(); + auto layer = (createFunctions[sceneIdx])(); layer->autorelease(); return layer; @@ -36,7 +36,7 @@ static Layer* backTestCase() if( sceneIdx < 0 ) sceneIdx += total; - Layer* layer = (createFunctions[sceneIdx])(); + auto layer = (createFunctions[sceneIdx])(); layer->autorelease(); return layer; @@ -44,7 +44,7 @@ static Layer* backTestCase() static Layer* restartTestCase() { - Layer* layer = (createFunctions[sceneIdx])(); + auto layer = (createFunctions[sceneIdx])(); layer->autorelease(); return layer; @@ -57,7 +57,7 @@ void RenderTextureTest::onEnter() void RenderTextureTest::restartCallback(Object* sender) { - Scene* s = new RenderTextureScene(); + auto s = new RenderTextureScene(); s->addChild(restartTestCase()); Director::getInstance()->replaceScene(s); @@ -66,7 +66,7 @@ void RenderTextureTest::restartCallback(Object* sender) void RenderTextureTest::nextCallback(Object* sender) { - Scene* s = new RenderTextureScene(); + auto s = new RenderTextureScene(); s->addChild( nextTestCase() ); Director::getInstance()->replaceScene(s); s->release(); @@ -74,7 +74,7 @@ void RenderTextureTest::nextCallback(Object* sender) void RenderTextureTest::backCallback(Object* sender) { - Scene* s = new RenderTextureScene(); + auto s = new RenderTextureScene(); s->addChild( backTestCase() ); Director::getInstance()->replaceScene(s); s->release(); @@ -95,7 +95,7 @@ std::string RenderTextureTest::subtitle() */ RenderTextureSave::RenderTextureSave() { - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); // create a render texture, this is what we are going to draw into _target = RenderTexture::create(s.width, s.height, Texture2D::PixelFormat::RGBA8888); @@ -115,9 +115,9 @@ RenderTextureSave::RenderTextureSave() // Save Image menu MenuItemFont::setFontSize(16); - MenuItem *item1 = MenuItemFont::create("Save Image", CC_CALLBACK_1(RenderTextureSave::saveImage, this)); - MenuItem *item2 = MenuItemFont::create("Clear", CC_CALLBACK_1(RenderTextureSave::clearImage, this)); - Menu *menu = Menu::create(item1, item2, NULL); + auto item1 = MenuItemFont::create("Save Image", CC_CALLBACK_1(RenderTextureSave::saveImage, this)); + auto item2 = MenuItemFont::create("Clear", CC_CALLBACK_1(RenderTextureSave::clearImage, this)); + auto menu = Menu::create(item1, item2, NULL); this->addChild(menu); menu->alignItemsVertically(); menu->setPosition(Point(VisibleRect::rightTop().x - 80, VisibleRect::rightTop().y - 30)); @@ -151,13 +151,13 @@ void RenderTextureSave::saveImage(cocos2d::Object *pSender) _target->saveToFile(jpg, Image::Format::JPG); - Image *pImage = _target->newImage(); + auto pImage = _target->newImage(); - Texture2D *tex = TextureCache::getInstance()->addUIImage(pImage, png); + auto tex = TextureCache::getInstance()->addUIImage(pImage, png); CC_SAFE_DELETE(pImage); - Sprite *sprite = Sprite::createWithTexture(tex); + auto sprite = Sprite::createWithTexture(tex); sprite->setScale(0.3f); addChild(sprite); @@ -178,9 +178,9 @@ RenderTextureSave::~RenderTextureSave() void RenderTextureSave::ccTouchesMoved(Set* touches, Event* event) { - Touch *touch = static_cast( touches->anyObject() ); - Point start = touch->getLocation(); - Point end = touch->getPreviousLocation(); + auto touch = static_cast( touches->anyObject() ); + auto start = touch->getLocation(); + auto end = touch->getPreviousLocation(); // begin drawing to the render texture _target->begin(); @@ -230,20 +230,20 @@ RenderTextureIssue937::RenderTextureIssue937() * B1: non-premulti sprite * B2: non-premulti render */ - LayerColor *background = LayerColor::create(Color4B(200,200,200,255)); + auto background = LayerColor::create(Color4B(200,200,200,255)); addChild(background); - Sprite *spr_premulti = Sprite::create("Images/fire.png"); + auto spr_premulti = Sprite::create("Images/fire.png"); spr_premulti->setPosition(Point(16,48)); - Sprite *spr_nonpremulti = Sprite::create("Images/fire.png"); + auto spr_nonpremulti = Sprite::create("Images/fire.png"); spr_nonpremulti->setPosition(Point(16,16)); /* A2 & B2 setup */ - RenderTexture *rend = RenderTexture::create(32, 64, Texture2D::PixelFormat::RGBA8888); + auto rend = RenderTexture::create(32, 64, Texture2D::PixelFormat::RGBA8888); if (NULL == rend) { @@ -258,7 +258,7 @@ RenderTextureIssue937::RenderTextureIssue937() spr_nonpremulti->visit(); rend->end(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); /* A1: setup */ spr_premulti->setPosition(Point(s.width/2-16, s.height/2+16)); @@ -284,7 +284,7 @@ std::string RenderTextureIssue937::subtitle() void RenderTextureScene::runThisTest() { - Layer* layer = nextTestCase(); + auto layer = nextTestCase(); addChild(layer); Director::getInstance()->replaceScene(this); @@ -297,16 +297,16 @@ void RenderTextureScene::runThisTest() RenderTextureZbuffer::RenderTextureZbuffer() { this->setTouchEnabled(true); - Size size = Director::getInstance()->getWinSize(); - LabelTTF *label = LabelTTF::create("vertexZ = 50", "Marker Felt", 64); + auto size = Director::getInstance()->getWinSize(); + auto label = LabelTTF::create("vertexZ = 50", "Marker Felt", 64); label->setPosition(Point(size.width / 2, size.height * 0.25f)); this->addChild(label); - LabelTTF *label2 = LabelTTF::create("vertexZ = 0", "Marker Felt", 64); + auto label2 = LabelTTF::create("vertexZ = 0", "Marker Felt", 64); label2->setPosition(Point(size.width / 2, size.height * 0.5f)); this->addChild(label2); - LabelTTF *label3 = LabelTTF::create("vertexZ = -50", "Marker Felt", 64); + auto label3 = LabelTTF::create("vertexZ = -50", "Marker Felt", 64); label3->setPosition(Point(size.width / 2, size.height * 0.75f)); this->addChild(label3); @@ -366,8 +366,8 @@ void RenderTextureZbuffer::ccTouchesBegan(cocos2d::Set *touches, cocos2d::Event for (auto &item: *touches) { - Touch *touch = static_cast(item); - Point location = touch->getLocation(); + auto touch = static_cast(item); + auto location = touch->getLocation(); sp1->setPosition(location); sp2->setPosition(location); @@ -385,8 +385,8 @@ void RenderTextureZbuffer::ccTouchesMoved(Set* touches, Event* event) { for (auto &item: *touches) { - Touch *touch = static_cast(item); - Point location = touch->getLocation(); + auto touch = static_cast(item); + auto location = touch->getLocation(); sp1->setPosition(location); sp2->setPosition(location); @@ -407,7 +407,7 @@ void RenderTextureZbuffer::ccTouchesEnded(Set* touches, Event* event) void RenderTextureZbuffer::renderScreenShot() { - RenderTexture *texture = RenderTexture::create(512, 512); + auto texture = RenderTexture::create(512, 512); if (NULL == texture) { return; @@ -419,7 +419,7 @@ void RenderTextureZbuffer::renderScreenShot() texture->end(); - Sprite *sprite = Sprite::createWithTexture(texture->getSprite()->getTexture()); + auto sprite = Sprite::createWithTexture(texture->getSprite()->getTexture()); sprite->setPosition(Point(256, 256)); sprite->setOpacity(182); @@ -436,12 +436,12 @@ void RenderTextureZbuffer::renderScreenShot() RenderTextureTestDepthStencil::RenderTextureTestDepthStencil() { - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *sprite = Sprite::create("Images/fire.png"); + auto sprite = Sprite::create("Images/fire.png"); sprite->setPosition(Point(s.width * 0.25f, 0)); sprite->setScale(10); - RenderTexture *rend = RenderTexture::create(s.width, s.height, Texture2D::PixelFormat::RGBA4444, GL_DEPTH24_STENCIL8); + auto rend = RenderTexture::create(s.width, s.height, Texture2D::PixelFormat::RGBA4444, GL_DEPTH24_STENCIL8); glStencilMask(0xFF); rend->beginWithClear(0, 0, 0, 0, 0, 0); @@ -491,7 +491,7 @@ RenderTextureTargetNode::RenderTextureTargetNode() * B1: non-premulti sprite * B2: non-premulti render */ - LayerColor *background = LayerColor::create(Color4B(40,40,40,255)); + auto background = LayerColor::create(Color4B(40,40,40,255)); addChild(background); // sprite 1 @@ -500,10 +500,10 @@ RenderTextureTargetNode::RenderTextureTargetNode() // sprite 2 sprite2 = Sprite::create("Images/fire_rgba8888.pvr"); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); /* Create the render texture */ - RenderTexture *renderTexture = RenderTexture::create(s.width, s.height, Texture2D::PixelFormat::RGBA4444); + auto renderTexture = RenderTexture::create(s.width, s.height, Texture2D::PixelFormat::RGBA4444); this->renderTexture = renderTexture; renderTexture->setPosition(Point(s.width/2, s.height/2)); @@ -524,8 +524,8 @@ RenderTextureTargetNode::RenderTextureTargetNode() scheduleUpdate(); // Toggle clear on / off - MenuItemFont *item = MenuItemFont::create("Clear On/Off", CC_CALLBACK_1(RenderTextureTargetNode::touched, this)); - Menu *menu = Menu::create(item, NULL); + auto item = MenuItemFont::create("Clear On/Off", CC_CALLBACK_1(RenderTextureTargetNode::touched, this)); + auto menu = Menu::create(item, NULL); addChild(menu); menu->setPosition(Point(s.width/2, s.height/2)); @@ -570,7 +570,7 @@ SpriteRenderTextureBug::SimpleSprite::SimpleSprite() : rt(NULL) {} SpriteRenderTextureBug::SimpleSprite* SpriteRenderTextureBug::SimpleSprite::create(const char* filename, const Rect &rect) { - SimpleSprite *sprite = new SimpleSprite(); + auto sprite = new SimpleSprite(); if (sprite && sprite->initWithFile(filename, rect)) { sprite->autorelease(); @@ -587,7 +587,7 @@ void SpriteRenderTextureBug::SimpleSprite::draw() { if (rt == NULL) { - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); rt = new RenderTexture(); rt->initWithWidthAndHeight(s.width, s.height, Texture2D::PixelFormat::RGBA8888); } @@ -629,7 +629,7 @@ SpriteRenderTextureBug::SpriteRenderTextureBug() { setTouchEnabled(true); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); addNewSpriteWithCoords(Point(s.width/2, s.height/2)); } @@ -639,7 +639,7 @@ SpriteRenderTextureBug::SimpleSprite* SpriteRenderTextureBug::addNewSpriteWithCo int x = (idx%5) * 85; int y = (idx/5) * 121; - SpriteRenderTextureBug::SimpleSprite *sprite = SpriteRenderTextureBug::SimpleSprite::create("Images/grossini_dance_atlas.png", + auto sprite = SpriteRenderTextureBug::SimpleSprite::create("Images/grossini_dance_atlas.png", Rect(x,y,85,121)); addChild(sprite); @@ -659,8 +659,8 @@ SpriteRenderTextureBug::SimpleSprite* SpriteRenderTextureBug::addNewSpriteWithCo else action = FadeOut::create(2); - FiniteTimeAction *action_back = action->reverse(); - Sequence *seq = Sequence::create(action, action_back, NULL); + auto action_back = action->reverse(); + auto seq = Sequence::create(action, action_back, NULL); sprite->runAction(RepeatForever::create(seq)); @@ -672,8 +672,8 @@ void SpriteRenderTextureBug::ccTouchesEnded(Set* touches, Event* event) { for (auto &item: *touches) { - Touch *touch = static_cast(item); - Point location = touch->getLocation(); + auto touch = static_cast(item); + auto location = touch->getLocation(); addNewSpriteWithCoords(location); } } diff --git a/samples/Cpp/TestCpp/Classes/RotateWorldTest/RotateWorldTest.cpp b/samples/Cpp/TestCpp/Classes/RotateWorldTest/RotateWorldTest.cpp index 8cbed145ec..865861a5ab 100644 --- a/samples/Cpp/TestCpp/Classes/RotateWorldTest/RotateWorldTest.cpp +++ b/samples/Cpp/TestCpp/Classes/RotateWorldTest/RotateWorldTest.cpp @@ -12,14 +12,14 @@ void TestLayer::onEnter() float x,y; - Size size = Director::getInstance()->getWinSize(); + auto size = Director::getInstance()->getWinSize(); x = size.width; y = size.height; - //CCMutableArray *array = [UIFont familyNames]; + //auto array = [UIFont familyNames]; //for( String *s in array ) // NSLog( s ); - LabelTTF* label = LabelTTF::create("cocos2d", "Tahoma", 64); + auto label = LabelTTF::create("cocos2d", "Tahoma", 64); label->setPosition( Point(x/2,y/2) ); @@ -37,13 +37,13 @@ void SpriteLayer::onEnter() float x,y; - Size size = Director::getInstance()->getWinSize(); + auto size = Director::getInstance()->getWinSize(); x = size.width; y = size.height; - Sprite* sprite = Sprite::create(s_pathGrossini); - Sprite* spriteSister1 = Sprite::create(s_pathSister1); - Sprite* spriteSister2 = Sprite::create(s_pathSister2); + auto sprite = Sprite::create(s_pathGrossini); + auto spriteSister1 = Sprite::create(s_pathSister1); + auto spriteSister2 = Sprite::create(s_pathSister2); sprite->setScale(1.5f); spriteSister1->setScale(1.5f); @@ -53,7 +53,7 @@ void SpriteLayer::onEnter() spriteSister1->setPosition(Point(40,y/2)); spriteSister2->setPosition(Point(x-40,y/2)); - Action *rot = RotateBy::create(16, -3600); + auto rot = RotateBy::create(16, -3600); addChild(sprite); addChild(spriteSister1); @@ -61,11 +61,11 @@ void SpriteLayer::onEnter() sprite->runAction(rot); - ActionInterval *jump1 = JumpBy::create(4, Point(-400,0), 100, 4); - ActionInterval *jump2 = jump1->reverse(); + auto jump1 = JumpBy::create(4, Point(-400,0), 100, 4); + auto jump2 = jump1->reverse(); - ActionInterval *rot1 = RotateBy::create(4, 360*2); - ActionInterval *rot2 = rot1->reverse(); + auto rot1 = RotateBy::create(4, 360*2); + auto rot2 = rot1->reverse(); spriteSister1->runAction(Repeat::create( Sequence::create(jump2, jump1, NULL), 5 )); spriteSister2->runAction(Repeat::create( Sequence::create(jump1->clone(), jump2->clone(), NULL), 5 )); @@ -86,14 +86,14 @@ void RotateWorldMainLayer::onEnter() float x,y; - Size size = Director::getInstance()->getWinSize(); + auto size = Director::getInstance()->getWinSize(); x = size.width; y = size.height; - Node* blue = LayerColor::create(Color4B(0,0,255,255)); - Node* red = LayerColor::create(Color4B(255,0,0,255)); - Node* green = LayerColor::create(Color4B(0,255,0,255)); - Node* white = LayerColor::create(Color4B(255,255,255,255)); + auto blue = LayerColor::create(Color4B(0,0,255,255)); + auto red = LayerColor::create(Color4B(255,0,0,255)); + auto green = LayerColor::create(Color4B(0,255,0,255)); + auto white = LayerColor::create(Color4B(255,255,255,255)); blue->setScale(0.5f); blue->setPosition(Point(-x/4,-y/4)); @@ -116,7 +116,7 @@ void RotateWorldMainLayer::onEnter() addChild(green); addChild(red); - Action* rot = RotateBy::create(8, 720); + auto rot = RotateBy::create(8, 720); blue->runAction(rot); red->runAction(rot->clone()); @@ -126,7 +126,7 @@ void RotateWorldMainLayer::onEnter() void RotateWorldTestScene::runThisTest() { - Layer* layer = RotateWorldMainLayer::create(); + auto layer = RotateWorldMainLayer::create(); addChild(layer); runAction( RotateBy::create(4, -360) ); diff --git a/samples/Cpp/TestCpp/Classes/SceneTest/SceneTest.cpp b/samples/Cpp/TestCpp/Classes/SceneTest/SceneTest.cpp index 4c175f8ede..aabbcd3846 100644 --- a/samples/Cpp/TestCpp/Classes/SceneTest/SceneTest.cpp +++ b/samples/Cpp/TestCpp/Classes/SceneTest/SceneTest.cpp @@ -18,21 +18,21 @@ enum SceneTestLayer1::SceneTestLayer1() { - MenuItemFont* item1 = MenuItemFont::create( "Test pushScene", CC_CALLBACK_1(SceneTestLayer1::onPushScene, this)); - MenuItemFont* item2 = MenuItemFont::create( "Test pushScene w/transition", CC_CALLBACK_1(SceneTestLayer1::onPushSceneTran, this)); - MenuItemFont* item3 = MenuItemFont::create( "Quit", CC_CALLBACK_1(SceneTestLayer1::onQuit, this)); + auto item1 = MenuItemFont::create( "Test pushScene", CC_CALLBACK_1(SceneTestLayer1::onPushScene, this)); + auto item2 = MenuItemFont::create( "Test pushScene w/transition", CC_CALLBACK_1(SceneTestLayer1::onPushSceneTran, this)); + auto item3 = MenuItemFont::create( "Quit", CC_CALLBACK_1(SceneTestLayer1::onQuit, this)); - Menu* menu = Menu::create( item1, item2, item3, NULL ); + auto menu = Menu::create( item1, item2, item3, NULL ); menu->alignItemsVertically(); addChild( menu ); - Size s = Director::getInstance()->getWinSize(); - Sprite* sprite = Sprite::create(s_pathGrossini); + auto s = Director::getInstance()->getWinSize(); + auto sprite = Sprite::create(s_pathGrossini); addChild(sprite); sprite->setPosition( Point(s.width-40, s.height/2) ); - ActionInterval* rotate = RotateBy::create(2, 360); - Action* repeat = RepeatForever::create(rotate); + auto rotate = RotateBy::create(2, 360); + auto repeat = RepeatForever::create(rotate); sprite->runAction(repeat); schedule( schedule_selector(SceneTestLayer1::testDealloc) ); @@ -62,8 +62,8 @@ SceneTestLayer1::~SceneTestLayer1() void SceneTestLayer1::onPushScene(Object* sender) { - Scene* scene = new SceneTestScene(); - Layer* layer = new SceneTestLayer2(); + auto scene = new SceneTestScene(); + auto layer = new SceneTestLayer2(); scene->addChild( layer, 0 ); Director::getInstance()->pushScene( scene ); scene->release(); @@ -72,8 +72,8 @@ void SceneTestLayer1::onPushScene(Object* sender) void SceneTestLayer1::onPushSceneTran(Object* sender) { - Scene* scene = new SceneTestScene(); - Layer* layer = new SceneTestLayer2(); + auto scene = new SceneTestScene(); + auto layer = new SceneTestLayer2(); scene->addChild( layer, 0 ); Director::getInstance()->pushScene( TransitionSlideInT::create(1, scene) ); @@ -103,21 +103,21 @@ SceneTestLayer2::SceneTestLayer2() { _timeCounter = 0; - MenuItemFont* item1 = MenuItemFont::create( "replaceScene", CC_CALLBACK_1(SceneTestLayer2::onReplaceScene, this)); - MenuItemFont* item2 = MenuItemFont::create( "replaceScene w/transition", CC_CALLBACK_1(SceneTestLayer2::onReplaceSceneTran, this)); - MenuItemFont* item3 = MenuItemFont::create( "Go Back", CC_CALLBACK_1(SceneTestLayer2::onGoBack, this)); + auto item1 = MenuItemFont::create( "replaceScene", CC_CALLBACK_1(SceneTestLayer2::onReplaceScene, this)); + auto item2 = MenuItemFont::create( "replaceScene w/transition", CC_CALLBACK_1(SceneTestLayer2::onReplaceSceneTran, this)); + auto item3 = MenuItemFont::create( "Go Back", CC_CALLBACK_1(SceneTestLayer2::onGoBack, this)); - Menu* menu = Menu::create( item1, item2, item3, NULL ); + auto menu = Menu::create( item1, item2, item3, NULL ); menu->alignItemsVertically(); addChild( menu ); - Size s = Director::getInstance()->getWinSize(); - Sprite* sprite = Sprite::create(s_pathGrossini); + auto s = Director::getInstance()->getWinSize(); + auto sprite = Sprite::create(s_pathGrossini); addChild(sprite); sprite->setPosition( Point(s.width-40, s.height/2) ); - ActionInterval* rotate = RotateBy::create(2, 360); - Action* repeat = RepeatForever::create(rotate); + auto rotate = RotateBy::create(2, 360); + auto repeat = RepeatForever::create(rotate); sprite->runAction(repeat); schedule( schedule_selector(SceneTestLayer2::testDealloc) ); @@ -137,8 +137,8 @@ void SceneTestLayer2::onGoBack(Object* sender) void SceneTestLayer2::onReplaceScene(Object* sender) { - Scene* scene = new SceneTestScene(); - Layer* layer = SceneTestLayer3::create(); + auto scene = new SceneTestScene(); + auto layer = SceneTestLayer3::create(); scene->addChild( layer, 0 ); Director::getInstance()->replaceScene( scene ); scene->release(); @@ -147,8 +147,8 @@ void SceneTestLayer2::onReplaceScene(Object* sender) void SceneTestLayer2::onReplaceSceneTran(Object* sender) { - Scene* scene = new SceneTestScene(); - Layer* layer = SceneTestLayer3::create(); + auto scene = new SceneTestScene(); + auto layer = SceneTestLayer3::create(); scene->addChild( layer, 0 ); Director::getInstance()->replaceScene( TransitionFlipX::create(2, scene) ); scene->release(); @@ -169,24 +169,24 @@ bool SceneTestLayer3::init() { if (LayerColor::initWithColor(Color4B(0,0,255,255))) { - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - MenuItemFont *item0 = MenuItemFont::create("Touch to pushScene (self)", CC_CALLBACK_1(SceneTestLayer3::item0Clicked, this)); - MenuItemFont *item1 = MenuItemFont::create("Touch to poscene", CC_CALLBACK_1(SceneTestLayer3::item1Clicked, this)); - MenuItemFont *item2 = MenuItemFont::create("Touch to popToRootScene", CC_CALLBACK_1(SceneTestLayer3::item2Clicked, this)); - MenuItemFont *item3 = MenuItemFont::create("Touch to popToSceneStackLevel(2)", CC_CALLBACK_1(SceneTestLayer3::item3Clicked, this)); + auto item0 = MenuItemFont::create("Touch to pushScene (self)", CC_CALLBACK_1(SceneTestLayer3::item0Clicked, this)); + auto item1 = MenuItemFont::create("Touch to poscene", CC_CALLBACK_1(SceneTestLayer3::item1Clicked, this)); + auto item2 = MenuItemFont::create("Touch to popToRootScene", CC_CALLBACK_1(SceneTestLayer3::item2Clicked, this)); + auto item3 = MenuItemFont::create("Touch to popToSceneStackLevel(2)", CC_CALLBACK_1(SceneTestLayer3::item3Clicked, this)); - Menu *menu = Menu::create(item0, item1, item2, item3, NULL); + auto menu = Menu::create(item0, item1, item2, item3, NULL); this->addChild(menu); menu->alignItemsVertically(); this->schedule(schedule_selector(SceneTestLayer3::testDealloc)); - Sprite* sprite = Sprite::create(s_pathGrossini); + auto sprite = Sprite::create(s_pathGrossini); addChild(sprite); sprite->setPosition( Point(s.width/2, 40) ); - ActionInterval* rotate = RotateBy::create(2, 360); - Action* repeat = RepeatForever::create(rotate); + auto rotate = RotateBy::create(2, 360); + auto repeat = RepeatForever::create(rotate); sprite->runAction(repeat); return true; } @@ -200,7 +200,7 @@ void SceneTestLayer3::testDealloc(float dt) void SceneTestLayer3::item0Clicked(Object* sender) { - Scene *newScene = Scene::create(); + auto newScene = Scene::create(); newScene->addChild(SceneTestLayer3::create()); Director::getInstance()->pushScene(TransitionFade::create(0.5, newScene, Color3B(0,255,255))); } @@ -222,7 +222,7 @@ void SceneTestLayer3::item3Clicked(Object* sender) void SceneTestScene::runThisTest() { - Layer* layer = new SceneTestLayer1(); + auto layer = new SceneTestLayer1(); addChild(layer); layer->release(); diff --git a/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.cpp b/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.cpp index 510f3b07b9..8f23804f7b 100644 --- a/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.cpp +++ b/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.cpp @@ -54,7 +54,7 @@ Layer* nextSchedulerTest() sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - Layer* layer = (createFunctions[sceneIdx])(); + auto layer = (createFunctions[sceneIdx])(); layer->init(); layer->autorelease(); @@ -68,7 +68,7 @@ Layer* backSchedulerTest() if( sceneIdx < 0 ) sceneIdx += total; - Layer* layer = (createFunctions[sceneIdx])(); + auto layer = (createFunctions[sceneIdx])(); layer->init(); layer->autorelease(); @@ -77,7 +77,7 @@ Layer* backSchedulerTest() Layer* restartSchedulerTest() { - Layer* layer = (createFunctions[sceneIdx])(); + auto layer = (createFunctions[sceneIdx])(); layer->init(); layer->autorelease(); @@ -96,8 +96,8 @@ void SchedulerTestLayer::onEnter() void SchedulerTestLayer::backCallback(Object* sender) { - Scene* scene = new SchedulerTestScene(); - Layer* layer = backSchedulerTest(); + auto scene = new SchedulerTestScene(); + auto layer = backSchedulerTest(); scene->addChild(layer); Director::getInstance()->replaceScene(scene); @@ -106,8 +106,8 @@ void SchedulerTestLayer::backCallback(Object* sender) void SchedulerTestLayer::nextCallback(Object* sender) { - Scene* scene = new SchedulerTestScene(); - Layer* layer = nextSchedulerTest(); + auto scene = new SchedulerTestScene(); + auto layer = nextSchedulerTest(); scene->addChild(layer); Director::getInstance()->replaceScene(scene); @@ -116,8 +116,8 @@ void SchedulerTestLayer::nextCallback(Object* sender) void SchedulerTestLayer::restartCallback(Object* sender) { - Scene* scene = new SchedulerTestScene(); - Layer* layer = restartSchedulerTest(); + auto scene = new SchedulerTestScene(); + auto layer = restartSchedulerTest(); scene->addChild(layer); Director::getInstance()->replaceScene(scene); @@ -235,7 +235,7 @@ void SchedulerPauseResumeAll::onEnter() { SchedulerTestLayer::onEnter(); - Sprite *sprite = Sprite::create("Images/grossinis_sister1.png"); + auto sprite = Sprite::create("Images/grossinis_sister1.png"); sprite->setPosition(VisibleRect::center()); this->addChild(sprite); sprite->runAction(RepeatForever::create(RotateBy::create(3.0, 360))); @@ -272,7 +272,7 @@ void SchedulerPauseResumeAll::tick2(float dt) void SchedulerPauseResumeAll::pause(float dt) { log("Pausing"); - Director* director = Director::getInstance(); + auto director = Director::getInstance(); _pausedTargets = director->getScheduler()->pauseAllTargets(); CC_SAFE_RETAIN(_pausedTargets); @@ -288,7 +288,7 @@ void SchedulerPauseResumeAll::pause(float dt) void SchedulerPauseResumeAll::resume(float dt) { log("Resuming"); - Director* director = Director::getInstance(); + auto director = Director::getInstance(); director->getScheduler()->resumeTargets(_pausedTargets); CC_SAFE_RELEASE_NULL(_pausedTargets); } @@ -324,9 +324,9 @@ void SchedulerPauseResumeAllUser::onEnter() { SchedulerTestLayer::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *sprite = Sprite::create("Images/grossinis_sister1.png"); + auto sprite = Sprite::create("Images/grossinis_sister1.png"); sprite->setPosition(Point(s.width/2, s.height/2)); this->addChild(sprite); sprite->runAction(RepeatForever::create(RotateBy::create(3.0, 360))); @@ -358,7 +358,7 @@ void SchedulerPauseResumeAllUser::tick2(float dt) void SchedulerPauseResumeAllUser::pause(float dt) { log("Pausing"); - Director* director = Director::getInstance(); + auto director = Director::getInstance(); _pausedTargets = director->getScheduler()->pauseAllTargetsWithMinPriority(Scheduler::PRIORITY_NON_SYSTEM_MIN); CC_SAFE_RETAIN(_pausedTargets); } @@ -366,7 +366,7 @@ void SchedulerPauseResumeAllUser::pause(float dt) void SchedulerPauseResumeAllUser::resume(float dt) { log("Resuming"); - Director* director = Director::getInstance(); + auto director = Director::getInstance(); director->getScheduler()->resumeTargets(_pausedTargets); CC_SAFE_RELEASE_NULL(_pausedTargets); } @@ -442,9 +442,9 @@ void SchedulerUnscheduleAllHard::onEnter() { SchedulerTestLayer::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *sprite = Sprite::create("Images/grossinis_sister1.png"); + auto sprite = Sprite::create("Images/grossinis_sister1.png"); sprite->setPosition(Point(s.width/2, s.height/2)); this->addChild(sprite); sprite->runAction(RepeatForever::create(RotateBy::create(3.0, 360))); @@ -462,7 +462,7 @@ void SchedulerUnscheduleAllHard::onExit() { if(!_actionManagerActive) { // Restore the director's action manager. - Director* director = Director::getInstance(); + auto director = Director::getInstance(); director->getScheduler()->scheduleUpdateForTarget(director->getActionManager(), Scheduler::PRIORITY_SYSTEM, false); } } @@ -512,9 +512,9 @@ void SchedulerUnscheduleAllUserLevel::onEnter() { SchedulerTestLayer::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *sprite = Sprite::create("Images/grossinis_sister1.png"); + auto sprite = Sprite::create("Images/grossinis_sister1.png"); sprite->setPosition(Point(s.width/2, s.height/2)); this->addChild(sprite); sprite->runAction(RepeatForever::create(RotateBy::create(3.0, 360))); @@ -647,42 +647,42 @@ void SchedulerUpdate::onEnter() { SchedulerTestLayer::onEnter(); - TestNode* d = new TestNode(); - String* pStr = new String("---"); + auto d = new TestNode(); + auto pStr = new String("---"); d->initWithString(pStr, 50); pStr->release(); addChild(d); d->release(); - TestNode* b = new TestNode(); + auto b = new TestNode(); pStr = new String("3rd"); b->initWithString(pStr, 0); pStr->release(); addChild(b); b->release(); - TestNode* a = new TestNode(); + auto a = new TestNode(); pStr = new String("1st"); a->initWithString(pStr, -10); pStr->release(); addChild(a); a->release(); - TestNode* c = new TestNode(); + auto c = new TestNode(); pStr = new String("4th"); c->initWithString(pStr, 10); pStr->release(); addChild(c); c->release(); - TestNode* e = new TestNode(); + auto e = new TestNode(); pStr = new String("5th"); e->initWithString(pStr, 20); pStr->release(); addChild(e); e->release(); - TestNode* f = new TestNode(); + auto f = new TestNode(); pStr = new String("2nd"); f->initWithString(pStr, -5); pStr->release(); @@ -694,7 +694,7 @@ void SchedulerUpdate::onEnter() void SchedulerUpdate::removeUpdates(float dt) { - Array* children = getChildren(); + auto children = getChildren(); Node* node; Object* pObject; CCARRAY_FOREACH(children, pObject) @@ -887,25 +887,25 @@ void SchedulerTimeScale::onEnter() { SchedulerTestLayer::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); // rotate and jump - ActionInterval *jump1 = JumpBy::create(4, Point(-s.width+80,0), 100, 4); - ActionInterval *jump2 = jump1->reverse(); - ActionInterval *rot1 = RotateBy::create(4, 360*2); - ActionInterval *rot2 = rot1->reverse(); + auto jump1 = JumpBy::create(4, Point(-s.width+80,0), 100, 4); + auto jump2 = jump1->reverse(); + auto rot1 = RotateBy::create(4, 360*2); + auto rot2 = rot1->reverse(); - Sequence* seq3_1 = Sequence::create(jump2, jump1, NULL); - Sequence* seq3_2 = Sequence::create(rot1, rot2, NULL); - FiniteTimeAction* spawn = Spawn::create(seq3_1, seq3_2, NULL); - Repeat* action = Repeat::create(spawn, 50); + auto seq3_1 = Sequence::create(jump2, jump1, NULL); + auto seq3_2 = Sequence::create(rot1, rot2, NULL); + auto spawn = Spawn::create(seq3_1, seq3_2, NULL); + auto action = Repeat::create(spawn, 50); - Repeat* action2 = action->clone(); - Repeat* action3 = action->clone(); + auto action2 = action->clone(); + auto action3 = action->clone(); - Sprite *grossini = Sprite::create("Images/grossini.png"); - Sprite *tamara = Sprite::create("Images/grossinis_sister1.png"); - Sprite *kathia = Sprite::create("Images/grossinis_sister2.png"); + auto grossini = Sprite::create("Images/grossini.png"); + auto tamara = Sprite::create("Images/grossinis_sister1.png"); + auto kathia = Sprite::create("Images/grossinis_sister2.png"); grossini->setPosition(Point(40,80)); tamara->setPosition(Point(40,80)); @@ -919,7 +919,7 @@ void SchedulerTimeScale::onEnter() tamara->runAction(Speed::create(action2, 1.5f)); kathia->runAction(Speed::create(action3, 1.0f)); - ParticleSystem *emitter = ParticleFireworks::create(); + auto emitter = ParticleFireworks::create(); emitter->setTexture( TextureCache::getInstance()->addImage(s_stars1) ); addChild(emitter); @@ -950,7 +950,7 @@ std::string SchedulerTimeScale::subtitle() ControlSlider *TwoSchedulers::sliderCtl() { - // CGRect frame = CGRectMake(12.0f, 12.0f, 120.0f, 7.0f); + // auto frame = CGRectMake(12.0f, 12.0f, 120.0f, 7.0f); ControlSlider *slider = ControlSlider::create("extensions/sliderTrack2.png","extensions/sliderProgress2.png" ,"extensions/sliderThumb.png"); //[[UISlider alloc] initWithFrame:frame]; slider->addTargetWithActionForControlEvents(this, cccontrol_selector(TwoSchedulers::sliderAction), Control::EventType::VALUE_CHANGED); @@ -983,24 +983,24 @@ void TwoSchedulers::onEnter() { SchedulerTestLayer::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); // rotate and jump - ActionInterval *jump1 = JumpBy::create(4, Point(0,0), 100, 4); - ActionInterval *jump2 = jump1->reverse(); + auto jump1 = JumpBy::create(4, Point(0,0), 100, 4); + auto jump2 = jump1->reverse(); - Sequence* seq = Sequence::create(jump2, jump1, NULL); - RepeatForever* action = RepeatForever::create(seq); + auto seq = Sequence::create(jump2, jump1, NULL); + auto action = RepeatForever::create(seq); // // Center // - Sprite *grossini = Sprite::create("Images/grossini.png"); + auto grossini = Sprite::create("Images/grossini.png"); addChild(grossini); grossini->setPosition(Point(s.width/2,100)); grossini->runAction(action->clone()); - Scheduler *defaultScheduler = Director::getInstance()->getScheduler(); + auto defaultScheduler = Director::getInstance()->getScheduler(); // // Left: @@ -1017,7 +1017,7 @@ void TwoSchedulers::onEnter() for( unsigned int i=0; i < 10; i++ ) { - Sprite *sprite = Sprite::create("Images/grossinis_sister1.png"); + auto sprite = Sprite::create("Images/grossinis_sister1.png"); // IMPORTANT: Set the actionManager running any action sprite->setActionManager(actionManager1); @@ -1042,7 +1042,7 @@ void TwoSchedulers::onEnter() sched2->scheduleUpdateForTarget(actionManager2, 0, false); for( unsigned int i=0; i < 10; i++ ) { - Sprite *sprite = Sprite::create("Images/grossinis_sister2.png"); + auto sprite = Sprite::create("Images/grossinis_sister2.png"); // IMPORTANT: Set the actionManager running any action sprite->setActionManager(actionManager2); @@ -1067,7 +1067,7 @@ void TwoSchedulers::onEnter() TwoSchedulers::~TwoSchedulers() { - Scheduler *defaultScheduler = Director::getInstance()->getScheduler(); + auto defaultScheduler = Director::getInstance()->getScheduler(); defaultScheduler->unscheduleAllForTarget(sched1); defaultScheduler->unscheduleAllForTarget(sched2); @@ -1154,7 +1154,7 @@ std::string SchedulerIssue2268::subtitle() //------------------------------------------------------------------ void SchedulerTestScene::runThisTest() { - Layer* layer = nextSchedulerTest(); + auto layer = nextSchedulerTest(); addChild(layer); Director::getInstance()->replaceScene(this); diff --git a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.cpp b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.cpp index 676082733e..77682f7012 100644 --- a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.cpp @@ -29,7 +29,7 @@ static Layer* nextAction(void) sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - Layer* layer = createShaderLayer(sceneIdx); + auto layer = createShaderLayer(sceneIdx); layer->autorelease(); return layer; @@ -42,7 +42,7 @@ static Layer* backAction(void) if( sceneIdx < 0 ) sceneIdx += total; - Layer* layer = createShaderLayer(sceneIdx); + auto layer = createShaderLayer(sceneIdx); layer->autorelease(); return layer; @@ -50,7 +50,7 @@ static Layer* backAction(void) static Layer* restartAction(void) { - Layer* layer = createShaderLayer(sceneIdx); + auto layer = createShaderLayer(sceneIdx); layer->autorelease(); return layer; @@ -64,7 +64,7 @@ ShaderTestDemo::ShaderTestDemo() void ShaderTestDemo::backCallback(Object* sender) { - Scene* s = new ShaderTestScene(); + auto s = new ShaderTestScene(); s->addChild( backAction() ); Director::getInstance()->replaceScene(s); s->release(); @@ -72,7 +72,7 @@ void ShaderTestDemo::backCallback(Object* sender) void ShaderTestDemo::nextCallback(Object* sender) { - Scene* s = new ShaderTestScene();//CCScene::create(); + auto s = new ShaderTestScene();//CCScene::create(); s->addChild( nextAction() ); Director::getInstance()->replaceScene(s); s->release(); @@ -90,7 +90,7 @@ std::string ShaderTestDemo::subtitle() void ShaderTestDemo::restartCallback(Object* sender) { - Scene* s = new ShaderTestScene(); + auto s = new ShaderTestScene(); s->addChild(restartAction()); Director::getInstance()->replaceScene(s); @@ -125,7 +125,7 @@ ShaderNode::~ShaderNode() ShaderNode* ShaderNode::shaderNodeWithVertex(const char *vert, const char *frag) { - ShaderNode *node = new ShaderNode(); + auto node = new ShaderNode(); node->initWithVertex(vert, frag); node->autorelease(); @@ -163,7 +163,7 @@ void ShaderNode::listenBackToForeground(Object *obj) void ShaderNode::loadShaderVertex(const char *vert, const char *frag) { - GLProgram *shader = new GLProgram(); + auto shader = new GLProgram(); shader->initWithVertexShaderFilename(vert, frag); shader->addAttribute("aVertex", GLProgram::VERTEX_ATTRIB_POSITION); @@ -188,7 +188,7 @@ void ShaderNode::update(float dt) void ShaderNode::setPosition(const Point &newPosition) { Node::setPosition(newPosition); - Point position = getPosition(); + auto position = getPosition(); _center = Vertex2F(position.x * CC_CONTENT_SCALE_FACTOR(), position.y * CC_CONTENT_SCALE_FACTOR()); } @@ -229,9 +229,9 @@ bool ShaderMonjori::init() { if (ShaderTestDemo::init()) { - ShaderNode *sn = ShaderNode::shaderNodeWithVertex("Shaders/example_Monjori.vsh", "Shaders/example_Monjori.fsh"); + auto sn = ShaderNode::shaderNodeWithVertex("Shaders/example_Monjori.vsh", "Shaders/example_Monjori.fsh"); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); sn->setPosition(Point(s.width/2, s.height/2)); addChild(sn); @@ -263,9 +263,9 @@ bool ShaderMandelbrot::init() { if (ShaderTestDemo::init()) { - ShaderNode *sn = ShaderNode::shaderNodeWithVertex("Shaders/example_Mandelbrot.vsh", "Shaders/example_Mandelbrot.fsh"); + auto sn = ShaderNode::shaderNodeWithVertex("Shaders/example_Mandelbrot.vsh", "Shaders/example_Mandelbrot.fsh"); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); sn->setPosition(Point(s.width/2, s.height/2)); addChild(sn); @@ -296,9 +296,9 @@ bool ShaderJulia::init() { if (ShaderTestDemo::init()) { - ShaderNode *sn = ShaderNode::shaderNodeWithVertex("Shaders/example_Julia.vsh", "Shaders/example_Julia.fsh"); + auto sn = ShaderNode::shaderNodeWithVertex("Shaders/example_Julia.vsh", "Shaders/example_Julia.fsh"); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); sn->setPosition(Point(s.width/2, s.height/2)); addChild(sn); @@ -330,9 +330,9 @@ bool ShaderHeart::init() { if (ShaderTestDemo::init()) { - ShaderNode *sn = ShaderNode::shaderNodeWithVertex("Shaders/example_Heart.vsh", "Shaders/example_Heart.fsh"); + auto sn = ShaderNode::shaderNodeWithVertex("Shaders/example_Heart.vsh", "Shaders/example_Heart.fsh"); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); sn->setPosition(Point(s.width/2, s.height/2)); addChild(sn); @@ -363,9 +363,9 @@ bool ShaderFlower::init() { if (ShaderTestDemo::init()) { - ShaderNode *sn = ShaderNode::shaderNodeWithVertex("Shaders/example_Flower.vsh", "Shaders/example_Flower.fsh"); + auto sn = ShaderNode::shaderNodeWithVertex("Shaders/example_Flower.vsh", "Shaders/example_Flower.fsh"); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); sn->setPosition(Point(s.width/2, s.height/2)); addChild(sn); @@ -396,9 +396,9 @@ bool ShaderPlasma::init() { if (ShaderTestDemo::init()) { - ShaderNode *sn = ShaderNode::shaderNodeWithVertex("Shaders/example_Plasma.vsh", "Shaders/example_Plasma.fsh"); + auto sn = ShaderNode::shaderNodeWithVertex("Shaders/example_Plasma.vsh", "Shaders/example_Plasma.fsh"); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); sn->setPosition(Point(s.width/2, s.height/2)); addChild(sn); @@ -475,7 +475,7 @@ bool SpriteBlur::initWithTexture(Texture2D* texture, const Rect& rect) EVNET_COME_TO_FOREGROUND, NULL); - Size s = getTexture()->getContentSizeInPixels(); + auto s = getTexture()->getContentSizeInPixels(); blur_ = Point(1/s.width, 1/s.height); sub_[0] = sub_[1] = sub_[2] = sub_[3] = 0; @@ -492,7 +492,7 @@ void SpriteBlur::initProgram() { GLchar * fragSource = (GLchar*) String::createWithContentsOfFile( FileUtils::getInstance()->fullPathForFilename("Shaders/example_Blur.fsh").c_str())->getCString(); - GLProgram* pProgram = new GLProgram(); + auto pProgram = new GLProgram(); pProgram->initWithVertexShaderByteArray(ccPositionTextureColor_vert, fragSource); setShaderProgram(pProgram); pProgram->release(); @@ -558,7 +558,7 @@ void SpriteBlur::draw() void SpriteBlur::setBlurSize(float f) { - Size s = getTexture()->getContentSizeInPixels(); + auto s = getTexture()->getContentSizeInPixels(); blur_ = Point(1/s.width, 1/s.height); blur_ = blur_ * f; @@ -583,7 +583,7 @@ std::string ShaderBlur::subtitle() ControlSlider* ShaderBlur::createSliderCtl() { - Size screenSize = Director::getInstance()->getWinSize(); + auto screenSize = Director::getInstance()->getWinSize(); ControlSlider *slider = ControlSlider::create("extensions/sliderTrack.png","extensions/sliderProgress.png" ,"extensions/sliderThumb.png"); slider->setAnchorPoint(Point(0.5f, 1.0f)); @@ -605,9 +605,9 @@ bool ShaderBlur::init() { _blurSprite = SpriteBlur::create("Images/grossini.png"); - Sprite *sprite = Sprite::create("Images/grossini.png"); + auto sprite = Sprite::create("Images/grossini.png"); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); _blurSprite->setPosition(Point(s.width/3, s.height/2)); sprite->setPosition(Point(2*s.width/3, s.height/2)); @@ -643,7 +643,7 @@ bool ShaderRetroEffect::init() if( ShaderTestDemo::init() ) { GLchar * fragSource = (GLchar*) String::createWithContentsOfFile(FileUtils::getInstance()->fullPathForFilename("Shaders/example_HorizontalColor.fsh").c_str())->getCString(); - GLProgram *p = new GLProgram(); + auto p = new GLProgram(); p->initWithVertexShaderByteArray(ccPositionTexture_vert, fragSource); p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); @@ -653,8 +653,8 @@ bool ShaderRetroEffect::init() p->updateUniforms(); - Director *director = Director::getInstance(); - Size s = director->getWinSize(); + auto director = Director::getInstance(); + auto s = director->getWinSize(); _label = LabelBMFont::create("RETRO EFFECT", "fonts/west_england-64.fnt"); @@ -678,15 +678,15 @@ void ShaderRetroEffect::update(float dt) { _accum += dt; - Array* pArray = _label->getChildren(); + auto pArray = _label->getChildren(); int i=0; Object* pObj = NULL; CCARRAY_FOREACH(pArray, pObj) { - Sprite *sprite = static_cast(pObj); + auto sprite = static_cast(pObj); i++; - Point oldPosition = sprite->getPosition(); + auto oldPosition = sprite->getPosition(); sprite->setPosition(Point( oldPosition.x, sinf( _accum * 2 + i/2.0) * 20 )); // add fabs() to prevent negative scaling @@ -737,7 +737,7 @@ gl_FragColor = colors[z] * texture2D(CC_Texture0, v_texCoord); \n\ ShaderFail::ShaderFail() { - GLProgram *p = new GLProgram(); + auto p = new GLProgram(); p->initWithVertexShaderByteArray(ccPositionTexture_vert, shader_frag_fail); p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); diff --git a/samples/Cpp/TestCpp/Classes/SpineTest/SpineTest.cpp b/samples/Cpp/TestCpp/Classes/SpineTest/SpineTest.cpp index b404303a8e..0912cb419e 100644 --- a/samples/Cpp/TestCpp/Classes/SpineTest/SpineTest.cpp +++ b/samples/Cpp/TestCpp/Classes/SpineTest/SpineTest.cpp @@ -39,7 +39,7 @@ using namespace std; //------------------------------------------------------------------ void SpineTestScene::runThisTest() { - Layer* layer = SpineTestLayer::create(); + auto layer = SpineTestLayer::create(); addChild(layer); Director::getInstance()->replaceScene(this); diff --git a/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id b/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id index e04e178c10..2ecb9ef8f4 100644 --- a/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id +++ b/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id @@ -1 +1 @@ -8853550dc382b38c368250fb940660f35ee5ad4d \ No newline at end of file +4373d9564b36664491ceb5aabe27159a2eca32a6 \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Classes/TextInputTest/TextInputTest.cpp b/samples/Cpp/TestCpp/Classes/TextInputTest/TextInputTest.cpp index 55ccc82be6..b373f5223f 100644 --- a/samples/Cpp/TestCpp/Classes/TextInputTest/TextInputTest.cpp +++ b/samples/Cpp/TestCpp/Classes/TextInputTest/TextInputTest.cpp @@ -33,7 +33,7 @@ Layer* restartTextInputTest() TextInputTest* pContainerLayer = new TextInputTest; pContainerLayer->autorelease(); - KeyboardNotificationLayer* pTestLayer = createTextInputTest(testIdx); + auto pTestLayer = createTextInputTest(testIdx); pTestLayer->autorelease(); pContainerLayer->addKeyboardNotificationLayer(pTestLayer); @@ -80,7 +80,7 @@ TextInputTest::TextInputTest() void TextInputTest::restartCallback(Object* sender) { - Scene* s = new TextInputTestScene(); + auto s = new TextInputTestScene(); s->addChild(restartTextInputTest()); Director::getInstance()->replaceScene(s); @@ -89,7 +89,7 @@ void TextInputTest::restartCallback(Object* sender) void TextInputTest::nextCallback(Object* sender) { - Scene* s = new TextInputTestScene(); + auto s = new TextInputTestScene(); s->addChild( nextTextInputTest() ); Director::getInstance()->replaceScene(s); s->release(); @@ -97,7 +97,7 @@ void TextInputTest::nextCallback(Object* sender) void TextInputTest::backCallback(Object* sender) { - Scene* s = new TextInputTestScene(); + auto s = new TextInputTestScene(); s->addChild( backTextInputTest() ); Director::getInstance()->replaceScene(s); s->release(); @@ -131,7 +131,7 @@ KeyboardNotificationLayer::KeyboardNotificationLayer() void KeyboardNotificationLayer::registerWithTouchDispatcher() { - Director* director = Director::getInstance(); + auto director = Director::getInstance(); director->getTouchDispatcher()->addTargetedDelegate(this, 0, false); } @@ -145,7 +145,7 @@ void KeyboardNotificationLayer::keyboardWillShow(IMEKeyboardNotificationInfo& in return; } - Rect rectTracked = getRect(_trackNode); + auto rectTracked = getRect(_trackNode); CCLOG("TextInputTest:trackingNodeAt(origin:%f,%f, size:%f,%f)", rectTracked.origin.x, rectTracked.origin.y, rectTracked.size.width, rectTracked.size.height); @@ -160,7 +160,7 @@ void KeyboardNotificationLayer::keyboardWillShow(IMEKeyboardNotificationInfo& in CCLOG("TextInputTest:needAdjustVerticalPosition(%f)", adjustVert); // move all the children node of KeyboardNotificationLayer - Array * children = getChildren(); + auto children = getChildren(); Node * node = 0; int count = children->count(); Point pos; @@ -189,7 +189,7 @@ void KeyboardNotificationLayer::ccTouchEnded(Touch *touch, Event *event) return; } - Point endPos = touch->getLocation(); + auto endPos = touch->getLocation(); float delta = 5.0f; if (::abs(endPos.x - _beginPos.x) > delta @@ -202,7 +202,7 @@ void KeyboardNotificationLayer::ccTouchEnded(Touch *touch, Event *event) // decide the trackNode is clicked. Rect rect; - Point point = convertTouchToNodeSpaceAR(touch); + auto point = convertTouchToNodeSpaceAR(touch); CCLOG("KeyboardNotificationLayer:clickedAt(%f,%f)", point.x, point.y); rect = getRect(_trackNode); @@ -224,7 +224,7 @@ std::string TextFieldTTFDefaultTest::subtitle() void TextFieldTTFDefaultTest::onClickTrackNode(bool bClicked) { - TextFieldTTF * pTextField = (TextFieldTTF*)_trackNode; + auto pTextField = (TextFieldTTF*)_trackNode; if (bClicked) { // TextFieldTTFTest be clicked @@ -244,9 +244,9 @@ void TextFieldTTFDefaultTest::onEnter() KeyboardNotificationLayer::onEnter(); // add TextFieldTTF - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - TextFieldTTF * pTextField = TextFieldTTF::textFieldWithPlaceHolder("", + auto pTextField = TextFieldTTF::textFieldWithPlaceHolder("", FONT_NAME, FONT_SIZE); addChild(pTextField); @@ -273,7 +273,7 @@ std::string TextFieldTTFActionTest::subtitle() void TextFieldTTFActionTest::onClickTrackNode(bool bClicked) { - TextFieldTTF * pTextField = (TextFieldTTF*)_trackNode; + auto pTextField = (TextFieldTTF*)_trackNode; if (bClicked) { // TextFieldTTFTest be clicked @@ -304,7 +304,7 @@ void TextFieldTTFActionTest::onEnter() _action = false; // add TextFieldTTF - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); _textField = TextFieldTTF::textFieldWithPlaceHolder("", FONT_NAME, @@ -367,25 +367,25 @@ bool TextFieldTTFActionTest::onTextFieldInsertText(TextFieldTTF * sender, const } // create a insert text sprite and do some action - LabelTTF * label = LabelTTF::create(text, FONT_NAME, FONT_SIZE); + auto label = LabelTTF::create(text, FONT_NAME, FONT_SIZE); this->addChild(label); Color3B color(226, 121, 7); label->setColor(color); // move the sprite from top to position - Point endPos = sender->getPosition(); + auto endPos = sender->getPosition(); if (sender->getCharCount()) { endPos.x += sender->getContentSize().width / 2; } - Size inputTextSize = label->getContentSize(); + auto inputTextSize = label->getContentSize(); Point beginPos(endPos.x, Director::getInstance()->getWinSize().height - inputTextSize.height * 2); float duration = 0.5; label->setPosition(beginPos); label->setScale(8); - Action * seq = Sequence::create( + auto seq = Sequence::create( Spawn::create( MoveTo::create(duration, endPos), ScaleTo::create(duration, 1), @@ -400,16 +400,16 @@ bool TextFieldTTFActionTest::onTextFieldInsertText(TextFieldTTF * sender, const bool TextFieldTTFActionTest::onTextFieldDeleteBackward(TextFieldTTF * sender, const char * delText, int nLen) { // create a delete text sprite and do some action - LabelTTF * label = LabelTTF::create(delText, FONT_NAME, FONT_SIZE); + auto label = LabelTTF::create(delText, FONT_NAME, FONT_SIZE); this->addChild(label); // move the sprite to fly out - Point beginPos = sender->getPosition(); - Size textfieldSize = sender->getContentSize(); - Size labelSize = label->getContentSize(); + auto beginPos = sender->getPosition(); + auto textfieldSize = sender->getContentSize(); + auto labelSize = label->getContentSize(); beginPos.x += (textfieldSize.width - labelSize.width) / 2.0f; - Size winSize = Director::getInstance()->getWinSize(); + auto winSize = Director::getInstance()->getWinSize(); Point endPos(- winSize.width / 4.0f, winSize.height * (0.5 + (float)rand() / (2.0f * RAND_MAX))); float duration = 1; @@ -417,7 +417,7 @@ bool TextFieldTTFActionTest::onTextFieldDeleteBackward(TextFieldTTF * sender, co int repeatTime = 5; label->setPosition(beginPos); - Action * seq = Sequence::create( + auto seq = Sequence::create( Spawn::create( MoveTo::create(duration, endPos), Repeat::create( @@ -447,7 +447,7 @@ void TextFieldTTFActionTest::callbackRemoveNodeWhenDidAction(Node * node) void TextInputTestScene::runThisTest() { - Layer* layer = nextTextInputTest(); + auto layer = nextTextInputTest(); addChild(layer); Director::getInstance()->replaceScene(this); diff --git a/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp b/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp index 745ce80598..bca7de18b8 100644 --- a/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp +++ b/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp @@ -80,7 +80,7 @@ static unsigned int TEST_CASE_COUNT = sizeof(createFunctions) / sizeof(createFun static int sceneIdx=-1; Layer* createTextureTest(int index) { - Layer* layer = (createFunctions[index])();; + auto layer = (createFunctions[index])();; if (layer) { @@ -127,7 +127,7 @@ void TextureDemo::onEnter() TextureCache::getInstance()->dumpCachedTextureInfo(); - LayerColor *col = LayerColor::create(Color4B(128,128,128,255)); + auto col = LayerColor::create(Color4B(128,128,128,255)); addChild(col, -10); TextureCache::getInstance()->dumpCachedTextureInfo(); @@ -141,7 +141,7 @@ TextureDemo::~TextureDemo() void TextureDemo::restartCallback(Object* sender) { - Scene *s = new TextureTestScene(); + auto s = new TextureTestScene(); s->addChild(restartTextureTest()); Director::getInstance()->replaceScene(s); s->autorelease(); @@ -149,7 +149,7 @@ void TextureDemo::restartCallback(Object* sender) void TextureDemo::nextCallback(Object* sender) { - Scene *s = new TextureTestScene(); + auto s = new TextureTestScene(); s->addChild(nextTextureTest()); Director::getInstance()->replaceScene(s); s->autorelease(); @@ -157,7 +157,7 @@ void TextureDemo::nextCallback(Object* sender) void TextureDemo::backCallback(Object* sender) { - Scene *s = new TextureTestScene(); + auto s = new TextureTestScene(); s->addChild(backTextureTest()); Director::getInstance()->replaceScene(s); s->autorelease(); @@ -182,9 +182,9 @@ std::string TextureDemo::subtitle() void TextureTIFF::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *img = Sprite::create("Images/test_image.tiff"); + auto img = Sprite::create("Images/test_image.tiff"); img->setPosition(Point( s.width/2.0f, s.height/2.0f)); this->addChild(img); TextureCache::getInstance()->dumpCachedTextureInfo(); @@ -204,9 +204,9 @@ void TexturePNG::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *img = Sprite::create("Images/test_image.png"); + auto img = Sprite::create("Images/test_image.png"); img->setPosition(Point( s.width/2.0f, s.height/2.0f)); addChild(img); TextureCache::getInstance()->dumpCachedTextureInfo(); @@ -225,9 +225,9 @@ std::string TexturePNG::title() void TextureJPEG::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *img = Sprite::create("Images/test_image.jpeg"); + auto img = Sprite::create("Images/test_image.jpeg"); img->setPosition(Point( s.width/2.0f, s.height/2.0f)); addChild(img); TextureCache::getInstance()->dumpCachedTextureInfo(); @@ -246,9 +246,9 @@ std::string TextureJPEG::title() void TextureWEBP::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *img = Sprite::create("Images/test_image.webp"); + auto img = Sprite::create("Images/test_image.webp"); img->setPosition(Point( s.width/2.0f, s.height/2.0f)); addChild(img); TextureCache::getInstance()->dumpCachedTextureInfo(); @@ -267,21 +267,21 @@ std::string TextureWEBP::title() void TextureMipMap::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Texture2D *texture0 = TextureCache::getInstance()->addImage("Images/grossini_dance_atlas.png"); + auto texture0 = TextureCache::getInstance()->addImage("Images/grossini_dance_atlas.png"); texture0->generateMipmap(); Texture2D::TexParams texParams = { GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE }; texture0->setTexParameters(texParams); - Texture2D *texture1 = TextureCache::getInstance()->addImage("Images/grossini_dance_atlas_nomipmap.png"); + auto texture1 = TextureCache::getInstance()->addImage("Images/grossini_dance_atlas_nomipmap.png"); - Sprite *img0 = Sprite::createWithTexture(texture0); + auto img0 = Sprite::createWithTexture(texture0); img0->setTextureRect(Rect(85, 121, 85, 121)); img0->setPosition(Point( s.width/3.0f, s.height/2.0f)); addChild(img0); - Sprite *img1 = Sprite::createWithTexture(texture1); + auto img1 = Sprite::createWithTexture(texture1); img1->setTextureRect(Rect(85, 121, 85, 121)); img1->setPosition(Point( 2*s.width/3.0f, s.height/2.0f)); addChild(img1); @@ -318,9 +318,9 @@ std::string TextureMipMap::subtitle() void TexturePVRMipMap::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *imgMipMap = Sprite::create("Images/logo-mipmap.pvr"); + auto imgMipMap = Sprite::create("Images/logo-mipmap.pvr"); if( imgMipMap ) { imgMipMap->setPosition(Point( s.width/2.0f-100, s.height/2.0f)); @@ -331,7 +331,7 @@ void TexturePVRMipMap::onEnter() imgMipMap->getTexture()->setTexParameters(texParams); } - Sprite *img = Sprite::create("Images/logo-nomipmap.pvr"); + auto img = Sprite::create("Images/logo-nomipmap.pvr"); if( img ) { img->setPosition(Point( s.width/2.0f+100, s.height/2.0f)); @@ -366,9 +366,9 @@ std::string TexturePVRMipMap::subtitle() void TexturePVRMipMap2::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *imgMipMap = Sprite::create("Images/test_image_rgba4444_mipmap.pvr"); + auto imgMipMap = Sprite::create("Images/test_image_rgba4444_mipmap.pvr"); imgMipMap->setPosition(Point( s.width/2.0f-100, s.height/2.0f)); addChild(imgMipMap); @@ -376,7 +376,7 @@ void TexturePVRMipMap2::onEnter() Texture2D::TexParams texParams = { GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE }; imgMipMap->getTexture()->setTexParameters(texParams); - Sprite *img = Sprite::create("Images/test_image.png"); + auto img = Sprite::create("Images/test_image.png"); img->setPosition(Point( s.width/2.0f+100, s.height/2.0f)); addChild(img); @@ -411,9 +411,9 @@ std::string TexturePVRMipMap2::subtitle() void TexturePVR2BPP::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *img = Sprite::create("Images/test_image_pvrtc2bpp.pvr"); + auto img = Sprite::create("Images/test_image_pvrtc2bpp.pvr"); if( img ) { @@ -438,9 +438,9 @@ std::string TexturePVR2BPP::title() void TexturePVRTest::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *img = Sprite::create("Images/test_image.pvr"); + auto img = Sprite::create("Images/test_image.pvr"); if( img ) { @@ -470,9 +470,9 @@ std::string TexturePVRTest::title() void TexturePVR4BPP::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *img = Sprite::create("Images/test_image_pvrtc4bpp.pvr"); + auto img = Sprite::create("Images/test_image_pvrtc4bpp.pvr"); if( img ) { @@ -501,9 +501,9 @@ std::string TexturePVR4BPP::title() void TexturePVRRGBA8888::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *img = Sprite::create("Images/test_image_rgba8888.pvr"); + auto img = Sprite::create("Images/test_image_rgba8888.pvr"); img->setPosition(Point( s.width/2.0f, s.height/2.0f)); addChild(img); TextureCache::getInstance()->dumpCachedTextureInfo(); @@ -524,9 +524,9 @@ std::string TexturePVRRGBA8888::title() void TexturePVRBGRA8888::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *img = Sprite::create("Images/test_image_bgra8888.pvr"); + auto img = Sprite::create("Images/test_image_bgra8888.pvr"); if( img ) { img->setPosition(Point( s.width/2.0f, s.height/2.0f)); @@ -554,9 +554,9 @@ std::string TexturePVRBGRA8888::title() void TexturePVRRGBA5551::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *img = Sprite::create("Images/test_image_rgba5551.pvr"); + auto img = Sprite::create("Images/test_image_rgba5551.pvr"); img->setPosition(Point( s.width/2.0f, s.height/2.0f)); addChild(img); TextureCache::getInstance()->dumpCachedTextureInfo(); @@ -577,9 +577,9 @@ std::string TexturePVRRGBA5551::title() void TexturePVRRGBA4444::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *img = Sprite::create("Images/test_image_rgba4444.pvr"); + auto img = Sprite::create("Images/test_image_rgba4444.pvr"); img->setPosition(Point( s.width/2.0f, s.height/2.0f)); addChild(img); TextureCache::getInstance()->dumpCachedTextureInfo(); @@ -600,13 +600,13 @@ std::string TexturePVRRGBA4444::title() void TexturePVRRGBA4444GZ::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) // android can not pack .gz file into apk file - Sprite *img = Sprite::create("Images/test_image_rgba4444.pvr"); + auto img = Sprite::create("Images/test_image_rgba4444.pvr"); #else - Sprite *img = Sprite::create("Images/test_image_rgba4444.pvr.gz"); + auto img = Sprite::create("Images/test_image_rgba4444.pvr.gz"); #endif img->setPosition(Point( s.width/2.0f, s.height/2.0f)); addChild(img); @@ -633,9 +633,9 @@ std::string TexturePVRRGBA4444GZ::subtitle() void TexturePVRRGBA4444CCZ::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *img = Sprite::create("Images/test_image_rgba4444.pvr.ccz"); + auto img = Sprite::create("Images/test_image_rgba4444.pvr.ccz"); img->setPosition(Point( s.width/2.0f, s.height/2.0f)); addChild(img); TextureCache::getInstance()->dumpCachedTextureInfo(); @@ -661,9 +661,9 @@ std::string TexturePVRRGBA4444CCZ::subtitle() void TexturePVRRGB565::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *img = Sprite::create("Images/test_image_rgb565.pvr"); + auto img = Sprite::create("Images/test_image_rgb565.pvr"); img->setPosition(Point( s.width/2.0f, s.height/2.0f)); addChild(img); TextureCache::getInstance()->dumpCachedTextureInfo(); @@ -680,9 +680,9 @@ std::string TexturePVRRGB565::title() void TexturePVRRGB888::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *img = Sprite::create("Images/test_image_rgb888.pvr"); + auto img = Sprite::create("Images/test_image_rgb888.pvr"); if (img != NULL) { img->setPosition(Point( s.width/2.0f, s.height/2.0f)); @@ -707,9 +707,9 @@ std::string TexturePVRRGB888::title() void TexturePVRA8::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *img = Sprite::create("Images/test_image_a8.pvr"); + auto img = Sprite::create("Images/test_image_a8.pvr"); img->setPosition(Point( s.width/2.0f, s.height/2.0f)); addChild(img); TextureCache::getInstance()->dumpCachedTextureInfo(); @@ -731,9 +731,9 @@ std::string TexturePVRA8::title() void TexturePVRI8::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *img = Sprite::create("Images/test_image_i8.pvr"); + auto img = Sprite::create("Images/test_image_i8.pvr"); img->setPosition(Point( s.width/2.0f, s.height/2.0f)); addChild(img); TextureCache::getInstance()->dumpCachedTextureInfo(); @@ -754,9 +754,9 @@ std::string TexturePVRI8::title() void TexturePVRAI88::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *img = Sprite::create("Images/test_image_ai88.pvr"); + auto img = Sprite::create("Images/test_image_ai88.pvr"); img->setPosition(Point( s.width/2.0f, s.height/2.0f)); addChild(img); TextureCache::getInstance()->dumpCachedTextureInfo(); @@ -771,9 +771,9 @@ std::string TexturePVRAI88::title() void TexturePVR2BPPv3::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *img = Sprite::create("Images/test_image_pvrtc2bpp_v3.pvr"); + auto img = Sprite::create("Images/test_image_pvrtc2bpp_v3.pvr"); if (img) { @@ -798,9 +798,9 @@ string TexturePVR2BPPv3::subtitle() void TexturePVRII2BPPv3::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *img = Sprite::create("Images/test_image_pvrtcii2bpp_v3.pvr"); + auto img = Sprite::create("Images/test_image_pvrtcii2bpp_v3.pvr"); if (img) { @@ -825,9 +825,9 @@ string TexturePVRII2BPPv3::subtitle() void TexturePVR4BPPv3::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *img = Sprite::create("Images/test_image_pvrtc4bpp_v3.pvr"); + auto img = Sprite::create("Images/test_image_pvrtc4bpp_v3.pvr"); if (img) { @@ -860,9 +860,9 @@ string TexturePVR4BPPv3::subtitle() void TexturePVRII4BPPv3::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *img = Sprite::create("Images/test_image_pvrtcii4bpp_v3.pvr"); + auto img = Sprite::create("Images/test_image_pvrtcii4bpp_v3.pvr"); if (img) { @@ -891,9 +891,9 @@ string TexturePVRII4BPPv3::subtitle() void TexturePVRRGBA8888v3::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *img = Sprite::create("Images/test_image_rgba8888_v3.pvr"); + auto img = Sprite::create("Images/test_image_rgba8888_v3.pvr"); if (img) { @@ -918,9 +918,9 @@ string TexturePVRRGBA8888v3::subtitle() void TexturePVRBGRA8888v3::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *img = Sprite::create("Images/test_image_bgra8888_v3.pvr"); + auto img = Sprite::create("Images/test_image_bgra8888_v3.pvr"); if (img) { @@ -949,9 +949,9 @@ string TexturePVRBGRA8888v3::subtitle() void TexturePVRRGBA5551v3::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *img = Sprite::create("Images/test_image_rgba5551_v3.pvr"); + auto img = Sprite::create("Images/test_image_rgba5551_v3.pvr"); if (img) { @@ -976,9 +976,9 @@ string TexturePVRRGBA5551v3::subtitle() void TexturePVRRGBA4444v3::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *img = Sprite::create("Images/test_image_rgba4444_v3.pvr"); + auto img = Sprite::create("Images/test_image_rgba4444_v3.pvr"); if (img) { @@ -1003,9 +1003,9 @@ string TexturePVRRGBA4444v3::subtitle() void TexturePVRRGB565v3::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *img = Sprite::create("Images/test_image_rgb565_v3.pvr"); + auto img = Sprite::create("Images/test_image_rgb565_v3.pvr"); if (img) { @@ -1030,9 +1030,9 @@ string TexturePVRRGB565v3::subtitle() void TexturePVRRGB888v3::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *img = Sprite::create("Images/test_image_rgb888_v3.pvr"); + auto img = Sprite::create("Images/test_image_rgb888_v3.pvr"); if (img) { @@ -1057,9 +1057,9 @@ string TexturePVRRGB888v3::subtitle() void TexturePVRA8v3::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *img = Sprite::create("Images/test_image_a8_v3.pvr"); + auto img = Sprite::create("Images/test_image_a8_v3.pvr"); if (img) { @@ -1084,9 +1084,9 @@ string TexturePVRA8v3::subtitle() void TexturePVRI8v3::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *img = Sprite::create("Images/test_image_i8_v3.pvr"); + auto img = Sprite::create("Images/test_image_i8_v3.pvr"); if (img) { @@ -1111,9 +1111,9 @@ string TexturePVRI8v3::subtitle() void TexturePVRAI88v3::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *img = Sprite::create("Images/test_image_ai88_v3.pvr"); + auto img = Sprite::create("Images/test_image_ai88_v3.pvr"); if (img) { @@ -1144,9 +1144,9 @@ string TexturePVRAI88v3::subtitle() void TexturePVRBadEncoding::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *img = Sprite::create("Images/test_image-bad_encoding.pvr"); + auto img = Sprite::create("Images/test_image-bad_encoding.pvr"); if( img ) { img->setPosition(Point( s.width/2.0f, s.height/2.0f)); @@ -1172,9 +1172,9 @@ std::string TexturePVRBadEncoding::subtitle() void TexturePVRNonSquare::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *img = Sprite::create("Images/grossini_128x256_mipmap.pvr"); + auto img = Sprite::create("Images/grossini_128x256_mipmap.pvr"); img->setPosition(Point( s.width/2.0f, s.height/2.0f)); addChild(img); TextureCache::getInstance()->dumpCachedTextureInfo(); @@ -1198,9 +1198,9 @@ std::string TexturePVRNonSquare::subtitle() void TexturePVRNPOT4444::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *img = Sprite::create("Images/grossini_pvr_rgba4444.pvr"); + auto img = Sprite::create("Images/grossini_pvr_rgba4444.pvr"); if ( img ) { img->setPosition(Point( s.width/2.0f, s.height/2.0f)); @@ -1227,9 +1227,9 @@ std::string TexturePVRNPOT4444::subtitle() void TexturePVRNPOT8888::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Sprite *img = Sprite::create("Images/grossini_pvr_rgba8888.pvr"); + auto img = Sprite::create("Images/grossini_pvr_rgba8888.pvr"); if( img ) { img->setPosition(Point( s.width/2.0f, s.height/2.0f)); @@ -1256,14 +1256,14 @@ std::string TexturePVRNPOT8888::subtitle() void TextureAlias::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); // // Sprite 1: GL_LINEAR // // Default filter is GL_LINEAR - Sprite *sprite = Sprite::create("Images/grossinis_sister1.png"); + auto sprite = Sprite::create("Images/grossinis_sister1.png"); sprite->setPosition(Point( s.width/3.0f, s.height/2.0f)); addChild(sprite); @@ -1274,7 +1274,7 @@ void TextureAlias::onEnter() // Sprite 1: GL_NEAREST // - Sprite *sprite2 = Sprite::create("Images/grossinis_sister2.png"); + auto sprite2 = Sprite::create("Images/grossinis_sister2.png"); sprite2->setPosition(Point( 2*s.width/3.0f, s.height/2.0f)); addChild(sprite2); @@ -1318,14 +1318,14 @@ void TexturePixelFormat::onEnter() // 4- 16-bit RGB565 TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - LayerColor *background = LayerColor::create(Color4B(128,128,128,255), s.width, s.height); + auto background = LayerColor::create(Color4B(128,128,128,255), s.width, s.height); addChild(background, -1); // RGBA 8888 image (32-bit) Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA8888); - Sprite *sprite1 = Sprite::create("Images/test-rgba1.png"); + auto sprite1 = Sprite::create("Images/test-rgba1.png"); sprite1->setPosition(Point(1*s.width/7, s.height/2+32)); addChild(sprite1, 0); @@ -1334,7 +1334,7 @@ void TexturePixelFormat::onEnter() // RGBA 4444 image (16-bit) Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA4444); - Sprite *sprite2 = Sprite::create("Images/test-rgba1.png"); + auto sprite2 = Sprite::create("Images/test-rgba1.png"); sprite2->setPosition(Point(2*s.width/7, s.height/2-32)); addChild(sprite2, 0); @@ -1343,7 +1343,7 @@ void TexturePixelFormat::onEnter() // RGB5A1 image (16-bit) Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGB5A1); - Sprite *sprite3 = Sprite::create("Images/test-rgba1.png"); + auto sprite3 = Sprite::create("Images/test-rgba1.png"); sprite3->setPosition(Point(3*s.width/7, s.height/2+32)); addChild(sprite3, 0); @@ -1352,7 +1352,7 @@ void TexturePixelFormat::onEnter() // RGB888 image Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGB888); - Sprite *sprite4 = Sprite::create("Images/test-rgba1.png"); + auto sprite4 = Sprite::create("Images/test-rgba1.png"); sprite4->setPosition(Point(4*s.width/7, s.height/2-32)); addChild(sprite4, 0); @@ -1361,7 +1361,7 @@ void TexturePixelFormat::onEnter() // RGB565 image (16-bit) Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGB565); - Sprite *sprite5 = Sprite::create("Images/test-rgba1.png"); + auto sprite5 = Sprite::create("Images/test-rgba1.png"); sprite5->setPosition(Point(5*s.width/7, s.height/2+32)); addChild(sprite5, 0); @@ -1370,7 +1370,7 @@ void TexturePixelFormat::onEnter() // A8 image (8-bit) Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::A8); - Sprite *sprite6 = Sprite::create("Images/test-rgba1.png"); + auto sprite6 = Sprite::create("Images/test-rgba1.png"); sprite6->setPosition(Point(6*s.width/7, s.height/2-32)); addChild(sprite6, 0); @@ -1420,7 +1420,7 @@ void TextureBlend::onEnter() { // BOTTOM sprites have alpha pre-multiplied // they use by default GL_ONE, GL_ONE_MINUS_SRC_ALPHA - Sprite *cloud = Sprite::create("Images/test_blend.png"); + auto cloud = Sprite::create("Images/test_blend.png"); addChild(cloud, i+1, 100+i); cloud->setPosition(Point(50+25*i, 80)); cloud->setBlendFunc( BlendFunc::ALPHA_PREMULTIPLIED ); @@ -1466,9 +1466,9 @@ void TextureAsync::onEnter() _imageOffset = 0; - Size size = Director::getInstance()->getWinSize(); + auto size = Director::getInstance()->getWinSize(); - LabelTTF *label = LabelTTF::create("Loading...", "Marker Felt", 32); + auto label = LabelTTF::create("Loading...", "Marker Felt", 32); label->setPosition(Point( size.width/2, size.height/2)); addChild(label, 10); @@ -1505,8 +1505,8 @@ void TextureAsync::loadImages(float dt) void TextureAsync::imageLoaded(Object* pObj) { - Texture2D* tex = static_cast(pObj); - Director *director = Director::getInstance(); + auto tex = static_cast(pObj); + auto director = Director::getInstance(); //CCASSERT( [NSThread currentThread] == [director runningThread], @"FAIL. Callback should be on cocos2d thread"); @@ -1514,11 +1514,11 @@ void TextureAsync::imageLoaded(Object* pObj) // This test just creates a sprite based on the Texture - Sprite *sprite = Sprite::createWithTexture(tex); + auto sprite = Sprite::createWithTexture(tex); sprite->setAnchorPoint(Point(0,0)); addChild(sprite, -1); - Size size = director->getWinSize(); + auto size = director->getWinSize(); int i = _imageOffset * 32; sprite->setPosition(Point( i % (int)size.width, (i / (int)size.width) * 32 )); @@ -1547,11 +1547,11 @@ void TextureGlClamp::onEnter() { TextureDemo::onEnter(); - Size size = Director::getInstance()->getWinSize(); + auto size = Director::getInstance()->getWinSize(); // The .png image MUST be power of 2 in order to create a continue effect. // eg: 32x64, 512x128, 256x1024, 64x64, etc.. - Sprite *sprite = Sprite::create("Images/pattern1.png", Rect(0,0,512,256)); + auto sprite = Sprite::create("Images/pattern1.png", Rect(0,0,512,256)); addChild(sprite, -1, kTagSprite1); sprite->setPosition(Point(size.width/2,size.height/2)); Texture2D::TexParams params = {GL_LINEAR,GL_LINEAR,GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE}; @@ -1584,11 +1584,11 @@ void TextureGlRepeat::onEnter() { TextureDemo::onEnter(); - Size size = Director::getInstance()->getWinSize(); + auto size = Director::getInstance()->getWinSize(); // The .png image MUST be power of 2 in order to create a continue effect. // eg: 32x64, 512x128, 256x1024, 64x64, etc.. - Sprite *sprite = Sprite::create("Images/pattern1.png", Rect(0, 0, 4096, 4096)); + auto sprite = Sprite::create("Images/pattern1.png", Rect(0, 0, 4096, 4096)); addChild(sprite, -1, kTagSprite1); sprite->setPosition(Point(size.width/2,size.height/2)); Texture2D::TexParams params = {GL_LINEAR,GL_LINEAR,GL_REPEAT,GL_REPEAT}; @@ -1670,7 +1670,7 @@ void TextureCache1::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); Sprite *sprite; @@ -1747,7 +1747,7 @@ void TextureDrawAtPoint::draw() { TextureDemo::draw(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); _tex1->drawAtPoint(Point(s.width/2-50, s.height/2 - 50)); _Tex2F->drawAtPoint(Point(s.width/2+50, s.height/2 - 50)); @@ -1776,10 +1776,10 @@ void TextureDrawInRect::draw() { TextureDemo::draw(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - Rect rect1 = Rect( s.width/2 - 80, 20, _tex1->getContentSize().width * 0.5f, _tex1->getContentSize().height *2 ); - Rect rect2 = Rect( s.width/2 + 80, s.height/2, _tex1->getContentSize().width * 2, _tex1->getContentSize().height * 0.5f ); + auto rect1 = Rect( s.width/2 - 80, 20, _tex1->getContentSize().width * 0.5f, _tex1->getContentSize().height *2 ); + auto rect2 = Rect( s.width/2 + 80, s.height/2, _tex1->getContentSize().width * 2, _tex1->getContentSize().height * 0.5f ); _tex1->drawInRect(rect1); _Tex2F->drawInRect(rect2); @@ -1803,7 +1803,7 @@ std::string TextureDrawInRect::subtitle() //------------------------------------------------------------------ void TextureTestScene::runThisTest() { - Layer* layer = nextTextureTest(); + auto layer = nextTextureTest(); addChild(layer); Director::getInstance()->replaceScene(this); } @@ -1820,34 +1820,34 @@ void TextureMemoryAlloc::onEnter() MenuItemFont::setFontSize(24); - MenuItem *item1 = MenuItemFont::create("PNG", CC_CALLBACK_1(TextureMemoryAlloc::updateImage, this)); + auto item1 = MenuItemFont::create("PNG", CC_CALLBACK_1(TextureMemoryAlloc::updateImage, this)); item1->setTag(0); - MenuItem *item2 = MenuItemFont::create("RGBA8", CC_CALLBACK_1(TextureMemoryAlloc::updateImage, this)); + auto item2 = MenuItemFont::create("RGBA8", CC_CALLBACK_1(TextureMemoryAlloc::updateImage, this)); item2->setTag(1); - MenuItem *item3 = MenuItemFont::create("RGB8", CC_CALLBACK_1(TextureMemoryAlloc::updateImage, this)); + auto item3 = MenuItemFont::create("RGB8", CC_CALLBACK_1(TextureMemoryAlloc::updateImage, this)); item3->setTag(2); - MenuItem *item4 = MenuItemFont::create("RGBA4", CC_CALLBACK_1(TextureMemoryAlloc::updateImage, this)); + auto item4 = MenuItemFont::create("RGBA4", CC_CALLBACK_1(TextureMemoryAlloc::updateImage, this)); item4->setTag(3); - MenuItem *item5 = MenuItemFont::create("A8", CC_CALLBACK_1(TextureMemoryAlloc::updateImage, this)); + auto item5 = MenuItemFont::create("A8", CC_CALLBACK_1(TextureMemoryAlloc::updateImage, this)); item5->setTag(4); - Menu *menu = Menu::create(item1, item2, item3, item4, item5, NULL); + auto menu = Menu::create(item1, item2, item3, item4, item5, NULL); menu->alignItemsHorizontally(); addChild(menu); - MenuItemFont *warmup = MenuItemFont::create("warm up texture", CC_CALLBACK_1(TextureMemoryAlloc::changeBackgroundVisible, this)); + auto warmup = MenuItemFont::create("warm up texture", CC_CALLBACK_1(TextureMemoryAlloc::changeBackgroundVisible, this)); - Menu *menu2 = Menu::create(warmup, NULL); + auto menu2 = Menu::create(warmup, NULL); menu2->alignItemsHorizontally(); addChild(menu2); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); menu2->setPosition(Point(s.width/2, s.height/4)); } @@ -1911,7 +1911,7 @@ void TextureMemoryAlloc::updateImage(cocos2d::Object *sender) _background->setVisible(false); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); _background->setPosition(Point(s.width/2, s.height/2)); } @@ -1928,20 +1928,20 @@ string TextureMemoryAlloc::subtitle() // TexturePVRv3Premult TexturePVRv3Premult::TexturePVRv3Premult() { - Size size = Director::getInstance()->getWinSize(); + auto size = Director::getInstance()->getWinSize(); - LayerColor *background = LayerColor::create(Color4B(128,128,128,255), size.width, size.height); + auto background = LayerColor::create(Color4B(128,128,128,255), size.width, size.height); addChild(background, -1); // PVR premultiplied - Sprite *pvr1 = Sprite::create("Images/grossinis_sister1-testalpha_premult.pvr"); + auto pvr1 = Sprite::create("Images/grossinis_sister1-testalpha_premult.pvr"); addChild(pvr1, 0); pvr1->setPosition(Point(size.width/4*1, size.height/2)); transformSprite(pvr1); // PVR non-premultiplied - Sprite *pvr2 = Sprite::create("Images/grossinis_sister1-testalpha_nopremult.pvr"); + auto pvr2 = Sprite::create("Images/grossinis_sister1-testalpha_nopremult.pvr"); addChild(pvr2, 0); pvr2->setPosition(Point(size.width/4*2, size.height/2)); transformSprite(pvr2); @@ -1949,7 +1949,7 @@ TexturePVRv3Premult::TexturePVRv3Premult() // PNG Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA8888); TextureCache::getInstance()->removeTextureForKey("Images/grossinis_sister1-testalpha.png"); - Sprite *png = Sprite::create("Images/grossinis_sister1-testalpha.png"); + auto png = Sprite::create("Images/grossinis_sister1-testalpha.png"); addChild(png, 0); png->setPosition(Point(size.width/4*3, size.height/2)); transformSprite(png); @@ -1990,9 +1990,9 @@ public: TextureETC1::TextureETC1() { - Sprite *sprite = Sprite::create("Images/ETC1.pkm"); + auto sprite = Sprite::create("Images/ETC1.pkm"); - Size size = Director::getInstance()->getWinSize(); + auto size = Director::getInstance()->getWinSize(); sprite->setPosition(Point(size.width/2, size.height/2)); addChild(sprite); @@ -2011,9 +2011,9 @@ std::string TextureETC1::subtitle() //Implement of S3TC Dxt1 TextureS3TCDxt1::TextureS3TCDxt1() { - Sprite *sprite = Sprite::create("Images/test_256x256_s3tc_dxt1_mipmaps.dds"); - //Sprite *sprite = Sprite::create("Images/water_2_dxt1.dds"); - Size size = Director::getInstance()->getWinSize(); + auto sprite = Sprite::create("Images/test_256x256_s3tc_dxt1_mipmaps.dds"); + //auto sprite = Sprite::create("Images/water_2_dxt1.dds"); + auto size = Director::getInstance()->getWinSize(); sprite->setPosition(Point(size.width / 2, size.height / 2)); addChild(sprite); @@ -2029,9 +2029,9 @@ std::string TextureS3TCDxt1::subtitle() //Implement of S3TC Dxt3 TextureS3TCDxt3::TextureS3TCDxt3() { - Sprite *sprite = Sprite::create("Images/test_256x256_s3tc_dxt3_mipmaps.dds"); - //Sprite *sprite = Sprite::create("Images/water_2_dxt3.dds"); - Size size = Director::getInstance()->getWinSize(); + auto sprite = Sprite::create("Images/test_256x256_s3tc_dxt3_mipmaps.dds"); + //auto sprite = Sprite::create("Images/water_2_dxt3.dds"); + auto size = Director::getInstance()->getWinSize(); sprite->setPosition(Point(size.width / 2, size.height / 2)); addChild(sprite); @@ -2047,9 +2047,9 @@ std::string TextureS3TCDxt3::subtitle() //Implement fo S3TC Dxt5 TextureS3TCDxt5::TextureS3TCDxt5() { - Sprite *sprite = Sprite::create("Images/test_256x256_s3tc_dxt5_mipmaps.dds"); - //Sprite *sprite = Sprite::create("Images/water_2_dxt5.dds"); - Size size = Director::getInstance()->getWinSize(); + auto sprite = Sprite::create("Images/test_256x256_s3tc_dxt5_mipmaps.dds"); + //auto sprite = Sprite::create("Images/water_2_dxt5.dds"); + auto size = Director::getInstance()->getWinSize(); sprite->setPosition(Point(size.width / 2, size.height / 2)); addChild(sprite); @@ -2067,7 +2067,7 @@ std::string TextureS3TCDxt5::subtitle() static void addImageToDemo(TextureDemo& demo, float x, float y, const char* path, Texture2D::PixelFormat format) { Texture2D::setDefaultAlphaPixelFormat(format); - Sprite *sprite = Sprite::create(path); + auto sprite = Sprite::create(path); sprite->setPosition(Point(x, y)); demo.addChild(sprite, 0); @@ -2080,9 +2080,9 @@ void TextureConvertRGB888::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - LayerColor *background = LayerColor::create(Color4B(255,0,0,255), s.width, s.height); + auto background = LayerColor::create(Color4B(255,0,0,255), s.width, s.height); addChild(background, -1); const char* img = "Images/test_image_rgb888.png"; @@ -2114,9 +2114,9 @@ void TextureConvertRGBA8888::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - LayerColor *background = LayerColor::create(Color4B(255,0,0,255), s.width, s.height); + auto background = LayerColor::create(Color4B(255,0,0,255), s.width, s.height); addChild(background, -1); const char* img = "Images/test_image_rgba8888.png"; @@ -2148,9 +2148,9 @@ void TextureConvertI8::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - LayerColor *background = LayerColor::create(Color4B(255,0,0,255), s.width, s.height); + auto background = LayerColor::create(Color4B(255,0,0,255), s.width, s.height); addChild(background, -1); const char* img = "Images/test_image_i8.png"; @@ -2182,9 +2182,9 @@ void TextureConvertAI88::onEnter() { TextureDemo::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - LayerColor *background = LayerColor::create(Color4B(255,0,0,255), s.width, s.height); + auto background = LayerColor::create(Color4B(255,0,0,255), s.width, s.height); addChild(background, -1); const char* img = "Images/test_image_ai88.png"; diff --git a/samples/Cpp/TestCpp/Classes/TextureCacheTest/TextureCacheTest.cpp b/samples/Cpp/TestCpp/Classes/TextureCacheTest/TextureCacheTest.cpp index c011000b78..32d9660ce4 100644 --- a/samples/Cpp/TestCpp/Classes/TextureCacheTest/TextureCacheTest.cpp +++ b/samples/Cpp/TestCpp/Classes/TextureCacheTest/TextureCacheTest.cpp @@ -9,7 +9,7 @@ TextureCacheTest::TextureCacheTest() : _numberOfSprites(20) , _numberOfLoadedSprites(0) { - Size size = Director::getInstance()->getWinSize(); + auto size = Director::getInstance()->getWinSize(); _labelLoading = LabelTTF::create("loading...", "Arial", 15); _labelPercent = LabelTTF::create("%0", "Arial", 15); @@ -60,28 +60,28 @@ void TextureCacheTest::loadingCallBack(Object *obj) void TextureCacheTest::addSprite() { - Size size = Director::getInstance()->getWinSize(); + auto size = Director::getInstance()->getWinSize(); // create sprites - Sprite *bg = Sprite::create("Images/HelloWorld.png"); + auto bg = Sprite::create("Images/HelloWorld.png"); bg->setPosition(Point(size.width / 2, size.height / 2)); - Sprite *s1 = Sprite::create("Images/grossini.png"); - Sprite *s2 = Sprite::create("Images/grossini_dance_01.png"); - Sprite *s3 = Sprite::create("Images/grossini_dance_02.png"); - Sprite *s4 = Sprite::create("Images/grossini_dance_03.png"); - Sprite *s5 = Sprite::create("Images/grossini_dance_04.png"); - Sprite *s6 = Sprite::create("Images/grossini_dance_05.png"); - Sprite *s7 = Sprite::create("Images/grossini_dance_06.png"); - Sprite *s8 = Sprite::create("Images/grossini_dance_07.png"); - Sprite *s9 = Sprite::create("Images/grossini_dance_08.png"); - Sprite *s10 = Sprite::create("Images/grossini_dance_09.png"); - Sprite *s11 = Sprite::create("Images/grossini_dance_10.png"); - Sprite *s12 = Sprite::create("Images/grossini_dance_11.png"); - Sprite *s13 = Sprite::create("Images/grossini_dance_12.png"); - Sprite *s14 = Sprite::create("Images/grossini_dance_13.png"); - Sprite *s15 = Sprite::create("Images/grossini_dance_14.png"); + auto s1 = Sprite::create("Images/grossini.png"); + auto s2 = Sprite::create("Images/grossini_dance_01.png"); + auto s3 = Sprite::create("Images/grossini_dance_02.png"); + auto s4 = Sprite::create("Images/grossini_dance_03.png"); + auto s5 = Sprite::create("Images/grossini_dance_04.png"); + auto s6 = Sprite::create("Images/grossini_dance_05.png"); + auto s7 = Sprite::create("Images/grossini_dance_06.png"); + auto s8 = Sprite::create("Images/grossini_dance_07.png"); + auto s9 = Sprite::create("Images/grossini_dance_08.png"); + auto s10 = Sprite::create("Images/grossini_dance_09.png"); + auto s11 = Sprite::create("Images/grossini_dance_10.png"); + auto s12 = Sprite::create("Images/grossini_dance_11.png"); + auto s13 = Sprite::create("Images/grossini_dance_12.png"); + auto s14 = Sprite::create("Images/grossini_dance_13.png"); + auto s15 = Sprite::create("Images/grossini_dance_14.png"); // just loading textures to slow down Sprite::create("Images/background1.png"); @@ -129,7 +129,7 @@ void TextureCacheTest::addSprite() void TextureCacheTestScene::runThisTest() { - Layer* layer = new TextureCacheTest(); + auto layer = new TextureCacheTest(); addChild(layer); Director::getInstance()->replaceScene(this); diff --git a/samples/Cpp/TestCpp/Classes/TexturePackerEncryptionTest/TextureAtlasEncryptionTest.cpp b/samples/Cpp/TestCpp/Classes/TexturePackerEncryptionTest/TextureAtlasEncryptionTest.cpp index cf9e4d72cc..0cf00124d1 100644 --- a/samples/Cpp/TestCpp/Classes/TexturePackerEncryptionTest/TextureAtlasEncryptionTest.cpp +++ b/samples/Cpp/TestCpp/Classes/TexturePackerEncryptionTest/TextureAtlasEncryptionTest.cpp @@ -16,16 +16,16 @@ void TextureAtlasEncryptionDemo::onEnter() { Layer::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); - LabelTTF* label = LabelTTF::create(title().c_str(), "Arial", 28); + auto label = LabelTTF::create(title().c_str(), "Arial", 28); label->setPosition( Point(s.width/2, s.height * 0.75f) ); this->addChild(label, 1); std::string strSubtitle = subtitle(); if(strSubtitle.empty() == false) { - LabelTTF* subLabel = LabelTTF::create(strSubtitle.c_str(), "Thonburi", 16); + auto subLabel = LabelTTF::create(strSubtitle.c_str(), "Thonburi", 16); subLabel->setPosition( Point(s.width/2, s.height-80) ); this->addChild(subLabel, 1); } @@ -34,11 +34,11 @@ void TextureAtlasEncryptionDemo::onEnter() SpriteFrameCache::getInstance()->addSpriteFramesWithFile("Images/nonencryptedAtlas.plist", "Images/nonencryptedAtlas.pvr.ccz"); // Create a sprite from the non-encrypted atlas - Sprite *nonencryptedSprite = Sprite::createWithSpriteFrameName("Icon.png"); + auto nonencryptedSprite = Sprite::createWithSpriteFrameName("Icon.png"); nonencryptedSprite->setPosition(Point(s.width * 0.25f, s.height * 0.5f)); this->addChild(nonencryptedSprite); - LabelTTF* nonencryptedSpriteLabel = LabelTTF::create("non-encrypted", "Arial", 28); + auto nonencryptedSpriteLabel = LabelTTF::create("non-encrypted", "Arial", 28); nonencryptedSpriteLabel->setPosition(Point(s.width * 0.25f, nonencryptedSprite->getBoundingBox().getMinY() - nonencryptedSprite->getContentSize().height/2)); this->addChild(nonencryptedSpriteLabel, 1); @@ -61,18 +61,18 @@ void TextureAtlasEncryptionDemo::onEnter() SpriteFrameCache::getInstance()->addSpriteFramesWithFile("Images/encryptedAtlas.plist", "Images/encryptedAtlas.pvr.ccz"); // 3) Create a sprite from the encrypted atlas - Sprite *encryptedSprite = Sprite::createWithSpriteFrameName("powered.png"); + auto encryptedSprite = Sprite::createWithSpriteFrameName("powered.png"); encryptedSprite->setPosition(Point(s.width * 0.75f, s.height * 0.5f)); this->addChild(encryptedSprite); - LabelTTF* encryptedSpriteLabel = LabelTTF::create("encrypted", "Arial", 28); + auto encryptedSpriteLabel = LabelTTF::create("encrypted", "Arial", 28); encryptedSpriteLabel->setPosition(Point(s.width * 0.75f, encryptedSprite->getBoundingBox().getMinY() - encryptedSpriteLabel->getContentSize().height/2)); this->addChild(encryptedSpriteLabel, 1); } void TextureAtlasEncryptionTestScene::runThisTest() { - Layer *layer = new TextureAtlasEncryptionDemo; + auto layer = new TextureAtlasEncryptionDemo; layer->autorelease(); addChild(layer); diff --git a/samples/Cpp/TestCpp/Classes/TileMapTest/TileMapTest.cpp b/samples/Cpp/TestCpp/Classes/TileMapTest/TileMapTest.cpp index 943f9d6485..5fa6a95a0b 100644 --- a/samples/Cpp/TestCpp/Classes/TileMapTest/TileMapTest.cpp +++ b/samples/Cpp/TestCpp/Classes/TileMapTest/TileMapTest.cpp @@ -17,7 +17,7 @@ Layer* restartTileMapAction(); //------------------------------------------------------------------ TileMapTest::TileMapTest() { - TileMapAtlas* map = TileMapAtlas::create(s_TilesPng, s_LevelMapTga, 16, 16); + auto map = TileMapAtlas::create(s_TilesPng, s_LevelMapTga, 16, 16); // Convert it to "alias" (GL_LINEAR filtering) map->getTexture()->setAntiAliasTexParameters(); @@ -32,10 +32,10 @@ TileMapTest::TileMapTest() map->setAnchorPoint( Point(0, 0.5f) ); - ScaleBy *scale = ScaleBy::create(4, 0.8f); - ActionInterval *scaleBack = scale->reverse(); + auto scale = ScaleBy::create(4, 0.8f); + auto scaleBack = scale->reverse(); - Sequence* seq = Sequence::create(scale, scaleBack, NULL); + auto seq = Sequence::create(scale, scaleBack, NULL); map->runAction(RepeatForever::create(seq)); } @@ -52,7 +52,7 @@ std::string TileMapTest::title() //------------------------------------------------------------------ TileMapEditTest::TileMapEditTest() { - TileMapAtlas* map = TileMapAtlas::create(s_TilesPng, s_LevelMapTga, 16, 16); + auto map = TileMapAtlas::create(s_TilesPng, s_LevelMapTga, 16, 16); // Create an Aliased Atlas map->getTexture()->setAliasTexParameters(); @@ -76,7 +76,7 @@ void TileMapEditTest::updateMap(float dt) // The only limitation is that you cannot change an empty, or assign an empty tile to a tile // The value 0 not rendered so don't assign or change a tile with value 0 - TileMapAtlas* tilemap = (TileMapAtlas*) getChildByTag(kTagTileMap); + auto tilemap = (TileMapAtlas*) getChildByTag(kTagTileMap); // // For example you can iterate over all the tiles @@ -119,16 +119,16 @@ TMXOrthoTest::TMXOrthoTest() // // it should not flicker. No artifacts should appear // - //CCLayerColor* color = LayerColor::create( Color4B(64,64,64,255) ); + //auto color = LayerColor::create( Color4B(64,64,64,255) ); //addChild(color, -1); - TMXTiledMap* map = TMXTiledMap::create("TileMaps/orthogonal-test2.tmx"); + auto map = TMXTiledMap::create("TileMaps/orthogonal-test2.tmx"); addChild(map, 0, kTagTileMap); Size CC_UNUSED s = map->getContentSize(); CCLOG("ContentSize: %f, %f", s.width,s.height); - Array * pChildrenArray = map->getChildren(); + auto pChildrenArray = map->getChildren(); SpriteBatchNode* child = NULL; Object* pObject = NULL; CCARRAY_FOREACH(pChildrenArray, pObject) @@ -171,13 +171,13 @@ std::string TMXOrthoTest::title() //------------------------------------------------------------------ TMXOrthoTest2::TMXOrthoTest2() { - TMXTiledMap* map = TMXTiledMap::create("TileMaps/orthogonal-test1.tmx"); + auto map = TMXTiledMap::create("TileMaps/orthogonal-test1.tmx"); addChild(map, 0, kTagTileMap); Size CC_UNUSED s = map->getContentSize(); CCLOG("ContentSize: %f, %f", s.width,s.height); - Array* pChildrenArray = map->getChildren(); + auto pChildrenArray = map->getChildren(); SpriteBatchNode* child = NULL; Object* pObject = NULL; CCARRAY_FOREACH(pChildrenArray, pObject) @@ -205,13 +205,13 @@ std::string TMXOrthoTest2::title() //------------------------------------------------------------------ TMXOrthoTest3::TMXOrthoTest3() { - TMXTiledMap *map = TMXTiledMap::create("TileMaps/orthogonal-test3.tmx"); + auto map = TMXTiledMap::create("TileMaps/orthogonal-test3.tmx"); addChild(map, 0, kTagTileMap); Size CC_UNUSED s = map->getContentSize(); CCLOG("ContentSize: %f, %f", s.width,s.height); - Array* pChildrenArray = map->getChildren(); + auto pChildrenArray = map->getChildren(); SpriteBatchNode* child = NULL; Object* pObject = NULL; CCARRAY_FOREACH(pChildrenArray, pObject) @@ -240,13 +240,13 @@ std::string TMXOrthoTest3::title() //------------------------------------------------------------------ TMXOrthoTest4::TMXOrthoTest4() { - TMXTiledMap *map = TMXTiledMap::create("TileMaps/orthogonal-test4.tmx"); + auto map = TMXTiledMap::create("TileMaps/orthogonal-test4.tmx"); addChild(map, 0, kTagTileMap); Size CC_UNUSED s1 = map->getContentSize(); CCLOG("ContentSize: %f, %f", s1.width,s1.height); - Array* pChildrenArray = map->getChildren(); + auto pChildrenArray = map->getChildren(); SpriteBatchNode* child = NULL; Object* pObject = NULL; CCARRAY_FOREACH(pChildrenArray, pObject) @@ -262,7 +262,7 @@ TMXOrthoTest4::TMXOrthoTest4() map->setAnchorPoint(Point(0, 0)); auto layer = map->getLayer("Layer 0"); - Size s = layer->getLayerSize(); + auto s = layer->getLayerSize(); Sprite* sprite; sprite = layer->getTileAt(Point(0,0)); @@ -284,9 +284,9 @@ void TMXOrthoTest4::removeSprite(float dt) auto map = static_cast( getChildByTag(kTagTileMap) ); auto layer = map->getLayer("Layer 0"); - Size s = layer->getLayerSize(); + auto s = layer->getLayerSize(); - Sprite* sprite = layer->getTileAt( Point(s.width-1,0) ); + auto sprite = layer->getTileAt( Point(s.width-1,0) ); layer->removeChild(sprite, true); } @@ -311,38 +311,38 @@ TMXReadWriteTest::TMXReadWriteTest() { _gid = 0; - TMXTiledMap* map = TMXTiledMap::create("TileMaps/orthogonal-test2.tmx"); + auto map = TMXTiledMap::create("TileMaps/orthogonal-test2.tmx"); addChild(map, 0, kTagTileMap); Size CC_UNUSED s = map->getContentSize(); CCLOG("ContentSize: %f, %f", s.width,s.height); - TMXLayer* layer = map->getLayer("Layer 0"); + auto layer = map->getLayer("Layer 0"); layer->getTexture()->setAntiAliasTexParameters(); map->setScale( 1 ); - Sprite *tile0 = layer->getTileAt(Point(1,63)); - Sprite *tile1 = layer->getTileAt(Point(2,63)); - Sprite *tile2 = layer->getTileAt(Point(3,62));//Point(1,62)); - Sprite *tile3 = layer->getTileAt(Point(2,62)); + auto tile0 = layer->getTileAt(Point(1,63)); + auto tile1 = layer->getTileAt(Point(2,63)); + auto tile2 = layer->getTileAt(Point(3,62));//Point(1,62)); + auto tile3 = layer->getTileAt(Point(2,62)); tile0->setAnchorPoint( Point(0.5f, 0.5f) ); tile1->setAnchorPoint( Point(0.5f, 0.5f) ); tile2->setAnchorPoint( Point(0.5f, 0.5f) ); tile3->setAnchorPoint( Point(0.5f, 0.5f) ); - ActionInterval* move = MoveBy::create(0.5f, Point(0,160)); - ActionInterval* rotate = RotateBy::create(2, 360); - ActionInterval* scale = ScaleBy::create(2, 5); - ActionInterval* opacity = FadeOut::create(2); - ActionInterval* fadein = FadeIn::create(2); - ActionInterval* scaleback = ScaleTo::create(1, 1); - ActionInstant* finish = CallFuncN::create(CC_CALLBACK_1(TMXReadWriteTest::removeSprite, this)); - Sequence* seq0 = Sequence::create(move, rotate, scale, opacity, fadein, scaleback, finish, NULL); - ActionInterval* seq1 = seq0->clone(); - ActionInterval* seq2 = seq0->clone(); - ActionInterval* seq3 = seq0->clone(); + auto move = MoveBy::create(0.5f, Point(0,160)); + auto rotate = RotateBy::create(2, 360); + auto scale = ScaleBy::create(2, 5); + auto opacity = FadeOut::create(2); + auto fadein = FadeIn::create(2); + auto scaleback = ScaleTo::create(1, 1); + auto finish = CallFuncN::create(CC_CALLBACK_1(TMXReadWriteTest::removeSprite, this)); + auto seq0 = Sequence::create(move, rotate, scale, opacity, fadein, scaleback, finish, NULL); + auto seq1 = seq0->clone(); + auto seq2 = seq0->clone(); + auto seq3 = seq0->clone(); tile0->runAction(seq0); tile1->runAction(seq1); @@ -366,7 +366,7 @@ TMXReadWriteTest::TMXReadWriteTest() void TMXReadWriteTest::removeSprite(Node* sender) { ////----CCLOG("removing tile: %x", sender); - Node* p = ((Node*)sender)->getParent(); + auto p = ((Node*)sender)->getParent(); if (p) { @@ -378,14 +378,14 @@ void TMXReadWriteTest::removeSprite(Node* sender) void TMXReadWriteTest::updateCol(float dt) { - TMXTiledMap* map = (TMXTiledMap*)getChildByTag(kTagTileMap); - TMXLayer *layer = (TMXLayer*)map->getChildByTag(0); + auto map = (TMXTiledMap*)getChildByTag(kTagTileMap); + auto layer = (TMXLayer*)map->getChildByTag(0); ////----CCLOG("++++atlas quantity: %d", layer->textureAtlas()->getTotalQuads()); ////----CCLOG("++++children: %d", layer->getChildren()->count() ); - Size s = layer->getLayerSize(); + auto s = layer->getLayerSize(); for( int y=0; y< s.height; y++ ) { @@ -399,10 +399,10 @@ void TMXReadWriteTest::repaintWithGID(float dt) { // unschedule:_cmd); - TMXTiledMap* map = (TMXTiledMap*)getChildByTag(kTagTileMap); - TMXLayer *layer = (TMXLayer*)map->getChildByTag(0); + auto map = (TMXTiledMap*)getChildByTag(kTagTileMap); + auto layer = (TMXLayer*)map->getChildByTag(0); - Size s = layer->getLayerSize(); + auto s = layer->getLayerSize(); for( int x=0; xgetChildByTag(0); - Size s = layer->getLayerSize(); + auto map = (TMXTiledMap*)getChildByTag(kTagTileMap); + auto layer = (TMXLayer*)map->getChildByTag(0); + auto s = layer->getLayerSize(); for( int y=0; y< s.height; y++ ) { @@ -439,10 +439,10 @@ std::string TMXReadWriteTest::title() //------------------------------------------------------------------ TMXHexTest::TMXHexTest() { - LayerColor* color = LayerColor::create( Color4B(64,64,64,255) ); + auto color = LayerColor::create( Color4B(64,64,64,255) ); addChild(color, -1); - TMXTiledMap* map = TMXTiledMap::create("TileMaps/hexa-test.tmx"); + auto map = TMXTiledMap::create("TileMaps/hexa-test.tmx"); addChild(map, 0, kTagTileMap); Size CC_UNUSED s = map->getContentSize(); @@ -461,15 +461,15 @@ std::string TMXHexTest::title() //------------------------------------------------------------------ TMXIsoTest::TMXIsoTest() { - LayerColor* color = LayerColor::create( Color4B(64,64,64,255) ); + auto color = LayerColor::create( Color4B(64,64,64,255) ); addChild(color, -1); - TMXTiledMap* map = TMXTiledMap::create("TileMaps/iso-test.tmx"); + auto map = TMXTiledMap::create("TileMaps/iso-test.tmx"); addChild(map, 0, kTagTileMap); // move map to the center of the screen - Size ms = map->getMapSize(); - Size ts = map->getTileSize(); + auto ms = map->getMapSize(); + auto ts = map->getTileSize(); map->runAction( MoveTo::create(1.0f, Point( -ms.width * ts.width/2, -ms.height * ts.height/2 )) ); } @@ -485,10 +485,10 @@ std::string TMXIsoTest::title() //------------------------------------------------------------------ TMXIsoTest1::TMXIsoTest1() { - LayerColor* color = LayerColor::create( Color4B(64,64,64,255) ); + auto color = LayerColor::create( Color4B(64,64,64,255) ); addChild(color, -1); - TMXTiledMap *map = TMXTiledMap::create("TileMaps/iso-test1.tmx"); + auto map = TMXTiledMap::create("TileMaps/iso-test1.tmx"); addChild(map, 0, kTagTileMap); Size CC_UNUSED s = map->getContentSize(); @@ -509,18 +509,18 @@ std::string TMXIsoTest1::title() //------------------------------------------------------------------ TMXIsoTest2::TMXIsoTest2() { - LayerColor* color = LayerColor::create( Color4B(64,64,64,255) ); + auto color = LayerColor::create( Color4B(64,64,64,255) ); addChild(color, -1); - TMXTiledMap *map = TMXTiledMap::create("TileMaps/iso-test2.tmx"); + auto map = TMXTiledMap::create("TileMaps/iso-test2.tmx"); addChild(map, 0, kTagTileMap); Size CC_UNUSED s = map->getContentSize(); CCLOG("ContentSize: %f, %f", s.width,s.height); // move map to the center of the screen - Size ms = map->getMapSize(); - Size ts = map->getTileSize(); + auto ms = map->getMapSize(); + auto ts = map->getTileSize(); map->runAction( MoveTo::create(1.0f, Point( -ms.width * ts.width/2, -ms.height * ts.height/2 ) )); } @@ -536,22 +536,22 @@ std::string TMXIsoTest2::title() //------------------------------------------------------------------ TMXUncompressedTest::TMXUncompressedTest() { - LayerColor* color = LayerColor::create( Color4B(64,64,64,255) ); + auto color = LayerColor::create( Color4B(64,64,64,255) ); addChild(color, -1); - TMXTiledMap *map = TMXTiledMap::create("TileMaps/iso-test2-uncompressed.tmx"); + auto map = TMXTiledMap::create("TileMaps/iso-test2-uncompressed.tmx"); addChild(map, 0, kTagTileMap); Size CC_UNUSED s = map->getContentSize(); CCLOG("ContentSize: %f, %f", s.width,s.height); // move map to the center of the screen - Size ms = map->getMapSize(); - Size ts = map->getTileSize(); + auto ms = map->getMapSize(); + auto ts = map->getTileSize(); map->runAction(MoveTo::create(1.0f, Point( -ms.width * ts.width/2, -ms.height * ts.height/2 ) )); // testing release map - Array* pChildrenArray = map->getChildren(); + auto pChildrenArray = map->getChildren(); TMXLayer* layer; Object* pObject = NULL; CCARRAY_FOREACH(pChildrenArray, pObject) @@ -578,7 +578,7 @@ std::string TMXUncompressedTest::title() //------------------------------------------------------------------ TMXTilesetTest::TMXTilesetTest() { - TMXTiledMap *map = TMXTiledMap::create("TileMaps/orthogonal-test5.tmx"); + auto map = TMXTiledMap::create("TileMaps/orthogonal-test5.tmx"); addChild(map, 0, kTagTileMap); Size CC_UNUSED s = map->getContentSize(); @@ -607,7 +607,7 @@ std::string TMXTilesetTest::title() //------------------------------------------------------------------ TMXOrthoObjectsTest::TMXOrthoObjectsTest() { - TMXTiledMap *map = TMXTiledMap::create("TileMaps/ortho-objects.tmx"); + auto map = TMXTiledMap::create("TileMaps/ortho-objects.tmx"); addChild(map, -1, kTagTileMap); Size CC_UNUSED s = map->getContentSize(); @@ -615,7 +615,7 @@ TMXOrthoObjectsTest::TMXOrthoObjectsTest() ////----CCLOG("----> Iterating over all the group objets"); auto group = map->getObjectGroup("Object Group 1"); - Array* objects = group->getObjects(); + auto objects = group->getObjects(); Dictionary* dict = NULL; Object* pObj = NULL; @@ -630,7 +630,7 @@ TMXOrthoObjectsTest::TMXOrthoObjectsTest() } ////----CCLOG("----> Fetching 1 object by name"); - // StringToStringDictionary* platform = group->objectNamed("platform"); + // auto platform = group->objectNamed("platform"); ////----CCLOG("platform: %x", platform); } @@ -639,7 +639,7 @@ void TMXOrthoObjectsTest::draw() auto map = static_cast( getChildByTag(kTagTileMap) ); auto group = map->getObjectGroup("Object Group 1"); - Array* objects = group->getObjects(); + auto objects = group->getObjects(); Dictionary* dict = NULL; Object* pObj = NULL; CCARRAY_FOREACH(objects, pObj) @@ -687,16 +687,16 @@ std::string TMXOrthoObjectsTest::subtitle() TMXIsoObjectsTest::TMXIsoObjectsTest() { - TMXTiledMap* map = TMXTiledMap::create("TileMaps/iso-test-objectgroup.tmx"); + auto map = TMXTiledMap::create("TileMaps/iso-test-objectgroup.tmx"); addChild(map, -1, kTagTileMap); Size CC_UNUSED s = map->getContentSize(); CCLOG("ContentSize: %f, %f", s.width,s.height); - TMXObjectGroup* group = map->getObjectGroup("Object Group 1"); + auto group = map->getObjectGroup("Object Group 1"); - //UxMutableArray* objects = group->objects(); - Array* objects = group->getObjects(); + //auto objects = group->objects(); + auto objects = group->getObjects(); //UxMutableDictionary* dict; Dictionary* dict; Object* pObj = NULL; @@ -713,10 +713,10 @@ TMXIsoObjectsTest::TMXIsoObjectsTest() void TMXIsoObjectsTest::draw() { - TMXTiledMap *map = (TMXTiledMap*) getChildByTag(kTagTileMap); - TMXObjectGroup *group = map->getObjectGroup("Object Group 1"); + auto map = (TMXTiledMap*) getChildByTag(kTagTileMap); + auto group = map->getObjectGroup("Object Group 1"); - Array* objects = group->getObjects(); + auto objects = group->getObjects(); Dictionary* dict; Object* pObj = NULL; CCARRAY_FOREACH(objects, pObj) @@ -764,7 +764,7 @@ std::string TMXIsoObjectsTest::subtitle() TMXResizeTest::TMXResizeTest() { - TMXTiledMap* map = TMXTiledMap::create("TileMaps/orthogonal-test5.tmx"); + auto map = TMXTiledMap::create("TileMaps/orthogonal-test5.tmx"); addChild(map, 0, kTagTileMap); Size CC_UNUSED s = map->getContentSize(); @@ -773,7 +773,7 @@ TMXResizeTest::TMXResizeTest() TMXLayer* layer; layer = map->getLayer("Layer 0"); - Size ls = layer->getLayerSize(); + auto ls = layer->getLayerSize(); for (unsigned int y = 0; y < ls.height; y++) { for (unsigned int x = 0; x < ls.width; x++) @@ -801,10 +801,10 @@ std::string TMXResizeTest::subtitle() //------------------------------------------------------------------ TMXIsoZorder::TMXIsoZorder() { - TMXTiledMap *map = TMXTiledMap::create("TileMaps/iso-test-zorder.tmx"); + auto map = TMXTiledMap::create("TileMaps/iso-test-zorder.tmx"); addChild(map, 0, kTagTileMap); - Size s = map->getContentSize(); + auto s = map->getContentSize(); CCLOG("ContentSize: %f, %f", s.width,s.height); map->setPosition(Point(-s.width/2,0)); @@ -816,9 +816,9 @@ TMXIsoZorder::TMXIsoZorder() _tamara->setAnchorPoint(Point(0.5f,0)); - ActionInterval* move = MoveBy::create(10, Point(300,250)); - ActionInterval* back = move->reverse(); - Sequence* seq = Sequence::create(move, back,NULL); + auto move = MoveBy::create(10, Point(300,250)); + auto back = move->reverse(); + auto seq = Sequence::create(move, back,NULL); _tamara->runAction( RepeatForever::create(seq) ); schedule( schedule_selector(TMXIsoZorder::repositionSprite) ); @@ -837,9 +837,9 @@ void TMXIsoZorder::onExit() void TMXIsoZorder::repositionSprite(float dt) { - Point p = _tamara->getPosition(); + auto p = _tamara->getPosition(); p = CC_POINT_POINTS_TO_PIXELS(p); - Node *map = getChildByTag(kTagTileMap); + auto map = getChildByTag(kTagTileMap); // there are only 4 layers. (grass and 3 trees layers) // if tamara < 48, z=4 @@ -870,7 +870,7 @@ std::string TMXIsoZorder::subtitle() //------------------------------------------------------------------ TMXOrthoZorder::TMXOrthoZorder() { - TMXTiledMap *map = TMXTiledMap::create("TileMaps/orthogonal-test-zorder.tmx"); + auto map = TMXTiledMap::create("TileMaps/orthogonal-test-zorder.tmx"); addChild(map, 0, kTagTileMap); Size CC_UNUSED s = map->getContentSize(); @@ -882,9 +882,9 @@ TMXOrthoZorder::TMXOrthoZorder() _tamara->setAnchorPoint(Point(0.5f,0)); - ActionInterval* move = MoveBy::create(10, Point(400,450)); - ActionInterval* back = move->reverse(); - Sequence* seq = Sequence::create(move, back,NULL); + auto move = MoveBy::create(10, Point(400,450)); + auto back = move->reverse(); + auto seq = Sequence::create(move, back,NULL); _tamara->runAction( RepeatForever::create(seq)); schedule( schedule_selector(TMXOrthoZorder::repositionSprite)); @@ -897,9 +897,9 @@ TMXOrthoZorder::~TMXOrthoZorder() void TMXOrthoZorder::repositionSprite(float dt) { - Point p = _tamara->getPosition(); + auto p = _tamara->getPosition(); p = CC_POINT_POINTS_TO_PIXELS(p); - Node* map = getChildByTag(kTagTileMap); + auto map = getChildByTag(kTagTileMap); // there are only 4 layers. (grass and 3 trees layers) // if tamara < 81, z=4 @@ -931,22 +931,22 @@ std::string TMXOrthoZorder::subtitle() //------------------------------------------------------------------ TMXIsoVertexZ::TMXIsoVertexZ() { - TMXTiledMap *map = TMXTiledMap::create("TileMaps/iso-test-vertexz.tmx"); + auto map = TMXTiledMap::create("TileMaps/iso-test-vertexz.tmx"); addChild(map, 0, kTagTileMap); - Size s = map->getContentSize(); + auto s = map->getContentSize(); map->setPosition( Point(-s.width/2,0) ); CCLOG("ContentSize: %f, %f", s.width,s.height); // because I'm lazy, I'm reusing a tile as an sprite, but since this method uses vertexZ, you // can use any Sprite and it will work OK. - TMXLayer* layer = map->getLayer("Trees"); + auto layer = map->getLayer("Trees"); _tamara = layer->getTileAt( Point(29,29) ); _tamara->retain(); - ActionInterval* move = MoveBy::create(10, Point(300,250) * (1/CC_CONTENT_SCALE_FACTOR())); - ActionInterval* back = move->reverse(); - Sequence* seq = Sequence::create(move, back,NULL); + auto move = MoveBy::create(10, Point(300,250) * (1/CC_CONTENT_SCALE_FACTOR())); + auto back = move->reverse(); + auto seq = Sequence::create(move, back,NULL); _tamara->runAction( RepeatForever::create(seq) ); schedule( schedule_selector(TMXIsoVertexZ::repositionSprite)); @@ -962,7 +962,7 @@ void TMXIsoVertexZ::repositionSprite(float dt) { // tile height is 64x32 // map size: 30x30 - Point p = _tamara->getPosition(); + auto p = _tamara->getPosition(); p = CC_POINT_POINTS_TO_PIXELS(p); float newZ = -(p.y+32) /16; _tamara->setVertexZ( newZ ); @@ -1001,7 +1001,7 @@ std::string TMXIsoVertexZ::subtitle() //------------------------------------------------------------------ TMXOrthoVertexZ::TMXOrthoVertexZ() { - TMXTiledMap *map = TMXTiledMap::create("TileMaps/orthogonal-test-vertexz.tmx"); + auto map = TMXTiledMap::create("TileMaps/orthogonal-test-vertexz.tmx"); addChild(map, 0, kTagTileMap); Size CC_UNUSED s = map->getContentSize(); @@ -1009,14 +1009,14 @@ TMXOrthoVertexZ::TMXOrthoVertexZ() // because I'm lazy, I'm reusing a tile as an sprite, but since this method uses vertexZ, you // can use any Sprite and it will work OK. - TMXLayer* layer = map->getLayer("trees"); + auto layer = map->getLayer("trees"); _tamara = layer->getTileAt(Point(0,11)); CCLOG("%p vertexZ: %f", _tamara, _tamara->getVertexZ()); _tamara->retain(); - ActionInterval* move = MoveBy::create(10, Point(400,450) * (1/CC_CONTENT_SCALE_FACTOR())); - ActionInterval* back = move->reverse(); - Sequence* seq = Sequence::create(move, back,NULL); + auto move = MoveBy::create(10, Point(400,450) * (1/CC_CONTENT_SCALE_FACTOR())); + auto back = move->reverse(); + auto seq = Sequence::create(move, back,NULL); _tamara->runAction( RepeatForever::create(seq)); schedule(schedule_selector(TMXOrthoVertexZ::repositionSprite)); @@ -1032,7 +1032,7 @@ void TMXOrthoVertexZ::repositionSprite(float dt) { // tile height is 101x81 // map size: 12x12 - Point p = _tamara->getPosition(); + auto p = _tamara->getPosition(); p = CC_POINT_POINTS_TO_PIXELS(p); _tamara->setVertexZ( -( (p.y+81) /81) ); } @@ -1070,7 +1070,7 @@ std::string TMXOrthoVertexZ::subtitle() //------------------------------------------------------------------ TMXIsoMoveLayer::TMXIsoMoveLayer() { - TMXTiledMap* map = TMXTiledMap::create("TileMaps/iso-test-movelayer.tmx"); + auto map = TMXTiledMap::create("TileMaps/iso-test-movelayer.tmx"); addChild(map, 0, kTagTileMap); map->setPosition(Point(-700,-50)); @@ -1097,7 +1097,7 @@ std::string TMXIsoMoveLayer::subtitle() //------------------------------------------------------------------ TMXOrthoMoveLayer::TMXOrthoMoveLayer() { - TMXTiledMap *map = TMXTiledMap::create("TileMaps/orthogonal-test-movelayer.tmx"); + auto map = TMXTiledMap::create("TileMaps/orthogonal-test-movelayer.tmx"); addChild(map, 0, kTagTileMap); Size CC_UNUSED s = map->getContentSize(); @@ -1122,7 +1122,7 @@ std::string TMXOrthoMoveLayer::subtitle() TMXTilePropertyTest::TMXTilePropertyTest() { - TMXTiledMap *map = TMXTiledMap::create("TileMaps/ortho-tile-property.tmx"); + auto map = TMXTiledMap::create("TileMaps/ortho-tile-property.tmx"); addChild(map ,0 ,kTagTileMap); for(int i=1;i<=20;i++){ @@ -1148,7 +1148,7 @@ std::string TMXTilePropertyTest::subtitle() TMXOrthoFlipTest::TMXOrthoFlipTest() { - TMXTiledMap *map = TMXTiledMap::create("TileMaps/ortho-rotation-test.tmx"); + auto map = TMXTiledMap::create("TileMaps/ortho-rotation-test.tmx"); addChild(map, 0, kTagTileMap); Size CC_UNUSED s = map->getContentSize(); @@ -1157,11 +1157,11 @@ TMXOrthoFlipTest::TMXOrthoFlipTest() Object* pObj = NULL; CCARRAY_FOREACH(map->getChildren(), pObj) { - SpriteBatchNode* child = static_cast(pObj); + auto child = static_cast(pObj); child->getTexture()->setAntiAliasTexParameters(); } - ScaleBy* action = ScaleBy::create(2, 0.5f); + auto action = ScaleBy::create(2, 0.5f); map->runAction(action); } @@ -1178,20 +1178,20 @@ std::string TMXOrthoFlipTest::title() TMXOrthoFlipRunTimeTest::TMXOrthoFlipRunTimeTest() { - TMXTiledMap *map = TMXTiledMap::create("TileMaps/ortho-rotation-test.tmx"); + auto map = TMXTiledMap::create("TileMaps/ortho-rotation-test.tmx"); addChild(map, 0, kTagTileMap); - Size s = map->getContentSize(); + auto s = map->getContentSize(); log("ContentSize: %f, %f", s.width,s.height); Object* pObj = NULL; CCARRAY_FOREACH(map->getChildren(), pObj) { - SpriteBatchNode* child = static_cast(pObj); + auto child = static_cast(pObj); child->getTexture()->setAntiAliasTexParameters(); } - ScaleBy* action = ScaleBy::create(2, 0.5f); + auto action = ScaleBy::create(2, 0.5f); map->runAction(action); schedule(schedule_selector(TMXOrthoFlipRunTimeTest::flipIt), 1.0f); @@ -1209,11 +1209,11 @@ std::string TMXOrthoFlipRunTimeTest::subtitle() void TMXOrthoFlipRunTimeTest::flipIt(float dt) { - TMXTiledMap *map = (TMXTiledMap*) getChildByTag(kTagTileMap); - TMXLayer *layer = map->getLayer("Layer 0"); + auto map = (TMXTiledMap*) getChildByTag(kTagTileMap); + auto layer = map->getLayer("Layer 0"); //blue diamond - Point tileCoord = Point(1,10); + auto tileCoord = Point(1,10); int flags; unsigned int GID = layer->getTileGIDAt(tileCoord, (ccTMXTileFlags*)&flags); // Vertical @@ -1254,23 +1254,23 @@ TMXOrthoFromXMLTest::TMXOrthoFromXMLTest() string resources = "TileMaps"; // partial paths are OK as resource paths. string file = resources + "/orthogonal-test1.tmx"; - String* str = String::createWithContentsOfFile(FileUtils::getInstance()->fullPathForFilename(file.c_str()).c_str()); + auto str = String::createWithContentsOfFile(FileUtils::getInstance()->fullPathForFilename(file.c_str()).c_str()); CCASSERT(str != NULL, "Unable to open file"); - TMXTiledMap *map = TMXTiledMap::createWithXML(str->getCString() ,resources.c_str()); + auto map = TMXTiledMap::createWithXML(str->getCString() ,resources.c_str()); addChild(map, 0, kTagTileMap); - Size s = map->getContentSize(); + auto s = map->getContentSize(); log("ContentSize: %f, %f", s.width,s.height); Object* pObj = NULL; CCARRAY_FOREACH(map->getChildren(), pObj) { - SpriteBatchNode* child = static_cast(pObj); + auto child = static_cast(pObj); child->getTexture()->setAntiAliasTexParameters(); } - ScaleBy* action = ScaleBy::create(2, 0.5f); + auto action = ScaleBy::create(2, 0.5f); map->runAction(action); } @@ -1286,13 +1286,13 @@ std::string TMXOrthoFromXMLTest::title() //------------------------------------------------------------------ TMXBug987::TMXBug987() { - TMXTiledMap *map = TMXTiledMap::create("TileMaps/orthogonal-test6.tmx"); + auto map = TMXTiledMap::create("TileMaps/orthogonal-test6.tmx"); addChild(map, 0, kTagTileMap); Size CC_UNUSED s1 = map->getContentSize(); CCLOG("ContentSize: %f, %f", s1.width,s1.height); - Array* childs = map->getChildren(); + auto childs = map->getChildren(); TMXLayer* node; Object* pObject = NULL; CCARRAY_FOREACH(childs, pObject) @@ -1303,7 +1303,7 @@ TMXBug987::TMXBug987() } map->setAnchorPoint(Point(0, 0)); - TMXLayer *layer = map->getLayer("Tile Layer 1"); + auto layer = map->getLayer("Tile Layer 1"); layer->setTileGID(3, Point(2,2)); } @@ -1324,7 +1324,7 @@ std::string TMXBug987::subtitle() //------------------------------------------------------------------ TMXBug787::TMXBug787() { - TMXTiledMap *map = TMXTiledMap::create("TileMaps/iso-test-bug787.tmx"); + auto map = TMXTiledMap::create("TileMaps/iso-test-bug787.tmx"); addChild(map, 0, kTagTileMap); map->setScale(0.25f); @@ -1399,7 +1399,7 @@ Layer* nextTileMapAction() sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - Layer* layer = createTileMalayer(sceneIdx); + auto layer = createTileMalayer(sceneIdx); layer->autorelease(); return layer; @@ -1412,7 +1412,7 @@ Layer* backTileMapAction() if( sceneIdx < 0 ) sceneIdx += total; - Layer* layer = createTileMalayer(sceneIdx); + auto layer = createTileMalayer(sceneIdx); layer->autorelease(); return layer; @@ -1420,7 +1420,7 @@ Layer* backTileMapAction() Layer* restartTileMapAction() { - Layer* layer = createTileMalayer(sceneIdx); + auto layer = createTileMalayer(sceneIdx); layer->autorelease(); return layer; @@ -1454,7 +1454,7 @@ void TileDemo::onEnter() void TileDemo::restartCallback(Object* sender) { - Scene* s = new TileMapTestScene(); + auto s = new TileMapTestScene(); s->addChild(restartTileMapAction()); Director::getInstance()->replaceScene(s); @@ -1463,7 +1463,7 @@ void TileDemo::restartCallback(Object* sender) void TileDemo::nextCallback(Object* sender) { - Scene* s = new TileMapTestScene(); + auto s = new TileMapTestScene(); s->addChild( nextTileMapAction() ); Director::getInstance()->replaceScene(s); s->release(); @@ -1471,7 +1471,7 @@ void TileDemo::nextCallback(Object* sender) void TileDemo::backCallback(Object* sender) { - Scene* s = new TileMapTestScene(); + auto s = new TileMapTestScene(); s->addChild( backTileMapAction() ); Director::getInstance()->replaceScene(s); s->release(); @@ -1479,17 +1479,17 @@ void TileDemo::backCallback(Object* sender) void TileDemo::ccTouchesMoved(Set *touches, Event *event) { - Touch *touch = static_cast(touches->anyObject()); + auto touch = static_cast(touches->anyObject()); - Point diff = touch->getDelta(); - Node *node = getChildByTag(kTagTileMap); - Point currentPos = node->getPosition(); + auto diff = touch->getDelta(); + auto node = getChildByTag(kTagTileMap); + auto currentPos = node->getPosition(); node->setPosition(currentPos + diff); } void TileMapTestScene::runThisTest() { - Layer* layer = nextTileMapAction(); + auto layer = nextTileMapAction(); addChild(layer); // fix bug #486, #419. @@ -1502,23 +1502,23 @@ void TileMapTestScene::runThisTest() TMXGIDObjectsTest::TMXGIDObjectsTest() { - TMXTiledMap *map = TMXTiledMap::create("TileMaps/test-object-layer.tmx"); + auto map = TMXTiledMap::create("TileMaps/test-object-layer.tmx"); addChild(map, -1, kTagTileMap); Size CC_UNUSED s = map->getContentSize(); CCLOG("Contentsize: %f, %f", s.width, s.height); CCLOG("----> Iterating over all the group objets"); - //CCTMXObjectGroup *group = map->objectGroupNamed("Object Layer 1"); + //auto group = map->objectGroupNamed("Object Layer 1"); } void TMXGIDObjectsTest::draw() { - TMXTiledMap *map = (TMXTiledMap*)getChildByTag(kTagTileMap); - TMXObjectGroup *group = map->getObjectGroup("Object Layer 1"); + auto map = (TMXTiledMap*)getChildByTag(kTagTileMap); + auto group = map->getObjectGroup("Object Layer 1"); - Array *array = group->getObjects(); + auto array = group->getObjects(); Dictionary* dict; Object* pObj = NULL; CCARRAY_FOREACH(array, pObj) diff --git a/samples/Cpp/TestCpp/Classes/TouchesTest/Ball.cpp b/samples/Cpp/TestCpp/Classes/TouchesTest/Ball.cpp index 1d4bdcc213..265dd5a2b9 100644 --- a/samples/Cpp/TestCpp/Classes/TouchesTest/Ball.cpp +++ b/samples/Cpp/TestCpp/Classes/TouchesTest/Ball.cpp @@ -42,7 +42,7 @@ void Ball::move(float delta) void Ball::collideWithPaddle(Paddle* paddle) { - Rect paddleRect = paddle->getRect(); + auto paddleRect = paddle->getRect(); paddleRect.origin.x += paddle->getPosition().x; paddleRect.origin.y += paddle->getPosition().y; diff --git a/samples/Cpp/TestCpp/Classes/TouchesTest/Paddle.cpp b/samples/Cpp/TestCpp/Classes/TouchesTest/Paddle.cpp index db6d109805..5a578d47f4 100644 --- a/samples/Cpp/TestCpp/Classes/TouchesTest/Paddle.cpp +++ b/samples/Cpp/TestCpp/Classes/TouchesTest/Paddle.cpp @@ -10,7 +10,7 @@ Paddle::~Paddle(void) Rect Paddle::getRect() { - Size s = getTexture()->getContentSize(); + auto s = getTexture()->getContentSize(); return Rect(-s.width / 2, -s.height / 2, s.width, s.height); } @@ -35,14 +35,14 @@ bool Paddle::initWithTexture(Texture2D* aTexture) void Paddle::onEnter() { - Director* director = Director::getInstance(); + auto director = Director::getInstance(); director->getTouchDispatcher()->addTargetedDelegate(this, 0, true); Sprite::onEnter(); } void Paddle::onExit() { - Director* director = Director::getInstance(); + auto director = Director::getInstance(); director->getTouchDispatcher()->removeDelegate(this); Sprite::onExit(); } @@ -72,7 +72,7 @@ void Paddle::ccTouchMoved(Touch* touch, Event* event) CCASSERT(_state == kPaddleStateGrabbed, "Paddle - Unexpected state!"); - Point touchPoint = touch->getLocation(); + auto touchPoint = touch->getLocation(); setPosition( Point(touchPoint.x, getPosition().y) ); } diff --git a/samples/Cpp/TestCpp/Classes/TouchesTest/TouchesTest.cpp b/samples/Cpp/TestCpp/Classes/TouchesTest/TouchesTest.cpp index 7cd86d42a3..6c57cac1b5 100644 --- a/samples/Cpp/TestCpp/Classes/TouchesTest/TouchesTest.cpp +++ b/samples/Cpp/TestCpp/Classes/TouchesTest/TouchesTest.cpp @@ -25,7 +25,7 @@ enum //------------------------------------------------------------------ PongScene::PongScene() { - PongLayer *pongLayer = new PongLayer();//PongLayer::create(); + auto pongLayer = new PongLayer();//PongLayer::create(); addChild(pongLayer); pongLayer->release(); } @@ -45,9 +45,9 @@ PongLayer::PongLayer() addChild( _ball ); _ball->retain(); - Texture2D* paddleTexture = TextureCache::getInstance()->addImage(s_Paddle); + auto paddleTexture = TextureCache::getInstance()->addImage(s_Paddle); - Array *paddlesM = Array::createWithCapacity(4); + auto paddlesM = Array::createWithCapacity(4); Paddle* paddle = Paddle::createWithTexture(paddleTexture); paddle->setPosition( Point(VisibleRect::center().x, VisibleRect::bottom().y + 15) ); diff --git a/samples/Cpp/TestCpp/Classes/TransitionsTest/TransitionsTest.cpp b/samples/Cpp/TestCpp/Classes/TransitionsTest/TransitionsTest.cpp index e79f1c58a6..aaa8915438 100644 --- a/samples/Cpp/TestCpp/Classes/TransitionsTest/TransitionsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/TransitionsTest/TransitionsTest.cpp @@ -267,7 +267,7 @@ TransitionScene* createTransition(int nIndex, float t, Scene* s) void TransitionsTestScene::runThisTest() { - Layer * layer = new TestLayer1(); + auto layer = new TestLayer1(); addChild(layer); layer->release(); @@ -278,30 +278,30 @@ TestLayer1::TestLayer1(void) { float x,y; - Size size = Director::getInstance()->getWinSize(); + auto size = Director::getInstance()->getWinSize(); x = size.width; y = size.height; - Sprite* bg1 = Sprite::create(s_back1); + auto bg1 = Sprite::create(s_back1); bg1->setPosition( Point(size.width/2, size.height/2) ); addChild(bg1, -1); - LabelTTF* title = LabelTTF::create( (transitions[s_nSceneIdx]).c_str(), "Thonburi", 32 ); + auto title = LabelTTF::create( (transitions[s_nSceneIdx]).c_str(), "Thonburi", 32 ); addChild(title); title->setColor( Color3B(255,32,32) ); title->setPosition( Point(x/2, y-100) ); - LabelTTF* label = LabelTTF::create("SCENE 1", "Marker Felt", 38); + auto label = LabelTTF::create("SCENE 1", "Marker Felt", 38); label->setColor( Color3B(16,16,255)); label->setPosition( Point(x/2,y/2)); addChild( label); // menu - MenuItemImage *item1 = MenuItemImage::create(s_pathB1, s_pathB2, CC_CALLBACK_1(TestLayer1::backCallback, this) ); - MenuItemImage *item2 = MenuItemImage::create(s_pathR1, s_pathR2, CC_CALLBACK_1(TestLayer1::restartCallback, this) ); - MenuItemImage *item3 = MenuItemImage::create(s_pathF1, s_pathF2, CC_CALLBACK_1(TestLayer1::nextCallback, this) ); + auto item1 = MenuItemImage::create(s_pathB1, s_pathB2, CC_CALLBACK_1(TestLayer1::backCallback, this) ); + auto item2 = MenuItemImage::create(s_pathR1, s_pathR2, CC_CALLBACK_1(TestLayer1::restartCallback, this) ); + auto item3 = MenuItemImage::create(s_pathF1, s_pathF2, CC_CALLBACK_1(TestLayer1::nextCallback, this) ); - Menu *menu = Menu::create(item1, item2, item3, NULL); + auto menu = Menu::create(item1, item2, item3, NULL); menu->setPosition( Point::ZERO ); item1->setPosition(Point(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2)); @@ -320,12 +320,12 @@ TestLayer1::~TestLayer1(void) void TestLayer1::restartCallback(Object* sender) { - Scene* s = new TransitionsTestScene(); + auto s = new TransitionsTestScene(); - Layer* layer = new TestLayer2(); + auto layer = new TestLayer2(); s->addChild(layer); - Scene* scene = createTransition(s_nSceneIdx, TRANSITION_DURATION, s); + auto scene = createTransition(s_nSceneIdx, TRANSITION_DURATION, s); s->release(); layer->release(); if (scene) @@ -339,12 +339,12 @@ void TestLayer1::nextCallback(Object* sender) s_nSceneIdx++; s_nSceneIdx = s_nSceneIdx % MAX_LAYER; - Scene* s = new TransitionsTestScene(); + auto s = new TransitionsTestScene(); - Layer* layer = new TestLayer2(); + auto layer = new TestLayer2(); s->addChild(layer); - Scene* scene = createTransition(s_nSceneIdx, TRANSITION_DURATION, s); + auto scene = createTransition(s_nSceneIdx, TRANSITION_DURATION, s); s->release(); layer->release(); if (scene) @@ -360,12 +360,12 @@ void TestLayer1::backCallback(Object* sender) if( s_nSceneIdx < 0 ) s_nSceneIdx += total; - Scene* s = new TransitionsTestScene(); + auto s = new TransitionsTestScene(); - Layer* layer = new TestLayer2(); + auto layer = new TestLayer2(); s->addChild(layer); - Scene* scene = createTransition(s_nSceneIdx, TRANSITION_DURATION, s); + auto scene = createTransition(s_nSceneIdx, TRANSITION_DURATION, s); s->release(); layer->release(); if (scene) @@ -407,30 +407,30 @@ TestLayer2::TestLayer2() { float x,y; - Size size = Director::getInstance()->getWinSize(); + auto size = Director::getInstance()->getWinSize(); x = size.width; y = size.height; - Sprite* bg1 = Sprite::create(s_back2); + auto bg1 = Sprite::create(s_back2); bg1->setPosition( Point(size.width/2, size.height/2) ); addChild(bg1, -1); - LabelTTF* title = LabelTTF::create((transitions[s_nSceneIdx]).c_str(), "Thonburi", 32 ); + auto title = LabelTTF::create((transitions[s_nSceneIdx]).c_str(), "Thonburi", 32 ); addChild(title); title->setColor( Color3B(255,32,32) ); title->setPosition( Point(x/2, y-100) ); - LabelTTF* label = LabelTTF::create("SCENE 2", "Marker Felt", 38); + auto label = LabelTTF::create("SCENE 2", "Marker Felt", 38); label->setColor( Color3B(16,16,255)); label->setPosition( Point(x/2,y/2)); addChild( label); // menu - MenuItemImage *item1 = MenuItemImage::create(s_pathB1, s_pathB2, CC_CALLBACK_1(TestLayer2::backCallback, this) ); - MenuItemImage *item2 = MenuItemImage::create(s_pathR1, s_pathR2, CC_CALLBACK_1(TestLayer2::restartCallback, this) ); - MenuItemImage *item3 = MenuItemImage::create(s_pathF1, s_pathF2, CC_CALLBACK_1(TestLayer2::nextCallback, this) ); + auto item1 = MenuItemImage::create(s_pathB1, s_pathB2, CC_CALLBACK_1(TestLayer2::backCallback, this) ); + auto item2 = MenuItemImage::create(s_pathR1, s_pathR2, CC_CALLBACK_1(TestLayer2::restartCallback, this) ); + auto item3 = MenuItemImage::create(s_pathF1, s_pathF2, CC_CALLBACK_1(TestLayer2::nextCallback, this) ); - Menu *menu = Menu::create(item1, item2, item3, NULL); + auto menu = Menu::create(item1, item2, item3, NULL); menu->setPosition( Point::ZERO ); item1->setPosition(Point(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2)); @@ -449,12 +449,12 @@ TestLayer2::~TestLayer2() void TestLayer2::restartCallback(Object* sender) { - Scene* s = new TransitionsTestScene(); + auto s = new TransitionsTestScene(); - Layer* layer = new TestLayer1(); + auto layer = new TestLayer1(); s->addChild(layer); - Scene* scene = createTransition(s_nSceneIdx, TRANSITION_DURATION, s); + auto scene = createTransition(s_nSceneIdx, TRANSITION_DURATION, s); s->release(); layer->release(); if (scene) @@ -468,12 +468,12 @@ void TestLayer2::nextCallback(Object* sender) s_nSceneIdx++; s_nSceneIdx = s_nSceneIdx % MAX_LAYER; - Scene* s = new TransitionsTestScene(); + auto s = new TransitionsTestScene(); - Layer* layer = new TestLayer1(); + auto layer = new TestLayer1(); s->addChild(layer); - Scene* scene = createTransition(s_nSceneIdx, TRANSITION_DURATION, s); + auto scene = createTransition(s_nSceneIdx, TRANSITION_DURATION, s); s->release(); layer->release(); if (scene) @@ -489,12 +489,12 @@ void TestLayer2::backCallback(Object* sender) if( s_nSceneIdx < 0 ) s_nSceneIdx += total; - Scene* s = new TransitionsTestScene(); + auto s = new TransitionsTestScene(); - Layer* layer = new TestLayer1(); + auto layer = new TestLayer1(); s->addChild(layer); - Scene* scene = createTransition(s_nSceneIdx, TRANSITION_DURATION, s); + auto scene = createTransition(s_nSceneIdx, TRANSITION_DURATION, s); s->release(); layer->release(); if (scene) diff --git a/samples/Cpp/TestCpp/Classes/UserDefaultTest/UserDefaultTest.cpp b/samples/Cpp/TestCpp/Classes/UserDefaultTest/UserDefaultTest.cpp index e7e656efd1..70d21c3cd4 100644 --- a/samples/Cpp/TestCpp/Classes/UserDefaultTest/UserDefaultTest.cpp +++ b/samples/Cpp/TestCpp/Classes/UserDefaultTest/UserDefaultTest.cpp @@ -7,8 +7,8 @@ UserDefaultTest::UserDefaultTest() { - Size s = Director::getInstance()->getWinSize(); - LabelTTF* label = LabelTTF::create("CCUserDefault test see log", "Arial", 28); + auto s = Director::getInstance()->getWinSize(); + auto label = LabelTTF::create("CCUserDefault test see log", "Arial", 28); addChild(label, 0); label->setPosition( Point(s.width/2, s.height-50) ); @@ -97,7 +97,7 @@ UserDefaultTest::~UserDefaultTest() void UserDefaultTestScene::runThisTest() { - Layer* layer = new UserDefaultTest(); + auto layer = new UserDefaultTest(); addChild(layer); Director::getInstance()->replaceScene(this); diff --git a/samples/Cpp/TestCpp/Classes/VisibleRect.cpp b/samples/Cpp/TestCpp/Classes/VisibleRect.cpp index f958697668..54f82a3784 100644 --- a/samples/Cpp/TestCpp/Classes/VisibleRect.cpp +++ b/samples/Cpp/TestCpp/Classes/VisibleRect.cpp @@ -6,7 +6,7 @@ void VisibleRect::lazyInit() { if (s_visibleRect.size.width == 0.0f && s_visibleRect.size.height == 0.0f) { - EGLView* glView = EGLView::getInstance(); + auto glView = EGLView::getInstance(); s_visibleRect.origin = glView->getVisibleOrigin(); s_visibleRect.size = glView->getVisibleSize(); } diff --git a/samples/Cpp/TestCpp/Classes/ZwoptexTest/ZwoptexTest.cpp b/samples/Cpp/TestCpp/Classes/ZwoptexTest/ZwoptexTest.cpp index afb4388c5d..76c508d860 100644 --- a/samples/Cpp/TestCpp/Classes/ZwoptexTest/ZwoptexTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ZwoptexTest/ZwoptexTest.cpp @@ -24,7 +24,7 @@ Layer* nextZwoptexTest() sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - Layer* layer = createZwoptexLayer(sceneIdx); + auto layer = createZwoptexLayer(sceneIdx); layer->autorelease(); return layer; @@ -37,7 +37,7 @@ Layer* backZwoptexTest() if( sceneIdx < 0 ) sceneIdx += total; - Layer* layer = createZwoptexLayer(sceneIdx); + auto layer = createZwoptexLayer(sceneIdx); layer->autorelease(); return layer; @@ -45,7 +45,7 @@ Layer* backZwoptexTest() Layer* restartZwoptexTest() { - Layer* layer = createZwoptexLayer(sceneIdx); + auto layer = createZwoptexLayer(sceneIdx); layer->autorelease(); return layer; @@ -63,21 +63,21 @@ void ZwoptexTest::onEnter() void ZwoptexTest::restartCallback(Object* sender) { - Scene *s = ZwoptexTestScene::create(); + auto s = ZwoptexTestScene::create(); s->addChild(restartZwoptexTest()); Director::getInstance()->replaceScene(s); } void ZwoptexTest::nextCallback(Object* sender) { - Scene *s = ZwoptexTestScene::create(); + auto s = ZwoptexTestScene::create(); s->addChild(nextZwoptexTest()); Director::getInstance()->replaceScene(s); } void ZwoptexTest::backCallback(Object* sender) { - Scene *s = ZwoptexTestScene::create(); + auto s = ZwoptexTestScene::create(); s->addChild(backZwoptexTest()); Director::getInstance()->replaceScene(s); } @@ -101,12 +101,12 @@ void ZwoptexGenericTest::onEnter() { ZwoptexTest::onEnter(); - Size s = Director::getInstance()->getWinSize(); + auto s = Director::getInstance()->getWinSize(); SpriteFrameCache::getInstance()->addSpriteFramesWithFile("zwoptex/grossini.plist"); SpriteFrameCache::getInstance()->addSpriteFramesWithFile("zwoptex/grossini-generic.plist"); - LayerColor *layer1 = LayerColor::create(Color4B(255, 0, 0, 255), 85, 121); + auto layer1 = LayerColor::create(Color4B(255, 0, 0, 255), 85, 121); layer1->setPosition(Point(s.width/2-80 - (85.0f * 0.5f), s.height/2 - (121.0f * 0.5f))); addChild(layer1); @@ -117,7 +117,7 @@ void ZwoptexGenericTest::onEnter() sprite1->setFlipX(false); sprite1->setFlipY(false); - LayerColor *layer2 = LayerColor::create(Color4B(255, 0, 0, 255), 85, 121); + auto layer2 = LayerColor::create(Color4B(255, 0, 0, 255), 85, 121); layer2->setPosition(Point(s.width/2+80 - (85.0f * 0.5f), s.height/2 - (121.0f * 0.5f))); addChild(layer2); @@ -193,7 +193,7 @@ ZwoptexGenericTest::~ZwoptexGenericTest() { sprite1->release(); sprite2->release(); - SpriteFrameCache *cache = SpriteFrameCache::getInstance(); + auto cache = SpriteFrameCache::getInstance(); cache->removeSpriteFramesFromFile("zwoptex/grossini.plist"); cache->removeSpriteFramesFromFile("zwoptex/grossini-generic.plist"); } @@ -210,7 +210,7 @@ std::string ZwoptexGenericTest::subtitle() void ZwoptexTestScene::runThisTest() { - Layer* layer = nextZwoptexTest(); + auto layer = nextZwoptexTest(); addChild(layer); Director::getInstance()->replaceScene(this); diff --git a/samples/Cpp/TestCpp/Classes/controller.cpp b/samples/Cpp/TestCpp/Classes/controller.cpp index a0f777a0fc..26971f6452 100644 --- a/samples/Cpp/TestCpp/Classes/controller.cpp +++ b/samples/Cpp/TestCpp/Classes/controller.cpp @@ -95,8 +95,8 @@ TestController::TestController() : _beginPos(Point::ZERO) { // add close menu - MenuItemImage *closeItem = MenuItemImage::create(s_pathClose, s_pathClose, CC_CALLBACK_1(TestController::closeCallback, this) ); - Menu* menu =Menu::create(closeItem, NULL); + auto closeItem = MenuItemImage::create(s_pathClose, s_pathClose, CC_CALLBACK_1(TestController::closeCallback, this) ); + auto menu =Menu::create(closeItem, NULL); menu->setPosition( Point::ZERO ); closeItem->setPosition(Point( VisibleRect::right().x - 30, VisibleRect::top().y - 30)); @@ -106,11 +106,11 @@ TestController::TestController() for (int i = 0; i < g_testCount; ++i) { // #if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE) -// LabelBMFont* label = LabelBMFont::create(g_aTestNames[i].c_str(), "fonts/arial16.fnt"); +// auto label = LabelBMFont::create(g_aTestNames[i].c_str(), "fonts/arial16.fnt"); // #else - LabelTTF* label = LabelTTF::create( g_aTestNames[i].test_name, "Arial", 24); + auto label = LabelTTF::create( g_aTestNames[i].test_name, "Arial", 24); // #endif - MenuItemLabel* menuItem = MenuItemLabel::create(label, CC_CALLBACK_1(TestController::menuCallback, this)); + auto menuItem = MenuItemLabel::create(label, CC_CALLBACK_1(TestController::menuCallback, this)); _itemMenu->addChild(menuItem, i + 10000); menuItem->setPosition( Point( VisibleRect::center().x, (VisibleRect::top().y - (i + 1) * LINE_SPACE) )); @@ -136,11 +136,11 @@ void TestController::menuCallback(Object * sender) Director::getInstance()->purgeCachedData(); // get the userdata, it's the index of the menu item clicked - MenuItem* menuItem = static_cast(sender); + auto menuItem = static_cast(sender); int idx = menuItem->getZOrder() - 10000; // create the test scene and run it - TestScene* scene = g_aTestNames[idx].callback(); + auto scene = g_aTestNames[idx].callback(); if (scene) { @@ -159,20 +159,20 @@ void TestController::closeCallback(Object * sender) void TestController::ccTouchesBegan(Set *touches, Event *event) { - Touch* touch = static_cast(touches->anyObject()); + auto touch = static_cast(touches->anyObject()); _beginPos = touch->getLocation(); } void TestController::ccTouchesMoved(Set *touches, Event *event) { - Touch* touch = static_cast(touches->anyObject()); + auto touch = static_cast(touches->anyObject()); - Point touchLocation = touch->getLocation(); + auto touchLocation = touch->getLocation(); float nMoveY = touchLocation.y - _beginPos.y; - Point curPos = _itemMenu->getPosition(); - Point nextPos = Point(curPos.x, curPos.y + nMoveY); + auto curPos = _itemMenu->getPosition(); + auto nextPos = Point(curPos.x, curPos.y + nMoveY); if (nextPos.y < 0.0f) { diff --git a/samples/Cpp/TestCpp/Classes/testBasic.cpp b/samples/Cpp/TestCpp/Classes/testBasic.cpp index adabca863e..c1c7b22bad 100644 --- a/samples/Cpp/TestCpp/Classes/testBasic.cpp +++ b/samples/Cpp/TestCpp/Classes/testBasic.cpp @@ -13,11 +13,11 @@ void TestScene::onEnter() //add the menu item for back to main menu //#if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE) -// LabelBMFont* label = LabelBMFont::create("MainMenu", "fonts/arial16.fnt"); +// auto label = LabelBMFont::create("MainMenu", "fonts/arial16.fnt"); //#else - LabelTTF* label = LabelTTF::create("MainMenu", "Arial", 20); + auto label = LabelTTF::create("MainMenu", "Arial", 20); //#endif - MenuItemLabel* menuItem = MenuItemLabel::create(label, [](Object *sender) { + auto menuItem = MenuItemLabel::create(label, [](Object *sender) { /* ****** GCC Compiler issue on Android and Linux (CLANG compiler is ok) ****** We couldn't use 'Scene::create' directly since gcc will trigger @@ -35,11 +35,11 @@ void TestScene::onEnter() outside the scope. So I choose the (2) solution. Commented by James Chen. */ -// Scene *scene = Scene::create(); - Scene *scene = new Scene(); +// auto scene = Scene::create(); + auto scene = new Scene(); if (scene && scene->init()) { - Layer* layer = new TestController(); + auto layer = new TestController(); scene->addChild(layer); layer->release(); Director::getInstance()->replaceScene(scene); @@ -47,7 +47,7 @@ void TestScene::onEnter() } }); - Menu* menu =Menu::create(menuItem, NULL); + auto menu =Menu::create(menuItem, NULL); menu->setPosition( Point::ZERO ); menuItem->setPosition( Point( VisibleRect::right().x - 50, VisibleRect::bottom().y + 25) ); diff --git a/samples/Cpp/TestCpp/proj.android/project.properties b/samples/Cpp/TestCpp/proj.android/project.properties index db4ff43492..b93e70be46 100644 --- a/samples/Cpp/TestCpp/proj.android/project.properties +++ b/samples/Cpp/TestCpp/proj.android/project.properties @@ -8,6 +8,6 @@ # project structure. # Project target. -target=android-13 +target=android-17 android.library.reference.1=../../../../cocos2dx/platform/android/java diff --git a/samples/Cpp/TestCpp/proj.linux/main.cpp b/samples/Cpp/TestCpp/proj.linux/main.cpp index f3ec556870..2a8e3be95f 100644 --- a/samples/Cpp/TestCpp/proj.linux/main.cpp +++ b/samples/Cpp/TestCpp/proj.linux/main.cpp @@ -13,7 +13,7 @@ int main(int argc, char **argv) { // create the application instance AppDelegate app; - EGLView* eglView = EGLView::getInstance(); + auto eglView = EGLView::getInstance(); eglView->setFrameSize(800, 480); return Application::getInstance()->run(); } diff --git a/samples/Cpp/TestCpp/proj.qt5/main.cpp b/samples/Cpp/TestCpp/proj.qt5/main.cpp index c77a203887..87fe8873df 100644 --- a/samples/Cpp/TestCpp/proj.qt5/main.cpp +++ b/samples/Cpp/TestCpp/proj.qt5/main.cpp @@ -13,7 +13,7 @@ int main(int argc, char **argv) { // create the application instance AppDelegate app; - CCEGLView* eglView = CCEGLView::sharedOpenGLView(); + auto eglView = CCEGLView::sharedOpenGLView(); eglView->setFrameSize(800, 480); return CCApplication::sharedApplication()->run(); } diff --git a/samples/Cpp/TestCpp/proj.tizen/src/TestCppEntry.cpp b/samples/Cpp/TestCpp/proj.tizen/src/TestCppEntry.cpp index d57b3d8ede..3ec1b2ae63 100644 --- a/samples/Cpp/TestCpp/proj.tizen/src/TestCppEntry.cpp +++ b/samples/Cpp/TestCpp/proj.tizen/src/TestCppEntry.cpp @@ -43,7 +43,7 @@ ApplicationInitialized(void) { AppDelegate* pAppDelegate = new AppDelegate; - EGLView* eglView = EGLView::getInstance(); + auto eglView = EGLView::getInstance(); eglView->setFrameSize(1280, 720); Application::getInstance()->run(); diff --git a/samples/Cpp/TestCpp/proj.win32/main.cpp b/samples/Cpp/TestCpp/proj.win32/main.cpp index 93b315bc2a..f0a5e1ff14 100644 --- a/samples/Cpp/TestCpp/proj.win32/main.cpp +++ b/samples/Cpp/TestCpp/proj.win32/main.cpp @@ -14,7 +14,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, // create the application instance AppDelegate app; - EGLView* eglView = EGLView::getInstance(); + auto eglView = EGLView::getInstance(); eglView->setViewName("TestCpp"); eglView->setFrameSize(480, 320); return Application::getInstance()->run(); diff --git a/samples/Javascript/CocosDragonJS/Classes/AppDelegate.cpp b/samples/Javascript/CocosDragonJS/Classes/AppDelegate.cpp index f4032775d8..670d57a92b 100644 --- a/samples/Javascript/CocosDragonJS/Classes/AppDelegate.cpp +++ b/samples/Javascript/CocosDragonJS/Classes/AppDelegate.cpp @@ -31,15 +31,15 @@ AppDelegate::~AppDelegate() bool AppDelegate::applicationDidFinishLaunching() { // initialize director - Director *pDirector = Director::getInstance(); + auto pDirector = Director::getInstance(); pDirector->setOpenGLView(EGLView::getInstance()); pDirector->setProjection(Director::Projection::_2D); - Size screenSize = EGLView::getInstance()->getFrameSize(); + auto screenSize = EGLView::getInstance()->getFrameSize(); - Size designSize = Size(320, 480); - Size resourceSize = Size(320, 480); + auto designSize = Size(320, 480); + auto resourceSize = Size(320, 480); std::vector resDirOrders; @@ -130,7 +130,7 @@ bool AppDelegate::applicationDidFinishLaunching() sc->start(); js_log("RUNNING Main"); - ScriptEngineProtocol *pEngine = ScriptingCore::getInstance(); + auto pEngine = ScriptingCore::getInstance(); ScriptEngineManager::getInstance()->setScriptEngine(pEngine); ScriptingCore::getInstance()->runScript("main.js"); @@ -141,7 +141,7 @@ void handle_signal(int signal) { static int internal_state = 0; ScriptingCore* sc = ScriptingCore::getInstance(); // should start everything back - Director* director = Director::getInstance(); + auto director = Director::getInstance(); if (director->getRunningScene()) { director->popToRootScene(); } else { diff --git a/samples/Javascript/CocosDragonJS/proj.win32/main.cpp b/samples/Javascript/CocosDragonJS/proj.win32/main.cpp index d85957e750..5a6ed2372d 100644 --- a/samples/Javascript/CocosDragonJS/proj.win32/main.cpp +++ b/samples/Javascript/CocosDragonJS/proj.win32/main.cpp @@ -24,7 +24,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, // create the application instance AppDelegate app; - EGLView* eglView = EGLView::getInstance(); + auto eglView = EGLView::getInstance(); eglView->setViewName("CocosDragonJS"); eglView->setFrameSize(320, 480); diff --git a/samples/Javascript/CrystalCraze/Classes/AppDelegate.cpp b/samples/Javascript/CrystalCraze/Classes/AppDelegate.cpp index 2ff4bce996..ec958730ba 100644 --- a/samples/Javascript/CrystalCraze/Classes/AppDelegate.cpp +++ b/samples/Javascript/CrystalCraze/Classes/AppDelegate.cpp @@ -27,15 +27,15 @@ AppDelegate::~AppDelegate() bool AppDelegate::applicationDidFinishLaunching() { // initialize director - Director *pDirector = Director::getInstance(); + auto pDirector = Director::getInstance(); pDirector->setOpenGLView(EGLView::getInstance()); pDirector->setProjection(Director::Projection::_2D); - Size screenSize = EGLView::getInstance()->getFrameSize(); + auto screenSize = EGLView::getInstance()->getFrameSize(); - Size designSize = Size(320, 480); - Size resourceSize = Size(320, 480); + auto designSize = Size(320, 480); + auto resourceSize = Size(320, 480); std::vector searchPaths; std::vector resDirOrders; @@ -112,7 +112,7 @@ bool AppDelegate::applicationDidFinishLaunching() sc->start(); js_log("RUNNING Main"); - ScriptEngineProtocol *pEngine = ScriptingCore::getInstance(); + auto pEngine = ScriptingCore::getInstance(); ScriptEngineManager::getInstance()->setScriptEngine(pEngine); ScriptingCore::getInstance()->runScript("main.js"); @@ -123,7 +123,7 @@ void handle_signal(int signal) { static int internal_state = 0; ScriptingCore* sc = ScriptingCore::getInstance(); // should start everything back - Director* director = Director::getInstance(); + auto director = Director::getInstance(); if (director->getRunningScene()) { director->popToRootScene(); } else { diff --git a/samples/Javascript/CrystalCraze/proj.win32/main.cpp b/samples/Javascript/CrystalCraze/proj.win32/main.cpp index fbdae74d9d..71c7855504 100644 --- a/samples/Javascript/CrystalCraze/proj.win32/main.cpp +++ b/samples/Javascript/CrystalCraze/proj.win32/main.cpp @@ -24,7 +24,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, // create the application instance AppDelegate app; - EGLView* eglView = EGLView::getInstance(); + auto eglView = EGLView::getInstance(); eglView->setViewName("CrystalCraze"); eglView->setFrameSize(320, 480); diff --git a/samples/Javascript/MoonWarriors/Classes/AppDelegate.cpp b/samples/Javascript/MoonWarriors/Classes/AppDelegate.cpp index f186a261fb..0932e12b27 100644 --- a/samples/Javascript/MoonWarriors/Classes/AppDelegate.cpp +++ b/samples/Javascript/MoonWarriors/Classes/AppDelegate.cpp @@ -27,7 +27,7 @@ AppDelegate::~AppDelegate() bool AppDelegate::applicationDidFinishLaunching() { // initialize director - Director *pDirector = Director::getInstance(); + auto pDirector = Director::getInstance(); pDirector->setOpenGLView(EGLView::getInstance()); pDirector->setProjection(Director::Projection::_2D); @@ -52,7 +52,7 @@ bool AppDelegate::applicationDidFinishLaunching() sc->start(); - ScriptEngineProtocol *pEngine = ScriptingCore::getInstance(); + auto pEngine = ScriptingCore::getInstance(); ScriptEngineManager::getInstance()->setScriptEngine(pEngine); #if JSB_ENABLE_DEBUGGER ScriptingCore::getInstance()->runScript("main.debug.js"); @@ -67,7 +67,7 @@ void handle_signal(int signal) { static int internal_state = 0; ScriptingCore* sc = ScriptingCore::getInstance(); // should start everything back - Director* director = Director::getInstance(); + auto director = Director::getInstance(); if (director->getRunningScene()) { director->popToRootScene(); } else { diff --git a/samples/Javascript/MoonWarriors/proj.win32/main.cpp b/samples/Javascript/MoonWarriors/proj.win32/main.cpp index cd59bf06ae..8c3a60b997 100644 --- a/samples/Javascript/MoonWarriors/proj.win32/main.cpp +++ b/samples/Javascript/MoonWarriors/proj.win32/main.cpp @@ -24,7 +24,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, // create the application instance AppDelegate app; - EGLView* eglView = EGLView::getInstance(); + auto eglView = EGLView::getInstance(); eglView->setViewName("MoonWarriors"); eglView->setFrameSize(320, 480); diff --git a/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp b/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp index 916e9ea534..de6a48a276 100644 --- a/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp +++ b/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp @@ -30,7 +30,7 @@ AppDelegate::~AppDelegate() bool AppDelegate::applicationDidFinishLaunching() { // initialize director - Director *pDirector = Director::getInstance(); + auto pDirector = Director::getInstance(); pDirector->setOpenGLView(EGLView::getInstance()); // JS-Test in Html5 uses 800x450 as design resolution @@ -55,7 +55,7 @@ bool AppDelegate::applicationDidFinishLaunching() sc->start(); - ScriptEngineProtocol *pEngine = ScriptingCore::getInstance(); + auto pEngine = ScriptingCore::getInstance(); ScriptEngineManager::getInstance()->setScriptEngine(pEngine); #ifdef JS_OBFUSCATED ScriptingCore::getInstance()->runScript("game.js"); @@ -69,7 +69,7 @@ void handle_signal(int signal) { static int internal_state = 0; ScriptingCore* sc = ScriptingCore::getInstance(); // should start everything back - Director* director = Director::getInstance(); + auto director = Director::getInstance(); if (director->getRunningScene()) { director->popToRootScene(); } else { diff --git a/samples/Javascript/TestJavascript/proj.win32/main.cpp b/samples/Javascript/TestJavascript/proj.win32/main.cpp index 8636461895..5f8f03ad23 100644 --- a/samples/Javascript/TestJavascript/proj.win32/main.cpp +++ b/samples/Javascript/TestJavascript/proj.win32/main.cpp @@ -24,7 +24,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, // create the application instance AppDelegate app; - EGLView* eglView = EGLView::getInstance(); + auto eglView = EGLView::getInstance(); eglView->setViewName("TestJavascript"); eglView->setFrameSize(800, 450); diff --git a/samples/Javascript/WatermelonWithMe/Classes/AppDelegate.cpp b/samples/Javascript/WatermelonWithMe/Classes/AppDelegate.cpp index 6919f85fe9..3364e34c12 100644 --- a/samples/Javascript/WatermelonWithMe/Classes/AppDelegate.cpp +++ b/samples/Javascript/WatermelonWithMe/Classes/AppDelegate.cpp @@ -27,7 +27,7 @@ AppDelegate::~AppDelegate() bool AppDelegate::applicationDidFinishLaunching() { // initialize director - Director *pDirector = Director::getInstance(); + auto pDirector = Director::getInstance(); pDirector->setOpenGLView(EGLView::getInstance()); // turn on display FPS @@ -50,7 +50,7 @@ bool AppDelegate::applicationDidFinishLaunching() sc->start(); - ScriptEngineProtocol *pEngine = ScriptingCore::getInstance(); + auto pEngine = ScriptingCore::getInstance(); ScriptEngineManager::getInstance()->setScriptEngine(pEngine); ScriptingCore::getInstance()->runScript("boot-jsb.js"); @@ -61,7 +61,7 @@ void handle_signal(int signal) { static int internal_state = 0; ScriptingCore* sc = ScriptingCore::getInstance(); // should start everything back - Director* director = Director::getInstance(); + auto director = Director::getInstance(); if (director->getRunningScene()) { director->popToRootScene(); } else { diff --git a/samples/Javascript/WatermelonWithMe/proj.win32/main.cpp b/samples/Javascript/WatermelonWithMe/proj.win32/main.cpp index 0a1699034c..c07c7c63cf 100644 --- a/samples/Javascript/WatermelonWithMe/proj.win32/main.cpp +++ b/samples/Javascript/WatermelonWithMe/proj.win32/main.cpp @@ -24,7 +24,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, // create the application instance AppDelegate app; - EGLView* eglView = EGLView::getInstance(); + auto eglView = EGLView::getInstance(); eglView->setViewName("WatermelonWithMe"); eglView->setFrameSize(800, 450); diff --git a/samples/Lua/HelloLua/Classes/AppDelegate.cpp b/samples/Lua/HelloLua/Classes/AppDelegate.cpp index 3116264745..1e2cef387a 100644 --- a/samples/Lua/HelloLua/Classes/AppDelegate.cpp +++ b/samples/Lua/HelloLua/Classes/AppDelegate.cpp @@ -23,7 +23,7 @@ AppDelegate::~AppDelegate() bool AppDelegate::applicationDidFinishLaunching() { // initialize director - Director *pDirector = Director::getInstance(); + auto pDirector = Director::getInstance(); pDirector->setOpenGLView(EGLView::getInstance()); EGLView::getInstance()->setDesignResolutionSize(480, 320, ResolutionPolicy::NO_BORDER); diff --git a/samples/Lua/HelloLua/proj.emscripten/main.cpp b/samples/Lua/HelloLua/proj.emscripten/main.cpp index 889133bbaa..32b1bd80b3 100644 --- a/samples/Lua/HelloLua/proj.emscripten/main.cpp +++ b/samples/Lua/HelloLua/proj.emscripten/main.cpp @@ -12,7 +12,7 @@ int main(int argc, char **argv) { // create the application instance AppDelegate app; - EGLView* eglView = EGLView::getInstance(); + auto eglView = EGLView::getInstance(); eglView->setFrameSize(960, 640); return Application::getInstance()->run(); } diff --git a/samples/Lua/HelloLua/proj.linux/main.cpp b/samples/Lua/HelloLua/proj.linux/main.cpp index 889133bbaa..32b1bd80b3 100644 --- a/samples/Lua/HelloLua/proj.linux/main.cpp +++ b/samples/Lua/HelloLua/proj.linux/main.cpp @@ -12,7 +12,7 @@ int main(int argc, char **argv) { // create the application instance AppDelegate app; - EGLView* eglView = EGLView::getInstance(); + auto eglView = EGLView::getInstance(); eglView->setFrameSize(960, 640); return Application::getInstance()->run(); } diff --git a/samples/Lua/HelloLua/proj.tizen/src/HelloLuaEntry.cpp b/samples/Lua/HelloLua/proj.tizen/src/HelloLuaEntry.cpp index d57b3d8ede..3ec1b2ae63 100644 --- a/samples/Lua/HelloLua/proj.tizen/src/HelloLuaEntry.cpp +++ b/samples/Lua/HelloLua/proj.tizen/src/HelloLuaEntry.cpp @@ -43,7 +43,7 @@ ApplicationInitialized(void) { AppDelegate* pAppDelegate = new AppDelegate; - EGLView* eglView = EGLView::getInstance(); + auto eglView = EGLView::getInstance(); eglView->setFrameSize(1280, 720); Application::getInstance()->run(); diff --git a/samples/Lua/HelloLua/proj.win32/main.cpp b/samples/Lua/HelloLua/proj.win32/main.cpp index 4d0fa76347..957882fa41 100644 --- a/samples/Lua/HelloLua/proj.win32/main.cpp +++ b/samples/Lua/HelloLua/proj.win32/main.cpp @@ -24,7 +24,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, // create the application instance AppDelegate app; - EGLView* eglView = EGLView::getInstance(); + auto eglView = EGLView::getInstance(); eglView->setViewName("HelloLua"); eglView->setFrameSize(480, 320); int ret = Application::getInstance()->run(); diff --git a/samples/Lua/TestLua/Classes/AppDelegate.cpp b/samples/Lua/TestLua/Classes/AppDelegate.cpp index 8b763a80bd..6f5f6dedfe 100644 --- a/samples/Lua/TestLua/Classes/AppDelegate.cpp +++ b/samples/Lua/TestLua/Classes/AppDelegate.cpp @@ -20,7 +20,7 @@ AppDelegate::~AppDelegate() bool AppDelegate::applicationDidFinishLaunching() { // initialize director - Director *pDirector = Director::getInstance(); + auto pDirector = Director::getInstance(); pDirector->setOpenGLView(EGLView::getInstance()); // turn on display FPS @@ -29,15 +29,15 @@ bool AppDelegate::applicationDidFinishLaunching() // set FPS. the default value is 1.0/60 if you don't call this pDirector->setAnimationInterval(1.0 / 60); - Size screenSize = EGLView::getInstance()->getFrameSize(); + auto screenSize = EGLView::getInstance()->getFrameSize(); - Size designSize = Size(480, 320); + auto designSize = Size(480, 320); - FileUtils* pFileUtils = FileUtils::getInstance(); + auto pFileUtils = FileUtils::getInstance(); if (screenSize.height > 320) { - Size resourceSize = Size(960, 640); + auto resourceSize = Size(960, 640); std::vector searchPaths; searchPaths.push_back("hd"); pFileUtils->setSearchPaths(searchPaths); diff --git a/samples/Lua/TestLua/proj.emscripten/main.cpp b/samples/Lua/TestLua/proj.emscripten/main.cpp index f3ec556870..2a8e3be95f 100644 --- a/samples/Lua/TestLua/proj.emscripten/main.cpp +++ b/samples/Lua/TestLua/proj.emscripten/main.cpp @@ -13,7 +13,7 @@ int main(int argc, char **argv) { // create the application instance AppDelegate app; - EGLView* eglView = EGLView::getInstance(); + auto eglView = EGLView::getInstance(); eglView->setFrameSize(800, 480); return Application::getInstance()->run(); } diff --git a/samples/Lua/TestLua/proj.linux/main.cpp b/samples/Lua/TestLua/proj.linux/main.cpp index f3ec556870..2a8e3be95f 100644 --- a/samples/Lua/TestLua/proj.linux/main.cpp +++ b/samples/Lua/TestLua/proj.linux/main.cpp @@ -13,7 +13,7 @@ int main(int argc, char **argv) { // create the application instance AppDelegate app; - EGLView* eglView = EGLView::getInstance(); + auto eglView = EGLView::getInstance(); eglView->setFrameSize(800, 480); return Application::getInstance()->run(); } diff --git a/samples/Lua/TestLua/proj.tizen/src/TestLuaEntry.cpp b/samples/Lua/TestLua/proj.tizen/src/TestLuaEntry.cpp index d57b3d8ede..3ec1b2ae63 100644 --- a/samples/Lua/TestLua/proj.tizen/src/TestLuaEntry.cpp +++ b/samples/Lua/TestLua/proj.tizen/src/TestLuaEntry.cpp @@ -43,7 +43,7 @@ ApplicationInitialized(void) { AppDelegate* pAppDelegate = new AppDelegate; - EGLView* eglView = EGLView::getInstance(); + auto eglView = EGLView::getInstance(); eglView->setFrameSize(1280, 720); Application::getInstance()->run(); diff --git a/samples/Lua/TestLua/proj.win32/main.cpp b/samples/Lua/TestLua/proj.win32/main.cpp index c893718e49..1b29a1277e 100644 --- a/samples/Lua/TestLua/proj.win32/main.cpp +++ b/samples/Lua/TestLua/proj.win32/main.cpp @@ -24,7 +24,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, // create the application instance AppDelegate app; - EGLView* eglView = EGLView::getInstance(); + auto eglView = EGLView::getInstance(); eglView->setViewName("TestLua"); eglView->setFrameSize(480, 320); From 6779f494f338cf36f4df0ee6402cf1b43cb5e205 Mon Sep 17 00:00:00 2001 From: boyu0 Date: Fri, 16 Aug 2013 16:09:46 +0800 Subject: [PATCH 029/126] issue #2517: Restore TestCpp proj.android that edited by mistake. --- samples/Cpp/TestCpp/proj.android/project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/Cpp/TestCpp/proj.android/project.properties b/samples/Cpp/TestCpp/proj.android/project.properties index b93e70be46..db4ff43492 100644 --- a/samples/Cpp/TestCpp/proj.android/project.properties +++ b/samples/Cpp/TestCpp/proj.android/project.properties @@ -8,6 +8,6 @@ # project structure. # Project target. -target=android-17 +target=android-13 android.library.reference.1=../../../../cocos2dx/platform/android/java From f0dbc22c16c865c63c3b0851ab2137cc2cf89477 Mon Sep 17 00:00:00 2001 From: godyZ Date: Fri, 16 Aug 2013 16:10:39 +0800 Subject: [PATCH 030/126] updata: [cocos2d's code style] add space before backslash and return before else if --- cocos2dx/Android.mk | 14 +++++++------- cocos2dx/platform/CCImageCommon_cpp.h | 27 ++++++++++++++++++--------- cocos2dx/proj.linux/Makefile | 4 ++-- 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/cocos2dx/Android.mk b/cocos2dx/Android.mk index efb01bbda7..f6f4798c82 100644 --- a/cocos2dx/Android.mk +++ b/cocos2dx/Android.mk @@ -125,9 +125,9 @@ text_input_node/CCTextFieldTTF.cpp \ textures/CCTexture2D.cpp \ textures/CCTextureAtlas.cpp \ textures/CCTextureCache.cpp \ -platform/third_party/common/etc/etc1.cpp\ -platform/third_party/common/s3tc/s3tc.cpp\ -platform/third_party/common/atitc/atitc.cpp\ +platform/third_party/common/etc/etc1.cpp \ +platform/third_party/common/s3tc/s3tc.cpp \ +platform/third_party/common/atitc/atitc.cpp \ tilemap_parallax_nodes/CCParallaxNode.cpp \ tilemap_parallax_nodes/CCTMXLayer.cpp \ tilemap_parallax_nodes/CCTMXObjectGroup.cpp \ @@ -142,16 +142,16 @@ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) \ $(LOCAL_PATH)/include \ $(LOCAL_PATH)/kazmath/include \ $(LOCAL_PATH)/platform/android \ - $(LOCAL_PATH)/platform/third_party/common/etc\ - $(LOCAL_PATH)/platform/third_party/common/s3tc\ + $(LOCAL_PATH)/platform/third_party/common/etc \ + $(LOCAL_PATH)/platform/third_party/common/s3tc \ $(LOCAL_PATH)/platform/third_party/common/atitc LOCAL_C_INCLUDES := $(LOCAL_PATH) \ $(LOCAL_PATH)/include \ $(LOCAL_PATH)/kazmath/include \ $(LOCAL_PATH)/platform/android \ - $(LOCAL_PATH)/platform/third_party/common/etc\ - $(LOCAL_PATH)/platform/third_party/common/s3tc\ + $(LOCAL_PATH)/platform/third_party/common/etc \ + $(LOCAL_PATH)/platform/third_party/common/s3tc \ $(LOCAL_PATH)/platform/third_party/common/atitc diff --git a/cocos2dx/platform/CCImageCommon_cpp.h b/cocos2dx/platform/CCImageCommon_cpp.h index fb4a67abe7..cb4a79e349 100644 --- a/cocos2dx/platform/CCImageCommon_cpp.h +++ b/cocos2dx/platform/CCImageCommon_cpp.h @@ -468,10 +468,12 @@ bool Image::initWithImageData(const unsigned char * data, int dataLen) if (ZipUtils::ccIsCCZBuffer(data, dataLen)) { unpackedLen = ZipUtils::ccInflateCCZBuffer(data, dataLen, &unpackedData); - }else if (ZipUtils::ccIsGZipBuffer(data, dataLen)) + } + else if (ZipUtils::ccIsGZipBuffer(data, dataLen)) { unpackedLen = ZipUtils::ccInflateMemory(const_cast(data), dataLen, &unpackedData); - }else + } + else { unpackedData = const_cast(data); unpackedLen = dataLen; @@ -622,25 +624,32 @@ Image::Format Image::detectFormat(const unsigned char * data, int dataLen) if (isPng(data, dataLen)) { return Format::PNG; - }else if (isJpg(data, dataLen)) + } + else if (isJpg(data, dataLen)) { return Format::JPG; - }else if (isTiff(data, dataLen)) + } + else if (isTiff(data, dataLen)) { return Format::TIFF; - }else if (isWebp(data, dataLen)) + } + else if (isWebp(data, dataLen)) { return Format::WEBP; - }else if (isPvr(data, dataLen)) + } + else if (isPvr(data, dataLen)) { return Format::PVR; - }else if (isEtc(data, dataLen)) + } + else if (isEtc(data, dataLen)) { return Format::ETC; - }else if (isS3TC(data, dataLen)) + } + else if (isS3TC(data, dataLen)) { return Format::S3TC; - }else if (isATITC(data, dataLen)) + } + else if (isATITC(data, dataLen)) { return Format::ATITC; } diff --git a/cocos2dx/proj.linux/Makefile b/cocos2dx/proj.linux/Makefile index 0ce2b90748..dc539d17ec 100644 --- a/cocos2dx/proj.linux/Makefile +++ b/cocos2dx/proj.linux/Makefile @@ -86,8 +86,8 @@ SOURCES = ../actions/CCAction.cpp \ ../platform/linux/CCImage.cpp \ ../platform/linux/CCDevice.cpp \ ../platform/third_party/common/etc/etc1.cpp \ -../platform/third_party/common/s3tc/s3tc.cpp\ -../platform/third_party/common/atitc/atitc.cpp\ +../platform/third_party/common/s3tc/s3tc.cpp \ +../platform/third_party/common/atitc/atitc.cpp \ ../script_support/CCScriptSupport.cpp \ ../sprite_nodes/CCAnimation.cpp \ ../sprite_nodes/CCAnimationCache.cpp \ From baa9e0a1e475f99e6b5746c6ff70f916e96c5a3a Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 16 Aug 2013 18:23:41 +0800 Subject: [PATCH 031/126] issue #2525:add iterator for Array and make Array can be used in range-based loop --- cocos2dx/cocoa/CCArray.cpp | 24 +++++++++++ cocos2dx/cocoa/CCArray.h | 40 ++++++++++++++++++- .../Classes/SchedulerTest/SchedulerTest.cpp | 8 ++-- .../SpriteTest/SpriteTest.cpp.REMOVED.git-id | 2 +- 4 files changed, 68 insertions(+), 6 deletions(-) diff --git a/cocos2dx/cocoa/CCArray.cpp b/cocos2dx/cocoa/CCArray.cpp index 056dacd2f3..f4c80d4356 100644 --- a/cocos2dx/cocoa/CCArray.cpp +++ b/cocos2dx/cocoa/CCArray.cpp @@ -406,4 +406,28 @@ void Array::acceptVisitor(DataVisitor &visitor) visitor.visit(this); } +Array::iterator Array::begin() +{ + if (data->num > 0) + { + return Array::ArrayIterator(data->arr[0], this); + } + else + { + return Array::ArrayIterator(nullptr, nullptr);; + } +} + +Array::iterator Array::end() +{ + if (data->num > 0) + { + return Array::ArrayIterator(data->arr[data->num], this); + } + else + { + return Array::ArrayIterator(nullptr, nullptr); + } +} + NS_CC_END diff --git a/cocos2dx/cocoa/CCArray.h b/cocos2dx/cocoa/CCArray.h index 28e34ccb07..e5ed9ad265 100644 --- a/cocos2dx/cocoa/CCArray.h +++ b/cocos2dx/cocoa/CCArray.h @@ -25,6 +25,7 @@ THE SOFTWARE. #ifndef __CCARRAY_H__ #define __CCARRAY_H__ +// #include "support/data_support/ccCArray.h" #include "support/data_support/ccCArray.h" /** @@ -112,7 +113,36 @@ NS_CC_BEGIN class CC_DLL Array : public Object, public Clonable { public: - ~Array(); + class ArrayIterator : public std::iterator + { + public: + ArrayIterator(Object *object, Array *array) : _ptr(object), _parent(array) {} + ArrayIterator(const ArrayIterator& arrayIterator) : _ptr(arrayIterator._ptr), _parent(arrayIterator._parent) {} + + ArrayIterator& operator++() + { + int index = ccArrayGetIndexOfObject(_parent->data, _ptr); + _ptr = _parent->data->arr[index+1]; + return *this; + } + ArrayIterator operator++(int) + { + ArrayIterator tmp(*this); + (*this)++; + return tmp; + } + bool operator==(const ArrayIterator& rhs) { return _ptr == rhs._ptr; } + bool operator!=(const ArrayIterator& rhs) { return _ptr != rhs._ptr; } + Object* operator*() { return _ptr; } + Object* operator->() { return _ptr; } + + private: + Object *_ptr; + Array *_parent; + }; + + typedef ArrayIterator iterator; + typedef ArrayIterator const_iterator; /** Create an array */ static Array* create(); @@ -136,6 +166,8 @@ public: invoker should call release(). */ static Array* createWithContentsOfFileThreadSafe(const char* pFileName); + + ~Array(); /** Initializes an array */ bool init(); @@ -211,8 +243,14 @@ public: virtual void acceptVisitor(DataVisitor &visitor); virtual Array* clone() const; + // functions for range-based loop + iterator begin(); + iterator end(); + public: + //ccArray* data; ccArray* data; + Array(); Array(unsigned int capacity); }; diff --git a/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.cpp b/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.cpp index 510f3b07b9..40c9034114 100644 --- a/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.cpp +++ b/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.cpp @@ -696,11 +696,11 @@ void SchedulerUpdate::removeUpdates(float dt) { Array* children = getChildren(); Node* node; - Object* pObject; - CCARRAY_FOREACH(children, pObject) - { - node = static_cast(pObject); + for (auto c : *children) + { + node = static_cast(c); + if (! node) { break; diff --git a/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id b/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id index e04e178c10..3e30ebaeca 100644 --- a/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id +++ b/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id @@ -1 +1 @@ -8853550dc382b38c368250fb940660f35ee5ad4d \ No newline at end of file +0b98a5e32d9f144fd4ade9949fa29c9e9fdc1e22 \ No newline at end of file From aff86b1b5246df1c0decafecb41733ec799c02d6 Mon Sep 17 00:00:00 2001 From: folecr Date: Fri, 16 Aug 2013 10:50:53 -0700 Subject: [PATCH 032/126] Keep TravisCI happy : build Android TestCpp for ARM architecture only. --- samples/Cpp/TestCpp/proj.android/jni/Application.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/Cpp/TestCpp/proj.android/jni/Application.mk b/samples/Cpp/TestCpp/proj.android/jni/Application.mk index acd94ddb68..5c3833f465 100644 --- a/samples/Cpp/TestCpp/proj.android/jni/Application.mk +++ b/samples/Cpp/TestCpp/proj.android/jni/Application.mk @@ -1,4 +1,4 @@ APP_STL := gnustl_static APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -DCOCOS2D_DEBUG=1 -std=c++11 APP_OPTIM := debug -APP_ABI := armeabi x86 +APP_ABI := armeabi From a188d8714256f2ac6f60ee2094c1e6eff7a6174a Mon Sep 17 00:00:00 2001 From: shinriyo Date: Sun, 18 Aug 2013 10:13:50 +0900 Subject: [PATCH 033/126] language option is invalid print mesage If we input invalid mistook language option --- tools/project_creator/create_project.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/project_creator/create_project.py b/tools/project_creator/create_project.py index 3a05aa20d0..728a068ecd 100755 --- a/tools/project_creator/create_project.py +++ b/tools/project_creator/create_project.py @@ -71,6 +71,10 @@ def checkParams(): context["src_project_name"] = "HelloJavascript" context["src_package_name"] = "org.cocos2dx.hellojavascript" context["src_project_path"] = os.path.join(template_dir, "multi-platform-js") + else: + print "Your language parameter doesn\'t exist." \ + "Check correct language option\'s parameter" + sys.exit() platforms_list = PLATFORMS.get(context["language"], []) return context, platforms_list # end of checkParams(context) function From 9d8e2d991b73d8f996829aa4a5cdecbfe4c989b7 Mon Sep 17 00:00:00 2001 From: folecr Date: Mon, 19 Aug 2013 15:57:25 -0700 Subject: [PATCH 034/126] Let CCDirector set all GL state --- cocos2dx/platform/android/nativeactivity.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/cocos2dx/platform/android/nativeactivity.cpp b/cocos2dx/platform/android/nativeactivity.cpp index de53135e3d..44f063c798 100644 --- a/cocos2dx/platform/android/nativeactivity.cpp +++ b/cocos2dx/platform/android/nativeactivity.cpp @@ -171,12 +171,6 @@ static cocos_dimensions engine_init_display(struct engine* engine) { engine->height = h; engine->state.angle = 0; - // Initialize GL state. - glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); - glEnable(GL_CULL_FACE); - glShadeModel(GL_SMOOTH); - glDisable(GL_DEPTH_TEST); - r.w = w; r.h = h; From 511ec1cc5d3bf01ffacf80161486d0f7bb02fd5a Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Mon, 19 Aug 2013 17:09:28 -0700 Subject: [PATCH 035/126] Compiles with improved CCArray Compiles both with std::vector or ccCArray --- cocos2dx/base_nodes/CCNode.cpp | 27 +- cocos2dx/cocoa/CCArray.cpp | 439 ++++++++++++++++-- cocos2dx/cocoa/CCArray.h | 276 +++++++++-- cocos2dx/sprite_nodes/CCSprite.cpp | 17 +- cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp | 51 +- cocos2dx/tilemap_parallax_nodes/CCTMXLayer.h | 1 + .../touch_dispatcher/CCTouchDispatcher.cpp | 19 +- extensions/CCArmature/CCArmature.cpp | 9 +- extensions/GUI/CCScrollView/CCScrollView.cpp | 9 +- extensions/GUI/CCScrollView/CCSorting.cpp | 2 + .../GUI/CCScrollView/CCTableViewCell.cpp | 1 + .../Classes/SchedulerTest/SchedulerTest.cpp | 4 +- 12 files changed, 707 insertions(+), 148 deletions(-) diff --git a/cocos2dx/base_nodes/CCNode.cpp b/cocos2dx/base_nodes/CCNode.cpp index 2c5657e677..f77aceb603 100644 --- a/cocos2dx/base_nodes/CCNode.cpp +++ b/cocos2dx/base_nodes/CCNode.cpp @@ -697,7 +697,7 @@ void Node::detachChild(Node *child, bool doCleanup) void Node::insertChild(Node* child, int z) { _reorderChildDirty = true; - ccArrayAppendObjectWithResize(_children->data, child); + _children->addObject(child); child->_setZOrder(z); } @@ -713,27 +713,27 @@ void Node::sortAllChildren() { if (_reorderChildDirty) { - int i,j,length = _children->data->num; - Node ** x = (Node**)_children->data->arr; - Node *tempItem; + int i,j,length = _children->count(); // insertion sort for(i=1; i( _children->getObjectAtIndex(i) ); + Node *tempJ = static_cast( _children->getObjectAtIndex(j) ); //continue moving element downwards while zOrder is smaller or when zOrder is the same but mutatedIndex is smaller - while(j>=0 && ( tempItem->_ZOrder < x[j]->_ZOrder || ( tempItem->_ZOrder== x[j]->_ZOrder && tempItem->_orderOfArrival < x[j]->_orderOfArrival ) ) ) + while(j>=0 && ( tempI->_ZOrder < tempJ->_ZOrder || + ( tempI->_ZOrder== tempJ->_ZOrder && + tempI->_orderOfArrival < tempJ->_orderOfArrival ) ) ) { - x[j+1] = x[j]; + _children->fastSetObject( tempJ, j+1 ); j = j-1; } - x[j+1] = tempItem; + _children->fastSetObject(tempI, j+1); } //don't need to check children recursively, that's done in visit of each child - _reorderChildDirty = false; } } @@ -770,10 +770,9 @@ void Node::visit() { sortAllChildren(); // draw children zOrder < 0 - ccArray *arrayData = _children->data; - for( ; i < arrayData->num; i++ ) + for( ; i < _children->count(); i++ ) { - pNode = (Node*) arrayData->arr[i]; + pNode = static_cast( _children->getObjectAtIndex(i) ); if ( pNode && pNode->_ZOrder < 0 ) { @@ -787,9 +786,9 @@ void Node::visit() // self draw this->draw(); - for( ; i < arrayData->num; i++ ) + for( ; i < _children->count(); i++ ) { - pNode = (Node*) arrayData->arr[i]; + pNode = static_cast( _children->getObjectAtIndex(i) ); if (pNode) { pNode->visit(); diff --git a/cocos2dx/cocoa/CCArray.cpp b/cocos2dx/cocoa/CCArray.cpp index f4c80d4356..5ae6b8fdbe 100644 --- a/cocos2dx/cocoa/CCArray.cpp +++ b/cocos2dx/cocoa/CCArray.cpp @@ -30,6 +30,12 @@ THE SOFTWARE. NS_CC_BEGIN +#if CC_USE_ARRAY_VECTOR + +// ---------------------------------------------------------------------------------- +// std::vector implementation +// ---------------------------------------------------------------------------------- + Array::Array() : data(NULL) { @@ -143,7 +149,6 @@ bool Array::init() bool Array::initWithObject(Object* pObject) { - ccArrayFree(data); bool bRet = initWithCapacity(1); if (bRet) { @@ -155,7 +160,6 @@ bool Array::initWithObject(Object* pObject) /** Initializes an array with some objects */ bool Array::initWithObjects(Object* pObject, ...) { - ccArrayFree(data); bool bRet = false; do { @@ -182,6 +186,373 @@ bool Array::initWithObjects(Object* pObject, ...) return bRet; } +bool Array::initWithCapacity(unsigned int capacity) +{ + data.reserve(capacity); + return true; +} + +bool Array::initWithArray(Array* otherArray) +{ + data = otherArray->data; + return true; +} + +int Array::getIndexOfObject(Object* object) const +{ +// auto it = std::find(data.begin(), data.end(), object ); +// if( it == data.end() ) +// return -1; +// return it - std::begin(data); + auto it = data.begin(); + + for (int i = 0; it != data.end(); ++it, ++i) + { + if (it->get() == object) + { + return i; + } + } + + return -1; +} + +Object* Array::getRandomObject() +{ + if (data.size()==0) + { + return nullptr; + } + + float r = CCRANDOM_0_1(); + + if (r == 1) // to prevent from accessing data-arr[data->num], out of range. + { + r = 0; + } + + r *= data.size(); + + return data[r].get(); +} + +bool Array::containsObject(Object* object) const +{ + int i = this->getIndexOfObject(object); + return (i >=0 ); +} + +bool Array::isEqualToArray(Array* otherArray) +{ + for (unsigned int i = 0; i< this->count(); i++) + { + if (!this->getObjectAtIndex(i)->isEqual(otherArray->getObjectAtIndex(i))) + { + return false; + } + } + return true; +} + +void Array::addObject(Object* object) +{ + data.push_back( RCPtr(object) ); +} + +void Array::addObjectsFromArray(Array* otherArray) +{ + data.insert(data.end(), otherArray->data.begin(), otherArray->data.end()); +} + +void Array::insertObject(Object* object, int index) +{ + data.insert( std::begin(data) + index, RCPtr(object) ); +} + +void Array::setObject(Object* object, int index) +{ + data[index] = RCPtr(object); +} + +void Array::removeLastObject(bool bReleaseObj) +{ + CCASSERT(data.size(), "no objects added"); + data.pop_back(); +} + +void Array::removeObject(Object* object, bool bReleaseObj /* ignored */) +{ +// auto begin = data.begin(); +// auto end = data.end(); +// +// auto it = std::find( begin, end, object); +// if( it != end ) { +// data.erase(it); +// } + + auto it = data.begin(); + for (; it != data.end(); ++it) + { + if (it->get() == object) + { + data.erase(it); + break; + } + } +} + +void Array::removeObjectAtIndex(unsigned int index, bool bReleaseObj /* ignored */) +{ + auto obj = data[index]; + data.erase( data.begin() + index ); +} + +void Array::removeObjectsInArray(Array* otherArray) +{ + CCASSERT(false, "not implemented"); +} + +void Array::removeAllObjects() +{ + data.erase(std::begin(data), std::end(data)); +} + +void Array::fastRemoveObjectAtIndex(unsigned int index) +{ + removeObjectAtIndex(index); +} + +void Array::fastRemoveObject(Object* object) +{ + removeObject(object); +} + +void Array::exchangeObject(Object* object1, Object* object2) +{ + int idx1 = getIndexOfObject(object1); + int idx2 = getIndexOfObject(object2); + + CCASSERT(idx1>=0 && idx2>=2, "invalid object index"); + + std::swap( data[idx1], data[idx2] ); +} + +void Array::exchangeObjectAtIndex(unsigned int index1, unsigned int index2) +{ + std::swap( data[index1], data[index2] ); +} + +void Array::replaceObjectAtIndex(unsigned int index, Object* pObject, bool bReleaseObject /* ignored */) +{ +// auto obj = data[index]; + data[index] = pObject; +} + +void Array::reverseObjects() +{ + std::reverse( std::begin(data), std::end(data) ); +} + +void Array::reduceMemoryFootprint() +{ + // N/A +} + +Array::~Array() +{ +} + +Array* Array::clone() const +{ + Array* ret = new Array(); + ret->autorelease(); + ret->initWithCapacity(this->data.size() > 0 ? this->data.size() : 1); + + Object* obj = NULL; + Object* tmpObj = NULL; + Clonable* clonable = NULL; + CCARRAY_FOREACH(this, obj) + { + clonable = dynamic_cast(obj); + if (clonable) + { + tmpObj = dynamic_cast(clonable->clone()); + if (tmpObj) + { + ret->addObject(tmpObj); + } + } + else + { + CCLOGWARN("%s isn't clonable.", typeid(*obj).name()); + } + } + return ret; +} + +void Array::acceptVisitor(DataVisitor &visitor) +{ + visitor.visit(this); +} + +// ---------------------------------------------------------------------------------- +// ccArray implementation +// ---------------------------------------------------------------------------------- + +#else + +Array::Array() +: data(NULL) +{ + init(); +} + +Array::Array(unsigned int capacity) +: data(NULL) +{ + initWithCapacity(capacity); +} + +Array* Array::create() +{ + Array* pArray = new Array(); + + if (pArray && pArray->init()) + { + pArray->autorelease(); + } + else + { + CC_SAFE_DELETE(pArray); + } + + return pArray; +} + +Array* Array::createWithObject(Object* pObject) +{ + Array* pArray = new Array(); + + if (pArray && pArray->initWithObject(pObject)) + { + pArray->autorelease(); + } + else + { + CC_SAFE_DELETE(pArray); + } + + return pArray; +} + +Array* Array::create(Object* pObject, ...) +{ + va_list args; + va_start(args,pObject); + + Array* pArray = create(); + if (pArray && pObject) + { + pArray->addObject(pObject); + Object *i = va_arg(args, Object*); + while(i) + { + pArray->addObject(i); + i = va_arg(args, Object*); + } + } + else + { + CC_SAFE_DELETE(pArray); + } + + va_end(args); + + return pArray; +} + +Array* Array::createWithArray(Array* otherArray) +{ + return otherArray->clone(); +} + +Array* Array::createWithCapacity(unsigned int capacity) +{ + Array* pArray = new Array(); + + if (pArray && pArray->initWithCapacity(capacity)) + { + pArray->autorelease(); + } + else + { + CC_SAFE_DELETE(pArray); + } + + return pArray; +} + +Array* Array::createWithContentsOfFile(const char* pFileName) +{ + Array* pRet = Array::createWithContentsOfFileThreadSafe(pFileName); + if (pRet != NULL) + { + pRet->autorelease(); + } + return pRet; +} + +Array* Array::createWithContentsOfFileThreadSafe(const char* pFileName) +{ + return FileUtils::getInstance()->createArrayWithContentsOfFile(pFileName); +} + +bool Array::init() +{ + return initWithCapacity(1); +} + +bool Array::initWithObject(Object* pObject) +{ + ccArrayFree(data); + bool bRet = initWithCapacity(1); + if (bRet) + { + addObject(pObject); + } + return bRet; +} + +/** Initializes an array with some objects */ +bool Array::initWithObjects(Object* pObject, ...) +{ + ccArrayFree(data); + bool bRet = false; + do + { + CC_BREAK_IF(pObject == NULL); + + va_list args; + va_start(args, pObject); + + if (pObject) + { + this->addObject(pObject); + Object* i = va_arg(args, Object*); + while(i) + { + this->addObject(i); + i = va_arg(args, Object*); + } + bRet = true; + } + va_end(args); + + } while (false); + + return bRet; +} + bool Array::initWithCapacity(unsigned int capacity) { ccArrayFree(data); @@ -193,48 +564,23 @@ bool Array::initWithArray(Array* otherArray) { ccArrayFree(data); bool bRet = false; - do + do { CC_BREAK_IF(! initWithCapacity(otherArray->data->num)); addObjectsFromArray(otherArray); bRet = true; } while (0); - + return bRet; } -unsigned int Array::count() const -{ - return data->num; -} - -unsigned int Array::capacity() const -{ - return data->max; -} - -unsigned int Array::indexOfObject(Object* object) const +int Array::getIndexOfObject(Object* object) const { return ccArrayGetIndexOfObject(data, object); } -Object* Array::objectAtIndex(unsigned int index) -{ - CCASSERT(index < data->num, "index out of range in objectAtIndex()"); - - return data->arr[index]; -} - -Object* Array::lastObject() -{ - if( data->num > 0 ) - return data->arr[data->num-1]; - - return NULL; -} - -Object* Array::randomObject() +Object* Array::getRandomObject() { if (data->num==0) { @@ -242,12 +588,12 @@ Object* Array::randomObject() } float r = CCRANDOM_0_1(); - + if (r == 1) // to prevent from accessing data-arr[data->num], out of range. { r = 0; } - + return data->arr[(int)(data->num * r)]; } @@ -260,7 +606,7 @@ bool Array::isEqualToArray(Array* otherArray) { for (unsigned int i = 0; i< this->count(); i++) { - if (!this->objectAtIndex(i)->isEqual(otherArray->objectAtIndex(i))) + if (!this->getObjectAtIndex(i)->isEqual(otherArray->getObjectAtIndex(i))) { return false; } @@ -278,11 +624,22 @@ void Array::addObjectsFromArray(Array* otherArray) ccArrayAppendArrayWithResize(data, otherArray->data); } -void Array::insertObject(Object* object, unsigned int index) +void Array::insertObject(Object* object, int index) { ccArrayInsertObjectAtIndex(data, object, index); } +void Array::setObject(Object* object, int index) +{ + CCASSERT(index>=0 && index < count(), "Invalid index"); + + if( object != data->arr[index] ) { + data->arr[index]->release(); + data->arr[index] = object; + object->retain(); + } +} + void Array::removeLastObject(bool bReleaseObj) { CCASSERT(data->num, "no objects added"); @@ -352,7 +709,7 @@ void Array::reverseObjects() if (data->num > 1) { // floorf(), since in the case of an even number, the number of swaps stays the same - int count = (int) floorf(data->num/2.f); + int count = (int) floorf(data->num/2.f); unsigned int maxIndex = data->num - 1; for (int i = 0; i < count ; i++) @@ -408,9 +765,9 @@ void Array::acceptVisitor(DataVisitor &visitor) Array::iterator Array::begin() { - if (data->num > 0) + if (count() > 0) { - return Array::ArrayIterator(data->arr[0], this); + return Array::ArrayIterator( getObjectAtIndex(0), this); } else { @@ -420,9 +777,9 @@ Array::iterator Array::begin() Array::iterator Array::end() { - if (data->num > 0) + if (count() > 0) { - return Array::ArrayIterator(data->arr[data->num], this); + return Array::ArrayIterator(getObjectAtIndex(count()), this); } else { @@ -430,4 +787,6 @@ Array::iterator Array::end() } } +#endif // uses ccArray + NS_CC_END diff --git a/cocos2dx/cocoa/CCArray.h b/cocos2dx/cocoa/CCArray.h index e5ed9ad265..82de141bf7 100644 --- a/cocos2dx/cocoa/CCArray.h +++ b/cocos2dx/cocoa/CCArray.h @@ -25,8 +25,103 @@ THE SOFTWARE. #ifndef __CCARRAY_H__ #define __CCARRAY_H__ -// #include "support/data_support/ccCArray.h" +#define CC_USE_ARRAY_VECTOR 0 + +#if CC_USE_ARRAY_VECTOR +#include +#include +#include "cocoa/CCObject.h" +#include "ccMacros.h" +#else #include "support/data_support/ccCArray.h" +#endif + + +#if CC_USE_ARRAY_VECTOR +/** + * A reference counting-managed pointer for classes derived from RCBase which can + * be used as C pointer + * Original code: http://www.codeproject.com/Articles/64111/Building-a-Quick-and-Handy-Reference-Counting-Clas + * License: http://www.codeproject.com/info/cpol10.aspx + */ +template < class T > +class RCPtr +{ +public: + //Construct using a C pointer + //e.g. RCPtr< T > x = new T(); + RCPtr(T* ptr = NULL) + : _ptr(ptr) + { + if(ptr != NULL) {ptr->retain();} + } + + //Copy constructor + RCPtr(const RCPtr &ptr) + : _ptr(ptr._ptr) + { +// printf("Array: copy constructor: %p\n", this); + if(_ptr != NULL) {_ptr->retain();} + } + + //Move constructor + RCPtr(RCPtr &&ptr) + : _ptr(ptr._ptr) + { +// printf("Array: Move Constructor: %p\n", this); + ptr._ptr = NULL; + } + + ~RCPtr() + { +// printf("Array: Destructor: %p\n", this); + if(_ptr != NULL) {_ptr->release();} + } + + //Assign a pointer + //e.g. x = new T(); + RCPtr &operator=(T* ptr) + { +// printf("Array: operator= T*: %p\n", this); + + //The following grab and release operations have to be performed + //in that order to handle the case where ptr == _ptr + //(See comment below by David Garlisch) + if(ptr != NULL) {ptr->retain();} + if(_ptr != NULL) {_ptr->release();} + _ptr = ptr; + return (*this); + } + + //Assign another RCPtr + RCPtr &operator=(const RCPtr &ptr) + { +// printf("Array: operator= const&: %p\n", this); + return (*this) = ptr._ptr; + } + + //Retrieve actual pointer + T* get() const + { + return _ptr; + } + + //Some overloaded operators to facilitate dealing with an RCPtr + //as a conventional C pointer. + //Without these operators, one can still use the less transparent + //get() method to access the pointer. + T* operator->() const {return _ptr;} //x->member + T &operator*() const {return *_ptr;} //*x, (*x).member + explicit operator T*() const {return _ptr;} //T* y = x; + explicit operator bool() const {return _ptr != NULL;} //if(x) {/*x is not NULL*/} + bool operator==(const RCPtr &ptr) {return _ptr == ptr._ptr;} + bool operator==(const T *ptr) {return _ptr == ptr;} + +private: + T *_ptr; //Actual pointer +}; +#endif // CC_USE_ARRAY_VECTOR + /** * @addtogroup data_structures @@ -49,6 +144,26 @@ __arr__++) I found that it's not work in C++. So it keep what it's look like in version 1.0.0-rc3. ---By Bin */ + +#if CC_USE_ARRAY_VECTOR +#define CCARRAY_FOREACH(__array__, __object__) \ + if (__array__) \ + for( auto __it__ = (__array__)->data.begin(); \ + __it__ != (__array__)->data.end() && ((__object__) = __it__->get()) != nullptr; \ + ++__it__) + + +#define CCARRAY_FOREACH_REVERSE(__array__, __object__) \ + if (__array__) \ + for( auto __it__ = (__array__)->data.rbegin(); \ + __it__ != (__array__)->data.rend() && ((__object__) = __it__->get()) != nullptr; \ + ++__it__ ) + + +#define CCARRAY_VERIFY_TYPE(__array__, __type__) void(0) + +#else // ! CC_USE_ARRAY_VECTOR -------------------------- + #define CCARRAY_FOREACH(__array__, __object__) \ if ((__array__) && (__array__)->data->num > 0) \ for(Object** __arr__ = (__array__)->data->arr, **__end__ = (__array__)->data->arr + (__array__)->data->num-1; \ @@ -73,6 +188,11 @@ I found that it's not work in C++. So it keep what it's look like in version 1.0 #define CCARRAY_VERIFY_TYPE(__array__, __type__) void(0) #endif +#endif // ! CC_USE_ARRAY_VECTOR + + +// Common defines ----------------------------------------------------------------------------------------------- + #define arrayMakeObjectsPerformSelector(pArray, func, elementType) \ do { \ if(pArray && pArray->count() > 0) \ @@ -113,36 +233,6 @@ NS_CC_BEGIN class CC_DLL Array : public Object, public Clonable { public: - class ArrayIterator : public std::iterator - { - public: - ArrayIterator(Object *object, Array *array) : _ptr(object), _parent(array) {} - ArrayIterator(const ArrayIterator& arrayIterator) : _ptr(arrayIterator._ptr), _parent(arrayIterator._parent) {} - - ArrayIterator& operator++() - { - int index = ccArrayGetIndexOfObject(_parent->data, _ptr); - _ptr = _parent->data->arr[index+1]; - return *this; - } - ArrayIterator operator++(int) - { - ArrayIterator tmp(*this); - (*this)++; - return tmp; - } - bool operator==(const ArrayIterator& rhs) { return _ptr == rhs._ptr; } - bool operator!=(const ArrayIterator& rhs) { return _ptr != rhs._ptr; } - Object* operator*() { return _ptr; } - Object* operator->() { return _ptr; } - - private: - Object *_ptr; - Array *_parent; - }; - - typedef ArrayIterator iterator; - typedef ArrayIterator const_iterator; /** Create an array */ static Array* create(); @@ -183,17 +273,49 @@ public: // Querying an Array /** Returns element count of the array */ - unsigned int count() const; + unsigned int count() const { +#if CC_USE_ARRAY_VECTOR + return data.size(); +#else + return data->num; +#endif + } /** Returns capacity of the array */ - unsigned int capacity() const; + unsigned int capacity() const { +#if CC_USE_ARRAY_VECTOR + return data.capacity(); +#else + return data->max; +#endif + } /** Returns index of a certain object, return UINT_MAX if doesn't contain the object */ - unsigned int indexOfObject(Object* object) const; + int getIndexOfObject(Object* object) const; + CC_DEPRECATED_ATTRIBUTE int indexOfObject(Object* object) const { return getIndexOfObject(object); } + /** Returns an element with a certain index */ - Object* objectAtIndex(unsigned int index); - /** Returns last element */ - Object* lastObject(); + Object* getObjectAtIndex(int index) { + CCASSERT(index>=0 && index < count(), "index out of range in objectAtIndex()"); +#if CC_USE_ARRAY_VECTOR + return data[index].get(); +#else + return data->arr[index]; +#endif + } + CC_DEPRECATED_ATTRIBUTE Object* objectAtIndex(int index) { return getObjectAtIndex(index); } + /** Returns the last element of the array */ + Object* getLastObject() { +#if CC_USE_ARRAY_VECTOR + return data.back().get(); +#else + if( data->num > 0 ) + return data->arr[data->num-1]; + return nullptr; +#endif + } + CC_DEPRECATED_ATTRIBUTE Object* lastObject() { return getLastObject(); } /** Returns a random element */ - Object* randomObject(); + Object* getRandomObject(); + CC_DEPRECATED_ATTRIBUTE Object* randomObject() { return getRandomObject(); } /** Returns a Boolean value that indicates whether object is present in array. */ bool containsObject(Object* object) const; /** @since 1.1 */ @@ -205,7 +327,27 @@ public: /** Add all elements of an existing array */ void addObjectsFromArray(Array* otherArray); /** Insert a certain object at a certain index */ - void insertObject(Object* object, unsigned int index); + void insertObject(Object* object, int index); + /** sets a certain object at a certain index */ + void setObject(Object* object, int index); + /** sets a certain object at a certain index without retaining. Use it with caution */ + void fastSetObject(Object* object, int index) { +#if CC_USE_ARRAY_VECTOR + setObject(object, index); +#else + // no retain + data->arr[index] = object; +#endif + } + + void swap( int indexOne, int indexTwo ) { + CCASSERT(indexOne >=0 && indexOne < count() && indexTwo >= 0 && indexTwo < count(), "Invalid indices"); +#if CC_USE_ARRAY_VECTOR + std::swap( data[indexOne], data[indexTwo] ); +#else + std::swap( data->arr[indexOne], data->arr[indexTwo] ); +#endif + } // Removing Objects @@ -242,15 +384,65 @@ public: /* override functions */ virtual void acceptVisitor(DataVisitor &visitor); virtual Array* clone() const; - + + // ------------------------------------------ + // Iterators + // ------------------------------------------ +#if CC_USE_ARRAY_VECTOR + typedef std::vector>::iterator iterator; + typedef std::vector>::const_iterator const_iterator; + + iterator begin() { return data.begin(); } + iterator end() { return data.end(); } + const_iterator cbegin() { return data.cbegin(); } + const_iterator cend() { return data.cend(); } + +#else + class ArrayIterator : public std::iterator + { + public: + ArrayIterator(Object *object, Array *array) : _ptr(object), _parent(array) {} + ArrayIterator(const ArrayIterator& arrayIterator) : _ptr(arrayIterator._ptr), _parent(arrayIterator._parent) {} + + ArrayIterator& operator++() + { + int index = _parent->getIndexOfObject(_ptr); + _ptr = _parent->getObjectAtIndex(index+1); + return *this; + } + ArrayIterator operator++(int) + { + ArrayIterator tmp(*this); + (*this)++; + return tmp; + } + bool operator==(const ArrayIterator& rhs) { return _ptr == rhs._ptr; } + bool operator!=(const ArrayIterator& rhs) { return _ptr != rhs._ptr; } + Object* operator*() { return _ptr; } + Object* operator->() { return _ptr; } + + private: + Object *_ptr; + Array *_parent; + }; + // functions for range-based loop + typedef ArrayIterator iterator; + typedef ArrayIterator const_iterator; iterator begin(); iterator end(); + +#endif + + public: - //ccArray* data; +#if CC_USE_ARRAY_VECTOR + std::vector> data; +#else ccArray* data; - +#endif + Array(); Array(unsigned int capacity); }; diff --git a/cocos2dx/sprite_nodes/CCSprite.cpp b/cocos2dx/sprite_nodes/CCSprite.cpp index c1ae8842a1..947e44a172 100644 --- a/cocos2dx/sprite_nodes/CCSprite.cpp +++ b/cocos2dx/sprite_nodes/CCSprite.cpp @@ -694,23 +694,24 @@ void Sprite::sortAllChildren() { if (_reorderChildDirty) { - int i = 0, j = 0, length = _children->data->num; - Node** x = (Node**)_children->data->arr; - Node *tempItem = NULL; + int i = 0, j = 0, length = _children->count(); // insertion sort for(i=1; i( _children->getObjectAtIndex(i) ); + Node *tempJ = static_cast( _children->getObjectAtIndex(j) ); - //continue moving element downwards while zOrder is smaller or when zOrder is the same but orderOfArrival is smaller - while(j>=0 && ( tempItem->getZOrder() < x[j]->getZOrder() || ( tempItem->getZOrder() == x[j]->getZOrder() && tempItem->getOrderOfArrival() < x[j]->getOrderOfArrival() ) ) ) + //continue moving element downwards while zOrder is smaller or when zOrder is the same but mutatedIndex is smaller + while(j>=0 && ( tempI->getZOrder() < tempJ->getZOrder() || + ( tempI->getZOrder() == tempJ->getZOrder() && + tempI->getOrderOfArrival() < tempJ->getOrderOfArrival() ) ) ) { - x[j+1] = x[j]; + _children->fastSetObject( tempJ, j+1 ); j = j-1; } - x[j+1] = tempItem; + _children->fastSetObject(tempI, j+1); } if ( _batchNode) diff --git a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp index 073d2718b3..3fc6aff74f 100644 --- a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp @@ -246,24 +246,24 @@ void SpriteBatchNode::sortAllChildren() { if (_reorderChildDirty) { - int i = 0,j = 0,length = _children->data->num; - Node ** x = (Node**)_children->data->arr; - Node *tempItem = NULL; + int i = 0,j = 0,length = _children->count(); - //insertion sort + // insertion sort for(i=1; i( _children->getObjectAtIndex(i) ); + Node *tempJ = static_cast( _children->getObjectAtIndex(j) ); - //continue moving element downwards while zOrder is smaller or when zOrder is the same but orderOfArrival is smaller - while(j>=0 && ( tempItem->getZOrder() < x[j]->getZOrder() || ( tempItem->getZOrder() == x[j]->getZOrder() && tempItem->getOrderOfArrival() < x[j]->getOrderOfArrival() ) ) ) + //continue moving element downwards while zOrder is smaller or when zOrder is the same but mutatedIndex is smaller + while(j>=0 && ( tempI->getZOrder() < tempJ->getZOrder() || + ( tempI->getZOrder() == tempJ->getZOrder() && + tempI->getOrderOfArrival() < tempJ->getOrderOfArrival() ) ) ) { - x[j+1] = x[j]; - j--; + _children->fastSetObject( tempJ, j+1 ); + j = j-1; } - - x[j+1] = tempItem; + _children->fastSetObject(tempI, j+1); } //sorted now check all children @@ -313,7 +313,7 @@ void SpriteBatchNode::updateAtlasIndex(Sprite* sprite, int* curIndex) { bool needNewIndex=true; - if (static_cast(array->data->arr[0])->getZOrder() >= 0) + if (static_cast(array->getObjectAtIndex(0) )->getZOrder() >= 0) { //all children are in front of the parent oldIndex = sprite->getAtlasIndex(); @@ -363,19 +363,13 @@ void SpriteBatchNode::updateAtlasIndex(Sprite* sprite, int* curIndex) void SpriteBatchNode::swap(int oldIndex, int newIndex) { - Object** x = _descendants->data->arr; V3F_C4B_T2F_Quad* quads = _textureAtlas->getQuads(); - Object* tempItem = x[oldIndex]; - V3F_C4B_T2F_Quad tempItemQuad=quads[oldIndex]; - //update the index of other swapped item - ((Sprite*) x[newIndex])->setAtlasIndex(oldIndex); + static_cast( _descendants->getObjectAtIndex(newIndex) )->setAtlasIndex(oldIndex); - x[oldIndex]=x[newIndex]; - quads[oldIndex]=quads[newIndex]; - x[newIndex]=tempItem; - quads[newIndex]=tempItemQuad; + std::swap( quads[oldIndex], quads[newIndex] ); + _descendants->swap( oldIndex, newIndex ); } void SpriteBatchNode::reorderBatch(bool reorder) @@ -568,16 +562,14 @@ void SpriteBatchNode::insertChild(Sprite *pSprite, unsigned int uIndex) V3F_C4B_T2F_Quad quad = pSprite->getQuad(); _textureAtlas->insertQuad(&quad, uIndex); - ccArray *descendantsData = _descendants->data; - - ccArrayInsertObjectAtIndex(descendantsData, pSprite, uIndex); + _descendants->insertObject(pSprite, uIndex); // update indices unsigned int i = uIndex+1; Sprite* child = nullptr; - for(; inum; i++){ - child = static_cast(descendantsData->arr[i]); + for(; i<_descendants->count(); i++){ + child = static_cast(_descendants->getObjectAtIndex(i)); child->setAtlasIndex(child->getAtlasIndex() + 1); } @@ -602,11 +594,8 @@ void SpriteBatchNode::appendChild(Sprite* sprite) increaseAtlasCapacity(); } - ccArray *descendantsData = _descendants->data; - - ccArrayAppendObjectWithResize(descendantsData, sprite); - - unsigned int index=descendantsData->num-1; + _descendants->addObject(sprite); + unsigned int index=_descendants->count()-1; sprite->setAtlasIndex(index); diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXLayer.h b/cocos2dx/tilemap_parallax_nodes/CCTMXLayer.h index e672fe4472..3724377da8 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXLayer.h +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXLayer.h @@ -30,6 +30,7 @@ THE SOFTWARE. #include "base_nodes/CCAtlasNode.h" #include "sprite_nodes/CCSpriteBatchNode.h" #include "CCTMXXMLParser.h" +#include "support/data_support/ccCArray.h" NS_CC_BEGIN class TMXMapInfo; diff --git a/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp b/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp index ba5584bc28..8d070abba4 100644 --- a/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp +++ b/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp @@ -38,10 +38,24 @@ NS_CC_BEGIN /** * Used for sort */ +#if 0 +static int less(const RCPtr& p1, const RCPtr& p2) +{ + Object *o1, *o2; + o1 = static_cast(p1); + o2 = static_cast(p2); + + TouchHandler *h1, *h2; + h1 = static_cast( o1 ); + h2 = static_cast( o2 ); + return ( h1->getPriority() < h2->getPriority() ); +} +#else static int less(const Object* p1, const Object* p2) { return ((TouchHandler*)p1)->getPriority() < ((TouchHandler*)p2)->getPriority(); } +#endif bool TouchDispatcher::isDispatchEvents(void) { @@ -290,9 +304,10 @@ TouchHandler* TouchDispatcher::findHandler(Array* pArray, TouchDelegate *pDelega return NULL; } -void TouchDispatcher::rearrangeHandlers(Array *pArray) +void TouchDispatcher::rearrangeHandlers(Array *array) { - std::sort(pArray->data->arr, pArray->data->arr + pArray->data->num, less); + std::sort(array->data->arr, array->data->arr + array->data->num, less); +// std::sort( std::begin(*array), std::end(*array), less); } void TouchDispatcher::setPriority(int nPriority, TouchDelegate *pDelegate) diff --git a/extensions/CCArmature/CCArmature.cpp b/extensions/CCArmature/CCArmature.cpp index 2efa6661ae..b29ab69a3b 100644 --- a/extensions/CCArmature/CCArmature.cpp +++ b/extensions/CCArmature/CCArmature.cpp @@ -559,14 +559,15 @@ Rect Armature::getBoundingBox() const Bone *Armature::getBoneAtPoint(float x, float y) { - int length = _children->data->num; - Bone **bs = (Bone **)_children->data->arr; + int length = _children->count(); + Bone *bs; for(int i = length - 1; i >= 0; i--) { - if(bs[i]->getDisplayManager()->containPoint(x, y)) + bs = static_cast( _children->getObjectAtIndex(i) ); + if(bs->getDisplayManager()->containPoint(x, y)) { - return bs[i]; + return bs; } } return NULL; diff --git a/extensions/GUI/CCScrollView/CCScrollView.cpp b/extensions/GUI/CCScrollView/CCScrollView.cpp index 0ee866e5d7..e468a41b01 100644 --- a/extensions/GUI/CCScrollView/CCScrollView.cpp +++ b/extensions/GUI/CCScrollView/CCScrollView.cpp @@ -553,13 +553,12 @@ void ScrollView::visit() if(_children) { - ccArray *arrayData = _children->data; unsigned int i=0; // draw children zOrder < 0 - for( ; i < arrayData->num; i++ ) + for( ; i < _children->count(); i++ ) { - Node *child = (Node*)arrayData->arr[i]; + Node *child = static_cast( _children->getObjectAtIndex(i) ); if ( child->getZOrder() < 0 ) { child->visit(); @@ -574,9 +573,9 @@ void ScrollView::visit() this->draw(); // draw children zOrder >= 0 - for( ; i < arrayData->num; i++ ) + for( ; i < _children->count(); i++ ) { - Node* child = (Node*)arrayData->arr[i]; + Node *child = static_cast( _children->getObjectAtIndex(i) ); child->visit(); } diff --git a/extensions/GUI/CCScrollView/CCSorting.cpp b/extensions/GUI/CCScrollView/CCSorting.cpp index 8b6b0eef62..7a82b768b4 100644 --- a/extensions/GUI/CCScrollView/CCSorting.cpp +++ b/extensions/GUI/CCScrollView/CCSorting.cpp @@ -24,6 +24,8 @@ ****************************************************************************/ #include "CCSorting.h" +#include "support/data_support/ccCArray.h" + NS_CC_EXT_BEGIN diff --git a/extensions/GUI/CCScrollView/CCTableViewCell.cpp b/extensions/GUI/CCScrollView/CCTableViewCell.cpp index ca3faa3b3e..3bab98917e 100644 --- a/extensions/GUI/CCScrollView/CCTableViewCell.cpp +++ b/extensions/GUI/CCScrollView/CCTableViewCell.cpp @@ -24,6 +24,7 @@ ****************************************************************************/ #include "CCTableViewCell.h" +#include "support/data_support/ccCArray.h" NS_CC_EXT_BEGIN diff --git a/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.cpp b/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.cpp index c49d7696dc..82982654a4 100644 --- a/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.cpp +++ b/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.cpp @@ -695,11 +695,11 @@ void SchedulerUpdate::onEnter() void SchedulerUpdate::removeUpdates(float dt) { auto children = getChildren(); - Node* node; for (auto c : *children) { - node = static_cast(c); + auto obj = static_cast(c); + auto node = static_cast(obj); if (! node) { From 6c02102b1768ea118be7cc3e5f5c6cf2a5d1a4ca Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Mon, 19 Aug 2013 17:27:31 -0700 Subject: [PATCH 036/126] Fixes crash when reordering --- cocos2dx/base_nodes/CCNode.cpp | 35 +++++++++------------ cocos2dx/sprite_nodes/CCSprite.cpp | 6 ++-- cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp | 6 ++-- 3 files changed, 22 insertions(+), 25 deletions(-) diff --git a/cocos2dx/base_nodes/CCNode.cpp b/cocos2dx/base_nodes/CCNode.cpp index f77aceb603..b1eb0ce076 100644 --- a/cocos2dx/base_nodes/CCNode.cpp +++ b/cocos2dx/base_nodes/CCNode.cpp @@ -697,7 +697,7 @@ void Node::detachChild(Node *child, bool doCleanup) void Node::insertChild(Node* child, int z) { _reorderChildDirty = true; - _children->addObject(child); + ccArrayAppendObjectWithResize(_children->data, child); child->_setZOrder(z); } @@ -719,21 +719,22 @@ void Node::sortAllChildren() for(i=1; i( _children->getObjectAtIndex(i) ); - Node *tempJ = static_cast( _children->getObjectAtIndex(j) ); + auto tempI = static_cast( _children->getObjectAtIndex(i) ); + auto tempJ = static_cast( _children->getObjectAtIndex(j) ); //continue moving element downwards while zOrder is smaller or when zOrder is the same but mutatedIndex is smaller - while(j>=0 && ( tempI->_ZOrder < tempJ->_ZOrder || - ( tempI->_ZOrder== tempJ->_ZOrder && - tempI->_orderOfArrival < tempJ->_orderOfArrival ) ) ) + while(j>=0 && ( tempI->_ZOrder < tempJ->_ZOrder || ( tempI->_ZOrder == tempJ->_ZOrder && tempI->_orderOfArrival < tempJ->_orderOfArrival ) ) ) { _children->fastSetObject( tempJ, j+1 ); j = j-1; + if(j>=0) + tempJ = static_cast( _children->getObjectAtIndex(j) ); } _children->fastSetObject(tempI, j+1); } //don't need to check children recursively, that's done in visit of each child + _reorderChildDirty = false; } } @@ -762,8 +763,6 @@ void Node::visit() } this->transform(); - - Node* pNode = NULL; unsigned int i = 0; if(_children && _children->count() > 0) @@ -772,28 +771,22 @@ void Node::visit() // draw children zOrder < 0 for( ; i < _children->count(); i++ ) { - pNode = static_cast( _children->getObjectAtIndex(i) ); + auto node = static_cast( _children->getObjectAtIndex(i) ); - if ( pNode && pNode->_ZOrder < 0 ) - { - pNode->visit(); - } + if ( node && node->_ZOrder < 0 ) + node->visit(); else - { break; - } } // self draw this->draw(); for( ; i < _children->count(); i++ ) { - pNode = static_cast( _children->getObjectAtIndex(i) ); - if (pNode) - { - pNode->visit(); - } - } + auto node = static_cast( _children->getObjectAtIndex(i) ); + if (node) + node->visit(); + } } else { diff --git a/cocos2dx/sprite_nodes/CCSprite.cpp b/cocos2dx/sprite_nodes/CCSprite.cpp index 947e44a172..be7447fc4b 100644 --- a/cocos2dx/sprite_nodes/CCSprite.cpp +++ b/cocos2dx/sprite_nodes/CCSprite.cpp @@ -700,8 +700,8 @@ void Sprite::sortAllChildren() for(i=1; i( _children->getObjectAtIndex(i) ); - Node *tempJ = static_cast( _children->getObjectAtIndex(j) ); + auto tempI = static_cast( _children->getObjectAtIndex(i) ); + auto tempJ = static_cast( _children->getObjectAtIndex(j) ); //continue moving element downwards while zOrder is smaller or when zOrder is the same but mutatedIndex is smaller while(j>=0 && ( tempI->getZOrder() < tempJ->getZOrder() || @@ -710,6 +710,8 @@ void Sprite::sortAllChildren() { _children->fastSetObject( tempJ, j+1 ); j = j-1; + if(j>=0) + tempJ = static_cast( _children->getObjectAtIndex(j) ); } _children->fastSetObject(tempI, j+1); } diff --git a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp index 3fc6aff74f..a79feb2402 100644 --- a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp @@ -252,8 +252,8 @@ void SpriteBatchNode::sortAllChildren() for(i=1; i( _children->getObjectAtIndex(i) ); - Node *tempJ = static_cast( _children->getObjectAtIndex(j) ); + auto tempI = static_cast( _children->getObjectAtIndex(i) ); + auto tempJ = static_cast( _children->getObjectAtIndex(j) ); //continue moving element downwards while zOrder is smaller or when zOrder is the same but mutatedIndex is smaller while(j>=0 && ( tempI->getZOrder() < tempJ->getZOrder() || @@ -262,6 +262,8 @@ void SpriteBatchNode::sortAllChildren() { _children->fastSetObject( tempJ, j+1 ); j = j-1; + if(j>=0) + tempJ = static_cast( _children->getObjectAtIndex(j) ); } _children->fastSetObject(tempI, j+1); } From 6c2c5f727f5dd610bb38d1dbbed27e8d96fc7076 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Mon, 19 Aug 2013 17:33:23 -0700 Subject: [PATCH 037/126] small fix to make it compile with std::vector too --- cocos2dx/base_nodes/CCNode.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2dx/base_nodes/CCNode.cpp b/cocos2dx/base_nodes/CCNode.cpp index b1eb0ce076..5a13af9c15 100644 --- a/cocos2dx/base_nodes/CCNode.cpp +++ b/cocos2dx/base_nodes/CCNode.cpp @@ -697,7 +697,7 @@ void Node::detachChild(Node *child, bool doCleanup) void Node::insertChild(Node* child, int z) { _reorderChildDirty = true; - ccArrayAppendObjectWithResize(_children->data, child); + _children->addObject(child); child->_setZOrder(z); } From 0d5042948cc43e5424ae8a2428f73594b5cec935 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 20 Aug 2013 10:04:46 +0800 Subject: [PATCH 038/126] Update AUTHORS --- AUTHORS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/AUTHORS b/AUTHORS index 097e73ddf5..74ffea3d2c 100644 --- a/AUTHORS +++ b/AUTHORS @@ -566,6 +566,9 @@ Developers: maciekczwa Fixing a bug that stroke color with channel color values other than 255 doesn't take effect on android. + + zcgit + a potential bug fix in Layer::init. Retired Core Developers: WenSheng Yang From 7a9f1d6804c15e7eeb2d2a6f48b330ed6db09e1d Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Tue, 20 Aug 2013 13:44:37 +0800 Subject: [PATCH 039/126] issue #2433:Modify TestLua samples and some .ini files --- .../AccelerometerTest/AccelerometerTest.lua | 24 +- .../luaScript/ExtensionTest/ExtensionTest.lua | 530 +++++------ .../luaScript/LayerTest/LayerTest.lua | 2 + .../Resources/luaScript/MenuTest/MenuTest.lua | 384 ++++---- .../MotionStreakTest/MotionStreakTest.lua | 62 +- .../Resources/luaScript/NodeTest/NodeTest.lua | 307 +++--- .../luaScript/OpenGLTest/OpenGLTest.lua | 207 ++--- .../luaScript/ParallaxTest/ParallaxTest.lua | 61 +- .../luaScript/ParticleTest/ParticleTest.lua | 483 +++++----- .../PerformanceTest/PerformanceSpriteTest.lua | 162 ++-- .../PerformanceTest/PerformanceTest.lua | 539 ++++++----- .../RenderTextureTest/RenderTextureTest.lua | 241 +++-- .../RotateWorldTest/RotateWorldTest.lua | 70 +- .../luaScript/SceneTest/SceneTest.lua | 101 +- .../luaScript/SpriteTest/SpriteTest.lua | 872 +++++++++--------- .../luaScript/Texture2dTest/Texture2dTest.lua | 765 +++++++-------- .../luaScript/TileMapTest/TileMapTest.lua | 423 ++++----- .../Resources/luaScript/TouchesTest/Ball.lua | 62 +- .../luaScript/TouchesTest/Paddle.lua | 12 +- .../luaScript/TouchesTest/TouchesTest.lua | 26 +- .../TransitionsTest/TransitionsTest.lua | 160 ++-- .../UserDefaultTest/UserDefaultTest.lua | 52 +- .../luaScript/ZwoptexTest/ZwoptexTest.lua | 32 +- .../TestLua/Resources/luaScript/extern.lua | 10 +- .../TestLua/Resources/luaScript/mainMenu.lua | 32 +- scripting/lua/cocos2dx_support/CCLuaStack.cpp | 2 + .../cocos2dx_support/LuaBasicConversions.cpp | 317 ++++--- .../cocos2dx_support/LuaBasicConversions.h | 8 + .../LuaOpengl.cpp.REMOVED.git-id | 2 +- .../lua_cocos2dx_auto.cpp.REMOVED.git-id | 2 +- .../generated/lua_cocos2dx_auto.hpp | 70 ++ .../lua_cocos2dx_auto_api.js.REMOVED.git-id | 2 +- ...cocos2dx_extension_auto.cpp.REMOVED.git-id | 2 +- .../generated/lua_cocos2dx_extension_auto.hpp | 137 +++ .../lua_cocos2dx_extension_auto_api.js | 860 ++++++++++++++++- .../generated/lua_cocos2dx_manual.cpp | 745 ++++++++++++++- scripting/lua/script/Cocos2d.lua | 136 ++- scripting/lua/script/Cocos2dConstants.lua | 31 +- tools/tolua/cocos2dx.ini | 6 +- tools/tolua/cocos2dx_extension.ini | 8 +- 40 files changed, 4834 insertions(+), 3113 deletions(-) diff --git a/samples/Lua/TestLua/Resources/luaScript/AccelerometerTest/AccelerometerTest.lua b/samples/Lua/TestLua/Resources/luaScript/AccelerometerTest/AccelerometerTest.lua index 65c0313efd..dbdb62a470 100644 --- a/samples/Lua/TestLua/Resources/luaScript/AccelerometerTest/AccelerometerTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/AccelerometerTest/AccelerometerTest.lua @@ -3,37 +3,37 @@ local function AccelerometerMainLayer() local function title() return "AccelerometerTest" end - local pLayer = CCLayer:create() + local pLayer = cc.Layer:create() pLayer:setAccelerometerEnabled(true) - local pLabel = CCLabelTTF:create(title(), "Arial", 32) + local pLabel = cc.LabelTTF:create(title(), "Arial", 32) pLayer:addChild(pLabel, 1) - pLabel:setPosition( CCPoint(VisibleRect:center().x, VisibleRect:top().y - 50) ) + pLabel:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - 50) ) - local pBall = CCSprite:create("Images/ball.png") - pBall:setPosition(CCPoint(VisibleRect:center().x, VisibleRect:center().y)) + local pBall = cc.Sprite:create("Images/ball.png") + pBall:setPosition(cc.p(VisibleRect:center().x, VisibleRect:center().y)) pLayer:addChild(pBall) pBall:retain() local function didAccelerate(x,y,z,timestamp) - local pDir = CCDirector:getInstance() + local pDir = cc.Director:getInstance() if nil == pBall then return end local szBall = pBall:getContentSize() - - local ptNowX,ptNowY = pBall:getPosition() + local ptNow = pBall:getPosition() + local ptNowX,ptNowY = ptNow.x, ptNow.y - local ptTmp = pDir:convertToUI(CCPoint(ptNowX,ptNowY)) + local ptTmp = pDir:convertToUI(cc.p(ptNowX,ptNowY)) ptTmp.x = ptTmp.x + x * 9.81 ptTmp.y = ptTmp.y - y * 9.81 - local ptNext = pDir:convertToGL(CCPoint(ptTmp.x,ptTmp.y)) + local ptNext = pDir:convertToGL(cc.p(ptTmp.x,ptTmp.y)) local nMinX = math.floor(VisibleRect:left().x + szBall.width / 2.0) local nMaxX = math.floor(VisibleRect:right().x - szBall.width / 2.0) if ptNext.x < nMinX then @@ -50,7 +50,7 @@ local function AccelerometerMainLayer() ptNext.y = nMaxY end - pBall:setPosition(CCPoint(ptNext.x,ptNext.y)) + pBall:setPosition(cc.p(ptNext.x,ptNext.y)) end @@ -63,7 +63,7 @@ end function AccelerometerMain() cclog("AccelerometerMain") - local scene = CCScene:create() + local scene = cc.Scene:create() scene:addChild(AccelerometerMainLayer()) scene:addChild(CreateBackMenuItem()) return scene diff --git a/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/ExtensionTest.lua b/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/ExtensionTest.lua index 4d7d78b849..70f68e16dc 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/ExtensionTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/ExtensionTest.lua @@ -35,14 +35,14 @@ function CreateExtensionsBasicLayerMenu(pMenu) local function toMainLayer() local pScene = ExtensionsTestMain() if pScene ~= nil then - CCDirector:getInstance():replaceScene(pScene) + cc.Director:getInstance():replaceScene(pScene) end end --Create BackMneu - CCMenuItemFont:setFontName("Arial") - CCMenuItemFont:setFontSize(24) - local pMenuItemFont = CCMenuItemFont:create("Back") - pMenuItemFont:setPosition(CCPoint(VisibleRect:rightBottom().x - 50, VisibleRect:rightBottom().y + 25)) + cc.MenuItemFont:setFontName("Arial") + cc.MenuItemFont:setFontSize(24) + local pMenuItemFont = cc.MenuItemFont:create("Back") + pMenuItemFont:setPosition(cc.p(VisibleRect:rightBottom().x - 50, VisibleRect:rightBottom().y + 25)) pMenuItemFont:registerScriptTapHandler(toMainLayer) pMenu:addChild(pMenuItemFont) end @@ -59,40 +59,40 @@ local NotificationCenterParam = } local function runNotificationCenterTest() - local pNewScene = CCScene:create() - local pNewLayer = CCLayer:create() + local pNewScene = cc.Scene:create() + local pNewLayer = cc.Layer:create() local function BaseInitSceneLayer(pLayer) if nil == pLayer then return end - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() local function toggleSwitch(tag,menuItem) - local toggleItem = tolua.cast(menuItem,"CCMenuItemToggle") + local toggleItem = tolua.cast(menuItem,"MenuItemToggle") local nIndex = toggleItem:getSelectedIndex() local selectedItem = toggleItem:getSelectedItem() if 0 == nIndex then selectedItem = nil end - CCNotificationCenter:getInstance():postNotification(NotificationCenterParam.MSG_SWITCH_STATE,selectedItem) + cc.NotificationCenter:getInstance():postNotification(NotificationCenterParam.MSG_SWITCH_STATE,selectedItem) end - local switchlabel1 = CCLabelTTF:create("switch off", "Marker Felt", 26) - local switchlabel2 = CCLabelTTF:create("switch on", "Marker Felt", 26) - local switchitem1 = CCMenuItemLabel:create(switchlabel1) - local switchitem2 = CCMenuItemLabel:create(switchlabel2) - local switchitem = CCMenuItemToggle:create(switchitem1) + local switchlabel1 = cc.LabelTTF:create("switch off", "Marker Felt", 26) + local switchlabel2 = cc.LabelTTF:create("switch on", "Marker Felt", 26) + local switchitem1 = cc.MenuItemLabel:create(switchlabel1) + local switchitem2 = cc.MenuItemLabel:create(switchlabel2) + local switchitem = cc.MenuItemToggle:create(switchitem1) switchitem:addSubItem(switchitem2) switchitem:registerScriptTapHandler(toggleSwitch) --turn on switchitem:setSelectedIndex(1) - local menu = CCMenu:create() + local menu = cc.Menu:create() menu:addChild(switchitem) - menu:setPosition(CCPoint(s.width/2+100, s.height/2)) + menu:setPosition(cc.p(s.width/2+100, s.height/2)) pLayer:addChild(menu) - local menuConnect = CCMenu:create() - menuConnect:setPosition(CCPoint(0,0)) + local menuConnect = cc.Menu:create() + menuConnect:setPosition(cc.p(0,0)) pLayer:addChild(menuConnect) local i = 1 local bSwitchOn = false @@ -129,32 +129,32 @@ local function runNotificationCenterTest() local function setIsConnectToSwitch(pLight,bConnect,nIdx) bConnectArray[nIdx] = bConnect if bConnect then - CCNotificationCenter:getInstance():registerScriptObserver(pLight, switchStateChanged,NotificationCenterParam.MSG_SWITCH_STATE) + cc.NotificationCenter:getInstance():registerScriptObserver(pLight, switchStateChanged,NotificationCenterParam.MSG_SWITCH_STATE) else - CCNotificationCenter:getInstance():unregisterScriptObserver(pLight,NotificationCenterParam.MSG_SWITCH_STATE) + cc.NotificationCenter:getInstance():unregisterScriptObserver(pLight,NotificationCenterParam.MSG_SWITCH_STATE) end updateLightState() end for i = 1, 3 do - lightArray[i] = CCSprite:create("Images/Pea.png") + lightArray[i] = cc.Sprite:create("Images/Pea.png") lightArray[i]:setTag(NotificationCenterParam.kTagLight + i) - lightArray[i]:setPosition(CCPoint(100, s.height / 4 * i) ) + lightArray[i]:setPosition(cc.p(100, s.height / 4 * i) ) pLayer:addChild(lightArray[i]) - local connectlabel1 = CCLabelTTF:create("not connected", "Marker Felt", 26) + local connectlabel1 = cc.LabelTTF:create("not connected", "Marker Felt", 26) - local connectlabel2 = CCLabelTTF:create("connected", "Marker Felt", 26) - local connectitem1 = CCMenuItemLabel:create(connectlabel1) - local connectitem2 = CCMenuItemLabel:create(connectlabel2) - local connectitem = CCMenuItemToggle:create(connectitem1) + local connectlabel2 = cc.LabelTTF:create("connected", "Marker Felt", 26) + local connectitem1 = cc.MenuItemLabel:create(connectlabel1) + local connectitem2 = cc.MenuItemLabel:create(connectlabel2) + local connectitem = cc.MenuItemToggle:create(connectitem1) connectitem:addSubItem(connectitem2) connectitem:setTag(NotificationCenterParam.kTagConnect+i) local function connectToSwitch(tag,menuItem) - local connectMenuitem = tolua.cast(menuItem,"CCMenuItemToggle") + local connectMenuitem = tolua.cast(menuItem,"MenuItemToggle") local bConnected = true if connectMenuitem:getSelectedIndex() == 0 then bConnected = false @@ -165,7 +165,7 @@ local function runNotificationCenterTest() connectitem:registerScriptTapHandler(connectToSwitch) local nX,nY = lightArray[i]:getPosition() - connectitem:setPosition(CCPoint(nX,nY+50)) + connectitem:setPosition(cc.p(nX,nY+50)) menuConnect:addChild(connectitem, 0,connectitem:getTag()) @@ -186,48 +186,48 @@ local function runNotificationCenterTest() if 0 == toggleSelectIndex then toggleSelectedItem = nil end - CCNotificationCenter:getInstance():postNotification(NotificationCenterParam.MSG_SWITCH_STATE, toggleSelectedItem) + cc.NotificationCenter:getInstance():postNotification(NotificationCenterParam.MSG_SWITCH_STATE, toggleSelectedItem) --for testing removeAllObservers */ local function doNothing() end - CCNotificationCenter:getInstance():registerScriptObserver(pNewLayer,doNothing, "random-observer1") - CCNotificationCenter:getInstance():registerScriptObserver(pNewLayer,doNothing, "random-observer2") - CCNotificationCenter:getInstance():registerScriptObserver(pNewLayer,doNothing, "random-observer3") + cc.NotificationCenter:getInstance():registerScriptObserver(pNewLayer,doNothing, "random-observer1") + cc.NotificationCenter:getInstance():registerScriptObserver(pNewLayer,doNothing, "random-observer2") + cc.NotificationCenter:getInstance():registerScriptObserver(pNewLayer,doNothing, "random-observer3") local function CreateToMainMenu(pMenu) if nil == pMenu then return end local function toMainLayer() - local numObserversRemoved = CCNotificationCenter:getInstance():removeAllObservers(pNewLayer) + local numObserversRemoved = cc.NotificationCenter:getInstance():removeAllObservers(pNewLayer) if 3 ~= numObserversRemoved then print("All observers were not removed!") end for i = 1 , 3 do if bConnectArray[i] then - CCNotificationCenter:getInstance():unregisterScriptObserver(lightArray[i],NotificationCenterParam.MSG_SWITCH_STATE) + cc.NotificationCenter:getInstance():unregisterScriptObserver(lightArray[i],NotificationCenterParam.MSG_SWITCH_STATE) end end local pScene = ExtensionsTestMain() if pScene ~= nil then - CCDirector:getInstance():replaceScene(pScene) + cc.Director:getInstance():replaceScene(pScene) end end --Create BackMneu - CCMenuItemFont:setFontName("Arial") - CCMenuItemFont:setFontSize(24) - local pMenuItemFont = CCMenuItemFont:create("Back") - pMenuItemFont:setPosition(CCPoint(VisibleRect:rightBottom().x - 50, VisibleRect:rightBottom().y + 25)) + cc.MenuItemFont:setFontName("Arial") + cc.MenuItemFont:setFontSize(24) + local pMenuItemFont = cc.MenuItemFont:create("Back") + pMenuItemFont:setPosition(cc.p(VisibleRect:rightBottom().x - 50, VisibleRect:rightBottom().y + 25)) pMenuItemFont:registerScriptTapHandler(toMainLayer) pMenu:addChild(pMenuItemFont) end --Add Menu - local pToMainMenu = CCMenu:create() + local pToMainMenu = cc.Menu:create() CreateToMainMenu(pToMainMenu) - pToMainMenu:setPosition(CCPoint(0, 0)) + pToMainMenu:setPosition(cc.p(0, 0)) pLayer:addChild(pToMainMenu,10) end @@ -281,7 +281,7 @@ local function runCCControlTest() return ControlExtensionsTestArray[nCurCase + 1] end - local pNewScene = CCScene:create() + local pNewScene = cc.Scene:create() local function CreateBasicMenu(pMenu) if nil == pMenu then @@ -307,21 +307,21 @@ local function runCCControlTest() CurrentControlScene() end - local size = CCDirector:getInstance():getWinSize() - local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2) + local size = cc.Director:getInstance():getWinSize() + local item1 = cc.MenuItemImage:create(s_pPathB1, s_pPathB2) item1:registerScriptTapHandler(backCallback) pMenu:addChild(item1,kItemTagBasic) - local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2) + local item2 = cc.MenuItemImage:create(s_pPathR1, s_pPathR2) item2:registerScriptTapHandler(restartCallback) pMenu:addChild(item2,kItemTagBasic) - local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2) + local item3 = cc.MenuItemImage:create(s_pPathF1, s_pPathF2) pMenu:addChild(item3,kItemTagBasic) item3:registerScriptTapHandler(nextCallback) - local size = CCDirector:getInstance():getWinSize() - item1:setPosition(CCPoint(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) - item2:setPosition(CCPoint(size.width / 2, item2:getContentSize().height / 2)) - item3:setPosition(CCPoint(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + local size = cc.Director:getInstance():getWinSize() + item1:setPosition(cc.p(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + item2:setPosition(cc.p(size.width / 2, item2:getContentSize().height / 2)) + item3:setPosition(cc.p(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) end @@ -330,31 +330,31 @@ local function runCCControlTest() return end --Add Menu - local pToMainMenu = CCMenu:create() + local pToMainMenu = cc.Menu:create() CreateExtensionsBasicLayerMenu(pToMainMenu) - pToMainMenu:setPosition(CCPoint(0, 0)) + pToMainMenu:setPosition(cc.p(0, 0)) pLayer:addChild(pToMainMenu,10) --Add the generated background - local pBackground = CCSprite:create("extensions/background.png") + local pBackground = cc.Sprite:create("extensions/background.png") pBackground:setPosition(VisibleRect:center()) pLayer:addChild(pBackground) --Add the ribbon - local pRibbon = CCScale9Sprite:create("extensions/ribbon.png", CCRect(1, 1, 48, 55)) - pRibbon:setContentSize(CCSize(VisibleRect:getVisibleRect().size.width, 57)) - pRibbon:setPosition(CCPoint(VisibleRect:center().x, VisibleRect:top().y - pRibbon:getContentSize().height / 2.0)) + local pRibbon = cc.Scale9Sprite:create("extensions/ribbon.png", cc.rect(1, 1, 48, 55)) + pRibbon:setContentSize(cc.size(VisibleRect:getVisibleRect().size.width, 57)) + pRibbon:setPosition(cc.p(VisibleRect:center().x, VisibleRect:top().y - pRibbon:getContentSize().height / 2.0)) pLayer:addChild(pRibbon) --Add the title - pSceneTitleLabel = CCLabelTTF:create("Title", "Arial", 12) - pSceneTitleLabel:setPosition(CCPoint (VisibleRect:center().x, VisibleRect:top().y - pSceneTitleLabel:getContentSize().height / 2 - 5)) + pSceneTitleLabel = cc.LabelTTF:create("Title", "Arial", 12) + pSceneTitleLabel:setPosition(cc.p (VisibleRect:center().x, VisibleRect:top().y - pSceneTitleLabel:getContentSize().height / 2 - 5)) pLayer:addChild(pSceneTitleLabel, 1) pSceneTitleLabel:setString(pStrTitle) - local pOperateMenu = CCMenu:create() + local pOperateMenu = cc.Menu:create() CreateBasicMenu(pOperateMenu) - pOperateMenu:setPosition(CCPoint(0, 0)) + pOperateMenu:setPosition(cc.p(0, 0)) pLayer:addChild(pOperateMenu,1) end @@ -363,19 +363,19 @@ local function runCCControlTest() return end - local screenSize = CCDirector:getInstance():getWinSize() + local screenSize = cc.Director:getInstance():getWinSize() --Add a label in which the slider value will be displayed - local pDisplayValueLabel = CCLabelTTF:create("Move the slider thumb!\nThe lower slider is restricted." ,"Marker Felt", 32) + local pDisplayValueLabel = cc.LabelTTF:create("Move the slider thumb!\nThe lower slider is restricted." ,"Marker Felt", 32) pDisplayValueLabel:retain() - pDisplayValueLabel:setAnchorPoint(CCPoint(0.5, -1.0)) - pDisplayValueLabel:setPosition(CCPoint(screenSize.width / 1.7, screenSize.height / 2.0)) + pDisplayValueLabel:setAnchorPoint(cc.p(0.5, -1.0)) + pDisplayValueLabel:setPosition(cc.p(screenSize.width / 1.7, screenSize.height / 2.0)) pLayer:addChild(pDisplayValueLabel) local function valueChanged(pSender) if nil == pSender or nil == pDisplayValueLabel then return end - local pControl = tolua.cast(pSender,"CCControlSlider") + local pControl = tolua.cast(pSender,"ControlSlider") local strFmt = nil if pControl:getTag() == 1 then strFmt = string.format("Upper slider value = %.02f",pControl:getValue()) @@ -384,31 +384,31 @@ local function runCCControlTest() end if nil ~= strFmt then - pDisplayValueLabel:setString(CCString:create(strFmt):getCString()) + pDisplayValueLabel:setString(cc.String:create(strFmt):getCString()) end end --Add the slider - local pSlider = CCControlSlider:create("extensions/sliderTrack.png","extensions/sliderProgress.png" ,"extensions/sliderThumb.png") - pSlider:setAnchorPoint(CCPoint(0.5, 1.0)) + local pSlider = cc.ControlSlider:create("extensions/sliderTrack.png","extensions/sliderProgress.png" ,"extensions/sliderThumb.png") + pSlider:setAnchorPoint(cc.p(0.5, 1.0)) pSlider:setMinimumValue(0.0) pSlider:setMaximumValue(5.0) - pSlider:setPosition(CCPoint(screenSize.width / 2.0, screenSize.height / 2.0 + 16)) + pSlider:setPosition(cc.p(screenSize.width / 2.0, screenSize.height / 2.0 + 16)) pSlider:setTag(1) --When the value of the slider will change, the given selector will be call - pSlider:registerControlEventHandler(valueChanged, CCControlEventValueChanged) + pSlider:registerControlEventHandler(valueChanged, cc.ControlEventValueChanged) - local pRestrictSlider = CCControlSlider:create("extensions/sliderTrack.png","extensions/sliderProgress.png" ,"extensions/sliderThumb.png") - pRestrictSlider:setAnchorPoint(CCPoint(0.5, 1.0)) + local pRestrictSlider = cc.ControlSlider:create("extensions/sliderTrack.png","extensions/sliderProgress.png" ,"extensions/sliderThumb.png") + pRestrictSlider:setAnchorPoint(cc.p(0.5, 1.0)) pRestrictSlider:setMinimumValue(0.0) pRestrictSlider:setMaximumValue(5.0) pRestrictSlider:setMaximumAllowedValue(4.0) pRestrictSlider:setMinimumAllowedValue(1.5) pRestrictSlider:setValue(3.0) - pRestrictSlider:setPosition(CCPoint(screenSize.width / 2.0, screenSize.height / 2.0 - 24)) + pRestrictSlider:setPosition(cc.p(screenSize.width / 2.0, screenSize.height / 2.0 - 24)) pRestrictSlider:setTag(2) --same with restricted - pRestrictSlider:registerControlEventHandler(valueChanged, CCControlEventValueChanged) + pRestrictSlider:registerControlEventHandler(valueChanged, cc.ControlEventValueChanged) pLayer:addChild(pSlider) pLayer:addChild(pRestrictSlider) end @@ -418,11 +418,11 @@ local function runCCControlTest() if nil == pLayer then return end - local screenSize = CCDirector:getInstance():getWinSize() + local screenSize = cc.Director:getInstance():getWinSize() local pColorLabel = nil - local pNode = CCNode:create() - pNode:setPosition(CCPoint (screenSize.width / 2, screenSize.height / 2)) + local pNode = cc.Node:create() + pNode:setPosition(cc.p (screenSize.width / 2, screenSize.height / 2)) pLayer:addChild(pNode, 1) local dLayer_width = 0 @@ -433,33 +433,33 @@ local function runCCControlTest() return end - local pPicker = tolua.cast(pSender,"CCControlColourPicker") + local pPicker = tolua.cast(pSender,"ControlColourPicker") local strFmt = string.format("#%02X%02X%02X",pPicker:getColor().r, pPicker:getColor().g, pPicker:getColor().b) - pColorLabel:setString(CCString:create(strFmt):getCString()) + pColorLabel:setString(cc.String:create(strFmt):getCString()) end - local pColourPicker = CCControlColourPicker:create() - pColourPicker:setColor(Color3B(37, 46, 252)) - pColourPicker:setPosition(CCPoint (pColourPicker:getContentSize().width / 2, 0)) - pColourPicker:registerControlEventHandler(colourValueChanged, CCControlEventValueChanged) + local pColourPicker = cc.ControlColourPicker:create() + pColourPicker:setColor(cc.c3b(37, 46, 252)) + pColourPicker:setPosition(cc.p (pColourPicker:getContentSize().width / 2, 0)) + pColourPicker:registerControlEventHandler(colourValueChanged, cc.ControlEventValueChanged) pNode:addChild(pColourPicker) dLayer_width = dLayer_width + pColourPicker:getContentSize().width --Add the black background for the text - local pBackground = CCScale9Sprite:create("extensions/buttonBackground.png") - pBackground:setContentSize(CCSize(150, 50)) - pBackground:setPosition(CCPoint(dLayer_width + pBackground:getContentSize().width / 2.0, 0)) + local pBackground = cc.Scale9Sprite:create("extensions/buttonBackground.png") + pBackground:setContentSize(cc.size(150, 50)) + pBackground:setPosition(cc.p(dLayer_width + pBackground:getContentSize().width / 2.0, 0)) pNode:addChild(pBackground) dLayer_width = dLayer_width + pBackground:getContentSize().width - pColorLabel = CCLabelTTF:create("#color", "Marker Felt", 30) + pColorLabel = cc.LabelTTF:create("#color", "Marker Felt", 30) pColorLabel:retain() pColorLabel:setPosition(pBackground:getPosition()) pNode:addChild(pColorLabel) --Set the layer size - pNode:setContentSize(CCSize(dLayer_width, 0)) - pNode:setAnchorPoint(CCPoint (0.5, 0.5)) + pNode:setContentSize(cc.size(dLayer_width, 0)) + pNode:setAnchorPoint(cc.p (0.5, 0.5)) --Update the color text colourValueChanged(pColourPicker) @@ -471,22 +471,22 @@ local function runCCControlTest() return end - local screenSize = CCDirector:getInstance():getWinSize() + local screenSize = cc.Director:getInstance():getWinSize() - local pNode = CCNode:create() - pNode:setPosition(CCPoint (screenSize.width / 2, screenSize.height / 2)) + local pNode = cc.Node:create() + pNode:setPosition(cc.p (screenSize.width / 2, screenSize.height / 2)) pLayer:addChild(pNode, 1) local dLayer_width = 0 --Add the black background for the text - local pBackground = CCScale9Sprite:create("extensions/buttonBackground.png") - pBackground:setContentSize(CCSize(80, 50)) - pBackground:setPosition(CCPoint(dLayer_width + pBackground:getContentSize().width / 2.0, 0)) + local pBackground = cc.Scale9Sprite:create("extensions/buttonBackground.png") + pBackground:setContentSize(cc.size(80, 50)) + pBackground:setPosition(cc.p(dLayer_width + pBackground:getContentSize().width / 2.0, 0)) pNode:addChild(pBackground) dLayer_width = dLayer_width + pBackground:getContentSize().width - local pDisplayValueLabel = CCLabelTTF:create("#color" ,"Marker Felt" ,30) + local pDisplayValueLabel = cc.LabelTTF:create("#color" ,"Marker Felt" ,30) pDisplayValueLabel:retain() pDisplayValueLabel:setPosition(pBackground:getPosition()) @@ -498,28 +498,28 @@ local function runCCControlTest() return end - local pControl = tolua.cast(pSender,"CCControlSwitch") + local pControl = tolua.cast(pSender,"ControlSwitch") if pControl:isOn() then pDisplayValueLabel:setString("On") else pDisplayValueLabel:setString("Off") end end - local pSwitchControl = CCControlSwitch:create( - CCSprite:create("extensions/switch-mask.png"), - CCSprite:create("extensions/switch-on.png"), - CCSprite:create("extensions/switch-off.png"), - CCSprite:create("extensions/switch-thumb.png"), - CCLabelTTF:create("On", "Arial-BoldMT", 16), - CCLabelTTF:create("Off", "Arial-BoldMT", 16) + local pSwitchControl = cc.ControlSwitch:create( + cc.Sprite:create("extensions/switch-mask.png"), + cc.Sprite:create("extensions/switch-on.png"), + cc.Sprite:create("extensions/switch-off.png"), + cc.Sprite:create("extensions/switch-thumb.png"), + cc.LabelTTF:create("On", "Arial-BoldMT", 16), + cc.LabelTTF:create("Off", "Arial-BoldMT", 16) ) - pSwitchControl:setPosition(CCPoint (dLayer_width + 10 + pSwitchControl:getContentSize().width / 2, 0)) + pSwitchControl:setPosition(cc.p (dLayer_width + 10 + pSwitchControl:getContentSize().width / 2, 0)) pNode:addChild(pSwitchControl) - pSwitchControl:registerControlEventHandler(valueChanged, CCControlEventValueChanged) + pSwitchControl:registerControlEventHandler(valueChanged, cc.ControlEventValueChanged) --Set the layer size - pNode:setContentSize(CCSize(dLayer_width, 0)) - pNode:setAnchorPoint(CCPoint (0.5, 0.5)) + pNode:setContentSize(cc.size(dLayer_width, 0)) + pNode:setAnchorPoint(cc.p (0.5, 0.5)) --Update the value label valueChanged(pSwitchControl) @@ -528,16 +528,16 @@ local function runCCControlTest() --Hvs:HelloVariableSize local function HvsStandardButtonWithTitle(pStrTitle) -- Creates and return a button with a default background and title color. - local pBackgroundButton = CCScale9Sprite:create("extensions/button.png") - local pBackgroundHighlightedButton = CCScale9Sprite:create("extensions/buttonHighlighted.png") + local pBackgroundButton = cc.Scale9Sprite:create("extensions/button.png") + local pBackgroundHighlightedButton = cc.Scale9Sprite:create("extensions/buttonHighlighted.png") - pTitleButton = CCLabelTTF:create(pStrTitle, "Marker Felt", 30) + pTitleButton = cc.LabelTTF:create(pStrTitle, "Marker Felt", 30) - pTitleButton:setColor(Color3B(159, 168, 176)) + pTitleButton:setColor(cc.c3b(159, 168, 176)) - local pButton = CCControlButton:create(pTitleButton, pBackgroundButton) - pButton:setBackgroundSpriteForState(pBackgroundHighlightedButton, CCControlStateHighlighted) - pButton:setTitleColorForState(Color3B(255,255,255), CCControlStateHighlighted) + local pButton = cc.ControlButton:create(pTitleButton, pBackgroundButton) + pButton:setBackgroundSpriteForState(pBackgroundHighlightedButton, cc.ControlStateHighlighted) + pButton:setTitleColorForState(cc.c3b(255,255,255), cc.ControlStateHighlighted) return pButton end @@ -547,14 +547,14 @@ local function runCCControlTest() return end - local screenSize = CCDirector:getInstance():getWinSize() - local strArray = CCArray:create() - strArray:addObject(CCString:create("Hello")) - strArray:addObject(CCString:create("Variable")) - strArray:addObject(CCString:create("Size")) - strArray:addObject(CCString:create("!")) + local screenSize = cc.Director:getInstance():getWinSize() + local strArray = cc.Array:create() + strArray:addObject(cc.String:create("Hello")) + strArray:addObject(cc.String:create("Variable")) + strArray:addObject(cc.String:create("Size")) + strArray:addObject(cc.String:create("!")) - local pNode = CCNode:create() + local pNode = cc.Node:create() pLayer:addChild(pNode,1) local dTotalWidth = 0 local dHeight = 0 @@ -563,10 +563,10 @@ local function runCCControlTest() local i = 0 local nLen = strArray:count() for i = 0, nLen - 1 do - pObj = tolua.cast(strArray:objectAtIndex(i), "CCString") + pObj = tolua.cast(strArray:objectAtIndex(i), "String") --Creates a button with pLayer string as title local pButton = HvsStandardButtonWithTitle(pObj:getCString()) - pButton:setPosition(CCPoint (dTotalWidth + pButton:getContentSize().width / 2, pButton:getContentSize().height / 2)) + pButton:setPosition(cc.p (dTotalWidth + pButton:getContentSize().width / 2, pButton:getContentSize().height / 2)) pNode:addChild(pButton) --Compute the size of the layer @@ -574,30 +574,30 @@ local function runCCControlTest() dTotalWidth = dTotalWidth + pButton:getContentSize().width end - pNode:setAnchorPoint(CCPoint (0.5, 0.5)) - pNode:setContentSize(CCSize(dTotalWidth, dHeight)) - pNode:setPosition(CCPoint(screenSize.width / 2.0, screenSize.height / 2.0)) + pNode:setAnchorPoint(cc.p (0.5, 0.5)) + pNode:setContentSize(cc.size(dTotalWidth, dHeight)) + pNode:setPosition(cc.p(screenSize.width / 2.0, screenSize.height / 2.0)) --Add the black background - local pBackground = CCScale9Sprite:create("extensions/buttonBackground.png") - pBackground:setContentSize(CCSize(dTotalWidth + 14, dHeight + 14)) - pBackground:setPosition(CCPoint(screenSize.width / 2.0, screenSize.height / 2.0)) + local pBackground = cc.Scale9Sprite:create("extensions/buttonBackground.png") + pBackground:setContentSize(cc.size(dTotalWidth + 14, dHeight + 14)) + pBackground:setPosition(cc.p(screenSize.width / 2.0, screenSize.height / 2.0)) pLayer:addChild(pBackground) end local function StylingStandardButtonWithTitle(pStrTitle) - local pBackgroundButton = CCScale9Sprite:create("extensions/button.png") - pBackgroundButton:setPreferredSize(CCSize(45, 45)) - local pBackgroundHighlightedButton = CCScale9Sprite:create("extensions/buttonHighlighted.png") - pBackgroundHighlightedButton:setPreferredSize(CCSize(45, 45)) + local pBackgroundButton = cc.Scale9Sprite:create("extensions/button.png") + pBackgroundButton:setPreferredSize(cc.size(45, 45)) + local pBackgroundHighlightedButton = cc.Scale9Sprite:create("extensions/buttonHighlighted.png") + pBackgroundHighlightedButton:setPreferredSize(cc.size(45, 45)) - local pTitleButton = CCLabelTTF:create(pStrTitle, "Marker Felt", 30) + local pTitleButton = cc.LabelTTF:create(pStrTitle, "Marker Felt", 30) - pTitleButton:setColor(Color3B(159, 168, 176)) + pTitleButton:setColor(cc.c3b(159, 168, 176)) - local pButton = CCControlButton:create(pTitleButton, pBackgroundButton) - pButton:setBackgroundSpriteForState(pBackgroundHighlightedButton, CCControlStateHighlighted) - pButton:setTitleColorForState(Color3B(255,255,255), CCControlStateHighlighted) + local pButton = cc.ControlButton:create(pTitleButton, pBackgroundButton) + pButton:setBackgroundSpriteForState(pBackgroundHighlightedButton, cc.ControlStateHighlighted) + pButton:setTitleColorForState(cc.c3b(255,255,255), cc.ControlStateHighlighted) return pButton end @@ -607,9 +607,9 @@ local function runCCControlTest() return end - local screenSize = CCDirector:getInstance():getWinSize() + local screenSize = cc.Director:getInstance():getWinSize() - local pNode = CCNode:create() + local pNode = cc.Node:create() pLayer:addChild(pNode, 1) local nSpace = 10 @@ -622,9 +622,9 @@ local function runCCControlTest() for j = 0, 2 do --Add the buttons local strFmt = string.format("%d",math.random(0,32767) % 30) - local pButton = StylingStandardButtonWithTitle(CCString:create(strFmt):getCString()) + local pButton = StylingStandardButtonWithTitle(cc.String:create(strFmt):getCString()) pButton:setAdjustBackgroundImage(false) - pButton:setPosition(CCPoint (pButton:getContentSize().width / 2 + (pButton:getContentSize().width + nSpace) * i, + pButton:setPosition(cc.p (pButton:getContentSize().width / 2 + (pButton:getContentSize().width + nSpace) * i, pButton:getContentSize().height / 2 + (pButton:getContentSize().height + nSpace) * j)) pNode:addChild(pButton) @@ -635,14 +635,14 @@ local function runCCControlTest() end - pNode:setAnchorPoint(CCPoint (0.5, 0.5)) - pNode:setContentSize(CCSize(nMax_w, nMax_h)) - pNode:setPosition(CCPoint(screenSize.width / 2.0, screenSize.height / 2.0)) + pNode:setAnchorPoint(cc.p (0.5, 0.5)) + pNode:setContentSize(cc.size(nMax_w, nMax_h)) + pNode:setPosition(cc.p(screenSize.width / 2.0, screenSize.height / 2.0)) --Add the black background - local pBackgroundButton = CCScale9Sprite:create("extensions/buttonBackground.png") - pBackgroundButton:setContentSize(CCSize(nMax_w + 14, nMax_h + 14)) - pBackgroundButton:setPosition(CCPoint(screenSize.width / 2.0, screenSize.height / 2.0)) + local pBackgroundButton = cc.Scale9Sprite:create("extensions/buttonBackground.png") + pBackgroundButton:setContentSize(cc.size(nMax_w + 14, nMax_h + 14)) + pBackgroundButton:setPosition(cc.p(screenSize.width / 2.0, screenSize.height / 2.0)) pLayer:addChild(pBackgroundButton) end @@ -651,99 +651,99 @@ local function runCCControlTest() return end - local screenSize = CCDirector:getInstance():getWinSize() + local screenSize = cc.Director:getInstance():getWinSize() --Add a label in which the button events will be displayed local pDisplayValueLabel = nil - pDisplayValueLabel = CCLabelTTF:create("No Event", "Marker Felt", 32) - pDisplayValueLabel:setAnchorPoint(CCPoint(0.5, -1)) - pDisplayValueLabel:setPosition(CCPoint(screenSize.width / 2.0, screenSize.height / 2.0)) + pDisplayValueLabel = cc.LabelTTF:create("No Event", "Marker Felt", 32) + pDisplayValueLabel:setAnchorPoint(cc.p(0.5, -1)) + pDisplayValueLabel:setPosition(cc.p(screenSize.width / 2.0, screenSize.height / 2.0)) pLayer:addChild(pDisplayValueLabel, 1) --Add the button - local pBackgroundButton = CCScale9Sprite:create("extensions/button.png") - local pBackgroundHighlightedButton = CCScale9Sprite:create("extensions/buttonHighlighted.png") + local pBackgroundButton = cc.Scale9Sprite:create("extensions/button.png") + local pBackgroundHighlightedButton = cc.Scale9Sprite:create("extensions/buttonHighlighted.png") - local pTitleButtonLabel = CCLabelTTF:create("Touch Me!", "Marker Felt", 30) - pTitleButtonLabel:setColor(Color3B(159, 168, 176)) + local pTitleButtonLabel = cc.LabelTTF:create("Touch Me!", "Marker Felt", 30) + pTitleButtonLabel:setColor(cc.c3b(159, 168, 176)) - local pControlButton = CCControlButton:create(pTitleButtonLabel, pBackgroundButton) + local pControlButton = cc.ControlButton:create(pTitleButtonLabel, pBackgroundButton) local function touchDownAction() if nil == pDisplayValueLabel then return end - pDisplayValueLabel:setString(CCString:create("Touch Down"):getCString()) + pDisplayValueLabel:setString(cc.String:create("Touch Down"):getCString()) end local function touchDragInsideAction() if nil == pDisplayValueLabel then return end - pDisplayValueLabel:setString(CCString:create("Drag Inside"):getCString()) + pDisplayValueLabel:setString(cc.String:create("Drag Inside"):getCString()) end local function touchDragOutsideAction() if nil == pDisplayValueLabel then return end - pDisplayValueLabel:setString(CCString:create("Drag Outside"):getCString()) + pDisplayValueLabel:setString(cc.String:create("Drag Outside"):getCString()) end local function touchDragEnterAction() if nil == pDisplayValueLabel then return end - pDisplayValueLabel:setString(CCString:create("Drag Enter"):getCString()) + pDisplayValueLabel:setString(cc.String:create("Drag Enter"):getCString()) end local function touchDragExitAction() if nil == pDisplayValueLabel then return end - pDisplayValueLabel:setString(CCString:create("Drag Exit"):getCString()) + pDisplayValueLabel:setString(cc.String:create("Drag Exit"):getCString()) end local function touchUpInsideAction() if nil == pDisplayValueLabel then return end - pDisplayValueLabel:setString(CCString:create("Touch Up Inside."):getCString()) + pDisplayValueLabel:setString(cc.String:create("Touch Up Inside."):getCString()) end local function touchUpOutsideAction() if nil == pDisplayValueLabel then return end - pDisplayValueLabel:setString(CCString:create("Touch Up Outside."):getCString()) + pDisplayValueLabel:setString(cc.String:create("Touch Up Outside."):getCString()) end local function touchCancelAction() if nil == pDisplayValueLabel then return end - pDisplayValueLabel:setString(CCString:create("Touch Cancel"):getCString()) + pDisplayValueLabel:setString(cc.String:create("Touch Cancel"):getCString()) end - pControlButton:setBackgroundSpriteForState(pBackgroundHighlightedButton, CCControlStateHighlighted) - pControlButton:setTitleColorForState(Color3B(255, 255, 255), CCControlStateHighlighted) - pControlButton:setAnchorPoint(CCPoint(0.5, 1)) - pControlButton:setPosition(CCPoint(screenSize.width / 2.0, screenSize.height / 2.0)) - pControlButton:registerControlEventHandler(touchDownAction,CCControlEventTouchDown) - pControlButton:registerControlEventHandler(touchDragInsideAction,CCControlEventTouchDragInside) - pControlButton:registerControlEventHandler(touchDragOutsideAction,CCControlEventTouchDragOutside) - pControlButton:registerControlEventHandler(touchDragEnterAction,CCControlEventTouchDragEnter) - pControlButton:registerControlEventHandler(touchDragExitAction,CCControlEventTouchDragExit) - pControlButton:registerControlEventHandler(touchUpInsideAction,CCControlEventTouchUpInside) - pControlButton:registerControlEventHandler(touchUpOutsideAction,CCControlEventTouchUpOutside) - pControlButton:registerControlEventHandler(touchCancelAction,CCControlEventTouchCancel) + pControlButton:setBackgroundSpriteForState(pBackgroundHighlightedButton, cc.ControlStateHighlighted) + pControlButton:setTitleColorForState(cc.c3b(255, 255, 255), cc.ControlStateHighlighted) + pControlButton:setAnchorPoint(cc.p(0.5, 1)) + pControlButton:setPosition(cc.p(screenSize.width / 2.0, screenSize.height / 2.0)) + pControlButton:registerControlEventHandler(touchDownAction,cc.ControlEventTouchDown) + pControlButton:registerControlEventHandler(touchDragInsideAction,cc.ControlEventTouchDragInside) + pControlButton:registerControlEventHandler(touchDragOutsideAction,cc.ControlEventTouchDragOutside) + pControlButton:registerControlEventHandler(touchDragEnterAction,cc.ControlEventTouchDragEnter) + pControlButton:registerControlEventHandler(touchDragExitAction,cc.ControlEventTouchDragExit) + pControlButton:registerControlEventHandler(touchUpInsideAction,cc.ControlEventTouchUpInside) + pControlButton:registerControlEventHandler(touchUpOutsideAction,cc.ControlEventTouchUpOutside) + pControlButton:registerControlEventHandler(touchCancelAction,cc.ControlEventTouchCancel) pLayer:addChild(pControlButton, 1) --Add the black background - local pBackgroundButton = CCScale9Sprite:create("extensions/buttonBackground.png") - pBackgroundButton:setContentSize(CCSize(300, 170)) - pBackgroundButton:setPosition(CCPoint(screenSize.width / 2.0, screenSize.height / 2.0)) + local pBackgroundButton = cc.Scale9Sprite:create("extensions/buttonBackground.png") + pBackgroundButton:setContentSize(cc.size(300, 170)) + pBackgroundButton:setPosition(cc.p(screenSize.width / 2.0, screenSize.height / 2.0)) pLayer:addChild(pBackgroundButton) end --PotentiometerTest @@ -752,23 +752,23 @@ local function runCCControlTest() return end - local screenSize = CCDirector:getInstance():getWinSize() + local screenSize = cc.Director:getInstance():getWinSize() - local pNode = CCNode:create() - pNode:setPosition(CCPoint (screenSize.width / 2, screenSize.height / 2)) + local pNode = cc.Node:create() + pNode:setPosition(cc.p (screenSize.width / 2, screenSize.height / 2)) pLayer:addChild(pNode, 1) local dLayer_width = 0 -- Add the black background for the text - local pBackground = CCScale9Sprite:create("extensions/buttonBackground.png") - pBackground:setContentSize(CCSize(80, 50)) - pBackground:setPosition(CCPoint(dLayer_width + pBackground:getContentSize().width / 2.0, 0)) + local pBackground = cc.Scale9Sprite:create("extensions/buttonBackground.png") + pBackground:setContentSize(cc.size(80, 50)) + pBackground:setPosition(cc.p(dLayer_width + pBackground:getContentSize().width / 2.0, 0)) pNode:addChild(pBackground) dLayer_width = dLayer_width + pBackground:getContentSize().width - local pDisplayValueLabel = CCLabelTTF:create("", "HelveticaNeue-Bold", 30) + local pDisplayValueLabel = cc.LabelTTF:create("", "HelveticaNeue-Bold", 30) pDisplayValueLabel:setPosition(pBackground:getPosition()) pNode:addChild(pDisplayValueLabel) @@ -778,24 +778,24 @@ local function runCCControlTest() return end - local pControl = tolua.cast(pSender,"CCControlPotentiometer") + local pControl = tolua.cast(pSender,"ControlPotentiometer") local strFmt = string.format("%0.2f",pControl:getValue()) - pDisplayValueLabel:setString(CCString:create(strFmt):getCString()) + pDisplayValueLabel:setString(cc.String:create(strFmt):getCString()) end - local pPotentiometer = CCControlPotentiometer:create("extensions/potentiometerTrack.png","extensions/potentiometerProgress.png" + local pPotentiometer = cc.ControlPotentiometer:create("extensions/potentiometerTrack.png","extensions/potentiometerProgress.png" ,"extensions/potentiometerButton.png") - pPotentiometer:setPosition(CCPoint (dLayer_width + 10 + pPotentiometer:getContentSize().width / 2, 0)) + pPotentiometer:setPosition(cc.p (dLayer_width + 10 + pPotentiometer:getContentSize().width / 2, 0)) -- When the value of the slider will change, the given selector will be call - pPotentiometer:registerControlEventHandler(valueChanged, CCControlEventValueChanged) + pPotentiometer:registerControlEventHandler(valueChanged, cc.ControlEventValueChanged) pNode:addChild(pPotentiometer) dLayer_width = dLayer_width + pPotentiometer:getContentSize().width -- Set the layer size - pNode:setContentSize(CCSize(dLayer_width, 0)) - pNode:setAnchorPoint(CCPoint (0.5, 0.5)) + pNode:setContentSize(cc.size(dLayer_width, 0)) + pNode:setAnchorPoint(cc.p (0.5, 0.5)) -- Update the value label valueChanged(pPotentiometer) @@ -806,49 +806,49 @@ local function runCCControlTest() return end - local screenSize = CCDirector:getInstance():getWinSize() + local screenSize = cc.Director:getInstance():getWinSize() - local pNode = CCNode:create() - pNode:setPosition(CCPoint (screenSize.width / 2, screenSize.height / 2)) + local pNode = cc.Node:create() + pNode:setPosition(cc.p (screenSize.width / 2, screenSize.height / 2)) pLayer:addChild(pNode, 1) local layer_width = 0 -- Add the black background for the text - local background = CCScale9Sprite:create("extensions/buttonBackground.png") - background:setContentSize(CCSize(100, 50)) - background:setPosition(CCPoint(layer_width + background:getContentSize().width / 2.0, 0)) + local background = cc.Scale9Sprite:create("extensions/buttonBackground.png") + background:setContentSize(cc.size(100, 50)) + background:setPosition(cc.p(layer_width + background:getContentSize().width / 2.0, 0)) pNode:addChild(background) - local pDisplayValueLabel = CCLabelTTF:create("0", "HelveticaNeue-Bold", 30) + local pDisplayValueLabel = cc.LabelTTF:create("0", "HelveticaNeue-Bold", 30) pDisplayValueLabel:setPosition(background:getPosition()) pNode:addChild(pDisplayValueLabel) layer_width = layer_width + background:getContentSize().width - local minusSprite = CCSprite:create("extensions/stepper-minus.png") - local plusSprite = CCSprite:create("extensions/stepper-plus.png") + local minusSprite = cc.Sprite:create("extensions/stepper-minus.png") + local plusSprite = cc.Sprite:create("extensions/stepper-plus.png") local function valueChanged(pSender) if nil == pDisplayValueLabel or nil == pSender then return end - local pControl = tolua.cast(pSender,"CCControlStepper") + local pControl = tolua.cast(pSender,"ControlStepper") local strFmt = string.format("%0.02f",pControl:getValue() ) - pDisplayValueLabel:setString(CCString:create(strFmt):getCString()) + pDisplayValueLabel:setString(cc.String:create(strFmt):getCString()) end - local stepper = CCControlStepper:create(minusSprite, plusSprite) - stepper:setPosition(CCPoint (layer_width + 10 + stepper:getContentSize().width / 2, 0)) - stepper:registerControlEventHandler(valueChanged, CCControlEventValueChanged) + local stepper = cc.ControlStepper:create(minusSprite, plusSprite) + stepper:setPosition(cc.p (layer_width + 10 + stepper:getContentSize().width / 2, 0)) + stepper:registerControlEventHandler(valueChanged, cc.ControlEventValueChanged) pNode:addChild(stepper) layer_width = layer_width + stepper:getContentSize().width -- Set the layer size - pNode:setContentSize(CCSize(layer_width, 0)) - pNode:setAnchorPoint(CCPoint (0.5, 0.5)) + pNode:setContentSize(cc.size(layer_width, 0)) + pNode:setAnchorPoint(cc.p (0.5, 0.5)) -- Update the value label valueChanged(stepper) @@ -876,18 +876,18 @@ local function runCCControlTest() function CurrentControlScene() pNewScene = nil - pNewScene = CCScene:create() - local pNewLayer = CCLayer:create() + pNewScene = cc.Scene:create() + local pNewLayer = cc.Layer:create() BaseInitSceneLayer(pNewLayer,GetControlExtensionsTitle()) InitSpecialSceneLayer(pNewLayer) pNewScene:addChild(pNewLayer) if nil ~= pNewScene then - CCDirector:getInstance():replaceScene(pNewScene) + cc.Director:getInstance():replaceScene(pNewScene) end end - local pNewLayer = CCLayer:create() + local pNewLayer = cc.Layer:create() BaseInitSceneLayer(pNewLayer,GetControlExtensionsTitle()) InitSpecialSceneLayer(pNewLayer) pNewScene:addChild(pNewLayer) @@ -896,32 +896,32 @@ local function runCCControlTest() end local function runEditBoxTest() - local newScene = CCScene:create() - local newLayer = CCLayer:create() - local visibleOrigin = CCEGLView:getInstance():getVisibleOrigin() - local visibleSize = CCEGLView:getInstance():getVisibleSize() + local newScene = cc.Scene:create() + local newLayer = cc.Layer:create() + local visibleOrigin = cc.EGLView:getInstance():getVisibleOrigin() + local visibleSize = cc.EGLView:getInstance():getVisibleSize() - local pBg = CCSprite:create("Images/HelloWorld.png") - pBg:setPosition(CCPoint(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/2)) + local pBg = cc.Sprite:create("Images/HelloWorld.png") + pBg:setPosition(cc.p(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/2)) newLayer:addChild(pBg) - local TTFShowEditReturn = CCLabelTTF:create("No edit control return!", "", 30) - TTFShowEditReturn:setPosition(CCPoint(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y + visibleSize.height - 50)) + local TTFShowEditReturn = cc.LabelTTF:create("No edit control return!", "", 30) + TTFShowEditReturn:setPosition(cc.p(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y + visibleSize.height - 50)) newLayer:addChild(TTFShowEditReturn) -- Back Menu - local pToMainMenu = CCMenu:create() + local pToMainMenu = cc.Menu:create() CreateExtensionsBasicLayerMenu(pToMainMenu) - pToMainMenu:setPosition(CCPoint(0, 0)) + pToMainMenu:setPosition(cc.p(0, 0)) newLayer:addChild(pToMainMenu,10) - local editBoxSize = CCSize(visibleSize.width - 100, 60) + local editBoxSize = cc.size(visibleSize.width - 100, 60) local EditName = nil local EditPassword = nil local EditEmail = nil local function editBoxTextEventHandle(strEventName,pSender) - local edit = tolua.cast(pSender,"CCEditBox") + local edit = tolua.cast(pSender,"EditBox") local strFmt if strEventName == "began" then strFmt = string.format("editBox %p DidBegin !", edit) @@ -945,18 +945,18 @@ local function runEditBoxTest() end end -- top - EditName = CCEditBox:create(editBoxSize, CCScale9Sprite:create("extensions/green_edit.png")) - EditName:setPosition(CCPoint(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height*3/4)) - local targetPlatform = CCApplication:getInstance():getTargetPlatform() + EditName = cc.EditBox:create(editBoxSize, cc.Scale9Sprite:create("extensions/green_edit.png")) + EditName:setPosition(cc.p(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height*3/4)) + local targetPlatform = cc.Application:getInstance():getTargetPlatform() if kTargetIphone == targetPlatform or kTargetIpad == targetPlatform then EditName:setFontName("Paint Boy") else EditName:setFontName("fonts/Paint Boy.ttf") end EditName:setFontSize(25) - EditName:setFontColor(Color3B(255,0,0)) + EditName:setFontColor(cc.c3b(255,0,0)) EditName:setPlaceHolder("Name:") - EditName:setPlaceholderFontColor(Color3B(255,255,255)) + EditName:setPlaceholderFontColor(cc.c3b(255,255,255)) EditName:setMaxLength(8) EditName:setReturnType(kKeyboardReturnTypeDone) --Handler @@ -964,8 +964,8 @@ local function runEditBoxTest() newLayer:addChild(EditName) --middle - EditPassword = CCEditBox:create(editBoxSize, CCScale9Sprite:create("extensions/orange_edit.png")) - EditPassword:setPosition(CCPoint(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/2)) + EditPassword = cc.EditBox:create(editBoxSize, cc.Scale9Sprite:create("extensions/orange_edit.png")) + EditPassword:setPosition(cc.p(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/2)) if kTargetIphone == targetPlatform or kTargetIpad == targetPlatform then EditPassword:setFont("American Typewriter", 30) else @@ -973,7 +973,7 @@ local function runEditBoxTest() end - EditPassword:setFontColor(Color3B(0,255,0)) + EditPassword:setFontColor(cc.c3b(0,255,0)) EditPassword:setPlaceHolder("Password:") EditPassword:setMaxLength(6) EditPassword:setInputFlag(kEditBoxInputFlagPassword) @@ -982,14 +982,14 @@ local function runEditBoxTest() newLayer:addChild(EditPassword) --bottom - EditEmail = CCEditBox:create(CCSize(editBoxSize.width, editBoxSize.height), CCScale9Sprite:create("extensions/yellow_edit.png")) - EditEmail:setPosition(CCPoint(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/4)) - EditEmail:setAnchorPoint(CCPoint(0.5, 1.0)) + EditEmail = cc.EditBox:create(cc.size(editBoxSize.width, editBoxSize.height), cc.Scale9Sprite:create("extensions/yellow_edit.png")) + EditEmail:setPosition(cc.p(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/4)) + EditEmail:setAnchorPoint(cc.p(0.5, 1.0)) EditEmail:setPlaceHolder("Email:") EditEmail:setInputMode(kEditBoxInputModeEmailAddr) EditEmail:registerScriptEditBoxHandler(editBoxTextEventHandle) newLayer:addChild(EditEmail) - newLayer:setPosition(CCPoint(10, 20)) + newLayer:setPosition(cc.p(10, 20)) newScene:addChild(newLayer) @@ -997,20 +997,20 @@ local function runEditBoxTest() end local function runScrollViewTest() - local newScene = CCScene:create() - local newLayer = CCLayer:create() + local newScene = cc.Scene:create() + local newLayer = cc.Layer:create() -- Back Menu - local pToMainMenu = CCMenu:create() + local pToMainMenu = cc.Menu:create() CreateExtensionsBasicLayerMenu(pToMainMenu) - pToMainMenu:setPosition(CCPoint(0, 0)) + pToMainMenu:setPosition(cc.p(0, 0)) newLayer:addChild(pToMainMenu,10) - local layerColor = CCLayerColor:create(Color4B(128,64,0,255)) + local layerColor = cc.LayerColor:create(cc.c4b(128,64,0,255)) newLayer:addChild(layerColor) - local scrollView1 = CCScrollView:create() - local screenSize = CCDirector:getInstance():getWinSize() + local scrollView1 = cc.ScrollView:create() + local screenSize = cc.Director:getInstance():getWinSize() local function scrollView1DidScroll() print("scrollView1DidScroll") end @@ -1018,11 +1018,11 @@ local function runScrollViewTest() print("scrollView1DidZoom") end if nil ~= scrollView1 then - scrollView1:setViewSize(CCSize(screenSize.width / 2,screenSize.height)) - scrollView1:setPosition(CCPoint(0,0)) + scrollView1:setViewSize(cc.size(screenSize.width / 2,screenSize.height)) + scrollView1:setPosition(cc.p(0,0)) scrollView1:setScale(1.0) scrollView1:ignoreAnchorPointForPosition(true) - local flowersprite1 = CCSprite:create("ccb/flower.jpg") + local flowersprite1 = cc.Sprite:create("ccb/flower.jpg") if nil ~= flowersprite1 then scrollView1:setContainer(flowersprite1) scrollView1:updateInset() @@ -1036,7 +1036,7 @@ local function runScrollViewTest() end newLayer:addChild(scrollView1) - local scrollView2 = CCScrollView:create() + local scrollView2 = cc.ScrollView:create() local function scrollView2DidScroll() print("scrollView2DidScroll") end @@ -1044,11 +1044,11 @@ local function runScrollViewTest() print("scrollView2DidZoom") end if nil ~= scrollView2 then - scrollView2:setViewSize(CCSize(screenSize.width / 2,screenSize.height)) - scrollView2:setPosition(CCPoint(screenSize.width / 2,0)) + scrollView2:setViewSize(cc.size(screenSize.width / 2,screenSize.height)) + scrollView2:setPosition(cc.p(screenSize.width / 2,0)) scrollView2:setScale(1.0) scrollView2:ignoreAnchorPointForPosition(true) - local flowersprite2 = CCSprite:create("ccb/flower.jpg") + local flowersprite2 = cc.Sprite:create("ccb/flower.jpg") if nil ~= flowersprite2 then scrollView2:setContainer(flowersprite2) scrollView2:updateInset() @@ -1082,7 +1082,7 @@ local CreateExtensionsTestTable = local function ExtensionsMainLayer() - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() local function CreateExtensionsTestScene(nPerformanceNo) local pNewscene = CreateExtensionsTestTable[nPerformanceNo]() @@ -1094,16 +1094,16 @@ local function ExtensionsMainLayer() local nIdx = pMenuItem:getZOrder() - kItemTagBasic local ExtensionsTestScene = CreateExtensionsTestScene(nIdx) if nil ~= ExtensionsTestScene then - CCDirector:getInstance():replaceScene(ExtensionsTestScene) + cc.Director:getInstance():replaceScene(ExtensionsTestScene) end end - local layer = CCLayer:create() - local menu = CCMenu:create() - menu:setPosition(CCPoint(0, 0)) - CCMenuItemFont:setFontName("Arial") - CCMenuItemFont:setFontSize(24) - local targetPlatform = CCApplication:getInstance():getTargetPlatform() + local layer = cc.Layer:create() + local menu = cc.Menu:create() + menu:setPosition(cc.p(0, 0)) + cc.MenuItemFont:setFontName("Arial") + cc.MenuItemFont:setFontSize(24) + local targetPlatform = cc.Application:getInstance():getTargetPlatform() local bSupportWebSocket = false if (kTargetIphone == targetPlatform) or (kTargetIpad == targetPlatform) or (kTargetAndroid == targetPlatform) or (kTargetWindows == targetPlatform) then bSupportWebSocket = true @@ -1115,7 +1115,7 @@ local function ExtensionsMainLayer() bSupportEdit = true end for i = 1, ExtensionTestEnum.TEST_MAX_COUNT do - local item = CCMenuItemFont:create(testsName[i]) + local item = cc.MenuItemFont:create(testsName[i]) item:registerScriptTapHandler(menuCallback) item:setPosition(s.width / 2, s.height - i * LINE_SPACE) menu:addChild(item, kItemTagBasic + i) @@ -1135,7 +1135,7 @@ end -- Extensions Test ------------------------------------- function ExtensionsTestMain() - local scene = CCScene:create() + local scene = cc.Scene:create() scene:addChild(ExtensionsMainLayer()) scene:addChild(CreateBackMenuItem()) diff --git a/samples/Lua/TestLua/Resources/luaScript/LayerTest/LayerTest.lua b/samples/Lua/TestLua/Resources/luaScript/LayerTest/LayerTest.lua index 5314142ab4..04e54d2842 100644 --- a/samples/Lua/TestLua/Resources/luaScript/LayerTest/LayerTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/LayerTest/LayerTest.lua @@ -49,12 +49,14 @@ local function setEnableRecursiveCascading(node, enable) local children = node:getChildren() if children == nil then -- cclog("children is nil") + print("children is nil") return end local i = 0 local len = table.getn(children) for i = 0, len-1, 1 do + print("come in") local child = tolua.cast(children[i + 1], "Node") setEnableRecursiveCascading(child, enable) end diff --git a/samples/Lua/TestLua/Resources/luaScript/MenuTest/MenuTest.lua b/samples/Lua/TestLua/Resources/luaScript/MenuTest/MenuTest.lua index 6f9d193543..cb2dc86af3 100644 --- a/samples/Lua/TestLua/Resources/luaScript/MenuTest/MenuTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/MenuTest/MenuTest.lua @@ -21,38 +21,38 @@ local MID_BACKCALLBACK = 1009 local function MenuLayerMainMenu() local m_disabledItem = nil - local ret = CCLayer:create() + local ret = cc.Layer:create() ret:setTouchEnabled(true) - ret:setTouchPriority(kCCMenuHandlerPriority + 1) - ret:setTouchMode(kCCTouchesOneByOne) + ret:setTouchPriority(cc.MENU_HANDLER_PRIORITY + 1) + ret:setTouchMode(cc.TOUCHES_ONE_BY_ONE ) -- Font Item - local spriteNormal = CCSprite:create(s_MenuItem, CCRect(0,23*2,115,23)) - local spriteSelected = CCSprite:create(s_MenuItem, CCRect(0,23*1,115,23)) - local spriteDisabled = CCSprite:create(s_MenuItem, CCRect(0,23*0,115,23)) + local spriteNormal = cc.Sprite:create(s_MenuItem, cc.rect(0,23*2,115,23)) + local spriteSelected = cc.Sprite:create(s_MenuItem, cc.rect(0,23*1,115,23)) + local spriteDisabled = cc.Sprite:create(s_MenuItem, cc.rect(0,23*0,115,23)) - local item1 = CCMenuItemSprite:create(spriteNormal, spriteSelected, spriteDisabled) + local item1 = cc.MenuItemSprite:create(spriteNormal, spriteSelected, spriteDisabled) local function menuCallback(sender) cclog("menuCallback...") - tolua.cast(ret:getParent(), "CCLayerMultiplex"):switchTo(1) + tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(1) end item1:registerScriptTapHandler(menuCallback) -- Image Item local function menuCallback2(sender) - tolua.cast(ret:getParent(), "CCLayerMultiplex"):switchTo(2) + tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(2) end - local item2 = CCMenuItemImage:create(s_SendScore, s_PressSendScore) + local item2 = cc.MenuItemImage:create(s_SendScore, s_PressSendScore) item2:registerScriptTapHandler(menuCallback2) local schedulerEntry = nil - local scheduler = CCDirector:getInstance():getScheduler() + local scheduler = cc.Director:getInstance():getScheduler() local function allowTouches(dt) - local pDirector = CCDirector:getInstance() - --pDirector:getTouchDispatcher():setPriority(kCCMenuHandlerPriority+1, ret) + local pDirector = cc.Director:getInstance() + --pDirector:getTouchDispatcher():setPriority(cc.MENU_HANDLER_PRIORITY +1, ret) if nil ~= schedulerEntry then scheduler:unscheduleScriptEntry(schedulerEntry) schedulerEntry = nil @@ -63,57 +63,57 @@ local function MenuLayerMainMenu() local function menuCallbackDisabled(sender) -- hijack all touch events for 5 seconds - local pDirector = CCDirector:getInstance() - --pDirector:getTouchDispatcher():setPriority(kCCMenuHandlerPriority-1, ret) + local pDirector = cc.Director:getInstance() + --pDirector:getTouchDispatcher():setPriority(cc.MENU_HANDLER_PRIORITY -1, ret) schedulerEntry = scheduler:scheduleScriptFunc(allowTouches, 5, false) cclog("TOUCHES DISABLED FOR 5 SECONDS") end -- Label Item (LabelAtlas) - local labelAtlas = CCLabelAtlas:create("0123456789", "fonts/labelatlas.png", 16, 24, string.byte('.')) - local item3 = CCMenuItemLabel:create(labelAtlas) + local labelAtlas = cc.LabelAtlas:_create("0123456789", "fonts/labelatlas.png", 16, 24, string.byte('.')) + local item3 = cc.MenuItemLabel:create(labelAtlas) item3:registerScriptTapHandler(menuCallbackDisabled) - item3:setDisabledColor( Color3B(32,32,64) ) - item3:setColor( Color3B(200,200,255) ) + item3:setDisabledColor( cc.c3b(32,32,64) ) + item3:setColor( cc.c3b(200,200,255) ) local function menuCallbackEnable(sender) m_disabledItem:setEnabled(not m_disabledItem:isEnabled() ) end -- Font Item - local item4 = CCMenuItemFont:create("I toggle enable items") + local item4 = cc.MenuItemFont:create("I toggle enable items") item4:registerScriptTapHandler(menuCallbackEnable) item4:setFontSizeObj(20) - CCMenuItemFont:setFontName("Marker Felt") + cc.MenuItemFont:setFontName("Marker Felt") local function menuCallbackConfig(sender) - tolua.cast(ret:getParent(), "CCLayerMultiplex"):switchTo(3) + tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(3) end - -- Label Item (CCLabelBMFont) - local label = CCLabelBMFont:create("configuration", "fonts/bitmapFontTest3.fnt") - local item5 = CCMenuItemLabel:create(label) + -- Label Item (cc.LabelBMFont) + local label = cc.LabelBMFont:create("configuration", "fonts/bitmapFontTest3.fnt") + local item5 = cc.MenuItemLabel:create(label) item5:registerScriptTapHandler(menuCallbackConfig) -- Testing issue #500 item5:setScale( 0.8 ) local function menuCallbackPriorityTest(pSender) - tolua.cast(ret:getParent(), "CCLayerMultiplex"):switchTo(4) + tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(4) end -- Events - CCMenuItemFont:setFontName("Marker Felt") - local item6 = CCMenuItemFont:create("Priority Test") + cc.MenuItemFont:setFontName("Marker Felt") + local item6 = cc.MenuItemFont:create("Priority Test") item6:registerScriptTapHandler(menuCallbackPriorityTest) local function menuCallbackBugsTest(pSender) - tolua.cast(ret:getParent(), "CCLayerMultiplex"):switchTo(5) + tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(5) end -- Bugs Item - local item7 = CCMenuItemFont:create("Bugs") + local item7 = cc.MenuItemFont:create("Bugs") item7:registerScriptTapHandler(menuCallbackBugsTest) local function onQuit(sender) @@ -121,25 +121,22 @@ local function MenuLayerMainMenu() end -- Font Item - local item8 = CCMenuItemFont:create("Quit") + local item8 = cc.MenuItemFont:create("Quit") item8:registerScriptTapHandler(onQuit) local function menuMovingCallback(pSender) - tolua.cast(ret:getParent(), "CCLayerMultiplex"):switchTo(6) + tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(6) end - local item9 = CCMenuItemFont:create("Remove menu item when moving") + local item9 = cc.MenuItemFont:create("Remove menu item when moving") item9:registerScriptTapHandler(menuMovingCallback) - local color_action = CCTintBy:create(0.5, 0, -255, -255) + local color_action = cc.TintBy:create(0.5, 0, -255, -255) local color_back = color_action:reverse() - local arr = CCArray:create() - arr:addObject(color_action) - arr:addObject(color_back) - local seq = CCSequence:create(arr) - item8:runAction(CCRepeatForever:create(seq)) + local seq = cc.Sequence:create(color_action, color_back) + item8:runAction(cc.RepeatForever:create(seq)) - local menu = CCMenu:create() + local menu = cc.Menu:create() menu:addChild(item1) menu:addChild(item2) @@ -154,27 +151,27 @@ local function MenuLayerMainMenu() menu:alignItemsVertically() -- elastic effect - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() local i = 0 local child = nil local pArray = menu:getChildren() - local len = pArray:count() + local len = table.getn(pArray) local pObject = nil for i = 0, len-1 do - pObject = pArray:objectAtIndex(i) + pObject = pArray[i + 1] if pObject == nil then break end - child = tolua.cast(pObject, "CCNode") - - local dstPointX, dstPointY = child:getPosition() + child = tolua.cast(pObject, "Node") + local dstPoint = child:getPosition() + local dstPointX, dstPointY = dstPoint.x,dstPoint.y local offset = s.width/2 + 50 if i % 2 == 0 then offset = 0-offset end - child:setPosition( CCPoint( dstPointX + offset, dstPointY) ) - child:runAction( CCEaseElasticOut:create(CCMoveBy:create(2, CCPoint(dstPointX - offset,0)), 0.35) ) + child:setPosition( cc.p( dstPointX + offset, dstPointY) ) + child:runAction( cc.EaseElasticOut:create(cc.MoveBy:create(2, cc.p(dstPointX - offset,0)), 0.35) ) end m_disabledItem = item3 @@ -183,7 +180,7 @@ local function MenuLayerMainMenu() m_disabledItem:setEnabled( false ) ret:addChild(menu) - menu:setPosition(CCPoint(s.width/2, s.height/2)) + menu:setPosition(cc.p(s.width/2, s.height/2)) -- local schedulerEntry = nil local function onNodeEvent(event) @@ -208,25 +205,27 @@ end -- -------------------------------------------------------------------- local function MenuLayer2() - local ret = CCLayer:create() + local ret = cc.Layer:create() local m_centeredMenu = nil local m_alignedH = false local function alignMenusH() local i = 0 for i=0, 1 do - local menu = tolua.cast(ret:getChildByTag(100+i), "CCMenu") + local menu = tolua.cast(ret:getChildByTag(100+i), "Menu") menu:setPosition( m_centeredMenu ) if i==0 then -- TIP: if no padding, padding = 5 menu:alignItemsHorizontally() - local x, y = menu:getPosition() - menu:setPosition( CCPoint.__add(CCPoint(x, y), CCPoint(0,30)) ) + local menuPos = menu:getPosition() + local x, y = menuPos.x,menuPos.y + menu:setPosition( cc.pAdd(cc.p(x, y), cc.p(0,30)) ) else -- TIP: but padding is configurable menu:alignItemsHorizontallyWithPadding(40) - local x, y = menu:getPosition() - menu:setPosition( CCPoint.__sub(CCPoint(x, y), CCPoint(0,30)) ) + local menuPos = menu:getPosition() + local x, y = menuPos.x,menuPos.y + menu:setPosition( cc.pSub(cc.p(x, y), cc.p(0,30)) ) end end end @@ -234,28 +233,30 @@ local function MenuLayer2() local function alignMenusV() local i = 0 for i=0, 1 do - local menu = tolua.cast(ret:getChildByTag(100+i), "CCMenu") + local menu = tolua.cast(ret:getChildByTag(100+i), "Menu") menu:setPosition( m_centeredMenu ) if i==0 then -- TIP: if no padding, padding = 5 menu:alignItemsVertically() - local x, y = menu:getPosition() - menu:setPosition( CCPoint.__add(CCPoint(x, y), CCPoint(100,0)) ) + local menuPos = menu:getPosition() + local x, y = menuPos.x,menuPos.y + menu:setPosition( cc.pAdd(cc.p(x, y), cc.p(100,0)) ) else -- TIP: but padding is configurable menu:alignItemsVerticallyWithPadding(40) - local x, y = menu:getPosition() - menu:setPosition( CCPoint.__sub(CCPoint(x, y), CCPoint(100,0)) ) + local menuPos = menu:getPosition() + local x, y = menuPos.x,menuPos.y + menu:setPosition( cc.pSub(cc.p(x, y), cc.p(100,0)) ) end end end local function menuCallback(sender) - tolua.cast(ret:getParent(), "CCLayerMultiplex"):switchTo(0) + tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(0) end local function menuCallbackOpacity(tag, sender) - local menu = tolua.cast(sender:getParent(), "CCMenu") + local menu = tolua.cast(sender:getParent(), "Menu") local opacity = menu:getOpacity() if opacity == 128 then menu:setOpacity(255) @@ -276,34 +277,34 @@ local function MenuLayer2() local i = 0 for i=0, 1 do - local item1 = CCMenuItemImage:create(s_PlayNormal, s_PlaySelect) + local item1 = cc.MenuItemImage:create(s_PlayNormal, s_PlaySelect) item1:registerScriptTapHandler(menuCallback) - local item2 = CCMenuItemImage:create(s_HighNormal, s_HighSelect) + local item2 = cc.MenuItemImage:create(s_HighNormal, s_HighSelect) item2:registerScriptTapHandler(menuCallbackOpacity) - local item3 = CCMenuItemImage:create(s_AboutNormal, s_AboutSelect) + local item3 = cc.MenuItemImage:create(s_AboutNormal, s_AboutSelect) item3:registerScriptTapHandler(menuCallbackAlign) item1:setScaleX( 1.5 ) item2:setScaleX( 0.5 ) item3:setScaleX( 0.5 ) - local menu = CCMenu:create() + local menu = cc.Menu:create() menu:addChild(item1) menu:addChild(item2) menu:addChild(item3) - local s = CCDirector:getInstance():getWinSize() - menu:setPosition(CCPoint(s.width/2, s.height/2)) + local s = cc.Director:getInstance():getWinSize() + menu:setPosition(cc.p(s.width/2, s.height/2)) menu:setTag( kTagMenu ) ret:addChild(menu, 0, 100+i) - - local x, y = menu:getPosition() - m_centeredMenu = CCPoint(x, y) + local menuPos = menu:getPosition() + local x, y = menuPos.x,menuPos.y + m_centeredMenu = cc.p(x, y) end m_alignedH = true @@ -319,9 +320,9 @@ end -------------------------------------------------------------------- local function MenuLayer3() local m_disabledItem = nil - local ret = CCLayer:create() + local ret = cc.Layer:create() local function menuCallback(sender) - tolua.cast(ret:getParent(), "CCLayerMultiplex"):switchTo(0) + tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(0) end local function menuCallback2(sender) @@ -334,58 +335,55 @@ local function MenuLayer3() cclog("MenuItemSprite clicked") end - CCMenuItemFont:setFontName("Marker Felt") - CCMenuItemFont:setFontSize(28) + cc.MenuItemFont:setFontName("Marker Felt") + cc.MenuItemFont:setFontSize(28) - local label = CCLabelBMFont:create("Enable AtlasItem", "fonts/bitmapFontTest3.fnt") - local item1 = CCMenuItemLabel:create(label) + local label = cc.LabelBMFont:create("Enable AtlasItem", "fonts/bitmapFontTest3.fnt") + local item1 = cc.MenuItemLabel:create(label) item1:registerScriptTapHandler(menuCallback2) - local item2 = CCMenuItemFont:create("--- Go Back ---") + local item2 = cc.MenuItemFont:create("--- Go Back ---") item2:registerScriptTapHandler(menuCallback) - local spriteNormal = CCSprite:create(s_MenuItem, CCRect(0,23*2,115,23)) - local spriteSelected = CCSprite:create(s_MenuItem, CCRect(0,23*1,115,23)) - local spriteDisabled = CCSprite:create(s_MenuItem, CCRect(0,23*0,115,23)) + local spriteNormal = cc.Sprite:create(s_MenuItem, cc.rect(0,23*2,115,23)) + local spriteSelected = cc.Sprite:create(s_MenuItem, cc.rect(0,23*1,115,23)) + local spriteDisabled = cc.Sprite:create(s_MenuItem, cc.rect(0,23*0,115,23)) - local item3 = CCMenuItemSprite:create(spriteNormal, spriteSelected, spriteDisabled) + local item3 = cc.MenuItemSprite:create(spriteNormal, spriteSelected, spriteDisabled) item3:registerScriptTapHandler(menuCallback3) m_disabledItem = item3 item3:retain() m_disabledItem:setEnabled( false ) - local menu = CCMenu:create() + local menu = cc.Menu:create() menu:addChild(item1) menu:addChild(item2) menu:addChild(item3) - menu:setPosition( CCPoint(0,0) ) + menu:setPosition( cc.p(0,0) ) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - item1:setPosition( CCPoint(s.width/2 - 150, s.height/2) ) - item2:setPosition( CCPoint(s.width/2 - 200, s.height/2) ) - item3:setPosition( CCPoint(s.width/2, s.height/2 - 100) ) + item1:setPosition( cc.p(s.width/2 - 150, s.height/2) ) + item2:setPosition( cc.p(s.width/2 - 200, s.height/2) ) + item3:setPosition( cc.p(s.width/2, s.height/2 - 100) ) - local jump = CCJumpBy:create(3, CCPoint(400,0), 50, 4) - local arr = CCArray:create() - arr:addObject(jump) - arr:addObject(jump:reverse()) - item2:runAction( CCRepeatForever:create(CCSequence:create( arr))) + local jump = cc.JumpBy:create(3, cc.p(400,0), 50, 4) + item2:runAction( cc.RepeatForever:create(cc.Sequence:create( jump, jump:reverse()))) - local spin1 = CCRotateBy:create(3, 360) - local spin2 = tolua.cast(spin1:clone(), "CCActionInterval") - local spin3 = tolua.cast(spin1:clone(), "CCActionInterval") + local spin1 = cc.RotateBy:create(3, 360) + local spin2 = tolua.cast(spin1:clone(), "ActionInterval") + local spin3 = tolua.cast(spin1:clone(), "ActionInterval") - item1:runAction( CCRepeatForever:create(spin1) ) - item2:runAction( CCRepeatForever:create(spin2) ) - item3:runAction( CCRepeatForever:create(spin3) ) + item1:runAction( cc.RepeatForever:create(spin1) ) + item2:runAction( cc.RepeatForever:create(spin2) ) + item3:runAction( cc.RepeatForever:create(spin3) ) ret:addChild( menu ) - menu:setPosition(CCPoint(0,0)) + menu:setPosition(cc.p(0,0)) local function onNodeEvent(event) if event == "exit" then @@ -407,70 +405,69 @@ end -- -------------------------------------------------------------------- local function MenuLayer4() - local ret = CCLayer:create() - CCMenuItemFont:setFontName("American Typewriter") - CCMenuItemFont:setFontSize(18) - local title1 = CCMenuItemFont:create("Sound") + local ret = cc.Layer:create() + cc.MenuItemFont:setFontName("American Typewriter") + cc.MenuItemFont:setFontSize(18) + local title1 = cc.MenuItemFont:create("Sound") title1:setEnabled(false) - CCMenuItemFont:setFontName( "Marker Felt" ) - CCMenuItemFont:setFontSize(34) - local item1 = CCMenuItemToggle:create(CCMenuItemFont:create( "On" )) + cc.MenuItemFont:setFontName( "Marker Felt" ) + cc.MenuItemFont:setFontSize(34) + local item1 = cc.MenuItemToggle:create(cc.MenuItemFont:create( "On" )) local function menuCallback(tag, sender) - cclog("selected item: tag: %d, index:%d", tag, tolua.cast(sender, "CCMenuItemToggle"):getSelectedIndex() ) + cclog("selected item: tag: %d, index:%d", tag, tolua.cast(sender, "MenuItemToggle"):getSelectedIndex() ) end local function backCallback(tag, sender) - tolua.cast(ret:getParent(), "CCLayerMultiplex"):switchTo(0) + tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(0) end item1:registerScriptTapHandler(menuCallback) - item1:addSubItem(CCMenuItemFont:create( "Off")) + item1:addSubItem(cc.MenuItemFont:create( "Off")) - CCMenuItemFont:setFontName( "American Typewriter" ) - CCMenuItemFont:setFontSize(18) - local title2 = CCMenuItemFont:create( "Music" ) + cc.MenuItemFont:setFontName( "American Typewriter" ) + cc.MenuItemFont:setFontSize(18) + local title2 = cc.MenuItemFont:create( "Music" ) title2:setEnabled(false) - CCMenuItemFont:setFontName( "Marker Felt" ) - CCMenuItemFont:setFontSize(34) - local item2 = CCMenuItemToggle:create(CCMenuItemFont:create( "On" )) + cc.MenuItemFont:setFontName( "Marker Felt" ) + cc.MenuItemFont:setFontSize(34) + local item2 = cc.MenuItemToggle:create(cc.MenuItemFont:create( "On" )) item2:registerScriptTapHandler(menuCallback) - item2:addSubItem(CCMenuItemFont:create( "Off")) + item2:addSubItem(cc.MenuItemFont:create( "Off")) - CCMenuItemFont:setFontName( "American Typewriter" ) - CCMenuItemFont:setFontSize(18) - local title3 = CCMenuItemFont:create( "Quality" ) + cc.MenuItemFont:setFontName( "American Typewriter" ) + cc.MenuItemFont:setFontSize(18) + local title3 = cc.MenuItemFont:create( "Quality" ) title3:setEnabled( false ) - CCMenuItemFont:setFontName( "Marker Felt" ) - CCMenuItemFont:setFontSize(34) - local item3 = CCMenuItemToggle:create(CCMenuItemFont:create( "High" )) + cc.MenuItemFont:setFontName( "Marker Felt" ) + cc.MenuItemFont:setFontSize(34) + local item3 = cc.MenuItemToggle:create(cc.MenuItemFont:create( "High" )) item3:registerScriptTapHandler(menuCallback) - item3:addSubItem(CCMenuItemFont:create( "Low" )) + item3:addSubItem(cc.MenuItemFont:create( "Low" )) - CCMenuItemFont:setFontName( "American Typewriter" ) - CCMenuItemFont:setFontSize(18) - local title4 = CCMenuItemFont:create( "Orientation" ) + cc.MenuItemFont:setFontName( "American Typewriter" ) + cc.MenuItemFont:setFontSize(18) + local title4 = cc.MenuItemFont:create( "Orientation" ) title4:setEnabled(false) - CCMenuItemFont:setFontName( "Marker Felt" ) - CCMenuItemFont:setFontSize(34) - local item4 = CCMenuItemToggle:create(CCMenuItemFont:create( "Off" )) + cc.MenuItemFont:setFontName( "Marker Felt" ) + cc.MenuItemFont:setFontSize(34) + local item4 = cc.MenuItemToggle:create(cc.MenuItemFont:create( "Off"), + cc.MenuItemFont:create( "33%" ), + cc.MenuItemFont:create( "66%" ), + cc.MenuItemFont:create( "100%")) item4:registerScriptTapHandler(menuCallback) - item4:getSubItems():addObject( CCMenuItemFont:create( "33%" ) ) - item4:getSubItems():addObject( CCMenuItemFont:create( "66%" ) ) - item4:getSubItems():addObject( CCMenuItemFont:create( "100%" ) ) - -- you can change the one of the items by doing this item4:setSelectedIndex( 2 ) - CCMenuItemFont:setFontName( "Marker Felt" ) - CCMenuItemFont:setFontSize( 34 ) + cc.MenuItemFont:setFontName( "Marker Felt" ) + cc.MenuItemFont:setFontSize( 34 ) - local label = CCLabelBMFont:create( "go back", "fonts/bitmapFontTest3.fnt" ) - local back = CCMenuItemLabel:create(label) + local label = cc.LabelBMFont:create( "go back", "fonts/bitmapFontTest3.fnt" ) + local back = cc.MenuItemLabel:create(label) back:registerScriptTapHandler(backCallback) - local menu = CCMenu:create() + local menu = cc.Menu:create() menu:addChild(title1) menu:addChild(title2) @@ -482,30 +479,24 @@ local function MenuLayer4() menu:addChild(item4 ) menu:addChild(back ) - local arr = CCArray:create() - arr:addObject(CCInteger:create(2)) - arr:addObject(CCInteger:create(2)) - arr:addObject(CCInteger:create(2)) - arr:addObject(CCInteger:create(2)) - arr:addObject(CCInteger:create(1)) - menu:alignItemsInColumnsWithArray(arr) + menu:alignItemsInColumns(2, 2, 2, 2, 1) ret:addChild(menu) - local s = CCDirector:getInstance():getWinSize() - menu:setPosition(CCPoint(s.width/2, s.height/2)) + local s = cc.Director:getInstance():getWinSize() + menu:setPosition(cc.p(s.width/2, s.height/2)) return ret end local function MenuLayerPriorityTest() - local ret = CCLayer:create() + local ret = cc.Layer:create() local m_bPriority = false -- Testing empty menu - local m_pMenu1 = CCMenu:create() - local m_pMenu2 = CCMenu:create() + local m_pMenu1 = cc.Menu:create() + local m_pMenu2 = cc.Menu:create() local function menuCallback(tag, pSender) - tolua.cast(ret:getParent(), "CCLayerMultiplex"):switchTo(0) + tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(0) end local function enableMenuCallback() @@ -514,31 +505,28 @@ local function MenuLayerPriorityTest() local function disableMenuCallback(tag, pSender) m_pMenu1:setEnabled(false) - local wait = CCDelayTime:create(5) - local enable = CCCallFunc:create(enableMenuCallback) - local arr = CCArray:create() - arr:addObject(wait) - arr:addObject(enable) - local seq = CCSequence:create(arr) + local wait = cc.DelayTime:create(5) + local enable = cc.CallFunc:create(enableMenuCallback) + local seq = cc.Sequence:create(wait, enable) m_pMenu1:runAction(seq) end local function togglePriorityCallback(tag, pSender) if m_bPriority then - m_pMenu2:setHandlerPriority(kCCMenuHandlerPriority + 20) + m_pMenu2:setHandlerPriority(cc.MENU_HANDLER_PRIORITY + 20) m_bPriority = false else - m_pMenu2:setHandlerPriority(kCCMenuHandlerPriority - 20) + m_pMenu2:setHandlerPriority(cc.MENU_HANDLER_PRIORITY - 20) m_bPriority = true end end -- Menu 1 - CCMenuItemFont:setFontName("Marker Felt") - CCMenuItemFont:setFontSize(18) - local item1 = CCMenuItemFont:create("Return to Main Menu") + cc.MenuItemFont:setFontName("Marker Felt") + cc.MenuItemFont:setFontSize(18) + local item1 = cc.MenuItemFont:create("Return to Main Menu") item1:registerScriptTapHandler(menuCallback) - local item2 = CCMenuItemFont:create("Disable menu for 5 seconds") + local item2 = cc.MenuItemFont:create("Disable menu for 5 seconds") item2:registerScriptTapHandler(disableMenuCallback) m_pMenu1:addChild(item1) @@ -550,10 +538,10 @@ local function MenuLayerPriorityTest() -- Menu 2 m_bPriority = true - CCMenuItemFont:setFontSize(48) - item1 = CCMenuItemFont:create("Toggle priority") + cc.MenuItemFont:setFontSize(48) + item1 = cc.MenuItemFont:create("Toggle priority") item2:registerScriptTapHandler(togglePriorityCallback) - item1:setColor(Color3B(0,0,255)) + item1:setColor(cc.c3b(0,0,255)) m_pMenu2:addChild(item1) ret:addChild(m_pMenu2) return ret @@ -562,78 +550,78 @@ end -- BugsTest local function BugsTest() - local ret = CCLayer:create() + local ret = cc.Layer:create() local function issue1410MenuCallback(tag, pSender) - local menu = tolua.cast(pSender:getParent(), "CCMenu") + local menu = tolua.cast(pSender:getParent(), "Menu") menu:setTouchEnabled(false) menu:setTouchEnabled(true) cclog("NO CRASHES") end local function issue1410v2MenuCallback(tag, pSender) - local menu = tolua.cast(pSender:getParent(), "CCMenu") + local menu = tolua.cast(pSender:getParent(), "Menu") menu:setTouchEnabled(true) menu:setTouchEnabled(false) cclog("NO CRASHES. AND MENU SHOULD STOP WORKING") end local function backMenuCallback(tag, pSender) - tolua.cast(ret:getParent(), "CCLayerMultiplex"):switchTo(0) + tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(0) end - local issue1410 = CCMenuItemFont:create("Issue 1410") + local issue1410 = cc.MenuItemFont:create("Issue 1410") issue1410:registerScriptTapHandler(issue1410MenuCallback) - local issue1410_2 = CCMenuItemFont:create("Issue 1410 #2") + local issue1410_2 = cc.MenuItemFont:create("Issue 1410 #2") issue1410_2:registerScriptTapHandler(issue1410v2MenuCallback) - local back = CCMenuItemFont:create("Back") + local back = cc.MenuItemFont:create("Back") back:registerScriptTapHandler(backMenuCallback) - local menu = CCMenu:create() + local menu = cc.Menu:create() menu:addChild(issue1410) menu:addChild(issue1410_2) menu:addChild(back) ret:addChild(menu) menu:alignItemsVertically() - local s = CCDirector:getInstance():getWinSize() - menu:setPosition(CCPoint(s.width/2, s.height/2)) + local s = cc.Director:getInstance():getWinSize() + menu:setPosition(cc.p(s.width/2, s.height/2)) return ret end local function RemoveMenuItemWhenMove() - local ret = CCLayer:create() - local s = CCDirector:getInstance():getWinSize() + local ret = cc.Layer:create() + local s = cc.Director:getInstance():getWinSize() - local label = CCLabelTTF:create("click item and move, should not crash", "Arial", 20) - label:setPosition(CCPoint(s.width/2, s.height - 30)) + local label = cc.LabelTTF:create("click item and move, should not crash", "Arial", 20) + label:setPosition(cc.p(s.width/2, s.height - 30)) ret:addChild(label) - local item = CCMenuItemFont:create("item 1") + local item = cc.MenuItemFont:create("item 1") item:retain() - local back = CCMenuItemFont:create("go back") + local back = cc.MenuItemFont:create("go back") local function goBack(tag, pSender) - tolua.cast(ret:getParent(), "CCLayerMultiplex"):switchTo(0) + tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(0) end back:registerScriptTapHandler(goBack) - local menu = CCMenu:create() + local menu = cc.Menu:create() menu:addChild(item) menu:addChild(back) ret:addChild(menu) menu:alignItemsVertically() - menu:setPosition(CCPoint(s.width/2, s.height/2)) + menu:setPosition(cc.p(s.width/2, s.height/2)) ret:setTouchEnabled(true) --[[ local function onNodeEvent(event) if event == "enter" then - CCDirector:getInstance():getTouchDispatcher():addTargetedDelegate(ret, -129, false) + cc.Director:getInstance():getTouchDispatcher():addTargetedDelegate(ret, -129, false) elseif event == "exit" then -- item:release() end @@ -647,7 +635,7 @@ local function RemoveMenuItemWhenMove() return true elseif eventType == "moved" then if item ~= nil then - item:removeFromParentAndCleanup(true) + item:removeFromParent(true) --item:release() --item = nil end @@ -660,7 +648,7 @@ end function MenuTestMain() cclog("MenuTestMain") - local scene = CCScene:create() + local scene = cc.Scene:create() local pLayer1 = MenuLayerMainMenu() local pLayer2 = MenuLayer2() @@ -671,17 +659,13 @@ function MenuTestMain() local pLayer6 = BugsTest() local pLayer7 = RemoveMenuItemWhenMove() - - local arr = CCArray:create() - arr:addObject(pLayer1) - arr:addObject(pLayer2) - arr:addObject(pLayer3) - arr:addObject(pLayer4) - arr:addObject(pLayer5) - arr:addObject(pLayer6) - arr:addObject(pLayer7) - - local layer = CCLayerMultiplex:createWithArray(arr) + local layer = cc.LayerMultiplex:create(pLayer1, + pLayer2, + pLayer3, + pLayer4, + pLayer5, + pLayer6, + pLayer7) scene:addChild(layer, 0) scene:addChild(CreateBackMenuItem()) diff --git a/samples/Lua/TestLua/Resources/luaScript/MotionStreakTest/MotionStreakTest.lua b/samples/Lua/TestLua/Resources/luaScript/MotionStreakTest/MotionStreakTest.lua index b4458da4dc..60cd559053 100644 --- a/samples/Lua/TestLua/Resources/luaScript/MotionStreakTest/MotionStreakTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/MotionStreakTest/MotionStreakTest.lua @@ -3,8 +3,8 @@ local streak = nil local titleLabel = nil local subtitleLabel = nil -local s = CCDirector:getInstance():getWinSize() -local scheduler = CCDirector:getInstance():getScheduler() +local s = cc.Director:getInstance():getWinSize() +local scheduler = cc.Director:getInstance():getScheduler() local firstTick = nil @@ -18,14 +18,14 @@ local function modeCallback(sender) end local function getBaseLayer() - local layer = CCLayer:create() + local layer = cc.Layer:create() - local itemMode = CCMenuItemToggle:create(CCMenuItemFont:create("Use High Quality Mode")) - itemMode:addSubItem(CCMenuItemFont:create("Use Fast Mode")) + local itemMode = cc.MenuItemToggle:create(cc.MenuItemFont:create("Use High Quality Mode")) + itemMode:addSubItem(cc.MenuItemFont:create("Use Fast Mode")) itemMode:registerScriptTapHandler(modeCallback) - local menuMode = CCMenu:create() + local menuMode = cc.Menu:create() menuMode:addChild(itemMode) - menuMode:setPosition(CCPoint(s.width / 2, s.height / 4)) + menuMode:setPosition(cc.p(s.width / 2, s.height / 4)) layer:addChild(menuMode) Helper.initWithLayer(layer) @@ -47,7 +47,7 @@ local function MotionStreakTest1_update(dt) return end - streak:setPosition(target:convertToWorldSpace(CCPoint(0, 0))) + streak:setPosition(target:convertToWorldSpace(cc.p(0, 0))) end local function MotionStreakTest1_onEnterOrExit(tag) @@ -61,32 +61,30 @@ end local function MotionStreakTest1() local layer = getBaseLayer() - root = CCSprite:create(s_pPathR1) + root = cc.Sprite:create(s_pPathR1) layer:addChild(root, 1) - root:setPosition(CCPoint(s.width / 2, s.height / 2)) + root:setPosition(cc.p(s.width / 2, s.height / 2)) - target = CCSprite:create(s_pPathR1) + target = cc.Sprite:create(s_pPathR1) root:addChild(target) - target:setPosition(CCPoint(s.width / 4, 0)) + target:setPosition(cc.p(s.width / 4, 0)) - streak = CCMotionStreak:create(2, 3, 32, Color3B(0, 255, 0), s_streak) + streak = cc.MotionStreak:create(2, 3, 32, cc.c3b(0, 255, 0), s_streak) layer:addChild(streak) - local a1 = CCRotateBy:create(2, 360) + local a1 = cc.RotateBy:create(2, 360) - local action1 = CCRepeatForever:create(a1) - local motion = CCMoveBy:create(2, CCPoint(100,0)) - root:runAction(CCRepeatForever:create(CCSequence:createWithTwoActions(motion, motion:reverse()))) + local action1 = cc.RepeatForever:create(a1) + local motion = cc.MoveBy:create(2, cc.p(100,0)) + root:runAction(cc.RepeatForever:create(cc.Sequence:create(motion, motion:reverse()))) root:runAction(action1) - local array = CCArray:create() - array:addObject(CCTintTo:create(0.2, 255, 0, 0)) - array:addObject(CCTintTo:create(0.2, 0, 255, 0)) - array:addObject(CCTintTo:create(0.2, 0, 0, 255)) - array:addObject(CCTintTo:create(0.2, 0, 255, 255)) - array:addObject(CCTintTo:create(0.2, 255, 255, 0)) - array:addObject(CCTintTo:create(0.2, 255, 255, 255)) - local colorAction = CCRepeatForever:create(CCSequence:create(array)) + local colorAction = cc.RepeatForever:create(cc.Sequence:create(cc.TintTo:create(0.2, 255, 0, 0), + cc.TintTo:create(0.2, 0, 255, 0), + cc.TintTo:create(0.2, 0, 0, 255), + cc.TintTo:create(0.2, 0, 255, 255), + cc.TintTo:create(0.2, 255, 255, 0), + cc.TintTo:create(0.2, 255, 255, 255))) streak:runAction(colorAction) @@ -103,10 +101,10 @@ end local function MotionStreakTest2() local layer = getBaseLayer() - streak = CCMotionStreak:create(3, 3, 64, Color3B(255, 255, 255), s_streak) + streak = cc.MotionStreak:create(3, 3, 64, cc.c3b(255, 255, 255), s_streak) layer:addChild(streak) - streak:setPosition(CCPoint(s.width / 2, s.height / 2)) + streak:setPosition(cc.p(s.width / 2, s.height / 2)) local function onTouchMoved(x, y) if firstTick == true then @@ -114,7 +112,7 @@ local function MotionStreakTest2() return end - streak:setPosition(CCPoint(x, y)) + streak:setPosition(cc.p(x, y)) end local function onTouch(eventType, x, y) @@ -149,7 +147,7 @@ local function Issue1358_update(dt) end fAngle = fAngle + 1.0 streak:setPosition( - CCPoint(center.x + math.cos(fAngle / 180 * math.pi) * fRadius, center.y + math.sin(fAngle/ 180 * math.pi) * fRadius)) + cc.p(center.x + math.cos(fAngle / 180 * math.pi) * fRadius, center.y + math.sin(fAngle/ 180 * math.pi) * fRadius)) end local function Issue1358_onEnterOrExit(tag) @@ -163,10 +161,10 @@ end local function Issue1358() local layer = getBaseLayer() - streak = CCMotionStreak:create(2.0, 1.0, 50.0, Color3B(255, 255, 0), "Images/Icon.png") + streak = cc.MotionStreak:create(2.0, 1.0, 50.0, cc.c3b(255, 255, 0), "Images/Icon.png") layer:addChild(streak) - center = CCPoint(s.width / 2, s.height / 2) + center = cc.p(s.width / 2, s.height / 2) fRadius = s.width / 3 fAngle = 0 @@ -179,7 +177,7 @@ local function Issue1358() end function MotionStreakTest() - local scene = CCScene:create() + local scene = cc.Scene:create() Helper.createFunctionTable = { MotionStreakTest1, diff --git a/samples/Lua/TestLua/Resources/luaScript/NodeTest/NodeTest.lua b/samples/Lua/TestLua/Resources/luaScript/NodeTest/NodeTest.lua index 22d7f28c87..54e27c2682 100644 --- a/samples/Lua/TestLua/Resources/luaScript/NodeTest/NodeTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/NodeTest/NodeTest.lua @@ -3,11 +3,11 @@ local kTagSprite2 = 2 local kTagSprite3 = 3 local kTagSlider = 4 -local s = CCDirector:getInstance():getWinSize() -local scheduler = CCDirector:getInstance():getScheduler() +local s = cc.Director:getInstance():getWinSize() +local scheduler = cc.Director:getInstance():getScheduler() local function getBaseLayer() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) @@ -21,50 +21,50 @@ local function CameraCenterTest() local layer = getBaseLayer() -- LEFT-TOP - local sprite = CCSprite:create("Images/white-512x512.png") + local sprite = cc.Sprite:create("Images/white-512x512.png") layer:addChild(sprite, 0) - sprite:setPosition(CCPoint(s.width / 5 * 1, s.height / 5 * 1)) - sprite:setColor(Color3B(255, 0, 0)) - sprite:setTextureRect(CCRect(0, 0, 120, 50)) - local orbit = CCOrbitCamera:create(10, 1, 0, 0, 360, 0, 0) - sprite:runAction(CCRepeatForever:create(orbit)) - -- [sprite setAnchorPoint: CCPoint(0,1)) + sprite:setPosition(cc.p(s.width / 5 * 1, s.height / 5 * 1)) + sprite:setColor(cc.c3b(255, 0, 0)) + sprite:setTextureRect(cc.rect(0, 0, 120, 50)) + local orbit = cc.OrbitCamera:create(10, 1, 0, 0, 360, 0, 0) + sprite:runAction(cc.RepeatForever:create(orbit)) + -- [sprite setAnchorPoint: cc.p(0,1)) -- LEFT-BOTTOM - sprite = CCSprite:create("Images/white-512x512.png") + sprite = cc.Sprite:create("Images/white-512x512.png") layer:addChild(sprite, 0, 40) - sprite:setPosition(CCPoint(s.width / 5 * 1, s.height / 5 * 4)) - sprite:setColor(Color3B(0, 0, 255)) - sprite:setTextureRect(CCRect(0, 0, 120, 50)) - orbit = CCOrbitCamera:create(10, 1, 0, 0, 360, 0, 0) - sprite:runAction(CCRepeatForever:create(orbit)) + sprite:setPosition(cc.p(s.width / 5 * 1, s.height / 5 * 4)) + sprite:setColor(cc.c3b(0, 0, 255)) + sprite:setTextureRect(cc.rect(0, 0, 120, 50)) + orbit = cc.OrbitCamera:create(10, 1, 0, 0, 360, 0, 0) + sprite:runAction(cc.RepeatForever:create(orbit)) -- RIGHT-TOP - sprite = CCSprite:create("Images/white-512x512.png") + sprite = cc.Sprite:create("Images/white-512x512.png") layer:addChild(sprite, 0) - sprite:setPosition(CCPoint(s.width / 5 * 4, s.height / 5 * 1)) - sprite:setColor(Color3B(255, 255, 0)) - sprite:setTextureRect(CCRect(0, 0, 120, 50)) - orbit = CCOrbitCamera:create(10, 1, 0, 0, 360, 0, 0) - sprite:runAction(CCRepeatForever:create(orbit)) + sprite:setPosition(cc.p(s.width / 5 * 4, s.height / 5 * 1)) + sprite:setColor(cc.c3b(255, 255, 0)) + sprite:setTextureRect(cc.rect(0, 0, 120, 50)) + orbit = cc.OrbitCamera:create(10, 1, 0, 0, 360, 0, 0) + sprite:runAction(cc.RepeatForever:create(orbit)) -- RIGHT-BOTTOM - sprite = CCSprite:create("Images/white-512x512.png") + sprite = cc.Sprite:create("Images/white-512x512.png") layer:addChild(sprite, 0, 40) - sprite:setPosition(CCPoint(s.width / 5 * 4, s.height / 5 * 4)) - sprite:setColor(Color3B(0, 255, 0)) - sprite:setTextureRect(CCRect(0, 0, 120, 50)) - orbit = CCOrbitCamera:create(10, 1, 0, 0, 360, 0, 0) - sprite:runAction(CCRepeatForever:create(orbit)) + sprite:setPosition(cc.p(s.width / 5 * 4, s.height / 5 * 4)) + sprite:setColor(cc.c3b(0, 255, 0)) + sprite:setTextureRect(cc.rect(0, 0, 120, 50)) + orbit = cc.OrbitCamera:create(10, 1, 0, 0, 360, 0, 0) + sprite:runAction(cc.RepeatForever:create(orbit)) -- CENTER - sprite = CCSprite:create("Images/white-512x512.png") + sprite = cc.Sprite:create("Images/white-512x512.png") layer:addChild(sprite, 0, 40) - sprite:setPosition(CCPoint(s.width / 2, s.height / 2)) - sprite:setColor(Color3B(255, 255, 255)) - sprite:setTextureRect(CCRect(0, 0, 120, 50)) - orbit = CCOrbitCamera:create(10, 1, 0, 0, 360, 0, 0) - sprite:runAction(CCRepeatForever:create(orbit)) + sprite:setPosition(cc.p(s.width / 2, s.height / 2)) + sprite:setColor(cc.c3b(255, 255, 255)) + sprite:setTextureRect(cc.rect(0, 0, 120, 50)) + orbit = cc.OrbitCamera:create(10, 1, 0, 0, 360, 0, 0) + sprite:runAction(cc.RepeatForever:create(orbit)) Helper.titleLabel:setString("Camera Center test") Helper.subtitleLabel:setString("Sprites should rotate at the same speed") @@ -77,13 +77,13 @@ end local function Test2() local layer = getBaseLayer() - local sp1 = CCSprite:create(s_pPathSister1) - local sp2 = CCSprite:create(s_pPathSister2) - local sp3 = CCSprite:create(s_pPathSister1) - local sp4 = CCSprite:create(s_pPathSister2) + local sp1 = cc.Sprite:create(s_pPathSister1) + local sp2 = cc.Sprite:create(s_pPathSister2) + local sp3 = cc.Sprite:create(s_pPathSister1) + local sp4 = cc.Sprite:create(s_pPathSister2) - sp1:setPosition(CCPoint(100, s.height /2)) - sp2:setPosition(CCPoint(380, s.height /2)) + sp1:setPosition(cc.p(100, s.height /2)) + sp2:setPosition(cc.p(380, s.height /2)) layer:addChild(sp1) layer:addChild(sp2) @@ -92,22 +92,13 @@ local function Test2() sp1:addChild(sp3) sp2:addChild(sp4) - local a1 = CCRotateBy:create(2, 360) - local a2 = CCScaleBy:create(2, 2) + local a1 = cc.RotateBy:create(2, 360) + local a2 = cc.ScaleBy:create(2, 2) - local array1 = CCArray:create() - array1:addObject(a1) - array1:addObject(a2) - array1:addObject(a2:reverse()) - local action1 = CCRepeatForever:create(CCSequence:create(array1)) + local action1 = cc.RepeatForever:create(cc.Sequence:create(a1, a2, a2:reverse())) + local action2 = cc.RepeatForever:create(cc.Sequence:create(a1:clone(), a2:clone(), a2:reverse())) - local array2 = CCArray:create() - array2:addObject(a1:clone()) - array2:addObject(a2:clone()) - array2:addObject(a2:reverse()) - local action2 = CCRepeatForever:create(CCSequence:create(array2)) - - sp2:setAnchorPoint(CCPoint(0,0)) + sp2:setAnchorPoint(cc.p(0,0)) sp1:runAction(action1) sp2:runAction(action2) @@ -125,7 +116,7 @@ local Test4_delay4Entry = nil local function delay2(dt) node = Test4_layer:getChildByTag(2) - local action1 = CCRotateBy:create(1, 360) + local action1 = cc.RotateBy:create(1, 360) node:runAction(action1) end @@ -147,10 +138,10 @@ end local function Test4() Test4_layer = getBaseLayer() - local sp1 = CCSprite:create(s_pPathSister1) - local sp2 = CCSprite:create(s_pPathSister2) - sp1:setPosition(CCPoint(100, 160)) - sp2:setPosition(CCPoint(380, 160)) + local sp1 = cc.Sprite:create(s_pPathSister1) + local sp2 = cc.Sprite:create(s_pPathSister2) + sp1:setPosition(cc.p(100, 160)) + sp2:setPosition(cc.p(380, 160)) Test4_layer:addChild(sp1, 0, 2) Test4_layer:addChild(sp2, 0, 3) @@ -195,19 +186,19 @@ end local function Test5() Test5_layer = getBaseLayer() - local sp1 = CCSprite:create(s_pPathSister1) - local sp2 = CCSprite:create(s_pPathSister2) + local sp1 = cc.Sprite:create(s_pPathSister1) + local sp2 = cc.Sprite:create(s_pPathSister2) - sp1:setPosition(CCPoint(100, 160)) - sp2:setPosition(CCPoint(380, 160)) + sp1:setPosition(cc.p(100, 160)) + sp2:setPosition(cc.p(380, 160)) - local rot = CCRotateBy:create(2, 360) + local rot = cc.RotateBy:create(2, 360) local rot_back = rot:reverse() - local forever = CCRepeatForever:create(CCSequence:createWithTwoActions(rot, rot_back)) + local forever = cc.RepeatForever:create(cc.Sequence:create(rot, rot_back)) - local rot2 = CCRotateBy:create(2, 360) + local rot2 = cc.RotateBy:create(2, 360) local rot2_back = rot2:reverse() - local forever2 = CCRepeatForever:create(CCSequence:createWithTwoActions(rot2, rot2_back)) + local forever2 = cc.RepeatForever:create(cc.Sequence:create(rot2, rot2_back)) forever:setTag(101) forever2:setTag(102) @@ -258,22 +249,22 @@ end local function Test6() Test6_layer = getBaseLayer() - local sp1 = CCSprite:create(s_pPathSister1) - local sp11 = CCSprite:create(s_pPathSister1) + local sp1 = cc.Sprite:create(s_pPathSister1) + local sp11 = cc.Sprite:create(s_pPathSister1) - local sp2 = CCSprite:create(s_pPathSister2) - local sp21 = CCSprite:create(s_pPathSister2) + local sp2 = cc.Sprite:create(s_pPathSister2) + local sp21 = cc.Sprite:create(s_pPathSister2) - sp1:setPosition(CCPoint(100, 160)) - sp2:setPosition(CCPoint(380, 160)) + sp1:setPosition(cc.p(100, 160)) + sp2:setPosition(cc.p(380, 160)) - local rot = CCRotateBy:create(2, 360) + local rot = cc.RotateBy:create(2, 360) local rot_back = rot:reverse() - local forever1 = CCRepeatForever:create(CCSequence:createWithTwoActions(rot, rot_back)) - local forever11 = tolua.cast(forever1:clone(), "CCRepeatForever") + local forever1 = cc.RepeatForever:create(cc.Sequence:create(rot, rot_back)) + local forever11 = tolua.cast(forever1:clone(), "RepeatForever") - local forever2 = tolua.cast(forever1:clone(), "CCRepeatForever") - local forever21 = tolua.cast(forever1:clone(), "CCRepeatForever") + local forever2 = tolua.cast(forever1:clone(), "RepeatForever") + local forever21 = tolua.cast(forever1:clone(), "RepeatForever") Test6_layer:addChild(sp1, 0, kTagSprite1) sp1:addChild(sp11) @@ -307,14 +298,14 @@ local function shouldNotCrash(dt) scheduler:unscheduleScriptEntry(StressTest1_entry) -- if the node has timers, it crashes - local explosion = CCParticleSun:create() - explosion:setTexture(CCTextureCache:getInstance():addImage("Images/fire.png")) + local explosion = cc.ParticleSun:create() + explosion:setTexture(cc.TextureCache:getInstance():addImage("Images/fire.png")) explosion:setPosition(s.width / 2, s.height / 2) - StressTest1_layer:setAnchorPoint(CCPoint(0, 0)) - local callFunc = CCCallFunc:create(removeMe) - StressTest1_layer:runAction(CCSequence:createWithTwoActions(CCRotateBy:create(2, 360), callFunc)) + StressTest1_layer:setAnchorPoint(cc.p(0, 0)) + local callFunc = cc.CallFunc:create(removeMe) + StressTest1_layer:runAction(cc.Sequence:create(cc.RotateBy:create(2, 360), callFunc)) StressTest1_layer:addChild(explosion) end @@ -330,10 +321,10 @@ end local function StressTest1() StressTest1_layer = getBaseLayer() - sp1 = CCSprite:create(s_pPathSister1) + sp1 = cc.Sprite:create(s_pPathSister1) StressTest1_layer:addChild(sp1, 0, kTagSprite1) - sp1:setPosition(CCPoint(s.width / 2, s.height / 2)) + sp1:setPosition(cc.p(s.width / 2, s.height / 2)) StressTest1_layer:registerScriptHandler(StressTest1_onEnterOrExit) @@ -365,25 +356,25 @@ end local function StressTest2() StressTest2_layer = getBaseLayer() - sublayer = CCLayer:create() + sublayer = cc.Layer:create() - local sp1 = CCSprite:create(s_pPathSister1) - sp1:setPosition(CCPoint(80, s.height / 2)) + local sp1 = cc.Sprite:create(s_pPathSister1) + sp1:setPosition(cc.p(80, s.height / 2)) - local move = CCMoveBy:create(3, CCPoint(350, 0)) - local move_ease_inout3 = CCEaseInOut:create(CCMoveBy:create(3, CCPoint(350, 0)), 2.0) + local move = cc.MoveBy:create(3, cc.p(350, 0)) + local move_ease_inout3 = cc.EaseInOut:create(cc.MoveBy:create(3, cc.p(350, 0)), 2.0) local move_ease_inout_back3 = move_ease_inout3:reverse() - local seq3 = CCSequence:createWithTwoActions(move_ease_inout3, move_ease_inout_back3) - sp1:runAction(CCRepeatForever:create(seq3)) + local seq3 = cc.Sequence:create(move_ease_inout3, move_ease_inout_back3) + sp1:runAction(cc.RepeatForever:create(seq3)) sublayer:addChild(sp1, 1) - local fire = CCParticleFire:create() - fire:setTexture(CCTextureCache:getInstance():addImage("Images/fire.png")) - fire = tolua.cast(fire, "CCNode") + local fire = cc.ParticleFire:create() + fire:setTexture(cc.TextureCache:getInstance():addImage("Images/fire.png")) + fire = tolua.cast(fire, "Node") fire:setPosition(80, s.height / 2 - 50) - local copy_seq3 = tolua.cast(seq3:clone(), "CCSequence") - fire:runAction(CCRepeatForever:create(copy_seq3)) + local copy_seq3 = tolua.cast(seq3:clone(), "Sequence") + fire:runAction(cc.RepeatForever:create(copy_seq3)) sublayer:addChild(fire, 2) StressTest2_layer:registerScriptHandler(StressTest2_onEnterOrExit) @@ -404,26 +395,26 @@ local function NodeToWorld() -- - It tests different anchor Points -- - It tests different children anchor points - local back = CCSprite:create(s_back3) + local back = cc.Sprite:create(s_back3) layer:addChild(back, -10) - back:setAnchorPoint(CCPoint(0, 0)) + back:setAnchorPoint(cc.p(0, 0)) local backSize = back:getContentSize() - local item = CCMenuItemImage:create(s_PlayNormal, s_PlaySelect) - local menu = CCMenu:create() + local item = cc.MenuItemImage:create(s_PlayNormal, s_PlaySelect) + local menu = cc.Menu:create() menu:addChild(item) menu:alignItemsVertically() - menu:setPosition(CCPoint(backSize.width / 2, backSize.height / 2)) + menu:setPosition(cc.p(backSize.width / 2, backSize.height / 2)) back:addChild(menu) - local rot = CCRotateBy:create(5, 360) - local fe = CCRepeatForever:create(rot) + local rot = cc.RotateBy:create(5, 360) + local fe = cc.RepeatForever:create(rot) item:runAction(fe) - local move = CCMoveBy:create(3, CCPoint(200, 0)) + local move = cc.MoveBy:create(3, cc.p(200, 0)) local move_back = move:reverse() - local seq = CCSequence:createWithTwoActions(move, move_back) - local fe2 = CCRepeatForever:create(seq) + local seq = cc.Sequence:create(move, move_back) + local fe2 = cc.RepeatForever:create(seq) back:runAction(fe2) Helper.titleLabel:setString("nodeToParent transform") @@ -435,50 +426,50 @@ end ----------------------------------- local function CameraOrbitTest_onEnterOrExit(tag) if tag == "enter" then - CCDirector:getInstance():setProjection(kCCDirectorProjection3D) + cc.Director:getInstance():setProjection(cc.DIRECTOR_PROJECTION3_D) elseif tag == "exit" then - CCDirector:getInstance():setProjection(kCCDirectorProjection2D) + cc.Director:getInstance():setProjection(cc.DIRECTOR_PROJECTION2_D) end end local function CameraOrbitTest() local layer = getBaseLayer() - local p = CCSprite:create(s_back3) + local p = cc.Sprite:create(s_back3) layer:addChild(p, 0) - p:setPosition(CCPoint(s.width / 2, s.height / 2)) + p:setPosition(cc.p(s.width / 2, s.height / 2)) p:setOpacity(128) -- LEFT local s = p:getContentSize() - local sprite = CCSprite:create(s_pPathGrossini) + local sprite = cc.Sprite:create(s_pPathGrossini) sprite:setScale(0.5) p:addChild(sprite, 0) - sprite:setPosition(CCPoint(s.width / 4 * 1, s.height / 2)) + sprite:setPosition(cc.p(s.width / 4 * 1, s.height / 2)) local cam = sprite:getCamera() - local orbit = CCOrbitCamera:create(2, 1, 0, 0, 360, 0, 0) - sprite:runAction(CCRepeatForever:create(orbit)) + local orbit = cc.OrbitCamera:create(2, 1, 0, 0, 360, 0, 0) + sprite:runAction(cc.RepeatForever:create(orbit)) -- CENTER - sprite = CCSprite:create(s_pPathGrossini) + sprite = cc.Sprite:create(s_pPathGrossini) sprite:setScale(1.0) p:addChild(sprite, 0) - sprite:setPosition(CCPoint(s.width / 4 * 2, s.height / 2)) - orbit = CCOrbitCamera:create(2, 1, 0, 0, 360, 45, 0) - sprite:runAction(CCRepeatForever:create(orbit)) + sprite:setPosition(cc.p(s.width / 4 * 2, s.height / 2)) + orbit = cc.OrbitCamera:create(2, 1, 0, 0, 360, 45, 0) + sprite:runAction(cc.RepeatForever:create(orbit)) -- RIGHT - sprite = CCSprite:create(s_pPathGrossini) + sprite = cc.Sprite:create(s_pPathGrossini) sprite:setScale(2.0) p:addChild(sprite, 0) - sprite:setPosition(CCPoint(s.width / 4 * 3, s.height / 2)) + sprite:setPosition(cc.p(s.width / 4 * 3, s.height / 2)) local ss = sprite:getContentSize() - orbit = CCOrbitCamera:create(2, 1, 0, 0, 360, 90, -45) - sprite:runAction(CCRepeatForever:create(orbit)) + orbit = cc.OrbitCamera:create(2, 1, 0, 0, 360, 90, -45) + sprite:runAction(cc.RepeatForever:create(orbit)) -- PARENT - orbit = CCOrbitCamera:create(10, 1, 0, 0, 360, 0, 90) - p:runAction(CCRepeatForever:create(orbit)) + orbit = cc.OrbitCamera:create(10, 1, 0, 0, 360, 0, 90) + p:runAction(cc.RepeatForever:create(orbit)) layer:setScale(1) @@ -498,19 +489,19 @@ local function CameraZoomTest_update(dt) local sprite = CameraZoomTest_layer:getChildByTag(20) local cam = sprite:getCamera() - cam:setEyeXYZ(0, 0, z) + cam:setEye(0, 0, z) sprite = CameraZoomTest_layer:getChildByTag(40) cam = sprite:getCamera() - cam:setEyeXYZ(0, 0, -z) + cam:setEye(0, 0, -z) end local function CameraZoomTest_onEnterOrExit(tag) if tag == "enter" then - CCDirector:getInstance():setProjection(kCCDirectorProjection3D) + cc.Director:getInstance():setProjection(cc.DIRECTOR_PROJECTION3_D) CameraZoomTest_entry = scheduler:scheduleScriptFunc(CameraZoomTest_update, 0.0, false) elseif tag == "exit" then - CCDirector:getInstance():setProjection(kCCDirectorProjection2D) + cc.Director:getInstance():setProjection(cc.DIRECTOR_PROJECTION2_D) scheduler:unscheduleScriptEntry(CameraZoomTest_entry) end end @@ -521,22 +512,22 @@ local function CameraZoomTest() z = 0 -- LEFT - local sprite = CCSprite:create(s_pPathGrossini) + local sprite = cc.Sprite:create(s_pPathGrossini) CameraZoomTest_layer:addChild(sprite, 0) - sprite:setPosition(CCPoint(s.width / 4 * 1, s.height / 2)) + sprite:setPosition(cc.p(s.width / 4 * 1, s.height / 2)) local cam = sprite:getCamera() - cam:setEyeXYZ(0, 0, 415 / 2) - cam:setCenterXYZ(0, 0, 0) + cam:setEye(0, 0, 415 / 2) + cam:setCenter(0, 0, 0) -- CENTER - sprite = CCSprite:create(s_pPathGrossini) + sprite = cc.Sprite:create(s_pPathGrossini) CameraZoomTest_layer:addChild(sprite, 0, 40) - sprite:setPosition(CCPoint(s.width / 4 * 2, s.height / 2)) + sprite:setPosition(cc.p(s.width / 4 * 2, s.height / 2)) -- RIGHT - sprite = CCSprite:create(s_pPathGrossini) + sprite = cc.Sprite:create(s_pPathGrossini) CameraZoomTest_layer:addChild(sprite, 0, 20) - sprite:setPosition(CCPoint(s.width / 4 * 3, s.height / 2)) + sprite:setPosition(cc.p(s.width / 4 * 3, s.height / 2)) CameraZoomTest_layer:scheduleUpdateWithPriorityLua(CameraZoomTest_update, 0) CameraZoomTest_layer:registerScriptHandler(CameraZoomTest_onEnterOrExit) @@ -553,28 +544,28 @@ local ConvertToNode_layer = nil local function ConvertToNode() ConvertToNode_layer = getBaseLayer() - local rotate = CCRotateBy:create(10, 360) - local action = CCRepeatForever:create(rotate) + local rotate = cc.RotateBy:create(10, 360) + local action = cc.RepeatForever:create(rotate) for i = 0, 2 do - local sprite = CCSprite:create("Images/grossini.png") - sprite:setPosition(CCPoint(s.width / 4 * (i + 1), s.height / 2)) + local sprite = cc.Sprite:create("Images/grossini.png") + sprite:setPosition(cc.p(s.width / 4 * (i + 1), s.height / 2)) - local point = CCSprite:create("Images/r1.png") + local point = cc.Sprite:create("Images/r1.png") point:setScale(0.25) point:setPosition(sprite:getPosition()) ConvertToNode_layer:addChild(point, 10, 100 + i) if i == 0 then - sprite:setAnchorPoint(CCPoint(0, 0)) + sprite:setAnchorPoint(cc.p(0, 0)) elseif i == 1 then - sprite:setAnchorPoint(CCPoint(0.5, 0.5)) + sprite:setAnchorPoint(cc.p(0.5, 0.5)) elseif i == 2 then - sprite:setAnchorPoint(CCPoint(1,1)) + sprite:setAnchorPoint(cc.p(1,1)) end point:setPosition(sprite:getPosition()) - local copy = tolua.cast(action:clone(), "CCRepeatForever") + local copy = tolua.cast(action:clone(), "RepeatForever") sprite:runAction(copy) ConvertToNode_layer:addChild(sprite, i) end @@ -583,8 +574,8 @@ local function ConvertToNode() for i = 0, 2 do local node = ConvertToNode_layer:getChildByTag(100 + i) local p1, p2 - p1 = node:convertToNodeSpaceAR(CCPoint(x, y)) - p2 = node:convertToNodeSpace(CCPoint(x, y)) + p1 = node:convertToNodeSpaceAR(cc.p(x, y)) + p2 = node:convertToNodeSpace(cc.p(x, y)) cclog("AR: x=" .. p1.x .. ", y=" .. p1.y .. " -- Not AR: x=" .. p2.x .. ", y=" .. p2.y) end @@ -613,12 +604,9 @@ local function NodeOpaqueTest() local layer = getBaseLayer() for i = 0, 49 do - local background = CCSprite:create("Images/background1.png") - local blendFunc = BlendFunc:new() - blendFunc.src = GL_ONE - blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA - background:setBlendFunc(blendFunc) - background:setAnchorPoint(CCPoint(0, 0)) + local background = cc.Sprite:create("Images/background1.png") + background:setBlendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA) + background:setAnchorPoint(cc.p(0, 0)) layer:addChild(background) end @@ -634,12 +622,9 @@ local function NodeNonOpaqueTest() local layer = getBaseLayer() for i = 0, 49 do - background = CCSprite:create("Images/background1.jpg") - local blendFunc = BlendFunc:new() - blendFunc.src = GL_ONE - blendFunc.dst = GL_ZERO - background:setBlendFunc(blendFunc) - background:setAnchorPoint(CCPoint(0, 0)) + background = cc.Sprite:create("Images/background1.jpg") + background:setBlendFunc(gl.ONE, gl.ZERO) + background:setAnchorPoint(cc.p(0, 0)) layer:addChild(background) end Helper.titleLabel:setString("Node Non Opaque Test") @@ -648,7 +633,7 @@ local function NodeNonOpaqueTest() end function CocosNodeTest() - local scene = CCScene:create() + local scene = cc.Scene:create() Helper.createFunctionTable = { CameraCenterTest, diff --git a/samples/Lua/TestLua/Resources/luaScript/OpenGLTest/OpenGLTest.lua b/samples/Lua/TestLua/Resources/luaScript/OpenGLTest/OpenGLTest.lua index 460fac980e..a840ccd203 100644 --- a/samples/Lua/TestLua/Resources/luaScript/OpenGLTest/OpenGLTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/OpenGLTest/OpenGLTest.lua @@ -8,7 +8,7 @@ local function OpenGLTestMainLayer() local curCase = 0 local accum = 0 local labelBMFont = nil - local size = CCDirector:getInstance():getWinSize() + local size = cc.Director:getInstance():getWinSize() local curLayer = nil local schedulEntry = nil local function OrderCallbackMenu() @@ -30,23 +30,23 @@ local function OpenGLTestMainLayer() ShowCurrentTest() end - local ordercallbackmenu = CCMenu:create() - local size = CCDirector:getInstance():getWinSize() - local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2) + local ordercallbackmenu = cc.Menu:create() + local size = cc.Director:getInstance():getWinSize() + local item1 = cc.MenuItemImage:create(s_pPathB1, s_pPathB2) item1:registerScriptTapHandler(backCallback) ordercallbackmenu:addChild(item1,kItemTagBasic) - local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2) + local item2 = cc.MenuItemImage:create(s_pPathR1, s_pPathR2) item2:registerScriptTapHandler(restartCallback) ordercallbackmenu:addChild(item2,kItemTagBasic) - local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2) + local item3 = cc.MenuItemImage:create(s_pPathF1, s_pPathF2) ordercallbackmenu:addChild(item3,kItemTagBasic) item3:registerScriptTapHandler(nextCallback) - item1:setPosition(CCPoint(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) - item2:setPosition(CCPoint(size.width / 2, item2:getContentSize().height / 2)) - item3:setPosition(CCPoint(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + item1:setPosition(cc.p(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + item2:setPosition(cc.p(size.width / 2, item2:getContentSize().height / 2)) + item3:setPosition(cc.p(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) - ordercallbackmenu:setPosition(CCPoint(0, 0)) + ordercallbackmenu:setPosition(cc.p(0, 0)) return ordercallbackmenu end @@ -125,14 +125,14 @@ local function OpenGLTestMainLayer() local function InitTitle(layer) --Title - local lableTitle = CCLabelTTF:create(GetTitle(), "Arial", 40) + local lableTitle = cc.LabelTTF:create(GetTitle(), "Arial", 40) layer:addChild(lableTitle, 15) - lableTitle:setPosition(CCPoint(size.width/2, size.height-32)) - lableTitle:setColor(Color3B(255,255,40)) + lableTitle:setPosition(cc.p(size.width/2, size.height-32)) + lableTitle:setColor(cc.c3b(255,255,40)) --SubTitle - local subLabelTitle = CCLabelTTF:create(GetSubTitle(), "Thonburi", 16) + local subLabelTitle = cc.LabelTTF:create(GetSubTitle(), "Thonburi", 16) layer:addChild(subLabelTitle, 15) - subLabelTitle:setPosition(CCPoint(size.width/2, size.height-80)) + subLabelTitle:setPosition(cc.p(size.width/2, size.height-80)) end local function updateRetroEffect(fTime) @@ -145,10 +145,11 @@ local function OpenGLTestMainLayer() return end local i = 0 - local len = children:count() + local len = table.getn(children) for i= 0 ,len - 1 do - local child = tolua.cast(children:objectAtIndex(i), "CCSprite") - local oldPosX,oldPosY = child:getPosition() + local child = tolua.cast(children[i + 1], "Sprite") + local oldPos = child:getPosition() + local oldPosX,oldPosY = oldPos.x, oldPos.y child:setPosition(oldPosX,math.sin(accum * 2 + i / 2.0) * 20) local scaleY = math.sin(accum * 2 + i / 2.0 + 0.707) child:setScaleY(scaleY) @@ -156,15 +157,15 @@ local function OpenGLTestMainLayer() end local function createShaderRetroEffect() - local RetroEffectlayer = CCLayer:create() + local RetroEffectlayer = cc.Layer:create() InitTitle(RetroEffectlayer) - local program = CCGLProgram:create("Shaders/example_ColorBars.vsh", "Shaders/example_ColorBars.fsh") - program:addAttribute(CCConstants.ATTRIBUTE_NAME_POSITION, CCConstants.VERTEX_ATTRIB_POSITION) - program:addAttribute(CCConstants.ATTRIBUTE_NAME_TEX_COORD, CCConstants.VERTEX_ATTRIB_TEX_COORDS) + local program = cc.GLProgram:create("Shaders/example_ColorBars.vsh", "Shaders/example_ColorBars.fsh") + program:addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION) + program:addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS) program:link() program:updateUniforms() - label = CCLabelBMFont:create("RETRO EFFECT","fonts/west_england-64.fnt") + label = cc.LabelBMFont:create("RETRO EFFECT","fonts/west_england-64.fnt") label:setShaderProgram( program ) label:setPosition(size.width/2, size.height/2) @@ -179,21 +180,21 @@ local function OpenGLTestMainLayer() local uniformResolution = 0 local time = 0 local squareVertexPositionBuffer = {} - local majorLayer = CCLayer:create() + local majorLayer = cc.Layer:create() InitTitle(majorLayer) --loadShaderVertex - local shader = CCGLProgram:create("Shaders/example_Monjori.vsh", "Shaders/example_Monjori.fsh") + local shader = cc.GLProgram:create("Shaders/example_Monjori.vsh", "Shaders/example_Monjori.fsh") - shader:addAttribute("aVertex", CCConstants.VERTEX_ATTRIB_POSITION) + shader:addAttribute("aVertex", cc.VERTEX_ATTRIB_POSITION) shader:link() shader:updateUniforms() local program = shader:getProgram() local glNode = gl.glNodeCreate() - glNode:setContentSize(CCSize(256,256)) - glNode:setAnchorPoint(CCPoint(0.5, 0.5)) + glNode:setContentSize(cc.size(256,256)) + glNode:setAnchorPoint(cc.p(0.5, 0.5)) uniformCenter = gl.getUniformLocation(program,"center") uniformResolution = gl.getUniformLocation( program, "resolution") glNode:setShaderProgram(shader) @@ -215,14 +216,14 @@ local function OpenGLTestMainLayer() shader:use() shader:setUniformsForBuiltins() --Uniforms - shader:setUniformLocationWith2f( uniformCenter, size.width/2, size.height/2) - shader:setUniformLocationWith2f( uniformResolution, 256, 256) + shader:setUniformLocationF32( uniformCenter, size.width/2, size.height/2) + shader:setUniformLocationF32( uniformResolution, 256, 256) - gl.glEnableVertexAttribs(CCConstants.VERTEX_ATTRIB_FLAG_POSITION) + gl.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION) --Draw fullscreen Square gl.bindBuffer(gl.ARRAY_BUFFER,squareVertexPositionBuffer) - gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) gl.drawArrays(gl.TRIANGLE_STRIP,0,4) gl.bindBuffer(gl.ARRAY_BUFFER,0) end @@ -241,11 +242,11 @@ local function OpenGLTestMainLayer() local uniformResolution = 0 local time = 0 local squareVertexPositionBuffer = {} - local mandelbrotLayer = CCLayer:create() + local mandelbrotLayer = cc.Layer:create() InitTitle(mandelbrotLayer) --loadShaderVertex - local shader = CCGLProgram:create("Shaders/example_Mandelbrot.vsh", "Shaders/example_Mandelbrot.fsh") + local shader = cc.GLProgram:create("Shaders/example_Mandelbrot.vsh", "Shaders/example_Mandelbrot.fsh") shader:addAttribute("aVertex", 0) shader:link() @@ -254,8 +255,8 @@ local function OpenGLTestMainLayer() local program = shader:getProgram() local glNode = gl.glNodeCreate() - glNode:setContentSize(CCSize(256,256)) - glNode:setAnchorPoint(CCPoint(0.5, 0.5)) + glNode:setContentSize(cc.size(256,256)) + glNode:setAnchorPoint(cc.p(0.5, 0.5)) uniformCenter = gl.getUniformLocation(program,"center") uniformResolution = gl.getUniformLocation( program, "resolution") glNode:setShaderProgram(shader) @@ -277,14 +278,14 @@ local function OpenGLTestMainLayer() shader:use() shader:setUniformsForBuiltins() --Uniforms - shader:setUniformLocationWith2f( uniformCenter, size.width/2, size.height/2) - shader:setUniformLocationWith2f( uniformResolution, 256, 256) + shader:setUniformLocationF32( uniformCenter, size.width/2, size.height/2) + shader:setUniformLocationF32( uniformResolution, 256, 256) gl.glEnableVertexAttribs(0x1) --Draw fullscreen Square gl.bindBuffer(gl.ARRAY_BUFFER,squareVertexPositionBuffer.buffer_id) - gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) gl.drawArrays(gl.TRIANGLE_STRIP,0,4) gl.bindBuffer(gl.ARRAY_BUFFER,0) end @@ -303,11 +304,11 @@ local function OpenGLTestMainLayer() local uniformResolution = 0 local time = 0 local squareVertexPositionBuffer = {} - local heartLayer = CCLayer:create() + local heartLayer = cc.Layer:create() InitTitle(heartLayer) --loadShaderVertex - local shader = CCGLProgram:create("Shaders/example_Heart.vsh", "Shaders/example_Heart.fsh") + local shader = cc.GLProgram:create("Shaders/example_Heart.vsh", "Shaders/example_Heart.fsh") shader:addAttribute("aVertex", 0) shader:link() @@ -316,8 +317,8 @@ local function OpenGLTestMainLayer() local program = shader:getProgram() local glNode = gl.glNodeCreate() - glNode:setContentSize(CCSize(256,256)) - glNode:setAnchorPoint(CCPoint(0.5, 0.5)) + glNode:setContentSize(cc.size(256,256)) + glNode:setAnchorPoint(cc.p(0.5, 0.5)) uniformCenter = gl.getUniformLocation(program,"center") uniformResolution = gl.getUniformLocation( program, "resolution") glNode:setShaderProgram(shader) @@ -339,14 +340,14 @@ local function OpenGLTestMainLayer() shader:use() shader:setUniformsForBuiltins() --Uniforms - shader:setUniformLocationWith2f( uniformCenter, size.width/2, size.height/2) - shader:setUniformLocationWith2f( uniformResolution, 256, 256) + shader:setUniformLocationF32( uniformCenter, size.width/2, size.height/2) + shader:setUniformLocationF32( uniformResolution, 256, 256) gl.glEnableVertexAttribs(0x1) --Draw fullscreen Square gl.bindBuffer(gl.ARRAY_BUFFER,squareVertexPositionBuffer.buffer_id) - gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) gl.drawArrays(gl.TRIANGLE_STRIP,0,4) gl.bindBuffer(gl.ARRAY_BUFFER,0) end @@ -365,11 +366,11 @@ local function OpenGLTestMainLayer() local uniformResolution = 0 local time = 0 local squareVertexPositionBuffer = {} - local plasmaLayer = CCLayer:create() + local plasmaLayer = cc.Layer:create() InitTitle(plasmaLayer) --loadShaderVertex - local shader = CCGLProgram:create("Shaders/example_Plasma.vsh", "Shaders/example_Plasma.fsh") + local shader = cc.GLProgram:create("Shaders/example_Plasma.vsh", "Shaders/example_Plasma.fsh") shader:addAttribute("aVertex", 0) shader:link() @@ -378,8 +379,8 @@ local function OpenGLTestMainLayer() local program = shader:getProgram() local glNode = gl.glNodeCreate() - glNode:setContentSize(CCSize(256,256)) - glNode:setAnchorPoint(CCPoint(0.5, 0.5)) + glNode:setContentSize(cc.size(256,256)) + glNode:setAnchorPoint(cc.p(0.5, 0.5)) uniformCenter = gl.getUniformLocation(program,"center") uniformResolution = gl.getUniformLocation( program, "resolution") glNode:setShaderProgram(shader) @@ -401,14 +402,14 @@ local function OpenGLTestMainLayer() shader:use() shader:setUniformsForBuiltins() --Uniforms - shader:setUniformLocationWith2f( uniformCenter, size.width/2, size.height/2) - shader:setUniformLocationWith2f( uniformResolution, 256, 256) + shader:setUniformLocationF32( uniformCenter, size.width/2, size.height/2) + shader:setUniformLocationF32( uniformResolution, 256, 256) gl.glEnableVertexAttribs(0x1) --Draw fullscreen Square gl.bindBuffer(gl.ARRAY_BUFFER,squareVertexPositionBuffer.buffer_id) - gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) gl.drawArrays(gl.TRIANGLE_STRIP,0,4) gl.bindBuffer(gl.ARRAY_BUFFER,0) end @@ -427,11 +428,11 @@ local function OpenGLTestMainLayer() local uniformResolution = 0 local time = 0 local squareVertexPositionBuffer = {} - local flowerLayer = CCLayer:create() + local flowerLayer = cc.Layer:create() InitTitle(flowerLayer) --loadShaderVertex - local shader = CCGLProgram:create("Shaders/example_Flower.vsh", "Shaders/example_Flower.fsh") + local shader = cc.GLProgram:create("Shaders/example_Flower.vsh", "Shaders/example_Flower.fsh") shader:addAttribute("aVertex", 0) shader:link() @@ -440,8 +441,8 @@ local function OpenGLTestMainLayer() local program = shader:getProgram() local glNode = gl.glNodeCreate() - glNode:setContentSize(CCSize(256,256)) - glNode:setAnchorPoint(CCPoint(0.5, 0.5)) + glNode:setContentSize(cc.size(256,256)) + glNode:setAnchorPoint(cc.p(0.5, 0.5)) uniformCenter = gl.getUniformLocation(program,"center") uniformResolution = gl.getUniformLocation( program, "resolution") glNode:setShaderProgram(shader) @@ -463,14 +464,14 @@ local function OpenGLTestMainLayer() shader:use() shader:setUniformsForBuiltins() --Uniforms - shader:setUniformLocationWith2f( uniformCenter, size.width/2, size.height/2) - shader:setUniformLocationWith2f( uniformResolution, 256, 256) + shader:setUniformLocationF32( uniformCenter, size.width/2, size.height/2) + shader:setUniformLocationF32( uniformResolution, 256, 256) gl.glEnableVertexAttribs(0x1) --Draw fullscreen Square gl.bindBuffer(gl.ARRAY_BUFFER,squareVertexPositionBuffer.buffer_id) - gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) gl.drawArrays(gl.TRIANGLE_STRIP,0,4) gl.bindBuffer(gl.ARRAY_BUFFER,0) end @@ -489,11 +490,11 @@ local function OpenGLTestMainLayer() local uniformResolution = 0 local time = 0 local squareVertexPositionBuffer = {} - local juliaLayer = CCLayer:create() + local juliaLayer = cc.Layer:create() InitTitle(juliaLayer) --loadShaderVertex - local shader = CCGLProgram:create("Shaders/example_Julia.vsh", "Shaders/example_Julia.fsh") + local shader = cc.GLProgram:create("Shaders/example_Julia.vsh", "Shaders/example_Julia.fsh") shader:addAttribute("aVertex", 0) shader:link() @@ -502,8 +503,8 @@ local function OpenGLTestMainLayer() local program = shader:getProgram() local glNode = gl.glNodeCreate() - glNode:setContentSize(CCSize(256,256)) - glNode:setAnchorPoint(CCPoint(0.5, 0.5)) + glNode:setContentSize(cc.size(256,256)) + glNode:setAnchorPoint(cc.p(0.5, 0.5)) uniformCenter = gl.getUniformLocation(program,"center") uniformResolution = gl.getUniformLocation( program, "resolution") glNode:setShaderProgram(shader) @@ -525,14 +526,14 @@ local function OpenGLTestMainLayer() shader:use() shader:setUniformsForBuiltins() --Uniforms - shader:setUniformLocationWith2f( uniformCenter, size.width/2, size.height/2) - shader:setUniformLocationWith2f( uniformResolution, 256, 256) + shader:setUniformLocationF32( uniformCenter, size.width/2, size.height/2) + shader:setUniformLocationF32( uniformResolution, 256, 256) gl.glEnableVertexAttribs(0x1) --Draw fullscreen Square gl.bindBuffer(gl.ARRAY_BUFFER,squareVertexPositionBuffer.buffer_id) - gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) gl.drawArrays(gl.TRIANGLE_STRIP,0,4) gl.bindBuffer(gl.ARRAY_BUFFER,0) end @@ -547,18 +548,18 @@ local function OpenGLTestMainLayer() end local function createGLGetActiveTest() - local glGetActiveLayer = CCLayer:create() + local glGetActiveLayer = cc.Layer:create() InitTitle(glGetActiveLayer) - local sprite = CCSprite:create("Images/grossini.png") + local sprite = cc.Sprite:create("Images/grossini.png") sprite:setPosition( size.width/2, size.height/2) glGetActiveLayer:addChild(sprite) local glNode = gl.glNodeCreate() glGetActiveLayer:addChild(glNode,-10) - local scheduler = CCDirector:getInstance():getScheduler() + local scheduler = cc.Director:getInstance():getScheduler() local function getCurrentResult() local var = {} - local glProgam = tolua.cast(sprite:getShaderProgram(),"CCGLProgram") + local glProgam = tolua.cast(sprite:getShaderProgram(),"GLProgram") if nil ~= glProgam then local p = glProgam:getProgram() local aaSize,aaType,aaName = gl.getActiveAttrib(p,0) @@ -597,14 +598,14 @@ local function OpenGLTestMainLayer() local texture = {} local squareVertexPositionBuffer = {} local squareVertexTextureBuffer = {} - local texImage2dLayer = CCLayer:create() + local texImage2dLayer = cc.Layer:create() InitTitle(texImage2dLayer) local glNode = gl.glNodeCreate() texImage2dLayer:addChild(glNode, 10) glNode:setPosition(size.width/2, size.height/2) - glNode:setContentSize(CCSize(128,128)) - glNode:setAnchorPoint(CCPoint(0.5,0.5)) - local shaderCache = CCShaderCache:getInstance() + glNode:setContentSize(cc.size(128,128)) + glNode:setAnchorPoint(cc.p(0.5,0.5)) + local shaderCache = cc.ShaderCache:getInstance() local shader = shaderCache:getProgram("ShaderPositionTexture") local function initGL() texture.texture_id = gl.createTexture() @@ -646,14 +647,14 @@ local function OpenGLTestMainLayer() shader:setUniformsForBuiltins() gl.bindTexture(gl.TEXTURE_2D, texture.texture_id) - gl.glEnableVertexAttribs(CCConstants.VERTEX_ATTRIB_FLAG_TEX_COORDS or CCConstants.VERTEX_ATTRIB_FLAG_POSITION) + gl.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_TEX_COORDS or cc.VERTEX_ATTRIB_FLAG_POSITION) gl.bindBuffer(gl.ARRAY_BUFFER, squareVertexPositionBuffer.buffer_id) - gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION,2,gl.FLOAT,false,0,0) + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,2,gl.FLOAT,false,0,0) gl.bindBuffer(gl.ARRAY_BUFFER, squareVertexTextureBuffer.buffer_id) - gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_TEX_COORDS,2,gl.FLOAT,false,0,0) + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS,2,gl.FLOAT,false,0,0) gl.drawArrays(gl.TRIANGLE_STRIP,0,4) @@ -668,7 +669,7 @@ local function OpenGLTestMainLayer() end local function CreateSupportedExtensionsLayer() - local extensionsLayer = CCLayer:create() + local extensionsLayer = cc.Layer:create() InitTitle(extensionsLayer) local glNode = gl.glNodeCreate() extensionsLayer:addChild(glNode,-10) @@ -687,7 +688,7 @@ local function OpenGLTestMainLayer() end local function CreateReadPixelsTest() - local readPixelsLayer = CCLayer:create() + local readPixelsLayer = cc.Layer:create() InitTitle(readPixelsLayer) local glNode = gl.glNodeCreate() readPixelsLayer:addChild(glNode,-10) @@ -695,10 +696,10 @@ local function OpenGLTestMainLayer() local x = size.width local y = size.height - local blue = CCLayerColor:create(Color4B(0, 0, 255, 255)) - local red = CCLayerColor:create(Color4B(255, 0, 0, 255)) - local green = CCLayerColor:create(Color4B(0, 255, 0, 255)) - local white = CCLayerColor:create(Color4B(255, 255, 255, 255)) + local blue = cc.LayerColor:create(cc.c4b(0, 0, 255, 255)) + local red = cc.LayerColor:create(cc.c4b(255, 0, 0, 255)) + local green = cc.LayerColor:create(cc.c4b(0, 255, 0, 255)) + local white = cc.LayerColor:create(cc.c4b(255, 255, 255, 255)) blue:setScale(0.5) blue:setPosition(-x / 4, -y / 4) @@ -717,7 +718,7 @@ local function OpenGLTestMainLayer() readPixelsLayer:addChild(green,12) readPixelsLayer:addChild(red,13) - local scheduler = CCDirector:getInstance():getScheduler() + local scheduler = cc.Director:getInstance():getScheduler() local function getCurrentResult() local x = size.width @@ -773,16 +774,16 @@ local function OpenGLTestMainLayer() end local function createClearTest() - local clearLayer = CCLayer:create() + local clearLayer = cc.Layer:create() InitTitle(clearLayer) - local blue = CCLayerColor:create(Color4B(0, 0, 255, 255)) + local blue = cc.LayerColor:create(cc.c4b(0, 0, 255, 255)) clearLayer:addChild( blue, 1 ) local glNode = gl.glNodeCreate() clearLayer:addChild(glNode,10) --gl.init() - local scheduler = CCDirector:getInstance():getScheduler() + local scheduler = cc.Director:getInstance():getScheduler() local function clearDraw() gl.clear(gl.COLOR_BUFFER_BIT) @@ -813,7 +814,7 @@ local function OpenGLTestMainLayer() end local function createNodeWebGLAPITest() - local nodeWebGLAPILayer = CCLayer:create() + local nodeWebGLAPILayer = cc.Layer:create() InitTitle(nodeWebGLAPILayer) local glNode = gl.glNodeCreate() nodeWebGLAPILayer:addChild(glNode,10) @@ -971,11 +972,11 @@ local function OpenGLTestMainLayer() end local function createGLNodeCCAPITest() - local nodeCCAPILayer = CCLayer:create() + local nodeCCAPILayer = cc.Layer:create() InitTitle(nodeCCAPILayer) local glNode = gl.glNodeCreate() nodeCCAPILayer:addChild(glNode,10) - local shader = CCShaderCache:getInstance():getProgram("ShaderPositionColor") + local shader = cc.ShaderCache:getInstance():getProgram("ShaderPositionColor") local triangleVertexPositionBuffer = {} local triangleVertexColorBuffer = {} local squareVertexPositionBuffer = {} @@ -1026,22 +1027,22 @@ local function OpenGLTestMainLayer() local function GLNodeCCAPIDraw() shader:use() shader:setUniformsForBuiltins() - gl.glEnableVertexAttribs(CCConstants.VERTEX_ATTRIB_FLAG_COLOR or CCConstants.VERTEX_ATTRIB_FLAG_POSITION) + gl.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_COLOR or cc.VERTEX_ATTRIB_FLAG_POSITION) -- gl.bindBuffer(gl.ARRAY_BUFFER, squareVertexPositionBuffer.buffer_id) - gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) gl.bindBuffer(gl.ARRAY_BUFFER, squareVertexColorBuffer.buffer_id) - gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_COLOR, 4, gl.FLOAT, false, 0, 0) + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, gl.FLOAT, false, 0, 0) gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4) gl.bindBuffer(gl.ARRAY_BUFFER, triangleVertexPositionBuffer.buffer_id) - gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) gl.bindBuffer(gl.ARRAY_BUFFER, triangleVertexColorBuffer.buffer_id) - gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_COLOR, 4, gl.FLOAT, false, 0, 0) + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, gl.FLOAT, false, 0, 0) gl.drawArrays(gl.TRIANGLE_STRIP, 0, 3) @@ -1056,7 +1057,7 @@ local function OpenGLTestMainLayer() end local function createGLTexParamterTest() - local glTexParamLayer = CCLayer:create() + local glTexParamLayer = cc.Layer:create() InitTitle(glTexParamLayer) local glNode = gl.glNodeCreate() glTexParamLayer:addChild(glNode,10) @@ -1079,14 +1080,14 @@ local function OpenGLTestMainLayer() end local function createGetUniformTest() - local getUniformLayer = CCLayer:create() + local getUniformLayer = cc.Layer:create() InitTitle(getUniformLayer) local glNode = gl.glNodeCreate() getUniformLayer:addChild(glNode,10) local pMatrix = {1,2,3,4, 4,3,2,1, 1,2,4,8, 1.1,1.2,1.3,1.4} local function runTest() - local shader = CCShaderCache:getInstance():getProgram("ShaderPositionTextureColor") + local shader = cc.ShaderCache:getInstance():getProgram("ShaderPositionTextureColor") local program = shader:getProgram() shader:use() @@ -1147,10 +1148,10 @@ local function OpenGLTestMainLayer() end function ShowCurrentTest() - local curScene = CCScene:create() + local curScene = cc.Scene:create() if nil ~= curScene then if nil ~= curLayer then - local scheduler = CCDirector:getInstance():getScheduler() + local scheduler = cc.Director:getInstance():getScheduler() if nil ~= schedulEntry then scheduler:unscheduleScriptEntry(schedulEntry) end @@ -1160,7 +1161,7 @@ local function OpenGLTestMainLayer() curScene:addChild(curLayer) curLayer:addChild(OrderCallbackMenu(),15) curScene:addChild(CreateBackMenuItem()) - CCDirector:getInstance():replaceScene(curScene) + cc.Director:getInstance():replaceScene(curScene) end end end @@ -1170,7 +1171,7 @@ local function OpenGLTestMainLayer() end function OpenGLTestMain() - local scene = CCScene:create() + local scene = cc.Scene:create() scene:addChild(OpenGLTestMainLayer()) scene:addChild(CreateBackMenuItem()) return scene diff --git a/samples/Lua/TestLua/Resources/luaScript/ParallaxTest/ParallaxTest.lua b/samples/Lua/TestLua/Resources/luaScript/ParallaxTest/ParallaxTest.lua index df34149294..24f5405368 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ParallaxTest/ParallaxTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ParallaxTest/ParallaxTest.lua @@ -2,7 +2,7 @@ local kTagNode = 0 local kTagGrossini = 1 local function createParallaxLayer(title, subtitle) - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) local titleStr = title == nil and "No title" or title local subTitleStr = subtitle == nil and "" or subtitle @@ -20,61 +20,56 @@ end local function Parallax1() local ret = createParallaxLayer("Parallax: parent and 3 children") -- Top Layer, a simple image - local cocosImage = CCSprite:create(s_Power) + local cocosImage = cc.Sprite:create(s_Power) -- scale the image (optional) cocosImage:setScale( 2.5 ) -- change the transform anchor point to 0,0 (optional) - cocosImage:setAnchorPoint( CCPoint(0,0) ) + cocosImage:setAnchorPoint( cc.p(0,0) ) -- Middle layer: a Tile map atlas - local tilemap = CCTileMapAtlas:create(s_TilesPng, s_LevelMapTga, 16, 16) + local tilemap = cc.TileMapAtlas:create(s_TilesPng, s_LevelMapTga, 16, 16) tilemap:releaseMap() -- change the transform anchor to 0,0 (optional) - tilemap:setAnchorPoint( CCPoint(0, 0) ) + tilemap:setAnchorPoint( cc.p(0, 0) ) -- Anti Aliased images tilemap:getTexture():setAntiAliasTexParameters() -- background layer: another image - local background = CCSprite:create(s_back) + local background = cc.Sprite:create(s_back) -- scale the image (optional) background:setScale( 1.5 ) -- change the transform anchor point (optional) - background:setAnchorPoint( CCPoint(0,0) ) + background:setAnchorPoint( cc.p(0,0) ) -- create a void node, a parent node - local voidNode = CCParallaxNode:create() + local voidNode = cc.ParallaxNode:create() -- NOW add the 3 layers to the 'void' node -- background image is moved at a ratio of 0.4x, 0.5y - voidNode:addChild(background, -1, CCPoint(0.4,0.5), CCPoint(0,0)) + voidNode:addChild(background, -1, cc.p(0.4,0.5), cc.p(0,0)) -- tiles are moved at a ratio of 2.2x, 1.0y - voidNode:addChild(tilemap, 1, CCPoint(2.2,1.0), CCPoint(0,-200) ) + voidNode:addChild(tilemap, 1, cc.p(2.2,1.0), cc.p(0,-200) ) -- top image is moved at a ratio of 3.0x, 2.5y - voidNode:addChild(cocosImage, 2, CCPoint(3.0,2.5), CCPoint(200,800) ) + voidNode:addChild(cocosImage, 2, cc.p(3.0,2.5), cc.p(200,800) ) -- now create some actions that will move the 'void' node -- and the children of the 'void' node will move at different -- speed, thus, simulation the 3D environment - local goUp = CCMoveBy:create(4, CCPoint(0,-500) ) + local goUp = cc.MoveBy:create(4, cc.p(0,-500) ) local goDown = goUp:reverse() - local go = CCMoveBy:create(8, CCPoint(-1000,0) ) + local go = cc.MoveBy:create(8, cc.p(-1000,0) ) local goBack = go:reverse() - local arr = CCArray:create() - arr:addObject(goUp) - arr:addObject(go) - arr:addObject(goDown) - arr:addObject(goBack) - local seq = CCSequence:create(arr) - voidNode:runAction( (CCRepeatForever:create(seq) )) + local seq = cc.Sequence:create(goUp, go, goDown, goBack) + voidNode:runAction( (cc.RepeatForever:create(seq) )) ret:addChild( voidNode ) return ret @@ -91,45 +86,45 @@ local function Parallax2() ret:setTouchEnabled( true ) -- Top Layer, a simple image - local cocosImage = CCSprite:create(s_Power) + local cocosImage = cc.Sprite:create(s_Power) -- scale the image (optional) cocosImage:setScale( 2.5 ) -- change the transform anchor point to 0,0 (optional) - cocosImage:setAnchorPoint( CCPoint(0,0) ) + cocosImage:setAnchorPoint( cc.p(0,0) ) -- Middle layer: a Tile map atlas - local tilemap = CCTileMapAtlas:create(s_TilesPng, s_LevelMapTga, 16, 16) + local tilemap = cc.TileMapAtlas:create(s_TilesPng, s_LevelMapTga, 16, 16) tilemap:releaseMap() -- change the transform anchor to 0,0 (optional) - tilemap:setAnchorPoint( CCPoint(0, 0) ) + tilemap:setAnchorPoint( cc.p(0, 0) ) -- Anti Aliased images tilemap:getTexture():setAntiAliasTexParameters() -- background layer: another image - local background = CCSprite:create(s_back) + local background = cc.Sprite:create(s_back) -- scale the image (optional) background:setScale( 1.5 ) -- change the transform anchor point (optional) - background:setAnchorPoint( CCPoint(0,0) ) + background:setAnchorPoint( cc.p(0,0) ) -- create a void node, a parent node - local voidNode = CCParallaxNode:create() + local voidNode = cc.ParallaxNode:create() -- NOW add the 3 layers to the 'void' node -- background image is moved at a ratio of 0.4x, 0.5y - voidNode:addChild(background, -1, CCPoint(0.4,0.5), CCPoint(0, 0)) + voidNode:addChild(background, -1, cc.p(0.4,0.5), cc.p(0, 0)) -- tiles are moved at a ratio of 1.0, 1.0y - voidNode:addChild(tilemap, 1, CCPoint(1.0,1.0), CCPoint(0,-200) ) + voidNode:addChild(tilemap, 1, cc.p(1.0,1.0), cc.p(0,-200) ) -- top image is moved at a ratio of 3.0x, 2.5y - voidNode:addChild( cocosImage, 2, CCPoint(3.0,2.5), CCPoint(200,1000) ) + voidNode:addChild( cocosImage, 2, cc.p(3.0,2.5), cc.p(200,1000) ) ret:addChild(voidNode, 0, kTagNode) local prev = {x = 0, y = 0} local function onTouchEvent(eventType, x, y) @@ -144,7 +139,7 @@ local function Parallax2() local diffX = x - prev.x local diffY = y - prev.y - node:setPosition( CCPoint.__add(CCPoint(newX, newY), CCPoint(diffX, diffY)) ) + node:setPosition( cc.pAdd(cc.p(newX, newY), cc.p(diffX, diffY)) ) prev.x = x prev.y = y end @@ -157,8 +152,8 @@ end function ParallaxTestMain() cclog("ParallaxMain") Helper.index = 1 - CCDirector:getInstance():setDepthTest(true) - local scene = CCScene:create() + cc.Director:getInstance():setDepthTest(true) + local scene = cc.Scene:create() Helper.createFunctionTable = { Parallax1, diff --git a/samples/Lua/TestLua/Resources/luaScript/ParticleTest/ParticleTest.lua b/samples/Lua/TestLua/Resources/luaScript/ParticleTest/ParticleTest.lua index 4bdc7c1a45..ad3f22d36b 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ParticleTest/ParticleTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ParticleTest/ParticleTest.lua @@ -10,7 +10,7 @@ local titleLabel = nil local subtitleLabel = nil local baseLayer_entry = nil -local s = CCDirector:getInstance():getWinSize() +local s = cc.Director:getInstance():getWinSize() local function backAction() SceneIdx = SceneIdx - 1 @@ -33,40 +33,40 @@ local function nextAction() end local function backCallback(sender) - local scene = CCScene:create() + local scene = cc.Scene:create() scene:addChild(backAction()) scene:addChild(CreateBackMenuItem()) - CCDirector:getInstance():replaceScene(scene) + cc.Director:getInstance():replaceScene(scene) end local function restartCallback(sender) - local scene = CCScene:create() + local scene = cc.Scene:create() scene:addChild(restartAction()) scene:addChild(CreateBackMenuItem()) - CCDirector:getInstance():replaceScene(scene) + cc.Director:getInstance():replaceScene(scene) end local function nextCallback(sender) - local scene = CCScene:create() + local scene = cc.Scene:create() scene:addChild(nextAction()) scene:addChild(CreateBackMenuItem()) - CCDirector:getInstance():replaceScene(scene) + cc.Director:getInstance():replaceScene(scene) end local function toggleCallback(sender) if emitter ~= nil then - if emitter:getPositionType() == kCCPositionTypeGrouped then - emitter:setPositionType(kCCPositionTypeFree) - elseif emitter:getPositionType() == kCCPositionTypeFree then - emitter:setPositionType(kCCPositionTypeRelative) - elseif emitter:getPositionType() == kCCPositionTypeRelative then - emitter:setPositionType(kCCPositionTypeGrouped) + if emitter:getPositionType() == cc.POSITION_TYPE_GROUPED then + emitter:setPositionType(cc.POSITION_TYPE_FREE) + elseif emitter:getPositionType() == cc.POSITION_TYPE_FREE then + emitter:setPositionType(cc.POSITION_TYPE_RELATIVE) + elseif emitter:getPositionType() == cc.POSITION_TYPE_RELATIVE then + emitter:setPositionType(cc.POSITION_TYPE_GROUPED) end end end @@ -85,7 +85,7 @@ local function update(dt) end local function baseLayer_onEnterOrExit(tag) - local scheduler = CCDirector:getInstance():getScheduler() + local scheduler = cc.Director:getInstance():getScheduler() if tag == "enter" then baseLayer_entry = scheduler:scheduleScriptFunc(update, 0, false) elseif tag == "exit" then @@ -94,67 +94,67 @@ local function baseLayer_onEnterOrExit(tag) end local function getBaseLayer() - local layer = CCLayerColor:create(Color4B(127,127,127,255)) + local layer = cc.LayerColor:create(cc.c4b(127,127,127,255)) emitter = nil - titleLabel = CCLabelTTF:create("", "Arial", 28) + titleLabel = cc.LabelTTF:create("", "Arial", 28) layer:addChild(titleLabel, 100, 1000) titleLabel:setPosition(s.width / 2, s.height - 50) - subtitleLabel = CCLabelTTF:create("", "Arial", 16) + subtitleLabel = cc.LabelTTF:create("", "Arial", 16) layer:addChild(subtitleLabel, 100) subtitleLabel:setPosition(s.width / 2, s.height - 80) - local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2) - local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2) - local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2) - local item4 = CCMenuItemToggle:create(CCMenuItemFont:create("Free Movement")) - item4:addSubItem(CCMenuItemFont:create("Relative Movement")) - item4:addSubItem(CCMenuItemFont:create("Grouped Movement")) + local item1 = cc.MenuItemImage:create(s_pPathB1, s_pPathB2) + local item2 = cc.MenuItemImage:create(s_pPathR1, s_pPathR2) + local item3 = cc.MenuItemImage:create(s_pPathF1, s_pPathF2) + local item4 = cc.MenuItemToggle:create(cc.MenuItemFont:create("Free Movement")) + item4:addSubItem(cc.MenuItemFont:create("Relative Movement")) + item4:addSubItem(cc.MenuItemFont:create("Grouped Movement")) item1:registerScriptTapHandler(backCallback) item2:registerScriptTapHandler(restartCallback) item3:registerScriptTapHandler(nextCallback) item4:registerScriptTapHandler(toggleCallback) - local menu = CCMenu:create() + local menu = cc.Menu:create() menu:addChild(item1) menu:addChild(item2) menu:addChild(item3) menu:addChild(item4) - menu:setPosition(CCPoint(0, 0)) - item1:setPosition(CCPoint(s.width/2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) - item2:setPosition(CCPoint(s.width/2, item2:getContentSize().height / 2)) - item3:setPosition(CCPoint(s.width/2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) - item4:setPosition(CCPoint(0, 100)) - item4:setAnchorPoint(CCPoint(0, 0)) + menu:setPosition(cc.p(0, 0)) + item1:setPosition(cc.p(s.width/2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + item2:setPosition(cc.p(s.width/2, item2:getContentSize().height / 2)) + item3:setPosition(cc.p(s.width/2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + item4:setPosition(cc.p(0, 100)) + item4:setAnchorPoint(cc.p(0, 0)) layer:addChild(menu, 100) - labelAtlas = CCLabelAtlas:create("0000", "fps_images.png", 12, 32, string.byte('.')) + labelAtlas = cc.LabelAtlas:_create("0000", "fps_images.png", 12, 32, string.byte('.')) layer:addChild(labelAtlas, 100) - labelAtlas:setPosition(CCPoint(s.width - 66, 50)) + labelAtlas:setPosition(cc.p(s.width - 66, 50)) -- moving background - background = CCSprite:create(s_back3) + background = cc.Sprite:create(s_back3) layer:addChild(background, 5) - background:setPosition(CCPoint(s.width / 2, s.height - 180)) + background:setPosition(cc.p(s.width / 2, s.height - 180)) - local move = CCMoveBy:create(4, CCPoint(300, 0)) + local move = cc.MoveBy:create(4, cc.p(300, 0)) local move_back = move:reverse() - local seq = CCSequence:createWithTwoActions(move, move_back) - background:runAction(CCRepeatForever:create(seq)) + local seq = cc.Sequence:create(move, move_back) + background:runAction(cc.RepeatForever:create(seq)) local function onTouchEnded(x, y) - local pos = CCPoint(0, 0) + local pos = cc.p(0, 0) if background ~= nil then - pos = background:convertToWorldSpace(CCPoint(0, 0)) + pos = background:convertToWorldSpace(cc.p(0, 0)) end if emitter ~= nil then - local newPos = CCPoint.__sub(CCPoint(x, y), pos) + local newPos = cc.pSub(cc.p(x, y), pos) emitter:setPosition(newPos.x, newPos.y) end end @@ -211,7 +211,7 @@ local function reorderParticles(dt) end local function ParticleReorder_onEnterOrExit(tag) - local scheduler = CCDirector:getInstance():getScheduler() + local scheduler = cc.Director:getInstance():getScheduler() if tag == "enter" then ParticleReorder_entry = scheduler:scheduleScriptFunc(reorderParticles, 1.0, false) elseif tag == "exit" then @@ -223,13 +223,13 @@ local function ParticleReorder() ParticleReorder_layer = getBaseLayer() ParticleReorder_Order = 0 - ParticleReorder_layer:setColor(Color3B(0, 0, 0)) + ParticleReorder_layer:setColor(cc.c3b(0, 0, 0)) ParticleReorder_layer:removeChild(background, true) background = nil - local ignore = CCParticleSystemQuad:create("Particles/SmallSun.plist") - local parent1 = CCNode:create() - local parent2 = CCParticleBatchNode:createWithTexture(ignore:getTexture()) + local ignore = cc.ParticleSystemQuad:create("Particles/SmallSun.plist") + local parent1 = cc.Node:create() + local parent2 = cc.ParticleBatchNode:createWithTexture(ignore:getTexture()) ignore:unscheduleUpdate() for i = 0, 1 do @@ -240,14 +240,14 @@ local function ParticleReorder() parent = parent2 end - local emitter1 = CCParticleSystemQuad:create("Particles/SmallSun.plist") - emitter1:setStartColor(Color4F(1,0,0,1)) + local emitter1 = cc.ParticleSystemQuad:create("Particles/SmallSun.plist") + emitter1:setStartColor(cc.c4f(1,0,0,1)) emitter1:setBlendAdditive(false) - local emitter2 = CCParticleSystemQuad:create("Particles/SmallSun.plist") - emitter2:setStartColor(Color4F(0,1,0,1)) + local emitter2 = cc.ParticleSystemQuad:create("Particles/SmallSun.plist") + emitter2:setStartColor(cc.c4f(0,1,0,1)) emitter2:setBlendAdditive(false) - local emitter3 = CCParticleSystemQuad:create("Particles/SmallSun.plist") - emitter3:setStartColor(Color4F(0,0,1,1)) + local emitter3 = cc.ParticleSystemQuad:create("Particles/SmallSun.plist") + emitter3:setStartColor(cc.c4f(0,0,1,1)) emitter3:setBlendAdditive(false) local neg = nil @@ -257,9 +257,9 @@ local function ParticleReorder() neg = -1 end - emitter1:setPosition(CCPoint( s.width / 2 - 30, s.height / 2 + 60 * neg)) - emitter2:setPosition(CCPoint( s.width / 2, s.height / 2 + 60 * neg)) - emitter3:setPosition(CCPoint( s.width / 2 + 30, s.height / 2 + 60 * neg)) + emitter1:setPosition(cc.p( s.width / 2 - 30, s.height / 2 + 60 * neg)) + emitter2:setPosition(cc.p( s.width / 2, s.height / 2 + 60 * neg)) + emitter3:setPosition(cc.p( s.width / 2 + 30, s.height / 2 + 60 * neg)) parent:addChild(emitter1, 0, 1) parent:addChild(emitter2, 0, 2) @@ -286,22 +286,22 @@ local function switchRender(dt) update(dt) local cond = (emitter:getBatchNode() ~= nil) - emitter:removeFromParentAndCleanup(false) + emitter:removeFromParent(false) local str = "Particle: Using new parent: " local newParent = nil if cond == true then newParent = ParticleBatchHybrid_parent2 - str = str .. "CCNode" + str = str .. "Node" else newParent = ParticleBatchHybrid_parent1 - str = str .. "CCParticleBatchNode" + str = str .. "ParticleBatchNode" end newParent:addChild(emitter) cclog(str) end local function ParticleBatchHybrid_onEnterOrExit(tag) - local scheduler = CCDirector:getInstance():getScheduler() + local scheduler = cc.Director:getInstance():getScheduler() if tag == "enter" then ParticleBatchHybrid_entry = scheduler:scheduleScriptFunc(switchRender, 2.0, false) elseif tag == "exit" then @@ -313,17 +313,17 @@ end local function ParticleBatchHybrid() local layer = getBaseLayer() - layer:setColor(Color3B(0, 0, 0)) + layer:setColor(cc.c3b(0, 0, 0)) layer:removeChild(background, true) background = nil - emitter = CCParticleSystemQuad:create("Particles/LavaFlow.plist") + emitter = cc.ParticleSystemQuad:create("Particles/LavaFlow.plist") ---- emitter:retain() - local batch = CCParticleBatchNode:createWithTexture(emitter:getTexture()) + local batch = cc.ParticleBatchNode:createWithTexture(emitter:getTexture()) batch:addChild(emitter) layer:addChild(batch, 10) - local node = CCNode:create() + local node = cc.Node:create() layer:addChild(node) ParticleBatchHybrid_parent1 = batch ParticleBatchHybrid_parent2 = node @@ -341,22 +341,22 @@ end local function ParticleBatchMultipleEmitters() local layer = getBaseLayer() - layer:setColor(Color3B(0, 0, 0)) + layer:setColor(cc.c3b(0, 0, 0)) layer:removeChild(background, true) background = nil - local emitter1 = CCParticleSystemQuad:create("Particles/LavaFlow.plist") - emitter1:setStartColor(Color4F(1,0,0,1)) - local emitter2 = CCParticleSystemQuad:create("Particles/LavaFlow.plist") - emitter2:setStartColor(Color4F(0,1,0,1)) - local emitter3 = CCParticleSystemQuad:create("Particles/LavaFlow.plist") - emitter3:setStartColor(Color4F(0,0,1,1)) + local emitter1 = cc.ParticleSystemQuad:create("Particles/LavaFlow.plist") + emitter1:setStartColor(cc.c4f(1,0,0,1)) + local emitter2 = cc.ParticleSystemQuad:create("Particles/LavaFlow.plist") + emitter2:setStartColor(cc.c4f(0,1,0,1)) + local emitter3 = cc.ParticleSystemQuad:create("Particles/LavaFlow.plist") + emitter3:setStartColor(cc.c4f(0,0,1,1)) - emitter1:setPosition(CCPoint(s.width / 1.25, s.height / 1.25)) - emitter2:setPosition(CCPoint(s.width / 2, s.height / 2)) - emitter3:setPosition(CCPoint(s.width / 4, s.height / 4)) + emitter1:setPosition(cc.p(s.width / 1.25, s.height / 1.25)) + emitter2:setPosition(cc.p(s.width / 2, s.height / 2)) + emitter3:setPosition(cc.p(s.width / 4, s.height / 4)) - local batch = CCParticleBatchNode:createWithTexture(emitter1:getTexture()) + local batch = cc.ParticleBatchNode:createWithTexture(emitter1:getTexture()) batch:addChild(emitter1, 0) batch:addChild(emitter2, 0) @@ -375,10 +375,10 @@ end local function DemoFlower() local layer = getBaseLayer() - emitter = CCParticleFlower:create() + emitter = cc.ParticleFlower:create() -- emitter:retain() background:addChild(emitter, 10) - emitter:setTexture(CCTextureCache:getInstance():addImage(s_stars1)) + emitter:setTexture(cc.TextureCache:getInstance():addImage(s_stars1)) setEmitterPosition() @@ -392,11 +392,11 @@ end local function DemoGalaxy() local layer = getBaseLayer() - emitter = CCParticleGalaxy:create() + emitter = cc.ParticleGalaxy:create() -- emitter:retain() background:addChild(emitter, 10) - emitter:setTexture(CCTextureCache:getInstance():addImage(s_fire)) + emitter:setTexture(cc.TextureCache:getInstance():addImage(s_fire)) setEmitterPosition() @@ -410,11 +410,11 @@ end local function DemoFirework() local layer = getBaseLayer() - emitter = CCParticleFireworks:create() + emitter = cc.ParticleFireworks:create() -- emitter:retain() background:addChild(emitter, 10) - emitter:setTexture(CCTextureCache:getInstance():addImage(s_stars1)) + emitter:setTexture(cc.TextureCache:getInstance():addImage(s_stars1)) setEmitterPosition() @@ -428,11 +428,11 @@ end local function DemoSpiral() local layer = getBaseLayer() - emitter = CCParticleSpiral:create() + emitter = cc.ParticleSpiral:create() -- emitter:retain() background:addChild(emitter, 10) - emitter:setTexture(CCTextureCache:getInstance():addImage(s_fire)) + emitter:setTexture(cc.TextureCache:getInstance():addImage(s_fire)) setEmitterPosition() @@ -446,11 +446,11 @@ end local function DemoSun() local layer = getBaseLayer() - emitter = CCParticleSun:create() + emitter = cc.ParticleSun:create() -- emitter:retain() background:addChild(emitter, 10) - emitter:setTexture(CCTextureCache:getInstance():addImage(s_fire)) + emitter:setTexture(cc.TextureCache:getInstance():addImage(s_fire)) setEmitterPosition() @@ -464,11 +464,11 @@ end local function DemoMeteor() local layer = getBaseLayer() - emitter = CCParticleMeteor:create() + emitter = cc.ParticleMeteor:create() -- emitter:retain() background:addChild(emitter, 10) - emitter:setTexture(CCTextureCache:getInstance():addImage(s_fire)) + emitter:setTexture(cc.TextureCache:getInstance():addImage(s_fire)) setEmitterPosition() @@ -482,12 +482,13 @@ end local function DemoFire() local layer = getBaseLayer() - emitter = CCParticleFire:create() + emitter = cc.ParticleFire:create() -- emitter:retain() background:addChild(emitter, 10) - emitter:setTexture(CCTextureCache:getInstance():addImage(s_fire)) - local pos_x, pos_y = emitter:getPosition() + emitter:setTexture(cc.TextureCache:getInstance():addImage(s_fire)) + local pos = emitter:getPosition() + local pos_x, pos_y = pos.x, pos.y emitter:setPosition(pos_x, 100) titleLabel:setString("ParticleFire") @@ -500,12 +501,12 @@ end local function DemoSmoke() local layer = getBaseLayer() - emitter = CCParticleSmoke:create() + emitter = cc.ParticleSmoke:create() -- emitter:retain() background:addChild(emitter, 10) - emitter:setTexture(CCTextureCache:getInstance():addImage(s_fire)) - - local pos_x, pos_y = emitter:getPosition() + emitter:setTexture(cc.TextureCache:getInstance():addImage(s_fire)) + local pos = emitter:getPosition() + local pos_x, pos_y = pos.x, pos.y emitter:setPosition(pos_x, 100) setEmitterPosition() @@ -520,11 +521,11 @@ end local function DemoExplosion() local layer = getBaseLayer() - emitter = CCParticleExplosion:create() + emitter = cc.ParticleExplosion:create() -- emitter:retain() background:addChild(emitter, 10) - emitter:setTexture(CCTextureCache:getInstance():addImage(s_stars1)) + emitter:setTexture(cc.TextureCache:getInstance():addImage(s_stars1)) emitter:setAutoRemoveOnFinish(true) @@ -540,17 +541,17 @@ end local function DemoSnow() local layer = getBaseLayer() - emitter = CCParticleSnow:create() + emitter = cc.ParticleSnow:create() -- emitter:retain() background:addChild(emitter, 10) - - local pos_x, pos_y = emitter:getPosition() + local pos = emitter:getPosition() + local pos_x, pos_y = pos.x, pos.y emitter:setPosition(pos_x, pos_y - 110) emitter:setLife(3) emitter:setLifeVar(1) -- gravity - emitter:setGravity(CCPoint(0, -10)) + emitter:setGravity(cc.p(0, -10)) -- speed of particles emitter:setSpeed(130) @@ -568,7 +569,7 @@ local function DemoSnow() emitter:setEmissionRate(emitter:getTotalParticles() / emitter:getLife()) - emitter:setTexture(CCTextureCache:getInstance():addImage(s_snow)) + emitter:setTexture(cc.TextureCache:getInstance():addImage(s_snow)) setEmitterPosition() @@ -582,15 +583,15 @@ end local function DemoRain() local layer = getBaseLayer() - emitter = CCParticleRain:create() + emitter = cc.ParticleRain:create() -- emitter:retain() background:addChild(emitter, 10) - - local pos_x, pos_y = emitter:getPosition() + local pos = emitter:getPosition() + local pos_x, pos_y = pos.x, pos.y emitter:setPosition(pos_x, pos_y - 100) emitter:setLife(4) - emitter:setTexture(CCTextureCache:getInstance():addImage(s_fire)) + emitter:setTexture(cc.TextureCache:getInstance():addImage(s_fire)) setEmitterPosition() @@ -604,17 +605,15 @@ end local function DemoBigFlower() local layer = getBaseLayer() - emitter = CCParticleSystemQuad:new() - emitter:initWithTotalParticles(50) - emitter:autorelease() + emitter = cc.ParticleSystemQuad:createWithTotalParticles(50) background:addChild(emitter, 10) ----emitter:release() -- win32 : use this line or remove this line and use autorelease() - emitter:setTexture( CCTextureCache:getInstance():addImage(s_stars1) ) + emitter:setTexture( cc.TextureCache:getInstance():addImage(s_stars1) ) emitter:setDuration(-1) -- gravity - emitter:setGravity(CCPoint(0, 0)) + emitter:setGravity(cc.p(0, 0)) -- angle emitter:setAngle(90) @@ -634,7 +633,7 @@ local function DemoBigFlower() -- emitter position emitter:setPosition(160, 240) - emitter:setPosVar(CCPoint(0, 0)) + emitter:setPosVar(cc.p(0, 0)) -- life of particles emitter:setLife(4) @@ -647,15 +646,15 @@ local function DemoBigFlower() emitter:setEndSpinVar(0) -- color of particles - emitter:setStartColor(Color4F(0.5, 0.5, 0.5, 1.0)) - emitter:setStartColorVar(Color4F(0.5, 0.5, 0.5, 1.0)) - emitter:setEndColor(Color4F(0.1, 0.1, 0.1, 0.2)) - emitter:setEndColorVar(Color4F(0.1, 0.1, 0.1, 0.2)) + emitter:setStartColor(cc.c4f(0.5, 0.5, 0.5, 1.0)) + emitter:setStartColorVar(cc.c4f(0.5, 0.5, 0.5, 1.0)) + emitter:setEndColor(cc.c4f(0.1, 0.1, 0.1, 0.2)) + emitter:setEndColorVar(cc.c4f(0.1, 0.1, 0.1, 0.2)) -- size, in pixels emitter:setStartSize(80.0) emitter:setStartSizeVar(40.0) - emitter:setEndSize(kCCParticleStartSizeEqualToEndSize) + emitter:setEndSize(cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE ) -- emits per second emitter:setEmissionRate(emitter:getTotalParticles() / emitter:getLife()) @@ -675,19 +674,17 @@ end local function DemoRotFlower() local layer = getBaseLayer() - emitter = CCParticleSystemQuad:new() - emitter:initWithTotalParticles(300) - emitter:autorelease() + emitter = cc.ParticleSystemQuad:createWithTotalParticles(300) background:addChild(emitter, 10) ----emitter:release() -- win32 : Remove this line - emitter:setTexture(CCTextureCache:getInstance():addImage(s_stars2)) + emitter:setTexture(cc.TextureCache:getInstance():addImage(s_stars2)) -- duration emitter:setDuration(-1) -- gravity - emitter:setGravity(CCPoint(0, 0)) + emitter:setGravity(cc.p(0, 0)) -- angle emitter:setAngle(90) @@ -707,7 +704,7 @@ local function DemoRotFlower() -- emitter position emitter:setPosition(160, 240) - emitter:setPosVar(CCPoint(0, 0)) + emitter:setPosVar(cc.p(0, 0)) -- life of particles emitter:setLife(3) @@ -720,15 +717,15 @@ local function DemoRotFlower() emitter:setEndSpinVar(2000) -- color of particles - emitter:setStartColor(Color4F(0.5, 0.5, 0.5, 1.0)) - emitter:setStartColorVar(Color4F(0.5, 0.5, 0.5, 1.0)) - emitter:setEndColor(Color4F(0.1, 0.1, 0.1, 0.2)) - emitter:setEndColorVar(Color4F(0.1, 0.1, 0.1, 0.2)) + emitter:setStartColor(cc.c4f(0.5, 0.5, 0.5, 1.0)) + emitter:setStartColorVar(cc.c4f(0.5, 0.5, 0.5, 1.0)) + emitter:setEndColor(cc.c4f(0.1, 0.1, 0.1, 0.2)) + emitter:setEndColorVar(cc.c4f(0.1, 0.1, 0.1, 0.2)) -- size, in pixels emitter:setStartSize(30.0) emitter:setStartSizeVar(0) - emitter:setEndSize(kCCParticleStartSizeEqualToEndSize) + emitter:setEndSize(cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE ) -- emits per second emitter:setEmissionRate(emitter:getTotalParticles() / emitter:getLife()) @@ -748,9 +745,7 @@ end local function DemoModernArt() local layer = getBaseLayer() - emitter = CCParticleSystemQuad:new() - emitter:initWithTotalParticles(1000) - emitter:autorelease() + emitter = cc.ParticleSystemQuad:createWithTotalParticles(1000) background:addChild(emitter, 10) ----emitter:release() @@ -759,7 +754,7 @@ local function DemoModernArt() emitter:setDuration(-1) -- gravity - emitter:setGravity(CCPoint(0,0)) + emitter:setGravity(cc.p(0,0)) -- angle emitter:setAngle(0) @@ -779,7 +774,7 @@ local function DemoModernArt() -- emitter position emitter:setPosition(s.width / 2, s.height / 2) - emitter:setPosVar(CCPoint(0, 0)) + emitter:setPosVar(cc.p(0, 0)) -- life of particles emitter:setLife(2.0) @@ -789,10 +784,10 @@ local function DemoModernArt() emitter:setEmissionRate(emitter:getTotalParticles() / emitter:getLife()) -- color of particles - emitter:setStartColor(Color4F(0.5, 0.5, 0.5, 1.0)) - emitter:setStartColorVar(Color4F(0.5, 0.5, 0.5, 1.0)) - emitter:setEndColor(Color4F(0.1, 0.1, 0.1, 0.2)) - emitter:setEndColorVar(Color4F(0.1, 0.1, 0.1, 0.2)) + emitter:setStartColor(cc.c4f(0.5, 0.5, 0.5, 1.0)) + emitter:setStartColorVar(cc.c4f(0.5, 0.5, 0.5, 1.0)) + emitter:setEndColor(cc.c4f(0.1, 0.1, 0.1, 0.2)) + emitter:setEndColorVar(cc.c4f(0.1, 0.1, 0.1, 0.2)) -- size, in pixels emitter:setStartSize(1.0) @@ -801,7 +796,7 @@ local function DemoModernArt() emitter:setEndSizeVar(8.0) -- texture - emitter:setTexture(CCTextureCache:getInstance():addImage(s_fire)) + emitter:setTexture(cc.TextureCache:getInstance():addImage(s_fire)) -- additive emitter:setBlendAdditive(false) @@ -818,12 +813,12 @@ end local function DemoRing() local layer = getBaseLayer() - emitter = CCParticleFlower:create() + emitter = cc.ParticleFlower:create() -- emitter:retain() background:addChild(emitter, 10) - emitter:setTexture(CCTextureCache:getInstance():addImage(s_stars1)) + emitter:setTexture(cc.TextureCache:getInstance():addImage(s_stars1)) emitter:setLifeVar(0) emitter:setLife(10) emitter:setSpeed(100) @@ -845,30 +840,30 @@ local function ParallaxParticle() background:getParent():removeChild(background, true) background = nil - local p = CCParallaxNode:create() + local p = cc.ParallaxNode:create() layer:addChild(p, 5) - local p1 = CCSprite:create(s_back3) - local p2 = CCSprite:create(s_back3) + local p1 = cc.Sprite:create(s_back3) + local p2 = cc.Sprite:create(s_back3) - p:addChild(p1, 1, CCPoint(0.5, 1), CCPoint(0, 250)) - p:addChild(p2, 2, CCPoint(1.5, 1), CCPoint(0, 50)) + p:addChild(p1, 1, cc.p(0.5, 1), cc.p(0, 250)) + p:addChild(p2, 2, cc.p(1.5, 1), cc.p(0, 50)) - emitter = CCParticleFlower:create() + emitter = cc.ParticleFlower:create() -- emitter:retain() - emitter:setTexture(CCTextureCache:getInstance():addImage(s_fire)) + emitter:setTexture(cc.TextureCache:getInstance():addImage(s_fire)) p1:addChild(emitter, 10) emitter:setPosition(250, 200) - local par = CCParticleSun:create() + local par = cc.ParticleSun:create() p2:addChild(par, 10) - par:setTexture(CCTextureCache:getInstance():addImage(s_fire)) + par:setTexture(cc.TextureCache:getInstance():addImage(s_fire)) - local move = CCMoveBy:create(4, CCPoint(300,0)) + local move = cc.MoveBy:create(4, cc.p(300,0)) local move_back = move:reverse() - local seq = CCSequence:createWithTwoActions(move, move_back) - p:runAction(CCRepeatForever:create(seq)) + local seq = cc.Sequence:create(move, move_back) + p:runAction(cc.RepeatForever:create(seq)) titleLabel:setString("Parallax + Particles") return layer @@ -880,14 +875,12 @@ end local function DemoParticleFromFile(name) local layer = getBaseLayer() - layer:setColor(Color3B(0, 0, 0)) + layer:setColor(cc.c3b(0, 0, 0)) layer:removeChild(background, true) background = nil - emitter = CCParticleSystemQuad:new() - emitter:autorelease() local filename = "Particles/" .. name .. ".plist" - emitter:initWithFile(filename) + emitter = cc.ParticleSystemQuad:create(filename) layer:addChild(emitter, 10) setEmitterPosition() @@ -902,20 +895,19 @@ end local function RadiusMode1() local layer = getBaseLayer() - layer:setColor(Color3B(0, 0, 0)) + layer:setColor(cc.c3b(0, 0, 0)) layer:removeChild(background, true) background = nil - emitter = CCParticleSystemQuad:new() - emitter:initWithTotalParticles(200) + emitter = cc.ParticleSystemQuad:createWithTotalParticles(200) layer:addChild(emitter, 10) - emitter:setTexture(CCTextureCache:getInstance():addImage("Images/stars-grayscale.png")) + emitter:setTexture(cc.TextureCache:getInstance():addImage("Images/stars-grayscale.png")) -- duration - emitter:setDuration(kCCParticleDurationInfinity) + emitter:setDuration(cc.PARTICLE_DURATION_INFINITY) -- radius mode - emitter:setEmitterMode(kCCParticleModeRadius) + emitter:setEmitterMode(cc.PARTICLE_MODE_RADIUS) -- radius mode: start and end radius in pixels emitter:setStartRadius(0) @@ -934,7 +926,7 @@ local function RadiusMode1() -- emitter position emitter:setPosition(s.width / 2, s.height / 2) - emitter:setPosVar(CCPoint(0, 0)) + emitter:setPosVar(cc.p(0, 0)) -- life of particles emitter:setLife(5) @@ -947,15 +939,15 @@ local function RadiusMode1() emitter:setEndSpinVar(0) -- color of particles - emitter:setStartColor(Color4F(0.5, 0.5, 0.5, 1.0)) - emitter:setStartColorVar(Color4F(0.5, 0.5, 0.5, 1.0)) - emitter:setEndColor(Color4F(0.1, 0.1, 0.1, 0.2)) - emitter:setEndColorVar(Color4F(0.1, 0.1, 0.1, 0.2)) + emitter:setStartColor(cc.c4f(0.5, 0.5, 0.5, 1.0)) + emitter:setStartColorVar(cc.c4f(0.5, 0.5, 0.5, 1.0)) + emitter:setEndColor(cc.c4f(0.1, 0.1, 0.1, 0.2)) + emitter:setEndColorVar(cc.c4f(0.1, 0.1, 0.1, 0.2)) -- size, in pixels emitter:setStartSize(32) emitter:setStartSizeVar(0) - emitter:setEndSize(kCCParticleStartSizeEqualToEndSize) + emitter:setEndSize(cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE ) -- emits per second emitter:setEmissionRate(emitter:getTotalParticles() / emitter:getLife()) @@ -973,25 +965,24 @@ end local function RadiusMode2() local layer = getBaseLayer() - layer:setColor(Color3B(0, 0, 0)) + layer:setColor(cc.c3b(0, 0, 0)) layer:removeChild(background, true) background = nil - emitter = CCParticleSystemQuad:new() - emitter:initWithTotalParticles(200) + emitter = cc.ParticleSystemQuad:createWithTotalParticles(200) layer:addChild(emitter, 10) - emitter:setTexture(CCTextureCache:getInstance():addImage("Images/stars-grayscale.png")) + emitter:setTexture(cc.TextureCache:getInstance():addImage("Images/stars-grayscale.png")) -- duration - emitter:setDuration(kCCParticleDurationInfinity) + emitter:setDuration(cc.PARTICLE_DURATION_INFINITY ) -- radius mode - emitter:setEmitterMode(kCCParticleModeRadius) + emitter:setEmitterMode(cc.PARTICLE_MODE_RADIUS) -- radius mode: start and end radius in pixels emitter:setStartRadius(100) emitter:setStartRadiusVar(0) - emitter:setEndRadius(kCCParticleStartRadiusEqualToEndRadius) + emitter:setEndRadius(cc.PARTICLE_START_RADIUS_EQUAL_TO_END_RADIUS) emitter:setEndRadiusVar(0) -- radius mode: degrees per second @@ -1004,7 +995,7 @@ local function RadiusMode2() -- emitter position emitter:setPosition(s.width / 2, s.height / 2) - emitter:setPosVar(CCPoint(0, 0)) + emitter:setPosVar(cc.p(0, 0)) -- life of particles emitter:setLife(4) @@ -1017,15 +1008,15 @@ local function RadiusMode2() emitter:setEndSpinVar(0) -- color of particles - emitter:setStartColor(Color4F(0.5, 0.5, 0.5, 1.0)) - emitter:setStartColorVar(Color4F(0.5, 0.5, 0.5, 1.0)) - emitter:setEndColor(Color4F(0.1, 0.1, 0.1, 0.2)) - emitter:setEndColorVar(Color4F(0.1, 0.1, 0.1, 0.2)) + emitter:setStartColor(cc.c4f(0.5, 0.5, 0.5, 1.0)) + emitter:setStartColorVar(cc.c4f(0.5, 0.5, 0.5, 1.0)) + emitter:setEndColor(cc.c4f(0.1, 0.1, 0.1, 0.2)) + emitter:setEndColorVar(cc.c4f(0.1, 0.1, 0.1, 0.2)) -- size, in pixels emitter:setStartSize(32) emitter:setStartSizeVar(0) - emitter:setEndSize(kCCParticleStartSizeEqualToEndSize) + emitter:setEndSize(cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE) -- emits per second emitter:setEmissionRate(emitter:getTotalParticles() / emitter:getLife()) @@ -1043,25 +1034,24 @@ end local function Issue704() local layer = getBaseLayer() - layer:setColor(Color3B(0, 0, 0)) + layer:setColor(cc.c3b(0, 0, 0)) layer:removeChild(background, true) background = nil - emitter = CCParticleSystemQuad:new() - emitter:initWithTotalParticles(100) + emitter = cc.ParticleSystemQuad:createWithTotalParticles(100) layer:addChild(emitter, 10) - emitter:setTexture(CCTextureCache:getInstance():addImage("Images/fire.png")) + emitter:setTexture(cc.TextureCache:getInstance():addImage("Images/fire.png")) -- duration - emitter:setDuration(kCCParticleDurationInfinity) + emitter:setDuration(cc.PARTICLE_DURATION_INFINITY) -- radius mode - emitter:setEmitterMode(kCCParticleModeRadius) + emitter:setEmitterMode(cc.PARTICLE_MODE_RADIUS) -- radius mode: start and end radius in pixels emitter:setStartRadius(50) emitter:setStartRadiusVar(0) - emitter:setEndRadius(kCCParticleStartRadiusEqualToEndRadius) + emitter:setEndRadius(cc.PARTICLE_START_RADIUS_EQUAL_TO_END_RADIUS ) emitter:setEndRadiusVar(0) -- radius mode: degrees per second @@ -1075,7 +1065,7 @@ local function Issue704() -- emitter position emitter:setPosition(s.width / 2, s.height / 2) - emitter:setPosVar(CCPoint(0, 0)) + emitter:setPosVar(cc.p(0, 0)) -- life of particles emitter:setLife(5) @@ -1088,15 +1078,15 @@ local function Issue704() emitter:setEndSpinVar(0) -- color of particles - emitter:setStartColor(Color4F(0.5, 0.5, 0.5, 1.0)) - emitter:setStartColorVar(Color4F(0.5, 0.5, 0.5, 1.0)) - emitter:setEndColor(Color4F(0.1, 0.1, 0.1, 0.2)) - emitter:setEndColorVar(Color4F(0.1, 0.1, 0.1, 0.2)) + emitter:setStartColor(cc.c4f(0.5, 0.5, 0.5, 1.0)) + emitter:setStartColorVar(cc.c4f(0.5, 0.5, 0.5, 1.0)) + emitter:setEndColor(cc.c4f(0.1, 0.1, 0.1, 0.2)) + emitter:setEndColorVar(cc.c4f(0.1, 0.1, 0.1, 0.2)) -- size, in pixels emitter:setStartSize(16) emitter:setStartSizeVar(0) - emitter:setEndSize(kCCParticleStartSizeEqualToEndSize) + emitter:setEndSize(cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE) -- emits per second emitter:setEmissionRate(emitter:getTotalParticles() / emitter:getLife()) @@ -1104,8 +1094,8 @@ local function Issue704() -- additive emitter:setBlendAdditive(false) - local rot = CCRotateBy:create(16, 360) - emitter:runAction(CCRepeatForever:create(rot)) + local rot = cc.RotateBy:create(16, 360) + emitter:runAction(cc.RepeatForever:create(rot)) titleLabel:setString("Issue 704. Free + Rot") subtitleLabel:setString("Emitted particles should not rotate") @@ -1122,12 +1112,12 @@ local function updateQuads(dt) update(dt) Issue870_index = math.mod(Issue870_index + 1, 4) - local rect = CCRect(Issue870_index * 32, 0, 32, 32) + local rect = cc.rect(Issue870_index * 32, 0, 32, 32) emitter:setTextureWithRect(emitter:getTexture(), rect) end local function Issue870_onEnterOrExit(tag) - local scheduler = CCDirector:getInstance():getScheduler() + local scheduler = cc.Director:getInstance():getScheduler() if tag == "enter" then Issue870_entry = scheduler:scheduleScriptFunc(updateQuads, 2.0, false) elseif tag == "exit" then @@ -1138,13 +1128,12 @@ end local function Issue870() local layer = getBaseLayer() - layer:setColor(Color3B(0, 0, 0)) + layer:setColor(cc.c3b(0, 0, 0)) layer:removeChild(background, true) background = nil - local system = CCParticleSystemQuad:new() - system:initWithFile("Particles/SpinningPeas.plist") - system:setTextureWithRect(CCTextureCache:getInstance():addImage("Images/particles.png"), CCRect(0,0,32,32)) + local system = cc.ParticleSystemQuad:create("Particles/SpinningPeas.plist") + system:setTextureWithRect(cc.TextureCache:getInstance():addImage("Images/particles.png"), cc.rect(0,0,32,32)) layer:addChild(system, 10) emitter = system @@ -1162,16 +1151,16 @@ end local function MultipleParticleSystems() local layer = getBaseLayer() - layer:setColor(Color3B(0, 0, 0)) + layer:setColor(cc.c3b(0, 0, 0)) layer:removeChild(background, true) background = nil - CCTextureCache:getInstance():addImage("Images/particles.png") + cc.TextureCache:getInstance():addImage("Images/particles.png") for i = 0, 4 do - local particleSystem = CCParticleSystemQuad:create("Particles/SpinningPeas.plist") + local particleSystem = cc.ParticleSystemQuad:create("Particles/SpinningPeas.plist") particleSystem:setPosition(i * 50, i * 50) - particleSystem:setPositionType(kCCPositionTypeGrouped) + particleSystem:setPositionType(cc.POSITION_TYPE_GROUPED ) layer:addChild(particleSystem) end @@ -1188,16 +1177,16 @@ end local function MultipleParticleSystemsBatched() local layer = getBaseLayer() - layer:setColor(Color3B(0, 0, 0)) + layer:setColor(cc.c3b(0, 0, 0)) layer:removeChild(background, true) background = nil - local batchNode = CCParticleBatchNode:createWithTexture(nil, 3000) + local batchNode = cc.ParticleBatchNode:createWithTexture(nil, 3000) layer:addChild(batchNode, 1, 2) for i = 0, 4 do - local particleSystem = CCParticleSystemQuad:create("Particles/SpinningPeas.plist") - particleSystem:setPositionType(kCCPositionTypeGrouped) + local particleSystem = cc.ParticleSystemQuad:create("Particles/SpinningPeas.plist") + particleSystem:setPositionType(cc.POSITION_TYPE_GROUPED ) particleSystem:setPosition(i * 50, i * 50) batchNode:setTexture(particleSystem:getTexture()) batchNode:addChild(particleSystem) @@ -1219,15 +1208,15 @@ local AddAndDeleteParticleSystems_batchNode = nil local function removeSystem(dt) update(dt) - local ChildrenCount = AddAndDeleteParticleSystems_batchNode:getChildren():count() + local ChildrenCount = table.getn(AddAndDeleteParticleSystems_batchNode:getChildren()) if ChildrenCount > 0 then cclog("remove random system") local rand = math.mod(math.random(1, 999999), ChildrenCount - 1) - AddAndDeleteParticleSystems_batchNode:removeChild(AddAndDeleteParticleSystems_batchNode:getChildren():objectAtIndex(rand), true) + AddAndDeleteParticleSystems_batchNode:removeChild(AddAndDeleteParticleSystems_batchNode:getChildren()[(rand)], true) --add new - local particleSystem = CCParticleSystemQuad:create("Particles/Spiral.plist") - particleSystem:setPositionType(kCCPositionTypeGrouped) + local particleSystem = cc.ParticleSystemQuad:create("Particles/Spiral.plist") + particleSystem:setPositionType(cc.POSITION_TYPE_GROUPED ) particleSystem:setTotalParticles(200) particleSystem:setPosition(math.mod(math.random(1, 999999), 300) ,math.mod(math.random(1, 999999), 400)) @@ -1239,7 +1228,7 @@ local function removeSystem(dt) end local function AddAndDeleteParticleSystems_onEnterOrExit(tag) - local scheduler = CCDirector:getInstance():getScheduler() + local scheduler = cc.Director:getInstance():getScheduler() if tag == "enter" then AddAndDeleteParticleSystems_entry = scheduler:scheduleScriptFunc(removeSystem, 2.0, false) elseif tag == "exit" then @@ -1250,20 +1239,20 @@ end local function AddAndDeleteParticleSystems() local layer = getBaseLayer() - layer:setColor(Color3B(0, 0, 0)) + layer:setColor(cc.c3b(0, 0, 0)) layer:removeChild(background, true) background = nil --adds the texture inside the plist to the texture cache - AddAndDeleteParticleSystems_batchNode = CCParticleBatchNode:createWithTexture(nil, 16000) + AddAndDeleteParticleSystems_batchNode = cc.ParticleBatchNode:createWithTexture(nil, 16000) layer:addChild(AddAndDeleteParticleSystems_batchNode, 1, 2) for i = 0, 5 do - local particleSystem = CCParticleSystemQuad:create("Particles/Spiral.plist") + local particleSystem = cc.ParticleSystemQuad:create("Particles/Spiral.plist") AddAndDeleteParticleSystems_batchNode:setTexture(particleSystem:getTexture()) - particleSystem:setPositionType(kCCPositionTypeGrouped) + particleSystem:setPositionType(cc.POSITION_TYPE_GROUPED ) particleSystem:setTotalParticles(200) particleSystem:setPosition(i * 15 + 100, i * 15 + 100) @@ -1290,14 +1279,16 @@ local ReorderParticleSystems_batchNode = nil local function reorderSystem(dt) update(dt) - local child = ReorderParticleSystems_batchNode:getChildren():randomObject() - -- problem: there's no getZOrder() for CCObject + local childArray = ReorderParticleSystems_batchNode:getChildren() + local random = math.random(1,table.getn(childArray)) + local child = childArray[random] + -- problem: there's no getZOrder() for cc.Object -- ReorderParticleSystems_batchNode:reorderChild(child, child:getZOrder() - 1) ReorderParticleSystems_batchNode:reorderChild(child, math.random(0, 99999)) end local function ReorderParticleSystems_onEnterOrExit(tag) - local scheduler = CCDirector:getInstance():getScheduler() + local scheduler = cc.Director:getInstance():getScheduler() if tag == "enter" then ReorderParticleSystems_entry = scheduler:scheduleScriptFunc(reorderSystem, 2.0, false) elseif tag == "exit" then @@ -1308,29 +1299,28 @@ end local function ReorderParticleSystems() local layer = getBaseLayer() - layer:setColor(Color3B(0, 0, 0)) + layer:setColor(cc.c3b(0, 0, 0)) layer:removeChild(background ,true) background = nil - ReorderParticleSystems_batchNode = CCParticleBatchNode:create("Images/stars-grayscale.png", 3000) + ReorderParticleSystems_batchNode = cc.ParticleBatchNode:create("Images/stars-grayscale.png", 3000) layer:addChild(ReorderParticleSystems_batchNode, 1, 2) for i = 0, 2 do - local particleSystem = CCParticleSystemQuad:new() - particleSystem:initWithTotalParticles(200) + local particleSystem = cc.ParticleSystemQuad:createWithTotalParticles(200) particleSystem:setTexture(ReorderParticleSystems_batchNode:getTexture()) -- duration - particleSystem:setDuration(kCCParticleDurationInfinity) + particleSystem:setDuration(cc.PARTICLE_DURATION_INFINITY) -- radius mode - particleSystem:setEmitterMode(kCCParticleModeRadius) + particleSystem:setEmitterMode(cc.PARTICLE_MODE_RADIUS) -- radius mode: 100 pixels from center particleSystem:setStartRadius(100) particleSystem:setStartRadiusVar(0) - particleSystem:setEndRadius(kCCParticleStartRadiusEqualToEndRadius) + particleSystem:setEndRadius(cc.PARTICLE_START_RADIUS_EQUAL_TO_END_RADIUS ) particleSystem:setEndRadiusVar(0) -- not used when start == end -- radius mode: degrees per second @@ -1344,7 +1334,7 @@ local function ReorderParticleSystems() particleSystem:setAngleVar(0) -- emitter position - particleSystem:setPosVar(CCPoint(0, 0)) + particleSystem:setPosVar(cc.p(0, 0)) -- life of particles particleSystem:setLife(4) @@ -1357,27 +1347,23 @@ local function ReorderParticleSystems() particleSystem:setEndSpinVar(0) -- color of particles - local startColor = Color4F:new() - startColor.r = 0 - startColor.g = 0 - startColor.b = 0 - startColor.a = 1 + local startColor = cc.c4f(0, 0, 0, 1) if i == 0 then startColor.r = 1 elseif i == 1 then startColor.g = 1 elseif i == 2 then startColor.b = 1 end particleSystem:setStartColor(startColor) - particleSystem:setStartColorVar(Color4F(0, 0, 0, 0)) + particleSystem:setStartColorVar(cc.c4f(0, 0, 0, 0)) local endColor = startColor particleSystem:setEndColor(endColor) - particleSystem:setEndColorVar(Color4F(0, 0, 0, 0)) + particleSystem:setEndColorVar(cc.c4f(0, 0, 0, 0)) -- size, in pixels particleSystem:setStartSize(32) particleSystem:setStartSizeVar(0) - particleSystem:setEndSize(kCCParticleStartSizeEqualToEndSize) + particleSystem:setEndSize(cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE) -- emits per second particleSystem:setEmissionRate(particleSystem:getTotalParticles() / particleSystem:getLife()) @@ -1386,9 +1372,9 @@ local function ReorderParticleSystems() particleSystem:setPosition(i * 10 + 120, 200) ReorderParticleSystems_batchNode:addChild(particleSystem) - particleSystem:setPositionType(kCCPositionTypeFree) + particleSystem:setPositionType(cc.POSITION_TYPE_FREE ) - particleSystem:release() + --particleSystem:release() end layer:registerScriptHandler(ReorderParticleSystems_onEnterOrExit) @@ -1405,23 +1391,20 @@ end local function PremultipliedAlphaTest() local layer = getBaseLayer() - layer:setColor(Color3B(0, 0, 255)) + layer:setColor(cc.c3b(0, 0, 255)) layer:removeChild(background, true) background = nil - emitter = CCParticleSystemQuad:create("Particles/BoilingFoam.plist") + emitter = cc.ParticleSystemQuad:create("Particles/BoilingFoam.plist") - local tBlendFunc = BlendFunc:new() - tBlendFunc.src = 1 --GL_ONE - tBlendFunc.dst = 0x0303 --GL_ONE_MINUS_SRC_ALPHA - emitter:setBlendFunc(tBlendFunc) + emitter:setBlendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA) --assert(emitter:getOpacityModifyRGB(), "Particle texture does not have premultiplied alpha, test is useless") - emitter:setStartColor(Color4F(1, 1, 1, 1)) - emitter:setEndColor(Color4F(1, 1, 1, 0)) - emitter:setStartColorVar(Color4F(0, 0, 0, 0)) - emitter:setEndColorVar(Color4F(0, 0, 0, 0)) + emitter:setStartColor(cc.c4f(1, 1, 1, 1)) + emitter:setEndColor(cc.c4f(1, 1, 1, 0)) + emitter:setStartColorVar(cc.c4f(0, 0, 0, 0)) + emitter:setEndColorVar(cc.c4f(0, 0, 0, 0)) layer:addChild(emitter, 10) @@ -1436,11 +1419,11 @@ end local function PremultipliedAlphaTest2() local layer = getBaseLayer() - layer:setColor(Color3B(0, 0, 0)) + layer:setColor(cc.c3b(0, 0, 0)) layer:removeChild(background, true) background = nil - emitter = CCParticleSystemQuad:create("Particles/TestPremultipliedAlpha.plist") + emitter = cc.ParticleSystemQuad:create("Particles/TestPremultipliedAlpha.plist") layer:addChild(emitter ,10) titleLabel:setString("premultiplied alpha 2") @@ -1502,7 +1485,7 @@ end function ParticleTest() cclog("ParticleTest") - local scene = CCScene:create() + local scene = cc.Scene:create() SceneIdx = -1 scene:addChild(nextAction()) diff --git a/samples/Lua/TestLua/Resources/luaScript/PerformanceTest/PerformanceSpriteTest.lua b/samples/Lua/TestLua/Resources/luaScript/PerformanceTest/PerformanceSpriteTest.lua index a2fba1bb9d..acf5a59927 100644 --- a/samples/Lua/TestLua/Resources/luaScript/PerformanceTest/PerformanceSpriteTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/PerformanceTest/PerformanceSpriteTest.lua @@ -3,68 +3,68 @@ local kBasicZOrder = 10 local kNodesIncrease = 250 local TEST_COUNT = 7 -local s = CCDirector:getInstance():getWinSize() +local s = cc.Director:getInstance():getWinSize() ----------------------------------- -- For test functions ----------------------------------- local function performanceActions(sprite) - sprite:setPosition(CCPoint(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height))) + sprite:setPosition(cc.p(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height))) local period = 0.5 + math.mod(math.random(1, 99999999), 1000) / 500.0 - local rot = CCRotateBy:create(period, 360.0 * math.random()) - local rot = CCRotateBy:create(period, 360.0 * math.random()) - local permanentRotation = CCRepeatForever:create(CCSequence:createWithTwoActions(rot, rot:reverse())) + local rot = cc.RotateBy:create(period, 360.0 * math.random()) + local rot = cc.RotateBy:create(period, 360.0 * math.random()) + local permanentRotation = cc.RepeatForever:create(cc.Sequence:createWithTwoActions(rot, rot:reverse())) sprite:runAction(permanentRotation) local growDuration = 0.5 + math.mod(math.random(1, 99999999), 1000) / 500.0 - local grow = CCScaleBy:create(growDuration, 0.5, 0.5) - local permanentScaleLoop = CCRepeatForever:create(CCSequence:createWithTwoActions(grow, grow:reverse())) + local grow = cc.ScaleBy:create(growDuration, 0.5, 0.5) + local permanentScaleLoop = cc.RepeatForever:create(cc.Sequence:createWithTwoActions(grow, grow:reverse())) sprite:runAction(permanentScaleLoop) end local function performanceActions20(sprite) if math.random() < 0.2 then - sprite:setPosition(CCPoint(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height))) + sprite:setPosition(cc.p(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height))) else - sprite:setPosition(CCPoint(-1000, -1000)) + sprite:setPosition(cc.p(-1000, -1000)) end local period = 0.5 + math.mod(math.random(1, 99999999), 1000) / 500.0 - local rot = CCRotateBy:create(period, 360.0 * math.random()) - local permanentRotation = CCRepeatForever:create(CCSequence:createWithTwoActions(rot, rot:reverse())) + local rot = cc.RotateBy:create(period, 360.0 * math.random()) + local permanentRotation = cc.RepeatForever:create(cc.Sequence:createWithTwoActions(rot, rot:reverse())) sprite:runAction(permanentRotation) local growDuration = 0.5 + math.mod(math.random(1, 99999999), 1000) / 500.0 - local grow = CCScaleBy:create(growDuration, 0.5, 0.5) - local permanentScaleLoop = CCRepeatForever:create(CCSequence:createWithTwoActions(grow, grow:reverse())) + local grow = cc.ScaleBy:create(growDuration, 0.5, 0.5) + local permanentScaleLoop = cc.RepeatForever:create(cc.Sequence:createWithTwoActions(grow, grow:reverse())) sprite:runAction(permanentScaleLoop) end local function performanceRotationScale(sprite) - sprite:setPosition(CCPoint(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height))) + sprite:setPosition(cc.p(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height))) sprite:setRotation(math.random() * 360) sprite:setScale(math.random() * 2) end local function performancePosition(sprite) - sprite:setPosition(CCPoint(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height))) + sprite:setPosition(cc.p(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height))) end local function performanceout20(sprite) if math.random() < 0.2 then - sprite:setPosition(CCPoint(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height))) + sprite:setPosition(cc.p(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height))) else - sprite:setPosition(CCPoint(-1000, -1000)) + sprite:setPosition(cc.p(-1000, -1000)) end end local function performanceOut100(sprite) - sprite:setPosition(CCPoint( -1000, -1000)) + sprite:setPosition(cc.p( -1000, -1000)) end local function performanceScale(sprite) - sprite:setPosition(CCPoint(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height))) + sprite:setPosition(cc.p(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height))) sprite:setScale(math.random() * 100 / 50) end @@ -72,43 +72,43 @@ end -- Subtest ----------------------------------- local subtestNumber = 1 -local batchNode = nil -- CCSpriteBatchNode -local parent = nil -- CCNode +local batchNode = nil -- cc.SpriteBatchNode +local parent = nil -- cc.Node local function initWithSubTest(nSubTest, p) subtestNumber = nSubTest parent = p batchNode = nil - local mgr = CCTextureCache:getInstance() + local mgr = cc.TextureCache:getInstance() -- remove all texture mgr:removeTexture(mgr:addImage("Images/grossinis_sister1.png")) mgr:removeTexture(mgr:addImage("Images/grossini_dance_atlas.png")) mgr:removeTexture(mgr:addImage("Images/spritesheet1.png")) if subtestNumber == 2 then - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888) - batchNode = CCSpriteBatchNode:create("Images/grossinis_sister1.png", 100) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888) + batchNode = cc.SpriteBatchNode:create("Images/grossinis_sister1.png", 100) p:addChild(batchNode, 0) elseif subtestNumber == 3 then - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444) - batchNode = CCSpriteBatchNode:create("Images/grossinis_sister1.png", 100) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444) + batchNode = cc.SpriteBatchNode:create("Images/grossinis_sister1.png", 100) p:addChild(batchNode, 0) elseif subtestNumber == 5 then - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888) - batchNode = CCSpriteBatchNode:create("Images/grossini_dance_atlas.png", 100) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888) + batchNode = cc.SpriteBatchNode:create("Images/grossini_dance_atlas.png", 100) p:addChild(batchNode, 0) elseif subtestNumber == 6 then - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444) - batchNode = CCSpriteBatchNode:create("Images/grossini_dance_atlas.png", 100) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444) + batchNode = cc.SpriteBatchNode:create("Images/grossini_dance_atlas.png", 100) p:addChild(batchNode, 0) elseif subtestNumber == 8 then - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888) - batchNode = CCSpriteBatchNode:create("Images/spritesheet1.png", 100) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888) + batchNode = cc.SpriteBatchNode:create("Images/spritesheet1.png", 100) p:addChild(batchNode, 0) elseif subtestNumber == 9 then - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444) - batchNode = CCSpriteBatchNode:create("Images/spritesheet1.png", 100) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444) + batchNode = cc.SpriteBatchNode:create("Images/spritesheet1.png", 100) p:addChild(batchNode, 0) end @@ -117,21 +117,21 @@ local function initWithSubTest(nSubTest, p) batchNode:retain() end - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_Default) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE_PIXELFORMAT_DEFAULT) end local function createSpriteWithTag(tag) - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888) local sprite = nil if subtestNumber == 1 then - sprite = CCSprite:create("Images/grossinis_sister1.png") + sprite = cc.Sprite:create("Images/grossinis_sister1.png") parent:addChild(sprite, -1, tag + 100) elseif subtestNumber == 2 then - sprite = CCSprite:createWithTexture(batchNode:getTexture(), CCRect(0, 0, 52, 139)) + sprite = cc.Sprite:createWithTexture(batchNode:getTexture(), cc.rect(0, 0, 52, 139)) batchNode:addChild(sprite, 0, tag + 100) elseif subtestNumber == 3 then - sprite = CCSprite:createWithTexture(batchNode:getTexture(), CCRect(0, 0, 52, 139)) + sprite = cc.Sprite:createWithTexture(batchNode:getTexture(), cc.rect(0, 0, 52, 139)) batchNode:addChild(sprite, 0, tag + 100) elseif subtestNumber == 4 then local idx = math.floor((math.random() * 1400 / 100)) + 1 @@ -142,7 +142,7 @@ local function createSpriteWithTag(tag) num = idx end local str = "Images/grossini_dance_" .. num .. ".png" - sprite = CCSprite:create(str) + sprite = cc.Sprite:create(str) parent:addChild(sprite, -1, tag + 100) elseif subtestNumber == 5 then local y, x @@ -151,7 +151,7 @@ local function createSpriteWithTag(tag) x = math.mod(r, 5) x = x * 85 y = y * 121 - sprite = CCSprite:createWithTexture(batchNode:getTexture(), CCRect(x, y, 85, 121)) + sprite = cc.Sprite:createWithTexture(batchNode:getTexture(), cc.rect(x, y, 85, 121)) batchNode:addChild(sprite, 0, tag + 100) elseif subtestNumber == 6 then local y, x @@ -160,7 +160,7 @@ local function createSpriteWithTag(tag) x = math.mod(r, 5) x = x * 85 y = y * 121 - sprite = CCSprite:createWithTexture(batchNode:getTexture(), CCRect(x, y, 85, 121)) + sprite = cc.Sprite:createWithTexture(batchNode:getTexture(), cc.rect(x, y, 85, 121)) batchNode:addChild(sprite, 0, tag + 100) elseif subtestNumber == 7 then local y, x @@ -168,7 +168,7 @@ local function createSpriteWithTag(tag) y = math.floor(r / 8) x = math.mod(r, 8) local str = "Images/sprites_test/sprite-"..x.."-"..y..".png" - sprite = CCSprite:create(str) + sprite = cc.Sprite:create(str) parent:addChild(sprite, -1, tag + 100) elseif subtestNumber == 8 then local y, x @@ -177,7 +177,7 @@ local function createSpriteWithTag(tag) x = math.mod(r, 8) x = x * 32 y = y * 32 - sprite = CCSprite:createWithTexture(batchNode:getTexture(), CCRect(x, y, 32, 32)) + sprite = cc.Sprite:createWithTexture(batchNode:getTexture(), cc.rect(x, y, 32, 32)) batchNode:addChild(sprite, 0, tag + 100) elseif subtestNumber == 9 then local y, x @@ -186,11 +186,11 @@ local function createSpriteWithTag(tag) x = math.mod(r, 8) x = x * 32 y = y * 32 - sprite = CCSprite:createWithTexture(batchNode:getTexture(), CCRect(x, y, 32, 32)) + sprite = cc.Sprite:createWithTexture(batchNode:getTexture(), cc.rect(x, y, 32, 32)) batchNode:addChild(sprite, 0, tag + 100) end - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_Default) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE_PIXELFORMAT_DEFAULT) return sprite end @@ -215,7 +215,7 @@ local maxCases = 7 local function showThisTest() local scene = CreateSpriteTestScene() - CCDirector:getInstance():replaceScene(scene) + cc.Director:getInstance():replaceScene(scene) end local function backCallback(sender) @@ -240,23 +240,23 @@ local function nextCallback(sender) end local function toPerformanceMainLayer(sender) - CCDirector:getInstance():replaceScene(PerformanceTest()) + cc.Director:getInstance():replaceScene(PerformanceTest()) end local function initWithLayer(layer, controlMenuVisible) - CCMenuItemFont:setFontName("Arial") - CCMenuItemFont:setFontSize(24) - local mainItem = CCMenuItemFont:create("Back") + cc.MenuItemFont:setFontName("Arial") + cc.MenuItemFont:setFontSize(24) + local mainItem = cc.MenuItemFont:create("Back") mainItem:registerScriptTapHandler(toPerformanceMainLayer) mainItem:setPosition(s.width - 50, 25) - local menu = CCMenu:create() + local menu = cc.Menu:create() menu:addChild(mainItem) - menu:setPosition(CCPoint(0, 0)) + menu:setPosition(cc.p(0, 0)) if controlMenuVisible == true then - local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2) - local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2) - local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2) + local item1 = cc.MenuItemImage:create(s_pPathB1, s_pPathB2) + local item2 = cc.MenuItemImage:create(s_pPathR1, s_pPathR2) + local item3 = cc.MenuItemImage:create(s_pPathF1, s_pPathF2) item1:registerScriptTapHandler(backCallback) item2:registerScriptTapHandler(restartCallback) item3:registerScriptTapHandler(nextCallback) @@ -342,56 +342,56 @@ local function initWithMainTest(scene, asubtest, nNodes) lastRenderedCount = 0 quantityNodes = 0 - CCMenuItemFont:setFontSize(65) - local decrease = CCMenuItemFont:create(" - ") + cc.MenuItemFont:setFontSize(65) + local decrease = cc.MenuItemFont:create(" - ") decrease:registerScriptTapHandler(onDecrease) - decrease:setColor(Color3B(0, 200, 20)) - local increase = CCMenuItemFont:create(" + ") + decrease:setColor(cc.c3b(0, 200, 20)) + local increase = cc.MenuItemFont:create(" + ") increase:registerScriptTapHandler(onIncrease) - increase:setColor(Color3B(0, 200, 20)) + increase:setColor(cc.c3b(0, 200, 20)) - local menu = CCMenu:create() + local menu = cc.Menu:create() menu:addChild(decrease) menu:addChild(increase) menu:alignItemsHorizontally() menu:setPosition(s.width / 2, s.height - 65) scene:addChild(menu, 1) - infoLabel = CCLabelTTF:create("0 nodes", "Marker Felt", 30) - infoLabel:setColor(Color3B(0, 200, 20)) + infoLabel = cc.LabelTTF:create("0 nodes", "Marker Felt", 30) + infoLabel:setColor(cc.c3b(0, 200, 20)) infoLabel:setPosition(s.width / 2, s.height - 90) scene:addChild(infoLabel, 1) maxCases = TEST_COUNT -- Sub Tests - CCMenuItemFont:setFontSize(32) - subMenu = CCMenu:create() + cc.MenuItemFont:setFontSize(32) + subMenu = cc.Menu:create() for i = 1, 9 do local str = i .. " " - local itemFont = CCMenuItemFont:create(str) + local itemFont = cc.MenuItemFont:create(str) itemFont:registerScriptTapHandler(testNCallback) --itemFont:setTag(i) subMenu:addChild(itemFont, kBasicZOrder + i, kBasicZOrder + i) if i <= 3 then - itemFont:setColor(Color3B(200, 20, 20)) + itemFont:setColor(cc.c3b(200, 20, 20)) elseif i <= 6 then - itemFont:setColor(Color3B(0, 200, 20)) + itemFont:setColor(cc.c3b(0, 200, 20)) else - itemFont:setColor(Color3B(0, 20, 200)) + itemFont:setColor(cc.c3b(0, 20, 200)) end end subMenu:alignItemsHorizontally() - subMenu:setPosition(CCPoint(s.width / 2, 80)) + subMenu:setPosition(cc.p(s.width / 2, 80)) scene:addChild(subMenu, 1) -- add title label - titleLabel = CCLabelTTF:create("No title", "Arial", 40) + titleLabel = cc.LabelTTF:create("No title", "Arial", 40) scene:addChild(titleLabel, 1) titleLabel:setPosition(s.width / 2, s.height - 32) - titleLabel:setColor(Color3B(255, 255, 40)) + titleLabel:setColor(cc.c3b(255, 255, 40)) while quantityNodes < nNodes do onIncrease() @@ -406,7 +406,7 @@ function doPerformSpriteTest1(sprite) end local function SpriteTestLayer1() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer, true) local str = "A (" .. subtestNumber .. ") position" @@ -423,7 +423,7 @@ function doPerformSpriteTest2(sprite) end local function SpriteTestLayer2() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer, true) local str = "B (" .. subtestNumber .. ") scale" @@ -440,7 +440,7 @@ function doPerformSpriteTest3(sprite) end local function SpriteTestLayer3() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer, true) local str = "C (" .. subtestNumber .. ") scale + rot" @@ -457,7 +457,7 @@ function doPerformSpriteTest4(sprite) end local function SpriteTestLayer4() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer, true) local str = "D (" .. subtestNumber .. ") 100% out" @@ -474,7 +474,7 @@ function doPerformSpriteTest5(sprite) end local function SpriteTestLayer5() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer, true) local str = "E (" .. subtestNumber .. ") 80% out" @@ -491,7 +491,7 @@ function doPerformSpriteTest6(sprite) end local function SpriteTestLayer6() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer, true) local str = "F (" .. subtestNumber .. ") actions" @@ -508,7 +508,7 @@ function doPerformSpriteTest7(sprite) end local function SpriteTestLayer7() - local layer = CCLayer:create() + local layer = cc.Layer:create() initWithLayer(layer, true) local str = "G (" .. subtestNumber .. ") actions 80% out" @@ -521,7 +521,7 @@ end -- PerformanceSpriteTest ----------------------------------- function CreateSpriteTestScene() - local scene = CCScene:create() + local scene = cc.Scene:create() initWithMainTest(scene, subtestNumber, kNodesIncrease) if curCase == 0 then diff --git a/samples/Lua/TestLua/Resources/luaScript/PerformanceTest/PerformanceTest.lua b/samples/Lua/TestLua/Resources/luaScript/PerformanceTest/PerformanceTest.lua index f0527c93ad..6673fc8d67 100644 --- a/samples/Lua/TestLua/Resources/luaScript/PerformanceTest/PerformanceTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/PerformanceTest/PerformanceTest.lua @@ -13,7 +13,7 @@ local testsName = "PerformanceTouchesTest" } -local s = CCDirector:getInstance():getWinSize() +local s = cc.Director:getInstance():getWinSize() --Create toMainLayr MenuItem function CreatePerfomBasicLayerMenu(pMenu) @@ -23,14 +23,14 @@ function CreatePerfomBasicLayerMenu(pMenu) local function toMainLayer() local pScene = PerformanceTestMain() if pScene ~= nil then - CCDirector:getInstance():replaceScene(pScene) + cc.Director:getInstance():replaceScene(pScene) end end --Create BackMneu - CCMenuItemFont:setFontName("Arial") - CCMenuItemFont:setFontSize(24) - local pMenuItemFont = CCMenuItemFont:create("Back") - pMenuItemFont:setPosition(CCPoint(VisibleRect:rightBottom().x - 50, VisibleRect:rightBottom().y + 25)) + cc.MenuItemFont:setFontName("Arial") + cc.MenuItemFont:setFontSize(24) + local pMenuItemFont = cc.MenuItemFont:create("Back") + pMenuItemFont:setPosition(cc.p(VisibleRect:rightBottom().x - 50, VisibleRect:rightBottom().y + 25)) pMenuItemFont:registerScriptTapHandler(toMainLayer) pMenu:addChild(pMenuItemFont) end @@ -62,7 +62,7 @@ local function runNodeChildrenTest() local nMaxCases = 0 local nCurCase = 0 - local pNewscene = CCScene:create() + local pNewscene = cc.Scene:create() local function GetTitle() if 0 == nCurCase then @@ -125,21 +125,21 @@ local function runNodeChildrenTest() ShowCurrentTest() end - local size = CCDirector:getInstance():getWinSize() - local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2) + local size = cc.Director:getInstance():getWinSize() + local item1 = cc.MenuItemImage:create(s_pPathB1, s_pPathB2) item1:registerScriptTapHandler(backCallback) pMenu:addChild(item1,kItemTagBasic) - local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2) + local item2 = cc.MenuItemImage:create(s_pPathR1, s_pPathR2) item2:registerScriptTapHandler(restartCallback) pMenu:addChild(item2,kItemTagBasic) - local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2) + local item3 = cc.MenuItemImage:create(s_pPathF1, s_pPathF2) pMenu:addChild(item3,kItemTagBasic) item3:registerScriptTapHandler(nextCallback) - local size = CCDirector:getInstance():getWinSize() - item1:setPosition(CCPoint(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) - item2:setPosition(CCPoint(size.width / 2, item2:getContentSize().height / 2)) - item3:setPosition(CCPoint(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + local size = cc.Director:getInstance():getWinSize() + item1:setPosition(cc.p(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + item2:setPosition(cc.p(size.width / 2, item2:getContentSize().height / 2)) + item3:setPosition(cc.p(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) end end end @@ -147,7 +147,7 @@ local function runNodeChildrenTest() local function updateQuantityLabel() if nQuantityOfNodes ~= nLastRenderedCount then -- local pInfoLabel = pNewscene:getChildByTag(NodeChildrenTestParam.kTagInfoLayer) - local pInfoLabel = tolua.cast(pNewscene:getChildByTag(NodeChildrenTestParam.kTagInfoLayer), "CCLabelTTF") + local pInfoLabel = tolua.cast(pNewscene:getChildByTag(NodeChildrenTestParam.kTagInfoLayer), "LabelTTF") local strNode = nQuantityOfNodes.." nodes" pInfoLabel:setString(strNode) nLastRenderedCount = nQuantityOfNodes @@ -164,9 +164,9 @@ local function runNodeChildrenTest() return end local i = 0 - local len = pChildren:count() + local len = table.getn(pChildren) for i = 0, len - 1, 1 do - local child = tolua.cast(pChildren:objectAtIndex(i), "CCSprite") + local child = tolua.cast(pChildren[i + 1], "Sprite") child:setVisible(false) end end @@ -180,16 +180,16 @@ local function runNodeChildrenTest() local nTotalToAdd = nCurrentQuantityOfNodes * 0.15 local zs = {} if nTotalToAdd > 0 then - local pSprites = CCArray:createWithCapacity(nTotalToAdd) + local pSprites = {} local i = 0 for i = 0 , nTotalToAdd - 1 do - local pSprite = CCSprite:createWithTexture(pBatchNode:getTexture(), CCRect(0,0,32,32)) - pSprites:addObject(pSprite) + local pSprite = cc.Sprite:createWithTexture(pBatchNode:getTexture(), cc.rect(0,0,32,32)) + pSprites[i + 1] = pSprite zs[i] = math.random(-1,1) * 50 end for i = 0 , nTotalToAdd - 1 do - local pChild = tolua.cast(pSprites:objectAtIndex(i),"CCNode") + local pChild = tolua.cast(pSprites[i + 1],"Node") pBatchNode:addChild(pChild, zs[i], NodeChildrenTestParam.kTagBase + i) end @@ -207,17 +207,16 @@ local function runNodeChildrenTest() end local nTotalToAdd = nCurrentQuantityOfNodes * 0.15 if nTotalToAdd > 0 then - local pSprites = CCArray:createWithCapacity(nTotalToAdd) - + local pSprites = {} -- Don't include the sprite creation time as part of the profiling local i = 0 for i = 0, nTotalToAdd - 1 do - local pSprite = CCSprite:createWithTexture(pBatchNode:getTexture(), CCRect(0,0,32,32)) - pSprites:addObject(pSprite) + local pSprite = cc.Sprite:createWithTexture(pBatchNode:getTexture(), cc.rect(0,0,32,32)) + pSprites[i + 1] = pSprite end -- add them with random Z (very important!) for i=0, nTotalToAdd - 1 do - local pChild = tolua.cast(pSprites:objectAtIndex(i),"CCNode") + local pChild = tolua.cast(pSprites[i + 1],"Node") pBatchNode:addChild(pChild, math.random(-1,1) * 50, NodeChildrenTestParam.kTagBase + i) end @@ -235,18 +234,17 @@ local function runNodeChildrenTest() local nTotalToAdd = nCurrentQuantityOfNodes * 0.15 if nTotalToAdd > 0 then - local pSprites = CCArray:createWithCapacity(nTotalToAdd) - + local pSprites = {} -- Don't include the sprite creation time as part of the profiling local i = 0 for i = 0,nTotalToAdd - 1 do - local pSprite = CCSprite:createWithTexture(pBatchNode:getTexture(), CCRect(0,0,32,32)) - pSprites:addObject(pSprite) + local pSprite = cc.Sprite:createWithTexture(pBatchNode:getTexture(), cc.rect(0,0,32,32)) + pSprites[i + 1] = pSprite end --dd them with random Z (very important!) for i = 0, nTotalToAdd - 1 do - local pChild = tolua.cast(pSprites:objectAtIndex(i),"CCNode") + local pChild = tolua.cast(pSprites[i + 1] ,"Node") pBatchNode:addChild(pChild, math.random(-1,1) * 50, NodeChildrenTestParam.kTagBase + i) end @@ -254,7 +252,7 @@ local function runNodeChildrenTest() -- reorder them for i = 0, nTotalToAdd - 1 do - local pNode = tolua.cast(pBatchNode:getChildren():objectAtIndex(i),"CCNode") + local pNode = tolua.cast(pSprites[i + 1],"Node") pBatchNode:reorderChild(pNode, math.random(-1,1) * 50) end pBatchNode:sortAllChildren() @@ -278,14 +276,14 @@ local function runNodeChildrenTest() end local function updateQuantityOfNodes() - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() --increase nodes if( nCurrentQuantityOfNodes < nQuantityOfNodes ) then local i = 0 for i = 0,nQuantityOfNodes - nCurrentQuantityOfNodes - 1 do - local sprite = CCSprite:createWithTexture(pBatchNode:getTexture(), CCRect(0, 0, 32, 32)) + local sprite = cc.Sprite:createWithTexture(pBatchNode:getTexture(), cc.rect(0, 0, 32, 32)) pBatchNode:addChild(sprite) - sprite:setPosition(CCPoint( math.random() * s.width, math.random() * s.height)) + sprite:setPosition(cc.p( math.random() * s.width, math.random() * s.height)) if 0 ~= nCurCase then sprite:setVisible(false) end @@ -325,29 +323,29 @@ local function runNodeChildrenTest() local function SpecialInitWithQuantityOfNodes() -- if 0 == nCurCase then - pBatchNode = CCSpriteBatchNode:create("Images/spritesheet1.png") + pBatchNode = cc.SpriteBatchNode:create("Images/spritesheet1.png") pNewscene:addChild(pBatchNode) --[[ else - pBatchNode = CCSpriteBatchNode:create("Images/spritesheet1.png") + pBatchNode = cc.SpriteBatchNode:create("Images/spritesheet1.png") pNewscene:addChild(pBatchNode) end ]]-- end local function MainSceneInitWithQuantityOfNodes(nNodes) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() --Title - local pLabel = CCLabelTTF:create(GetTitle(), "Arial", 40) + local pLabel = cc.LabelTTF:create(GetTitle(), "Arial", 40) pNewscene:addChild(pLabel, 1) - pLabel:setPosition(CCPoint(s.width/2, s.height-32)) - pLabel:setColor(Color3B(255,255,40)) + pLabel:setPosition(cc.p(s.width/2, s.height-32)) + pLabel:setColor(cc.c3b(255,255,40)) if (nil ~= GetSubTitle()) and ("" ~= GetSubTitle()) then - local pSubLabel = CCLabelTTF:create(GetSubTitle(), "Thonburi", 16) + local pSubLabel = cc.LabelTTF:create(GetSubTitle(), "Thonburi", 16) pNewscene:addChild(pSubLabel, 1) - pSubLabel:setPosition(CCPoint(s.width/2, s.height-80)) + pSubLabel:setPosition(cc.p(s.width/2, s.height-80)) end nLastRenderedCount = 0 @@ -355,33 +353,33 @@ local function runNodeChildrenTest() nQuantityOfNodes = nNodes --"+","-" Menu - CCMenuItemFont:setFontSize(65) - local pDecrease = CCMenuItemFont:create(" - ") + cc.MenuItemFont:setFontSize(65) + local pDecrease = cc.MenuItemFont:create(" - ") pDecrease:registerScriptTapHandler(onDecrease) - pDecrease:setColor(Color3B(0,200,20)) - local pIncrease = CCMenuItemFont:create(" + ") + pDecrease:setColor(cc.c3b(0,200,20)) + local pIncrease = cc.MenuItemFont:create(" + ") pIncrease:registerScriptTapHandler(onIncrease) - pIncrease:setColor(Color3B(0,200,20)) + pIncrease:setColor(cc.c3b(0,200,20)) - local pMenuAddOrSub = CCMenu:create() + local pMenuAddOrSub = cc.Menu:create() pMenuAddOrSub:addChild(pDecrease) pMenuAddOrSub:addChild(pIncrease) pMenuAddOrSub:alignItemsHorizontally() - pMenuAddOrSub:setPosition(CCPoint(s.width/2, s.height/2+15)) + pMenuAddOrSub:setPosition(cc.p(s.width/2, s.height/2+15)) pNewscene:addChild(pMenuAddOrSub,1) --InfoLayer - local pInfoLabel = CCLabelTTF:create("0 nodes", "Marker Felt", 30) - pInfoLabel:setColor(Color3B(0,200,20)) - pInfoLabel:setPosition(CCPoint(s.width/2, s.height/2-15)) + local pInfoLabel = cc.LabelTTF:create("0 nodes", "Marker Felt", 30) + pInfoLabel:setColor(cc.c3b(0,200,20)) + pInfoLabel:setPosition(cc.p(s.width/2, s.height/2-15)) pNewscene:addChild(pInfoLabel, 1, NodeChildrenTestParam.kTagInfoLayer) --NodeChildrenMenuLayer - local pNodeChildrenMenuLayer = CCLayer:create() - local pNodeChildrenMenuMenu = CCMenu:create() + local pNodeChildrenMenuLayer = cc.Layer:create() + local pNodeChildrenMenuMenu = cc.Menu:create() CreatePerfomBasicLayerMenu(pNodeChildrenMenuMenu) CreateBasicLayerMenuItem(pNodeChildrenMenuMenu,true,NodeChildrenTestParam.TEST_COUNT,nCurCase) - pNodeChildrenMenuMenu:setPosition(CCPoint(0, 0)) + pNodeChildrenMenuMenu:setPosition(cc.p(0, 0)) pNodeChildrenMenuLayer:addChild(pNodeChildrenMenuMenu) pNewscene:addChild(pNodeChildrenMenuLayer) @@ -395,13 +393,13 @@ local function runNodeChildrenTest() pNewscene:unscheduleUpdate() end - pNewscene = CCScene:create() + pNewscene = cc.Scene:create() if nil ~= pNewscene then SpecialInitWithQuantityOfNodes() MainSceneInitWithQuantityOfNodes(nQuantityOfNodes) -- pNewscene:registerScriptHandler(onNodeEvent) NodeChildrenScheduleUpdate() - CCDirector:getInstance():replaceScene(pNewscene) + cc.Director:getInstance():replaceScene(pNewscene) end end @@ -442,7 +440,7 @@ local function runParticleTest() local ScheduleSelector = nil - local pNewScene = CCScene:create() + local pNewScene = cc.Scene:create() local function GetTitle() local strTitle = nil @@ -483,21 +481,21 @@ local function runParticleTest() ShowCurrentTest() end - local size = CCDirector:getInstance():getWinSize() - local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2) + local size = cc.Director:getInstance():getWinSize() + local item1 = cc.MenuItemImage:create(s_pPathB1, s_pPathB2) item1:registerScriptTapHandler(backCallback) pMenu:addChild(item1,kItemTagBasic) - local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2) + local item2 = cc.MenuItemImage:create(s_pPathR1, s_pPathR2) item2:registerScriptTapHandler(restartCallback) pMenu:addChild(item2,kItemTagBasic) - local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2) + local item3 = cc.MenuItemImage:create(s_pPathF1, s_pPathF2) pMenu:addChild(item3,kItemTagBasic) item3:registerScriptTapHandler(nextCallback) - local size = CCDirector:getInstance():getWinSize() - item1:setPosition(CCPoint(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) - item2:setPosition(CCPoint(size.width / 2, item2:getContentSize().height / 2)) - item3:setPosition(CCPoint(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + local size = cc.Director:getInstance():getWinSize() + item1:setPosition(cc.p(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + item2:setPosition(cc.p(size.width / 2, item2:getContentSize().height / 2)) + item3:setPosition(cc.p(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) end end end @@ -510,7 +508,7 @@ local function runParticleTest() local function UpdateQuantityLabel() if nQuantityParticles ~= nLastRenderedCount then - local pInfoLabel = tolua.cast(pNewScene:getChildByTag(ParticleTestParam.kTagInfoLayer), "CCLabelTTF") + local pInfoLabel = tolua.cast(pNewScene:getChildByTag(ParticleTestParam.kTagInfoLayer), "LabelTTF") local strInfo = string.format("%u particles", nQuantityParticles) pInfoLabel:setString(strInfo) @@ -519,8 +517,8 @@ local function runParticleTest() end local function doTest() - local s = CCDirector:getInstance():getWinSize() - local pParticleSystem = tolua.cast(pNewScene:getChildByTag(ParticleTestParam.kTagParticleSystem),"CCParticleSystem") + local s = cc.Director:getInstance():getWinSize() + local pParticleSystem = tolua.cast(pNewScene:getChildByTag(ParticleTestParam.kTagParticleSystem),"ParticleSystem") if nil == pParticleSystem then return end @@ -529,7 +527,7 @@ local function runParticleTest() pParticleSystem:setDuration(-1) --gravity - pParticleSystem:setGravity(CCPoint(0,-90)) + pParticleSystem:setGravity(cc.p(0,-90)) --angle pParticleSystem:setAngle(90) @@ -544,8 +542,8 @@ local function runParticleTest() pParticleSystem:setSpeedVar(50) -- emitter position - pParticleSystem:setPosition(CCPoint(s.width/2, 100)) - pParticleSystem:setPosVar(CCPoint(s.width/2,0)) + pParticleSystem:setPosition(cc.p(s.width/2, 100)) + pParticleSystem:setPosVar(cc.p(s.width/2,0)) -- life of particles pParticleSystem:setLife(2.0) @@ -555,13 +553,13 @@ local function runParticleTest() pParticleSystem:setEmissionRate(pParticleSystem:getTotalParticles() / pParticleSystem:getLife()) --color of particles - pParticleSystem:setStartColor(Color4F(0.5, 0.5, 0.5, 1.0)) + pParticleSystem:setStartColor(cc.c4f(0.5, 0.5, 0.5, 1.0)) - pParticleSystem:setStartColorVar( Color4F(0.5, 0.5, 0.5, 1.0)) + pParticleSystem:setStartColorVar( cc.c4f(0.5, 0.5, 0.5, 1.0)) - pParticleSystem:setEndColor(Color4F(0.1, 0.1, 0.1, 0.2)) + pParticleSystem:setEndColor(cc.c4f(0.1, 0.1, 0.1, 0.2)) - pParticleSystem:setEndColorVar(Color4F(0.1, 0.1, 0.1, 0.2)) + pParticleSystem:setEndColorVar(cc.c4f(0.1, 0.1, 0.1, 0.2)) -- size, in pixels pParticleSystem:setEndSize(4.0) @@ -577,7 +575,7 @@ local function runParticleTest() pParticleSystem:setDuration(-1) --gravity - pParticleSystem:setGravity(CCPoint(0,-90)) + pParticleSystem:setGravity(cc.p(0,-90)) --angle pParticleSystem:setAngle(90) @@ -592,8 +590,8 @@ local function runParticleTest() pParticleSystem:setSpeedVar(50) -- emitter position - pParticleSystem:setPosition(CCPoint(s.width/2, 100)) - pParticleSystem:setPosVar(CCPoint(s.width/2,0)) + pParticleSystem:setPosition(cc.p(s.width/2, 100)) + pParticleSystem:setPosVar(cc.p(s.width/2,0)) -- life of particles pParticleSystem:setLife(2.0) @@ -603,13 +601,13 @@ local function runParticleTest() pParticleSystem:setEmissionRate(pParticleSystem:getTotalParticles() / pParticleSystem:getLife()) --color of particles - pParticleSystem:setStartColor(Color4F(0.5, 0.5, 0.5, 1.0)) + pParticleSystem:setStartColor(cc.c4f(0.5, 0.5, 0.5, 1.0)) - pParticleSystem:setStartColorVar( Color4F(0.5, 0.5, 0.5, 1.0)) + pParticleSystem:setStartColorVar( cc.c4f(0.5, 0.5, 0.5, 1.0)) - pParticleSystem:setEndColor(Color4F(0.1, 0.1, 0.1, 0.2)) + pParticleSystem:setEndColor(cc.c4f(0.1, 0.1, 0.1, 0.2)) - pParticleSystem:setEndColorVar(Color4F(0.1, 0.1, 0.1, 0.2)) + pParticleSystem:setEndColorVar(cc.c4f(0.1, 0.1, 0.1, 0.2)) -- size, in pixels pParticleSystem:setEndSize(8.0) @@ -624,7 +622,7 @@ local function runParticleTest() pParticleSystem:setDuration(-1) --gravity - pParticleSystem:setGravity(CCPoint(0,-90)) + pParticleSystem:setGravity(cc.p(0,-90)) --angle pParticleSystem:setAngle(90) @@ -639,8 +637,8 @@ local function runParticleTest() pParticleSystem:setSpeedVar(50) -- emitter position - pParticleSystem:setPosition(CCPoint(s.width/2, 100)) - pParticleSystem:setPosVar(CCPoint(s.width/2,0)) + pParticleSystem:setPosition(cc.p(s.width/2, 100)) + pParticleSystem:setPosVar(cc.p(s.width/2,0)) -- life of particles pParticleSystem:setLife(2.0) @@ -650,13 +648,13 @@ local function runParticleTest() pParticleSystem:setEmissionRate(pParticleSystem:getTotalParticles() / pParticleSystem:getLife()) --color of particles - pParticleSystem:setStartColor(Color4F(0.5, 0.5, 0.5, 1.0)) + pParticleSystem:setStartColor(cc.c4f(0.5, 0.5, 0.5, 1.0)) - pParticleSystem:setStartColorVar( Color4F(0.5, 0.5, 0.5, 1.0)) + pParticleSystem:setStartColorVar( cc.c4f(0.5, 0.5, 0.5, 1.0)) - pParticleSystem:setEndColor(Color4F(0.1, 0.1, 0.1, 0.2)) + pParticleSystem:setEndColor(cc.c4f(0.1, 0.1, 0.1, 0.2)) - pParticleSystem:setEndColorVar(Color4F(0.1, 0.1, 0.1, 0.2)) + pParticleSystem:setEndColorVar(cc.c4f(0.1, 0.1, 0.1, 0.2)) -- size, in pixels pParticleSystem:setEndSize(32.0) @@ -671,7 +669,7 @@ local function runParticleTest() pParticleSystem:setDuration(-1) --gravity - pParticleSystem:setGravity(CCPoint(0,-90)) + pParticleSystem:setGravity(cc.p(0,-90)) --angle pParticleSystem:setAngle(90) @@ -686,8 +684,8 @@ local function runParticleTest() pParticleSystem:setSpeedVar(50) -- emitter position - pParticleSystem:setPosition(CCPoint(s.width/2, 100)) - pParticleSystem:setPosVar(CCPoint(s.width/2,0)) + pParticleSystem:setPosition(cc.p(s.width/2, 100)) + pParticleSystem:setPosVar(cc.p(s.width/2,0)) -- life of particles pParticleSystem:setLife(2.0) @@ -697,13 +695,13 @@ local function runParticleTest() pParticleSystem:setEmissionRate(pParticleSystem:getTotalParticles() / pParticleSystem:getLife()) --color of particles - pParticleSystem:setStartColor(Color4F(0.5, 0.5, 0.5, 1.0)) + pParticleSystem:setStartColor(cc.c4f(0.5, 0.5, 0.5, 1.0)) - pParticleSystem:setStartColorVar( Color4F(0.5, 0.5, 0.5, 1.0)) + pParticleSystem:setStartColorVar( cc.c4f(0.5, 0.5, 0.5, 1.0)) - pParticleSystem:setEndColor(Color4F(0.1, 0.1, 0.1, 0.2)) + pParticleSystem:setEndColor(cc.c4f(0.1, 0.1, 0.1, 0.2)) - pParticleSystem:setEndColorVar(Color4F(0.1, 0.1, 0.1, 0.2)) + pParticleSystem:setEndColorVar(cc.c4f(0.1, 0.1, 0.1, 0.2)) -- size, in pixels pParticleSystem:setEndSize(64.0) @@ -733,21 +731,21 @@ local function runParticleTest() pNewScene:removeChildByTag(ParticleTestParam.kTagParticleSystem, true) --remove the "fire.png" from the TextureCache cache. - local pTexture = CCTextureCache:getInstance():addImage("Images/fire.png") - CCTextureCache:getInstance():removeTexture(pTexture) - local pParticleSystem = CCParticleSystemQuad:new() + local pTexture = cc.TextureCache:getInstance():addImage("Images/fire.png") + cc.TextureCache:getInstance():removeTexture(pTexture) + local pParticleSystem = cc.ParticleSystemQuad:new() if 1 == nSubtestNumber then - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888) elseif 2 == nSubtestNumber then - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444) elseif 3 == nSubtestNumber then - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_A8) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_A8) elseif 4 == nSubtestNumber then - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888) elseif 5 == nSubtestNumber then - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444) elseif 6 == nSubtestNumber then - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_A8) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_A8) else pParticleSystem = nil print("Shall not happen!") @@ -755,26 +753,26 @@ local function runParticleTest() if nil ~= pParticleSystem then pParticleSystem:initWithTotalParticles(nQuantityParticles) - pParticleSystem:setTexture(CCTextureCache:getInstance():addImage("Images/fire.png")) + pParticleSystem:setTexture(cc.TextureCache:getInstance():addImage("Images/fire.png")) end pNewScene:addChild(pParticleSystem, 0, ParticleTestParam.kTagParticleSystem) doTest() --restore the default pixel format - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888) end local function step(t) - local pAtlas = tolua.cast(pNewScene:getChildByTag(ParticleTestParam.kTagLabelAtlas),"CCLabelAtlas") - local pEmitter = tolua.cast(pNewScene:getChildByTag(ParticleTestParam.kTagParticleSystem),"CCParticleSystem") + local pAtlas = tolua.cast(pNewScene:getChildByTag(ParticleTestParam.kTagLabelAtlas),"LabelAtlas") + local pEmitter = tolua.cast(pNewScene:getChildByTag(ParticleTestParam.kTagParticleSystem),"ParticleSystem") local strInfo = string.format("%4d",pEmitter:getParticleCount()) pAtlas:setString(strInfo) end local function ScheduleFuncion() local function OnEnterOrExit(tag) - local scheduler = CCDirector:getInstance():getScheduler() + local scheduler = cc.Director:getInstance():getScheduler() if tag == "enter" then ScheduleSelector = scheduler:scheduleScriptFunc(step,0,false) elseif tag == "exit" then @@ -806,69 +804,69 @@ local function runParticleTest() local function InitWithSubTest(nSubtest,nParticles) nSubtestNumber = nSubtest - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() nLastRenderedCount = 0 nQuantityParticles = nParticles --"+","-" Menu - CCMenuItemFont:setFontSize(65) - local pDecrease = CCMenuItemFont:create(" - ") + cc.MenuItemFont:setFontSize(65) + local pDecrease = cc.MenuItemFont:create(" - ") pDecrease:registerScriptTapHandler(onDecrease) - pDecrease:setColor(Color3B(0,200,20)) - local pIncrease = CCMenuItemFont:create(" + ") + pDecrease:setColor(cc.c3b(0,200,20)) + local pIncrease = cc.MenuItemFont:create(" + ") pIncrease:registerScriptTapHandler(onIncrease) - pIncrease:setColor(Color3B(0,200,20)) + pIncrease:setColor(cc.c3b(0,200,20)) - local pMenuAddOrSub = CCMenu:create() + local pMenuAddOrSub = cc.Menu:create() pMenuAddOrSub:addChild(pDecrease) pMenuAddOrSub:addChild(pIncrease) pMenuAddOrSub:alignItemsHorizontally() - pMenuAddOrSub:setPosition(CCPoint(s.width/2, s.height/2+15)) + pMenuAddOrSub:setPosition(cc.p(s.width/2, s.height/2+15)) pNewScene:addChild(pMenuAddOrSub,1) - local pInfoLabel = CCLabelTTF:create("0 nodes", "Marker Felt", 30) - pInfoLabel:setColor(Color3B(0,200,20)) - pInfoLabel:setPosition(CCPoint(s.width/2, s.height - 90)) + local pInfoLabel = cc.LabelTTF:create("0 nodes", "Marker Felt", 30) + pInfoLabel:setColor(cc.c3b(0,200,20)) + pInfoLabel:setPosition(cc.p(s.width/2, s.height - 90)) pNewScene:addChild(pInfoLabel, 1, ParticleTestParam.kTagInfoLayer) --particles on stage - local pLabelAtlas = CCLabelAtlas:create("0000", "fps_images.png", 12, 32, string.byte('.')) + local pLabelAtlas = cc.LabelAtlas:_create("0000", "fps_images.png", 12, 32, string.byte('.')) pNewScene:addChild(pLabelAtlas, 0, ParticleTestParam.kTagLabelAtlas) - pLabelAtlas:setPosition(CCPoint(s.width-66,50)) + pLabelAtlas:setPosition(cc.p(s.width-66,50)) --ParticleTestMenuLayer - local pParticleMenuLayer = CCLayer:create() - local pParticleMenu = CCMenu:create() + local pParticleMenuLayer = cc.Layer:create() + local pParticleMenu = cc.Menu:create() CreatePerfomBasicLayerMenu(pParticleMenu) CreateBasicLayerMenuItem(pParticleMenu,true,ParticleTestParam.TEST_COUNT,nCurCase) - pParticleMenu:setPosition(CCPoint(0, 0)) + pParticleMenu:setPosition(cc.p(0, 0)) pParticleMenuLayer:addChild(pParticleMenu) pNewScene:addChild(pParticleMenuLayer) --Sub Tests - CCMenuItemFont:setFontSize(40) - local pSubMenu = CCMenu:create() + cc.MenuItemFont:setFontSize(40) + local pSubMenu = cc.Menu:create() local i = 1 for i = 1, 6 do local strNum = string.format("%d ",i) - local pItemFont = CCMenuItemFont:create(strNum) + local pItemFont = cc.MenuItemFont:create(strNum) pItemFont:registerScriptTapHandler(TestNCallback) pSubMenu:addChild(pItemFont, i + ParticleTestParam.kSubMenuBasicZOrder) if i <= 3 then - pItemFont:setColor(Color3B(200,20,20)) + pItemFont:setColor(cc.c3b(200,20,20)) else - pItemFont:setColor(Color3B(0,200,20)) + pItemFont:setColor(cc.c3b(0,200,20)) end end pSubMenu:alignItemsHorizontally() - pSubMenu:setPosition(CCPoint(s.width/2, 80)) + pSubMenu:setPosition(cc.p(s.width/2, 80)) pNewScene:addChild(pSubMenu, 2) - local pLabel = CCLabelTTF:create(GetTitle(), "Arial", 40) + local pLabel = cc.LabelTTF:create(GetTitle(), "Arial", 40) pNewScene:addChild(pLabel, 1) - pLabel:setPosition(CCPoint(s.width/2, s.height-32)) - pLabel:setColor(Color3B(255,255,40)) + pLabel:setPosition(cc.p(s.width/2, s.height-32)) + pLabel:setColor(cc.c3b(255,255,40)) UpdateQuantityLabel() CreateParticleSystem() @@ -877,11 +875,11 @@ local function runParticleTest() function ShowCurrentTest() if nil ~= pNewScene then - CCDirector:getInstance():getScheduler():unscheduleScriptEntry(ScheduleSelector) + cc.Director:getInstance():getScheduler():unscheduleScriptEntry(ScheduleSelector) end - pNewScene = CCScene:create() + pNewScene = cc.Scene:create() InitWithSubTest(nSubtestNumber,nQuantityParticles) - CCDirector:getInstance():replaceScene(pNewScene) + cc.Director:getInstance():replaceScene(pNewScene) end @@ -944,7 +942,7 @@ local function runSpriteTest() return strTitle end - local pNewScene = CCScene:create() + local pNewScene = cc.Scene:create() local function CreateBasicLayerMenuItem(pMenu,bMenuVisible,nMaxCasesNum,nCurCaseIndex) if nil ~= pMenu then @@ -971,28 +969,28 @@ local function runSpriteTest() ShowCurrentTest() end - local size = CCDirector:getInstance():getWinSize() - local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2) + local size = cc.Director:getInstance():getWinSize() + local item1 = cc.MenuItemImage:create(s_pPathB1, s_pPathB2) item1:registerScriptTapHandler(backCallback) pMenu:addChild(item1,kItemTagBasic) - local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2) + local item2 = cc.MenuItemImage:create(s_pPathR1, s_pPathR2) item2:registerScriptTapHandler(restartCallback) pMenu:addChild(item2,kItemTagBasic) - local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2) + local item3 = cc.MenuItemImage:create(s_pPathF1, s_pPathF2) pMenu:addChild(item3,kItemTagBasic) item3:registerScriptTapHandler(nextCallback) - local size = CCDirector:getInstance():getWinSize() - item1:setPosition(CCPoint(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) - item2:setPosition(CCPoint(size.width / 2, item2:getContentSize().height / 2)) - item3:setPosition(CCPoint(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + local size = cc.Director:getInstance():getWinSize() + item1:setPosition(cc.p(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + item2:setPosition(cc.p(size.width / 2, item2:getContentSize().height / 2)) + item3:setPosition(cc.p(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) end end end local function UpdateNodes() if nQuantityNodes ~= nLastRenderedCount then - local pInfoLabel = tolua.cast(pNewScene:getChildByTag(SpriteTestParam.kTagInfoLayer), "CCLabelTTF") + local pInfoLabel = tolua.cast(pNewScene:getChildByTag(SpriteTestParam.kTagInfoLayer), "LabelTTF") local strInfo = string.format("%u nodes", nQuantityNodes) pInfoLabel:setString(strInfo) nLastRenderedCount = nQuantityNodes @@ -1000,99 +998,90 @@ local function runSpriteTest() end local function PerformancePosition(pSprite) - local size = CCDirector:getInstance():getWinSize() - pSprite:setPosition(CCPoint((math.random(0,SpriteTestParam.kRandMax) % (size.width) ), (math.random(0,SpriteTestParam.kRandMax) % (size.height)))) + local size = cc.Director:getInstance():getWinSize() + pSprite:setPosition(cc.p((math.random(0,SpriteTestParam.kRandMax) % (size.width) ), (math.random(0,SpriteTestParam.kRandMax) % (size.height)))) end local function PerformanceScale(pSprite) - local size = CCDirector:getInstance():getWinSize() - pSprite:setPosition(CCPoint((math.random(0,SpriteTestParam.kRandMax) % (size.width) ), (math.random(0,SpriteTestParam.kRandMax) % (size.height)))) + local size = cc.Director:getInstance():getWinSize() + pSprite:setPosition(cc.p((math.random(0,SpriteTestParam.kRandMax) % (size.width) ), (math.random(0,SpriteTestParam.kRandMax) % (size.height)))) pSprite:setScale(math.random() * 100 / 50) end local function PerformanceRotationScale(pSprite) - local size = CCDirector:getInstance():getWinSize() - pSprite:setPosition(CCPoint((math.random(0,SpriteTestParam.kRandMax) % (size.width) ), (math.random(0,SpriteTestParam.kRandMax) % (size.height)))) + local size = cc.Director:getInstance():getWinSize() + pSprite:setPosition(cc.p((math.random(0,SpriteTestParam.kRandMax) % (size.width) ), (math.random(0,SpriteTestParam.kRandMax) % (size.height)))) pSprite:setRotation(math.random() * 360) pSprite:setScale(math.random() * 2) end local function PerformanceOut100(pSprite) - pSprite:setPosition(CCPoint( -1000, -1000)) + pSprite:setPosition(cc.p( -1000, -1000)) end local function Performanceout20(pSprite) - local size = CCDirector:getInstance():getWinSize() + local size = cc.Director:getInstance():getWinSize() if math.random() < 0.2 then - pSprite:setPosition(CCPoint((math.random(0,SpriteTestParam.kRandMax) % (size.width) ), (math.random(0,SpriteTestParam.kRandMax) % (size.height)))) + pSprite:setPosition(cc.p((math.random(0,SpriteTestParam.kRandMax) % (size.width) ), (math.random(0,SpriteTestParam.kRandMax) % (size.height)))) else - pSprite:setPosition(CCPoint( -1000, -1000)) + pSprite:setPosition(cc.p( -1000, -1000)) end end local function PerformanceActions(pSprite) - local size = CCDirector:getInstance():getWinSize() - pSprite:setPosition(CCPoint((math.random(0,SpriteTestParam.kRandMax) % (size.width) ), (math.random(0,SpriteTestParam.kRandMax) % (size.height)))) + local size = cc.Director:getInstance():getWinSize() + pSprite:setPosition(cc.p((math.random(0,SpriteTestParam.kRandMax) % (size.width) ), (math.random(0,SpriteTestParam.kRandMax) % (size.height)))) local fPeriod = 0.5 + (math.random(0,SpriteTestParam.kRandMax) % 1000) / 500.0 - local pRot = CCRotateBy:create(fPeriod, 360.0 * math.random() ) + local pRot = cc.RotateBy:create(fPeriod, 360.0 * math.random() ) local pRot_back = pRot:reverse() - local arrRot = CCArray:create() - arrRot:addObject(pRot) - arrRot:addObject(pRot_back) - local pPermanentRotation = CCRepeatForever:create(CCSequence:create(arrRot)) + local pPermanentRotation = cc.RepeatForever:create(cc.Sequence:create(pRot, pRot_back)) pSprite:runAction(pPermanentRotation) local fGrowDuration = 0.5 + (math.random(0,SpriteTestParam.kRandMax) % 1000) / 500.0 - local pGrow = CCScaleBy:create(fGrowDuration, 0.5, 0.5) - local arrGrow = CCArray:create() - arrGrow:addObject(pGrow) - arrGrow:addObject(pGrow:reverse()) - local pPermanentScaleLoop = CCRepeatForever:create(CCSequence:create(arrGrow)) + local pGrow = cc.ScaleBy:create(fGrowDuration, 0.5, 0.5) + local pPermanentScaleLoop = cc.RepeatForever:create(cc.Sequence:create(pGrow, pGrow:reverse())) pSprite:runAction(pPermanentScaleLoop) end local function PerformanceActions20(pSprite) - local size = CCDirector:getInstance():getWinSize() + local size = cc.Director:getInstance():getWinSize() if math.random() < 0.2 then - pSprite:setPosition(CCPoint((math.random(0,SpriteTestParam.kRandMax) % (size.width) ), (math.random(0,SpriteTestParam.kRandMax) % (size.height)))) + pSprite:setPosition(cc.p((math.random(0,SpriteTestParam.kRandMax) % (size.width) ), (math.random(0,SpriteTestParam.kRandMax) % (size.height)))) else - pSprite:setPosition(CCPoint( -1000, -1000)) + pSprite:setPosition(cc.p( -1000, -1000)) end local pPeriod = 0.5 + (math.random(0,SpriteTestParam.kRandMax) % 1000) / 500.0 - local pRot = CCRotateBy:create(pPeriod, 360.0 * math.random()) + local pRot = cc.RotateBy:create(pPeriod, 360.0 * math.random()) local pRot_back = pRot:reverse() - local arrRot = CCArray:create() - arrRot:addObject(pRot) - arrRot:addObject(pRot_back) - local pPermanentRotation = CCRepeatForever:create(CCSequence:create(arrRot)) + local pPermanentRotation = cc.RepeatForever:create(cc.Sequence:create(pRot, pRot_back)) pSprite:runAction(pPermanentRotation) local fGrowDuration = 0.5 + (math.random(0,SpriteTestParam.kRandMax) % 1000) / 500.0 - local pGrow = CCScaleBy:create(fGrowDuration, 0.5, 0.5) - local pPermanentScaleLoop = CCRepeatForever:create(CCSequence:createWithTwoActions(pGrow, pGrow:reverse())) + local pGrow = cc.ScaleBy:create(fGrowDuration, 0.5, 0.5) + local pPermanentScaleLoop = cc.RepeatForever:create(cc.Sequence:create(pGrow, pGrow:reverse())) pSprite:runAction(pPermanentScaleLoop) end local function CreateSpriteWithTag(nTag) --create - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888) local pSprite = nil if 1 == nSubtestNumber then - pSprite = CCSprite:create("Images/grossinis_sister1.png") + pSprite = cc.Sprite:create("Images/grossinis_sister1.png") pNewScene:addChild(pSprite, 0, nTag+100) elseif 2 == nSubtestNumber or 3 == nSubtestNumber then - pSprite = CCSprite:createWithTexture(pBatchNode:getTexture(), CCRect(0, 0, 52, 139)) + pSprite = cc.Sprite:createWithTexture(pBatchNode:getTexture(), cc.rect(0, 0, 52, 139)) pBatchNode:addChild(pSprite, 0, nTag+100) elseif 4 == nSubtestNumber then local nIndex = math.floor((math.random() * 1400 / 100)) + 1 local strPath = string.format("Images/grossini_dance_%02d.png", nIndex) - pSprite = CCSprite:create(strPath) + pSprite = cc.Sprite:create(strPath) pNewScene:addChild(pSprite, 0, nTag+100) elseif 5 == nSubtestNumber or 6 == nSubtestNumber then local nY = 0 @@ -1104,7 +1093,7 @@ local function runSpriteTest() nX = nX * 85 nY = nY * 121 - pSprite = CCSprite:createWithTexture(pBatchNode:getTexture(), CCRect(nX,nY,85,121)) + pSprite = cc.Sprite:createWithTexture(pBatchNode:getTexture(), cc.rect(nX,nY,85,121)) pBatchNode:addChild(pSprite, 0, nTag+100) elseif 7 == nSubtestNumber then local nX = 0 @@ -1115,7 +1104,7 @@ local function runSpriteTest() nY = math.floor(nR / 8) local strPath = string.format("Images/sprites_test/sprite-%d-%d.png", nX, nY) - pSprite = CCSprite:create(strPath) + pSprite = cc.Sprite:create(strPath) pNewScene:addChild(pSprite, 0, nTag+100) elseif 8 == nSubtestNumber or 9 == nSubtestNumber then local nX = 0 @@ -1127,10 +1116,10 @@ local function runSpriteTest() nX = nX * 32 nY = nY * 32 - pSprite = CCSprite:createWithTexture(pBatchNode:getTexture(), CCRect(nX,nY,32,32)) + pSprite = cc.Sprite:createWithTexture(pBatchNode:getTexture(), cc.rect(nX,nY,32,32)) pBatchNode:addChild(pSprite, 0, nTag+100) end - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_Default) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE_PIXELFORMAT_DEFAULT ) return pSprite end @@ -1215,7 +1204,7 @@ local function runSpriteTest() *12: 64 (4-bit) PVRTC Batch Node of 32 x 32 each ]]-- --purge textures - local pMgr = CCTextureCache:getInstance() + local pMgr = cc.TextureCache:getInstance() --[mgr removeAllTextures] pMgr:removeTexture(pMgr:addImage("Images/grossinis_sister1.png")) pMgr:removeTexture(pMgr:addImage("Images/grossini_dance_atlas.png")) @@ -1223,28 +1212,28 @@ local function runSpriteTest() if 1 == nSubTest or 4 == nSubTest or 7 == nSubTest then elseif 2 == nSubTest then - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888) - pBatchNode = CCSpriteBatchNode:create("Images/grossinis_sister1.png", 100) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888) + pBatchNode = cc.SpriteBatchNode:create("Images/grossinis_sister1.png", 100) pNewScene:addChild(pBatchNode, 0) elseif 3 == nSubTest then - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444) - pBatchNode = CCSpriteBatchNode:create("Images/grossinis_sister1.png", 100) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444) + pBatchNode = cc.SpriteBatchNode:create("Images/grossinis_sister1.png", 100) pNewScene:addChild(pBatchNode, 0) elseif 5 == nSubTest then - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888) - pBatchNode = CCSpriteBatchNode:create("Images/grossini_dance_atlas.png", 100) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888) + pBatchNode = cc.SpriteBatchNode:create("Images/grossini_dance_atlas.png", 100) pNewScene:addChild(pBatchNode, 0) elseif 6 == nSubTest then - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444) - pBatchNode = CCSpriteBatchNode:create("Images/grossini_dance_atlas.png", 100) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444) + pBatchNode = cc.SpriteBatchNode:create("Images/grossini_dance_atlas.png", 100) pNewScene:addChild(pBatchNode, 0) elseif 8 == nSubTest then - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888) - pBatchNode = CCSpriteBatchNode:create("Images/spritesheet1.png", 100) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888) + pBatchNode = cc.SpriteBatchNode:create("Images/spritesheet1.png", 100) pNewScene:addChild(pBatchNode, 0) elseif 9 == nSubTest then - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444) - pBatchNode = CCSpriteBatchNode:create("Images/spritesheet1.png", 100) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444) + pBatchNode = cc.SpriteBatchNode:create("Images/spritesheet1.png", 100) pNewScene:addChild(pBatchNode, 0) end @@ -1252,85 +1241,85 @@ local function runSpriteTest() pBatchNode:retain() end - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_Default) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE_PIXELFORMAT_DEFAULT ) end local function InitWithSpriteTest(nSubtest,nNodes) nSubtestNumber = nSubtest --about create subset InitWithSubTest(nSubtest) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() nLastRenderedCount = 0 nQuantityNodes = 0 --"+","-" Menu - CCMenuItemFont:setFontSize(65) - local pDecrease = CCMenuItemFont:create(" - ") + cc.MenuItemFont:setFontSize(65) + local pDecrease = cc.MenuItemFont:create(" - ") pDecrease:registerScriptTapHandler(onDecrease) - pDecrease:setColor(Color3B(0,200,20)) - local pIncrease = CCMenuItemFont:create(" + ") + pDecrease:setColor(cc.c3b(0,200,20)) + local pIncrease = cc.MenuItemFont:create(" + ") pIncrease:registerScriptTapHandler(onIncrease) - pIncrease:setColor(Color3B(0,200,20)) + pIncrease:setColor(cc.c3b(0,200,20)) - local pMenuAddOrSub = CCMenu:create() + local pMenuAddOrSub = cc.Menu:create() pMenuAddOrSub:addChild(pDecrease) pMenuAddOrSub:addChild(pIncrease) pMenuAddOrSub:alignItemsHorizontally() - pMenuAddOrSub:setPosition(CCPoint(s.width/2, s.height/2+15)) + pMenuAddOrSub:setPosition(cc.p(s.width/2, s.height/2+15)) pNewScene:addChild(pMenuAddOrSub,1) - local pInfoLabel = CCLabelTTF:create("0 nodes", "Marker Felt", 30) - pInfoLabel:setColor(Color3B(0,200,20)) - pInfoLabel:setPosition(CCPoint(s.width/2, s.height - 90)) + local pInfoLabel = cc.LabelTTF:create("0 nodes", "Marker Felt", 30) + pInfoLabel:setColor(cc.c3b(0,200,20)) + pInfoLabel:setPosition(cc.p(s.width/2, s.height - 90)) pNewScene:addChild(pInfoLabel, 1, SpriteTestParam.kTagInfoLayer) --SpriteTestMenuLayer - local pSpriteMenuLayer = CCLayer:create() - local pSpriteMenu = CCMenu:create() + local pSpriteMenuLayer = cc.Layer:create() + local pSpriteMenu = cc.Menu:create() CreatePerfomBasicLayerMenu(pSpriteMenu) CreateBasicLayerMenuItem(pSpriteMenu,true,SpriteTestParam.TEST_COUNT,nCurCase) - pSpriteMenu:setPosition(CCPoint(0, 0)) + pSpriteMenu:setPosition(cc.p(0, 0)) pSpriteMenuLayer:addChild(pSpriteMenu) pNewScene:addChild(pSpriteMenuLayer,1,SpriteTestParam.kTagMenuLayer) --Sub Tests - CCMenuItemFont:setFontSize(40) - local pSubMenu = CCMenu:create() + cc.MenuItemFont:setFontSize(40) + local pSubMenu = cc.Menu:create() local i = 1 for i = 1, 9 do local strNum = string.format("%d ",i) - local pItemFont = CCMenuItemFont:create(strNum) + local pItemFont = cc.MenuItemFont:create(strNum) pItemFont:registerScriptTapHandler(TestNCallback) pSubMenu:addChild(pItemFont, i + SpriteTestParam.kSubMenuBasicZOrder) if i <= 3 then - pItemFont:setColor(Color3B(200,20,20)) + pItemFont:setColor(cc.c3b(200,20,20)) elseif i <= 6 then - pItemFont:setColor(Color3B(0,200,20)) + pItemFont:setColor(cc.c3b(0,200,20)) else - pItemFont:setColor(Color3B(0,20,200)) + pItemFont:setColor(cc.c3b(0,20,200)) end end pSubMenu:alignItemsHorizontally() - pSubMenu:setPosition(CCPoint(s.width/2, 80)) + pSubMenu:setPosition(cc.p(s.width/2, 80)) pNewScene:addChild(pSubMenu, 2) - local pLabel = CCLabelTTF:create(GetTitle(), "Arial", 40) + local pLabel = cc.LabelTTF:create(GetTitle(), "Arial", 40) pNewScene:addChild(pLabel, 1) - pLabel:setPosition(CCPoint(s.width/2, s.height-32)) - pLabel:setColor(Color3B(255,255,40)) + pLabel:setPosition(cc.p(s.width/2, s.height-32)) + pLabel:setColor(cc.c3b(255,255,40)) while nQuantityNodes < nNodes do onIncrease() end end function ShowCurrentTest() - pNewScene = CCScene:create() + pNewScene = cc.Scene:create() InitWithSpriteTest(nSubtestNumber,nQuantityNodes) - CCDirector:getInstance():replaceScene(pNewScene) + cc.Director:getInstance():replaceScene(pNewScene) end InitWithSpriteTest(1,SpriteTestParam.kInitNodes) @@ -1357,16 +1346,16 @@ local function runTextureTest() end local nTexCurCase = 0 - local pNewscene = CCScene:create() - local pLayer = CCLayer:create() - local s = CCDirector:getInstance():getWinSize() + local pNewscene = cc.Scene:create() + local pLayer = cc.Layer:create() + local s = cc.Director:getInstance():getWinSize() local function PerformTestsPNG(strFileName) local time local pTexture = nil - local pCache = CCTextureCache:getInstance() + local pCache = cc.TextureCache:getInstance() print("RGBA 8888") - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888) pTexture = pCache:addImage(strFileName) if nil ~= pTexture then --os.time()--get secs,not micr sec @@ -1377,7 +1366,7 @@ local function runTextureTest() pCache:removeTexture(pTexture) print("RGBA 4444") - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444) --gettimeofday(&now, NULL) pTexture = pCache:addImage(strFileName) if nil ~= pTexture then @@ -1388,7 +1377,7 @@ local function runTextureTest() pCache:removeTexture(pTexture) print("RGBA 5551") - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGB5A1) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB5_A1) --gettimeofday(&now, NULL) pTexture = pCache:addImage(strFileName) if nil ~= pTexture then @@ -1399,7 +1388,7 @@ local function runTextureTest() pCache:removeTexture(pTexture) print("RGB 565") - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGB565) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RG_B565) -- gettimeofday(&now, NULL) pTexture = pCache:addImage(strFileName) if nil ~= pTexture then @@ -1437,20 +1426,20 @@ local function runTextureTest() end --Title - local pLabel = CCLabelTTF:create(GetTitle(), "Arial", 40) + local pLabel = cc.LabelTTF:create(GetTitle(), "Arial", 40) pLayer:addChild(pLabel, 1) - pLabel:setPosition(CCPoint(s.width/2, s.height-32)) - pLabel:setColor(Color3B(255,255,40)) + pLabel:setPosition(cc.p(s.width/2, s.height-32)) + pLabel:setColor(cc.c3b(255,255,40)) --Subtitle - local pSubLabel = CCLabelTTF:create(GetSubtitle(), "Thonburi", 16) + local pSubLabel = cc.LabelTTF:create(GetSubtitle(), "Thonburi", 16) pLayer:addChild(pSubLabel, 1) - pSubLabel:setPosition(CCPoint(s.width/2, s.height-80)) + pSubLabel:setPosition(cc.p(s.width/2, s.height-80)) --menu - local pMenu = CCMenu:create() + local pMenu = cc.Menu:create() CreatePerfomBasicLayerMenu(pMenu) - pMenu:setPosition(CCPoint(0, 0)) + pMenu:setPosition(cc.p(0, 0)) pLayer:addChild(pMenu) PerformTests() @@ -1481,9 +1470,9 @@ local function runTouchesTest() local nNumberOfTouchesC = 0 local fElapsedTime = 0.0 - local s = CCDirector:getInstance():getWinSize() - local pNewscene = CCScene:create() - local pLayer = CCLayer:create() + local s = cc.Director:getInstance():getWinSize() + local pNewscene = cc.Scene:create() + local pLayer = cc.Layer:create() local function GetTitle() if 0 == nCurCase then @@ -1518,21 +1507,21 @@ local function runTouchesTest() ShowCurrentTest() end - local size = CCDirector:getInstance():getWinSize() - local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2) + local size = cc.Director:getInstance():getWinSize() + local item1 = cc.MenuItemImage:create(s_pPathB1, s_pPathB2) item1:registerScriptTapHandler(backCallback) pMenu:addChild(item1,kItemTagBasic) - local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2) + local item2 = cc.MenuItemImage:create(s_pPathR1, s_pPathR2) item2:registerScriptTapHandler(restartCallback) pMenu:addChild(item2,kItemTagBasic) - local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2) + local item3 = cc.MenuItemImage:create(s_pPathF1, s_pPathF2) pMenu:addChild(item3,kItemTagBasic) item3:registerScriptTapHandler(nextCallback) - local size = CCDirector:getInstance():getWinSize() - item1:setPosition(CCPoint(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) - item2:setPosition(CCPoint(size.width / 2, item2:getContentSize().height / 2)) - item3:setPosition(CCPoint(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + local size = cc.Director:getInstance():getWinSize() + item1:setPosition(cc.p(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + item2:setPosition(cc.p(size.width / 2, item2:getContentSize().height / 2)) + item3:setPosition(cc.p(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) end end end @@ -1606,22 +1595,22 @@ local function runTouchesTest() local function InitLayer() --menu - local pTouchesTestMenu = CCMenu:create() + local pTouchesTestMenu = cc.Menu:create() CreatePerfomBasicLayerMenu(pTouchesTestMenu) CreateBasicLayerMenuItem(pTouchesTestMenu,true,TouchesTestParam.TEST_COUNT,nCurCase) - pTouchesTestMenu:setPosition(CCPoint(0, 0)) + pTouchesTestMenu:setPosition(cc.p(0, 0)) pLayer:addChild(pTouchesTestMenu) --Title - local pLabel = CCLabelTTF:create(GetTitle(), "Arial", 40) + local pLabel = cc.LabelTTF:create(GetTitle(), "Arial", 40) pLayer:addChild(pLabel, 1) - pLabel:setPosition(CCPoint(s.width/2, s.height-32)) - pLabel:setColor(Color3B(255,255,40)) + pLabel:setPosition(cc.p(s.width/2, s.height-32)) + pLabel:setColor(cc.c3b(255,255,40)) pLayer:scheduleUpdateWithPriorityLua(update,0) - pClassLabel = CCLabelBMFont:create("00.0", "fonts/arial16.fnt") - pClassLabel:setPosition(CCPoint(s.width/2, s.height/2)) + pClassLabel = cc.LabelBMFont:create("00.0", "fonts/arial16.fnt") + pClassLabel:setPosition(cc.p(s.width/2, s.height/2)) pLayer:addChild(pClassLabel) fElapsedTime = 0.0 @@ -1639,13 +1628,13 @@ local function runTouchesTest() pLayer:unscheduleUpdate() end - pNewscene = CCScene:create() + pNewscene = cc.Scene:create() if nil ~= pNewscene then - pLayer = CCLayer:create() + pLayer = cc.Layer:create() InitLayer() pNewscene:addChild(pLayer) - CCDirector:getInstance():replaceScene(pNewscene) + cc.Director:getInstance():replaceScene(pNewscene) end end @@ -1676,19 +1665,19 @@ local function menuCallback(tag, pMenuItem) local nIdx = pMenuItem:getZOrder() - kItemTagBasic local PerformanceTestScene = CreatePerformancesTestScene(nIdx) if nil ~= PerformanceTestScene then - CCDirector:getInstance():replaceScene(PerformanceTestScene) + cc.Director:getInstance():replaceScene(PerformanceTestScene) end end local function PerformanceMainLayer() - local layer = CCLayer:create() + local layer = cc.Layer:create() - local menu = CCMenu:create() - menu:setPosition(CCPoint(0, 0)) - CCMenuItemFont:setFontName("Arial") - CCMenuItemFont:setFontSize(24) + local menu = cc.Menu:create() + menu:setPosition(cc.p(0, 0)) + cc.MenuItemFont:setFontName("Arial") + cc.MenuItemFont:setFontSize(24) for i = 1, MAX_COUNT do - local item = CCMenuItemFont:create(testsName[i]) + local item = cc.MenuItemFont:create(testsName[i]) item:registerScriptTapHandler(menuCallback) item:setPosition(s.width / 2, s.height - (i + 1) * LINE_SPACE) menu:addChild(item, kItemTagBasic + i) @@ -1703,7 +1692,7 @@ end -- Performance Test ------------------------------------- function PerformanceTestMain() - local scene = CCScene:create() + local scene = cc.Scene:create() scene:addChild(PerformanceMainLayer()) scene:addChild(CreateBackMenuItem()) diff --git a/samples/Lua/TestLua/Resources/luaScript/RenderTextureTest/RenderTextureTest.lua b/samples/Lua/TestLua/Resources/luaScript/RenderTextureTest/RenderTextureTest.lua index aa8686027f..4fe937a42d 100644 --- a/samples/Lua/TestLua/Resources/luaScript/RenderTextureTest/RenderTextureTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/RenderTextureTest/RenderTextureTest.lua @@ -7,7 +7,7 @@ local function RenderTextureSave() local ret = createTestLayer("Touch the screen", "Press 'Save Image' to create an snapshot of the render texture") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() local m_pTarget = nil local m_pBrush = nil local m_pTarget = nil @@ -20,20 +20,20 @@ local function RenderTextureSave() local png = string.format("image-%d.png", counter) local jpg = string.format("image-%d.jpg", counter) - m_pTarget:saveToFile(png, kCCImageFormatPNG) - m_pTarget:saveToFile(jpg, kCCImageFormatJPEG) + m_pTarget:saveToFile(png, cc.IMAGE_FORMAT_PNG) + m_pTarget:saveToFile(jpg, cc.IMAGE_FORMAT_JPEG) - local pImage = m_pTarget:newCCImage() + local pImage = m_pTarget:newImage() - local tex = CCTextureCache:getInstance():addUIImage(pImage, png) + local tex = cc.TextureCache:getInstance():addUIImage(pImage, png) pImage:release() - local sprite = CCSprite:createWithTexture(tex) + local sprite = cc.Sprite:createWithTexture(tex) sprite:setScale(0.3) ret:addChild(sprite) - sprite:setPosition(CCPoint(40, 40)) + sprite:setPosition(cc.p(40, 40)) sprite:setRotation(counter * 3) cclog("Image saved %s and %s", png, jpg) @@ -44,25 +44,25 @@ local function RenderTextureSave() if event == "exit" then m_pBrush:release() m_pTarget:release() - CCTextureCache:getInstance():removeUnusedTextures() + cc.TextureCache:getInstance():removeUnusedTextures() end end ret:registerScriptHandler(onNodeEvent) -- create a render texture, this is what we are going to draw into - m_pTarget = CCRenderTexture:create(s.width, s.height, kCCTexture2DPixelFormat_RGBA8888) + m_pTarget = cc.RenderTexture:create(s.width, s.height, cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888) m_pTarget:retain() - m_pTarget:setPosition(CCPoint(s.width / 2, s.height / 2)) + m_pTarget:setPosition(cc.p(s.width / 2, s.height / 2)) - -- note that the render texture is a CCNode, and contains a sprite of its texture for convience, - -- so we can just parent it to the scene like any other CCNode + -- note that the render texture is a cc.Node, and contains a sprite of its texture for convience, + -- so we can just parent it to the scene like any other cc.Node ret:addChild(m_pTarget, -1) -- create a brush image to draw into the texture with - m_pBrush = CCSprite:create("Images/fire.png") + m_pBrush = cc.Sprite:create("Images/fire.png") m_pBrush:retain() - m_pBrush:setColor(Color3B(255, 0, 0)) + m_pBrush:setColor(cc.c3b(255, 0, 0)) m_pBrush:setOpacity(20) @@ -76,15 +76,15 @@ local function RenderTextureSave() local diffX = x - prev.x local diffY = y - prev.y - local startP = CCPoint(x, y) - local endP = CCPoint(prev.x, prev.y) + local startP = cc.p(x, y) + local endP = cc.p(prev.x, prev.y) -- begin drawing to the render texture m_pTarget:begin() -- for extra points, we'll draw this smoothly from the last position and vary the sprite's -- scale/rotation/offset - local distance = startP:getDistance(endP) + local distance = cc.pGetDistance(startP, endP) if distance > 1 then local d = distance local i = 0 @@ -92,13 +92,13 @@ local function RenderTextureSave() local difx = endP.x - startP.x local dify = endP.y - startP.y local delta = i / distance - m_pBrush:setPosition(CCPoint(startP.x + (difx * delta), startP.y + (dify * delta))) + m_pBrush:setPosition(cc.p(startP.x + (difx * delta), startP.y + (dify * delta))) m_pBrush:setRotation(math.random(0, 359)) local r = math.random(0, 49) / 50.0 + 0.25 m_pBrush:setScale(r) - -- Use CCRANDOM_0_1() will cause error when loading libtests.so on android, I don't know why. - m_pBrush:setColor(Color3B(math.random(0, 126) + 128, 255, 255)) + -- Use cc.RANDOM_0_1() will cause error when loading libtests.so on android, I don't know why. + m_pBrush:setColor(cc.c3b(math.random(0, 126) + 128, 255, 255)) -- Call visit to draw the brush, don't call draw.. m_pBrush:visit() end @@ -115,18 +115,15 @@ local function RenderTextureSave() ret:setTouchEnabled(true) ret:registerScriptTouchHandler(onTouchEvent) -- Save Image menu - CCMenuItemFont:setFontSize(16) - local item1 = CCMenuItemFont:create("Save Image") + cc.MenuItemFont:setFontSize(16) + local item1 = cc.MenuItemFont:create("Save Image") item1:registerScriptTapHandler(saveImage) - local item2 = CCMenuItemFont:create("Clear") + local item2 = cc.MenuItemFont:create("Clear") item2:registerScriptTapHandler(clearImage) - local arr = CCArray:create() - arr:addObject(item1) - arr:addObject(item2) - local menu = CCMenu:createWithArray(arr) + local menu = cc.Menu:create(item1, item2) ret:addChild(menu) menu:alignItemsVertically() - menu:setPosition(CCPoint(VisibleRect:rightTop().x - 80, VisibleRect:rightTop().y - 30)) + menu:setPosition(cc.p(VisibleRect:rightTop().x - 80, VisibleRect:rightTop().y - 30)) return ret end @@ -150,20 +147,20 @@ end -- * B1: non-premulti sprite -- * B2: non-premulti render -- */ --- local background = CCLayerColor:create(Color4B(200,200,200,255)) +-- local background = cc.LayerColor:create(cc.c4b(200,200,200,255)) -- addChild(background) --- local spr_premulti = CCSprite:create("Images/fire.png") --- spr_premulti:setPosition(CCPoint(16,48)) +-- local spr_premulti = cc.Sprite:create("Images/fire.png") +-- spr_premulti:setPosition(cc.p(16,48)) --- local spr_nonpremulti = CCSprite:create("Images/fire.png") --- spr_nonpremulti:setPosition(CCPoint(16,16)) +-- local spr_nonpremulti = cc.Sprite:create("Images/fire.png") +-- spr_nonpremulti:setPosition(cc.p(16,16)) -- /* A2 & B2 setup */ --- local rend = CCRenderTexture:create(32, 64, kCCTexture2DPixelFormat_RGBA8888) +-- local rend = cc.RenderTexture:create(32, 64, cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888) -- if (NULL == rend) @@ -178,14 +175,14 @@ end -- spr_nonpremulti:visit() -- rend:end() --- local s = CCDirector:getInstance():getWinSize() +-- local s = cc.Director:getInstance():getWinSize() -- --/* A1: setup */ --- spr_premulti:setPosition(CCPoint(s.width/2-16, s.height/2+16)) +-- spr_premulti:setPosition(cc.p(s.width/2-16, s.height/2+16)) -- --/* B1: setup */ --- spr_nonpremulti:setPosition(CCPoint(s.width/2-16, s.height/2-16)) +-- spr_nonpremulti:setPosition(cc.p(s.width/2-16, s.height/2-16)) --- rend:setPosition(CCPoint(s.width/2+16, s.height/2)) +-- rend:setPosition(cc.p(s.width/2+16, s.height/2)) -- addChild(spr_nonpremulti) -- addChild(spr_premulti) @@ -207,7 +204,7 @@ end -- local pLayer = nextTestCase() -- addChild(pLayer) --- CCDirector:getInstance():replaceScene(this) +-- cc.Director:getInstance():replaceScene(this) -- end -- --/** @@ -217,35 +214,35 @@ end -- local function RenderTextureZbuffer() -- this:setTouchEnabled(true) --- local size = CCDirector:getInstance():getWinSize() --- local label = CCLabelTTF:create("vertexZ = 50", "Marker Felt", 64) --- label:setPosition(CCPoint(size.width / 2, size.height * 0.25)) +-- local size = cc.Director:getInstance():getWinSize() +-- local label = cc.LabelTTF:create("vertexZ = 50", "Marker Felt", 64) +-- label:setPosition(cc.p(size.width / 2, size.height * 0.25)) -- this:addChild(label) --- local label2 = CCLabelTTF:create("vertexZ = 0", "Marker Felt", 64) --- label2:setPosition(CCPoint(size.width / 2, size.height * 0.5)) +-- local label2 = cc.LabelTTF:create("vertexZ = 0", "Marker Felt", 64) +-- label2:setPosition(cc.p(size.width / 2, size.height * 0.5)) -- this:addChild(label2) --- local label3 = CCLabelTTF:create("vertexZ = -50", "Marker Felt", 64) --- label3:setPosition(CCPoint(size.width / 2, size.height * 0.75)) +-- local label3 = cc.LabelTTF:create("vertexZ = -50", "Marker Felt", 64) +-- label3:setPosition(cc.p(size.width / 2, size.height * 0.75)) -- this:addChild(label3) -- label:setVertexZ(50) -- label2:setVertexZ(0) -- label3:setVertexZ(-50) --- CCSpriteFrameCache:getInstance():addSpriteFramesWithFile("Images/bugs/circle.plist") --- mgr = CCSpriteBatchNode:create("Images/bugs/circle.png", 9) +-- cc.SpriteFrameCache:getInstance():addSpriteFramesWithFile("Images/bugs/circle.plist") +-- mgr = cc.SpriteBatchNode:create("Images/bugs/circle.png", 9) -- this:addChild(mgr) --- sp1 = CCSprite:createWithSpriteFrameName("circle.png") --- sp2 = CCSprite:createWithSpriteFrameName("circle.png") --- sp3 = CCSprite:createWithSpriteFrameName("circle.png") --- sp4 = CCSprite:createWithSpriteFrameName("circle.png") --- sp5 = CCSprite:createWithSpriteFrameName("circle.png") --- sp6 = CCSprite:createWithSpriteFrameName("circle.png") --- sp7 = CCSprite:createWithSpriteFrameName("circle.png") --- sp8 = CCSprite:createWithSpriteFrameName("circle.png") --- sp9 = CCSprite:createWithSpriteFrameName("circle.png") +-- sp1 = cc.Sprite:createWithSpriteFrameName("circle.png") +-- sp2 = cc.Sprite:createWithSpriteFrameName("circle.png") +-- sp3 = cc.Sprite:createWithSpriteFrameName("circle.png") +-- sp4 = cc.Sprite:createWithSpriteFrameName("circle.png") +-- sp5 = cc.Sprite:createWithSpriteFrameName("circle.png") +-- sp6 = cc.Sprite:createWithSpriteFrameName("circle.png") +-- sp7 = cc.Sprite:createWithSpriteFrameName("circle.png") +-- sp8 = cc.Sprite:createWithSpriteFrameName("circle.png") +-- sp9 = cc.Sprite:createWithSpriteFrameName("circle.png") -- mgr:addChild(sp1, 9) -- mgr:addChild(sp2, 8) @@ -268,7 +265,7 @@ end -- sp9:setVertexZ(-400) -- sp9:setScale(2) --- sp9:setColor(Color3B::YELLOW) +-- sp9:setColor(cc.c3b::YELLOW) -- end -- local function title() @@ -281,13 +278,13 @@ end -- return "Touch screen. It should be green" -- end --- local function ccTouchesBegan(cocos2d:CCSet *touches, cocos2d:CCEvent *event) +-- local function ccTouchesBegan(cocos2d:cc.Set *touches, cocos2d:cc.Event *event) --- CCSetIterator iter --- CCTouch *touch +-- cc.SetIterator iter +-- cc.Touch *touch -- for (iter = touches:begin() iter != touches:end() ++iter) --- touch = (CCTouch *)(*iter) +-- touch = (cc.Touch *)(*iter) -- local location = touch:getLocation() -- sp1:setPosition(location) @@ -302,13 +299,13 @@ end -- end -- end --- local function ccTouchesMoved(CCSet* touches, CCEvent* event) +-- local function ccTouchesMoved(cc.Set* touches, cc.Event* event) --- CCSetIterator iter --- CCTouch *touch +-- cc.SetIterator iter +-- cc.Touch *touch -- for (iter = touches:begin() iter != touches:end() ++iter) --- touch = (CCTouch *)(*iter) +-- touch = (cc.Touch *)(*iter) -- local location = touch:getLocation() -- sp1:setPosition(location) @@ -323,35 +320,35 @@ end -- end -- end --- local function ccTouchesEnded(CCSet* touches, CCEvent* event) +-- local function ccTouchesEnded(cc.Set* touches, cc.Event* event) -- this:renderScreenShot() -- end -- local function renderScreenShot() --- local texture = CCRenderTexture:create(512, 512) +-- local texture = cc.RenderTexture:create(512, 512) -- if (NULL == texture) -- return -- end --- texture:setAnchorPoint(CCPoint(0, 0)) +-- texture:setAnchorPoint(cc.p(0, 0)) -- texture:begin() -- this:visit() -- texture:end() --- local sprite = CCSprite:createWithTexture(texture:getSprite():getTexture()) +-- local sprite = cc.Sprite:createWithTexture(texture:getSprite():getTexture()) --- sprite:setPosition(CCPoint(256, 256)) +-- sprite:setPosition(cc.p(256, 256)) -- sprite:setOpacity(182) -- sprite:setFlipY(1) -- this:addChild(sprite, 999999) --- sprite:setColor(Color3B::GREEN) +-- sprite:setColor(cc.c3b::GREEN) --- sprite:runAction(CCSequence:create(CCFadeTo:create(2, 0), --- CCHide:create(), +-- sprite:runAction(cc.Sequence:create(cc.FadeTo:create(2, 0), +-- cc.Hide:create(), -- NULL)) -- end @@ -359,12 +356,12 @@ end -- local function RenderTextureTestDepthStencil() --- local s = CCDirector:getInstance():getWinSize() +-- local s = cc.Director:getInstance():getWinSize() --- local sprite = CCSprite:create("Images/fire.png") --- sprite:setPosition(CCPoint(s.width * 0.25, 0)) +-- local sprite = cc.Sprite:create("Images/fire.png") +-- sprite:setPosition(cc.p(s.width * 0.25, 0)) -- sprite:setScale(10) --- local rend = CCRenderTexture:create(s.width, s.height, kCCTexture2DPixelFormat_RGBA4444, GL_DEPTH24_STENCIL8) +-- local rend = cc.RenderTexture:create(s.width, s.height, kcc.Texture2DPixelFormat_RGBA4444, GL_DEPTH24_STENCIL8) -- glStencilMask(0xFF) -- rend:beginWithClear(0, 0, 0, 0, 0, 0) @@ -377,7 +374,7 @@ end -- sprite:visit() -- --! move sprite half width and height, and draw only where not marked --- sprite:setPosition(CCPoint.__add(sprite:getPosition(), CCPoint.__mul(CCPoint(sprite:getContentSize().width * sprite:getScale(), sprite:getContentSize().height * sprite:getScale()), 0.5))) +-- sprite:setPosition(cc.p__add(sprite:getPosition(), cc.p__mul(cc.p(sprite:getContentSize().width * sprite:getScale(), sprite:getContentSize().height * sprite:getScale()), 0.5))) -- glStencilFunc(GL_NOTEQUAL, 1, 0xFF) -- glColorMask(1, 1, 1, 1) -- sprite:visit() @@ -386,7 +383,7 @@ end -- glDisable(GL_STENCIL_TEST) --- rend:setPosition(CCPoint(s.width * 0.5, s.height * 0.5)) +-- rend:setPosition(cc.p(s.width * 0.5, s.height * 0.5)) -- this:addChild(rend) -- end @@ -416,29 +413,29 @@ end -- * B1: non-premulti sprite -- * B2: non-premulti render -- */ --- local background = CCLayerColor:create(Color4B(40,40,40,255)) +-- local background = cc.LayerColor:create(cc.c4b(40,40,40,255)) -- addChild(background) -- -- sprite 1 --- sprite1 = CCSprite:create("Images/fire.png") +-- sprite1 = cc.Sprite:create("Images/fire.png") -- -- sprite 2 --- sprite2 = CCSprite:create("Images/fire_rgba8888.pvr") +-- sprite2 = cc.Sprite:create("Images/fire_rgba8888.pvr") --- local s = CCDirector:getInstance():getWinSize() +-- local s = cc.Director:getInstance():getWinSize() -- /* Create the render texture */ --- local renderTexture = CCRenderTexture:create(s.width, s.height, kCCTexture2DPixelFormat_RGBA4444) +-- local renderTexture = cc.RenderTexture:create(s.width, s.height, kcc.Texture2DPixelFormat_RGBA4444) -- this:renderTexture = renderTexture --- renderTexture:setPosition(CCPoint(s.width/2, s.height/2)) --- -- [renderTexture setPosition:CCPoint(s.width, s.height)] +-- renderTexture:setPosition(cc.p(s.width/2, s.height/2)) +-- -- [renderTexture setPosition:cc.p(s.width, s.height)] -- -- renderTexture.scale = 2 -- /* add the sprites to the render texture */ -- renderTexture:addChild(sprite1) -- renderTexture:addChild(sprite2) --- renderTexture:setClearColor(Color4F(0, 0, 0, 0)) +-- renderTexture:setClearColor(cc.c4f(0, 0, 0, 0)) -- renderTexture:setClearFlags(GL_COLOR_BUFFER_BIT) -- /* add the render texture to the scene */ @@ -449,14 +446,14 @@ end -- scheduleUpdate() -- -- Toggle clear on / off --- local item = CCMenuItemFont:create("Clear On/Off", this, menu_selector(RenderTextureTargetNode:touched)) --- local menu = CCMenu:create(item, NULL) +-- local item = cc.MenuItemFont:create("Clear On/Off", this, menu_selector(RenderTextureTargetNode:touched)) +-- local menu = cc.Menu:create(item, NULL) -- addChild(menu) --- menu:setPosition(CCPoint(s.width/2, s.height/2)) +-- menu:setPosition(cc.p(s.width/2, s.height/2)) -- end --- local function touched(CCObject* sender) +-- local function touched(cc.Object* sender) -- if (renderTexture:getClearFlags() == 0) @@ -465,7 +462,7 @@ end -- else -- renderTexture:setClearFlags(0) --- renderTexture:setClearColor(Color4F( CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 1)) +-- renderTexture:setClearColor(cc.c4f( cc.RANDOM_0_1(), cc.RANDOM_0_1(), cc.RANDOM_0_1(), 1)) -- end -- end @@ -473,8 +470,8 @@ end -- static float time = 0 -- float r = 80 --- sprite1:setPosition(CCPoint(cosf(time * 2) * r, sinf(time * 2) * r)) --- sprite2:setPosition(CCPoint(sinf(time * 2) * r, cosf(time * 2) * r)) +-- sprite1:setPosition(cc.p(cosf(time * 2) * r, sinf(time * 2) * r)) +-- sprite2:setPosition(cc.p(sinf(time * 2) * r, cosf(time * 2) * r)) -- time += dt -- end @@ -493,7 +490,7 @@ end -- local function SimpleSprite() : rt(NULL) {} --- local function SimpleSprite* SpriteRenderTextureBug:SimpleSprite:create(const char* filename, const CCRect &rect) +-- local function SimpleSprite* SpriteRenderTextureBug:SimpleSprite:create(const char* filename, const cc.rect &rect) -- SimpleSprite *sprite = new SimpleSprite() -- if (sprite && sprite:initWithFile(filename, rect)) @@ -502,7 +499,7 @@ end -- end -- else --- CC_SAFE_DELETE(sprite) +-- cc._SAFE_DELETE(sprite) -- end -- return sprite @@ -512,14 +509,14 @@ end -- if (rt == NULL) --- local s = CCDirector:getInstance():getWinSize() --- rt = new CCRenderTexture() --- rt:initWithWidthAndHeight(s.width, s.height, kCCTexture2DPixelFormat_RGBA8888) +-- local s = cc.Director:getInstance():getWinSize() +-- rt = new cc.RenderTexture() +-- rt:initWithWidthAndHeight(s.width, s.height, cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888) -- end -- rt:beginWithClear(0.0, 0.0, 0.0, 1.0) -- rt:end() --- CC_NODE_DRAW_SETUP() +-- cc._NODE_DRAW_SETUP() -- BlendFunc blend = getBlendFunc() -- ccGLBlendFunc(blend.src, blend.dst) @@ -530,22 +527,22 @@ end -- -- Attributes -- -- --- ccGLEnableVertexAttribs(kCCVertexAttribFlag_PosColorTex) +-- ccGLEnableVertexAttribs(kcc.VertexAttribFlag_PosColorTex) -- #define kQuadSize sizeof(m_sQuad.bl) -- long offset = (long)&m_sQuad -- -- vertex -- int diff = offsetof( V3F_C4B_T2F, vertices) --- glVertexAttribPointer(kCCVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff)) +-- glVertexAttribPointer(kcc.VertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff)) -- -- texCoods -- diff = offsetof( V3F_C4B_T2F, texCoords) --- glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff)) +-- glVertexAttribPointer(kcc.VertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff)) -- -- color -- diff = offsetof( V3F_C4B_T2F, colors) --- glVertexAttribPointer(kCCVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff)) +-- glVertexAttribPointer(kcc.VertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff)) -- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4) -- end @@ -554,51 +551,51 @@ end -- setTouchEnabled(true) --- local s = CCDirector:getInstance():getWinSize() --- addNewSpriteWithCoords(CCPoint(s.width/2, s.height/2)) +-- local s = cc.Director:getInstance():getWinSize() +-- addNewSpriteWithCoords(cc.p(s.width/2, s.height/2)) -- end --- local function SimpleSprite* SpriteRenderTextureBug:addNewSpriteWithCoords(const CCPoint& p) +-- local function SimpleSprite* SpriteRenderTextureBug:addNewSpriteWithCoords(const cc.p& p) --- int idx = CCRANDOM_0_1() * 1400 / 100 +-- int idx = cc.RANDOM_0_1() * 1400 / 100 -- int x = (idx%5) * 85 -- int y = (idx/5) * 121 -- SpriteRenderTextureBug:SimpleSprite *sprite = SpriteRenderTextureBug:SimpleSprite:create("Images/grossini_dance_atlas.png", --- CCRect(x,y,85,121)) +-- cc.rect(x,y,85,121)) -- addChild(sprite) -- sprite:setPosition(p) -- local action = NULL --- float rd = CCRANDOM_0_1() +-- float rd = cc.RANDOM_0_1() -- if (rd < 0.20) --- action = CCScaleBy:create(3, 2) +-- action = cc.ScaleBy:create(3, 2) -- else if (rd < 0.40) --- action = CCRotateBy:create(3, 360) +-- action = cc.RotateBy:create(3, 360) -- else if (rd < 0.60) --- action = CCBlink:create(1, 3) +-- action = cc.Blink:create(1, 3) -- else if (rd < 0.8 ) --- action = CCTintBy:create(2, 0, -255, -255) +-- action = cc.TintBy:create(2, 0, -255, -255) -- else --- action = CCFadeOut:create(2) +-- action = cc.FadeOut:create(2) -- local action_back = action:reverse() --- local seq = CCSequence:create(action, action_back, NULL) +-- local seq = cc.Sequence:create(action, action_back, NULL) --- sprite:runAction(CCRepeatForever:create(seq)) +-- sprite:runAction(cc.RepeatForever:create(seq)) -- --return sprite -- return NULL -- end --- local function ccTouchesEnded(CCSet* touches, CCEvent* event) +-- local function ccTouchesEnded(cc.Set* touches, cc.Event* event) --- CCSetIterator iter = touches:begin() +-- cc.SetIterator iter = touches:begin() -- for( iter != touches:end() ++iter) --- local location = ((CCTouch*)(*iter)):getLocation() +-- local location = ((cc.Touch*)(*iter)):getLocation() -- addNewSpriteWithCoords(location) -- end -- end @@ -616,7 +613,7 @@ end function RenderTextureTestMain() cclog("RenderTextureTestMain") Helper.index = 1 - local scene = CCScene:create() + local scene = cc.Scene:create() Helper.createFunctionTable = { RenderTextureSave, diff --git a/samples/Lua/TestLua/Resources/luaScript/RotateWorldTest/RotateWorldTest.lua b/samples/Lua/TestLua/Resources/luaScript/RotateWorldTest/RotateWorldTest.lua index 1c43ed7d0c..e196832723 100644 --- a/samples/Lua/TestLua/Resources/luaScript/RotateWorldTest/RotateWorldTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/RotateWorldTest/RotateWorldTest.lua @@ -1,60 +1,60 @@ -local size = CCDirector:getInstance():getWinSize() +local size = cc.Director:getInstance():getWinSize() local function CreateSpriteLayer() - local layer = CCLayer:create() + local layer = cc.Layer:create() local x, y x = size.width y = size.height - local sprite = CCSprite:create(s_pPathGrossini) - local spriteSister1 = CCSprite:create(s_pPathSister1) - local spriteSister2 = CCSprite:create(s_pPathSister2) + local sprite = cc.Sprite:create(s_pPathGrossini) + local spriteSister1 = cc.Sprite:create(s_pPathSister1) + local spriteSister2 = cc.Sprite:create(s_pPathSister2) sprite:setScale(1.5) spriteSister1:setScale(1.5) spriteSister2:setScale(1.5) - sprite:setPosition(CCPoint(x / 2, y / 2)) - spriteSister1:setPosition(CCPoint(40, y / 2)) - spriteSister2:setPosition(CCPoint(x - 40, y / 2)) + sprite:setPosition(cc.p(x / 2, y / 2)) + spriteSister1:setPosition(cc.p(40, y / 2)) + spriteSister2:setPosition(cc.p(x - 40, y / 2)) layer:addChild(sprite) layer:addChild(spriteSister1) layer:addChild(spriteSister2) - local rot = CCRotateBy:create(16, -3600) + local rot = cc.RotateBy:create(16, -3600) sprite:runAction(rot) - local jump1 = CCJumpBy:create(4, CCPoint(-400, 0), 100, 4) + local jump1 = cc.JumpBy:create(4, cc.p(-400, 0), 100, 4) local jump2 = jump1:reverse() - local rot1 = CCRotateBy:create(4, 360 * 2) + local rot1 = cc.RotateBy:create(4, 360 * 2) local rot2 = rot1:reverse() - local jump3 = CCJumpBy:create(4, CCPoint(-400, 0), 100, 4) + local jump3 = cc.JumpBy:create(4, cc.p(-400, 0), 100, 4) local jump4 = jump3:reverse() - local rot3 = CCRotateBy:create(4, 360 * 2) + local rot3 = cc.RotateBy:create(4, 360 * 2) local rot4 = rot3:reverse() - spriteSister1:runAction(CCRepeat:create(CCSequence:createWithTwoActions(jump2, jump1), 5)) - spriteSister2:runAction(CCRepeat:create(CCSequence:createWithTwoActions(jump3, jump4), 5)) + spriteSister1:runAction(cc.Repeat:create(cc.Sequence:create(jump2, jump1), 5)) + spriteSister2:runAction(cc.Repeat:create(cc.Sequence:create(jump3, jump4), 5)) - spriteSister1:runAction(CCRepeat:create(CCSequence:createWithTwoActions(rot1, rot2), 5)) - spriteSister2:runAction(CCRepeat:create(CCSequence:createWithTwoActions(rot4, rot3), 5)) + spriteSister1:runAction(cc.Repeat:create(cc.Sequence:create(rot1, rot2), 5)) + spriteSister2:runAction(cc.Repeat:create(cc.Sequence:create(rot4, rot3), 5)) return layer end local function CreateTestLayer() - local layer = CCLayer:create() + local layer = cc.Layer:create() local x, y x = size.width y = size.height - local label = CCLabelTTF:create("cocos2d", "Tahoma", 64) + local label = cc.LabelTTF:create("cocos2d", "Tahoma", 64) label:setPosition(x / 2, y / 2) layer:addChild(label) @@ -62,42 +62,42 @@ local function CreateTestLayer() end local function CreateRotateWorldLayer() - local layer = CCLayer:create() + local layer = cc.Layer:create() local x, y x = size.width y = size.height - local blue = CCLayerColor:create(Color4B(0,0,255,255)) - local red = CCLayerColor:create(Color4B(255,0,0,255)) - local green = CCLayerColor:create(Color4B(0,255,0,255)) - local white = CCLayerColor:create(Color4B(255,255,255,255)) + local blue = cc.LayerColor:create(cc.c4b(0,0,255,255)) + local red = cc.LayerColor:create(cc.c4b(255,0,0,255)) + local green = cc.LayerColor:create(cc.c4b(0,255,0,255)) + local white = cc.LayerColor:create(cc.c4b(255,255,255,255)) blue:setScale(0.5) - blue:setPosition(CCPoint(- x / 4, - y / 4)) + blue:setPosition(cc.p(- x / 4, - y / 4)) blue:addChild(CreateSpriteLayer()) red:setScale(0.5) - red:setPosition(CCPoint(x / 4, - y / 4)) + red:setPosition(cc.p(x / 4, - y / 4)) green:setScale(0.5) - green:setPosition(CCPoint(- x / 4, y / 4)) + green:setPosition(cc.p(- x / 4, y / 4)) green:addChild(CreateTestLayer()) white:setScale(0.5) - white:setPosition(CCPoint(x / 4, y / 4)) + white:setPosition(cc.p(x / 4, y / 4)) white:ignoreAnchorPointForPosition(false) - white:setPosition(CCPoint(x / 4 * 3, y / 4 * 3)) + white:setPosition(cc.p(x / 4 * 3, y / 4 * 3)) layer:addChild(blue, -1) layer:addChild(white) layer:addChild(green) layer:addChild(red) - local rot = CCRotateBy:create(8, 720) - local rot1 = CCRotateBy:create(8, 720) - local rot2 = CCRotateBy:create(8, 720) - local rot3 = CCRotateBy:create(8, 720) + local rot = cc.RotateBy:create(8, 720) + local rot1 = cc.RotateBy:create(8, 720) + local rot2 = cc.RotateBy:create(8, 720) + local rot3 = cc.RotateBy:create(8, 720) blue:runAction(rot) red:runAction(rot1) @@ -112,12 +112,12 @@ end -------------------------------- function RotateWorldTest() cclog("RotateWorldTest") - local scene = CCScene:create() + local scene = cc.Scene:create() local layer = CreateRotateWorldLayer() scene:addChild(layer) scene:addChild(CreateBackMenuItem()) - scene:runAction(CCRotateBy:create(4, -360)) + scene:runAction(cc.RotateBy:create(4, -360)) return scene end diff --git a/samples/Lua/TestLua/Resources/luaScript/SceneTest/SceneTest.lua b/samples/Lua/TestLua/Resources/luaScript/SceneTest/SceneTest.lua index 0212a1a90f..6621cc1797 100644 --- a/samples/Lua/TestLua/Resources/luaScript/SceneTest/SceneTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/SceneTest/SceneTest.lua @@ -16,22 +16,22 @@ local SceneTestLayer3 = nil -------------------------------------------------------------------- SceneTestLayer1 = function() - local ret = CCLayer:create() + local ret = cc.Layer:create() local function onPushScene(tag, pSender) - local scene = CCScene:create() + local scene = cc.Scene:create() local layer = SceneTestLayer2() scene:addChild(layer, 0) scene:addChild(CreateBackMenuItem()) - CCDirector:getInstance():pushScene( scene ) + cc.Director:getInstance():pushScene( scene ) end local function onPushSceneTran(tag, pSender) - local scene = CCScene:create() + local scene = cc.Scene:create() local layer = SceneTestLayer2() scene:addChild(layer, 0) scene:addChild(CreateBackMenuItem()) - CCDirector:getInstance():pushScene( CCTransitionSlideInT:create(1, scene) ) + cc.Director:getInstance():pushScene( cc.TransitionSlideInT:create(1, scene) ) end @@ -39,28 +39,24 @@ SceneTestLayer1 = function() cclog("onQuit") end - local item1 = CCMenuItemFont:create( "Test pushScene") + local item1 = cc.MenuItemFont:create( "Test pushScene") item1:registerScriptTapHandler(onPushScene) - local item2 = CCMenuItemFont:create( "Test pushScene w/transition") + local item2 = cc.MenuItemFont:create( "Test pushScene w/transition") item2:registerScriptTapHandler(onPushSceneTran) - local item3 = CCMenuItemFont:create( "Quit") + local item3 = cc.MenuItemFont:create( "Quit") item3:registerScriptTapHandler(onQuit) - local arr = CCArray:create() - arr:addObject(item1) - arr:addObject(item2) - arr:addObject(item3) - local menu = CCMenu:createWithArray(arr) + local menu = cc.Menu:create(item1, item2, item3) menu:alignItemsVertically() ret:addChild( menu ) - local s = CCDirector:getInstance():getWinSize() - local sprite = CCSprite:create(s_pPathGrossini) + local s = cc.Director:getInstance():getWinSize() + local sprite = cc.Sprite:create(s_pPathGrossini) ret:addChild(sprite) - sprite:setPosition( CCPoint(s.width-40, s.height/2) ) - local rotate = CCRotateBy:create(2, 360) - local repeatAction = CCRepeatForever:create(rotate) + sprite:setPosition( cc.p(s.width-40, s.height/2) ) + local rotate = cc.RotateBy:create(2, 360) + local repeatAction = cc.RepeatForever:create(rotate) sprite:runAction(repeatAction) local function onNodeEvent(event) @@ -82,51 +78,47 @@ end -------------------------------------------------------------------- SceneTestLayer2 = function() - local ret = CCLayer:create() + local ret = cc.Layer:create() local m_timeCounter = 0 local function onGoBack(tag, pSender) - CCDirector:getInstance():popScene() + cc.Director:getInstance():popScene() end local function onReplaceScene(tag, pSender) - local scene = CCScene:create() + local scene = cc.Scene:create() local layer = SceneTestLayer3() scene:addChild(layer, 0) scene:addChild(CreateBackMenuItem()) - CCDirector:getInstance():replaceScene( scene ) + cc.Director:getInstance():replaceScene( scene ) end local function onReplaceSceneTran(tag, pSender) - local scene = CCScene:create() + local scene = cc.Scene:create() local layer = SceneTestLayer3() scene:addChild(layer, 0) scene:addChild(CreateBackMenuItem()) - CCDirector:getInstance():replaceScene( CCTransitionFlipX:create(2, scene) ) + cc.Director:getInstance():replaceScene( cc.TransitionFlipX:create(2, scene) ) end - local item1 = CCMenuItemFont:create( "replaceScene") + local item1 = cc.MenuItemFont:create( "replaceScene") item1:registerScriptTapHandler(onReplaceScene) - local item2 = CCMenuItemFont:create( "replaceScene w/transition") + local item2 = cc.MenuItemFont:create( "replaceScene w/transition") item2:registerScriptTapHandler(onReplaceSceneTran) - local item3 = CCMenuItemFont:create( "Go Back") + local item3 = cc.MenuItemFont:create( "Go Back") item3:registerScriptTapHandler(onGoBack) - local arr = CCArray:create() - arr:addObject(item1) - arr:addObject(item2) - arr:addObject(item3) - local menu = CCMenu:createWithArray(arr) + local menu = cc.Menu:create(item1, item2, item3) menu:alignItemsVertically() ret:addChild( menu ) - local s = CCDirector:getInstance():getWinSize() - local sprite = CCSprite:create(s_pPathGrossini) + local s = cc.Director:getInstance():getWinSize() + local sprite = cc.Sprite:create(s_pPathGrossini) ret:addChild(sprite) - sprite:setPosition( CCPoint(s.width-40, s.height/2) ) - local rotate = CCRotateBy:create(2, 360) - local repeat_action = CCRepeatForever:create(rotate) + sprite:setPosition( cc.p(s.width-40, s.height/2) ) + local rotate = cc.RotateBy:create(2, 360) + local repeat_action = cc.RepeatForever:create(rotate) sprite:runAction(repeat_action) return ret @@ -139,44 +131,39 @@ end -------------------------------------------------------------------- SceneTestLayer3 = function() - local ret = CCLayerColor:create(Color4B(0,0,255,255)) - local s = CCDirector:getInstance():getWinSize() + local ret = cc.LayerColor:create(cc.c4b(0,0,255,255)) + local s = cc.Director:getInstance():getWinSize() local function item0Clicked(tag, pSender) - local newScene = CCScene:create() + local newScene = cc.Scene:create() newScene:addChild(SceneTestLayer3()) - CCDirector:getInstance():pushScene(CCTransitionFade:create(0.5, newScene, Color3B(0,255,255))) + cc.Director:getInstance():pushScene(cc.TransitionFade:create(0.5, newScene, cc.c3b(0,255,255))) end local function item1Clicked(tag, pSender) - CCDirector:getInstance():popScene() + cc.Director:getInstance():popScene() end local function item2Clicked(tag, pSender) - CCDirector:getInstance():popToRootScene() + cc.Director:getInstance():popToRootScene() end - local item0 = CCMenuItemFont:create("Touch to pushScene (self)") + local item0 = cc.MenuItemFont:create("Touch to pushScene (self)") item0:registerScriptTapHandler(item0Clicked) - local item1 = CCMenuItemFont:create("Touch to popScene") + local item1 = cc.MenuItemFont:create("Touch to popScene") item1:registerScriptTapHandler(item1Clicked) - local item2 = CCMenuItemFont:create("Touch to popToRootScene") + local item2 = cc.MenuItemFont:create("Touch to popToRootScene") item2:registerScriptTapHandler(item2Clicked) - local arr = CCArray:create() - arr:addObject(item0) - arr:addObject(item1) - arr:addObject(item2) - - local menu = CCMenu:createWithArray(arr) + local menu = cc.Menu:create(item0, item1, item2) ret:addChild(menu) menu:alignItemsVertically() - local sprite = CCSprite:create(s_pPathGrossini) + local sprite = cc.Sprite:create(s_pPathGrossini) ret:addChild(sprite) - sprite:setPosition( CCPoint(s.width/2, 40) ) - local rotate = CCRotateBy:create(2, 360) - local repeatAction = CCRepeatForever:create(rotate) + sprite:setPosition( cc.p(s.width/2, 40) ) + local rotate = cc.RotateBy:create(2, 360) + local repeatAction = cc.RepeatForever:create(rotate) sprite:runAction(repeatAction) return ret end @@ -185,7 +172,7 @@ end function SceneTestMain() cclog("SceneTestMain") - local scene = CCScene:create() + local scene = cc.Scene:create() local layer = SceneTestLayer1() scene:addChild(layer, 0) scene:addChild(CreateBackMenuItem()) diff --git a/samples/Lua/TestLua/Resources/luaScript/SpriteTest/SpriteTest.lua b/samples/Lua/TestLua/Resources/luaScript/SpriteTest/SpriteTest.lua index 7ec8dd09a9..c6e9c6dd7b 100644 --- a/samples/Lua/TestLua/Resources/luaScript/SpriteTest/SpriteTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/SpriteTest/SpriteTest.lua @@ -1,4 +1,4 @@ -local size = CCDirector:getInstance():getWinSize() +local size = cc.Director:getInstance():getWinSize() local kTagTileMap = 1 local kTagSpriteBatchNode = 1 local kTagNode = 2 @@ -29,46 +29,46 @@ function Sprite1.addNewSpriteWithCoords(layer, point) local x = math.floor(math.mod(idx,5) * 85) local y = math.floor(idx / 5 * 121) - local sprite = CCSprite:create("Images/grossini_dance_atlas.png", CCRect(x,y,85,121) ) + local sprite = cc.Sprite:create("Images/grossini_dance_atlas.png", cc.rect(x,y,85,121) ) layer:addChild( sprite ) - sprite:setPosition( CCPoint(point.x, point.y) ) + sprite:setPosition( cc.p(point.x, point.y) ) local action = nil local random = math.random() cclog("random = " .. random) if( random < 0.20 ) then - action = CCScaleBy:create(3, 2) + action = cc.ScaleBy:create(3, 2) elseif(random < 0.40) then - action = CCRotateBy:create(3, 360) + action = cc.RotateBy:create(3, 360) elseif( random < 0.60) then - action = CCBlink:create(1, 3) + action = cc.Blink:create(1, 3) elseif( random < 0.8 ) then - action = CCTintBy:create(2, 0, -255, -255) + action = cc.TintBy:create(2, 0, -255, -255) else - action = CCFadeOut:create(2) + action = cc.FadeOut:create(2) end local action_back = action:reverse() - local seq = CCSequence:createWithTwoActions( action, action_back) + local seq = cc.Sequence:create( action, action_back) - sprite:runAction( CCRepeatForever:create(seq) ) + sprite:runAction( cc.RepeatForever:create(seq) ) end function Sprite1.onTouch(event, x, y) if event == "began" then return true elseif event == "ended" then - Sprite1.addNewSpriteWithCoords(Helper.currentLayer, CCPoint(x,y)) + Sprite1.addNewSpriteWithCoords(Helper.currentLayer, cc.p(x,y)) return true end end function Sprite1.create() cclog("sprite1") - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) - Sprite1.addNewSpriteWithCoords(layer, CCPoint(size.width/2, size.height/2)) + Sprite1.addNewSpriteWithCoords(layer, cc.p(size.width/2, size.height/2)) layer:setTouchEnabled(true) layer:registerScriptTouchHandler(Sprite1.onTouch) @@ -89,48 +89,48 @@ function SpriteBatchNode1.addNewSpriteWithCoords(layer, point) local x = math.floor(math.mod(idx,5) * 85) local y = math.floor(idx / 5 * 121) - local sprite = CCSprite:createWithTexture(BatchNode:getTexture(), CCRect(x,y,85,121) ) + local sprite = cc.Sprite:createWithTexture(BatchNode:getTexture(), cc.rect(x,y,85,121) ) layer:addChild( sprite ) - sprite:setPosition( CCPoint(point.x, point.y) ) + sprite:setPosition( cc.p(point.x, point.y) ) local action = nil local random = math.random() cclog("random = " .. random) if( random < 0.20 ) then - action = CCScaleBy:create(3, 2) + action = cc.ScaleBy:create(3, 2) elseif(random < 0.40) then - action = CCRotateBy:create(3, 360) + action = cc.RotateBy:create(3, 360) elseif( random < 0.60) then - action = CCBlink:create(1, 3) + action = cc.Blink:create(1, 3) elseif( random < 0.8 ) then - action = CCTintBy:create(2, 0, -255, -255) + action = cc.TintBy:create(2, 0, -255, -255) else - action = CCFadeOut:create(2) + action = cc.FadeOut:create(2) end local action_back = action:reverse() - local seq = CCSequence:createWithTwoActions( action, action_back) + local seq = cc.Sequence:create( action, action_back) - sprite:runAction( CCRepeatForever:create(seq) ) + sprite:runAction( cc.RepeatForever:create(seq) ) end function SpriteBatchNode1.onTouch(event, x, y) if event == "began" then return true elseif event == "ended" then - SpriteBatchNode1.addNewSpriteWithCoords(Helper.currentLayer, CCPoint(x,y)) + SpriteBatchNode1.addNewSpriteWithCoords(Helper.currentLayer, cc.p(x,y)) return true end end function SpriteBatchNode1.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) - local BatchNode = CCSpriteBatchNode:create("Images/grossini_dance_atlas.png", 50) + local BatchNode = cc.SpriteBatchNode:create("Images/grossini_dance_atlas.png", 50) layer:addChild(BatchNode, 0, kTagSpriteBatchNode) - SpriteBatchNode1.addNewSpriteWithCoords(layer, CCPoint(size.width/2, size.height/2)) + SpriteBatchNode1.addNewSpriteWithCoords(layer, cc.p(size.width/2, size.height/2)) layer:setTouchEnabled(true) layer:registerScriptTouchHandler(SpriteBatchNode1.onTouch) @@ -148,41 +148,41 @@ SpriteColorOpacity.__index = SpriteColorOpacity SpriteColorOpacity.entry = nil function SpriteColorOpacity.setLayerSprite(layer) - local sprite1 = CCSprite:create("Images/grossini_dance_atlas.png", CCRect(85*0, 121*1, 85, 121)) - local sprite2 = CCSprite:create("Images/grossini_dance_atlas.png", CCRect(85*1, 121*1, 85, 121)) - local sprite3 = CCSprite:create("Images/grossini_dance_atlas.png", CCRect(85*2, 121*1, 85, 121)) - local sprite4 = CCSprite:create("Images/grossini_dance_atlas.png", CCRect(85*3, 121*1, 85, 121)) + local sprite1 = cc.Sprite:create("Images/grossini_dance_atlas.png", cc.rect(85*0, 121*1, 85, 121)) + local sprite2 = cc.Sprite:create("Images/grossini_dance_atlas.png", cc.rect(85*1, 121*1, 85, 121)) + local sprite3 = cc.Sprite:create("Images/grossini_dance_atlas.png", cc.rect(85*2, 121*1, 85, 121)) + local sprite4 = cc.Sprite:create("Images/grossini_dance_atlas.png", cc.rect(85*3, 121*1, 85, 121)) - local sprite5 = CCSprite:create("Images/grossini_dance_atlas.png", CCRect(85*0, 121*1, 85, 121)) - local sprite6 = CCSprite:create("Images/grossini_dance_atlas.png", CCRect(85*1, 121*1, 85, 121)) - local sprite7 = CCSprite:create("Images/grossini_dance_atlas.png", CCRect(85*2, 121*1, 85, 121)) - local sprite8 = CCSprite:create("Images/grossini_dance_atlas.png", CCRect(85*3, 121*1, 85, 121)) + local sprite5 = cc.Sprite:create("Images/grossini_dance_atlas.png", cc.rect(85*0, 121*1, 85, 121)) + local sprite6 = cc.Sprite:create("Images/grossini_dance_atlas.png", cc.rect(85*1, 121*1, 85, 121)) + local sprite7 = cc.Sprite:create("Images/grossini_dance_atlas.png", cc.rect(85*2, 121*1, 85, 121)) + local sprite8 = cc.Sprite:create("Images/grossini_dance_atlas.png", cc.rect(85*3, 121*1, 85, 121)) - local s = CCDirector:getInstance():getWinSize() - sprite1:setPosition( CCPoint( (s.width/5)*1, (s.height/3)*1) ) - sprite2:setPosition( CCPoint( (s.width/5)*2, (s.height/3)*1) ) - sprite3:setPosition( CCPoint( (s.width/5)*3, (s.height/3)*1) ) - sprite4:setPosition( CCPoint( (s.width/5)*4, (s.height/3)*1) ) - sprite5:setPosition( CCPoint( (s.width/5)*1, (s.height/3)*2) ) - sprite6:setPosition( CCPoint( (s.width/5)*2, (s.height/3)*2) ) - sprite7:setPosition( CCPoint( (s.width/5)*3, (s.height/3)*2) ) - sprite8:setPosition( CCPoint( (s.width/5)*4, (s.height/3)*2) ) + local s = cc.Director:getInstance():getWinSize() + sprite1:setPosition( cc.p( (s.width/5)*1, (s.height/3)*1) ) + sprite2:setPosition( cc.p( (s.width/5)*2, (s.height/3)*1) ) + sprite3:setPosition( cc.p( (s.width/5)*3, (s.height/3)*1) ) + sprite4:setPosition( cc.p( (s.width/5)*4, (s.height/3)*1) ) + sprite5:setPosition( cc.p( (s.width/5)*1, (s.height/3)*2) ) + sprite6:setPosition( cc.p( (s.width/5)*2, (s.height/3)*2) ) + sprite7:setPosition( cc.p( (s.width/5)*3, (s.height/3)*2) ) + sprite8:setPosition( cc.p( (s.width/5)*4, (s.height/3)*2) ) - local action = CCFadeIn:create(2) + local action = cc.FadeIn:create(2) local action_back = action:reverse() - local fade = CCRepeatForever:create( CCSequence:createWithTwoActions( action, action_back) ) + local fade = cc.RepeatForever:create( cc.Sequence:create( action, action_back) ) - local tintred = CCTintBy:create(2, 0, -255, -255) + local tintred = cc.TintBy:create(2, 0, -255, -255) local tintred_back = tintred:reverse() - local red = CCRepeatForever:create( CCSequence:createWithTwoActions( tintred, tintred_back) ) + local red = cc.RepeatForever:create( cc.Sequence:create( tintred, tintred_back) ) - local tintgreen = CCTintBy:create(2, -255, 0, -255) + local tintgreen = cc.TintBy:create(2, -255, 0, -255) local tintgreen_back = tintgreen:reverse() - local green = CCRepeatForever:create( CCSequence:createWithTwoActions( tintgreen, tintgreen_back) ) + local green = cc.RepeatForever:create( cc.Sequence:create( tintgreen, tintgreen_back) ) - local tintblue = CCTintBy:create(2, -255, -255, 0) + local tintblue = cc.TintBy:create(2, -255, -255, 0) local tintblue_back = tintblue:reverse() - local blue = CCRepeatForever:create( CCSequence:createWithTwoActions( tintblue, tintblue_back) ) + local blue = cc.RepeatForever:create( cc.Sequence:create( tintblue, tintblue_back) ) sprite5:runAction(red) sprite6:runAction(green) @@ -220,7 +220,7 @@ function SpriteColorOpacity.removeAndAddSprite(dt) end function SpriteColorOpacity.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) SpriteColorOpacity.setLayerSprite(layer) layer:registerScriptHandler(SpriteColorOpacity.onEnterOrExit) @@ -240,51 +240,56 @@ SpriteFrameTest.m_pSprite2 = nil SpriteFrameTest.m_nCounter = 0 function SpriteFrameTest.onEnter() - local s = CCDirector:getInstance():getWinSize() - local cache = CCSpriteFrameCache:getInstance() + local s = cc.Director:getInstance():getWinSize() + local cache = cc.SpriteFrameCache:getInstance() - cache:addSpriteFramesWithFile("animations/grossini.plist") - cache:addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png") - cache:addSpriteFramesWithFile("animations/grossini_blue.plist", "animations/grossini_blue.png") + cache:addSpriteFrames("animations/grossini.plist") + cache:addSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray.png") + cache:addSpriteFrames("animations/grossini_blue.plist", "animations/grossini_blue.png") - SpriteFrameTest.m_pSprite1 = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - SpriteFrameTest.m_pSprite1:setPosition( CCPoint( s.width/2-80, s.height/2) ) + SpriteFrameTest.m_pSprite1 = cc.Sprite:createWithSpriteFrameName("grossini_dance_01.png") + SpriteFrameTest.m_pSprite1:setPosition( cc.p( s.width/2-80, s.height/2) ) - local spritebatch = CCSpriteBatchNode:create("animations/grossini.png") + local spritebatch = cc.SpriteBatchNode:create("animations/grossini.png") spritebatch:addChild(SpriteFrameTest.m_pSprite1) Helper.currentLayer:addChild(spritebatch) - local animFrames = CCArray:createWithCapacity(15) + local animFrames = {} for i = 1,14 do - local frame = cache:getSpriteFrameByName( string.format("grossini_dance_%02d.png", i) ) - animFrames:addObject(frame) + local frame = cache:getSpriteFrame( string.format("grossini_dance_%02d.png", i) ) + animFrames[i] = frame end - local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.3) - SpriteFrameTest.m_pSprite1:runAction( CCRepeatForever:create( CCAnimate:create(animation) ) ) + local animation = cc.Animation:createWithSpriteFrames(animFrames, 0.3) + SpriteFrameTest.m_pSprite1:runAction( cc.RepeatForever:create( cc.Animate:create(animation) ) ) SpriteFrameTest.m_pSprite1:setFlipX(false) SpriteFrameTest.m_pSprite1:setFlipY(false) - SpriteFrameTest.m_pSprite2 = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - SpriteFrameTest.m_pSprite2:setPosition( CCPoint( s.width/2 + 80, s.height/2) ) + SpriteFrameTest.m_pSprite2 = cc.Sprite:createWithSpriteFrameName("grossini_dance_01.png") + SpriteFrameTest.m_pSprite2:setPosition( cc.p( s.width/2 + 80, s.height/2) ) Helper.currentLayer:addChild(SpriteFrameTest.m_pSprite2) - local moreFrames = CCArray:createWithCapacity(20) + local moreFrames = {} for i = 1,14 do - local frame = cache:getSpriteFrameByName(string.format("grossini_dance_gray_%02d.png",i)) - moreFrames:addObject(frame) + local frame = cache:getSpriteFrame(string.format("grossini_dance_gray_%02d.png",i)) + moreFrames[i] = frame end for i = 1,4 do - local frame = cache:getSpriteFrameByName(string.format("grossini_blue_%02d.png",i)) - moreFrames:addObject(frame) + local frame = cache:getSpriteFrame(string.format("grossini_blue_%02d.png",i)) + moreFrames[14 + i] = frame end - moreFrames:addObjectsFromArray(animFrames) - local animMixed = CCAnimation:createWithSpriteFrames(moreFrames, 0.3) + --contact + for i = 1, 14 do + moreFrames[18 + i] = animFrames[i] + end - SpriteFrameTest.m_pSprite2:runAction(CCRepeatForever:create( CCAnimate:create(animMixed) ) ) + + local animMixed = cc.Animation:createWithSpriteFrames(moreFrames, 0.3) + + SpriteFrameTest.m_pSprite2:runAction(cc.RepeatForever:create( cc.Animate:create(animMixed) ) ) SpriteFrameTest.m_pSprite2:setFlipX(false) SpriteFrameTest.m_pSprite2:setFlipY(false) @@ -295,7 +300,7 @@ function SpriteFrameTest.onEnter() end function SpriteFrameTest.onExit() - local cache = CCSpriteFrameCache:getInstance() + local cache = cc.SpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") cache:removeSpriteFramesFromFile("animations/grossini_blue.plist") @@ -342,7 +347,7 @@ function SpriteFrameTest.onEnterOrExit(tag) end function SpriteFrameTest.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) layer:registerScriptHandler(SpriteFrameTest.onEnterOrExit) @@ -360,33 +365,33 @@ local SpriteFrameAliasNameTest = {} SpriteFrameAliasNameTest.__index = SpriteFrameAliasNameTest function SpriteFrameAliasNameTest.onEnter() - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local cache = CCSpriteFrameCache:getInstance() - cache:addSpriteFramesWithFile("animations/grossini-aliases.plist", "animations/grossini-aliases.png") + local cache = cc.SpriteFrameCache:getInstance() + cache:addSpriteFrames("animations/grossini-aliases.plist", "animations/grossini-aliases.png") - local sprite = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - sprite:setPosition(CCPoint(s.width * 0.5, s.height * 0.5)) + local sprite = cc.Sprite:createWithSpriteFrameName("grossini_dance_01.png") + sprite:setPosition(cc.p(s.width * 0.5, s.height * 0.5)) - local spriteBatch = CCSpriteBatchNode:create("animations/grossini-aliases.png") + local spriteBatch = cc.SpriteBatchNode:create("animations/grossini-aliases.png") cclog("spriteBatch = " .. tostring(tolua.isnull(spriteBatch))) cclog("sprite = " .. tostring(tolua.isnull(sprite))) spriteBatch:addChild(sprite) Helper.currentLayer:addChild(spriteBatch) - local animFrames = CCArray:createWithCapacity(15) + local animFrames = {} for i = 1,14 do - local frame = cache:getSpriteFrameByName(string.format("dance_%02d", i)) - animFrames:addObject(frame) + local frame = cache:getSpriteFrame(string.format("dance_%02d", i)) + animFrames[i] = frame end - local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.3) + local animation = cc.Animation:createWithSpriteFrames(animFrames, 0.3) -- 14 frames * 1sec = 14 seconds - sprite:runAction(CCRepeatForever:create(CCAnimate:create(animation))) + sprite:runAction(cc.RepeatForever:create(cc.Animate:create(animation))) end function SpriteFrameAliasNameTest.onExit() - CCSpriteFrameCache:getInstance():removeSpriteFramesFromFile("animations/grossini-aliases.plist") + cc.SpriteFrameCache:getInstance():removeSpriteFramesFromFile("animations/grossini-aliases.plist") end function SpriteFrameAliasNameTest.onEnterOrExit(tag) @@ -398,7 +403,7 @@ function SpriteFrameAliasNameTest.onEnterOrExit(tag) end function SpriteFrameAliasNameTest.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) layer:registerScriptHandler(SpriteFrameAliasNameTest.onEnterOrExit) @@ -417,30 +422,30 @@ local SpriteAnchorPoint = {} SpriteAnchorPoint.__index = SpriteAnchorPoint function SpriteAnchorPoint.initLayer(layer) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local rotate = CCRotateBy:create(10, 360) - local action = CCRepeatForever:create(rotate) + local rotate = cc.RotateBy:create(10, 360) + local action = cc.RepeatForever:create(rotate) for i = 0, 2 do - local sprite = CCSprite:create("Images/grossini_dance_atlas.png", CCRect(85*i, 121*1, 85, 121) ) - sprite:setPosition( CCPoint( s.width/4*(i+1), s.height/2) ) + local sprite = cc.Sprite:create("Images/grossini_dance_atlas.png", cc.rect(85*i, 121*1, 85, 121) ) + sprite:setPosition( cc.p( s.width/4*(i+1), s.height/2) ) - local point = CCSprite:create("Images/r1.png") + local point = cc.Sprite:create("Images/r1.png") point:setScale( 0.25 ) point:setPosition( sprite:getPosition() ) layer:addChild(point, 10) if i == 0 then - sprite:setAnchorPoint( CCPoint(0, 0) ) + sprite:setAnchorPoint( cc.p(0, 0) ) elseif i == 1 then - sprite:setAnchorPoint( CCPoint(0.5, 0.5) ) + sprite:setAnchorPoint( cc.p(0.5, 0.5) ) elseif i == 2 then - sprite:setAnchorPoint( CCPoint(1,1) ) + sprite:setAnchorPoint( cc.p(1,1) ) end point:setPosition( sprite:getPosition() ) - local copy = tolua.cast(action:clone(), "CCAction") + local copy = tolua.cast(action:clone(), "Action") sprite:runAction(copy) layer:addChild(sprite, i) end @@ -449,7 +454,7 @@ function SpriteAnchorPoint.initLayer(layer) end function SpriteAnchorPoint.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) layer = SpriteAnchorPoint.initLayer(layer) @@ -467,33 +472,33 @@ SpriteBatchNodeAnchorPoint.__index = SpriteBatchNodeAnchorPoint function SpriteBatchNodeAnchorPoint.initLayer(layer) -- small capacity. Testing resizing. -- Don't use capacity=1 in your real game. It is expensive to resize the capacity - local batch = CCSpriteBatchNode:create("Images/grossini_dance_atlas.png", 1) + local batch = cc.SpriteBatchNode:create("Images/grossini_dance_atlas.png", 1) layer:addChild(batch, 0, kTagSpriteBatchNode) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local rotate = CCRotateBy:create(10, 360) - local action = CCRepeatForever:create(rotate) + local rotate = cc.RotateBy:create(10, 360) + local action = cc.RepeatForever:create(rotate) for i=0,2 do - local sprite = CCSprite:createWithTexture(batch:getTexture(), CCRect(85*i, 121*1, 85, 121)) - sprite:setPosition( CCPoint( s.width/4*(i+1), s.height/2) ) + local sprite = cc.Sprite:createWithTexture(batch:getTexture(), cc.rect(85*i, 121*1, 85, 121)) + sprite:setPosition( cc.p( s.width/4*(i+1), s.height/2) ) - local point = CCSprite:create("Images/r1.png") + local point = cc.Sprite:create("Images/r1.png") point:setScale( 0.25 ) - point:setPosition( CCPoint(sprite:getPosition()) ) + point:setPosition( cc.p(sprite:getPosition()) ) layer:addChild(point, 1) if i == 0 then - sprite:setAnchorPoint( CCPoint(0,0) ) + sprite:setAnchorPoint( cc.p(0,0) ) elseif i == 1 then - sprite:setAnchorPoint( CCPoint(0.5, 0.5) ) + sprite:setAnchorPoint( cc.p(0.5, 0.5) ) elseif i == 2 then - sprite:setAnchorPoint( CCPoint(1,1) ) + sprite:setAnchorPoint( cc.p(1,1) ) end - point:setPosition( CCPoint(sprite:getPosition()) ) + point:setPosition( cc.p(sprite:getPosition()) ) - local copy = tolua.cast(action:clone(), "CCAction") + local copy = tolua.cast(action:clone(), "Action") sprite:runAction(copy) batch:addChild(sprite, i) end @@ -502,7 +507,7 @@ function SpriteBatchNodeAnchorPoint.initLayer(layer) end function SpriteBatchNodeAnchorPoint.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) layer = SpriteBatchNodeAnchorPoint.initLayer(layer) @@ -521,43 +526,43 @@ local SpriteOffsetAnchorRotation = {} SpriteOffsetAnchorRotation.__index = SpriteOffsetAnchorRotation function SpriteOffsetAnchorRotation.initLayer(layer) - local s = CCDirector:getInstance():getWinSize() - local cache = CCSpriteFrameCache:getInstance() - cache:addSpriteFramesWithFile("animations/grossini.plist") - cache:addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png") + local s = cc.Director:getInstance():getWinSize() + local cache = cc.SpriteFrameCache:getInstance() + cache:addSpriteFrames("animations/grossini.plist") + cache:addSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray.png") for i=0,2 do -- -- Animation using Sprite batch -- - local sprite = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - sprite:setPosition(CCPoint( s.width/4*(i+1), s.height/2)) + local sprite = cc.Sprite:createWithSpriteFrameName("grossini_dance_01.png") + sprite:setPosition(cc.p( s.width/4*(i+1), s.height/2)) - local point = CCSprite:create("Images/r1.png") + local point = cc.Sprite:create("Images/r1.png") point:setScale( 0.25 ) point:setPosition( sprite:getPosition() ) layer:addChild(point, 1) if i == 0 then - sprite:setAnchorPoint( CCPoint(0, 0) ) + sprite:setAnchorPoint( cc.p(0, 0) ) elseif i == 1 then - sprite:setAnchorPoint( CCPoint(0.5, 0.5) ) + sprite:setAnchorPoint( cc.p(0.5, 0.5) ) elseif i == 2 then - sprite:setAnchorPoint( CCPoint(1,1) ) + sprite:setAnchorPoint( cc.p(1,1) ) end - point:setPosition( CCPoint(sprite:getPosition()) ) + point:setPosition( cc.p(sprite:getPosition()) ) - local animFrames = CCArray:createWithCapacity(14) + local animFrames = {} for i = 0, 13 do - local frame = cache:getSpriteFrameByName(string.format("grossini_dance_%02d.png",(i+1))) - animFrames:addObject(frame) + local frame = cache:getSpriteFrame(string.format("grossini_dance_%02d.png",(i+1))) + animFrames[i + 1] = frame end - local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.3) - sprite:runAction(CCRepeatForever:create( CCAnimate:create(animation) ) ) - sprite:runAction(CCRepeatForever:create(CCRotateBy:create(10, 360) ) ) + local animation = cc.Animation:createWithSpriteFrames(animFrames, 0.3) + sprite:runAction(cc.RepeatForever:create( cc.Animate:create(animation) ) ) + sprite:runAction(cc.RepeatForever:create(cc.RotateBy:create(10, 360) ) ) layer:addChild(sprite, 0) end @@ -567,14 +572,14 @@ end function SpriteOffsetAnchorRotation.eventHandler(tag) if tag == "exit" then - local cache = CCSpriteFrameCache:getInstance() + local cache = cc.SpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") end end function SpriteOffsetAnchorRotation.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() layer:registerScriptHandler(SpriteOffsetAnchorRotation.eventHandler) Helper.initWithLayer(layer) @@ -595,13 +600,13 @@ SpriteBatchNodeOffsetAnchorRotation.__index = SpriteBatchNodeOffsetAnchorRotatio function SpriteBatchNodeOffsetAnchorRotation.initLayer(layer) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local cache = CCSpriteFrameCache:getInstance() - cache:addSpriteFramesWithFile("animations/grossini.plist") - cache:addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png") + local cache = cc.SpriteFrameCache:getInstance() + cache:addSpriteFrames("animations/grossini.plist") + cache:addSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray.png") - local spritebatch = CCSpriteBatchNode:create("animations/grossini.png") + local spritebatch = cc.SpriteBatchNode:create("animations/grossini.png") cclog("1") layer:addChild(spritebatch) @@ -610,33 +615,33 @@ function SpriteBatchNodeOffsetAnchorRotation.initLayer(layer) -- -- Animation using Sprite BatchNode -- - local sprite = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - sprite:setPosition( CCPoint( s.width/4*(i+1), s.height/2)) + local sprite = cc.Sprite:createWithSpriteFrameName("grossini_dance_01.png") + sprite:setPosition( cc.p( s.width/4*(i+1), s.height/2)) - local point = CCSprite:create("Images/r1.png") + local point = cc.Sprite:create("Images/r1.png") point:setScale( 0.25 ) - point:setPosition( CCPoint(sprite:getPosition()) ) + point:setPosition( cc.p(sprite:getPosition()) ) layer:addChild(point, 200) if i == 0 then - sprite:setAnchorPoint( CCPoint(0,0) ) + sprite:setAnchorPoint( cc.p(0,0) ) elseif i == 1 then - sprite:setAnchorPoint( CCPoint(0.5, 0.5) ) + sprite:setAnchorPoint( cc.p(0.5, 0.5) ) elseif i == 2 then - sprite:setAnchorPoint( CCPoint(1,1) ) + sprite:setAnchorPoint( cc.p(1,1) ) end - point:setPosition( CCPoint(sprite:getPosition()) ) + point:setPosition( cc.p(sprite:getPosition()) ) - local animFrames = CCArray:createWithCapacity(14) + local animFrames = {} for k = 0, 13 do - local frame = cache:getSpriteFrameByName(string.format("grossini_dance_%02d.png",(k+1))) - animFrames:addObject(frame) + local frame = cache:getSpriteFrame(string.format("grossini_dance_%02d.png",(k+1))) + animFrames[k + 1] = frame end - local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.3) - sprite:runAction(CCRepeatForever:create( CCAnimate:create(animation) )) - sprite:runAction(CCRepeatForever:create(CCRotateBy:create(10, 360) )) + local animation = cc.Animation:createWithSpriteFrames(animFrames, 0.3) + sprite:runAction(cc.RepeatForever:create( cc.Animate:create(animation) )) + sprite:runAction(cc.RepeatForever:create(cc.RotateBy:create(10, 360) )) spritebatch:addChild(sprite, i) end @@ -645,14 +650,14 @@ end function SpriteBatchNodeOffsetAnchorRotation.eventHandler(tag) if tag == "exit" then - local cache = CCSpriteFrameCache:getInstance() + local cache = cc.SpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") end end function SpriteBatchNodeOffsetAnchorRotation.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() layer:registerScriptHandler(SpriteBatchNodeOffsetAnchorRotation.eventHandler) Helper.initWithLayer(layer) @@ -672,48 +677,48 @@ local SpriteOffsetAnchorScale = {} SpriteOffsetAnchorScale.__index = SpriteOffsetAnchorScale function SpriteOffsetAnchorScale.initLayer(layer) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local cache = CCSpriteFrameCache:getInstance() - cache:addSpriteFramesWithFile("animations/grossini.plist") - cache:addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png") + local cache = cc.SpriteFrameCache:getInstance() + cache:addSpriteFrames("animations/grossini.plist") + cache:addSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray.png") for i = 0,2 do -- -- Animation using Sprite BatchNode -- - local sprite = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - sprite:setPosition( CCPoint( s.width/4*(i+1), s.height/2) ) + local sprite = cc.Sprite:createWithSpriteFrameName("grossini_dance_01.png") + sprite:setPosition( cc.p( s.width/4*(i+1), s.height/2) ) - local point = CCSprite:create("Images/r1.png") + local point = cc.Sprite:create("Images/r1.png") point:setScale( 0.25 ) point:setPosition( sprite:getPosition() ) layer:addChild(point, 1) if i == 0 then - sprite:setAnchorPoint( CCPoint(0, 0) ) + sprite:setAnchorPoint( cc.p(0, 0) ) elseif i == 1 then - sprite:setAnchorPoint( CCPoint(0.5, 0.5) ) + sprite:setAnchorPoint( cc.p(0.5, 0.5) ) elseif i == 2 then - sprite:setAnchorPoint( CCPoint(1,1) ) + sprite:setAnchorPoint( cc.p(1,1) ) end - point:setPosition( CCPoint(sprite:getPosition()) ) + point:setPosition( cc.p(sprite:getPosition()) ) - local animFrames = CCArray:createWithCapacity(14) + local animFrames = {} for i = 0, 13 do - local frame = cache:getSpriteFrameByName(string.format("grossini_dance_%02d.png",(i+1))) - animFrames:addObject(frame) + local frame = cache:getSpriteFrame(string.format("grossini_dance_%02d.png",(i+1))) + animFrames[i + 1] = frame end - local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.3) - sprite:runAction(CCRepeatForever:create( CCAnimate:create(animation) )) + local animation = cc.Animation:createWithSpriteFrames(animFrames, 0.3) + sprite:runAction(cc.RepeatForever:create( cc.Animate:create(animation) )) - local scale = CCScaleBy:create(2, 2) + local scale = cc.ScaleBy:create(2, 2) local scale_back = scale:reverse() - local seq_scale = CCSequence:createWithTwoActions(scale, scale_back) - sprite:runAction(CCRepeatForever:create(seq_scale)) + local seq_scale = cc.Sequence:create(scale, scale_back) + sprite:runAction(cc.RepeatForever:create(seq_scale)) layer:addChild(sprite, 0) end @@ -723,14 +728,14 @@ end function SpriteOffsetAnchorScale.eventHandler(tag) if tag == "exit" then - local cache = CCSpriteFrameCache:getInstance() + local cache = cc.SpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") end end function SpriteOffsetAnchorScale.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() layer:registerScriptHandler(SpriteOffsetAnchorScale.eventHandler) Helper.initWithLayer(layer) @@ -749,50 +754,50 @@ end local SpriteBatchNodeOffsetAnchorScale = {} function SpriteBatchNodeOffsetAnchorScale.initLayer(layer) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local cache = CCSpriteFrameCache:getInstance() - cache:addSpriteFramesWithFile("animations/grossini.plist") - cache:addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png") + local cache = cc.SpriteFrameCache:getInstance() + cache:addSpriteFrames("animations/grossini.plist") + cache:addSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray.png") - local spritesheet = CCSpriteBatchNode:create("animations/grossini.png") + local spritesheet = cc.SpriteBatchNode:create("animations/grossini.png") layer:addChild(spritesheet) for i = 0,2 do -- Animation using Sprite BatchNode - local sprite = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - sprite:setPosition(CCPoint(s.width/4*(i+1), s.height/2)) + local sprite = cc.Sprite:createWithSpriteFrameName("grossini_dance_01.png") + sprite:setPosition(cc.p(s.width/4*(i+1), s.height/2)) - local point = CCSprite:create("Images/r1.png") + local point = cc.Sprite:create("Images/r1.png") point:setScale(0.25) point:setPosition(sprite:getPosition()) layer:addChild(point, 200) if i == 0 then - sprite:setAnchorPoint(CCPoint(0,0)) + sprite:setAnchorPoint(cc.p(0,0)) elseif i == 1 then - sprite:setAnchorPoint(CCPoint(0.5, 0.5)) + sprite:setAnchorPoint(cc.p(0.5, 0.5)) else - sprite:setAnchorPoint(CCPoint(1, 1)) + sprite:setAnchorPoint(cc.p(1, 1)) end point:setPosition(sprite:getPosition()) - local animFrames = CCArray:createWithCapacity(14) + local animFrames = {} local str for k = 0, 13 do str = string.format("grossini_dance_%02d.png", (k+1)) - local frame = cache:getSpriteFrameByName(str) - animFrames:addObject(frame) + local frame = cache:getSpriteFrame(str) + animFrames[k + 1] = frame end - local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.3) - sprite:runAction(CCRepeatForever:create(CCAnimate:create(animation))) + local animation = cc.Animation:createWithSpriteFrames(animFrames, 0.3) + sprite:runAction(cc.RepeatForever:create(cc.Animate:create(animation))) - local scale = CCScaleBy:create(2, 2) + local scale = cc.ScaleBy:create(2, 2) local scale_back = scale:reverse() - local seq_scale = CCSequence:createWithTwoActions(scale, scale_back) - sprite:runAction(CCRepeatForever:create(seq_scale)) + local seq_scale = cc.Sequence:create(scale, scale_back) + sprite:runAction(cc.RepeatForever:create(seq_scale)) spritesheet:addChild(sprite, i) end @@ -801,7 +806,7 @@ function SpriteBatchNodeOffsetAnchorScale.initLayer(layer) end function SpriteBatchNodeOffsetAnchorScale.onExit() - local cache = CCSpriteFrameCache:getInstance() + local cache = cc.SpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") end @@ -813,7 +818,7 @@ function SpriteBatchNodeOffsetAnchorScale.eventHandler(tag) end function SpriteBatchNodeOffsetAnchorScale.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) layer:registerScriptHandler(SpriteBatchNodeOffsetAnchorScale.eventHandler) @@ -834,55 +839,50 @@ SpriteOffsetAnchorSkew.__index = SpriteOffsetAnchorSkew function SpriteOffsetAnchorSkew.initLayer(layer) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local cache = CCSpriteFrameCache:getInstance() - cache:addSpriteFramesWithFile("animations/grossini.plist") - cache:addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png") + local cache = cc.SpriteFrameCache:getInstance() + cache:addSpriteFrames("animations/grossini.plist") + cache:addSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray.png") for i = 0, 2 do -- -- Animation using Sprite batch -- - local sprite = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - sprite:setPosition(CCPoint(s.width / 4 * (i + 1), s.height / 2)) + local sprite = cc.Sprite:createWithSpriteFrameName("grossini_dance_01.png") + sprite:setPosition(cc.p(s.width / 4 * (i + 1), s.height / 2)) - local point = CCSprite:create("Images/r1.png") + local point = cc.Sprite:create("Images/r1.png") point:setScale(0.25) point:setPosition(sprite:getPosition()) layer:addChild(point, 1) if i == 0 then - sprite:setAnchorPoint(CCPoint(0, 0)) + sprite:setAnchorPoint(cc.p(0, 0)) elseif i == 1 then - sprite:setAnchorPoint(CCPoint(0.5, 0.5)) + sprite:setAnchorPoint(cc.p(0.5, 0.5)) elseif i == 2 then - sprite:setAnchorPoint(CCPoint(1, 1)) + sprite:setAnchorPoint(cc.p(1, 1)) end point:setPosition(sprite:getPosition()) - local animFrames = CCArray:create() + local animFrames = {} for j = 0, 13 do - local frame = cache:getSpriteFrameByName(string.format("grossini_dance_%02d.png", j + 1)) - animFrames:addObject(frame) + local frame = cache:getSpriteFrame(string.format("grossini_dance_%02d.png", j + 1)) + animFrames[j + 1] = frame end - local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.3) - sprite:runAction(CCRepeatForever:create(CCAnimate:create(animation))) + local animation = cc.Animation:createWithSpriteFrames(animFrames, 0.3) + sprite:runAction(cc.RepeatForever:create(cc.Animate:create(animation))) - local actionArray = CCArray:create() - local skewX = CCSkewBy:create(2, 45, 0) - actionArray:addObject(skewX) + local skewX = cc.SkewBy:create(2, 45, 0) local skewX_back = skewX:reverse() - actionArray:addObject(skewX_back) - local skewY = CCSkewBy:create(2, 0, 45) - actionArray:addObject(skewY) + local skewY = cc.SkewBy:create(2, 0, 45) local skewY_back = skewY:reverse() - actionArray:addObject(skewY_back) - local seq_skew = CCSequence:create(actionArray) - sprite:runAction(CCRepeatForever:create(seq_skew)) + local seq_skew = cc.Sequence:create(skewX, skewX_back, skewY, skewY_back) + sprite:runAction(cc.RepeatForever:create(seq_skew)) layer:addChild(sprite, 0) end @@ -892,14 +892,14 @@ end function SpriteOffsetAnchorSkew.eventHandler(tag) if tag == "exit" then - local cache = CCSpriteFrameCache:getInstance() + local cache = cc.SpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") end end function SpriteOffsetAnchorSkew.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() layer:registerScriptHandler(SpriteOffsetAnchorSkew.eventHandler) Helper.initWithLayer(layer) @@ -917,55 +917,50 @@ SpriteOffsetAnchorRotationalSkew.__index = SpriteOffsetAnchorRotationalSkew function SpriteOffsetAnchorRotationalSkew.initLayer(layer) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local cache = CCSpriteFrameCache:getInstance() - cache:addSpriteFramesWithFile("animations/grossini.plist") - cache:addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png") + local cache = cc.SpriteFrameCache:getInstance() + cache:addSpriteFrames("animations/grossini.plist") + cache:addSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray.png") for i = 0, 2 do -- -- Animation using Sprite batch -- - local sprite = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - sprite:setPosition(CCPoint(s.width/4*(i+1), s.height/2)) + local sprite = cc.Sprite:createWithSpriteFrameName("grossini_dance_01.png") + sprite:setPosition(cc.p(s.width/4*(i+1), s.height/2)) - local point = CCSprite:create("Images/r1.png") + local point = cc.Sprite:create("Images/r1.png") point:setScale(0.25) - point:setPosition(CCPoint(sprite:getPosition())) + point:setPosition(cc.p(sprite:getPosition())) layer:addChild(point, 1) if i == 0 then - sprite:setAnchorPoint(CCPoint(0,0)) + sprite:setAnchorPoint(cc.p(0,0)) elseif i == 1 then - sprite:setAnchorPoint(CCPoint(0.5, 0.5)) + sprite:setAnchorPoint(cc.p(0.5, 0.5)) elseif i == 2 then - sprite:setAnchorPoint(CCPoint(1,1)) + sprite:setAnchorPoint(cc.p(1,1)) end - point:setPosition(CCPoint(sprite:getPosition())) + point:setPosition(cc.p(sprite:getPosition())) - local animFrames = CCArray:create() + local animFrames = {} for i = 0,13 do - local frame = cache:getSpriteFrameByName(string.format("grossini_dance_%02d.png", (i+1))) - animFrames:addObject(frame) + local frame = cache:getSpriteFrame(string.format("grossini_dance_%02d.png", (i+1))) + animFrames[i + 1] = frame end - local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.3) - sprite:runAction(CCRepeatForever:create(CCAnimate:create(animation))) + local animation = cc.Animation:createWithSpriteFrames(animFrames, 0.3) + sprite:runAction(cc.RepeatForever:create(cc.Animate:create(animation))) - local actionArray = CCArray:create() - local skewX = CCRotateBy:create(2, 45) - actionArray:addObject(skewX) + local skewX = cc.RotateBy:create(2, 45) local skewX_back = skewX:reverse() - actionArray:addObject(skewX_back) - local skewY = CCRotateBy:create(2, -45) - actionArray:addObject(skewY) + local skewY = cc.RotateBy:create(2, -45) local skewY_back = skewY:reverse() - actionArray:addObject(skewY_back) - local seq_skew = CCSequence:create(actionArray) - sprite:runAction(CCRepeatForever:create(seq_skew)) + local seq_skew = cc.Sequence:create(skewX, skewX_back, skewY, skewY_back) + sprite:runAction(cc.RepeatForever:create(seq_skew)) layer:addChild(sprite, 0) end @@ -974,14 +969,14 @@ end function SpriteOffsetAnchorRotationalSkew.eventHandler(tag) if tag == "exit" then - local cache = CCSpriteFrameCache:getInstance() + local cache = cc.SpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") end end function SpriteOffsetAnchorRotationalSkew.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() layer:registerScriptHandler(SpriteOffsetAnchorRotationalSkew.eventHandler) Helper.initWithLayer(layer) @@ -1001,58 +996,53 @@ SpriteBatchNodeOffsetAnchorSkew.__index = SpriteBatchNodeOffsetAnchorSkew function SpriteBatchNodeOffsetAnchorSkew.initLayer(layer) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local cache = CCSpriteFrameCache:getInstance() - cache:addSpriteFramesWithFile("animations/grossini.plist") - cache:addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png") + local cache = cc.SpriteFrameCache:getInstance() + cache:addSpriteFrames("animations/grossini.plist") + cache:addSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray.png") - local spritebatch = CCSpriteBatchNode:create("animations/grossini.png") + local spritebatch = cc.SpriteBatchNode:create("animations/grossini.png") layer:addChild(spritebatch) for i = 0, 2 do -- -- Animation using Sprite batch -- - local sprite = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - sprite:setPosition(CCPoint(s.width / 4 * (i + 1), s.height / 2)) + local sprite = cc.Sprite:createWithSpriteFrameName("grossini_dance_01.png") + sprite:setPosition(cc.p(s.width / 4 * (i + 1), s.height / 2)) - local point = CCSprite:create("Images/r1.png") + local point = cc.Sprite:create("Images/r1.png") point:setScale(0.25) - point:setPosition(CCPoint(sprite:getPosition())) + point:setPosition(cc.p(sprite:getPosition())) layer:addChild(point, 200) if i == 0 then - sprite:setAnchorPoint(CCPoint(0, 0)) + sprite:setAnchorPoint(cc.p(0, 0)) elseif i == 1 then - sprite:setAnchorPoint(CCPoint(0.5, 0.5)) + sprite:setAnchorPoint(cc.p(0.5, 0.5)) elseif i == 2 then - sprite:setAnchorPoint(CCPoint(1, 1)) + sprite:setAnchorPoint(cc.p(1, 1)) end - point:setPosition(CCPoint(sprite:getPosition())) + point:setPosition(cc.p(sprite:getPosition())) - local animFrames = CCArray:create() + local animFrames = {} for j = 0, 13 do - local frame = cache:getSpriteFrameByName(string.format("grossini_dance_%02d.png", j + 1)) - animFrames:addObject(frame) + local frame = cache:getSpriteFrame(string.format("grossini_dance_%02d.png", j + 1)) + animFrames[j + 1] = frame end - local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.3) - sprite:runAction(CCRepeatForever:create(CCAnimate:create(animation))) + local animation = cc.Animation:createWithSpriteFrames(animFrames, 0.3) + sprite:runAction(cc.RepeatForever:create(cc.Animate:create(animation))) - local actionArray = CCArray:create() - local skewX = CCSkewBy:create(2, 45, 0) - actionArray:addObject(skewX) + local skewX = cc.SkewBy:create(2, 45, 0) local skewX_back = skewX:reverse() - actionArray:addObject(skewX_back) - local skewY = CCSkewBy:create(2, 0, 45) - actionArray:addObject(skewY) + local skewY = cc.SkewBy:create(2, 0, 45) local skewY_back = skewY:reverse() - actionArray:addObject(skewY_back) - local seq_skew = CCSequence:create(actionArray) - sprite:runAction(CCRepeatForever:create(seq_skew)) + local seq_skew = cc.Sequence:create(skewX, skewX_back, skewY, skewY_back) + sprite:runAction(cc.RepeatForever:create(seq_skew)) spritebatch:addChild(sprite, i) end @@ -1062,14 +1052,14 @@ end function SpriteBatchNodeOffsetAnchorSkew.eventHandler(tag) if tag == "exit" then - local cache = CCSpriteFrameCache:getInstance() + local cache = cc.SpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") end end function SpriteBatchNodeOffsetAnchorSkew.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() layer:registerScriptHandler(SpriteBatchNodeOffsetAnchorSkew.eventHandler) Helper.initWithLayer(layer) @@ -1088,59 +1078,54 @@ SpriteBatchNodeOffsetAnchorRotationalSkew.__index = SpriteBatchNodeOffsetAnchorR function SpriteBatchNodeOffsetAnchorRotationalSkew.initLayer(layer) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local cache = CCSpriteFrameCache:getInstance() - cache:addSpriteFramesWithFile("animations/grossini.plist") - cache:addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png") + local cache = cc.SpriteFrameCache:getInstance() + cache:addSpriteFrames("animations/grossini.plist") + cache:addSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray.png") - local spritebatch = CCSpriteBatchNode:create("animations/grossini.png") + local spritebatch = cc.SpriteBatchNode:create("animations/grossini.png") layer:addChild(spritebatch) for i = 0, 2 do -- -- Animation using Sprite batch -- - local sprite = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - sprite:setPosition(CCPoint(s.width/4*(i+1), s.height/2)) + local sprite = cc.Sprite:createWithSpriteFrameName("grossini_dance_01.png") + sprite:setPosition(cc.p(s.width/4*(i+1), s.height/2)) - local point = CCSprite:create("Images/r1.png") + local point = cc.Sprite:create("Images/r1.png") point:setScale(0.25) - point:setPosition(CCPoint(sprite:getPosition())) + point:setPosition(cc.p(sprite:getPosition())) layer:addChild(point, 200) if i == 0 then - sprite:setAnchorPoint(CCPoint(0,0)) + sprite:setAnchorPoint(cc.p(0,0)) elseif i == 1 then - sprite:setAnchorPoint(CCPoint(0.5, 0.5)) + sprite:setAnchorPoint(cc.p(0.5, 0.5)) elseif i == 2 then - sprite:setAnchorPoint(CCPoint(1,1)) + sprite:setAnchorPoint(cc.p(1,1)) end - point:setPosition(CCPoint(sprite:getPosition())) + point:setPosition(cc.p(sprite:getPosition())) - local animFrames = CCArray:create() + local animFrames = {} for j = 0, 13 do - local frame = cache:getSpriteFrameByName(string.format("grossini_dance_%02d.png", (j+1))) - animFrames:addObject(frame) + local frame = cache:getSpriteFrame(string.format("grossini_dance_%02d.png", (j+1))) + animFrames[j + 1] = frame end - local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.3) - sprite:runAction(CCRepeatForever:create(CCAnimate:create(animation))) + local animation = cc.Animation:createWithSpriteFrames(animFrames, 0.3) + sprite:runAction(cc.RepeatForever:create(cc.Animate:create(animation))) - local actionArray = CCArray:create() - local skewX = CCRotateBy:create(2, 45) - actionArray:addObject(skewX) + local skewX = cc.RotateBy:create(2, 45) local skewX_back = skewX:reverse() - actionArray:addObject(skewX_back) - local skewY = CCRotateBy:create(2, -45) - actionArray:addObject(skewY) + local skewY = cc.RotateBy:create(2, -45) local skewY_back = skewY:reverse() - actionArray:addObject(skewY_back) - local seq_skew = CCSequence:create(actionArray) - sprite:runAction(CCRepeatForever:create(seq_skew)) + local seq_skew = cc.Sequence:create(skewX, skewX_back, skewY, skewY_back) + sprite:runAction(cc.RepeatForever:create(seq_skew)) spritebatch:addChild(sprite, i) end @@ -1151,14 +1136,14 @@ end -- remove resources function SpriteBatchNodeOffsetAnchorRotationalSkew.eventHandler(tag) if tag == "exit" then - local cache = CCSpriteFrameCache:getInstance() + local cache = cc.SpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") end end function SpriteBatchNodeOffsetAnchorRotationalSkew.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() layer:registerScriptHandler(SpriteBatchNodeOffsetAnchorRotationalSkew.eventHandler) Helper.initWithLayer(layer) @@ -1175,60 +1160,55 @@ end local SpriteOffsetAnchorSkewScale = {} function SpriteOffsetAnchorSkewScale.initLayer(layer) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local cache = CCSpriteFrameCache:getInstance() - cache:addSpriteFramesWithFile("animations/grossini.plist") - cache:addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png") + local cache = cc.SpriteFrameCache:getInstance() + cache:addSpriteFrames("animations/grossini.plist") + cache:addSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray.png") for i = 0, 2 do -- Animation using Sprite batch - local sprite = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - sprite:setPosition(CCPoint(s.width / 4 * (i + 1), s.height / 2)) + local sprite = cc.Sprite:createWithSpriteFrameName("grossini_dance_01.png") + sprite:setPosition(cc.p(s.width / 4 * (i + 1), s.height / 2)) - local point = CCSprite:create("Images/r1.png") + local point = cc.Sprite:create("Images/r1.png") point:setScale(0.25) point:setPosition(sprite:getPosition()) layer:addChild(point, 1) if i == 0 then - sprite:setAnchorPoint(CCPoint(0,0)) + sprite:setAnchorPoint(cc.p(0,0)) elseif i == 1 then - sprite:setAnchorPoint(CCPoint(0.5, 0.5)) + sprite:setAnchorPoint(cc.p(0.5, 0.5)) else - sprite:setAnchorPoint(CCPoint(1, 1)) + sprite:setAnchorPoint(cc.p(1, 1)) end point:setPosition(sprite:getPosition()) - local animFrames = CCArray:create() + local animFrames = {} for j = 0, 13 do - local frame = cache:getSpriteFrameByName(string.format("grossini_dance_%02d.png", j+1)) - animFrames:addObject(frame) + local frame = cache:getSpriteFrame(string.format("grossini_dance_%02d.png", j+1)) + animFrames[j + 1] = frame end - local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.3) - sprite:runAction(CCRepeatForever:create(CCAnimate:create(animation))) + local animation = cc.Animation:createWithSpriteFrames(animFrames, 0.3) + sprite:runAction(cc.RepeatForever:create(cc.Animate:create(animation))) -- Skew - local skewX = CCSkewBy:create(2, 45, 0) + local skewX = cc.SkewBy:create(2, 45, 0) local skewX_back = skewX:reverse() - local skewY = CCSkewBy:create(2, 0, 45) + local skewY = cc.SkewBy:create(2, 0, 45) local skewY_back = skewY:reverse() - local actionArray = CCArray:create() - actionArray:addObject(skewX) - actionArray:addObject(skewX_back) - actionArray:addObject(skewY) - actionArray:addObject(skewY_back) - local seq_skew = CCSequence:create(actionArray) - sprite:runAction(CCRepeatForever:create(seq_skew)) + local seq_skew = cc.Sequence:create(skewX, skewX_back, skewY, skewY_back) + sprite:runAction(cc.RepeatForever:create(seq_skew)) -- Scale - local scale = CCScaleBy:create(2, 2) + local scale = cc.ScaleBy:create(2, 2) local scale_back = scale:reverse() - local seq_scale = CCSequence:createWithTwoActions(scale, scale_back) - sprite:runAction(CCRepeatForever:create(seq_scale)) + local seq_scale = cc.Sequence:create(scale, scale_back) + sprite:runAction(cc.RepeatForever:create(seq_scale)) layer:addChild(sprite, 0) end @@ -1238,14 +1218,14 @@ end function SpriteOffsetAnchorSkewScale.eventHandler(tag) if tag == "exit" then - local cache = CCSpriteFrameCache:getInstance() + local cache = cc.SpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") end end function SpriteOffsetAnchorSkewScale.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() layer:registerScriptHandler(SpriteOffsetAnchorSkewScale.eventHandler) Helper.initWithLayer(layer) @@ -1261,60 +1241,55 @@ end local SpriteOffsetAnchorRotationalSkewScale = {} function SpriteOffsetAnchorRotationalSkewScale.initLayer(layer) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local cache = CCSpriteFrameCache:getInstance() - cache:addSpriteFramesWithFile("animations/grossini.plist") - cache:addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png") + local cache = cc.SpriteFrameCache:getInstance() + cache:addSpriteFrames("animations/grossini.plist") + cache:addSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray.png") for i = 0, 2 do -- Animation using Sprite batch - local sprite = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - sprite:setPosition(CCPoint(s.width/4*(i+1), s.height/2)) + local sprite = cc.Sprite:createWithSpriteFrameName("grossini_dance_01.png") + sprite:setPosition(cc.p(s.width/4*(i+1), s.height/2)) - local point = CCSprite:create("Images/r1.png") + local point = cc.Sprite:create("Images/r1.png") point:setScale(0.25) point:setPosition(sprite:getPosition()) layer:addChild(point, 1) if i == 0 then - sprite:setAnchorPoint(CCPoint(0, 0)) + sprite:setAnchorPoint(cc.p(0, 0)) elseif i == 1 then - sprite:setAnchorPoint(CCPoint(0.5, 0.5)) + sprite:setAnchorPoint(cc.p(0.5, 0.5)) else - sprite:setAnchorPoint(CCPoint(1, 1)) + sprite:setAnchorPoint(cc.p(1, 1)) end point:setPosition(sprite:getPosition()) - local animFrames = CCArray:create() + local animFrames = {} for j = 0, 13 do - local frame = cache:getSpriteFrameByName(string.format("grossini_dance_%02d.png", (j+1))) - animFrames:addObject(frame) + local frame = cache:getSpriteFrame(string.format("grossini_dance_%02d.png", (j+1))) + animFrames[j + 1] = frame end - local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.3) - sprite:runAction(CCRepeatForever:create(CCAnimate:create(animation))) + local animation = cc.Animation:createWithSpriteFrames(animFrames, 0.3) + sprite:runAction(cc.RepeatForever:create(cc.Animate:create(animation))) -- Skew - local skewX = CCRotateBy:create(2, 45, 0) + local skewX = cc.RotateBy:create(2, 45, 0) local skewX_back = skewX:reverse() - local skewY = CCRotateBy:create(2, 0, 45) + local skewY = cc.RotateBy:create(2, 0, 45) local skewY_back = skewY:reverse() - local actionArray = CCArray:create() - actionArray:addObject(skewX) - actionArray:addObject(skewX_back) - actionArray:addObject(skewY) - actionArray:addObject(skewY_back) - local seq_skew = CCSequence:create(actionArray) - sprite:runAction(CCRepeatForever:create(seq_skew)) + local seq_skew = cc.Sequence:create(skewX, skewX_back, skewY, skewY_back) + sprite:runAction(cc.RepeatForever:create(seq_skew)) -- Scale - local scale = CCScaleBy:create(2, 2) + local scale = cc.ScaleBy:create(2, 2) local scale_back = scale:reverse() - local seq_scale = CCSequence:createWithTwoActions(scale, scale_back) - sprite:runAction(CCRepeatForever:create(seq_scale)) + local seq_scale = cc.Sequence:create(scale, scale_back) + sprite:runAction(cc.RepeatForever:create(seq_scale)) layer:addChild(sprite, i) end @@ -1324,14 +1299,14 @@ end function SpriteOffsetAnchorRotationalSkewScale.eventHandler(tag) if tag == "exit" then - local cache = CCSpriteFrameCache:getInstance() + local cache = cc.SpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") end end function SpriteOffsetAnchorRotationalSkewScale.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() layer:registerScriptHandler(SpriteOffsetAnchorRotationalSkewScale.eventHandler) Helper.initWithLayer(layer) @@ -1347,65 +1322,60 @@ end local SpriteBatchNodeOffsetAnchorSkewScale = {} function SpriteBatchNodeOffsetAnchorSkewScale.initLayer(layer) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local cache = CCSpriteFrameCache:getInstance() - cache:addSpriteFramesWithFile("animations/grossini.plist") - cache:addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png") + local cache = cc.SpriteFrameCache:getInstance() + cache:addSpriteFrames("animations/grossini.plist") + cache:addSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray.png") - local spritebatch = CCSpriteBatchNode:create("animations/grossini.png") + local spritebatch = cc.SpriteBatchNode:create("animations/grossini.png") layer:addChild(spritebatch) for i = 0, 2 do -- Animation using Sprite batch - local sprite = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - sprite:setPosition(CCPoint(s.width / 4 * (i + 1), s.height / 2)) + local sprite = cc.Sprite:createWithSpriteFrameName("grossini_dance_01.png") + sprite:setPosition(cc.p(s.width / 4 * (i + 1), s.height / 2)) - local point = CCSprite:create("Images/r1.png") + local point = cc.Sprite:create("Images/r1.png") point:setScale(0.25) point:setPosition(sprite:getPosition()) layer:addChild(point, 200) if i == 0 then - sprite:setAnchorPoint(CCPoint(0, 0)) + sprite:setAnchorPoint(cc.p(0, 0)) elseif i == 1 then - sprite:setAnchorPoint(CCPoint(0.5, 0.5)) + sprite:setAnchorPoint(cc.p(0.5, 0.5)) else - sprite:setAnchorPoint(CCPoint(1, 1)) + sprite:setAnchorPoint(cc.p(1, 1)) end point:setPosition(sprite:getPosition()) - local animFrames = CCArray:create() + local animFrames = {} for j = 0, 13 do - local frame = cache:getSpriteFrameByName(string.format("grossini_dance_%02d.png", (j+1))) - animFrames:addObject(frame) + local frame = cache:getSpriteFrame(string.format("grossini_dance_%02d.png", (j+1))) + animFrames[j + 1] = frame end - local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.3) - sprite:runAction(CCRepeatForever:create(CCAnimate:create(animation))) + local animation = cc.Animation:createWithSpriteFrames(animFrames, 0.3) + sprite:runAction(cc.RepeatForever:create(cc.Animate:create(animation))) -- skew - local skewX = CCSkewBy:create(2, 45, 0) + local skewX = cc.SkewBy:create(2, 45, 0) local skewX_back = skewX:reverse() - local skewY = CCSkewBy:create(2, 0, 45) + local skewY = cc.SkewBy:create(2, 0, 45) local skewY_back = skewY:reverse() - local actionArray = CCArray:create() - actionArray:addObject(skewX) - actionArray:addObject(skewX_back) - actionArray:addObject(skewY) - actionArray:addObject(skewY_back) - local seq_skew = CCSequence:create(actionArray) - sprite:runAction(CCRepeatForever:create(seq_skew)) + local seq_skew = cc.Sequence:create(skewX, skewX_back, skewY, skewY_back) + sprite:runAction(cc.RepeatForever:create(seq_skew)) -- scale - local scale = CCScaleBy:create(2, 2) + local scale = cc.ScaleBy:create(2, 2) local scale_back = scale:reverse() - local seq_scale = CCSequence:createWithTwoActions(scale, scale_back) - sprite:runAction(CCRepeatForever:create(seq_scale)) + local seq_scale = cc.Sequence:create(scale, scale_back) + sprite:runAction(cc.RepeatForever:create(seq_scale)) spritebatch:addChild(sprite, i) end @@ -1413,14 +1383,14 @@ end function SpriteBatchNodeOffsetAnchorSkewScale.eventHandler(tag) if tag == "exit" then - local cache = CCSpriteFrameCache:getInstance() + local cache = cc.SpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") end end function SpriteBatchNodeOffsetAnchorSkewScale.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() layer:registerScriptHandler(SpriteBatchNodeOffsetAnchorSkewScale.eventHandler) Helper.initWithLayer(layer) @@ -1435,21 +1405,21 @@ end -- local SpriteBatchNodeOffsetAnchorRotationalSkewScale = {} function SpriteBatchNodeOffsetAnchorRotationalSkewScale.initLayer(layer) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local cache = CCSpriteFrameCache:getInstance() - cache:addSpriteFramesWithFile("animations/grossini.plist") - cache:addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png") + local cache = cc.SpriteFrameCache:getInstance() + cache:addSpriteFrames("animations/grossini.plist") + cache:addSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray.png") - local spritebatch = CCSpriteBatchNode:create("animations/grossini.png") + local spritebatch = cc.SpriteBatchNode:create("animations/grossini.png") layer:addChild(spritebatch) for i = 0, 2 do -- Animation using Sprite batch - local sprite = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - sprite:setPosition(CCPoint(s.width/4*(i+1), s.height/2)) + local sprite = cc.Sprite:createWithSpriteFrameName("grossini_dance_01.png") + sprite:setPosition(cc.p(s.width/4*(i+1), s.height/2)) - local point = CCSprite:create("Images/r1.png") + local point = cc.Sprite:create("Images/r1.png") point:setScale(0.25) point:setPosition(sprite:getPosition()) @@ -1457,42 +1427,37 @@ function SpriteBatchNodeOffsetAnchorRotationalSkewScale.initLayer(layer) layer:addChild(point, 200) if i == 0 then - sprite:setAnchorPoint(CCPoint(0, 0)) + sprite:setAnchorPoint(cc.p(0, 0)) elseif i == 1 then - sprite:setAnchorPoint(CCPoint(0.5, 0.5)) + sprite:setAnchorPoint(cc.p(0.5, 0.5)) else - sprite:setAnchorPoint(CCPoint(1, 1)) + sprite:setAnchorPoint(cc.p(1, 1)) end point:setPosition(sprite:getPosition()) - local animFrames = CCArray:create() + local animFrames = {} for j = 0, 13 do - local frame = cache:getSpriteFrameByName(string.format("grossini_dance_%02d.png", j+1)) - animFrames:addObject(frame) + local frame = cache:getSpriteFrame(string.format("grossini_dance_%02d.png", j+1)) + animFrames[j + 1] = frame end - local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.3) - sprite:runAction(CCRepeatForever:create(CCAnimate:create(animation))) + local animation = cc.Animation:createWithSpriteFrames(animFrames, 0.3) + sprite:runAction(cc.RepeatForever:create(cc.Animate:create(animation))) -- Skew - local skewX = CCRotateBy:create(2, 45, 0) + local skewX = cc.RotateBy:create(2, 45, 0) local skewX_back = skewX:reverse() - local skewY = CCRotateBy:create(2, 0, 45) + local skewY = cc.RotateBy:create(2, 0, 45) local skewY_back = skewY:reverse() - local actionArray = CCArray:create() - actionArray:addObject(skewX) - actionArray:addObject(skewX_back) - actionArray:addObject(skewY) - actionArray:addObject(skewY_back) - local seq_skew = CCSequence:create(actionArray) - sprite:runAction(CCRepeatForever:create(seq_skew)) + local seq_skew = cc.Sequence:create(skewX, skewX_back, skewY, skewY_back) + sprite:runAction(cc.RepeatForever:create(seq_skew)) -- Scale - local scale = CCScaleBy:create(2, 2) + local scale = cc.ScaleBy:create(2, 2) local scale_back = scale:reverse() - local seq_scale = CCSequence:createWithTwoActions(scale, scale_back) - sprite:runAction(CCRepeatForever:create(seq_scale)) + local seq_scale = cc.Sequence:create(scale, scale_back) + sprite:runAction(cc.RepeatForever:create(seq_scale)) spritebatch:addChild(sprite, i) end @@ -1500,14 +1465,14 @@ end function SpriteBatchNodeOffsetAnchorRotationalSkewScale.eventHandler(tag) if tag == "exit" then - local cache = CCSpriteFrameCache:getInstance() + local cache = cc.SpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") end end function SpriteBatchNodeOffsetAnchorRotationalSkewScale.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() layer:registerScriptHandler(SpriteBatchNodeOffsetAnchorRotationalSkewScale.eventHandler) Helper.initWithLayer(layer) SpriteBatchNodeOffsetAnchorRotationalSkewScale.initLayer(layer) @@ -1522,53 +1487,48 @@ end -- local SpriteOffsetAnchorFlip = {} function SpriteOffsetAnchorFlip.initLayer(layer) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local cache = CCSpriteFrameCache:getInstance() - cache:addSpriteFramesWithFile("animations/grossini.plist") - cache:addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png") + local cache = cc.SpriteFrameCache:getInstance() + cache:addSpriteFrames("animations/grossini.plist") + cache:addSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray.png") for i = 0, 2 do -- Animation using Sprite batch - local sprite = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - sprite:setPosition(CCPoint(s.width / 4 * (i + 1), s.height / 2)) + local sprite = cc.Sprite:createWithSpriteFrameName("grossini_dance_01.png") + sprite:setPosition(cc.p(s.width / 4 * (i + 1), s.height / 2)) - local point = CCSprite:create("Images/r1.png") + local point = cc.Sprite:create("Images/r1.png") point:setScale(0.25) point:setPosition(sprite:getPosition()) layer:addChild(point, 1) if i == 0 then - sprite:setAnchorPoint(CCPoint(0, 0)) + sprite:setAnchorPoint(cc.p(0, 0)) elseif i == 1 then - sprite:setAnchorPoint(CCPoint(0.5, 0.5)) + sprite:setAnchorPoint(cc.p(0.5, 0.5)) else - sprite:setAnchorPoint(CCPoint(1, 1)) + sprite:setAnchorPoint(cc.p(1, 1)) end point:setPosition(sprite:getPosition()) - local animFrames = CCArray:create() + local animFrames = {} for j = 0, 13 do - local frame = cache:getSpriteFrameByName(string.format("grossini_dance_%02d.png", j+1)) - animFrames:addObject(frame) + local frame = cache:getSpriteFrame(string.format("grossini_dance_%02d.png", j+1)) + animFrames[j + 1] = frame end - local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.3) - sprite:runAction(CCRepeatForever:create(CCAnimate:create(animation))) + local animation = cc.Animation:createWithSpriteFrames(animFrames, 0.3) + sprite:runAction(cc.RepeatForever:create(cc.Animate:create(animation))) - local flip = CCFlipY:create(true) - local flip_back = CCFlipY:create(false) - local delay = CCDelayTime:create(1) - local delay2 = CCDelayTime:create(1) + local flip = cc.FlipY:create(true) + local flip_back = cc.FlipY:create(false) + local delay = cc.DelayTime:create(1) + local delay2 = cc.DelayTime:create(1) - local actionArray = CCArray:create() - actionArray:addObject(delay) - actionArray:addObject(flip) - actionArray:addObject(delay2) - actionArray:addObject(flip_back) - local seq = CCSequence:create(actionArray) - sprite:runAction(CCRepeatForever:create(seq)) + local seq = cc.Sequence:create(delay, flip, delay2, flip_back) + sprite:runAction(cc.RepeatForever:create(seq)) layer:addChild(sprite, 0) end @@ -1576,14 +1536,14 @@ end function SpriteOffsetAnchorFlip.eventHandler(tag) if tag == "exit" then - local cache = CCSpriteFrameCache:getInstance() + local cache = cc.SpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") end end function SpriteOffsetAnchorFlip.create() - local layer = CCLayer:create() + local layer = cc.Layer:create() layer:registerScriptHandler(SpriteOffsetAnchorFlip.eventHandler) Helper.initWithLayer(layer) @@ -1596,7 +1556,7 @@ end function SpriteTest() - local scene = CCScene:create() + local scene = cc.Scene:create() Helper.createFunctionTable = { Sprite1.create, diff --git a/samples/Lua/TestLua/Resources/luaScript/Texture2dTest/Texture2dTest.lua b/samples/Lua/TestLua/Resources/luaScript/Texture2dTest/Texture2dTest.lua index 40c2dcf0b3..ec191438b1 100644 --- a/samples/Lua/TestLua/Resources/luaScript/Texture2dTest/Texture2dTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/Texture2dTest/Texture2dTest.lua @@ -1,4 +1,4 @@ -local scheduler = CCDirector:getInstance():getScheduler() +local scheduler = cc.Director:getInstance():getScheduler() local kTagLabel = 1 local kTagSprite1 = 2 local kTagSprite2 = 3 @@ -7,10 +7,10 @@ local originCreateLayer = createTestLayer local function createTestLayer(title, subtitle) local ret = originCreateLayer(title, subtitle) Helper.titleLabel:setTag(kTagLabel) - CCTextureCache:getInstance():dumpCachedTextureInfo() - local col = CCLayerColor:create(Color4B(128,128,128,255)) + cc.TextureCache:getInstance():dumpCachedTextureInfo() + local col = cc.LayerColor:create(cc.c4b(128,128,128,255)) ret:addChild(col, -10) - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end -------------------------------------------------------------------- @@ -21,12 +21,12 @@ end local function TextureTIFF() local ret = createTestLayer("TIFF Test") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image.tiff") - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + local img = cc.Sprite:create("Images/test_image.tiff") + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -38,12 +38,12 @@ end local function TexturePNG() local ret = createTestLayer("PNG Test") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image.png") - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + local img = cc.Sprite:create("Images/test_image.png") + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -54,12 +54,12 @@ end -------------------------------------------------------------------- local function TextureJPEG() local ret = createTestLayer("JPEG Test") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image.jpeg") - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + local img = cc.Sprite:create("Images/test_image.jpeg") + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -70,12 +70,12 @@ end -------------------------------------------------------------------- local function TextureWEBP() local ret = createTestLayer("WEBP Test") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image.webp") - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + local img = cc.Sprite:create("Images/test_image.webp") + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -87,47 +87,35 @@ end local function TextureMipMap() local ret = createTestLayer("Texture Mipmap", "Left image uses mipmap. Right image doesn't") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local texture0 = CCTextureCache:getInstance():addImage( + local texture0 = cc.TextureCache:getInstance():addImage( "Images/grossini_dance_atlas.png") texture0:generateMipmap() - local texParams = CCTexture:TexParams() - texParams.minFilter = GL_LINEAR_MIPMAP_LINEAR - texParams.magFilter = GL_LINEAR - texParams.wrapS = GL_CLAMP_TO_EDGE - texParams.wrapT = GL_CLAMP_TO_EDGE - texture0:setTexParameters(texParams) + texture0:setTexParameters(gl.LINEAR_MIPMAP_LINEAR, gl.LINEAR, gl.CLAMP_TO_EDGE, gl.CLAMP_TO_EDGE) - local texture1 = CCTextureCache:getInstance():addImage( + local texture1 = cc.TextureCache:getInstance():addImage( "Images/grossini_dance_atlas_nomipmap.png") - local img0 = CCSprite:createWithTexture(texture0) - img0:setTextureRect(CCRect(85, 121, 85, 121)) - img0:setPosition(CCPoint( s.width/3.0, s.height/2.0)) + local img0 = cc.Sprite:createWithTexture(texture0) + img0:setTextureRect(cc.rect(85, 121, 85, 121)) + img0:setPosition(cc.p( s.width/3.0, s.height/2.0)) ret:addChild(img0) - local img1 = CCSprite:createWithTexture(texture1) - img1:setTextureRect(CCRect(85, 121, 85, 121)) - img1:setPosition(CCPoint( 2*s.width/3.0, s.height/2.0)) + local img1 = cc.Sprite:createWithTexture(texture1) + img1:setTextureRect(cc.rect(85, 121, 85, 121)) + img1:setPosition(cc.p( 2*s.width/3.0, s.height/2.0)) ret:addChild(img1) - local scale1 = CCEaseOut:create(CCScaleBy:create(4, 0.01), 3) + local scale1 = cc.EaseOut:create(cc.ScaleBy:create(4, 0.01), 3) local sc_back = scale1:reverse() - local scale2 = tolua.cast(scale1:clone(), "CCEaseOut") + local scale2 = tolua.cast(scale1:clone(), "EaseOut") local sc_back2 = scale2:reverse() - local arr = CCArray:create() - arr:addObject(scale1) - arr:addObject(sc_back) - img0:runAction(CCRepeatForever:create(CCSequence:create(arr))) - - arr = CCArray:create() - arr:addObject(scale2) - arr:addObject(sc_back2) - img1:runAction(CCRepeatForever:create(CCSequence:create(arr))) - CCTextureCache:getInstance():dumpCachedTextureInfo() + img0:runAction(cc.RepeatForever:create(cc.Sequence:create(scale1, sc_back))) + img1:runAction(cc.RepeatForever:create(cc.Sequence:create(scale2, sc_back2))) + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -140,47 +128,33 @@ end -------------------------------------------------------------------- local function TexturePVRMipMap() local ret = createTestLayer("PVRTC MipMap Test", "Left image uses mipmap. Right image doesn't") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local imgMipMap = CCSprite:create("Images/logo-mipmap.pvr") + local imgMipMap = cc.Sprite:create("Images/logo-mipmap.pvr") if imgMipMap ~= nil then - imgMipMap:setPosition(CCPoint( s.width/2.0-100, s.height/2.0)) + imgMipMap:setPosition(cc.p( s.width/2.0-100, s.height/2.0)) ret:addChild(imgMipMap) -- support mipmap filtering - local texParams = CCTexture:TexParams() - texParams.minFilter = GL_LINEAR_MIPMAP_LINEAR - texParams.magFilter = GL_LINEAR - texParams.wrapS = GL_CLAMP_TO_EDGE - texParams.wrapT = GL_CLAMP_TO_EDGE - - imgMipMap:getTexture():setTexParameters(texParams) + imgMipMap:getTexture():setTexParameters(gl.LINEAR_MIPMAP_LINEAR, gl.LINEAR, gl.CLAMP_TO_EDGE, gl.CLAMP_TO_EDGE) end - local img = CCSprite:create("Images/logo-nomipmap.pvr") + local img = cc.Sprite:create("Images/logo-nomipmap.pvr") if img ~= nil then - img:setPosition(CCPoint( s.width/2.0+100, s.height/2.0)) + img:setPosition(cc.p( s.width/2.0+100, s.height/2.0)) ret:addChild(img) - local scale1 = CCEaseOut:create(CCScaleBy:create(4, 0.01), 3) + local scale1 = cc.EaseOut:create(cc.ScaleBy:create(4, 0.01), 3) local sc_back = scale1:reverse() - local scale2 = tolua.cast(scale1:clone(), "CCEaseOut") + local scale2 = tolua.cast(scale1:clone(), "EaseOut") local sc_back2 = scale2:reverse() - local arr = CCArray:create() - arr:addObject(scale1) - arr:addObject(sc_back) - imgMipMap:runAction(CCRepeatForever:create(CCSequence:create(arr))) - - arr = CCArray:create() - arr:addObject(scale2) - arr:addObject(sc_back2) - - img:runAction(CCRepeatForever:create(CCSequence:create(arr))) + imgMipMap:runAction(cc.RepeatForever:create(cc.Sequence:create(scale1, sc_back))) + img:runAction(cc.RepeatForever:create(cc.Sequence:create(scale2, sc_back2))) end - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -192,42 +166,29 @@ end -------------------------------------------------------------------- local function TexturePVRMipMap2() local ret = createTestLayer("PVR MipMap Test #2", "Left image uses mipmap. Right image doesn't") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local imgMipMap = CCSprite:create("Images/test_image_rgba4444_mipmap.pvr") - imgMipMap:setPosition(CCPoint( s.width/2.0-100, s.height/2.0)) + local imgMipMap = cc.Sprite:create("Images/test_image_rgba4444_mipmap.pvr") + imgMipMap:setPosition(cc.p( s.width/2.0-100, s.height/2.0)) ret:addChild(imgMipMap) -- support mipmap filtering - local texParams = CCTexture:TexParams() - texParams.minFilter = GL_LINEAR_MIPMAP_LINEAR - texParams.magFilter = GL_LINEAR - texParams.wrapS = GL_CLAMP_TO_EDGE - texParams.wrapT = GL_CLAMP_TO_EDGE + imgMipMap:getTexture():setTexParameters(gl.LINEAR_MIPMAP_LINEAR, gl.LINEAR, gl.CLAMP_TO_EDGE, gl.CLAMP_TO_EDGE) - imgMipMap:getTexture():setTexParameters(texParams) - - local img = CCSprite:create("Images/test_image.png") - img:setPosition(CCPoint( s.width/2.0+100, s.height/2.0)) + local img = cc.Sprite:create("Images/test_image.png") + img:setPosition(cc.p( s.width/2.0+100, s.height/2.0)) ret:addChild(img) - local scale1 = CCEaseOut:create(CCScaleBy:create(4, 0.01), 3) + local scale1 = cc.EaseOut:create(cc.ScaleBy:create(4, 0.01), 3) local sc_back = scale1:reverse() - local scale2 = tolua.cast(scale1:clone(), "CCEaseOut") + local scale2 = tolua.cast(scale1:clone(), "EaseOut") local sc_back2 = scale2:reverse() - local arr = CCArray:create() - arr:addObject(scale1) - arr:addObject(sc_back) - imgMipMap:runAction(CCRepeatForever:create(CCSequence:create(arr))) + imgMipMap:runAction(cc.RepeatForever:create(cc.Sequence:create(scale1, sc_back))) + img:runAction(cc.RepeatForever:create(cc.Sequence:create(scale2, sc_back2))) - arr = CCArray:create() - arr:addObject(scale2) - arr:addObject(sc_back2) - - img:runAction(CCRepeatForever:create(CCSequence:create(arr))) - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -241,16 +202,16 @@ end local function TexturePVR2BPP() local ret = createTestLayer("PVR TC 2bpp Test") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_pvrtc2bpp.pvr") + local img = cc.Sprite:create("Images/test_image_pvrtc2bpp.pvr") if img ~= nil then - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) end - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -263,17 +224,17 @@ end -------------------------------------------------------------------- local function TexturePVR() local ret = createTestLayer("PVR TC 4bpp Test #2") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image.pvr") + local img = cc.Sprite:create("Images/test_image.pvr") if img ~= nil then - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) else cclog("This test is not supported.") end - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -287,17 +248,17 @@ end local function TexturePVR4BPP() local ret = createTestLayer("PVR TC 4bpp Test #3") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_pvrtc4bpp.pvr") + local img = cc.Sprite:create("Images/test_image_pvrtc4bpp.pvr") if img ~= nil then - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) else cclog("This test is not supported in cocos2d-mac") end - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -311,12 +272,12 @@ end local function TexturePVRRGBA8888() local ret = createTestLayer("PVR + RGBA 8888 Test") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_rgba8888.pvr") - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + local img = cc.Sprite:create("Images/test_image_rgba8888.pvr") + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -330,16 +291,16 @@ end local function TexturePVRBGRA8888() local ret = createTestLayer("PVR + BGRA 8888 Test") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_bgra8888.pvr") + local img = cc.Sprite:create("Images/test_image_bgra8888.pvr") if img ~= nil then - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) else cclog("BGRA8888 images are not supported") end - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -352,12 +313,12 @@ end -------------------------------------------------------------------- local function TexturePVRRGBA5551() local ret = createTestLayer("PVR + RGBA 5551 Test") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_rgba5551.pvr") - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + local img = cc.Sprite:create("Images/test_image_rgba5551.pvr") + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -370,12 +331,12 @@ end -------------------------------------------------------------------- local function TexturePVRRGBA4444() local ret = createTestLayer("PVR + RGBA 4444 Test") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_rgba4444.pvr") - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + local img = cc.Sprite:create("Images/test_image_rgba4444.pvr") + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -389,12 +350,12 @@ end local function TexturePVRRGBA4444GZ() local ret = createTestLayer("PVR + RGBA 4444 + GZ Test", "This is a gzip PVR image") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_rgba4444.pvr") - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + local img = cc.Sprite:create("Images/test_image_rgba4444.pvr") + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -406,14 +367,14 @@ end -- -------------------------------------------------------------------- local function TexturePVRRGBA4444CCZ() - local ret = createTestLayer("PVR + RGBA 4444 + CCZ Test", + local ret = createTestLayer("PVR + RGBA 4444 + cc.Z Test", "This is a ccz PVR image") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_rgba4444.pvr.ccz") - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + local img = cc.Sprite:create("Images/test_image_rgba4444.pvr.ccz") + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -426,12 +387,12 @@ end -------------------------------------------------------------------- local function TexturePVRRGB565() local ret = createTestLayer("PVR + RGB 565 Test") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_rgb565.pvr") - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + local img = cc.Sprite:create("Images/test_image_rgb565.pvr") + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -440,14 +401,14 @@ end -- http:--www.imgtec.com/powervr/insider/powervr-pvrtextool.asp local function TexturePVRRGB888() local ret = createTestLayer("PVR + RGB 888 Test") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_rgb888.pvr") + local img = cc.Sprite:create("Images/test_image_rgb888.pvr") if img ~= nil then - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) end - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -460,12 +421,12 @@ end -------------------------------------------------------------------- local function TexturePVRA8() local ret = createTestLayer("PVR + A8 Test") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_a8.pvr") - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + local img = cc.Sprite:create("Images/test_image_a8.pvr") + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -478,12 +439,12 @@ end -------------------------------------------------------------------- local function TexturePVRI8() local ret = createTestLayer("PVR + I8 Test") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_i8.pvr") - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + local img = cc.Sprite:create("Images/test_image_i8.pvr") + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -497,61 +458,61 @@ end -------------------------------------------------------------------- local function TexturePVRAI88() local ret = createTestLayer("PVR + AI88 Test") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_ai88.pvr") - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + local img = cc.Sprite:create("Images/test_image_ai88.pvr") + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end -- TexturePVR2BPPv3 local function TexturePVR2BPPv3() local ret = createTestLayer("PVR TC 2bpp Test", "Testing PVR File Format v3") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_pvrtc2bpp_v3.pvr") + local img = cc.Sprite:create("Images/test_image_pvrtc2bpp_v3.pvr") if img ~= nil then - img:setPosition(CCPoint(s.width/2.0, s.height/2.0)) + img:setPosition(cc.p(s.width/2.0, s.height/2.0)) ret:addChild(img) end - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end -- TexturePVRII2BPPv3 local function TexturePVRII2BPPv3() local ret = createTestLayer("PVR TC II 2bpp Test", "Testing PVR File Format v3") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_pvrtcii2bpp_v3.pvr") + local img = cc.Sprite:create("Images/test_image_pvrtcii2bpp_v3.pvr") if img ~= nil then - img:setPosition(CCPoint(s.width/2.0, s.height/2.0)) + img:setPosition(cc.p(s.width/2.0, s.height/2.0)) ret:addChild(img) end - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end -- TexturePVR4BPPv3 local function TexturePVR4BPPv3() local ret = createTestLayer("PVR TC 4bpp Test", "Testing PVR File Format v3") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_pvrtc4bpp_v3.pvr") + local img = cc.Sprite:create("Images/test_image_pvrtc4bpp_v3.pvr") if img ~= nil then - img:setPosition(CCPoint(s.width/2.0, s.height/2.0)) + img:setPosition(cc.p(s.width/2.0, s.height/2.0)) ret:addChild(img) else cclog("This test is not supported") end - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -563,17 +524,17 @@ end local function TexturePVRII4BPPv3() local ret = createTestLayer("PVR TC II 4bpp Test", "Testing PVR File Format v3") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_pvrtcii4bpp_v3.pvr") + local img = cc.Sprite:create("Images/test_image_pvrtcii4bpp_v3.pvr") if img ~= nil then - img:setPosition(CCPoint(s.width/2.0, s.height/2.0)) + img:setPosition(cc.p(s.width/2.0, s.height/2.0)) ret:addChild(img) else cclog("This test is not supported") end - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -581,16 +542,16 @@ end local function TexturePVRRGBA8888v3() local ret = createTestLayer("PVR + RGBA 8888 Test", "Testing PVR File Format v3") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_rgba8888_v3.pvr") + local img = cc.Sprite:create("Images/test_image_rgba8888_v3.pvr") if img ~= nil then - img:setPosition(CCPoint(s.width/2.0, s.height/2.0)) + img:setPosition(cc.p(s.width/2.0, s.height/2.0)) ret:addChild(img) end - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -599,18 +560,18 @@ local function TexturePVRBGRA8888v3() local ret = createTestLayer("PVR + BGRA 8888 Test", "Testing PVR File Format v3") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_bgra8888_v3.pvr") + local img = cc.Sprite:create("Images/test_image_bgra8888_v3.pvr") if img ~= nil then - img:setPosition(CCPoint(s.width/2.0, s.height/2.0)) + img:setPosition(cc.p(s.width/2.0, s.height/2.0)) ret:addChild(img) else cclog("BGRA images are not supported") end - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -618,15 +579,15 @@ end local function TexturePVRRGBA5551v3() local ret = createTestLayer("PVR + RGBA 5551 Test", "Testing PVR File Format v3") - local s = CCDirector:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_rgba5551_v3.pvr") + local s = cc.Director:getInstance():getWinSize() + local img = cc.Sprite:create("Images/test_image_rgba5551_v3.pvr") if img ~= nil then - img:setPosition(CCPoint(s.width/2.0, s.height/2.0)) + img:setPosition(cc.p(s.width/2.0, s.height/2.0)) ret:addChild(img) end - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -634,16 +595,16 @@ end local function TexturePVRRGBA4444v3() local ret = createTestLayer("PVR + RGBA 4444 Test", "Testing PVR File Format v3") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_rgba4444_v3.pvr") + local img = cc.Sprite:create("Images/test_image_rgba4444_v3.pvr") if img ~= nil then - img:setPosition(CCPoint(s.width/2.0, s.height/2.0)) + img:setPosition(cc.p(s.width/2.0, s.height/2.0)) ret:addChild(img) end - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -651,16 +612,16 @@ end local function TexturePVRRGB565v3() local ret = createTestLayer("PVR + RGB 565 Test", "Testing PVR File Format v3") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_rgb565_v3.pvr") + local img = cc.Sprite:create("Images/test_image_rgb565_v3.pvr") if img ~= nil then - img:setPosition(CCPoint(s.width/2.0, s.height/2.0)) + img:setPosition(cc.p(s.width/2.0, s.height/2.0)) ret:addChild(img) end - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -668,16 +629,16 @@ end local function TexturePVRRGB888v3() local ret = createTestLayer("PVR + RGB 888 Test", "Testing PVR File Format v3") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_rgb888_v3.pvr") + local img = cc.Sprite:create("Images/test_image_rgb888_v3.pvr") if img ~= nil then - img:setPosition(CCPoint(s.width/2.0, s.height/2.0)) + img:setPosition(cc.p(s.width/2.0, s.height/2.0)) ret:addChild(img) end - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -685,16 +646,16 @@ end local function TexturePVRA8v3() local ret = createTestLayer("PVR + A8 Test", "Testing PVR File Format v3") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_a8_v3.pvr") + local img = cc.Sprite:create("Images/test_image_a8_v3.pvr") if img ~= nil then - img:setPosition(CCPoint(s.width/2.0, s.height/2.0)) + img:setPosition(cc.p(s.width/2.0, s.height/2.0)) ret:addChild(img) end - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -702,16 +663,16 @@ end local function TexturePVRI8v3() local ret = createTestLayer("PVR + I8 Test", "Testing PVR File Format v3") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_i8_v3.pvr") + local img = cc.Sprite:create("Images/test_image_i8_v3.pvr") if img ~= nil then - img:setPosition(CCPoint(s.width/2.0, s.height/2.0)) + img:setPosition(cc.p(s.width/2.0, s.height/2.0)) ret:addChild(img) end - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -719,16 +680,16 @@ end local function TexturePVRAI88v3() local ret = createTestLayer("PVR + AI88 Test", "Testing PVR File Format v3") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image_ai88_v3.pvr") + local img = cc.Sprite:create("Images/test_image_ai88_v3.pvr") if img ~= nil then - img:setPosition(CCPoint(s.width/2.0, s.height/2.0)) + img:setPosition(cc.p(s.width/2.0, s.height/2.0)) ret:addChild(img) end - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -742,11 +703,11 @@ end local function TexturePVRBadEncoding() local ret = createTestLayer("PVR Unsupported encoding", "You should not see any image") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/test_image-bad_encoding.pvr") + local img = cc.Sprite:create("Images/test_image-bad_encoding.pvr") if img ~= nil then - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) end return ret @@ -760,12 +721,12 @@ end local function TexturePVRNonSquare() local ret = createTestLayer("PVR + Non square texture", "Loading a 128x256 texture") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/grossini_128x256_mipmap.pvr") - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + local img = cc.Sprite:create("Images/grossini_128x256_mipmap.pvr") + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -777,14 +738,14 @@ end local function TexturePVRNPOT4444() local ret = createTestLayer("PVR RGBA4 + NPOT texture", "Loading a 81x121 RGBA4444 texture.") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/grossini_pvr_rgba4444.pvr") + local img = cc.Sprite:create("Images/grossini_pvr_rgba4444.pvr") if img ~= nil then - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) end - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -796,14 +757,14 @@ end local function TexturePVRNPOT8888() local ret = createTestLayer("PVR RGBA8 + NPOT texture", "Loading a 81x121 RGBA8888 texture.") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local img = CCSprite:create("Images/grossini_pvr_rgba8888.pvr") + local img = cc.Sprite:create("Images/grossini_pvr_rgba8888.pvr") if img ~= nil then - img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) + img:setPosition(cc.p( s.width/2.0, s.height/2.0)) ret:addChild(img) end - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -815,15 +776,15 @@ end local function TextureAlias() local ret = createTestLayer("AntiAlias / Alias textures", "Left image is antialiased. Right image is aliases") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() -- - -- Sprite 1: GL_LINEAR + -- Sprite 1: gl.LINEAR -- - -- Default filter is GL_LINEAR + -- Default filter is gl.LINEAR - local sprite = CCSprite:create("Images/grossinis_sister1.png") - sprite:setPosition(CCPoint( s.width/3.0, s.height/2.0)) + local sprite = cc.Sprite:create("Images/grossinis_sister1.png") + sprite:setPosition(cc.p( s.width/3.0, s.height/2.0)) ret:addChild(sprite) -- this is the default filterting @@ -833,25 +794,22 @@ local function TextureAlias() -- Sprite 1: GL_NEAREST -- - local sprite2 = CCSprite:create("Images/grossinis_sister2.png") - sprite2:setPosition(CCPoint( 2*s.width/3.0, s.height/2.0)) + local sprite2 = cc.Sprite:create("Images/grossinis_sister2.png") + sprite2:setPosition(cc.p( 2*s.width/3.0, s.height/2.0)) ret:addChild(sprite2) -- Use Nearest in this one sprite2:getTexture():setAliasTexParameters() -- scale them to show - local sc = CCScaleBy:create(3, 8.0) - local sc_back = tolua.cast(sc:reverse(), "CCScaleBy") - local arr = CCArray:create() - arr:addObject(sc) - arr:addObject(sc_back) - local scaleforever = CCRepeatForever:create(CCSequence:create(arr)) - local scaleToo = tolua.cast(scaleforever:clone(), "CCRepeatForever") + local sc = cc.ScaleBy:create(3, 8.0) + local sc_back = tolua.cast(sc:reverse(), "ScaleBy") + local scaleforever = cc.RepeatForever:create(cc.Sequence:create(sc, sc_back)) + local scaleToo = tolua.cast(scaleforever:clone(), "RepeatForever") sprite2:runAction(scaleforever) sprite:runAction(scaleToo) - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -871,80 +829,76 @@ local function TexturePixelFormat() -- 3- 16-bit RGB5A1 -- 4- 16-bit RGB565 - local label = tolua.cast(ret:getChildByTag(kTagLabel), "CCLabelTTF") - label:setColor(Color3B(16,16,255)) + local label = tolua.cast(ret:getChildByTag(kTagLabel), "LabelTTF") + label:setColor(cc.c3b(16,16,255)) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local background = CCLayerColor:create(Color4B(128,128,128,255), s.width, s.height) + local background = cc.LayerColor:create(cc.c4b(128,128,128,255), s.width, s.height) ret:addChild(background, -1) -- RGBA 8888 image (32-bit) - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888) - local sprite1 = CCSprite:create("Images/test-rgba1.png") - sprite1:setPosition(CCPoint(1*s.width/7, s.height/2+32)) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888) + local sprite1 = cc.Sprite:create("Images/test-rgba1.png") + sprite1:setPosition(cc.p(1*s.width/7, s.height/2+32)) ret:addChild(sprite1, 0) -- remove texture from texture manager - CCTextureCache:getInstance():removeTexture(sprite1:getTexture()) + cc.TextureCache:getInstance():removeTexture(sprite1:getTexture()) -- RGBA 4444 image (16-bit) - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444) - local sprite2 = CCSprite:create("Images/test-rgba1.png") - sprite2:setPosition(CCPoint(2*s.width/7, s.height/2-32)) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444) + local sprite2 = cc.Sprite:create("Images/test-rgba1.png") + sprite2:setPosition(cc.p(2*s.width/7, s.height/2-32)) ret:addChild(sprite2, 0) -- remove texture from texture manager - CCTextureCache:getInstance():removeTexture(sprite2:getTexture()) + cc.TextureCache:getInstance():removeTexture(sprite2:getTexture()) -- RGB5A1 image (16-bit) - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGB5A1) - local sprite3 = CCSprite:create("Images/test-rgba1.png") - sprite3:setPosition(CCPoint(3*s.width/7, s.height/2+32)) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB5_A1) + local sprite3 = cc.Sprite:create("Images/test-rgba1.png") + sprite3:setPosition(cc.p(3*s.width/7, s.height/2+32)) ret:addChild(sprite3, 0) -- remove texture from texture manager - CCTextureCache:getInstance():removeTexture(sprite3:getTexture()) + cc.TextureCache:getInstance():removeTexture(sprite3:getTexture()) -- RGB888 image - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGB888) - local sprite4 = CCSprite:create("Images/test-rgba1.png") - sprite4:setPosition(CCPoint(4*s.width/7, s.height/2-32)) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RG_B888 ) + local sprite4 = cc.Sprite:create("Images/test-rgba1.png") + sprite4:setPosition(cc.p(4*s.width/7, s.height/2-32)) ret:addChild(sprite4, 0) -- remove texture from texture manager - CCTextureCache:getInstance():removeTexture(sprite4:getTexture()) + cc.TextureCache:getInstance():removeTexture(sprite4:getTexture()) -- RGB565 image (16-bit) - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGB565) - local sprite5 = CCSprite:create("Images/test-rgba1.png") - sprite5:setPosition(CCPoint(5*s.width/7, s.height/2+32)) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RG_B565) + local sprite5 = cc.Sprite:create("Images/test-rgba1.png") + sprite5:setPosition(cc.p(5*s.width/7, s.height/2+32)) ret:addChild(sprite5, 0) -- remove texture from texture manager - CCTextureCache:getInstance():removeTexture(sprite5:getTexture()) + cc.TextureCache:getInstance():removeTexture(sprite5:getTexture()) -- A8 image (8-bit) - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_A8) - local sprite6 = CCSprite:create("Images/test-rgba1.png") - sprite6:setPosition(CCPoint(6*s.width/7, s.height/2-32)) + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_A8 ) + local sprite6 = cc.Sprite:create("Images/test-rgba1.png") + sprite6:setPosition(cc.p(6*s.width/7, s.height/2-32)) ret:addChild(sprite6, 0) -- remove texture from texture manager - CCTextureCache:getInstance():removeTexture(sprite6:getTexture()) + cc.TextureCache:getInstance():removeTexture(sprite6:getTexture()) - local fadeout = CCFadeOut:create(2) - local fadein = CCFadeIn:create(2) - local arr = CCArray:create() - arr:addObject(CCDelayTime:create(2)) - arr:addObject(fadeout) - arr:addObject(fadein) - local seq = CCSequence:create(arr) - local seq_4ever = CCRepeatForever:create(seq) - local seq_4ever2 = tolua.cast(seq_4ever:clone(), "CCRepeatForever") - local seq_4ever3 = tolua.cast(seq_4ever:clone(), "CCRepeatForever") - local seq_4ever4 = tolua.cast(seq_4ever:clone(), "CCRepeatForever") - local seq_4ever5 = tolua.cast(seq_4ever:clone(), "CCRepeatForever") + local fadeout = cc.FadeOut:create(2) + local fadein = cc.FadeIn:create(2) + local seq = cc.Sequence:create(cc.DelayTime:create(2), fadeout, fadein) + local seq_4ever = cc.RepeatForever:create(seq) + local seq_4ever2 = tolua.cast(seq_4ever:clone(), "RepeatForever") + local seq_4ever3 = tolua.cast(seq_4ever:clone(), "RepeatForever") + local seq_4ever4 = tolua.cast(seq_4ever:clone(), "RepeatForever") + local seq_4ever5 = tolua.cast(seq_4ever:clone(), "RepeatForever") sprite1:runAction(seq_4ever) sprite2:runAction(seq_4ever2) @@ -953,8 +907,8 @@ local function TexturePixelFormat() sprite5:runAction(seq_4ever5) -- restore default - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_Default) - CCTextureCache:getInstance():dumpCachedTextureInfo() + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_DEFAULT) + cc.TextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -970,33 +924,24 @@ local function TextureBlend() for i=0, 14 do -- BOTTOM sprites have alpha pre-multiplied -- they use by default GL_ONE, GL_ONE_MINUS_SRC_ALPHA - local cloud = CCSprite:create("Images/test_blend.png") + local cloud = cc.Sprite:create("Images/test_blend.png") ret:addChild(cloud, i+1, 100+i) - cloud:setPosition(CCPoint(50+25*i, 80)) - local blendFunc1 = BlendFunc() - blendFunc1.src = GL_ONE - blendFunc1.dst = GL_ONE_MINUS_SRC_ALPHA - cloud:setBlendFunc(blendFunc1) + cloud:setPosition(cc.p(50+25*i, 80)) + cloud:setBlendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA) -- CENTER sprites have also alpha pre-multiplied -- they use by default GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA - cloud = CCSprite:create("Images/test_blend.png") + cloud = cc.Sprite:create("Images/test_blend.png") ret:addChild(cloud, i+1, 200+i) - cloud:setPosition(CCPoint(50+25*i, 160)) - local blendFunc2 = BlendFunc() - blendFunc2.src = GL_ONE_MINUS_DST_COLOR - blendFunc2.dst = GL_ZERO - cloud:setBlendFunc(blendFunc2) + cloud:setPosition(cc.p(50+25*i, 160)) + cloud:setBlendFunc(gl.ONE_MINUS_DST_COLOR , gl.ZERO) -- UPPER sprites are using custom blending function -- You can set any blend function to your sprites - cloud = CCSprite:create("Images/test_blend.png") + cloud = cc.Sprite:create("Images/test_blend.png") ret:addChild(cloud, i+1, 200+i) - cloud:setPosition(CCPoint(50+25*i, 320-80)) - local blendFunc3 = BlendFunc() - blendFunc3.src = GL_SRC_ALPHA - blendFunc3.dst = GL_ONE - cloud:setBlendFunc(blendFunc3) -- additive blending + cloud:setPosition(cc.p(50+25*i, 320-80)) + cloud:setBlendFunc(gl.SRC_ALPHA, gl.ONE) -- additive blending end return ret end @@ -1012,37 +957,34 @@ local function TextureAsync() "Textures should load while an animation is being run") local m_nImageOffset = 0 - local size =CCDirector:getInstance():getWinSize() + local size =cc.Director:getInstance():getWinSize() - local label = CCLabelTTF:create("Loading...", "Marker Felt", 32) - label:setPosition(CCPoint( size.width/2, size.height/2)) + local label = cc.LabelTTF:create("Loading...", "Marker Felt", 32) + label:setPosition(cc.p( size.width/2, size.height/2)) ret:addChild(label, 10) - local scale = CCScaleBy:create(0.3, 2) - local scale_back = tolua.cast(scale:reverse(), "CCScaleBy") - local arr = CCArray:create() - arr:addObject(scale) - arr:addObject(scale_back) - local seq = CCSequence:create(arr) - label:runAction(CCRepeatForever:create(seq)) + local scale = cc.ScaleBy:create(0.3, 2) + local scale_back = tolua.cast(scale:reverse(), "ScaleBy") + local seq = cc.Sequence:create(scale, scale_back) + label:runAction(cc.RepeatForever:create(seq)) local function imageLoaded(pObj) - local tex = tolua.cast(pObj, "CCTexture2D") - local director = CCDirector:getInstance() + local tex = tolua.cast(pObj, "Texture2D") + local director = cc.Director:getInstance() - --CCASSERT( [NSThread currentThread] == [director runningThread], @"FAIL. Callback should be on cocos2d thread") + --cc.ASSERT( [NSThread currentThread] == [director runningThread], @"FAIL. Callback should be on cocos2d thread") -- IMPORTANT: The order on the callback is not guaranteed. Don't depend on the callback -- This test just creates a sprite based on the Texture - local sprite = CCSprite:createWithTexture(tex) - sprite:setAnchorPoint(CCPoint(0,0)) + local sprite = cc.Sprite:createWithTexture(tex) + sprite:setAnchorPoint(cc.p(0,0)) ret:addChild(sprite, -1) local size = director:getWinSize() local i = m_nImageOffset * 32 - sprite:setPosition(CCPoint( i % size.width, (i / size.width) * 32 )) + sprite:setPosition(cc.p( i % size.width, (i / size.width) * 32 )) m_nImageOffset = m_nImageOffset + 1 cclog("Image loaded:...")-- %p", tex) @@ -1055,16 +997,16 @@ local function TextureAsync() for j=0, 7 do local szSpriteName = string.format( "Images/sprites_test/sprite-%d-%d.png", i, j) - CCTextureCache:getInstance():addImageAsync( + cc.TextureCache:getInstance():addImageAsync( szSpriteName, imageLoaded) end end - CCTextureCache:getInstance():addImageAsync("Images/background1.jpg", imageLoaded) - CCTextureCache:getInstance():addImageAsync("Images/background2.jpg", imageLoaded) - CCTextureCache:getInstance():addImageAsync("Images/background.png", imageLoaded) - CCTextureCache:getInstance():addImageAsync("Images/atlastest.png", imageLoaded) - CCTextureCache:getInstance():addImageAsync("Images/grossini_dance_atlas.png",imageLoaded) + cc.TextureCache:getInstance():addImageAsync("Images/background1.jpg", imageLoaded) + cc.TextureCache:getInstance():addImageAsync("Images/background2.jpg", imageLoaded) + cc.TextureCache:getInstance():addImageAsync("Images/background.png", imageLoaded) + cc.TextureCache:getInstance():addImageAsync("Images/atlastest.png", imageLoaded) + cc.TextureCache:getInstance():addImageAsync("Images/grossini_dance_atlas.png",imageLoaded) end local schedulerEntry = nil @@ -1073,7 +1015,7 @@ local function TextureAsync() schedulerEntry = scheduler:scheduleScriptFunc(loadImages, 1.0, false) elseif event == "exit" then scheduler:unscheduleScriptEntry(schedulerEntry) - CCTextureCache:getInstance():removeAllTextures() + cc.TextureCache:getInstance():removeAllTextures() end end @@ -1089,33 +1031,24 @@ end local function TextureGlClamp() local ret = createTestLayer("Texture GL_CLAMP") - local size = CCDirector:getInstance():getWinSize() + local size = cc.Director:getInstance():getWinSize() -- The .png image MUST be power of 2 in order to create a continue effect. -- eg: 32x64, 512x128, 256x1024, 64x64, etc.. - local sprite = CCSprite:create("Images/pattern1.png", CCRect(0,0,512,256)) + local sprite = cc.Sprite:create("Images/pattern1.png", cc.rect(0,0,512,256)) ret:addChild(sprite, -1, kTagSprite1) - sprite:setPosition(CCPoint(size.width/2,size.height/2)) - local texParams = CCTexture:TexParams() - texParams.minFilter = GL_LINEAR - texParams.magFilter = GL_LINEAR - texParams.wrapS = GL_CLAMP_TO_EDGE - texParams.wrapT = GL_CLAMP_TO_EDGE + sprite:setPosition(cc.p(size.width/2,size.height/2)) + sprite:getTexture():setTexParameters(gl.LINEAR, gl.LINEAR, gl.CLAMP_TO_EDGE, gl.CLAMP_TO_EDGE) - sprite:getTexture():setTexParameters(texParams) - - local rotate = CCRotateBy:create(4, 360) + local rotate = cc.RotateBy:create(4, 360) sprite:runAction(rotate) - local scale = CCScaleBy:create(2, 0.04) - local scaleBack = tolua.cast(scale:reverse(), "CCScaleBy") - local arr = CCArray:create() - arr:addObject(scale) - arr:addObject(scaleBack) - local seq = CCSequence:create(arr) + local scale = cc.ScaleBy:create(2, 0.04) + local scaleBack = tolua.cast(scale:reverse(), "ScaleBy") + local seq = cc.Sequence:create(scale, scaleBack) sprite:runAction(seq) local function onNodeEvent(event) if event == "exit" then - CCTextureCache:getInstance():removeUnusedTextures() + cc.TextureCache:getInstance():removeUnusedTextures() end end @@ -1130,36 +1063,26 @@ end -- -------------------------------------------------------------------- local function TextureGlRepeat() - local ret = createTestLayer("Texture GL_REPEAT") + local ret = createTestLayer("Texture gl.REPEAT") - local size = CCDirector:getInstance():getWinSize() + local size = cc.Director:getInstance():getWinSize() -- The .png image MUST be power of 2 in order to create a continue effect. -- eg: 32x64, 512x128, 256x1024, 64x64, etc.. - local sprite = CCSprite:create("Images/pattern1.png", CCRect(0, 0, 4096, 4096)) + local sprite = cc.Sprite:create("Images/pattern1.png", cc.rect(0, 0, 4096, 4096)) ret:addChild(sprite, -1, kTagSprite1) - sprite:setPosition(CCPoint(size.width/2,size.height/2)) - local texParams = CCTexture:TexParams() + sprite:setPosition(cc.p(size.width/2,size.height/2)) + sprite:getTexture():setTexParameters(gl.LINEAR, gl.LINEAR, gl.REPEAT, gl.REPEAT) - texParams.minFilter = GL_LINEAR - texParams.magFilter = GL_LINEAR - texParams.wrapS = GL_REPEAT - texParams.wrapT = GL_REPEAT - - sprite:getTexture():setTexParameters(texParams) - - local rotate = CCRotateBy:create(4, 360) + local rotate = cc.RotateBy:create(4, 360) sprite:runAction(rotate) - local scale = CCScaleBy:create(2, 0.04) - local scaleBack = tolua.cast(scale:reverse(), "CCScaleBy") - local arr = CCArray:create() - arr:addObject(scale) - arr:addObject(scaleBack) - local seq = CCSequence:create(arr) + local scale = cc.ScaleBy:create(2, 0.04) + local scaleBack = tolua.cast(scale:reverse(), "ScaleBy") + local seq = cc.Sequence:create(scale, scaleBack) sprite:runAction(seq) local function onNodeEvent(event) if event == "exit" then - CCTextureCache:getInstance():removeUnusedTextures() + cc.TextureCache:getInstance():removeUnusedTextures() end end @@ -1179,28 +1102,28 @@ local function TextureSizeTest() local sprite = nil cclog("Loading 512x512 image...") - sprite = CCSprite:create("Images/texture512x512.png") + sprite = cc.Sprite:create("Images/texture512x512.png") if sprite ~= nil then cclog("OK\n") else cclog("Error\n") cclog("Loading 1024x1024 image...") - sprite = CCSprite:create("Images/texture1024x1024.png") + sprite = cc.Sprite:create("Images/texture1024x1024.png") if sprite ~= nil then cclog("OK\n") else cclog("Error\n") -- @todo -- cclog("Loading 2048x2048 image...") - -- sprite = CCSprite:create("Images/texture2048x2048.png") + -- sprite = cc.Sprite:create("Images/texture2048x2048.png") -- if( sprite ) -- cclog("OK\n") -- else -- cclog("Error\n") -- -- cclog("Loading 4096x4096 image...") - -- sprite = CCSprite:create("Images/texture4096x4096.png") + -- sprite = cc.Sprite:create("Images/texture4096x4096.png") -- if( sprite ) -- cclog("OK\n") -- else @@ -1215,38 +1138,38 @@ end -- -------------------------------------------------------------------- local function TextureCache1() - local ret = createTestLayer("CCTextureCache: remove", + local ret = createTestLayer("TextureCache: remove", "4 images should appear: alias, antialias, alias, antilias") - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() local sprite = nil - sprite = CCSprite:create("Images/grossinis_sister1.png") - sprite:setPosition(CCPoint(s.width/5*1, s.height/2)) + sprite = cc.Sprite:create("Images/grossinis_sister1.png") + sprite:setPosition(cc.p(s.width/5*1, s.height/2)) sprite:getTexture():setAliasTexParameters() sprite:setScale(2) ret:addChild(sprite) - CCTextureCache:getInstance():removeTexture(sprite:getTexture()) + cc.TextureCache:getInstance():removeTexture(sprite:getTexture()) - sprite = CCSprite:create("Images/grossinis_sister1.png") - sprite:setPosition(CCPoint(s.width/5*2, s.height/2)) + sprite = cc.Sprite:create("Images/grossinis_sister1.png") + sprite:setPosition(cc.p(s.width/5*2, s.height/2)) sprite:getTexture():setAntiAliasTexParameters() sprite:setScale(2) ret:addChild(sprite) -- 2nd set of sprites - sprite = CCSprite:create("Images/grossinis_sister2.png") - sprite:setPosition(CCPoint(s.width/5*3, s.height/2)) + sprite = cc.Sprite:create("Images/grossinis_sister2.png") + sprite:setPosition(cc.p(s.width/5*3, s.height/2)) sprite:getTexture():setAliasTexParameters() sprite:setScale(2) ret:addChild(sprite) - CCTextureCache:getInstance():removeTextureForKey("Images/grossinis_sister2.png") + cc.TextureCache:getInstance():removeTextureForKey("Images/grossinis_sister2.png") - sprite = CCSprite:create("Images/grossinis_sister2.png") - sprite:setPosition(CCPoint(s.width/5*4, s.height/2)) + sprite = cc.Sprite:create("Images/grossinis_sister2.png") + sprite:setPosition(cc.p(s.width/5*4, s.height/2)) sprite:getTexture():setAntiAliasTexParameters() sprite:setScale(2) ret:addChild(sprite) @@ -1257,20 +1180,20 @@ end local function TextureDrawAtPoint() local m_pTex1 = nil local m_pTex2F = nil - local ret = createTestLayer("CCTexture2D: drawAtPoint", + local ret = createTestLayer("Texture2D: drawAtPoint", "draws 2 textures using drawAtPoint") local function draw() -- TextureDemo:draw() - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - m_pTex1:drawAtPoint(CCPoint(s.width/2-50, s.height/2 - 50)) - m_pTex2F:drawAtPoint(CCPoint(s.width/2+50, s.height/2 - 50)) + m_pTex1:drawAtPoint(cc.p(s.width/2-50, s.height/2 - 50)) + m_pTex2F:drawAtPoint(cc.p(s.width/2+50, s.height/2 - 50)) end - m_pTex1 = CCTextureCache:getInstance():addImage("Images/grossinis_sister1.png") - m_pTex2F = CCTextureCache:getInstance():addImage("Images/grossinis_sister2.png") + m_pTex1 = cc.TextureCache:getInstance():addImage("Images/grossinis_sister1.png") + m_pTex2F = cc.TextureCache:getInstance():addImage("Images/grossinis_sister2.png") m_pTex1:retain() m_pTex2F:retain() @@ -1289,22 +1212,22 @@ end -- TextureDrawInRect local function TextureDrawInRect() - local ret = createTestLayer("CCTexture2D: drawInRect", + local ret = createTestLayer("Texture2D: drawInRect", "draws 2 textures using drawInRect") local function draw() -- TextureDemo:draw() - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - local rect1 = CCRect( s.width/2 - 80, 20, m_pTex1:getContentSize().width * 0.5, m_pTex1:getContentSize().height *2 ) - local rect2 = CCRect( s.width/2 + 80, s.height/2, m_pTex1:getContentSize().width * 2, m_pTex1:getContentSize().height * 0.5 ) + local rect1 = cc.rect( s.width/2 - 80, 20, m_pTex1:getContentSize().width * 0.5, m_pTex1:getContentSize().height *2 ) + local rect2 = cc.rect( s.width/2 + 80, s.height/2, m_pTex1:getContentSize().width * 2, m_pTex1:getContentSize().height * 0.5 ) m_pTex1:drawInRect(rect1) m_pTex2F:drawInRect(rect2) end - local m_pTex1 = CCTextureCache:getInstance():addImage("Images/grossinis_sister1.png") - local m_pTex2F = CCTextureCache:getInstance():addImage("Images/grossinis_sister2.png") + local m_pTex1 = cc.TextureCache:getInstance():addImage("Images/grossinis_sister1.png") + local m_pTex2F = cc.TextureCache:getInstance():addImage("Images/grossinis_sister2.png") m_pTex1:retain() m_pTex2F:retain() @@ -1330,14 +1253,14 @@ local function TextureMemoryAlloc() "Testing Texture Memory allocation. Use Instruments + VM Tracker") local m_pBackground = nil - CCMenuItemFont:setFontSize(24) + cc.MenuItemFont:setFontSize(24) local function updateImage(tag,sender) if m_pBackground ~= nil then cclog("updateImage"..tag) - m_pBackground:removeFromParentAndCleanup(true) + m_pBackground:removeFromParent(true) end - CCTextureCache:getInstance():removeUnusedTextures() + cc.TextureCache:getInstance():removeUnusedTextures() local file = "" if tag == 0 then @@ -1352,47 +1275,41 @@ local function TextureMemoryAlloc() file = "Images/test_1021x1024_a8.pvr" end - m_pBackground = CCSprite:create(file) + m_pBackground = cc.Sprite:create(file) ret:addChild(m_pBackground, -10) m_pBackground:setVisible(false) - local s = CCDirector:getInstance():getWinSize() - m_pBackground:setPosition(CCPoint(s.width/2, s.height/2)) + local s = cc.Director:getInstance():getWinSize() + m_pBackground:setPosition(cc.p(s.width/2, s.height/2)) end - local item1 = CCMenuItemFont:create("PNG") + local item1 = cc.MenuItemFont:create("PNG") item1:registerScriptTapHandler(updateImage) item1:setTag(0) - local item2 = CCMenuItemFont:create("RGBA8") + local item2 = cc.MenuItemFont:create("RGBA8") item2:registerScriptTapHandler(updateImage) item2:setTag(1) - local item3 = CCMenuItemFont:create("RGB8") + local item3 = cc.MenuItemFont:create("RGB8") item3:registerScriptTapHandler(updateImage) item3:setTag(2) - local item4 = CCMenuItemFont:create("RGBA4") + local item4 = cc.MenuItemFont:create("RGBA4") item4:registerScriptTapHandler(updateImage) item4:setTag(3) - local item5 = CCMenuItemFont:create("A8") + local item5 = cc.MenuItemFont:create("A8") item5:registerScriptTapHandler(updateImage) item5:setTag(4) - local arr = CCArray:create() - arr:addObject(item1) - arr:addObject(item2) - arr:addObject(item3) - arr:addObject(item4) - arr:addObject(item5) - local menu = CCMenu:createWithArray(arr) + local menu = cc.Menu:create(item1, item2, item3, item4, item5) menu:alignItemsHorizontally() ret:addChild(menu) - local warmup = CCMenuItemFont:create("warm up texture") + local warmup = cc.MenuItemFont:create("warm up texture") local function changeBackgroundVisible(tag, sender) if m_pBackground ~= nil then @@ -1402,14 +1319,14 @@ local function TextureMemoryAlloc() end warmup:registerScriptTapHandler(changeBackgroundVisible) - local menu2 = CCMenu:createWithItem(warmup) + local menu2 = cc.Menu:create(warmup) menu2:alignItemsHorizontally() ret:addChild(menu2) - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() - menu2:setPosition(CCPoint(s.width/2, s.height/4)) + menu2:setPosition(cc.p(s.width/2, s.height/4)) return ret end @@ -1419,42 +1336,38 @@ local function TexturePVRv3Premult() "All images should look exactly the same") local function transformSprite(sprite) - local fade = CCFadeOut:create(2) - local dl = CCDelayTime:create(2) - local fadein = tolua.cast(fade:reverse(), "CCFadeOut") - local arr = CCArray:create() - arr:addObject(fade) - arr:addObject(fadein) - arr:addObject(dl) - local seq = CCSequence:create(arr) - local repeatAction = CCRepeatForever:create(seq) + local fade = cc.FadeOut:create(2) + local dl = cc.DelayTime:create(2) + local fadein = tolua.cast(fade:reverse(), "FadeOut") + local seq = cc.Sequence:create(fade, fadein, dl) + local repeatAction = cc.RepeatForever:create(seq) sprite:runAction(repeatAction) end - local size = CCDirector:getInstance():getWinSize() + local size = cc.Director:getInstance():getWinSize() - local background = CCLayerColor:create(Color4B(128,128,128,255), size.width, size.height) + local background = cc.LayerColor:create(cc.c4b(128,128,128,255), size.width, size.height) ret:addChild(background, -1) -- PVR premultiplied - local pvr1 = CCSprite:create("Images/grossinis_sister1-testalpha_premult.pvr") + local pvr1 = cc.Sprite:create("Images/grossinis_sister1-testalpha_premult.pvr") ret:addChild(pvr1, 0) - pvr1:setPosition(CCPoint(size.width/4*1, size.height/2)) + pvr1:setPosition(cc.p(size.width/4*1, size.height/2)) transformSprite(pvr1) -- PVR non-premultiplied - local pvr2 = CCSprite:create("Images/grossinis_sister1-testalpha_nopremult.pvr") + local pvr2 = cc.Sprite:create("Images/grossinis_sister1-testalpha_nopremult.pvr") ret:addChild(pvr2, 0) - pvr2:setPosition(CCPoint(size.width/4*2, size.height/2)) + pvr2:setPosition(cc.p(size.width/4*2, size.height/2)) transformSprite(pvr2) -- PNG - CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888) - CCTextureCache:getInstance():removeTextureForKey("Images/grossinis_sister1-testalpha.png") - local png = CCSprite:create("Images/grossinis_sister1-testalpha.png") + cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888) + cc.TextureCache:getInstance():removeTextureForKey("Images/grossinis_sister1-testalpha.png") + local png = cc.Sprite:create("Images/grossinis_sister1-testalpha.png") ret:addChild(png, 0) - png:setPosition(CCPoint(size.width/4*3, size.height/2)) + png:setPosition(cc.p(size.width/4*3, size.height/2)) transformSprite(png) return ret end @@ -1463,7 +1376,7 @@ end function Texture2dTestMain() cclog("Texture2dTestMain") Helper.index = 1 - local scene = CCScene:create() + local scene = cc.Scene:create() Helper.createFunctionTable = { TextureMemoryAlloc, TextureAlias, diff --git a/samples/Lua/TestLua/Resources/luaScript/TileMapTest/TileMapTest.lua b/samples/Lua/TestLua/Resources/luaScript/TileMapTest/TileMapTest.lua index 2440455ac6..b80891af25 100644 --- a/samples/Lua/TestLua/Resources/luaScript/TileMapTest/TileMapTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/TileMapTest/TileMapTest.lua @@ -1,11 +1,11 @@ -local size = CCDirector:getInstance():getWinSize() -local scheduler = CCDirector:getInstance():getScheduler() +local size = cc.Director:getInstance():getWinSize() +local scheduler = cc.Director:getInstance():getScheduler() local kTagTileMap = 1 local function createTileDemoLayer(title, subtitle) - local layer = CCLayer:create() + local layer = cc.Layer:create() Helper.initWithLayer(layer) local titleStr = title == nil and "No title" or title local subTitleStr = subtitle == nil and "drag the screen" or subtitle @@ -25,7 +25,7 @@ local function createTileDemoLayer(title, subtitle) local diffX = x - prev.x local diffY = y - prev.y - node:setPosition( CCPoint.__add(CCPoint(newX, newY), CCPoint(diffX, diffY)) ) + node:setPosition( cc.pAdd(cc.p(newX, newY), cc.p(diffX, diffY)) ) prev.x = x prev.y = y end @@ -42,7 +42,7 @@ end local function TileMapTest() local layer = createTileDemoLayer("TileMapAtlas") - local map = CCTileMapAtlas:create(s_TilesPng, s_LevelMapTga, 16, 16) + local map = cc.TileMapAtlas:create(s_TilesPng, s_LevelMapTga, 16, 16) -- Convert it to "alias" (GL_LINEAR filtering) map:getTexture():setAntiAliasTexParameters() @@ -55,17 +55,14 @@ local function TileMapTest() layer:addChild(map, 0, kTagTileMap) - map:setAnchorPoint( CCPoint(0, 0.5) ) + map:setAnchorPoint( cc.p(0, 0.5) ) - local scale = CCScaleBy:create(4, 0.8) + local scale = cc.ScaleBy:create(4, 0.8) local scaleBack = scale:reverse() - local action_arr = CCArray:create() - action_arr:addObject(scale) - action_arr:addObject(scaleBack) - local seq = CCSequence:create(action_arr) + local seq = cc.Sequence:create(scale, scaleBack) - map:runAction(CCRepeatForever:create(seq)) + map:runAction(cc.RepeatForever:create(seq)) return layer end @@ -77,7 +74,7 @@ end -------------------------------------------------------------------- local function TileMapEditTest() local layer = createTileDemoLayer("Editable TileMapAtlas") - local map = CCTileMapAtlas:create(s_TilesPng, s_LevelMapTga, 16, 16) + local map = cc.TileMapAtlas:create(s_TilesPng, s_LevelMapTga, 16, 16) -- Create an Aliased Atlas map:getTexture():setAliasTexParameters() @@ -93,7 +90,7 @@ local function TileMapEditTest() -- The only limitation is that you cannot change an empty, or assign an empty tile to a tile -- The value 0 not rendered so don't assign or change a tile with value 0 - local tilemap = tolua.cast(layer:getChildByTag(kTagTileMap), "CCTileMapAtlas") + local tilemap = tolua.cast(layer:getChildByTag(kTagTileMap), "TileMapAtlas") -- -- For example you can iterate over all the tiles @@ -109,7 +106,7 @@ local function TileMapEditTest() -- end -- NEW since v0.7 - local c = tilemap:getTileAt(CCPoint(13,21)) + local c = tilemap:getTileAt(cc.p(13,21)) c.r = c.r + 1 c.r = c.r % 50 @@ -117,7 +114,7 @@ local function TileMapEditTest() c.r=1 end -- NEW since v0.7 - tilemap:setTile(c, CCPoint(13,21) ) + tilemap:setTile(c, cc.p(13,21) ) end local schedulerEntry = nil @@ -133,8 +130,8 @@ local function TileMapEditTest() layer:addChild(map, 0, kTagTileMap) - map:setAnchorPoint( CCPoint(0, 0) ) - map:setPosition( CCPoint(-20,-200) ) + map:setAnchorPoint( cc.p(0, 0) ) + map:setPosition( cc.p(-20,-200) ) return layer end @@ -152,10 +149,10 @@ local function TMXOrthoTest() -- -- it should not flicker. No artifacts should appear -- - --local color = CCLayerColor:create( Color4B(64,64,64,255) ) + --local color = cc.LayerColor:create( cc.c4b(64,64,64,255) ) --addChild(color, -1) - local map = CCTMXTiledMap:create("TileMaps/orthogonal-test2.tmx") + local map = cc.TMXTiledMap:create("TileMaps/orthogonal-test2.tmx") layer:addChild(map, 0, kTagTileMap) local s = map:getContentSize() @@ -165,10 +162,10 @@ local function TMXOrthoTest() local child = nil local pObject = nil local i = 0 - local len = pChildrenArray:count() + local len = table.getn(pChildrenArray) for i = 0, len-1, 1 do - pObject = pChildrenArray:objectAtIndex(i) - child = tolua.cast(pObject, "CCSpriteBatchNode") + pObject = pChildrenArray[i + 1] + child = tolua.cast(pObject, "SpriteBatchNode") if child == nil then break @@ -180,18 +177,18 @@ local function TMXOrthoTest() local x = 0 local y = 0 local z = 0 - x, y, z = map:getCamera():getEyeXYZ(x, y, z) + x, y, z = map:getCamera():getEye() cclog("before eye x="..x..",y="..y..",z="..z) - map:getCamera():setEyeXYZ(x-200, y, z+300) - x, y, z = map:getCamera():getEyeXYZ(x, y, z) + map:getCamera():setEye(x-200, y, z+300) + x, y, z = map:getCamera():getEye() cclog("after eye x="..x..",y="..y..",z="..z) local function onNodeEvent(event) if event == "enter" then - CCDirector:getInstance():setProjection(kCCDirectorProjection3D) + cc.Director:getInstance():setProjection(cc.DIRECTOR_PROJECTION3_D ) elseif event == "exit" then - CCDirector:getInstance():setProjection(kCCDirectorProjection2D) + cc.Director:getInstance():setProjection(cc.DIRECTOR_PROJECTION2_D ) end end @@ -209,7 +206,7 @@ end local function TMXOrthoTest2() local layer = createTileDemoLayer("TMX Ortho test2") - local map = CCTMXTiledMap:create("TileMaps/orthogonal-test1.tmx") + local map = cc.TMXTiledMap:create("TileMaps/orthogonal-test1.tmx") layer:addChild(map, 0, kTagTileMap) local s = map:getContentSize() @@ -219,10 +216,10 @@ local function TMXOrthoTest2() local child = nil local pObject = nil local i = 0 - local len = pChildrenArray:count() + local len = table.getn(pChildrenArray) for i = 0, len-1, 1 do - child = tolua.cast(pChildrenArray:objectAtIndex(i), "CCSpriteBatchNode") + child = tolua.cast(pChildrenArray[i + 1], "SpriteBatchNode") if child == nil then break @@ -230,7 +227,7 @@ local function TMXOrthoTest2() child:getTexture():setAntiAliasTexParameters() end - map:runAction( CCScaleBy:create(2, 0.5) ) + map:runAction( cc.ScaleBy:create(2, 0.5) ) return layer end @@ -241,7 +238,7 @@ end -------------------------------------------------------------------- local function TMXOrthoTest3() local layer = createTileDemoLayer("TMX anchorPoint test") - local map = CCTMXTiledMap:create("TileMaps/orthogonal-test3.tmx") + local map = cc.TMXTiledMap:create("TileMaps/orthogonal-test3.tmx") layer:addChild(map, 0, kTagTileMap) local s = map:getContentSize() @@ -251,10 +248,10 @@ local function TMXOrthoTest3() local child = nil local pObject = nil local i = 0 - local len = pChildrenArray:count() + local len = table.getn(pChildrenArray) for i = 0, len-1, 1 do - child = tolua.cast(pChildrenArray:objectAtIndex(i), "CCSpriteBatchNode") + child = tolua.cast(pChildrenArray[i + 1], "SpriteBatchNode") if child == nil then break @@ -263,7 +260,7 @@ local function TMXOrthoTest3() end map:setScale(0.2) - map:setAnchorPoint( CCPoint(0.5, 0.5) ) + map:setAnchorPoint( cc.p(0.5, 0.5) ) return layer end @@ -275,7 +272,7 @@ end -------------------------------------------------------------------- local function TMXOrthoTest4() local ret = createTileDemoLayer("TMX width/height test") - local map = CCTMXTiledMap:create("TileMaps/orthogonal-test4.tmx") + local map = cc.TMXTiledMap:create("TileMaps/orthogonal-test4.tmx") ret:addChild(map, 0, kTagTileMap) local s1 = map:getContentSize() @@ -285,10 +282,10 @@ local function TMXOrthoTest4() local child = nil local pObject = nil local i = 0 - local len = pChildrenArray:count() + local len = table.getn(pChildrenArray) for i = 0, len-1, 1 do - child = tolua.cast(pChildrenArray:objectAtIndex(i), "CCSpriteBatchNode") + child = tolua.cast(pChildrenArray[i + 1], "SpriteBatchNode") if child == nil then break @@ -296,18 +293,18 @@ local function TMXOrthoTest4() child:getTexture():setAntiAliasTexParameters() end - map:setAnchorPoint(CCPoint(0, 0)) + map:setAnchorPoint(cc.p(0, 0)) local layer = map:getLayer("Layer 0") local s = layer:getLayerSize() - local sprite = layer:getTileAt(CCPoint(0,0)) + local sprite = layer:getTileAt(cc.p(0,0)) sprite:setScale(2) - sprite = layer:getTileAt(CCPoint(s.width-1,0)) + sprite = layer:getTileAt(cc.p(s.width-1,0)) sprite:setScale(2) - sprite = layer:getTileAt(CCPoint(0,s.height-1)) + sprite = layer:getTileAt(cc.p(0,s.height-1)) sprite:setScale(2) - sprite = layer:getTileAt(CCPoint(s.width-1,s.height-1)) + sprite = layer:getTileAt(cc.p(s.width-1,s.height-1)) sprite:setScale(2) local schedulerEntry = nil @@ -315,11 +312,11 @@ local function TMXOrthoTest4() local function removeSprite(dt) scheduler:unscheduleScriptEntry(schedulerEntry) schedulerEntry = nil - local map = tolua.cast(ret:getChildByTag(kTagTileMap), "CCTMXTiledMap") + local map = tolua.cast(ret:getChildByTag(kTagTileMap), "TMXTiledMap") local layer0 = map:getLayer("Layer 0") local s = layer0:getLayerSize() - local sprite = layer0:getTileAt( CCPoint(s.width-1,0) ) + local sprite = layer0:getTileAt( cc.p(s.width-1,0) ) layer0:removeChild(sprite, true) end @@ -349,7 +346,7 @@ local function TMXReadWriteTest() local ret = createTileDemoLayer("TMX Read/Write test") local m_gid = 0 local m_gid2 = 0 - local map = CCTMXTiledMap:create("TileMaps/orthogonal-test2.tmx") + local map = cc.TMXTiledMap:create("TileMaps/orthogonal-test2.tmx") ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() @@ -361,25 +358,25 @@ local function TMXReadWriteTest() map:setScale( 1 ) - local tile0 = layer:getTileAt(CCPoint(1,63)) - local tile1 = layer:getTileAt(CCPoint(2,63)) - local tile2 = layer:getTileAt(CCPoint(3,62))--CCPoint(1,62)) - local tile3 = layer:getTileAt(CCPoint(2,62)) - tile0:setAnchorPoint( CCPoint(0.5, 0.5) ) - tile1:setAnchorPoint( CCPoint(0.5, 0.5) ) - tile2:setAnchorPoint( CCPoint(0.5, 0.5) ) - tile3:setAnchorPoint( CCPoint(0.5, 0.5) ) + local tile0 = layer:getTileAt(cc.p(1,63)) + local tile1 = layer:getTileAt(cc.p(2,63)) + local tile2 = layer:getTileAt(cc.p(3,62))--cc.p(1,62)) + local tile3 = layer:getTileAt(cc.p(2,62)) + tile0:setAnchorPoint( cc.p(0.5, 0.5) ) + tile1:setAnchorPoint( cc.p(0.5, 0.5) ) + tile2:setAnchorPoint( cc.p(0.5, 0.5) ) + tile3:setAnchorPoint( cc.p(0.5, 0.5) ) - local move = CCMoveBy:create(0.5, CCPoint(0,160)) - local rotate = CCRotateBy:create(2, 360) - local scale = CCScaleBy:create(2, 5) - local opacity = CCFadeOut:create(2) - local fadein = CCFadeIn:create(2) - local scaleback = CCScaleTo:create(1, 1) + local move = cc.MoveBy:create(0.5, cc.p(0,160)) + local rotate = cc.RotateBy:create(2, 360) + local scale = cc.ScaleBy:create(2, 5) + local opacity = cc.FadeOut:create(2) + local fadein = cc.FadeIn:create(2) + local scaleback = cc.ScaleTo:create(1, 1) local function removeSprite(sender) --------cclog("removing tile: %x", sender) - local node = tolua.cast(sender, "CCNode") + local node = tolua.cast(sender, "Node") if nil == node then print("Errro node is nil") end @@ -391,19 +388,11 @@ local function TMXReadWriteTest() ----------cclog("atlas quantity: %d", p:textureAtlas():totalQuads()) end - local finish = CCCallFunc:create(removeSprite) - local arr = CCArray:create() - arr:addObject(move) - arr:addObject(rotate) - arr:addObject(scale) - arr:addObject(opacity) - arr:addObject(fadein) - arr:addObject(scaleback) - arr:addObject(finish) - local seq0 = CCSequence:create(arr) - local seq1 = tolua.cast(seq0:clone(), "CCAction") - local seq2 = tolua.cast(seq0:clone(), "CCAction") - local seq3 = tolua.cast(seq0:clone(), "CCAction") + local finish = cc.CallFunc:create(removeSprite) + local seq0 = cc.Sequence:create(move, rotate, scale, opacity, fadein, scaleback, finish) + local seq1 = tolua.cast(seq0:clone(), "Action") + local seq2 = tolua.cast(seq0:clone(), "Action") + local seq3 = tolua.cast(seq0:clone(), "Action") tile0:runAction(seq0) tile1:runAction(seq1) @@ -411,7 +400,7 @@ local function TMXReadWriteTest() tile3:runAction(seq3) - m_gid = layer:getTileGIDAt(CCPoint(0,63)) + m_gid = layer:getTileGIDAt(cc.p(0,63)) --------cclog("Tile GID at:(0,63) is: %d", m_gid) local updateColScheduler = nil local repainWithGIDScheduler = nil @@ -419,8 +408,8 @@ local function TMXReadWriteTest() local function updateCol(dt) - local map = tolua.cast(ret:getChildByTag(kTagTileMap), "CCTMXTiledMap") - local layer = tolua.cast(map:getChildByTag(0), "CCTMXLayer") + local map = tolua.cast(ret:getChildByTag(kTagTileMap), "TMXTiledMap") + local layer = tolua.cast(map:getChildByTag(0), "TMXLayer") --------cclog("++++atlas quantity: %d", layer:textureAtlas():getTotalQuads()) --------cclog("++++children: %d", layer:getChildren():count() ) @@ -429,7 +418,7 @@ local function TMXReadWriteTest() local s = layer:getLayerSize() local y = 0 for y=0, s.height-1, 1 do - layer:setTileGID(m_gid2, CCPoint(3, y)) + layer:setTileGID(m_gid2, cc.p(3, y)) end m_gid2 = (m_gid2 + 1) % 80 @@ -437,27 +426,27 @@ local function TMXReadWriteTest() local function repaintWithGID(dt) -- unschedule:_cmd) - local map = tolua.cast(ret:getChildByTag(kTagTileMap), "CCTMXTiledMap") - local layer = tolua.cast(map:getChildByTag(0), "CCTMXLayer") + local map = tolua.cast(ret:getChildByTag(kTagTileMap), "TMXTiledMap") + local layer = tolua.cast(map:getChildByTag(0), "TMXLayer") local s = layer:getLayerSize() local x = 0 for x=0, s.width-1, 1 do local y = s.height-1 - local tmpgid = layer:getTileGIDAt( CCPoint(x, y) ) - layer:setTileGID(tmpgid+1, CCPoint(x, y)) + local tmpgid = layer:getTileGIDAt( cc.p(x, y) ) + layer:setTileGID(tmpgid+1, cc.p(x, y)) end end local function removeTiles(dt) scheduler:unscheduleScriptEntry(removeTilesScheduler) removeTilesScheduler = nil - local map = tolua.cast(ret:getChildByTag(kTagTileMap), "CCTMXTiledMap") - local layer = tolua.cast(map:getChildByTag(0), "CCTMXLayer") + local map = tolua.cast(ret:getChildByTag(kTagTileMap), "TMXTiledMap") + local layer = tolua.cast(map:getChildByTag(0), "TMXLayer") local s = layer:getLayerSize() local y = 0 for y=0, s.height-1, 1 do - layer:removeTileAt( CCPoint(5.0, y) ) + layer:removeTileAt( cc.p(5.0, y) ) end end @@ -498,10 +487,10 @@ end -------------------------------------------------------------------- local function TMXHexTest() local ret = createTileDemoLayer("TMX Hex tes") - local color = CCLayerColor:create( Color4B(64,64,64,255) ) + local color = cc.LayerColor:create( cc.c4b(64,64,64,255) ) ret:addChild(color, -1) - local map = CCTMXTiledMap:create("TileMaps/hexa-test.tmx") + local map = cc.TMXTiledMap:create("TileMaps/hexa-test.tmx") ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() @@ -516,16 +505,16 @@ end -------------------------------------------------------------------- local function TMXIsoTest() local ret = createTileDemoLayer("TMX Isometric test 0") - local color = CCLayerColor:create( Color4B(64,64,64,255) ) + local color = cc.LayerColor:create( cc.c4b(64,64,64,255) ) ret:addChild(color, -1) - local map = CCTMXTiledMap:create("TileMaps/iso-test.tmx") + local map = cc.TMXTiledMap:create("TileMaps/iso-test.tmx") ret:addChild(map, 0, kTagTileMap) -- move map to the center of the screen local ms = map:getMapSize() local ts = map:getTileSize() - map:runAction( CCMoveTo:create(1.0, CCPoint( -ms.width * ts.width/2, -ms.height * ts.height/2 )) ) + map:runAction( cc.MoveTo:create(1.0, cc.p( -ms.width * ts.width/2, -ms.height * ts.height/2 )) ) return ret end @@ -536,16 +525,16 @@ end -------------------------------------------------------------------- local function TMXIsoTest1() local ret = createTileDemoLayer("TMX Isometric test + anchorPoint") - local color = CCLayerColor:create( Color4B(64,64,64,255) ) + local color = cc.LayerColor:create( cc.c4b(64,64,64,255) ) ret:addChild(color, -1) - local map = CCTMXTiledMap:create("TileMaps/iso-test1.tmx") + local map = cc.TMXTiledMap:create("TileMaps/iso-test1.tmx") ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() cclog("ContentSize: %f, %f", s.width,s.height) - map:setAnchorPoint(CCPoint(0.5, 0.5)) + map:setAnchorPoint(cc.p(0.5, 0.5)) return ret end @@ -556,10 +545,10 @@ end -------------------------------------------------------------------- local function TMXIsoTest2() local ret = createTileDemoLayer("TMX Isometric test 2") - local color = CCLayerColor:create( Color4B(64,64,64,255) ) + local color = cc.LayerColor:create( cc.c4b(64,64,64,255) ) ret:addChild(color, -1) - local map = CCTMXTiledMap:create("TileMaps/iso-test2.tmx") + local map = cc.TMXTiledMap:create("TileMaps/iso-test2.tmx") ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() @@ -568,7 +557,7 @@ local function TMXIsoTest2() -- move map to the center of the screen local ms = map:getMapSize() local ts = map:getTileSize() - map:runAction( CCMoveTo:create(1.0, CCPoint( -ms.width * ts.width/2, -ms.height * ts.height/2 ) )) + map:runAction( cc.MoveTo:create(1.0, cc.p( -ms.width * ts.width/2, -ms.height * ts.height/2 ) )) return ret end @@ -579,10 +568,10 @@ end -------------------------------------------------------------------- local function TMXUncompressedTest() local ret = createTileDemoLayer("TMX Uncompressed test") - local color = CCLayerColor:create( Color4B(64,64,64,255) ) + local color = cc.LayerColor:create( cc.c4b(64,64,64,255) ) ret:addChild(color, -1) - local map = CCTMXTiledMap:create("TileMaps/iso-test2-uncompressed.tmx") + local map = cc.TMXTiledMap:create("TileMaps/iso-test2-uncompressed.tmx") ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() @@ -591,15 +580,15 @@ local function TMXUncompressedTest() -- move map to the center of the screen local ms = map:getMapSize() local ts = map:getTileSize() - map:runAction(CCMoveTo:create(1.0, CCPoint( -ms.width * ts.width/2, -ms.height * ts.height/2 ) )) + map:runAction(cc.MoveTo:create(1.0, cc.p( -ms.width * ts.width/2, -ms.height * ts.height/2 ) )) -- testing release map local pChildrenArray = map:getChildren() local layer = nil local i = 0 - local len = pChildrenArray:count() + local len = table.getn(pChildrenArray) for i = 0, len-1, 1 do - layer = tolua.cast(pChildrenArray:objectAtIndex(i), "CCTMXLayer") + layer = tolua.cast(pChildrenArray[i + 1], "TMXLayer") if layer == nil then break end @@ -615,7 +604,7 @@ end -------------------------------------------------------------------- local function TMXTilesetTest() local ret = createTileDemoLayer("TMX Tileset test") - local map = CCTMXTiledMap:create("TileMaps/orthogonal-test5.tmx") + local map = cc.TMXTiledMap:create("TileMaps/orthogonal-test5.tmx") ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() @@ -639,7 +628,7 @@ end -------------------------------------------------------------------- local function TMXOrthoObjectsTest() local ret = createTileDemoLayer("TMX Ortho object test", "You should see a white box around the 3 platforms") - local map = CCTMXTiledMap:create("TileMaps/ortho-objects.tmx") + local map = cc.TMXTiledMap:create("TileMaps/ortho-objects.tmx") ret:addChild(map, -1, kTagTileMap) local s = map:getContentSize() @@ -651,10 +640,10 @@ local function TMXOrthoObjectsTest() local dict = nil local i = 0 - local len = objects:count() + local len = table.getn(objects) for i = 0, len-1, 1 do - dict = tolua.cast(objects:objectAtIndex(i), "CCDictionary") + dict = objects[i + 1] if dict == nil then break @@ -670,35 +659,35 @@ end local function draw() - local map = tolua.cast(getChildByTag(kTagTileMap), "CCTMXTiledMap") + local map = tolua.cast(getChildByTag(kTagTileMap), "TMXTiledMap") local group = map:getObjectGroup("Object Group 1") local objects = group:getObjects() local dict = nil local i = 0 - local len = objects:count() + local len = table.getn(objects) for i = 0, len-1, 1 do - dict = tolua.cast(objects:objectAtIndex(i), "CCDictionary") + dict = objects[i + 1] if dict == nil then break end local key = "x" - local x = (tolua.cast(dict:objectForKey(key), "CCString")):intValue() + local x = dict["x"] key = "y" - local y = (tolua.cast(dict:objectForKey(key), "CCString")):intValue()--dynamic_cast(dict:objectForKey("y")):getNumber() + local y = dict["y"]--dynamic_cast(dict:objectForKey("y")):getNumber() key = "width" - local width = (tolua.cast(dict:objectForKey(key), "CCString")):intValue()--dynamic_cast(dict:objectForKey("width")):getNumber() + local width = dict["width"]--dynamic_cast(dict:objectForKey("width")):getNumber() key = "height" - local height = (tolua.cast(dict:objectForKey(key), "CCString")):intValue()--dynamic_cast(dict:objectForKey("height")):getNumber() + local height = dict["height"]--dynamic_cast(dict:objectForKey("height")):getNumber() glLineWidth(3) - CCDrawPrimitives.ccDrawLine( CCPoint(x, y), CCPoint((x+width), y) ) - CCDrawPrimitives.ccDrawLine( CCPoint((x+width), y), CCPoint((x+width), (y+height)) ) - CCDrawPrimitives.ccDrawLine( CCPoint((x+width), (y+height)), CCPoint(x, (y+height)) ) - CCDrawPrimitives.ccDrawLine( CCPoint(x, (y+height)), CCPoint(x, y) ) + cc.DrawPrimitives.ccDrawLine( cc.p(x, y), cc.p((x+width), y) ) + cc.DrawPrimitives.ccDrawLine( cc.p((x+width), y), cc.p((x+width), (y+height)) ) + cc.DrawPrimitives.ccDrawLine( cc.p((x+width), (y+height)), cc.p(x, (y+height)) ) + cc.DrawPrimitives.ccDrawLine( cc.p(x, (y+height)), cc.p(x, y) ) glLineWidth(1) end @@ -712,7 +701,7 @@ end local function TMXIsoObjectsTest() local ret = createTileDemoLayer("TMX Iso object test", "You need to parse them manually. See bug #810") - local map = CCTMXTiledMap:create("TileMaps/iso-test-objectgroup.tmx") + local map = cc.TMXTiledMap:create("TileMaps/iso-test-objectgroup.tmx") ret:addChild(map, -1, kTagTileMap) local s = map:getContentSize() @@ -725,9 +714,9 @@ local function TMXIsoObjectsTest() --UxMutableDictionary* dict local dict = nil local i = 0 - local len = objects:count() + local len = table.getn(objects) for i = 0, len-1, 1 do - dict = tolua.cast(objects:objectAtIndex(i), "CCDictionary") + dict = tolua.cast(objects[i + 1], "Dictionary") if dict == nil then break @@ -739,35 +728,35 @@ end local function draw() - local map = tolua.cast(getChildByTag(kTagTileMap), "CCTMXTiledMap") + local map = tolua.cast(getChildByTag(kTagTileMap), "TMXTiledMap") local group = map:getObjectGroup("Object Group 1") local objects = group:getObjects() local dict = nil local i = 0 - local len = objects:count() + local len = table.getn(objects) for i = 0, len-1, 1 do - dict = tolua.cast(objects:objectAtIndex(i), "CCDictionary") + dict = tolua.cast(objects[i + 1], "Dictionary") if dict == nil then break end local key = "x" - local x = (tolua.cast(dict:objectForKey(key), "CCString")):intValue()--dynamic_cast(dict:objectForKey("x")):getNumber() + local x = (tolua.cast(dict:objectForKey(key), "String")):intValue()--dynamic_cast(dict:objectForKey("x")):getNumber() key = "y" - local y = (tolua.cast(dict:objectForKey(key), "CCString")):intValue()--dynamic_cast(dict:objectForKey("y")):getNumber() + local y = (tolua.cast(dict:objectForKey(key), "String")):intValue()--dynamic_cast(dict:objectForKey("y")):getNumber() key = "width" - local width = (tolua.cast(dict:objectForKey(key), "CCString")):intValue()--dynamic_cast(dict:objectForKey("width")):getNumber() + local width = (tolua.cast(dict:objectForKey(key), "String")):intValue()--dynamic_cast(dict:objectForKey("width")):getNumber() key = "height" - local height = (tolua.cast(dict:objectForKey(key), "CCString")):intValue()--dynamic_cast(dict:objectForKey("height")):getNumber() + local height = (tolua.cast(dict:objectForKey(key), "String")):intValue()--dynamic_cast(dict:objectForKey("height")):getNumber() glLineWidth(3) - CCDrawPrimitives.ccDrawLine( CCPoint(x,y), CCPoint(x+width,y) ) - CCDrawPrimitives.ccDrawLine( CCPoint(x+width,y), CCPoint(x+width,y+height) ) - CCDrawPrimitives.ccDrawLine( CCPoint(x+width,y+height), CCPoint(x,y+height) ) - CCDrawPrimitives.ccDrawLine( CCPoint(x,y+height), CCPoint(x,y) ) + cc.DrawPrimitives.ccDrawLine( cc.p(x,y), cc.p(x+width,y) ) + cc.DrawPrimitives.ccDrawLine( cc.p(x+width,y), cc.p(x+width,y+height) ) + cc.DrawPrimitives.ccDrawLine( cc.p(x+width,y+height), cc.p(x,y+height) ) + cc.DrawPrimitives.ccDrawLine( cc.p(x,y+height), cc.p(x,y) ) glLineWidth(1) end @@ -781,7 +770,7 @@ end local function TMXResizeTest() local ret = createTileDemoLayer("TMX resize test", "Should not crash. Testing issue #740") - local map = CCTMXTiledMap:create("TileMaps/orthogonal-test5.tmx") + local map = cc.TMXTiledMap:create("TileMaps/orthogonal-test5.tmx") ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() @@ -793,7 +782,7 @@ local function TMXResizeTest() local y = 0 for y = 0, ls.height-1, 1 do for x = 0, ls.width-1, 1 do - layer:setTileGID(1, CCPoint( x, y ) ) + layer:setTileGID(1, cc.p( x, y ) ) end end return ret @@ -807,31 +796,27 @@ end local function TMXIsoZorder() local m_tamara = nil local ret = createTileDemoLayer("TMX Iso Zorder", "Sprite should hide behind the trees") - local map = CCTMXTiledMap:create("TileMaps/iso-test-zorder.tmx") + local map = cc.TMXTiledMap:create("TileMaps/iso-test-zorder.tmx") ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() cclog("ContentSize: %f, %f", s.width,s.height) - map:setPosition(CCPoint(-s.width/2,0)) + map:setPosition(cc.p(-s.width/2,0)) - m_tamara = CCSprite:create(s_pPathSister1) - map:addChild(m_tamara, map:getChildren():count() ) + m_tamara = cc.Sprite:create(s_pPathSister1) + map:addChild(m_tamara, table.getn(map:getChildren())) m_tamara:retain() local mapWidth = map:getMapSize().width * map:getTileSize().width - m_tamara:setPosition(CC_POINT_PIXELS_TO_POINTS(CCPoint( mapWidth/2,0))) - m_tamara:setAnchorPoint(CCPoint(0.5,0)) + m_tamara:setPosition(CC_POINT_PIXELS_TO_POINTS(cc.p( mapWidth/2,0))) + m_tamara:setAnchorPoint(cc.p(0.5,0)) - local move = CCMoveBy:create(10, CCPoint(300,250)) + local move = cc.MoveBy:create(10, cc.p(300,250)) local back = move:reverse() - local arr = CCArray:create() - arr:addObject(move) - arr:addObject(back) - local seq = CCSequence:create(arr) - m_tamara:runAction( CCRepeatForever:create(seq) ) + local seq = cc.Sequence:create(move, back) + m_tamara:runAction( cc.RepeatForever:create(seq) ) local function repositionSprite(dt) - local x,y = m_tamara:getPosition() - local p = CCPoint(x, y) + local p = m_tamara:getPosition() p = CC_POINT_POINTS_TO_PIXELS(p) local map = ret:getChildByTag(kTagTileMap) @@ -871,29 +856,25 @@ end local function TMXOrthoZorder() local m_tamara = nil local ret = createTileDemoLayer("TMX Ortho Zorder", "Sprite should hide behind the trees") - local map = CCTMXTiledMap:create("TileMaps/orthogonal-test-zorder.tmx") + local map = cc.TMXTiledMap:create("TileMaps/orthogonal-test-zorder.tmx") ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() cclog("ContentSize: %f, %f", s.width,s.height) - m_tamara = CCSprite:create(s_pPathSister1) - map:addChild(m_tamara, map:getChildren():count()) + m_tamara = cc.Sprite:create(s_pPathSister1) + map:addChild(m_tamara, table.getn(map:getChildren())) m_tamara:retain() - m_tamara:setAnchorPoint(CCPoint(0.5,0)) + m_tamara:setAnchorPoint(cc.p(0.5,0)) - local move = CCMoveBy:create(10, CCPoint(400,450)) + local move = cc.MoveBy:create(10, cc.p(400,450)) local back = move:reverse() - local arr = CCArray:create() - arr:addObject(move) - arr:addObject(back) - local seq = CCSequence:create(arr) - m_tamara:runAction( CCRepeatForever:create(seq)) + local seq = cc.Sequence:create(move, back) + m_tamara:runAction( cc.RepeatForever:create(seq)) local function repositionSprite(dt) - local x, y = m_tamara:getPosition() - local p = CCPoint(x, y) + local p = m_tamara:getPosition() p = CC_POINT_POINTS_TO_PIXELS(p) local map = ret:getChildByTag(kTagTileMap) @@ -933,32 +914,28 @@ end local function TMXIsoVertexZ() local m_tamara = nil local ret = createTileDemoLayer("TMX Iso VertexZ", "Sprite should hide behind the trees") - local map = CCTMXTiledMap:create("TileMaps/iso-test-vertexz.tmx") + local map = cc.TMXTiledMap:create("TileMaps/iso-test-vertexz.tmx") ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() - map:setPosition( CCPoint(-s.width/2,0) ) + map:setPosition( cc.p(-s.width/2,0) ) cclog("ContentSize: %f, %f", s.width,s.height) -- because I'm lazy, I'm reusing a tile as an sprite, but since this method uses vertexZ, you - -- can use any CCSprite and it will work OK. + -- can use any cc.Sprite and it will work OK. local layer = map:getLayer("Trees") - m_tamara = layer:getTileAt( CCPoint(29,29) ) + m_tamara = layer:getTileAt( cc.p(29,29) ) m_tamara:retain() - local move = CCMoveBy:create(10, CCPoint.__mul( CCPoint(300,250), 1/CC_CONTENT_SCALE_FACTOR() ) ) + local move = cc.MoveBy:create(10, cc.pMul( cc.p(300,250), 1/CC_CONTENT_SCALE_FACTOR() ) ) local back = move:reverse() - local arr = CCArray:create() - arr:addObject(move) - arr:addObject(back) - local seq = CCSequence:create(arr) - m_tamara:runAction( CCRepeatForever:create(seq) ) + local seq = cc.Sequence:create(move, back) + m_tamara:runAction( cc.RepeatForever:create(seq) ) local function repositionSprite(dt) -- tile height is 64x32 -- map size: 30x30 - local x, y = m_tamara:getPosition() - local p = CCPoint(x, y) + local p = m_tamara:getPosition() p = CC_POINT_POINTS_TO_PIXELS(p) local newZ = -(p.y+32) /16 m_tamara:setVertexZ( newZ ) @@ -968,11 +945,11 @@ local function TMXIsoVertexZ() local function onNodeEvent(event) if event == "enter" then -- TIP: 2d projection should be used - CCDirector:getInstance():setProjection(kCCDirectorProjection2D) + cc.Director:getInstance():setProjection(cc.DIRECTOR_PROJECTION2_D ) schedulerEntry = scheduler:scheduleScriptFunc(repositionSprite, 0, false) elseif event == "exit" then -- At exit use any other projection. - -- CCDirector:getInstance():setProjection:kCCDirectorProjection3D) + -- cc.Director:getInstance():setProjection:cc.DIRECTOR_PROJECTION3_D ) if m_tamara ~= nil then m_tamara:release() @@ -993,32 +970,28 @@ end local function TMXOrthoVertexZ() local m_tamara = nil local ret = createTileDemoLayer("TMX Ortho vertexZ", "Sprite should hide behind the trees") - local map = CCTMXTiledMap:create("TileMaps/orthogonal-test-vertexz.tmx") + local map = cc.TMXTiledMap:create("TileMaps/orthogonal-test-vertexz.tmx") ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() cclog("ContentSize: %f, %f", s.width,s.height) -- because I'm lazy, I'm reusing a tile as an sprite, but since this method uses vertexZ, you - -- can use any CCSprite and it will work OK. + -- can use any cc.Sprite and it will work OK. local layer = map:getLayer("trees") - m_tamara = layer:getTileAt(CCPoint(0,11)) + m_tamara = layer:getTileAt(cc.p(0,11)) cclog("vertexZ:"..m_tamara:getVertexZ()) m_tamara:retain() - local move = CCMoveBy:create(10, CCPoint.__mul( CCPoint(400,450), 1/CC_CONTENT_SCALE_FACTOR())) + local move = cc.MoveBy:create(10, cc.pMul( cc.p(400,450), 1/CC_CONTENT_SCALE_FACTOR())) local back = move:reverse() - local arr = CCArray:create() - arr:addObject(move) - arr:addObject(back) - local seq = CCSequence:create(arr) - m_tamara:runAction( CCRepeatForever:create(seq)) + local seq = cc.Sequence:create(move, back) + m_tamara:runAction( cc.RepeatForever:create(seq)) local function repositionSprite(dt) -- tile height is 101x81 -- map size: 12x12 - local x, y = m_tamara:getPosition() - local p = CCPoint(x, y) + local p = m_tamara:getPosition() p = CC_POINT_POINTS_TO_PIXELS(p) m_tamara:setVertexZ( -( (p.y+81) /81) ) end @@ -1027,11 +1000,11 @@ local function TMXOrthoVertexZ() local function onNodeEvent(event) if event == "enter" then -- TIP: 2d projection should be used - CCDirector:getInstance():setProjection(kCCDirectorProjection2D) + cc.Director:getInstance():setProjection(cc.DIRECTOR_PROJECTION2_D ) schedulerEntry = scheduler:scheduleScriptFunc(repositionSprite, 0, false) elseif event == "exit" then -- At exit use any other projection. - -- CCDirector:getInstance():setProjection:kCCDirectorProjection3D) + -- cc.Director:getInstance():setProjection:cc.DIRECTOR_PROJECTION3_D ) if m_tamara ~= nil then m_tamara:release() end @@ -1049,10 +1022,10 @@ end -------------------------------------------------------------------- local function TMXIsoMoveLayer() local ret = createTileDemoLayer("TMX Iso Move Layer", "Trees should be horizontally aligned") - local map = CCTMXTiledMap:create("TileMaps/iso-test-movelayer.tmx") + local map = cc.TMXTiledMap:create("TileMaps/iso-test-movelayer.tmx") ret:addChild(map, 0, kTagTileMap) - map:setPosition(CCPoint(-700,-50)) + map:setPosition(cc.p(-700,-50)) local s = map:getContentSize() cclog("ContentSize: %f, %f", s.width,s.height) @@ -1067,7 +1040,7 @@ end -------------------------------------------------------------------- local function TMXOrthoMoveLayer() local ret = createTileDemoLayer("TMX Ortho Move Layer", "Trees should be horizontally aligned") - local map = CCTMXTiledMap:create("TileMaps/orthogonal-test-movelayer.tmx") + local map = cc.TMXTiledMap:create("TileMaps/orthogonal-test-movelayer.tmx") ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() @@ -1083,7 +1056,7 @@ end local function TMXTilePropertyTest() local ret = createTileDemoLayer("TMX Tile Property Test", "In the console you should see tile properties") - local map = CCTMXTiledMap:create("TileMaps/ortho-tile-property.tmx") + local map = cc.TMXTiledMap:create("TileMaps/ortho-tile-property.tmx") ret:addChild(map ,0 ,kTagTileMap) local i = 0 for i=1, 20, 1 do @@ -1100,19 +1073,19 @@ end local function TMXOrthoFlipTest() local ret = createTileDemoLayer("TMX tile flip test") - local map = CCTMXTiledMap:create("TileMaps/ortho-rotation-test.tmx") + local map = cc.TMXTiledMap:create("TileMaps/ortho-rotation-test.tmx") ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() cclog("ContentSize: %f, %f", s.width,s.height) local i = 0 - for i = 0, map:getChildren():count()-1, 1 do - local child = tolua.cast(map:getChildren():objectAtIndex(i), "CCSpriteBatchNode") + for i = 0, table.getn(map:getChildren())-1, 1 do + local child = tolua.cast(map:getChildren()[i + 1], "SpriteBatchNode") child:getTexture():setAntiAliasTexParameters() end - local action = CCScaleBy:create(2, 0.5) + local action = cc.ScaleBy:create(2, 0.5) map:runAction(action) return ret end @@ -1125,54 +1098,54 @@ end local function TMXOrthoFlipRunTimeTest() local ret = createTileDemoLayer("TMX tile flip run time test", "in 2 sec bottom left tiles will flip") - local map = CCTMXTiledMap:create("TileMaps/ortho-rotation-test.tmx") + local map = cc.TMXTiledMap:create("TileMaps/ortho-rotation-test.tmx") ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() cclog("ContentSize: %f, %f", s.width,s.height) local i = 0 - for i = 0, map:getChildren():count()-1, 1 do - local child = tolua.cast(map:getChildren():objectAtIndex(i), "CCSpriteBatchNode") + for i = 0, table.getn(map:getChildren())-1, 1 do + local child = tolua.cast(map:getChildren()[i + 1], "SpriteBatchNode") child:getTexture():setAntiAliasTexParameters() end - local action = CCScaleBy:create(2, 0.5) + local action = cc.ScaleBy:create(2, 0.5) map:runAction(action) local function flipIt(dt) - -- local map = tolua.cast(ret:getChildByTag(kTagTileMap), "CCTMXTiledMap") + -- local map = tolua.cast(ret:getChildByTag(kTagTileMap), "TMXTiledMap") -- local layer = map:getLayer("Layer 0") -- --blue diamond - -- local tileCoord = CCPoint(1,10) + -- local tileCoord = cc.p(1,10) -- local flags = 0 -- local GID = layer:getTileGIDAt(tileCoord, (ccTMXTileFlags*)&flags) -- -- Vertical - -- if( flags & kCCTMXTileVerticalFlag ) - -- flags &= ~kCCTMXTileVerticalFlag + -- if( flags & kcc.TMXTileVerticalFlag ) + -- flags &= ~kcc.TMXTileVerticalFlag -- else - -- flags |= kCCTMXTileVerticalFlag + -- flags |= kcc.TMXTileVerticalFlag -- layer:setTileGID(GID ,tileCoord, (ccTMXTileFlags)flags) - -- tileCoord = CCPoint(1,8) + -- tileCoord = cc.p(1,8) -- GID = layer:getTileGIDAt(tileCoord, (ccTMXTileFlags*)&flags) -- -- Vertical - -- if( flags & kCCTMXTileVerticalFlag ) - -- flags &= ~kCCTMXTileVerticalFlag + -- if( flags & kcc.TMXTileVerticalFlag ) + -- flags &= ~kcc.TMXTileVerticalFlag -- else - -- flags |= kCCTMXTileVerticalFlag + -- flags |= kcc.TMXTileVerticalFlag -- layer:setTileGID(GID ,tileCoord, (ccTMXTileFlags)flags) - -- tileCoord = CCPoint(2,8) + -- tileCoord = cc.p(2,8) -- GID = layer:getTileGIDAt(tileCoord, (ccTMXTileFlags*)&flags) -- -- Horizontal - -- if( flags & kCCTMXTileHorizontalFlag ) - -- flags &= ~kCCTMXTileHorizontalFlag + -- if( flags & kcc.TMXTileHorizontalFlag ) + -- flags &= ~kcc.TMXTileHorizontalFlag -- else - -- flags |= kCCTMXTileHorizontalFlag + -- flags |= kcc.TMXTileHorizontalFlag -- layer:setTileGID(GID, tileCoord, (ccTMXTileFlags)flags) end local schedulerEntry = nil @@ -1198,26 +1171,26 @@ local function TMXOrthoFromXMLTest() local resources = "TileMaps" -- partial paths are OK as resource paths. local file = resources.."/orthogonal-test1.tmx" - local str = CCString:createWithContentsOfFile(CCFileUtils:getInstance():fullPathForFilename(file)):getCString() - -- CCASSERT(str != NULL, "Unable to open file") + local str = cc.FileUtils:getInstance():getStringFromFile(file) + -- cc.ASSERT(str != NULL, "Unable to open file") if (str == nil) then cclog("Unable to open file") end - local map = CCTMXTiledMap:createWithXML(str ,resources) + local map = cc.TMXTiledMap:createWithXML(str ,resources) ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() cclog("ContentSize: %f, %f", s.width,s.height) local i = 0 - local len = map:getChildren():count() + local len = table.getn(map:getChildren()) for i = 0, len-1, 1 do - local child = tolua.cast(map:getChildren():objectAtIndex(i), "CCSpriteBatchNode") + local child = tolua.cast(map:getChildren()[i + 1], "SpriteBatchNode") child:getTexture():setAntiAliasTexParameters() end - local action = CCScaleBy:create(2, 0.5) + local action = cc.ScaleBy:create(2, 0.5) map:runAction(action) return ret end @@ -1229,7 +1202,7 @@ end -------------------------------------------------------------------- local function TMXBug987() local ret = createTileDemoLayer("TMX Bug 987", "You should see an square") - local map = CCTMXTiledMap:create("TileMaps/orthogonal-test6.tmx") + local map = cc.TMXTiledMap:create("TileMaps/orthogonal-test6.tmx") ret:addChild(map, 0, kTagTileMap) local s1 = map:getContentSize() @@ -1238,19 +1211,19 @@ local function TMXBug987() local childs = map:getChildren() local i = 0 - local len = childs:count() + local len = table.getn(childs) local pNode = nil for i = 0, len-1, 1 do - pNode = tolua.cast(childs:objectAtIndex(i), "CCTMXLayer") + pNode = tolua.cast(childs[i + 1], "TMXLayer") if pNode == nil then break end pNode:getTexture():setAntiAliasTexParameters() end - map:setAnchorPoint(CCPoint(0, 0)) + map:setAnchorPoint(cc.p(0, 0)) local layer = map:getLayer("Tile Layer 1") - layer:setTileGID(3, CCPoint(2,2)) + layer:setTileGID(3, cc.p(2,2)) return ret end @@ -1261,7 +1234,7 @@ end -------------------------------------------------------------------- local function TMXBug787() local ret = createTileDemoLayer("TMX Bug 787", "You should see a map") - local map = CCTMXTiledMap:create("TileMaps/iso-test-bug787.tmx") + local map = cc.TMXTiledMap:create("TileMaps/iso-test-bug787.tmx") ret:addChild(map, 0, kTagTileMap) map:setScale(0.25) return ret @@ -1270,8 +1243,8 @@ end function TileMapTestMain() cclog("TileMapTestMain") Helper.index = 1 - CCDirector:getInstance():setDepthTest(true) - local scene = CCScene:create() + cc.Director:getInstance():setDepthTest(true) + local scene = cc.Scene:create() Helper.createFunctionTable = { TileMapTest, diff --git a/samples/Lua/TestLua/Resources/luaScript/TouchesTest/Ball.lua b/samples/Lua/TestLua/Resources/luaScript/TouchesTest/Ball.lua index e970a286f0..06c967b2a6 100644 --- a/samples/Lua/TestLua/Resources/luaScript/TouchesTest/Ball.lua +++ b/samples/Lua/TestLua/Resources/luaScript/TouchesTest/Ball.lua @@ -4,12 +4,12 @@ require "luaScript/VisibleRect" require "luaScript/TouchesTest/Paddle" Ball = class("Ball", function(texture) - return CCSprite:createWithTexture(texture) + return cc.Sprite:createWithTexture(texture) end) Ball.__index = Ball -Ball.m_velocity = CCPoint(0,0) +Ball.m_velocity = cc.p(0,0) local M_PI = 3.1415926 @@ -19,56 +19,56 @@ function Ball:radius() end function Ball:move(delta) - local getPosition = CCPoint(self:getPosition()) - local position = CCPoint.__mul(self.m_velocity, delta) - self:setPosition( CCPoint.__add(getPosition, position) ); + local getPosition = cc.p(self:getPosition()) + local position = cc.pMul(self.m_velocity, delta) + self:setPosition( cc.pAdd(getPosition, position) ) if (getPosition.x > VisibleRect:right().x - self:radius()) then - self:setPosition( CCPoint( VisibleRect:right().x - self:radius(), getPosition.y) ); - self.m_velocity.x = self.m_velocity.x * -1; + self:setPosition( cc.p( VisibleRect:right().x - self:radius(), getPosition.y) ) + self.m_velocity.x = self.m_velocity.x * -1 elseif (getPosition.x < VisibleRect:left().x + self:radius()) then - self:setPosition( CCPoint(VisibleRect:left().x + self:radius(), getPosition.y) ); - self.m_velocity.x = self.m_velocity.x * -1; + self:setPosition( cc.p(VisibleRect:left().x + self:radius(), getPosition.y) ) + self.m_velocity.x = self.m_velocity.x * -1 end end function Ball:collideWithPaddle(paddle) local paddleRect = paddle:rect() - local paddleGetPosition = CCPoint(paddle:getPosition()) - local selfGetPosition = CCPoint(self:getPosition()) + local paddleGetPosition = cc.p(paddle:getPosition()) + local selfGetPosition = cc.p(self:getPosition()) - paddleRect.origin.x = paddleRect.origin.x + paddleGetPosition.x; - paddleRect.origin.y = paddleRect.origin.y + paddleGetPosition.y; + paddleRect.x = paddleRect.x + paddleGetPosition.x + paddleRect.y = paddleRect.y + paddleGetPosition.y - local lowY = paddleRect:getMinY(); - local midY = paddleRect:getMidY(); - local highY = paddleRect:getMaxY(); + local lowY = cc.rectGetMinY(paddleRect) + local midY = cc.rectGetMidY(paddleRect) + local highY = cc.rectGetMaxY(paddleRect) - local leftX = paddleRect:getMinX(); - local rightX = paddleRect:getMaxX(); + local leftX = cc.rectGetMinX(paddleRect) + local rightX = cc.rectGetMaxX(paddleRect) if (selfGetPosition.x > leftX and selfGetPosition.x < rightX) then - local hit = false; - local angleOffset = 0.0; + local hit = false + local angleOffset = 0.0 if (selfGetPosition.y > midY and selfGetPosition.y <= highY + self:radius()) then - self:setPosition( CCPoint(selfGetPosition.x, highY + self:radius()) ); - hit = true; - angleOffset = M_PI / 2; + self:setPosition( cc.p(selfGetPosition.x, highY + self:radius()) ) + hit = true + angleOffset = M_PI / 2 elseif (selfGetPosition.y < midY and selfGetPosition.y >= lowY - self:radius()) then - self:setPosition( CCPoint(selfGetPosition.x, lowY - self:radius()) ); - hit = true; - angleOffset = -M_PI / 2; + self:setPosition( cc.p(selfGetPosition.x, lowY - self:radius()) ) + hit = true + angleOffset = -M_PI / 2 end if (hit) then - local hitAngle = (CCPoint.__sub(paddleGetPosition, paddleGetPosition)):getAngle() + angleOffset; + local hitAngle = cc.pToAngleSelf(cc.pSub(paddleGetPosition, paddleGetPosition)) + angleOffset - local scalarVelocity = (self.m_velocity):getLength() * 1.05; - local velocityAngle = -(self.m_velocity):getAngle() + 0.5 * hitAngle; + local scalarVelocity = cc.pGetLength(self.m_velocity) * 1.05 + local velocityAngle = -cc.pToAngleSelf(self.m_velocity) + 0.5 * hitAngle - self.m_velocity = CCPoint.__mul(CCPoint:forAngle(velocityAngle), scalarVelocity); + self.m_velocity = cc.pMul(cc.pForAngle(velocityAngle), scalarVelocity) end end @@ -89,7 +89,7 @@ function Ball.ballWithTexture(aTexture) end local ball = Ball.new(aTexture) - ball:autorelease() + --ball:autorelease() return ball end diff --git a/samples/Lua/TestLua/Resources/luaScript/TouchesTest/Paddle.lua b/samples/Lua/TestLua/Resources/luaScript/TouchesTest/Paddle.lua index ebbadec579..050d587ed5 100644 --- a/samples/Lua/TestLua/Resources/luaScript/TouchesTest/Paddle.lua +++ b/samples/Lua/TestLua/Resources/luaScript/TouchesTest/Paddle.lua @@ -2,7 +2,7 @@ require "luaScript/extern" require "luaScript/VisibleRect" Paddle = class("Paddle", function(texture) - return CCSprite:createWithTexture(texture) + return cc.Sprite:createWithTexture(texture) end) Paddle.__index = Paddle @@ -15,14 +15,14 @@ Paddle.m_state = kPaddleStateGrabbed function Paddle:rect() local s = self:getTexture():getContentSize() - return CCRect(-s.width / 2, -s.height / 2, s.width, s.height) + return cc.rect(-s.width / 2, -s.height / 2, s.width, s.height) end function Paddle:containsTouchLocation(x,y) - local position = CCPoint(self:getPosition()) + local position = cc.p(self:getPosition()) local s = self:getTexture():getContentSize() - local touchRect = CCRect(-s.width / 2 + position.x, -s.height / 2 + position.y, s.width, s.height) - local b = touchRect:containsPoint(CCPoint(x,y)) + local touchRect = cc.rect(-s.width / 2 + position.x, -s.height / 2 + position.y, s.width, s.height) + local b = cc.rectContainsPoint(touchRect, cc.p(x,y)) return b end @@ -36,7 +36,7 @@ function Paddle:ccTouchBegan(x, y) end function Paddle:ccTouchMoved(x, y) - self:setPosition( CCPoint(x,y) ); + self:setPosition( cc.p(x,y) ); end function Paddle:ccTouchEnded(x, y) diff --git a/samples/Lua/TestLua/Resources/luaScript/TouchesTest/TouchesTest.lua b/samples/Lua/TestLua/Resources/luaScript/TouchesTest/TouchesTest.lua index 48b6de4098..085de21ebe 100644 --- a/samples/Lua/TestLua/Resources/luaScript/TouchesTest/TouchesTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/TouchesTest/TouchesTest.lua @@ -16,14 +16,14 @@ local m_paddles = {} local layer = nil local function backCallback(sender) - local scene = CCScene:create() + local scene = cc.Scene:create() scene:addChild(CreateBackMenuItem()) - CCDirector:getInstance():replaceScene(scene) + cc.Director:getInstance():replaceScene(scene) end local function resetAndScoreBallForPlayer(player) - m_ballStartingVelocity = CCPoint.__mul(m_ballStartingVelocity, -1.1); + m_ballStartingVelocity = cc.pMul(m_ballStartingVelocity, -1.1); m_ball:setVelocity( m_ballStartingVelocity ); m_ball:setPosition( VisibleRect:center() ); end @@ -39,7 +39,7 @@ local function doStep(delta) m_ball:collideWithPaddle( paddle ); end - local ballPosition = CCPoint(m_ball:getPosition()) + local ballPosition = cc.p(m_ball:getPosition()) if (ballPosition.y > VisibleRect:top().y - kStatusBarHeight + m_ball:radius()) then resetAndScoreBallForPlayer( kLowPlayer ); elseif (ballPosition.y < VisibleRect:bottom().y-m_ball:radius()) then @@ -60,10 +60,10 @@ local function onTouch(event, x, y) end local function CreateTouchesLayer() - layer = CCLayer:create() + layer = cc.Layer:create() - m_ballStartingVelocity = CCPoint(20.0, -100.0); - local mgr = CCTextureCache:getInstance() + m_ballStartingVelocity = cc.p(20.0, -100.0); + local mgr = cc.TextureCache:getInstance() local texture = mgr:addImage(s_Ball) m_ball = Ball.ballWithTexture(texture); @@ -72,24 +72,24 @@ local function CreateTouchesLayer() layer:addChild( m_ball ); m_ball:retain(); - local paddleTexture = CCTextureCache:getInstance():addImage(s_Paddle); + local paddleTexture = cc.TextureCache:getInstance():addImage(s_Paddle); local paddlesM = {} local paddle = Paddle:paddleWithTexture(paddleTexture); - paddle:setPosition( CCPoint(VisibleRect:center().x, VisibleRect:bottom().y + 15) ); + paddle:setPosition( cc.p(VisibleRect:center().x, VisibleRect:bottom().y + 15) ); paddlesM[#paddlesM+1] = paddle paddle = Paddle:paddleWithTexture( paddleTexture ); - paddle:setPosition( CCPoint(VisibleRect:center().x, VisibleRect:top().y - kStatusBarHeight - 15) ); + paddle:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - kStatusBarHeight - 15) ); paddlesM[#paddlesM+1] = paddle paddle = Paddle:paddleWithTexture( paddleTexture ); - paddle:setPosition( CCPoint(VisibleRect:center().x, VisibleRect:bottom().y + 100) ); + paddle:setPosition( cc.p(VisibleRect:center().x, VisibleRect:bottom().y + 100) ); paddlesM[#paddlesM+1] = paddle paddle = Paddle:paddleWithTexture( paddleTexture ); - paddle:setPosition( CCPoint(VisibleRect:center().x, VisibleRect:top().y - kStatusBarHeight - 100) ); + paddle:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - kStatusBarHeight - 100) ); paddlesM[#paddlesM+1] = paddle m_paddles = paddlesM @@ -117,7 +117,7 @@ local function nextAction() end function TouchesTest() - local scene = CCScene:create() + local scene = cc.Scene:create() scene:addChild(nextAction()) scene:addChild(CreateBackMenuItem()) return scene diff --git a/samples/Lua/TestLua/Resources/luaScript/TransitionsTest/TransitionsTest.lua b/samples/Lua/TestLua/Resources/luaScript/TransitionsTest/TransitionsTest.lua index 3f659a9fa2..bb9bb8692f 100644 --- a/samples/Lua/TestLua/Resources/luaScript/TransitionsTest/TransitionsTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/TransitionsTest/TransitionsTest.lua @@ -4,7 +4,7 @@ require "luaScript/TransitionsTest/TransitionsName" local SceneIdx = -1 local CurSceneNo = 2 local TRANSITION_DURATION = 1.2 -local s = CCDirector:getInstance():getWinSize() +local s = cc.Director:getInstance():getWinSize() local function switchSceneTypeNo() if CurSceneNo == 1 then @@ -38,56 +38,56 @@ end local function backCallback(sender) local scene = backAction() - CCDirector:getInstance():replaceScene(scene) + cc.Director:getInstance():replaceScene(scene) end local function restartCallback(sender) local scene = restartAction() - CCDirector:getInstance():replaceScene(scene) + cc.Director:getInstance():replaceScene(scene) end local function nextCallback(sender) local scene = nextAction() - CCDirector:getInstance():replaceScene(scene) + cc.Director:getInstance():replaceScene(scene) end ----------------------------- -- TestLayer1 ----------------------------- local function createLayer1() - local layer = CCLayer:create() + local layer = cc.Layer:create() local x, y = s.width, s.height - local bg1 = CCSprite:create(s_back1) - bg1:setPosition(CCPoint(s.width / 2, s.height / 2)) + local bg1 = cc.Sprite:create(s_back1) + bg1:setPosition(cc.p(s.width / 2, s.height / 2)) layer:addChild(bg1, -1) - local titleLabel = CCLabelTTF:create(Transition_Name[SceneIdx], "Thonburi", 32) + local titleLabel = cc.LabelTTF:create(Transition_Name[SceneIdx], "Thonburi", 32) layer:addChild(titleLabel) - titleLabel:setColor(Color3B(255,32,32)) + titleLabel:setColor(cc.c3b(255,32,32)) titleLabel:setPosition(x / 2, y - 100) - local label = CCLabelTTF:create("SCENE 1", "Marker Felt", 38) - label:setColor(Color3B(16,16,255)) + local label = cc.LabelTTF:create("SCENE 1", "Marker Felt", 38) + label:setColor(cc.c3b(16,16,255)) label:setPosition(x / 2, y / 2) layer:addChild(label) -- menu - local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2) - local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2) - local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2) + local item1 = cc.MenuItemImage:create(s_pPathB1, s_pPathB2) + local item2 = cc.MenuItemImage:create(s_pPathR1, s_pPathR2) + local item3 = cc.MenuItemImage:create(s_pPathF1, s_pPathF2) item1:registerScriptTapHandler(backCallback) item2:registerScriptTapHandler(restartCallback) item3:registerScriptTapHandler(nextCallback) - local menu = CCMenu:create() + local menu = cc.Menu:create() menu:addChild(item1) menu:addChild(item2) menu:addChild(item3) - menu:setPosition(CCPoint(0, 0)) - item1:setPosition(CCPoint(s.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) - item2:setPosition(CCPoint(s.width / 2, item2:getContentSize().height / 2)) - item3:setPosition(CCPoint(s.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + menu:setPosition(cc.p(0, 0)) + item1:setPosition(cc.p(s.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + item2:setPosition(cc.p(s.width / 2, item2:getContentSize().height / 2)) + item3:setPosition(cc.p(s.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) layer:addChild(menu, 1) @@ -98,39 +98,39 @@ end -- TestLayer2 ----------------------------- local function createLayer2() - local layer = CCLayer:create() + local layer = cc.Layer:create() local x, y = s.width, s.height - local bg1 = CCSprite:create(s_back2) - bg1:setPosition(CCPoint(s.width / 2, s.height / 2)) + local bg1 = cc.Sprite:create(s_back2) + bg1:setPosition(cc.p(s.width / 2, s.height / 2)) layer:addChild(bg1, -1) - local titleLabel = CCLabelTTF:create(Transition_Name[SceneIdx], "Thonburi", 32 ) + local titleLabel = cc.LabelTTF:create(Transition_Name[SceneIdx], "Thonburi", 32 ) layer:addChild(titleLabel) - titleLabel:setColor(Color3B(255,32,32)) + titleLabel:setColor(cc.c3b(255,32,32)) titleLabel:setPosition(x / 2, y - 100) - local label = CCLabelTTF:create("SCENE 2", "Marker Felt", 38) - label:setColor(Color3B(16,16,255)) + local label = cc.LabelTTF:create("SCENE 2", "Marker Felt", 38) + label:setColor(cc.c3b(16,16,255)) label:setPosition(x / 2, y / 2) layer:addChild(label) -- menu - local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2) - local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2) - local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2) + local item1 = cc.MenuItemImage:create(s_pPathB1, s_pPathB2) + local item2 = cc.MenuItemImage:create(s_pPathR1, s_pPathR2) + local item3 = cc.MenuItemImage:create(s_pPathF1, s_pPathF2) item1:registerScriptTapHandler(backCallback) item2:registerScriptTapHandler(restartCallback) item3:registerScriptTapHandler(nextCallback) - local menu = CCMenu:create() + local menu = cc.Menu:create() menu:addChild(item1) menu:addChild(item2) menu:addChild(item3) - menu:setPosition(CCPoint(0, 0)) - item1:setPosition(CCPoint(s.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) - item2:setPosition(CCPoint(s.width / 2, item2:getContentSize().height / 2)) - item3:setPosition(CCPoint(s.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + menu:setPosition(cc.p(0, 0)) + item1:setPosition(cc.p(s.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + item2:setPosition(cc.p(s.width / 2, item2:getContentSize().height / 2)) + item3:setPosition(cc.p(s.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) layer:addChild(menu, 1) @@ -141,7 +141,7 @@ end -- Create Transition Test ----------------------------- local function createTransition(index, t, scene) - CCDirector:getInstance():setDepthTest(false) + cc.Director:getInstance():setDepthTest(false) if firstEnter == true then firstEnter = false @@ -149,96 +149,96 @@ local function createTransition(index, t, scene) end if index == Transition_Table.CCTransitionJumpZoom then - scene = CCTransitionJumpZoom:create(t, scene) + scene = cc.TransitionJumpZoom:create(t, scene) elseif index == Transition_Table.CCTransitionProgressRadialCCW then - scene = CCTransitionProgressRadialCCW:create(t, scene) + scene = cc.TransitionProgressRadialCCW:create(t, scene) elseif index == Transition_Table.CCTransitionProgressRadialCW then - scene = CCTransitionProgressRadialCW:create(t, scene) + scene = cc.TransitionProgressRadialCW:create(t, scene) elseif index == Transition_Table.CCTransitionProgressHorizontal then - scene = CCTransitionProgressHorizontal:create(t, scene) + scene = cc.TransitionProgressHorizontal:create(t, scene) elseif index == Transition_Table.CCTransitionProgressVertical then - scene = CCTransitionProgressVertical:create(t, scene) + scene = cc.TransitionProgressVertical:create(t, scene) elseif index == Transition_Table.CCTransitionProgressInOut then - scene = CCTransitionProgressInOut:create(t, scene) + scene = cc.TransitionProgressInOut:create(t, scene) elseif index == Transition_Table.CCTransitionProgressOutIn then - scene = CCTransitionProgressOutIn:create(t, scene) + scene = cc.TransitionProgressOutIn:create(t, scene) elseif index == Transition_Table.CCTransitionCrossFade then - scene = CCTransitionCrossFade:create(t, scene) + scene = cc.TransitionCrossFade:create(t, scene) elseif index == Transition_Table.TransitionPageForward then - CCDirector:getInstance():setDepthTest(true) - scene = CCTransitionPageTurn:create(t, scene, false) + cc.Director:getInstance():setDepthTest(true) + scene = cc.TransitionPageTurn:create(t, scene, false) elseif index == Transition_Table.TransitionPageBackward then - CCDirector:getInstance():setDepthTest(true) - scene = CCTransitionPageTurn:create(t, scene, true) + cc.Director:getInstance():setDepthTest(true) + scene = cc.TransitionPageTurn:create(t, scene, true) elseif index == Transition_Table.CCTransitionFadeTR then - scene = CCTransitionFadeTR:create(t, scene) + scene = cc.TransitionFadeTR:create(t, scene) elseif index == Transition_Table.CCTransitionFadeBL then - scene = CCTransitionFadeBL:create(t, scene) + scene = cc.TransitionFadeBL:create(t, scene) elseif index == Transition_Table.CCTransitionFadeUp then - scene = CCTransitionFadeUp:create(t, scene) + scene = cc.TransitionFadeUp:create(t, scene) elseif index == Transition_Table.CCTransitionFadeDown then - scene = CCTransitionFadeDown:create(t, scene) + scene = cc.TransitionFadeDown:create(t, scene) elseif index == Transition_Table.CCTransitionTurnOffTiles then - scene = CCTransitionTurnOffTiles:create(t, scene) + scene = cc.TransitionTurnOffTiles:create(t, scene) elseif index == Transition_Table.CCTransitionSplitRows then - scene = CCTransitionSplitRows:create(t, scene) + scene = cc.TransitionSplitRows:create(t, scene) elseif index == Transition_Table.CCTransitionSplitCols then - scene = CCTransitionSplitCols:create(t, scene) + scene = cc.TransitionSplitCols:create(t, scene) elseif index == Transition_Table.CCTransitionFade then - scene = CCTransitionFade:create(t, scene) + scene = cc.TransitionFade:create(t, scene) elseif index == Transition_Table.FadeWhiteTransition then - scene = CCTransitionFade:create(t, scene, Color3B(255, 255, 255)) + scene = cc.TransitionFade:create(t, scene, cc.c3b(255, 255, 255)) elseif index == Transition_Table.FlipXLeftOver then - scene = CCTransitionFlipX:create(t, scene, kCCTransitionOrientationLeftOver) + scene = cc.TransitionFlipX:create(t, scene, cc.TRANSITION_ORIENTATION_LEFT_OVER ) elseif index == Transition_Table.FlipXRightOver then - scene = CCTransitionFlipX:create(t, scene, kCCTransitionOrientationRightOver) + scene = cc.TransitionFlipX:create(t, scene, cc.TRANSITION_ORIENTATION_RIGHT_OVER ) elseif index == Transition_Table.FlipYUpOver then - scene = CCTransitionFlipY:create(t, scene, kCCTransitionOrientationUpOver) + scene = cc.TransitionFlipY:create(t, scene, cc.TRANSITION_ORIENTATION_UP_OVER) elseif index == Transition_Table.FlipYDownOver then - scene = CCTransitionFlipY:create(t, scene, kCCTransitionOrientationDownOver) + scene = cc.TransitionFlipY:create(t, scene, cc.TRANSITION_ORIENTATION_DOWN_OVER ) elseif index == Transition_Table.FlipAngularLeftOver then - scene = CCTransitionFlipAngular:create(t, scene, kCCTransitionOrientationLeftOver) + scene = cc.TransitionFlipAngular:create(t, scene, cc.TRANSITION_ORIENTATION_LEFT_OVER ) elseif index == Transition_Table.FlipAngularRightOver then - scene = CCTransitionFlipAngular:create(t, scene, kCCTransitionOrientationRightOver) + scene = cc.TransitionFlipAngular:create(t, scene, cc.TRANSITION_ORIENTATION_RIGHT_OVER ) elseif index == Transition_Table.ZoomFlipXLeftOver then - scene = CCTransitionZoomFlipX:create(t, scene, kCCTransitionOrientationLeftOver) + scene = cc.TransitionZoomFlipX:create(t, scene, cc.TRANSITION_ORIENTATION_LEFT_OVER ) elseif index == Transition_Table.ZoomFlipXRightOver then - scene = CCTransitionZoomFlipX:create(t, scene, kCCTransitionOrientationRightOver) + scene = cc.TransitionZoomFlipX:create(t, scene, cc.TRANSITION_ORIENTATION_RIGHT_OVER ) elseif index == Transition_Table.ZoomFlipYUpOver then - scene = CCTransitionZoomFlipY:create(t, scene, kCCTransitionOrientationUpOver) + scene = cc.TransitionZoomFlipY:create(t, scene, cc.TRANSITION_ORIENTATION_UP_OVER) elseif index == Transition_Table.ZoomFlipYDownOver then - scene = CCTransitionZoomFlipY:create(t, scene, kCCTransitionOrientationDownOver) + scene = cc.TransitionZoomFlipY:create(t, scene, cc.TRANSITION_ORIENTATION_DOWN_OVER ) elseif index == Transition_Table.ZoomFlipAngularLeftOver then - scene = CCTransitionZoomFlipAngular:create(t, scene, kCCTransitionOrientationLeftOver) + scene = cc.TransitionZoomFlipAngular:create(t, scene, cc.TRANSITION_ORIENTATION_LEFT_OVER ) elseif index == Transition_Table.ZoomFlipAngularRightOver then - scene = CCTransitionZoomFlipAngular:create(t, scene, kCCTransitionOrientationRightOver) + scene = cc.TransitionZoomFlipAngular:create(t, scene, cc.TRANSITION_ORIENTATION_RIGHT_OVER ) elseif index == Transition_Table.CCTransitionShrinkGrow then - scene = CCTransitionShrinkGrow:create(t, scene) + scene = cc.TransitionShrinkGrow:create(t, scene) elseif index == Transition_Table.CCTransitionRotoZoom then - scene = CCTransitionRotoZoom:create(t, scene) + scene = cc.TransitionRotoZoom:create(t, scene) elseif index == Transition_Table.CCTransitionMoveInL then - scene = CCTransitionMoveInL:create(t, scene) + scene = cc.TransitionMoveInL:create(t, scene) elseif index == Transition_Table.CCTransitionMoveInR then - scene = CCTransitionMoveInR:create(t, scene) + scene = cc.TransitionMoveInR:create(t, scene) elseif index == Transition_Table.CCTransitionMoveInT then - scene = CCTransitionMoveInT:create(t, scene) + scene = cc.TransitionMoveInT:create(t, scene) elseif index == Transition_Table.CCTransitionMoveInB then - scene = CCTransitionMoveInB:create(t, scene) + scene = cc.TransitionMoveInB:create(t, scene) elseif index == Transition_Table.CCTransitionSlideInL then - scene = CCTransitionSlideInL:create(t, scene) + scene = cc.TransitionSlideInL:create(t, scene) elseif index == Transition_Table.CCTransitionSlideInR then - scene = CCTransitionSlideInR:create(t, scene) + scene = cc.TransitionSlideInR:create(t, scene) elseif index == Transition_Table.CCTransitionSlideInT then - scene = CCTransitionSlideInT:create(t, scene) + scene = cc.TransitionSlideInT:create(t, scene) elseif index == Transition_Table.CCTransitionSlideInB then - scene = CCTransitionSlideInB:create(t, scene) + scene = cc.TransitionSlideInB:create(t, scene) end return scene end function generateTranScene() - local scene = CCScene:create() + local scene = cc.Scene:create() local layer = nil if CurSceneNo == 1 then @@ -255,7 +255,7 @@ end function TransitionsTest() cclog("TransitionsTest") - local scene = CCScene:create() + local scene = cc.Scene:create() SceneIdx = -1 CurSceneNo = 2 diff --git a/samples/Lua/TestLua/Resources/luaScript/UserDefaultTest/UserDefaultTest.lua b/samples/Lua/TestLua/Resources/luaScript/UserDefaultTest/UserDefaultTest.lua index 9a4ad1e713..beab70922e 100644 --- a/samples/Lua/TestLua/Resources/luaScript/UserDefaultTest/UserDefaultTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/UserDefaultTest/UserDefaultTest.lua @@ -6,62 +6,62 @@ local function doTest() -- set default value - CCUserDefault:getInstance():setStringForKey("string", "value1") - CCUserDefault:getInstance():setIntegerForKey("integer", 10) - CCUserDefault:getInstance():setFloatForKey("float", 2.3) - CCUserDefault:getInstance():setDoubleForKey("double", 2.4) - CCUserDefault:getInstance():setBoolForKey("bool", true) + cc.UserDefault:getInstance():setStringForKey("string", "value1") + cc.UserDefault:getInstance():setIntegerForKey("integer", 10) + cc.UserDefault:getInstance():setFloatForKey("float", 2.3) + cc.UserDefault:getInstance():setDoubleForKey("double", 2.4) + cc.UserDefault:getInstance():setBoolForKey("bool", true) -- print value - local ret = CCUserDefault:getInstance():getStringForKey("string") + local ret = cc.UserDefault:getInstance():getStringForKey("string") cclog("string is %s", ret) - local d = CCUserDefault:getInstance():getDoubleForKey("double") + local d = cc.UserDefault:getInstance():getDoubleForKey("double") cclog("double is %f", d) - local i = CCUserDefault:getInstance():getIntegerForKey("integer") + local i = cc.UserDefault:getInstance():getIntegerForKey("integer") cclog("integer is %d", i) - local f = CCUserDefault:getInstance():getFloatForKey("float") + local f = cc.UserDefault:getInstance():getFloatForKey("float") cclog("float is %f", f) - local b = CCUserDefault:getInstance():getBoolForKey("bool") + local b = cc.UserDefault:getInstance():getBoolForKey("bool") if b == true then cclog("bool is true") else cclog("bool is false") end - --CCUserDefault:getInstance():flush() + --cc.UserDefault:getInstance():flush() cclog("********************** after change value ***********************") -- change the value - CCUserDefault:getInstance():setStringForKey("string", "value2") - CCUserDefault:getInstance():setIntegerForKey("integer", 11) - CCUserDefault:getInstance():setFloatForKey("float", 2.5) - CCUserDefault:getInstance():setDoubleForKey("double", 2.6) - CCUserDefault:getInstance():setBoolForKey("bool", false) + cc.UserDefault:getInstance():setStringForKey("string", "value2") + cc.UserDefault:getInstance():setIntegerForKey("integer", 11) + cc.UserDefault:getInstance():setFloatForKey("float", 2.5) + cc.UserDefault:getInstance():setDoubleForKey("double", 2.6) + cc.UserDefault:getInstance():setBoolForKey("bool", false) - CCUserDefault:getInstance():flush() + cc.UserDefault:getInstance():flush() -- print value - ret = CCUserDefault:getInstance():getStringForKey("string") + ret = cc.UserDefault:getInstance():getStringForKey("string") cclog("string is %s", ret) - d = CCUserDefault:getInstance():getDoubleForKey("double") + d = cc.UserDefault:getInstance():getDoubleForKey("double") cclog("double is %f", d) - i = CCUserDefault:getInstance():getIntegerForKey("integer") + i = cc.UserDefault:getInstance():getIntegerForKey("integer") cclog("integer is %d", i) - f = CCUserDefault:getInstance():getFloatForKey("float") + f = cc.UserDefault:getInstance():getFloatForKey("float") cclog("float is %f", f) - b = CCUserDefault:getInstance():getBoolForKey("bool") + b = cc.UserDefault:getInstance():getBoolForKey("bool") if b == true then cclog("bool is true") else @@ -70,11 +70,11 @@ local function doTest() end function UserDefaultTestMain() - local ret = CCScene:create() - local s = CCDirector:getInstance():getWinSize() - local label = CCLabelTTF:create("CCUserDefault test see log", "Arial", 28) + local ret = cc.Scene:create() + local s = cc.Director:getInstance():getWinSize() + local label = cc.LabelTTF:create("UserDefault test see log", "Arial", 28) ret:addChild(label, 0) - label:setPosition( CCPoint(s.width/2, s.height-50) ) + label:setPosition( cc.p(s.width/2, s.height-50) ) doTest() return ret end diff --git a/samples/Lua/TestLua/Resources/luaScript/ZwoptexTest/ZwoptexTest.lua b/samples/Lua/TestLua/Resources/luaScript/ZwoptexTest/ZwoptexTest.lua index e7b6b1710b..a84dbbf085 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ZwoptexTest/ZwoptexTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ZwoptexTest/ZwoptexTest.lua @@ -1,4 +1,4 @@ -local scheduler = CCDirector:getInstance():getScheduler() +local scheduler = cc.Director:getInstance():getScheduler() -------------------------------------------------------------------- -- -- ZwoptexGenericTest @@ -9,33 +9,33 @@ local function ZwoptexGenericTest() "Coordinate Formats, Rotation, Trimming, flipX/Y") local spriteFrameIndex = 0 local counter = 0 - local s = CCDirector:getInstance():getWinSize() + local s = cc.Director:getInstance():getWinSize() local schedulerEntry = nil local schedulerFlipSpriteEntry = nil local sprite1 = nil local sprite2 = nil local function onEnter() - CCSpriteFrameCache:getInstance():addSpriteFramesWithFile("zwoptex/grossini.plist") - CCSpriteFrameCache:getInstance():addSpriteFramesWithFile("zwoptex/grossini-generic.plist") + cc.SpriteFrameCache:getInstance():addSpriteFrames("zwoptex/grossini.plist") + cc.SpriteFrameCache:getInstance():addSpriteFrames("zwoptex/grossini-generic.plist") - local layer1 = CCLayerColor:create(Color4B(255, 0, 0, 255), 85, 121) - layer1:setPosition(CCPoint(s.width/2-80 - (85.0 * 0.5), s.height/2 - (121.0 * 0.5))) + local layer1 = cc.LayerColor:create(cc.c4b(255, 0, 0, 255), 85, 121) + layer1:setPosition(cc.p(s.width/2-80 - (85.0 * 0.5), s.height/2 - (121.0 * 0.5))) ret:addChild(layer1) - sprite1 = CCSprite:createWithSpriteFrame(CCSpriteFrameCache:getInstance():getSpriteFrameByName("grossini_dance_01.png")) - sprite1:setPosition(CCPoint( s.width/2-80, s.height/2)) + sprite1 = cc.Sprite:createWithSpriteFrame(cc.SpriteFrameCache:getInstance():getSpriteFrame("grossini_dance_01.png")) + sprite1:setPosition(cc.p( s.width/2-80, s.height/2)) ret:addChild(sprite1) sprite1:setFlipX(false) sprite1:setFlipY(false) - local layer2 = CCLayerColor:create(Color4B(255, 0, 0, 255), 85, 121) - layer2:setPosition(CCPoint(s.width/2+80 - (85.0 * 0.5), s.height/2 - (121.0 * 0.5))) + local layer2 = cc.LayerColor:create(cc.c4b(255, 0, 0, 255), 85, 121) + layer2:setPosition(cc.p(s.width/2+80 - (85.0 * 0.5), s.height/2 - (121.0 * 0.5))) ret:addChild(layer2) - sprite2 = CCSprite:createWithSpriteFrame(CCSpriteFrameCache:getInstance():getSpriteFrameByName("grossini_dance_generic_01.png")) - sprite2:setPosition(CCPoint( s.width/2 + 80, s.height/2)) + sprite2 = cc.Sprite:createWithSpriteFrame(cc.SpriteFrameCache:getInstance():getSpriteFrame("grossini_dance_generic_01.png")) + sprite2:setPosition(cc.p( s.width/2 + 80, s.height/2)) ret:addChild(sprite2) sprite2:setFlipX(false) @@ -74,8 +74,8 @@ local function ZwoptexGenericTest() local str1 = string.format("grossini_dance_%02d.png", spriteFrameIndex) local str2 = string.format("grossini_dance_generic_%02d.png", spriteFrameIndex) - sprite1:setDisplayFrame(CCSpriteFrameCache:getInstance():getSpriteFrameByName(str1)) - sprite2:setDisplayFrame(CCSpriteFrameCache:getInstance():getSpriteFrameByName(str2)) + sprite1:setDisplayFrame(cc.SpriteFrameCache:getInstance():getSpriteFrame(str1)) + sprite2:setDisplayFrame(cc.SpriteFrameCache:getInstance():getSpriteFrame(str2)) end sprite1:retain() @@ -97,7 +97,7 @@ local function ZwoptexGenericTest() end sprite1:release() sprite2:release() - local cache = CCSpriteFrameCache:getInstance() + local cache = cc.SpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("zwoptex/grossini.plist") cache:removeSpriteFramesFromFile("zwoptex/grossini-generic.plist") end @@ -118,7 +118,7 @@ end function ZwoptexTestMain() cclog("ZwoptexTestMain") Helper.index = 1 - local scene = CCScene:create() + local scene = cc.Scene:create() Helper.createFunctionTable = { ZwoptexGenericTest } diff --git a/samples/Lua/TestLua/Resources/luaScript/extern.lua b/samples/Lua/TestLua/Resources/luaScript/extern.lua index 60c03ba54a..172db1a9ed 100644 --- a/samples/Lua/TestLua/Resources/luaScript/extern.lua +++ b/samples/Lua/TestLua/Resources/luaScript/extern.lua @@ -60,16 +60,16 @@ function class(classname, super) end function schedule(node, callback, delay) - local delay = CCDelayTime:create(delay) - local sequence = CCSequence:createWithTwoActions(delay, CCCallFunc:create(callback)) - local action = CCRepeatForever:create(sequence) + local delay = cc.DelayTime:create(delay) + local sequence = cc.Sequence:create(delay, cc.CallFunc:create(callback)) + local action = cc.RepeatForever:create(sequence) node:runAction(action) return action end function performWithDelay(node, callback, delay) - local delay = CCDelayTime:create(delay) - local sequence = CCSequence:createWithTwoActions(delay, CCCallFunc:create(callback)) + local delay = cc.DelayTime:create(delay) + local sequence = cc.Sequence:create(delay, cc.CallFunc:create(callback)) node:runAction(sequence) return sequence end diff --git a/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua b/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua index a68bb24f2c..1e2bb48e4f 100644 --- a/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua +++ b/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua @@ -8,6 +8,7 @@ require "luaScript/helper" require "luaScript/testResource" require "luaScript/VisibleRect" +require "luaScript/AccelerometerTest/AccelerometerTest" require "luaScript/ActionManagerTest/ActionManagerTest" require "luaScript/ActionsEaseTest/ActionsEaseTest" require "luaScript/ActionsProgressTest/ActionsProgressTest" @@ -19,35 +20,30 @@ require "luaScript/CurrentLanguageTest/CurrentLanguageTest" require "luaScript/DrawPrimitivesTest/DrawPrimitivesTest" require "luaScript/EffectsTest/EffectsTest" require "luaScript/EffectsAdvancedTest/EffectsAdvancedTest" +require "luaScript/ExtensionTest/ExtensionTest" require "luaScript/FontTest/FontTest" require "luaScript/IntervalTest/IntervalTest" require "luaScript/KeypadTest/KeypadTest" require "luaScript/LabelTest/LabelTest" require "luaScript/LayerTest/LayerTest" - ---[[ -require "luaScript/TransitionsTest/TransitionsTest" -require "luaScript/RotateWorldTest/RotateWorldTest" -require "luaScript/ParticleTest/ParticleTest" +require "luaScript/MenuTest/MenuTest" require "luaScript/MotionStreakTest/MotionStreakTest" require "luaScript/NodeTest/NodeTest" -require "luaScript/TouchesTest/TouchesTest" -require "luaScript/SpriteTest/SpriteTest" - -require "luaScript/PerformanceTest/PerformanceTest" +require "luaScript/OpenGLTest/OpenGLTest" require "luaScript/ParallaxTest/ParallaxTest" -require "luaScript/TileMapTest/TileMapTest" - -require "luaScript/MenuTest/MenuTest" +require "luaScript/ParticleTest/ParticleTest" +require "luaScript/PerformanceTest/PerformanceTest" +require "luaScript/RenderTextureTest/RenderTextureTest" +require "luaScript/RotateWorldTest/RotateWorldTest" +require "luaScript/SpriteTest/SpriteTest" require "luaScript/SceneTest/SceneTest" require "luaScript/Texture2dTest/Texture2dTest" -require "luaScript/RenderTextureTest/RenderTextureTest" -require "luaScript/ZwoptexTest/ZwoptexTest" +require "luaScript/TileMapTest/TileMapTest" +require "luaScript/TouchesTest/TouchesTest" +require "luaScript/TransitionsTest/TransitionsTest" require "luaScript/UserDefaultTest/UserDefaultTest" -require "luaScript/ExtensionTest/ExtensionTest" -require "luaScript/AccelerometerTest/AccelerometerTest" -require "luaScript/OpenGLTest/OpenGLTest" -]]-- +require "luaScript/ZwoptexTest/ZwoptexTest" + local LINE_SPACE = 40 diff --git a/scripting/lua/cocos2dx_support/CCLuaStack.cpp b/scripting/lua/cocos2dx_support/CCLuaStack.cpp index e8ff07d4dc..c342250d9f 100644 --- a/scripting/lua/cocos2dx_support/CCLuaStack.cpp +++ b/scripting/lua/cocos2dx_support/CCLuaStack.cpp @@ -49,6 +49,7 @@ extern "C" { #include "lua_cocos2dx_auto.hpp" #include "lua_cocos2dx_extension_auto.hpp" #include "lua_cocos2dx_manual.hpp" +#include "LuaBasicConversions.h" namespace { int lua_print(lua_State * luastate) @@ -125,6 +126,7 @@ bool LuaStack::init(void) {NULL, NULL} }; luaL_register(_state, "_G", global_functions); + g_luaType.clear(); register_all_cocos2dx(_state); tolua_opengl_open(_state); register_all_cocos2dx_extension(_state); diff --git a/scripting/lua/cocos2dx_support/LuaBasicConversions.cpp b/scripting/lua/cocos2dx_support/LuaBasicConversions.cpp index e26a3d41df..27b8888883 100644 --- a/scripting/lua/cocos2dx_support/LuaBasicConversions.cpp +++ b/scripting/lua/cocos2dx_support/LuaBasicConversions.cpp @@ -23,9 +23,16 @@ ****************************************************************************/ #include "LuaBasicConversions.h" + +#ifdef __cplusplus extern "C" { -#include "tolua++.h" +#endif +#include "tolua_fix.h" +#ifdef __cplusplus } +#endif + +std::map g_luaType; #if COCOS2D_DEBUG >=1 void luaval_to_native_err(lua_State* L,const char* msg,tolua_Error* err) @@ -881,6 +888,50 @@ bool luaval_to_array_of_Point(lua_State* L,int lo,Point **points, int *numPoints return ok; } + +bool luavals_variadic_to_array(lua_State* L,int argc, Array** ret) +{ + if (nullptr == L || argc == 0 ) + return false; + + bool ok = true; + + Array* array = Array::create(); + for (int i = 0; i < argc; i++) + { + double num = 0.0; + if (lua_isnumber(L, i + 2)) + { + ok &= luaval_to_number(L, i + 2, &num); + if (!ok) + break; + + array->addObject(Integer::create((int)num)); + } + else if (lua_isstring(L, i + 2)) + { + std::string str = lua_tostring(L, i + 2); + array->addObject(String::create(str)); + } + else if (lua_isuserdata(L, i + 2)) + { + tolua_Error err; + if (!tolua_isusertype(L, i + 2, "Object", 0, &err)) + { + luaval_to_native_err(L,"#ferror:",&err); + ok = false; + break; + } + Object* obj = static_cast(tolua_tousertype(L, i + 2, nullptr)); + array->addObject(obj); + } + } + + *ret = array; + + return ok; +} + void point_to_luaval(lua_State* L,const Point& pt) { if (NULL == L) @@ -1064,171 +1115,171 @@ void fontdefinition_to_luaval(lua_State* L,const FontDefinition& inValue) void array_to_luaval(lua_State* L,Array* inValue) { - if (NULL == L || NULL == inValue) + if (nullptr == L || nullptr == inValue) return; - if (0 == inValue->count() ) - return; - - Object* obj = NULL; + Object* obj = nullptr; lua_newtable(L); std::string className = ""; - int pos = 0; - String* strVal = NULL; - Dictionary* dictVal = NULL; - Array* arrVal = NULL; - Double* doubleVal = NULL; - Bool* boolVal = NULL; - Float* floatVal = NULL; - Integer* intVal = NULL; + String* strVal = nullptr; + Dictionary* dictVal = nullptr; + Array* arrVal = nullptr; + Double* doubleVal = nullptr; + Bool* boolVal = nullptr; + Float* floatVal = nullptr; + Integer* intVal = nullptr; + int indexTable = 1; CCARRAY_FOREACH(inValue, obj) { - if (NULL == obj) + if (nullptr == obj) continue; - className = typeid(*obj).name(); - pos = className.rfind(":"); - if (pos > 0 && pos + 1 < className.length() ) + uint32_t typeId = cocos2d::getHashCodeByString(typeid(*obj).name()); + auto iter = g_luaType.find(typeId); + if (g_luaType.end() != iter) { - className = className.substr(pos + 1, std::string::npos); - - luaL_getmetatable(L, className.c_str()); /* stack: table mt */ - - if (!lua_isnil(L, -1)) + className = iter->second; + if (nullptr != dynamic_cast(obj)) { - lua_pop(L, 1); - tolua_pushusertype(L, (void*)obj, className.c_str()); - } - else - { - lua_pop(L, -1); - if((strVal = dynamic_cast(obj))) - { - lua_pushstring(L, strVal->getCString()); - } - else if ((dictVal = dynamic_cast(obj))) - { - dictionary_to_luaval(L, dictVal); - } - else if ((arrVal = dynamic_cast(obj))) - { - array_to_luaval(L, arrVal); - } - else if ((doubleVal = dynamic_cast(obj))) - { - lua_pushnumber(L, (lua_Number)doubleVal->getValue()); - } - else if ((floatVal = dynamic_cast(obj))) - { - lua_pushnumber(L, (lua_Number)floatVal->getValue()); - } - else if ((intVal = dynamic_cast(obj))) - { - lua_pushinteger(L, (lua_Integer)intVal->getValue()); - } - else if ((boolVal = dynamic_cast(obj))) - { - lua_pushboolean(L, boolVal->getValue()); - } else - { - CCASSERT(false, "the type isn't suppored."); - } + lua_pushnumber(L, (lua_Number)indexTable); + int ID = (obj) ? (int)obj->_ID : -1; + int* luaID = (obj) ? &obj->_luaID : NULL; + toluafix_pushusertype_ccobject(L, ID, luaID, (void*)obj,className.c_str()); + lua_rawset(L, -3); + obj->retain(); + ++indexTable; } } + else if((strVal = dynamic_cast(obj))) + { + lua_pushnumber(L, (lua_Number)indexTable); + lua_pushstring(L, strVal->getCString()); + lua_rawset(L, -3); + ++indexTable; + } + else if ((dictVal = dynamic_cast(obj))) + { + dictionary_to_luaval(L, dictVal); + } + else if ((arrVal = dynamic_cast(obj))) + { + array_to_luaval(L, arrVal); + } + else if ((doubleVal = dynamic_cast(obj))) + { + lua_pushnumber(L, (lua_Number)indexTable); + lua_pushnumber(L, (lua_Number)doubleVal->getValue()); + lua_rawset(L, -3); + ++indexTable; + } + else if ((floatVal = dynamic_cast(obj))) + { + lua_pushnumber(L, (lua_Number)indexTable); + lua_pushnumber(L, (lua_Number)floatVal->getValue()); + lua_rawset(L, -3); + ++indexTable; + } + else if ((intVal = dynamic_cast(obj))) + { + lua_pushnumber(L, (lua_Number)indexTable); + lua_pushinteger(L, (lua_Integer)intVal->getValue()); + lua_rawset(L, -3); + ++indexTable; + } + else if ((boolVal = dynamic_cast(obj))) + { + lua_pushnumber(L, (lua_Number)indexTable); + lua_pushboolean(L, boolVal->getValue()); + lua_rawset(L, -3); + ++indexTable; + } + else + { + CCASSERT(false, "the type isn't suppored."); + } } } void dictionary_to_luaval(lua_State* L, Dictionary* dict) { - if (NULL == L || NULL == dict) + if (nullptr == L || nullptr == dict) return; - if (0 == dict->count() ) - return; - - DictElement* element = NULL; + DictElement* element = nullptr; lua_newtable(L); std::string className = ""; - int pos = 0; - String* strVal = NULL; - Dictionary* dictVal = NULL; - Array* arrVal = NULL; - Double* doubleVal = NULL; - Bool* boolVal = NULL; - Float* floatVal = NULL; - Integer* intVal = NULL; - Object* obj = NULL; + String* strVal = nullptr; + Dictionary* dictVal = nullptr; + Array* arrVal = nullptr; + Double* doubleVal = nullptr; + Bool* boolVal = nullptr; + Float* floatVal = nullptr; + Integer* intVal = nullptr; CCDICT_FOREACH(dict, element) { if (NULL == element) continue; - className = typeid(*element).name(); - pos = className.rfind(":"); - if (pos > 0 && pos + 1 < className.length() ) + uint32_t typeId = cocos2d::getHashCodeByString(typeid(element->getObject()).name()); + auto iter = g_luaType.find(typeId); + if (g_luaType.end() != iter) { - obj = element->getObject(); - if (NULL == obj) - continue; - - className = className.substr(pos + 1, std::string::npos); - - luaL_getmetatable(L, className.c_str()); /* stack: table mt */ - if (!lua_isnil(L, -1)) + className = iter->second; + if ( nullptr != dynamic_cast(element->getObject())) { - lua_pop(L, 1); - tolua_pushusertype(L, (void*)obj, className.c_str()); - } - else - { - lua_pop(L, -1); - if((strVal = dynamic_cast(obj))) - { - lua_pushstring(L, element->getStrKey()); - lua_pushstring(L, strVal->getCString()); - lua_rawset(L, -3); - } - else if ((dictVal = dynamic_cast(obj))) - { - dictionary_to_luaval(L, dictVal); - } - else if ((arrVal = dynamic_cast(obj))) - { - array_to_luaval(L, arrVal); - } - else if ((doubleVal = dynamic_cast(obj))) - { - lua_pushstring(L, element->getStrKey()); - lua_pushnumber(L, (lua_Number)doubleVal->getValue()); - lua_rawset(L, -3); - } - else if ((floatVal = dynamic_cast(obj))) - { - lua_pushstring(L, element->getStrKey()); - lua_pushnumber(L, (lua_Number)floatVal->getValue()); - lua_rawset(L, -3); - } - else if ((intVal = dynamic_cast(obj))) - { - lua_pushstring(L, element->getStrKey()); - lua_pushinteger(L, (lua_Integer)intVal->getValue()); - lua_rawset(L, -3); - } - else if ((boolVal = dynamic_cast(obj))) - { - lua_pushstring(L, element->getStrKey()); - lua_pushboolean(L, boolVal->getValue()); - lua_rawset(L, -3); - } - else - { - CCASSERT(false, "the type isn't suppored."); - } + lua_pushstring(L, element->getStrKey()); + int ID = (element->getObject()) ? (int)element->getObject()->_ID : -1; + int* luaID = (element->getObject()) ? &(element->getObject()->_luaID) : NULL; + toluafix_pushusertype_ccobject(L, ID, luaID, (void*)element->getObject(),className.c_str()); + lua_rawset(L, -3); + element->getObject()->retain(); } } + else if((strVal = dynamic_cast(element->getObject()))) + { + lua_pushstring(L, element->getStrKey()); + lua_pushstring(L, strVal->getCString()); + lua_rawset(L, -3); + } + else if ((dictVal = dynamic_cast(element->getObject()))) + { + dictionary_to_luaval(L, dictVal); + } + else if ((arrVal = dynamic_cast(element->getObject()))) + { + array_to_luaval(L, arrVal); + } + else if ((doubleVal = dynamic_cast(element->getObject()))) + { + lua_pushstring(L, element->getStrKey()); + lua_pushnumber(L, (lua_Number)doubleVal->getValue()); + lua_rawset(L, -3); + } + else if ((floatVal = dynamic_cast(element->getObject()))) + { + lua_pushstring(L, element->getStrKey()); + lua_pushnumber(L, (lua_Number)floatVal->getValue()); + lua_rawset(L, -3); + } + else if ((intVal = dynamic_cast(element->getObject()))) + { + lua_pushstring(L, element->getStrKey()); + lua_pushinteger(L, (lua_Integer)intVal->getValue()); + lua_rawset(L, -3); + } + else if ((boolVal = dynamic_cast(element->getObject()))) + { + lua_pushstring(L, element->getStrKey()); + lua_pushboolean(L, boolVal->getValue()); + lua_rawset(L, -3); + } + else + { + CCASSERT(false, "the type isn't suppored."); + } } } diff --git a/scripting/lua/cocos2dx_support/LuaBasicConversions.h b/scripting/lua/cocos2dx_support/LuaBasicConversions.h index bbd6dca25a..87171e0782 100644 --- a/scripting/lua/cocos2dx_support/LuaBasicConversions.h +++ b/scripting/lua/cocos2dx_support/LuaBasicConversions.h @@ -3,12 +3,19 @@ extern "C" { #include "lua.h" +#include "tolua++.h" } #include "cocos2d.h" using namespace cocos2d; +extern std::map g_luaType; + +#if COCOS2D_DEBUG >=1 +void luaval_to_native_err(lua_State* L,const char* msg,tolua_Error* err); +#endif + // to native extern bool luaval_to_int32(lua_State* L,int lo,int* outValue); extern bool luaval_to_uint32(lua_State* L, int lo, unsigned int* outValue); @@ -29,6 +36,7 @@ extern bool luaval_to_fontdefinition(lua_State* L, int lo, FontDefinition* outVa extern bool luaval_to_array(lua_State* L,int lo, Array** outValue); extern bool luaval_to_dictionary(lua_State* L,int lo, Dictionary** outValue); extern bool luaval_to_array_of_Point(lua_State* L,int lo,Point **points, int *numPoints); +extern bool luavals_variadic_to_array(lua_State* L,int argc, Array** ret); // from native extern void point_to_luaval(lua_State* L,const Point& pt); diff --git a/scripting/lua/cocos2dx_support/LuaOpengl.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/LuaOpengl.cpp.REMOVED.git-id index d3e9b8256b..1a95695d30 100644 --- a/scripting/lua/cocos2dx_support/LuaOpengl.cpp.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/LuaOpengl.cpp.REMOVED.git-id @@ -1 +1 @@ -faeffa101e0d6ba77fa19f3bd83b12a267209994 \ No newline at end of file +13bc27135b11b87249075c37897972a41802f216 \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id index 3199a451d6..58dc858cdf 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id @@ -1 +1 @@ -2a962b5abd27e8a47e73534fe2e521e181cc64be \ No newline at end of file +e29ba39a2c542d0e15e41231b795fadbdad66af3 \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.hpp b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.hpp index 69abad2a2d..9b672e575f 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.hpp +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.hpp @@ -1982,6 +1982,76 @@ int register_all_cocos2dx(lua_State* tolua_S); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id index 1ac1962780..81938e2d35 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id @@ -1 +1 @@ -4b98d069e4cc8f6af4dc2c64c6ec3fa2590bd927 \ No newline at end of file +171d6ef055d78d7211eb55d8a8de5eda09476d0a \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id index f01619e02a..627a599501 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id @@ -1 +1 @@ -a63246415c81d091a2eb88c4ba396b6d3c80c027 \ No newline at end of file +00379738c9ad94edf867bd46e85597812c340f29 \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.hpp b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.hpp index a2f3e2a6d3..727217721f 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.hpp +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.hpp @@ -246,6 +246,143 @@ int register_all_cocos2dx_extension(lua_State* tolua_S); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto_api.js b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto_api.js index da9e2d08bd..5b4f3a5b7c 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto_api.js +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto_api.js @@ -135,6 +135,12 @@ addOwnerOutletName : function () {}, */ getOwnerCallbackNames : function () {}, +/** + * @method addDocumentCallbackControlEvents + * @param {cocos2d::extension::Control::EventType} + */ +addDocumentCallbackControlEvents : function () {}, + /** * @method setCCBRootPath * @param {const char*} @@ -166,6 +172,12 @@ readSoundKeyframesForSeq : function () {}, */ getCCBRootPath : function () {}, +/** + * @method getOwnerCallbackControlEvents + * @return A value converted from C/C++ "cocos2d::Array*" + */ +getOwnerCallbackControlEvents : function () {}, + /** * @method getOwnerOutletNodes * @return A value converted from C/C++ "cocos2d::Array*" @@ -178,6 +190,12 @@ getOwnerOutletNodes : function () {}, */ readUTF8 : function () {}, +/** + * @method addOwnerCallbackControlEvents + * @param {cocos2d::extension::Control::EventType} + */ +addOwnerCallbackControlEvents : function () {}, + /** * @method getOwnerOutletNames * @return A value converted from C/C++ "cocos2d::Array*" @@ -1062,6 +1080,13 @@ getLastCompletedSequenceName : function () {}, */ setRootNode : function () {}, +/** + * @method runAnimationsForSequenceNamedTweenDuration + * @param {const char*} + * @param {float} + */ +runAnimationsForSequenceNamedTweenDuration : function () {}, + /** * @method addDocumentOutletName * @param {std::string} @@ -1106,6 +1131,12 @@ actionForCallbackChannel : function () {}, */ getDocumentOutletNames : function () {}, +/** + * @method addDocumentCallbackControlEvents + * @param {cocos2d::extension::Control::EventType} + */ +addDocumentCallbackControlEvents : function () {}, + /** * @method init * @return A value converted from C/C++ "bool" @@ -1119,11 +1150,10 @@ init : function () {}, getKeyframeCallbacks : function () {}, /** - * @method runAnimationsForSequenceNamedTweenDuration - * @param {const char*} - * @param {float} + * @method getDocumentCallbackControlEvents + * @return A value converted from C/C++ "cocos2d::Array*" */ -runAnimationsForSequenceNamedTweenDuration : function () {}, +getDocumentCallbackControlEvents : function () {}, /** * @method setRootContainerSize @@ -1232,6 +1262,828 @@ CCBAnimationManager : function () {}, }; +/** + * @class ControlHuePicker + */ +cc.ControlHuePicker = { + +/** + * @method setEnabled + * @param {bool} + */ +setEnabled : function () {}, + +/** + * @method initWithTargetAndPos + * @return A value converted from C/C++ "bool" + * @param {cocos2d::Node*} + * @param {cocos2d::Point} + */ +initWithTargetAndPos : function () {}, + +/** + * @method setHue + * @param {float} + */ +setHue : function () {}, + +/** + * @method getStartPos + * @return A value converted from C/C++ "cocos2d::Point" + */ +getStartPos : function () {}, + +/** + * @method getHue + * @return A value converted from C/C++ "float" + */ +getHue : function () {}, + +/** + * @method ccTouchBegan + * @return A value converted from C/C++ "bool" + * @param {cocos2d::Touch*} + * @param {cocos2d::Event*} + */ +ccTouchBegan : function () {}, + +/** + * @method setBackground + * @param {cocos2d::Sprite*} + */ +setBackground : function () {}, + +/** + * @method setHuePercentage + * @param {float} + */ +setHuePercentage : function () {}, + +/** + * @method getBackground + * @return A value converted from C/C++ "cocos2d::Sprite*" + */ +getBackground : function () {}, + +/** + * @method ccTouchMoved + * @param {cocos2d::Touch*} + * @param {cocos2d::Event*} + */ +ccTouchMoved : function () {}, + +/** + * @method getSlider + * @return A value converted from C/C++ "cocos2d::Sprite*" + */ +getSlider : function () {}, + +/** + * @method getHuePercentage + * @return A value converted from C/C++ "float" + */ +getHuePercentage : function () {}, + +/** + * @method setSlider + * @param {cocos2d::Sprite*} + */ +setSlider : function () {}, + +/** + * @method create + * @return A value converted from C/C++ "cocos2d::extension::ControlHuePicker*" + * @param {cocos2d::Node*} + * @param {cocos2d::Point} + */ +create : function () {}, + +/** + * @method ControlHuePicker + * @constructor + */ +ControlHuePicker : function () {}, + +}; + +/** + * @class ControlSaturationBrightnessPicker + */ +cc.ControlSaturationBrightnessPicker = { + +/** + * @method getShadow + * @return A value converted from C/C++ "cocos2d::Sprite*" + */ +getShadow : function () {}, + +/** + * @method initWithTargetAndPos + * @return A value converted from C/C++ "bool" + * @param {cocos2d::Node*} + * @param {cocos2d::Point} + */ +initWithTargetAndPos : function () {}, + +/** + * @method getStartPos + * @return A value converted from C/C++ "cocos2d::Point" + */ +getStartPos : function () {}, + +/** + * @method getOverlay + * @return A value converted from C/C++ "cocos2d::Sprite*" + */ +getOverlay : function () {}, + +/** + * @method setEnabled + * @param {bool} + */ +setEnabled : function () {}, + +/** + * @method getSlider + * @return A value converted from C/C++ "cocos2d::Sprite*" + */ +getSlider : function () {}, + +/** + * @method getBackground + * @return A value converted from C/C++ "cocos2d::Sprite*" + */ +getBackground : function () {}, + +/** + * @method getSaturation + * @return A value converted from C/C++ "float" + */ +getSaturation : function () {}, + +/** + * @method getBrightness + * @return A value converted from C/C++ "float" + */ +getBrightness : function () {}, + +/** + * @method create + * @return A value converted from C/C++ "cocos2d::extension::ControlSaturationBrightnessPicker*" + * @param {cocos2d::Node*} + * @param {cocos2d::Point} + */ +create : function () {}, + +/** + * @method ControlSaturationBrightnessPicker + * @constructor + */ +ControlSaturationBrightnessPicker : function () {}, + +}; + +/** + * @class ControlColourPicker + */ +cc.ControlColourPicker = { + +/** + * @method setEnabled + * @param {bool} + */ +setEnabled : function () {}, + +/** + * @method getHuePicker + * @return A value converted from C/C++ "cocos2d::extension::ControlHuePicker*" + */ +getHuePicker : function () {}, + +/** + * @method setColor + * @param {cocos2d::Color3B} + */ +setColor : function () {}, + +/** + * @method hueSliderValueChanged + * @param {cocos2d::Object*} + * @param {cocos2d::extension::Control::EventType} + */ +hueSliderValueChanged : function () {}, + +/** + * @method getcolourPicker + * @return A value converted from C/C++ "cocos2d::extension::ControlSaturationBrightnessPicker*" + */ +getcolourPicker : function () {}, + +/** + * @method setBackground + * @param {cocos2d::Sprite*} + */ +setBackground : function () {}, + +/** + * @method init + * @return A value converted from C/C++ "bool" + */ +init : function () {}, + +/** + * @method setcolourPicker + * @param {cocos2d::extension::ControlSaturationBrightnessPicker*} + */ +setcolourPicker : function () {}, + +/** + * @method colourSliderValueChanged + * @param {cocos2d::Object*} + * @param {cocos2d::extension::Control::EventType} + */ +colourSliderValueChanged : function () {}, + +/** + * @method setHuePicker + * @param {cocos2d::extension::ControlHuePicker*} + */ +setHuePicker : function () {}, + +/** + * @method getBackground + * @return A value converted from C/C++ "cocos2d::Sprite*" + */ +getBackground : function () {}, + +/** + * @method create + * @return A value converted from C/C++ "cocos2d::extension::ControlColourPicker*" + */ +create : function () {}, + +/** + * @method ControlColourPicker + * @constructor + */ +ControlColourPicker : function () {}, + +}; + +/** + * @class ControlPotentiometer + */ +cc.ControlPotentiometer = { + +/** + * @method setPreviousLocation + * @param {cocos2d::Point} + */ +setPreviousLocation : function () {}, + +/** + * @method setProgressTimer + * @param {cocos2d::ProgressTimer*} + */ +setProgressTimer : function () {}, + +/** + * @method potentiometerMoved + * @param {cocos2d::Point} + */ +potentiometerMoved : function () {}, + +/** + * @method ccTouchEnded + * @param {cocos2d::Touch*} + * @param {cocos2d::Event*} + */ +ccTouchEnded : function () {}, + +/** + * @method getMinimumValue + * @return A value converted from C/C++ "float" + */ +getMinimumValue : function () {}, + +/** + * @method setThumbSprite + * @param {cocos2d::Sprite*} + */ +setThumbSprite : function () {}, + +/** + * @method ccTouchMoved + * @param {cocos2d::Touch*} + * @param {cocos2d::Event*} + */ +ccTouchMoved : function () {}, + +/** + * @method ccTouchBegan + * @return A value converted from C/C++ "bool" + * @param {cocos2d::Touch*} + * @param {cocos2d::Event*} + */ +ccTouchBegan : function () {}, + +/** + * @method setEnabled + * @param {bool} + */ +setEnabled : function () {}, + +/** + * @method setValue + * @param {float} + */ +setValue : function () {}, + +/** + * @method setMaximumValue + * @param {float} + */ +setMaximumValue : function () {}, + +/** + * @method setMinimumValue + * @param {float} + */ +setMinimumValue : function () {}, + +/** + * @method potentiometerEnded + * @param {cocos2d::Point} + */ +potentiometerEnded : function () {}, + +/** + * @method distanceBetweenPointAndPoint + * @return A value converted from C/C++ "float" + * @param {cocos2d::Point} + * @param {cocos2d::Point} + */ +distanceBetweenPointAndPoint : function () {}, + +/** + * @method getProgressTimer + * @return A value converted from C/C++ "cocos2d::ProgressTimer*" + */ +getProgressTimer : function () {}, + +/** + * @method getMaximumValue + * @return A value converted from C/C++ "float" + */ +getMaximumValue : function () {}, + +/** + * @method angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint + * @return A value converted from C/C++ "float" + * @param {cocos2d::Point} + * @param {cocos2d::Point} + * @param {cocos2d::Point} + * @param {cocos2d::Point} + */ +angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint : function () {}, + +/** + * @method isTouchInside + * @return A value converted from C/C++ "bool" + * @param {cocos2d::Touch*} + */ +isTouchInside : function () {}, + +/** + * @method getValue + * @return A value converted from C/C++ "float" + */ +getValue : function () {}, + +/** + * @method potentiometerBegan + * @param {cocos2d::Point} + */ +potentiometerBegan : function () {}, + +/** + * @method getThumbSprite + * @return A value converted from C/C++ "cocos2d::Sprite*" + */ +getThumbSprite : function () {}, + +/** + * @method initWithTrackSprite_ProgressTimer_ThumbSprite + * @return A value converted from C/C++ "bool" + * @param {cocos2d::Sprite*} + * @param {cocos2d::ProgressTimer*} + * @param {cocos2d::Sprite*} + */ +initWithTrackSprite_ProgressTimer_ThumbSprite : function () {}, + +/** + * @method getPreviousLocation + * @return A value converted from C/C++ "cocos2d::Point" + */ +getPreviousLocation : function () {}, + +/** + * @method create + * @return A value converted from C/C++ "cocos2d::extension::ControlPotentiometer*" + * @param {const char*} + * @param {const char*} + * @param {const char*} + */ +create : function () {}, + +/** + * @method ControlPotentiometer + * @constructor + */ +ControlPotentiometer : function () {}, + +}; + +/** + * @class ControlSlider + */ +cc.ControlSlider = { + +/** + * @method locationFromTouch + * @return A value converted from C/C++ "cocos2d::Point" + * @param {cocos2d::Touch*} + */ +locationFromTouch : function () {}, + +/** + * @method setProgressSprite + * @param {cocos2d::Sprite*} + */ +setProgressSprite : function () {}, + +/** + * @method getMaximumAllowedValue + * @return A value converted from C/C++ "float" + */ +getMaximumAllowedValue : function () {}, + +/** + * @method getMinimumAllowedValue + * @return A value converted from C/C++ "float" + */ +getMinimumAllowedValue : function () {}, + +/** + * @method getMinimumValue + * @return A value converted from C/C++ "float" + */ +getMinimumValue : function () {}, + +/** + * @method setThumbSprite + * @param {cocos2d::Sprite*} + */ +setThumbSprite : function () {}, + +/** + * @method setMinimumValue + * @param {float} + */ +setMinimumValue : function () {}, + +/** + * @method setMinimumAllowedValue + * @param {float} + */ +setMinimumAllowedValue : function () {}, + +/** + * @method setEnabled + * @param {bool} + */ +setEnabled : function () {}, + +/** + * @method setValue + * @param {float} + */ +setValue : function () {}, + +/** + * @method setMaximumValue + * @param {float} + */ +setMaximumValue : function () {}, + +/** + * @method needsLayout + */ +needsLayout : function () {}, + +/** + * @method getBackgroundSprite + * @return A value converted from C/C++ "cocos2d::Sprite*" + */ +getBackgroundSprite : function () {}, + +/** + * @method initWithSprites + * @return A value converted from C/C++ "bool" + * @param {cocos2d::Sprite*} + * @param {cocos2d::Sprite*} + * @param {cocos2d::Sprite*} + */ +initWithSprites : function () {}, + +/** + * @method getMaximumValue + * @return A value converted from C/C++ "float" + */ +getMaximumValue : function () {}, + +/** + * @method isTouchInside + * @return A value converted from C/C++ "bool" + * @param {cocos2d::Touch*} + */ +isTouchInside : function () {}, + +/** + * @method getValue + * @return A value converted from C/C++ "float" + */ +getValue : function () {}, + +/** + * @method getThumbSprite + * @return A value converted from C/C++ "cocos2d::Sprite*" + */ +getThumbSprite : function () {}, + +/** + * @method getProgressSprite + * @return A value converted from C/C++ "cocos2d::Sprite*" + */ +getProgressSprite : function () {}, + +/** + * @method setBackgroundSprite + * @param {cocos2d::Sprite*} + */ +setBackgroundSprite : function () {}, + +/** + * @method setMaximumAllowedValue + * @param {float} + */ +setMaximumAllowedValue : function () {}, + +/** + * @method ControlSlider + * @constructor + */ +ControlSlider : function () {}, + +}; + +/** + * @class ControlStepper + */ +cc.ControlStepper = { + +/** + * @method setMinusSprite + * @param {cocos2d::Sprite*} + */ +setMinusSprite : function () {}, + +/** + * @method ccTouchBegan + * @return A value converted from C/C++ "bool" + * @param {cocos2d::Touch*} + * @param {cocos2d::Event*} + */ +ccTouchBegan : function () {}, + +/** + * @method getMinusLabel + * @return A value converted from C/C++ "cocos2d::LabelTTF*" + */ +getMinusLabel : function () {}, + +/** + * @method setWraps + * @param {bool} + */ +setWraps : function () {}, + +/** + * @method ccTouchEnded + * @param {cocos2d::Touch*} + * @param {cocos2d::Event*} + */ +ccTouchEnded : function () {}, + +/** + * @method isContinuous + * @return A value converted from C/C++ "bool" + */ +isContinuous : function () {}, + +/** + * @method getMinusSprite + * @return A value converted from C/C++ "cocos2d::Sprite*" + */ +getMinusSprite : function () {}, + +/** + * @method updateLayoutUsingTouchLocation + * @param {cocos2d::Point} + */ +updateLayoutUsingTouchLocation : function () {}, + +/** + * @method setValueWithSendingEvent + * @param {double} + * @param {bool} + */ +setValueWithSendingEvent : function () {}, + +/** + * @method getPlusLabel + * @return A value converted from C/C++ "cocos2d::LabelTTF*" + */ +getPlusLabel : function () {}, + +/** + * @method stopAutorepeat + */ +stopAutorepeat : function () {}, + +/** + * @method ccTouchMoved + * @param {cocos2d::Touch*} + * @param {cocos2d::Event*} + */ +ccTouchMoved : function () {}, + +/** + * @method setMaximumValue + * @param {double} + */ +setMaximumValue : function () {}, + +/** + * @method setPlusSprite + * @param {cocos2d::Sprite*} + */ +setPlusSprite : function () {}, + +/** + * @method setMinusLabel + * @param {cocos2d::LabelTTF*} + */ +setMinusLabel : function () {}, + +/** + * @method setValue + * @param {double} + */ +setValue : function () {}, + +/** + * @method setStepValue + * @param {double} + */ +setStepValue : function () {}, + +/** + * @method getPlusSprite + * @return A value converted from C/C++ "cocos2d::Sprite*" + */ +getPlusSprite : function () {}, + +/** + * @method update + * @param {float} + */ +update : function () {}, + +/** + * @method setMinimumValue + * @param {double} + */ +setMinimumValue : function () {}, + +/** + * @method startAutorepeat + */ +startAutorepeat : function () {}, + +/** + * @method initWithMinusSpriteAndPlusSprite + * @return A value converted from C/C++ "bool" + * @param {cocos2d::Sprite*} + * @param {cocos2d::Sprite*} + */ +initWithMinusSpriteAndPlusSprite : function () {}, + +/** + * @method getValue + * @return A value converted from C/C++ "double" + */ +getValue : function () {}, + +/** + * @method setPlusLabel + * @param {cocos2d::LabelTTF*} + */ +setPlusLabel : function () {}, + +/** + * @method create + * @return A value converted from C/C++ "cocos2d::extension::ControlStepper*" + * @param {cocos2d::Sprite*} + * @param {cocos2d::Sprite*} + */ +create : function () {}, + +/** + * @method ControlStepper + * @constructor + */ +ControlStepper : function () {}, + +}; + +/** + * @class ControlSwitch + */ +cc.ControlSwitch = { + +/** + * @method setEnabled + * @param {bool} + */ +setEnabled : function () {}, + +/** + * @method ccTouchBegan + * @return A value converted from C/C++ "bool" + * @param {cocos2d::Touch*} + * @param {cocos2d::Event*} + */ +ccTouchBegan : function () {}, + +/** + * @method isOn + * @return A value converted from C/C++ "bool" + */ +isOn : function () {}, + +/** + * @method ccTouchCancelled + * @param {cocos2d::Touch*} + * @param {cocos2d::Event*} + */ +ccTouchCancelled : function () {}, + +/** + * @method ccTouchEnded + * @param {cocos2d::Touch*} + * @param {cocos2d::Event*} + */ +ccTouchEnded : function () {}, + +/** + * @method ccTouchMoved + * @param {cocos2d::Touch*} + * @param {cocos2d::Event*} + */ +ccTouchMoved : function () {}, + +/** + * @method hasMoved + * @return A value converted from C/C++ "bool" + */ +hasMoved : function () {}, + +/** + * @method locationFromTouch + * @return A value converted from C/C++ "cocos2d::Point" + * @param {cocos2d::Touch*} + */ +locationFromTouch : function () {}, + +/** + * @method ControlSwitch + * @constructor + */ +ControlSwitch : function () {}, + +}; + /** * @class TableViewCell */ diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_manual.cpp b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_manual.cpp index 372407218f..1db8768fb8 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_manual.cpp +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_manual.cpp @@ -291,6 +291,93 @@ tolua_lerror: return 0; } + + +static int tolua_cocos2dx_Menu_alignItemsInRows(lua_State* tolua_S) +{ + if (nullptr == tolua_S) + return 0; + + int argc = 0; + Menu* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"Menu",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(tolua_S,1,0)); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(tolua_S,"invalid 'self' in function 'lua_cocos2dx_Menu_alignItemsInRows'\n", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + if (argc > 0) + { + Array* array = NULL; + if (luavals_variadic_to_array(tolua_S, argc, &array)) + { + self->alignItemsInRowsWithArray(array); + } + return 0; + } + + CCLOG("wrong number of arguments in tolua_cocos2dx_Menu_alignItemsInRows: %d, was expecting %d\n", argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'alignItemsInRows'.\n",&tolua_err); +#endif + return 0; +} + +static int tolua_cocos2dx_Menu_alignItemsInColumns(lua_State* tolua_S) +{ + + if (nullptr == tolua_S) + return 0; + + int argc = 0; + Menu* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"Menu",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(tolua_S,1,0)); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2dx_Menu_alignItemsInColumns'\n", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + if (argc > 0) + { + Array* array = NULL; + if (luavals_variadic_to_array(tolua_S, argc, &array)) + { + self->alignItemsInColumnsWithArray(array); + } + return 0; + } + + CCLOG("wrong number of arguments in tolua_cocos2dx_Menu_alignItemsInColumns: %d, was expecting %d\n", argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'alignItemsInRows'.\n",&tolua_err); +#endif + return 0; +} + static int tolua_cocos2d_MenuItemToggle_create(lua_State* tolua_S) { if (NULL == tolua_S) @@ -304,18 +391,34 @@ static int tolua_cocos2d_MenuItemToggle_create(lua_State* tolua_S) #endif argc = lua_gettop(tolua_S) - 1; - if(1 == argc) + if(argc >= 1) { - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,2,"MenuItem",0,&tolua_err) ) + MenuItemToggle* tolua_ret = MenuItemToggle::create(); + if (NULL == tolua_ret) { - goto tolua_lerror; + return 0; } + + for (uint32_t i = 0; i < argc; ++i) + { +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S, i + 2,"MenuItem",0,&tolua_err) ) + { + goto tolua_lerror; + } #endif - MenuItem* item = (MenuItem*) tolua_tousertype(tolua_S,2,0); - MenuItemToggle* tolua_ret = (MenuItemToggle*) MenuItemToggle::create(item); - int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; + MenuItem* item = static_cast(tolua_tousertype(tolua_S, i + 2,0)); + if (0 == i) + { + tolua_ret->initWithItem(item); + } + else + { + tolua_ret->addSubItem(item); + } + } + + 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,"MenuItemToggle"); return 1; @@ -534,7 +637,7 @@ tolua_lerror: #endif } -int tolua_cocos2d_Layer_registerScriptKeypadHandler(lua_State* tolua_S) +static int tolua_cocos2d_Layer_registerScriptKeypadHandler(lua_State* tolua_S) { if (NULL == tolua_S) return 0; @@ -579,7 +682,7 @@ tolua_lerror: #endif } -int tolua_cocos2d_Layer_unregisterScriptKeypadHandler(lua_State* tolua_S) +static int tolua_cocos2d_Layer_unregisterScriptKeypadHandler(lua_State* tolua_S) { if (NULL == tolua_S) return 0; @@ -618,7 +721,7 @@ tolua_lerror: #endif } -int tolua_cocos2d_Layer_registerScriptAccelerateHandler(lua_State* tolua_S) +static int tolua_cocos2d_Layer_registerScriptAccelerateHandler(lua_State* tolua_S) { if (NULL == tolua_S) return 0; @@ -663,9 +766,9 @@ tolua_lerror: #endif } -int tolua_cocos2d_Layer_unregisterScriptAccelerateHandler(lua_State* tolua_S) +static int tolua_cocos2d_Layer_unregisterScriptAccelerateHandler(lua_State* tolua_S) { - if (NULL == tolua_S) + if (nullptr == tolua_S) return 0; int argc = 0; @@ -703,7 +806,6 @@ tolua_lerror: #endif } - static int tolua_cocos2d_Scheduler_scheduleScriptFunc(lua_State* tolua_S) { if (NULL == tolua_S) @@ -1590,6 +1692,559 @@ static int tolua_cocos2dx_LayerColor_setBlendFunc(lua_State* tolua_S) return tolua_cocos2dx_setBlendFunc(tolua_S,"LayerColor"); } +static int tolua_cocos2dx_ParticleSystem_setBlendFunc(lua_State* tolua_S) +{ + return tolua_cocos2dx_setBlendFunc(tolua_S,"ParticleSystem"); +} + +static int tolua_cocos2dx_LayerMultiplex_create(lua_State* tolua_S) +{ + if (nullptr == tolua_S) + return 0; + + int argc = 0; + Array* array = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertable(tolua_S, 1, "LayerMultiplex", 0, &tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc > 0) + { + if (luavals_variadic_to_array(tolua_S, argc, &array) && nullptr != array ) + { + LayerMultiplex* tolua_ret = LayerMultiplex::createWithArray(array); + 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; + } + else + { + CCLOG("error in tolua_cocos2dx_LayerMultiplex_create \n"); + return 0; + } + } + + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2dx_Camera_getCenterXYZ(lua_State* tolua_S) +{ + if (nullptr == tolua_S) + return 0; + + int argc = 0; + Camera* self = nullptr; +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"Camera",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(tolua_S,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) + { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2dx_Camera_getCenterXYZ'\n", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (0 == argc) + { + float x; + float y; + float z; + self->getCenterXYZ(&x, &y, &z); + tolua_pushnumber(tolua_S,(lua_Number)x); + tolua_pushnumber(tolua_S, (lua_Number)y); + tolua_pushnumber(tolua_S, (lua_Number)z); + return 3; + } + + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'getCenterXYZ'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2dx_Camera_getEyeXYZ(lua_State* tolua_S) +{ + if (nullptr == tolua_S) + return 0; + + int argc = 0; + Camera* self = nullptr; +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"Camera",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(tolua_S,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2dx_Camera_getEyeXYZ'\n", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (0 == argc) + { + float x; + float y; + float z; + self->getEyeXYZ(&x, &y, &z); + tolua_pushnumber(tolua_S,(lua_Number)x); + tolua_pushnumber(tolua_S, (lua_Number)y); + tolua_pushnumber(tolua_S, (lua_Number)z); + return 3; + } + + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'getEyeXYZ'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2dx_Camera_getUpXYZ(lua_State* tolua_S) +{ + if (nullptr == tolua_S) + return 0; + + int argc = 0; + Camera* self = nullptr; +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"Camera",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(tolua_S,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2dx_Camera_getUpXYZ'\n", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (0 == argc) + { + float x; + float y; + float z; + self->getUpXYZ(&x, &y, &z); + tolua_pushnumber(tolua_S,(lua_Number)x); + tolua_pushnumber(tolua_S, (lua_Number)y); + tolua_pushnumber(tolua_S, (lua_Number)z); + return 3; + } + + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'getUpXYZ'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2dx_FileUtils_getStringFromFile(lua_State* tolua_S) +{ + if (nullptr == tolua_S) + return 0; + + int argc = 0; + FileUtils* self = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"FileUtils",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(tolua_S,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) + { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2dx_FileUtils_getStringFromFile'\n", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (1 == argc) + { + const char* arg0; + std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); + if (ok) + { + std::string fullPathName = FileUtils::getInstance()->fullPathForFilename(arg0); + String* contentsOfFile = String::createWithContentsOfFile(fullPathName.c_str()); + if (nullptr != contentsOfFile) + { + const char* tolua_ret = contentsOfFile->getCString(); + tolua_pushstring(tolua_S, tolua_ret); + } + return 1; + } + } + + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'getStringFromFile'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2dx_UserDefault_getInstance(lua_State* tolua_S) +{ + if (nullptr == tolua_S) + return 0; + + int argc = 0; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertable(tolua_S,1,"UserDefault",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if(0 == argc) + { + UserDefault* tolua_ret = (UserDefault*) UserDefault::getInstance(); + tolua_pushusertype(tolua_S,(void*)tolua_ret,"UserDefault"); + return 1; + } + + CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'getInstance'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2dx_GLProgram_create(lua_State* tolua_S) +{ + if (nullptr == tolua_S) + return 0; + + int argc = 0; + bool ok = false; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertable(tolua_S,1,"GLProgram",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if(2 == argc) + { + const char *arg0, *arg1; + std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); + std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp); arg1 = arg1_tmp.c_str(); + + GLProgram* tolua_ret = new GLProgram(); + if (nullptr == tolua_ret) + return 0; + + tolua_ret->autorelease(); + tolua_ret->initWithVertexShaderFilename(arg0, arg1); + int ID = (tolua_ret) ? (int)tolua_ret->_ID : -1; + int* luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; + toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret,"GLProgram"); + return 1; + + } + + CCLOG("'create' function of GLProgram wrong number of arguments: %d, was expecting %d\n", argc, 2); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_cocos2d_GLProgram_getProgram(lua_State* tolua_S) +{ + if (nullptr == tolua_S) + return 0; + + int argc = 0; + GLProgram* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"GLProgram",0,&tolua_err)) goto tolua_lerror; +#endif + + self = (GLProgram*) tolua_tousertype(tolua_S,1,0); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) + { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_GLProgram_getProgram'\n", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + if (0 == argc) + { + unsigned const int tolua_ret = ( unsigned const int) self->getProgram(); + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); + return 1; + } + + CCLOG("'getProgram' function of GLProgram wrong number of arguments: %d, was expecting %d\n", argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'getProgram'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2dx_GLProgram_setUniformLocationF32(lua_State* tolua_S) +{ + if (nullptr == tolua_S) + return 0; + + int argc = 0; + GLProgram* self = nullptr; + int location = 0; + double f1 = 0.0; + double f2 = 0.0; + double f3 = 0.0; + double f4 = 0.0; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"GLProgram",0,&tolua_err)) goto tolua_lerror; +#endif + + self = (GLProgram*) tolua_tousertype(tolua_S,1,0); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) + { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_GLProgram_getProgram'\n", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc >= 2 && argc <= 5) + { +#if COCOS2D_DEBUG >= 1 + if (!tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err)) + { + goto tolua_lerror; + } +#endif + + location = (int) tolua_tonumber(tolua_S,2,0); + f1 = (float) tolua_tonumber(tolua_S,3,0); + + if (2 == argc) + { + self->setUniformLocationWith1f(location,f1); + return 0; + } + + if (argc >= 3) + { +#if COCOS2D_DEBUG >= 1 + if (!tolua_isnumber(tolua_S,4,0,&tolua_err)) + goto tolua_lerror; +#endif + + f2 = (float) tolua_tonumber(tolua_S,3,0); + if (3 == argc) + { + self->setUniformLocationWith2f(location, f1, f2); + return 0; + } + } + + if (argc >= 4) + { +#if COCOS2D_DEBUG >= 1 + if (!tolua_isnumber(tolua_S,5,0,&tolua_err)) + goto tolua_lerror; +#endif + + f3 = (float) tolua_tonumber(tolua_S,3,0); + if (4 == argc) + { + self->setUniformLocationWith3f(location, f1, f2, f3); + return 0; + } + } + + if (argc == 5) + { +#if COCOS2D_DEBUG >= 1 + if (!tolua_isnumber(tolua_S,6,0,&tolua_err)) + goto tolua_lerror; +#endif + + f4 = (float) tolua_tonumber(tolua_S,3,0); + if (4 == argc) + { + self->setUniformLocationWith4f(location, f1, f2, f3, f4); + return 0; + } + + } + } + + CCLOG("'setUniformLocationF32' function of GLProgram wrong number of arguments: %d, was expecting %d\n", argc, 2); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'setUniformLocationF32'.",&tolua_err); + return 0; +#endif + +} + +static void extendGLProgram(lua_State* tolua_S) +{ + lua_pushstring(tolua_S, "GLProgram"); + lua_rawget(tolua_S, LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"create"); + lua_pushcfunction(tolua_S,tolua_cocos2dx_GLProgram_create ); + lua_rawset(tolua_S,-3); + + lua_pushstring(tolua_S,"getProgram"); + lua_pushcfunction(tolua_S,tolua_cocos2d_GLProgram_getProgram ); + lua_rawset(tolua_S,-3); + + lua_pushstring(tolua_S,"setUniformLocationF32"); + lua_pushcfunction(tolua_S,tolua_cocos2dx_GLProgram_setUniformLocationF32 ); + lua_rawset(tolua_S,-3); + } +} + +static int tolua_cocos2dx_Texture2D_setTexParameters(lua_State* tolua_S) +{ + if (nullptr == tolua_S) + return 0; + + int argc = 0; + Texture2D* self = nullptr; + GLuint arg1 = 0; + GLuint arg2 = 0; + GLuint arg3 = 0; + GLuint arg4 = 0; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"Texture2D",0,&tolua_err)) goto tolua_lerror; +#endif + + self = (Texture2D*) tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) + { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2dx_Texture2D_setTexParameters'\n", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (4 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!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)) + { + goto tolua_lerror; + } +#endif + + arg1 = (GLuint)tolua_tonumber(tolua_S, 2, 0); + arg2 = (GLuint)tolua_tonumber(tolua_S, 3, 0); + arg3 = (GLuint)tolua_tonumber(tolua_S, 4, 0); + arg4 = (GLuint)tolua_tonumber(tolua_S, 5, 0); + + Texture2D::TexParams param = { arg1, arg2, arg3, arg4 }; + + self->setTexParameters(param); + + return 0; + } + + CCLOG("'setTexParameters' function of Texture2D wrong number of arguments: %d, was expecting %d\n", argc,4); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'setTexParameters'.",&tolua_err); + return 0; +#endif +} + +static void extendTexture2D(lua_State* tolua_S) +{ + lua_pushstring(tolua_S, "Texture2D"); + lua_rawget(tolua_S, LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"setTexParameters"); + lua_pushcfunction(tolua_S,tolua_cocos2dx_Texture2D_setTexParameters ); + lua_rawset(tolua_S,-3); + } +} + int register_all_cocos2dx_manual(lua_State* tolua_S) { if (NULL == tolua_S) @@ -1659,6 +2314,12 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) lua_pushstring(tolua_S,"create"); lua_pushcfunction(tolua_S,tolua_cocos2d_Menu_create); lua_rawset(tolua_S,-3); + lua_pushstring(tolua_S,"alignItemsInRows"); + lua_pushcfunction(tolua_S,tolua_cocos2dx_Menu_alignItemsInRows); + lua_rawset(tolua_S,-3); + lua_pushstring(tolua_S,"alignItemsInColumns"); + lua_pushcfunction(tolua_S,tolua_cocos2dx_Menu_alignItemsInColumns); + lua_rawset(tolua_S,-3); } lua_pushstring(tolua_S,"Node"); @@ -1814,5 +2475,61 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) lua_rawset(tolua_S,-3); } + lua_pushstring(tolua_S,"LayerMultiplex"); + lua_rawget(tolua_S,LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"create"); + lua_pushcfunction(tolua_S,tolua_cocos2dx_LayerMultiplex_create); + lua_rawset(tolua_S,-3); + } + + lua_pushstring(tolua_S,"ParticleSystem"); + lua_rawget(tolua_S,LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"setBlendFunc"); + lua_pushcfunction(tolua_S,tolua_cocos2dx_ParticleSystem_setBlendFunc); + lua_rawset(tolua_S,-3); + } + + lua_pushstring(tolua_S, "Camera"); + lua_rawget(tolua_S, LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"getCenter"); + lua_pushcfunction(tolua_S,tolua_cocos2dx_Camera_getCenterXYZ ); + lua_rawset(tolua_S,-3); + + lua_pushstring(tolua_S,"getUp"); + lua_pushcfunction(tolua_S,tolua_cocos2dx_Camera_getUpXYZ ); + lua_rawset(tolua_S,-3); + + lua_pushstring(tolua_S,"getEye"); + lua_pushcfunction(tolua_S,tolua_cocos2dx_Camera_getEyeXYZ ); + lua_rawset(tolua_S,-3); + } + + lua_pushstring(tolua_S, "FileUtils"); + lua_rawget(tolua_S, LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"getStringFromFile"); + lua_pushcfunction(tolua_S,tolua_cocos2dx_FileUtils_getStringFromFile ); + lua_rawset(tolua_S,-3); + } + + lua_pushstring(tolua_S, "UserDefault"); + lua_rawget(tolua_S, LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"getInstance"); + lua_pushcfunction(tolua_S,tolua_cocos2dx_UserDefault_getInstance ); + lua_rawset(tolua_S,-3); + } + + extendGLProgram(tolua_S); + extendTexture2D(tolua_S); + return 0; } \ No newline at end of file diff --git a/scripting/lua/script/Cocos2d.lua b/scripting/lua/script/Cocos2d.lua index fff43e987d..cc6b948c82 100644 --- a/scripting/lua/script/Cocos2d.lua +++ b/scripting/lua/script/Cocos2d.lua @@ -5,10 +5,30 @@ cc.DIRECTOR_PROJECTION_3D = 1 --Point function cc.p(_x,_y) - return { x = _x, y = _y } + if nil == _y then + return { x = _x.x, y = _x.y } + else + return { x = _x, y = _y } + end end -function cc.getPLength(pt) +function cc.pAdd(pt1,pt2) + return {x = pt1.x + pt2.x , y = pt1.y + pt2.y } +end + +function cc.pSub(pt1,pt2) + return {x = pt1.x - pt2.x , y = pt1.y - pt2.y } +end + +function cc.pMul(pt1,factor) + return { x = pt1.x * factor , y = pt1.y * factor } +end + +function cc.pForAngle(a) + return { x = math.cos(a), y = math.sin(a) } +end + +function cc.pGetLength(pt) return math.sqrt( pt.x * pt.x + pt.y * pt.y ); end @@ -21,6 +41,33 @@ function cc.pNormalize(pt) return { x = pt.x / length, y = pt.y / length } end +function cc.pCross(self,other) + return self.x * other.y - self.y * other.x +end + +function cc.pDot(self,other) + return self.x * other.x - self.y * other.y +end + +function cc.pToAngleSelf(self) + return math.atan2(self.y, self.x) +end + +function cc.pToAngle(self,other) + local a2 = cc.pNormalize(self) + local b2 = cc.pNormalize(other) + local angle = math.atan2(cc.pCross(a2, b2), cc.pDot(a2, b2) ) + if angle < 1.192092896e-7 then + return 0.0 + end + + return angle +end + +function cc.pGetDistance(startP,endP) + return cc.pGetLength(cc.pSub(startP,endP)) +end + --Size function cc.size( _width,_height ) return { width = _width, height = _height } @@ -31,6 +78,80 @@ function cc.rect(_x,_y,_width,_height) return { x = _x, y = _y, width = _width, height = _height } end +function cc.rectEqualToRect(rect1,rect2) + if ((rect1.x >= rect2.x) or (rect1.y >= rect2.y) or + ( rect1.x + rect1.width <= rect2.x + rect2.width) or + ( rect1.y + rect1.height <= rect2.y + rect2.height)) then + return false + end + + return true +end + +function cc.rectGetMaxX(rect) + return rect.x + rect.width +end + +function cc.rectGetMidX(rect) + return rect.x + rect.width / 2.0 +end + +function cc.rectGetMinX(rect) + return rect.x; +end + +function cc.rectGetMaxY(rect) + return rect.y + rect.height +end + +function cc.rectGetMidY(rect) + return rect.y + rect.height / 2.0 +end + +function cc.rectGetMinY(rect) + return rect.y +end + +function cc.rectContainsPoint( rect, point ) + local ret = false + + if (point.x >= rect.x) and (point.x <= rect.x + rect.width) and + (point.y >= rect.y) and (point.y <= rect.y + rect.height) then + ret = true + end + + return ret +end + +function cc.rectIntersectsRect( rect1, rect2 ) + local intersect = not ( rect1.x > rect2.x + rect2.width or + rect1.x + rect1.width < rect2.x or + rect1.y > rect2.y + rect2.height or + rect1.y + rect1.height < rect2.y ) + + return intersect +end + +function cc.rectUnion( rect1, rect2 ) + local rect = cc.rect(0, 0, 0, 0) + rect.x = math.min(rect1.x, rect2.x) + rect.y = math.min(rect1.y, rect2.y) + rect.width = math.max(rect1.x + rect1.width, rect2.x + rect2.width) - rect.x + rect.height = math.max(rect1.y + rect1.height, rect2.y + rect2.height) - rect.y + return rect +end + +function cc.rectIntersection( rect1, rect2 ) + local intersection = cc.rect( + math.max(rect1.x, rect2.x), + math.max(rect1.y, rect2.y), + 0, 0) + + intersection.width = math.min(rect1.x + rect1.width, rect2.x + rect2.width) - intersection.x + intersection.height = math.min(rect1.y + rect1.height, rect2.y + rect2.height) - intersection.y + return intersection; +end + --Color3B function cc.c3b( _r,_g,_b ) return { r = _r, g = _g, b = _b } @@ -46,15 +167,4 @@ function cc.c4f( _r,_g,_b,_a ) return { r = _r, g = _g, b = _b, a = _a } end -function cc.rectContainsPoint( rect, point ) - local ret = false - - if (point.x >= rect.x) and (point.x <= rect.x + rect.width) and - (point.y >= rect.y) and (point.y <= rect.y + rect.height) then - ret = true - end - - return ret; -end - diff --git a/scripting/lua/script/Cocos2dConstants.lua b/scripting/lua/script/Cocos2dConstants.lua index a86697dfef..e363efaca6 100644 --- a/scripting/lua/script/Cocos2dConstants.lua +++ b/scripting/lua/script/Cocos2dConstants.lua @@ -88,17 +88,26 @@ cc.TMX_TILE_VERTICAL_FLAG = 0x40000000 cc.TEXT_ALIGNMENT_CENTER = 0x1 cc.TEXT_ALIGNMENT_LEFT = 0x0 cc.TEXT_ALIGNMENT_RIGHT = 0x2 -cc.TEXTURE2_D_PIXEL_FORMAT_A8 = 0x3 -cc.TEXTURE2_D_PIXEL_FORMAT_A_I88 = 0x5 -cc.TEXTURE2_D_PIXEL_FORMAT_DEFAULT = 0x0 -cc.TEXTURE2_D_PIXEL_FORMAT_I8 = 0x4 -cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC2 = 0x9 -cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC4 = 0x8 -cc.TEXTURE2_D_PIXEL_FORMAT_RG_B565 = 0x2 -cc.TEXTURE2_D_PIXEL_FORMAT_RGB5_A1 = 0x7 -cc.TEXTURE2_D_PIXEL_FORMAT_RG_B888 = 0x1 -cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444 = 0x6 -cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888 = 0x0 + +cc.TEXTURE2_D_PIXEL_FORMAT_AUTO = 0x0 +cc.TEXTURE2_D_PIXEL_FORMAT_BGR_A8888 = 0x1 +cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888 = 0x2 +cc.TEXTURE2_D_PIXEL_FORMAT_RG_B888 = 0x3 +cc.TEXTURE2_D_PIXEL_FORMAT_RG_B565 = 0x4 +cc.TEXTURE2_D_PIXEL_FORMAT_A8 = 0x5 +cc.TEXTURE2_D_PIXEL_FORMAT_I8 = 0x6 +cc.TEXTURE2_D_PIXEL_FORMAT_A_I88 = 0x7 +cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444 = 0x8 +cc.TEXTURE2_D_PIXEL_FORMAT_RGB5_A1 = 0x9 +cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC4 = 0xa +cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC4A = 0xb +cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC2 = 0xc +cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC2A = 0xd +cc.TEXTURE2_D_PIXEL_FORMAT_ETC = 0xe +cc.TEXTURE2_D_PIXEL_FORMAT_S3TC_DXT1 = 0xf +cc.TEXTURE2_D_PIXEL_FORMAT_S3TC_DXT3 = 0x10 +cc.TEXTURE2_D_PIXEL_FORMAT_S3TC_DXT5 = 0x11 +cc.TEXTURE2_D_PIXEL_FORMAT_DEFAULT = 0x0 cc.TOUCHES_ALL_AT_ONCE = 0x0 cc.TOUCHES_ONE_BY_ONE = 0x1 cc.TRANSITION_ORIENTATION_DOWN_OVER = 0x1 diff --git a/tools/tolua/cocos2dx.ini b/tools/tolua/cocos2dx.ini index 2200bd45c0..278b930c3a 100644 --- a/tools/tolua/cocos2dx.ini +++ b/tools/tolua/cocos2dx.ini @@ -26,7 +26,7 @@ headers = %(cocosdir)s/cocos2dx/include/cocos2d.h %(cocosdir)s/CocosDenshion/inc # 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$ +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 # 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 @@ -103,10 +103,10 @@ skip = Node::[setGLServerState description getUserObject .*UserData getGLServerS Application::[^application.* ^run$], Camera::[getEyeXYZ getCenterXYZ getUpXYZ], ccFontDefinition::[*], - Object::[autorelease isEqual acceptVisitor update] + Object::[autorelease isEqual acceptVisitor update], + UserDefault::[getInstance (s|g)etDataForKey] rename_functions = SpriteFrameCache::[addSpriteFramesWithFile=addSpriteFrames getSpriteFrameByName=getSpriteFrame isFlipX=isFlippedX isFlipY=isFlippedY], - MenuItemFont::[setFontNameObj=setFontName setFontSizeObj=setFontSize getFontSizeObj=getFontSize getFontNameObj=getFontName], ProgressTimer::[setReverseProgress=setReverseDirection], Animation::[addSpriteFrameWithFileName=addSpriteFrameWithFile], AnimationCache::[addAnimationsWithFile=addAnimations animationByName=getAnimation removeAnimationByName=removeAnimation], diff --git a/tools/tolua/cocos2dx_extension.ini b/tools/tolua/cocos2dx_extension.ini index 5b499f8cc1..f9688a8765 100644 --- a/tools/tolua/cocos2dx_extension.ini +++ b/tools/tolua/cocos2dx_extension.ini @@ -26,7 +26,7 @@ headers = %(cocosdir)s/extensions/cocos-ext.h # 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 = CCBReader.* CCBAnimationManager.* Scale9Sprite Control$ ControlButton.* ScrollView$ TableView$ TableViewCell$ EditBox$ +classes = CCBReader.* CCBAnimationManager.* Scale9Sprite Control.* ControlButton.* ScrollView$ TableView$ TableViewCell$ EditBox$ # 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 @@ -40,10 +40,12 @@ skip = CCBReader::[^CCBReader$ addOwnerCallbackName isJSControlled readByte getC ScrollView::[(g|s)etDelegate$], .*Delegate::[*], .*Loader.*::[*], - *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType (g|s)etDelegate], + *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType (g|s)etDelegate .*HSV], EditBox::[(g|s)etDelegate ^keyboard.* touchDownAction getScriptEditBoxHandler registerScriptEditBoxHandler unregisterScriptEditBoxHandler], TableView::[create (g|s)etDataSource$ (g|s)etDelegate], - Control::[removeHandleOfControlEvent addHandleOfControlEvent] + Control::[removeHandleOfControlEvent addHandleOfControlEvent], + ControlUtils::[*], + ControlSwitchSprite::[*] rename_functions = CCBReader::[getAnimationManager=getActionManager setAnimationManager=setActionManager], CCBAnimationManager::[setCallFunc=setCallFuncForJSCallbackNamed] From d79e6dee7a521ff8c97525159320ece0d20fdc35 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 20 Aug 2013 14:25:45 +0800 Subject: [PATCH 040/126] Update AUTHORS [ci skip] --- AUTHORS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/AUTHORS b/AUTHORS index 74ffea3d2c..30120c5fb0 100644 --- a/AUTHORS +++ b/AUTHORS @@ -569,6 +569,9 @@ Developers: zcgit a potential bug fix in Layer::init. + + gkosciolek + Fixing a bug that observers with the same target and name but different sender are the same observer in NotificationCenter. Retired Core Developers: WenSheng Yang From d2684338a5e7248e52b88fbcd3db7872ff1a9d76 Mon Sep 17 00:00:00 2001 From: xbruce Date: Tue, 20 Aug 2013 14:58:26 +0800 Subject: [PATCH 041/126] Update CCScrollView.cpp change release mode --- extensions/GUI/CCScrollView/CCScrollView.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/GUI/CCScrollView/CCScrollView.cpp b/extensions/GUI/CCScrollView/CCScrollView.cpp index 2deb105f74..64a1766b51 100644 --- a/extensions/GUI/CCScrollView/CCScrollView.cpp +++ b/extensions/GUI/CCScrollView/CCScrollView.cpp @@ -61,7 +61,7 @@ ScrollView::ScrollView() ScrollView::~ScrollView() { - _touches->release(); + CC_SAFE_RELEASE(_touches); } ScrollView* ScrollView::create(Size size, Node* container/* = NULL*/) From 0d349d75d087a418cb6ba63d596c1d38b8c63225 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 20 Aug 2013 16:38:03 +0800 Subject: [PATCH 042/126] Update AUTHORS [ci skip] --- AUTHORS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/AUTHORS b/AUTHORS index 30120c5fb0..6845dc99bd 100644 --- a/AUTHORS +++ b/AUTHORS @@ -573,6 +573,9 @@ Developers: gkosciolek Fixing a bug that observers with the same target and name but different sender are the same observer in NotificationCenter. + xbruce + Fixing a bug that crash appears when extending cc.ScrollView in JS + Retired Core Developers: WenSheng Yang Author of windows port, CCTextField, From 5407719f4440535b8deba103d3f8fb2216dba552 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 20 Aug 2013 17:50:43 +0800 Subject: [PATCH 043/126] closed #2586: The utf8 response in XmlHttpRequest are mess codes. --- .../javascript/bindings/XMLHTTPRequest.cpp | 50 +++++++++++-------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/scripting/javascript/bindings/XMLHTTPRequest.cpp b/scripting/javascript/bindings/XMLHTTPRequest.cpp index 5869fd9fb3..f4c27d8bb1 100644 --- a/scripting/javascript/bindings/XMLHTTPRequest.cpp +++ b/scripting/javascript/bindings/XMLHTTPRequest.cpp @@ -322,8 +322,8 @@ JS_BINDED_CONSTRUCTOR_IMPL(MinXmlHttpRequest) */ JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, onreadystatechange) { - if (onreadystateCallback) { - + if (onreadystateCallback) + { JSString *tmpstr = JS_NewStringCopyZ(cx, "1"); jsval tmpval = STRING_TO_JSVAL(tmpstr); JS_SetProperty(cx, onreadystateCallback, "readyState", &tmpval); @@ -485,12 +485,15 @@ JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, status) */ JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, statusText) { - JSString* str = JS_NewStringCopyZ(cx, statusText.c_str());//, dataSize); + jsval strVal = std_string_to_jsval(cx, statusText); - if (str) { - vp.set(STRING_TO_JSVAL(str)); + if (strVal != JSVAL_NULL) + { + vp.set(strVal); return JS_TRUE; - } else { + } + else + { JS_ReportError(cx, "Error trying to create JSString from data"); return JS_FALSE; } @@ -526,10 +529,11 @@ JS_BINDED_PROP_SET_IMPL(MinXmlHttpRequest, withCredentials) */ JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, responseText) { - JSString* str = JS_NewStringCopyZ(cx, data.str().c_str());//, dataSize); + jsval strVal = std_string_to_jsval(cx, data.str()); - if (str) { - vp.set(STRING_TO_JSVAL(str)); + if (strVal != JSVAL_NULL) + { + vp.set(strVal); //JS_ReportError(cx, "Result: %s", data.str().c_str()); return JS_TRUE; } else { @@ -548,13 +552,15 @@ JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, response) if (responseType == kRequestResponseTypeJSON) { jsval outVal; - JSString* str = JS_NewStringCopyZ(cx, data.str().c_str());//, dataSize); - if (JS_ParseJSON(cx, JS_GetStringCharsZ(cx, str), dataSize, &outVal)) { - + jsval strVal = std_string_to_jsval(cx, data.str()); + if (JS_ParseJSON(cx, JS_GetStringCharsZ(cx, JSVAL_TO_STRING(strVal)), dataSize, &outVal)) + { vp.set(outVal); return JS_TRUE; } - } else if (responseType == kRequestResponseTypeArrayBuffer) { + } + else if (responseType == kRequestResponseTypeArrayBuffer) + { JSObject* tmp = JS_NewArrayBuffer(cx, dataSize); uint8_t* tmpData = JS_GetArrayBufferData(tmp); data.read((char*)tmpData, dataSize); @@ -675,12 +681,14 @@ JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, getAllResponseHeaders) responseheader = responseheaders.str(); - JSString* str = JS_NewStringCopyZ(cx, responseheader.c_str()); - - if (str) { - JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(str)); + jsval strVal = std_string_to_jsval(cx, responseheader); + if (strVal != JSVAL_NULL) + { + JS_SET_RVAL(cx, vp, strVal); return JS_TRUE; - } else { + } + else + { JS_ReportError(cx, "Error trying to create JSString from data"); return JS_FALSE; } @@ -714,10 +722,8 @@ JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, getResponseHeader) map::iterator iter = http_header.find(value); if (iter != http_header.end() ) { - JSString *js_ret_val = JS_NewStringCopyZ(cx, iter->second.c_str()); - - // iter->second - JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(js_ret_val)); + jsval js_ret_val = std_string_to_jsval(cx, iter->second); + JS_SET_RVAL(cx, vp, js_ret_val); return JS_TRUE; } else { From 5a393994cdff53e8fc48d957ef2f2e5b6915899f Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 20 Aug 2013 18:35:15 +0800 Subject: [PATCH 044/126] [Best C++ practice] ResponseType is enum class now. Renaming properties in MinXmlHttpRequest class. --- .../javascript/bindings/XMLHTTPRequest.cpp | 253 ++++++++++-------- .../javascript/bindings/XMLHTTPRequest.h | 83 +++--- 2 files changed, 177 insertions(+), 159 deletions(-) diff --git a/scripting/javascript/bindings/XMLHTTPRequest.cpp b/scripting/javascript/bindings/XMLHTTPRequest.cpp index f4c27d8bb1..a096756af5 100644 --- a/scripting/javascript/bindings/XMLHTTPRequest.cpp +++ b/scripting/javascript/bindings/XMLHTTPRequest.cpp @@ -37,7 +37,8 @@ using namespace std; * @brief Implementation for header retrieving. * @param header */ -void MinXmlHttpRequest::_gotHeader(string header) { +void MinXmlHttpRequest::_gotHeader(string header) +{ // Get Header and Set StatusText // Split String into Tokens char * cstr = new char [header.length()+1]; @@ -45,8 +46,8 @@ void MinXmlHttpRequest::_gotHeader(string header) { // check for colon. unsigned found_header_field = header.find_first_of(":"); - if (found_header_field != std::string::npos) { - + if (found_header_field != std::string::npos) + { // Found a header field. string http_field; string http_value; @@ -59,11 +60,11 @@ void MinXmlHttpRequest::_gotHeader(string header) { http_value.erase(http_value.size() - 1); } - http_header[http_field] = http_value; + _httpHeader[http_field] = http_value; } - else { - + else + { // Seems like we have the response Code! Parse it and check for it. char * pch; std::strcpy(cstr, header.c_str()); @@ -91,15 +92,13 @@ void MinXmlHttpRequest::_gotHeader(string header) { pch = strtok (NULL, " "); mystream << " " << pch; - statusText = mystream.str(); + _statusText = mystream.str(); } pch = strtok (NULL, " "); } - } - } /** @@ -107,39 +106,37 @@ void MinXmlHttpRequest::_gotHeader(string header) { * @param field Name of the Header to be set. * @param value Value of the Headerfield */ -void MinXmlHttpRequest::_setRequestHeader(const char* field, const char* value) { - +void MinXmlHttpRequest::_setRequestHeader(const char* field, const char* value) +{ stringstream header_s; stringstream value_s; string header; - map::iterator iter = request_header.find(field); + map::iterator iter = _requestHeader.find(field); // Concatenate values when header exists. - if (iter != request_header.end() ) { - + if (iter != _requestHeader.end()) + { value_s << iter->second << "," << value; - } - else { + else + { value_s << value; } - request_header[field] = value_s.str(); - return; - + _requestHeader[field] = value_s.str(); } /** * @brief If headers has been set, pass them to curl. * */ -void MinXmlHttpRequest::_setHttpRequestHeader() { - +void MinXmlHttpRequest::_setHttpRequestHeader() +{ std::vector header; - for (std::map::iterator it = request_header.begin(); it != request_header.end(); ++it) { - + for (auto it = _requestHeader.begin(); it != _requestHeader.end(); ++it) + { const char* first = it->first.c_str(); const char* second = it->second.c_str(); size_t len = sizeof(char) * (strlen(first) + 3 + strlen(second)); @@ -156,8 +153,9 @@ void MinXmlHttpRequest::_setHttpRequestHeader() { } - if (!header.empty()) { - cc_request->setHeaders(header); + if (!header.empty()) + { + _httpRequest->setHeaders(header); } } @@ -167,8 +165,8 @@ void MinXmlHttpRequest::_setHttpRequestHeader() { * @param sender Object which initialized callback * @param respone Response object */ -void MinXmlHttpRequest::handle_requestResponse(cocos2d::extension::HttpClient *sender, cocos2d::extension::HttpResponse *response) { - +void MinXmlHttpRequest::handle_requestResponse(cocos2d::extension::HttpClient *sender, cocos2d::extension::HttpResponse *response) +{ if (0 != strlen(response->getHttpRequest()->getTag())) { CCLOG("%s completed", response->getHttpRequest()->getTag()); @@ -208,14 +206,14 @@ void MinXmlHttpRequest::handle_requestResponse(cocos2d::extension::HttpClient *s if (statusCode == 200) { //Succeeded - status = 200; - readyState = DONE; - data << concatenated; + _status = 200; + _readyState = DONE; + _data << concatenated; } else { - status = 0; + _status = 0; } // Free Memory. free((void*) concatHeader); @@ -225,12 +223,14 @@ void MinXmlHttpRequest::handle_requestResponse(cocos2d::extension::HttpClient *s void* ptr = (void*)this; p = jsb_get_native_proxy(ptr); - if(p){ + if(p) + { JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); - if (onreadystateCallback) { + if (_onreadystateCallback) + { //JS_IsExceptionPending(cx) && JS_ReportPendingException(cx); - jsval fval = OBJECT_TO_JSVAL(onreadystateCallback); + jsval fval = OBJECT_TO_JSVAL(_onreadystateCallback); jsval out; JS_CallFunctionValue(cx, NULL, fval, 0, NULL, &out); } @@ -242,44 +242,44 @@ void MinXmlHttpRequest::handle_requestResponse(cocos2d::extension::HttpClient *s * @brief Send out request and fire callback when done. * @param cx Javascript context */ -void MinXmlHttpRequest::_sendRequest(JSContext *cx) { - - cc_request->setResponseCallback(this, httpresponse_selector(MinXmlHttpRequest::handle_requestResponse)); - cocos2d::extension::HttpClient::getInstance()->send(cc_request); - cc_request->release(); - +void MinXmlHttpRequest::_sendRequest(JSContext *cx) +{ + _httpRequest->setResponseCallback(this, httpresponse_selector(MinXmlHttpRequest::handle_requestResponse)); + cocos2d::extension::HttpClient::getInstance()->send(_httpRequest); + _httpRequest->release(); } /** * @brief Constructor initializes cchttprequest and stuff * */ -MinXmlHttpRequest::MinXmlHttpRequest() : onreadystateCallback(NULL), isNetwork(true) { - - http_header.clear(); - request_header.clear(); - withCredentialsValue = true; - cx = ScriptingCore::getInstance()->getGlobalContext(); - cc_request = new cocos2d::extension::HttpRequest(); +MinXmlHttpRequest::MinXmlHttpRequest() : _onreadystateCallback(NULL), _isNetwork(true) +{ + _httpHeader.clear(); + _requestHeader.clear(); + _withCredentialsValue = true; + _cx = ScriptingCore::getInstance()->getGlobalContext(); + _httpRequest = new cocos2d::extension::HttpRequest(); } /** - * @brief Destructor cleans up cc_request and stuff + * @brief Destructor cleans up _httpRequest and stuff * */ -MinXmlHttpRequest::~MinXmlHttpRequest() { +MinXmlHttpRequest::~MinXmlHttpRequest() +{ + _httpHeader.clear(); + _requestHeader.clear(); - http_header.clear(); - request_header.clear(); - - if (onreadystateCallback != NULL) + if (_onreadystateCallback != NULL) { - JS_RemoveObjectRoot(cx, &onreadystateCallback); + JS_RemoveObjectRoot(_cx, &_onreadystateCallback); } - if (cc_request) { - // We don't need to release cc_request here since it will be released in the http callback. -// cc_request->release(); + if (_httpRequest) + { + // We don't need to release _httpRequest here since it will be released in the http callback. +// _httpRequest->release(); } } @@ -322,16 +322,18 @@ JS_BINDED_CONSTRUCTOR_IMPL(MinXmlHttpRequest) */ JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, onreadystatechange) { - if (onreadystateCallback) + if (_onreadystateCallback) { JSString *tmpstr = JS_NewStringCopyZ(cx, "1"); jsval tmpval = STRING_TO_JSVAL(tmpstr); - JS_SetProperty(cx, onreadystateCallback, "readyState", &tmpval); + JS_SetProperty(cx, _onreadystateCallback, "readyState", &tmpval); - jsval out = OBJECT_TO_JSVAL(onreadystateCallback); + jsval out = OBJECT_TO_JSVAL(_onreadystateCallback); vp.set(out); - } else { + } + else + { vp.set(JSVAL_NULL); } return JS_TRUE; @@ -345,9 +347,10 @@ JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, onreadystatechange) JS_BINDED_PROP_SET_IMPL(MinXmlHttpRequest, onreadystatechange) { jsval callback = vp.get(); - if (callback != JSVAL_NULL) { - onreadystateCallback = JSVAL_TO_OBJECT(callback); - JS_AddNamedObjectRoot(cx, &onreadystateCallback, "onreadystateCallback"); + if (callback != JSVAL_NULL) + { + _onreadystateCallback = JSVAL_TO_OBJECT(callback); + JS_AddNamedObjectRoot(cx, &_onreadystateCallback, "onreadystateCallback"); } return JS_TRUE; } @@ -381,7 +384,7 @@ JS_BINDED_PROP_SET_IMPL(MinXmlHttpRequest, upload) */ JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, timeout) { - vp.set(INT_TO_JSVAL(timeout)); + vp.set(INT_TO_JSVAL(_timeout)); return JS_TRUE; } @@ -394,7 +397,7 @@ JS_BINDED_PROP_SET_IMPL(MinXmlHttpRequest, timeout) { jsval timeout_ms = vp.get(); - timeout = JSVAL_TO_INT(timeout_ms); + _timeout = JSVAL_TO_INT(timeout_ms); //curl_easy_setopt(curlHandle, CURLOPT_CONNECTTIMEOUT_MS, timeout); return JS_TRUE; @@ -434,19 +437,25 @@ JS_BINDED_PROP_SET_IMPL(MinXmlHttpRequest, responseType) if (type.isString()) { JSString* str = type.toString(); JSBool equal; + JS_StringEqualsAscii(cx, str, "text", &equal); - if (equal) { - responseType = kRequestResponseTypeString; + if (equal) + { + _responseType = ResponseType::STRING; return JS_TRUE; } + JS_StringEqualsAscii(cx, str, "arraybuffer", &equal); - if (equal) { - responseType = kRequestResponseTypeArrayBuffer; + if (equal) + { + _responseType = ResponseType::ARRAY_BUFFER; return JS_TRUE; } + JS_StringEqualsAscii(cx, str, "json", &equal); - if (equal) { - responseType = kRequestResponseTypeJSON; + if (equal) + { + _responseType = ResponseType::JSON; return JS_TRUE; } // ignore the rest of the response types for now @@ -463,7 +472,7 @@ JS_BINDED_PROP_SET_IMPL(MinXmlHttpRequest, responseType) */ JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, readyState) { - vp.set(INT_TO_JSVAL(readyState)); + vp.set(INT_TO_JSVAL(_readyState)); return JS_TRUE; } @@ -474,7 +483,7 @@ JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, readyState) */ JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, status) { - vp.set(INT_TO_JSVAL(status)); + vp.set(INT_TO_JSVAL(_status)); return JS_TRUE; } @@ -485,7 +494,7 @@ JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, status) */ JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, statusText) { - jsval strVal = std_string_to_jsval(cx, statusText); + jsval strVal = std_string_to_jsval(cx, _statusText); if (strVal != JSVAL_NULL) { @@ -505,7 +514,7 @@ JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, statusText) */ JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, withCredentials) { - vp.set(BOOLEAN_TO_JSVAL(withCredentialsValue)); + vp.set(BOOLEAN_TO_JSVAL(_withCredentialsValue)); return JS_TRUE; } @@ -516,8 +525,9 @@ JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, withCredentials) JS_BINDED_PROP_SET_IMPL(MinXmlHttpRequest, withCredentials) { jsval credential = vp.get(); - if (credential != JSVAL_NULL) { - withCredentialsValue = JSVAL_TO_BOOLEAN(credential); + if (credential != JSVAL_NULL) + { + _withCredentialsValue = JSVAL_TO_BOOLEAN(credential); } return JS_TRUE; @@ -529,7 +539,7 @@ JS_BINDED_PROP_SET_IMPL(MinXmlHttpRequest, withCredentials) */ JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, responseText) { - jsval strVal = std_string_to_jsval(cx, data.str()); + jsval strVal = std_string_to_jsval(cx, _data.str()); if (strVal != JSVAL_NULL) { @@ -549,21 +559,22 @@ JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, responseText) JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, response) { - if (responseType == kRequestResponseTypeJSON) { + if (_responseType == ResponseType::JSON) + { jsval outVal; - jsval strVal = std_string_to_jsval(cx, data.str()); - if (JS_ParseJSON(cx, JS_GetStringCharsZ(cx, JSVAL_TO_STRING(strVal)), dataSize, &outVal)) + jsval strVal = std_string_to_jsval(cx, _data.str()); + if (JS_ParseJSON(cx, JS_GetStringCharsZ(cx, JSVAL_TO_STRING(strVal)), _dataSize, &outVal)) { vp.set(outVal); return JS_TRUE; } } - else if (responseType == kRequestResponseTypeArrayBuffer) + else if (_responseType == ResponseType::ARRAY_BUFFER) { - JSObject* tmp = JS_NewArrayBuffer(cx, dataSize); + JSObject* tmp = JS_NewArrayBuffer(cx, _dataSize); uint8_t* tmpData = JS_GetArrayBufferData(tmp); - data.read((char*)tmpData, dataSize); + _data.read((char*)tmpData, _dataSize); jsval outVal = OBJECT_TO_JSVAL(tmp); vp.set(outVal); @@ -579,8 +590,8 @@ JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, response) */ JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, open) { - - if (argc >= 2) { + if (argc >= 2) + { jsval* argv = JS_ARGV(cx, vp); const char* method; const char* urlstr; @@ -597,26 +608,29 @@ JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, open) method = w1; urlstr = w2; - url = urlstr; - meth = method; - readyState = 1; - isAsync = async; + _url = urlstr; + _meth = method; + _readyState = 1; + _isAsync = async; - if (url.length() > 5 && url.compare(url.length() - 5, 5, ".json") == 0) { - responseType = kRequestResponseTypeJSON; + if (_url.length() > 5 && _url.compare(_url.length() - 5, 5, ".json") == 0) + { + _responseType = ResponseType::JSON; } - if (meth.compare("post") == 0 || meth.compare("POST") == 0) { - cc_request->setRequestType(cocos2d::extension::HttpRequest::Type::POST); + if (_meth.compare("post") == 0 || _meth.compare("POST") == 0) + { + _httpRequest->setRequestType(cocos2d::extension::HttpRequest::Type::POST); } - else { - cc_request->setRequestType(cocos2d::extension::HttpRequest::Type::GET); + else + { + _httpRequest->setRequestType(cocos2d::extension::HttpRequest::Type::GET); } - cc_request->setUrl(url.c_str()); + _httpRequest->setUrl(_url.c_str()); - isNetwork = true; - readyState = OPENED; + _isNetwork = true; + _readyState = OPENED; return JS_TRUE; } @@ -632,23 +646,26 @@ JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, open) */ JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, send) { - JSString *str = NULL; std::string data; // Clean up header map. New request, new headers! - http_header.clear(); - if (argc == 1) { - if (!JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "S", &str)) { + _httpHeader.clear(); + + if (argc == 1) + { + if (!JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "S", &str)) + { return JS_FALSE; - }; + } JSStringWrapper strWrap(str); data = strWrap.get(); } - if (data.length() > 0 && (meth.compare("post") == 0 || meth.compare("POST") == 0)) { - cc_request->setRequestData(data.c_str(), data.length()); + if (data.length() > 0 && (_meth.compare("post") == 0 || _meth.compare("POST") == 0)) + { + _httpRequest->setRequestData(data.c_str(), data.length()); } _setHttpRequestHeader(); @@ -675,7 +692,8 @@ JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, getAllResponseHeaders) stringstream responseheaders; string responseheader; - for (std::map::iterator it=http_header.begin(); it!=http_header.end(); ++it) { + for (auto it = _httpHeader.begin(); it != _httpHeader.end(); ++it) + { responseheaders << it->first << ": " << it->second << "\n"; } @@ -702,7 +720,6 @@ JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, getAllResponseHeaders) */ JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, getResponseHeader) { - JSString *header_value; if (!JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "S", &header_value)) { @@ -719,9 +736,9 @@ JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, getResponseHeader) string value = streamdata.str(); - map::iterator iter = http_header.find(value); - if (iter != http_header.end() ) { - + auto iter = _httpHeader.find(value); + if (iter != _httpHeader.end()) + { jsval js_ret_val = std_string_to_jsval(cx, iter->second); JS_SET_RVAL(cx, vp, js_ret_val); return JS_TRUE; @@ -730,7 +747,6 @@ JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, getResponseHeader) JS_SET_RVAL(cx, vp, JSVAL_NULL); return JS_TRUE; } - } /** @@ -740,8 +756,8 @@ JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, getResponseHeader) */ JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, setRequestHeader) { - - if (argc >= 2) { + if (argc >= 2) + { jsval* argv = JS_ARGV(cx, vp); const char* field; const char* value; @@ -778,7 +794,8 @@ JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, overrideMimeType) * @brief destructor for Javascript * */ -static void basic_object_finalize(JSFreeOp *freeOp, JSObject *obj) { +static void basic_object_finalize(JSFreeOp *freeOp, JSObject *obj) +{ CCLOG("basic_object_finalize %p ...", obj); } @@ -787,8 +804,8 @@ static void basic_object_finalize(JSFreeOp *freeOp, JSObject *obj) { * @param cx Global Spidermonkey JS Context. * @param global Global Spidermonkey Javascript object. */ -void MinXmlHttpRequest::_js_register(JSContext *cx, JSObject *global) { - +void MinXmlHttpRequest::_js_register(JSContext *cx, JSObject *global) +{ JSClass js_class = { "XMLHttpRequest", JSCLASS_HAS_PRIVATE, JS_PropertyStub, JS_DeletePropertyStub, JS_PropertyStub, JS_StrictPropertyStub, diff --git a/scripting/javascript/bindings/XMLHTTPRequest.h b/scripting/javascript/bindings/XMLHTTPRequest.h index 557286c080..b94e05e5fe 100644 --- a/scripting/javascript/bindings/XMLHTTPRequest.h +++ b/scripting/javascript/bindings/XMLHTTPRequest.h @@ -37,52 +37,28 @@ #include "jsfriendapi.h" #include "jsb_helper.h" -enum MinXmlHttpRequestResponseType { - kRequestResponseTypeString, - kRequestResponseTypeArrayBuffer, - kRequestResponseTypeBlob, - kRequestResponseTypeDocument, - kRequestResponseTypeJSON -}; - -// Ready States (http://www.w3.org/TR/XMLHttpRequest/#interface-xmlhttprequest) -const unsigned short UNSENT = 0; -const unsigned short OPENED = 1; -const unsigned short HEADERS_RECEIVED = 2; -const unsigned short LOADING = 3; -const unsigned short DONE = 4; - class MinXmlHttpRequest : public cocos2d::Object { - std::string url; - JSContext *cx; - std::string meth; - std::string type; - std::stringstream data; - size_t dataSize; - JSObject* onreadystateCallback; - int readyState; - int status; - std::string statusText; - int responseType; - unsigned timeout; - bool isAsync; - cocos2d::extension::HttpRequest* cc_request; - - bool isNetwork; - bool withCredentialsValue; - map http_header; - map request_header; - - void _gotHeader(std::string header); - - void _setRequestHeader(const char* field, const char* value); - void _setHttpRequestHeader(); - void _sendRequest(JSContext *cx); - public: + enum class ResponseType + { + STRING, + ARRAY_BUFFER, + BLOB, + DOCUMENT, + JSON + }; + + // Ready States (http://www.w3.org/TR/XMLHttpRequest/#interface-xmlhttprequest) + static const unsigned short UNSENT = 0; + static const unsigned short OPENED = 1; + static const unsigned short HEADERS_RECEIVED = 2; + static const unsigned short LOADING = 3; + static const unsigned short DONE = 4; + MinXmlHttpRequest(); ~MinXmlHttpRequest(); + JS_BINDED_CLASS_GLUE(MinXmlHttpRequest); JS_BINDED_CONSTRUCTOR(MinXmlHttpRequest); JS_BINDED_PROP_ACCESSOR(MinXmlHttpRequest, onreadystatechange); @@ -106,6 +82,31 @@ public: void handle_requestResponse(cocos2d::extension::HttpClient *sender, cocos2d::extension::HttpResponse *response); + +private: + void _gotHeader(std::string header); + void _setRequestHeader(const char* field, const char* value); + void _setHttpRequestHeader(); + void _sendRequest(JSContext *cx); + + std::string _url; + JSContext* _cx; + std::string _meth; + std::string _type; + std::stringstream _data; + size_t _dataSize; + JSObject* _onreadystateCallback; + int _readyState; + int _status; + std::string _statusText; + ResponseType _responseType; + unsigned _timeout; + bool _isAsync; + cocos2d::extension::HttpRequest* _httpRequest; + bool _isNetwork; + bool _withCredentialsValue; + std::map _httpHeader; + std::map _requestHeader; }; #endif From fb3d422f0c85ff786613684bfe6730f89d4000f4 Mon Sep 17 00:00:00 2001 From: NatWeiss Date: Tue, 20 Aug 2013 10:22:44 -0700 Subject: [PATCH 045/126] Fixes full paths on Android (cleaner) If one adds a search resolutions order directory without a trailing slash, CCFileUtils::getFullPathForDirectoryAndFilename will fail on Android. For example it will return: assets/sdBg1.png Instead of the expected: assets/sd/Bg1.png This small commit fixes the function to add a slash if necessary, fixing the issue on Android. Compared to the last pull request of this name, formatting matches the style of code around it and comments have been added. --- cocos2dx/platform/CCFileUtils.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cocos2dx/platform/CCFileUtils.cpp b/cocos2dx/platform/CCFileUtils.cpp index c14a759f64..2fd742d2f4 100644 --- a/cocos2dx/platform/CCFileUtils.cpp +++ b/cocos2dx/platform/CCFileUtils.cpp @@ -785,7 +785,14 @@ void FileUtils::loadFilenameLookupDictionaryFromFile(const char* filename) std::string FileUtils::getFullPathForDirectoryAndFilename(const std::string& strDirectory, const std::string& strFilename) { - std::string ret = strDirectory+strFilename; + // get directory+filename, safely adding '/' as necessary + std::string ret = strDirectory; + if (strDirectory.size() && strDirectory[strDirectory.size()-1] != '/'){ + ret += '/'; + } + ret += strFilename; + + // if the file doesn't exist, return an empty string if (!isFileExist(ret)) { ret = ""; } From 5225758c5c5e6facbf9a0ce96dd225f2246361c6 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Tue, 20 Aug 2013 14:16:43 -0700 Subject: [PATCH 046/126] CCArray: performance improvements CCArray: - Iterator uses position for iterator. MUCH faster. - Do not double init the array. performance improvements in memory. Signed-off-by: Ricardo Quesada --- cocos2dx/cocoa/CCArray.cpp | 228 ++++++++++++++++++------------------- cocos2dx/cocoa/CCArray.h | 41 ++++--- 2 files changed, 129 insertions(+), 140 deletions(-) diff --git a/cocos2dx/cocoa/CCArray.cpp b/cocos2dx/cocoa/CCArray.cpp index 5ae6b8fdbe..eb80982de0 100644 --- a/cocos2dx/cocoa/CCArray.cpp +++ b/cocos2dx/cocoa/CCArray.cpp @@ -50,60 +50,60 @@ Array::Array(unsigned int capacity) Array* Array::create() { - Array* pArray = new Array(); + Array* array = new Array(); - if (pArray && pArray->init()) + if (array && array->init()) { - pArray->autorelease(); + array->autorelease(); } else { - CC_SAFE_DELETE(pArray); + CC_SAFE_DELETE(array); } - return pArray; + return array; } -Array* Array::createWithObject(Object* pObject) +Array* Array::createWithObject(Object* object) { - Array* pArray = new Array(); + Array* array = new Array(); - if (pArray && pArray->initWithObject(pObject)) + if (array && array->initWithObject(object)) { - pArray->autorelease(); + array->autorelease(); } else { - CC_SAFE_DELETE(pArray); + CC_SAFE_DELETE(array); } - return pArray; + return array; } -Array* Array::create(Object* pObject, ...) +Array* Array::create(Object* object, ...) { va_list args; - va_start(args,pObject); + va_start(args,object); - Array* pArray = create(); - if (pArray && pObject) + Array* array = create(); + if (array && object) { - pArray->addObject(pObject); + array->addObject(object); Object *i = va_arg(args, Object*); while(i) { - pArray->addObject(i); + array->addObject(i); i = va_arg(args, Object*); } } else { - CC_SAFE_DELETE(pArray); + CC_SAFE_DELETE(array); } va_end(args); - return pArray; + return array; } Array* Array::createWithArray(Array* otherArray) @@ -113,23 +113,23 @@ Array* Array::createWithArray(Array* otherArray) Array* Array::createWithCapacity(unsigned int capacity) { - Array* pArray = new Array(); + Array* array = new Array(); - if (pArray && pArray->initWithCapacity(capacity)) + if (array && array->initWithCapacity(capacity)) { - pArray->autorelease(); + array->autorelease(); } else { - CC_SAFE_DELETE(pArray); + CC_SAFE_DELETE(array); } - return pArray; + return array; } -Array* Array::createWithContentsOfFile(const char* pFileName) +Array* Array::createWithContentsOfFile(const char* fileName) { - Array* pRet = Array::createWithContentsOfFileThreadSafe(pFileName); + Array* pRet = Array::createWithContentsOfFileThreadSafe(fileName); if (pRet != NULL) { pRet->autorelease(); @@ -137,9 +137,9 @@ Array* Array::createWithContentsOfFile(const char* pFileName) return pRet; } -Array* Array::createWithContentsOfFileThreadSafe(const char* pFileName) +Array* Array::createWithContentsOfFileThreadSafe(const char* fileName) { - return FileUtils::getInstance()->createArrayWithContentsOfFile(pFileName); + return FileUtils::getInstance()->createArrayWithContentsOfFile(fileName); } bool Array::init() @@ -147,43 +147,43 @@ bool Array::init() return initWithCapacity(1); } -bool Array::initWithObject(Object* pObject) +bool Array::initWithObject(Object* object) { - bool bRet = initWithCapacity(1); - if (bRet) + bool ret = initWithCapacity(1); + if (ret) { - addObject(pObject); + addObject(object); } - return bRet; + return ret; } /** Initializes an array with some objects */ -bool Array::initWithObjects(Object* pObject, ...) +bool Array::initWithObjects(Object* object, ...) { - bool bRet = false; + bool ret = false; do { - CC_BREAK_IF(pObject == NULL); + CC_BREAK_IF(object == NULL); va_list args; - va_start(args, pObject); + va_start(args, object); - if (pObject) + if (object) { - this->addObject(pObject); + this->addObject(object); Object* i = va_arg(args, Object*); while(i) { this->addObject(i); i = va_arg(args, Object*); } - bRet = true; + ret = true; } va_end(args); } while (false); - return bRet; + return ret; } bool Array::initWithCapacity(unsigned int capacity) @@ -274,13 +274,13 @@ void Array::setObject(Object* object, int index) data[index] = RCPtr(object); } -void Array::removeLastObject(bool bReleaseObj) +void Array::removeLastObject(bool releaseObj) { CCASSERT(data.size(), "no objects added"); data.pop_back(); } -void Array::removeObject(Object* object, bool bReleaseObj /* ignored */) +void Array::removeObject(Object* object, bool releaseObj /* ignored */) { // auto begin = data.begin(); // auto end = data.end(); @@ -301,7 +301,7 @@ void Array::removeObject(Object* object, bool bReleaseObj /* ignored */) } } -void Array::removeObjectAtIndex(unsigned int index, bool bReleaseObj /* ignored */) +void Array::removeObjectAtIndex(unsigned int index, bool releaseObj /* ignored */) { auto obj = data[index]; data.erase( data.begin() + index ); @@ -342,10 +342,10 @@ void Array::exchangeObjectAtIndex(unsigned int index1, unsigned int index2) std::swap( data[index1], data[index2] ); } -void Array::replaceObjectAtIndex(unsigned int index, Object* pObject, bool bReleaseObject /* ignored */) +void Array::replaceObjectAtIndex(unsigned int index, Object* object, bool releaseObject /* ignored */) { // auto obj = data[index]; - data[index] = pObject; + data[index] = object; } void Array::reverseObjects() @@ -404,7 +404,7 @@ void Array::acceptVisitor(DataVisitor &visitor) Array::Array() : data(NULL) { - init(); +// init(); } Array::Array(unsigned int capacity) @@ -415,60 +415,60 @@ Array::Array(unsigned int capacity) Array* Array::create() { - Array* pArray = new Array(); + Array* array = new Array(); - if (pArray && pArray->init()) + if (array && array->init()) { - pArray->autorelease(); + array->autorelease(); } else { - CC_SAFE_DELETE(pArray); + CC_SAFE_DELETE(array); } - return pArray; + return array; } -Array* Array::createWithObject(Object* pObject) +Array* Array::createWithObject(Object* object) { - Array* pArray = new Array(); + Array* array = new Array(); - if (pArray && pArray->initWithObject(pObject)) + if (array && array->initWithObject(object)) { - pArray->autorelease(); + array->autorelease(); } else { - CC_SAFE_DELETE(pArray); + CC_SAFE_DELETE(array); } - return pArray; + return array; } -Array* Array::create(Object* pObject, ...) +Array* Array::create(Object* object, ...) { va_list args; - va_start(args,pObject); + va_start(args,object); - Array* pArray = create(); - if (pArray && pObject) + Array* array = create(); + if (array && object) { - pArray->addObject(pObject); + array->addObject(object); Object *i = va_arg(args, Object*); while(i) { - pArray->addObject(i); + array->addObject(i); i = va_arg(args, Object*); } } else { - CC_SAFE_DELETE(pArray); + CC_SAFE_DELETE(array); } va_end(args); - return pArray; + return array; } Array* Array::createWithArray(Array* otherArray) @@ -478,23 +478,23 @@ Array* Array::createWithArray(Array* otherArray) Array* Array::createWithCapacity(unsigned int capacity) { - Array* pArray = new Array(); + Array* array = new Array(); - if (pArray && pArray->initWithCapacity(capacity)) + if (array && array->initWithCapacity(capacity)) { - pArray->autorelease(); + array->autorelease(); } else { - CC_SAFE_DELETE(pArray); + CC_SAFE_DELETE(array); } - return pArray; + return array; } -Array* Array::createWithContentsOfFile(const char* pFileName) +Array* Array::createWithContentsOfFile(const char* fileName) { - Array* pRet = Array::createWithContentsOfFileThreadSafe(pFileName); + Array* pRet = Array::createWithContentsOfFileThreadSafe(fileName); if (pRet != NULL) { pRet->autorelease(); @@ -502,9 +502,9 @@ Array* Array::createWithContentsOfFile(const char* pFileName) return pRet; } -Array* Array::createWithContentsOfFileThreadSafe(const char* pFileName) +Array* Array::createWithContentsOfFileThreadSafe(const char* fileName) { - return FileUtils::getInstance()->createArrayWithContentsOfFile(pFileName); + return FileUtils::getInstance()->createArrayWithContentsOfFile(fileName); } bool Array::init() @@ -512,67 +512,71 @@ bool Array::init() return initWithCapacity(1); } -bool Array::initWithObject(Object* pObject) +bool Array::initWithObject(Object* object) { - ccArrayFree(data); - bool bRet = initWithCapacity(1); - if (bRet) + CCASSERT(!data, "Array cannot be re-initialized"); + + bool ret = initWithCapacity(1); + if (ret) { - addObject(pObject); + addObject(object); } - return bRet; + return ret; } /** Initializes an array with some objects */ -bool Array::initWithObjects(Object* pObject, ...) +bool Array::initWithObjects(Object* object, ...) { - ccArrayFree(data); - bool bRet = false; + CCASSERT(!data, "Array cannot be re-initialized"); + + bool ret = false; do { - CC_BREAK_IF(pObject == NULL); + CC_BREAK_IF(object == NULL); va_list args; - va_start(args, pObject); + va_start(args, object); - if (pObject) + if (object) { - this->addObject(pObject); + this->addObject(object); Object* i = va_arg(args, Object*); while(i) { this->addObject(i); i = va_arg(args, Object*); } - bRet = true; + ret = true; } va_end(args); } while (false); - return bRet; + return ret; } bool Array::initWithCapacity(unsigned int capacity) { - ccArrayFree(data); + CCASSERT(!data, "Array cannot be re-initialized"); + data = ccArrayNew(capacity); return true; } bool Array::initWithArray(Array* otherArray) { - ccArrayFree(data); - bool bRet = false; + CCASSERT(!data, "Array cannot be re-initialized"); + + bool ret = false; do { CC_BREAK_IF(! initWithCapacity(otherArray->data->num)); addObjectsFromArray(otherArray); - bRet = true; + ret = true; } while (0); - return bRet; + return ret; } int Array::getIndexOfObject(Object* object) const @@ -640,20 +644,20 @@ void Array::setObject(Object* object, int index) } } -void Array::removeLastObject(bool bReleaseObj) +void Array::removeLastObject(bool releaseObj) { CCASSERT(data->num, "no objects added"); - ccArrayRemoveObjectAtIndex(data, data->num-1, bReleaseObj); + ccArrayRemoveObjectAtIndex(data, data->num-1, releaseObj); } -void Array::removeObject(Object* object, bool bReleaseObj/* = true*/) +void Array::removeObject(Object* object, bool releaseObj/* = true*/) { - ccArrayRemoveObject(data, object, bReleaseObj); + ccArrayRemoveObject(data, object, releaseObj); } -void Array::removeObjectAtIndex(unsigned int index, bool bReleaseObj) +void Array::removeObjectAtIndex(unsigned int index, bool releaseObj) { - ccArrayRemoveObjectAtIndex(data, index, bReleaseObj); + ccArrayRemoveObjectAtIndex(data, index, releaseObj); } void Array::removeObjectsInArray(Array* otherArray) @@ -698,9 +702,9 @@ void Array::exchangeObjectAtIndex(unsigned int index1, unsigned int index2) ccArraySwapObjectsAtIndexes(data, index1, index2); } -void Array::replaceObjectAtIndex(unsigned int index, Object* pObject, bool bReleaseObject/* = true*/) +void Array::replaceObjectAtIndex(unsigned int index, Object* object, bool releaseObject/* = true*/) { - ccArrayInsertObjectAtIndex(data, pObject, index); + ccArrayInsertObjectAtIndex(data, object, index); ccArrayRemoveObjectAtIndex(data, index+1); } @@ -765,26 +769,12 @@ void Array::acceptVisitor(DataVisitor &visitor) Array::iterator Array::begin() { - if (count() > 0) - { - return Array::ArrayIterator( getObjectAtIndex(0), this); - } - else - { - return Array::ArrayIterator(nullptr, nullptr);; - } + return Array::ArrayIterator(0, this); } Array::iterator Array::end() { - if (count() > 0) - { - return Array::ArrayIterator(getObjectAtIndex(count()), this); - } - else - { - return Array::ArrayIterator(nullptr, nullptr); - } + return Array::ArrayIterator(count(), this); } #endif // uses ccArray diff --git a/cocos2dx/cocoa/CCArray.h b/cocos2dx/cocoa/CCArray.h index 82de141bf7..749ddc7f46 100644 --- a/cocos2dx/cocoa/CCArray.h +++ b/cocos2dx/cocoa/CCArray.h @@ -210,7 +210,7 @@ do { \ } \ while(false) -#define arrayMakeObjectsPerformSelectorWithObject(pArray, func, pObject, elementType) \ +#define arrayMakeObjectsPerformSelectorWithObject(pArray, func, object, elementType) \ do { \ if(pArray && pArray->count() > 0) \ { \ @@ -220,7 +220,7 @@ do { \ elementType pNode = static_cast(child); \ if(pNode) \ { \ - pNode->func(pObject); \ + pNode->func(object); \ } \ } \ } \ @@ -237,9 +237,9 @@ public: /** Create an array */ static Array* create(); /** Create an array with some objects */ - static Array* create(Object* pObject, ...) CC_REQUIRES_NULL_TERMINATION; + static Array* create(Object* object, ...) CC_REQUIRES_NULL_TERMINATION; /** Create an array with one object */ - static Array* createWithObject(Object* pObject); + static Array* createWithObject(Object* object); /** Create an array with capacity */ static Array* createWithCapacity(unsigned int capacity); /** Create an array with an existing array */ @@ -262,9 +262,9 @@ public: /** Initializes an array */ bool init(); /** Initializes an array with one object */ - bool initWithObject(Object* pObject); + bool initWithObject(Object* object); /** Initializes an array with some objects */ - bool initWithObjects(Object* pObject, ...) CC_REQUIRES_NULL_TERMINATION; + bool initWithObjects(Object* object, ...) CC_REQUIRES_NULL_TERMINATION; /** Initializes an array with capacity */ bool initWithCapacity(unsigned int capacity); /** Initializes an array with an existing array */ @@ -319,7 +319,7 @@ public: /** Returns a Boolean value that indicates whether object is present in array. */ bool containsObject(Object* object) const; /** @since 1.1 */ - bool isEqualToArray(Array* pOtherArray); + bool isEqualToArray(Array* otherArray); // Adding Objects /** Add a certain object */ @@ -352,11 +352,11 @@ public: // Removing Objects /** Remove last object */ - void removeLastObject(bool bReleaseObj = true); + void removeLastObject(bool releaseObj = true); /** Remove a certain object */ - void removeObject(Object* object, bool bReleaseObj = true); + void removeObject(Object* object, bool releaseObj = true); /** Remove an element with a certain index */ - void removeObjectAtIndex(unsigned int index, bool bReleaseObj = true); + void removeObjectAtIndex(unsigned int index, bool releaseObj = true); /** Remove all elements */ void removeObjectsInArray(Array* otherArray); /** Remove all objects */ @@ -374,7 +374,7 @@ public: void exchangeObjectAtIndex(unsigned int index1, unsigned int index2); /** Replace object at index with another object. */ - void replaceObjectAtIndex(unsigned int uIndex, Object* pObject, bool bReleaseObject = true); + void replaceObjectAtIndex(unsigned int index, Object* object, bool releaseObject = true); /** Revers the array */ void reverseObjects(); @@ -401,28 +401,27 @@ public: class ArrayIterator : public std::iterator { public: - ArrayIterator(Object *object, Array *array) : _ptr(object), _parent(array) {} - ArrayIterator(const ArrayIterator& arrayIterator) : _ptr(arrayIterator._ptr), _parent(arrayIterator._parent) {} + ArrayIterator(int index, Array *array) : _index(index), _parent(array) {} + ArrayIterator(const ArrayIterator& arrayIterator) : _index(arrayIterator._index), _parent(arrayIterator._parent) {} ArrayIterator& operator++() { - int index = _parent->getIndexOfObject(_ptr); - _ptr = _parent->getObjectAtIndex(index+1); + ++_index; return *this; } - ArrayIterator operator++(int) + ArrayIterator operator++(int dummy) { ArrayIterator tmp(*this); (*this)++; return tmp; } - bool operator==(const ArrayIterator& rhs) { return _ptr == rhs._ptr; } - bool operator!=(const ArrayIterator& rhs) { return _ptr != rhs._ptr; } - Object* operator*() { return _ptr; } - Object* operator->() { return _ptr; } + bool operator==(const ArrayIterator& rhs) { return _index == rhs._index; } + bool operator!=(const ArrayIterator& rhs) { return _index != rhs._index; } + Object* operator*() { return _parent->getObjectAtIndex(_index); } + Object* operator->() { return _parent->getObjectAtIndex(_index); } private: - Object *_ptr; + int _index; Array *_parent; }; From 4d6d2d0dfa5d788984d1588e61bf57b55b0c2189 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Tue, 20 Aug 2013 14:17:26 -0700 Subject: [PATCH 047/126] Better default values for auto-release pool 150 is a reasonable number for auto-release pool. By using 150, it prevents the unneeded re-alloc of the pool. Signed-off-by: Ricardo Quesada --- cocos2dx/cocoa/CCAutoreleasePool.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2dx/cocoa/CCAutoreleasePool.cpp b/cocos2dx/cocoa/CCAutoreleasePool.cpp index 8c360e383a..fba96dced5 100644 --- a/cocos2dx/cocoa/CCAutoreleasePool.cpp +++ b/cocos2dx/cocoa/CCAutoreleasePool.cpp @@ -31,7 +31,7 @@ static PoolManager* s_pPoolManager = NULL; AutoreleasePool::AutoreleasePool() { _managedObjectArray = new Array(); - _managedObjectArray->init(); + _managedObjectArray->initWithCapacity(150); } AutoreleasePool::~AutoreleasePool() @@ -107,7 +107,7 @@ void PoolManager::purgePoolManager() PoolManager::PoolManager() { _releasePoolStack = new Array(); - _releasePoolStack->init(); + _releasePoolStack->initWithCapacity(150); _curReleasePool = 0; } From d96a504f3c3c954050dceda2e06c144ac9a45573 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Tue, 20 Aug 2013 14:17:43 -0700 Subject: [PATCH 048/126] cocos2d in lowercase Cocos2d -> cocos2d Signed-off-by: Ricardo Quesada --- cocos2dx/platform/ios/CCCommon.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2dx/platform/ios/CCCommon.mm b/cocos2dx/platform/ios/CCCommon.mm index dcf3a66a33..1d029a5b3a 100644 --- a/cocos2dx/platform/ios/CCCommon.mm +++ b/cocos2dx/platform/ios/CCCommon.mm @@ -34,7 +34,7 @@ NS_CC_BEGIN // XXX deprecated void CCLog(const char * pszFormat, ...) { - printf("Cocos2d: "); + printf("cocos2d: "); char szBuf[kMaxLogLen+1] = {0}; va_list ap; va_start(ap, pszFormat); @@ -46,7 +46,7 @@ void CCLog(const char * pszFormat, ...) void log(const char * pszFormat, ...) { - printf("Cocos2d: "); + printf("cocos2d: "); char szBuf[kMaxLogLen+1] = {0}; va_list ap; va_start(ap, pszFormat); From 4c99492589cae0e505888e685ccb9e233d19679e Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Tue, 20 Aug 2013 14:18:06 -0700 Subject: [PATCH 049/126] Profiling: more useful information Prints min,max, #calls Signed-off-by: Ricardo Quesada --- cocos2dx/support/CCProfiling.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cocos2dx/support/CCProfiling.cpp b/cocos2dx/support/CCProfiling.cpp index e238c45651..de3ea7122b 100644 --- a/cocos2dx/support/CCProfiling.cpp +++ b/cocos2dx/support/CCProfiling.cpp @@ -117,9 +117,10 @@ ProfilingTimer::~ProfilingTimer(void) const char* ProfilingTimer::description() const { - static char s_szDesciption[256] = {0}; - sprintf(s_szDesciption, "%s: avg time, %fms", _nameStr.c_str(), _averageTime); - return s_szDesciption; + static char s_desciption[512] = {0}; + + sprintf(s_desciption, "%s ::\tavg: %fms,\tmin: %fms,\tmax: %fms,\ttotal: %.2fs,\tnr calls: %ld", _nameStr.c_str(), _averageTime, minTime, maxTime, totalTime / 1000.0, (unsigned long)numberOfCalls); + return s_desciption; } void ProfilingTimer::reset() From c9b250d4a40cd8712504fb2e6a69391be129f473 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Tue, 20 Aug 2013 14:18:32 -0700 Subject: [PATCH 050/126] Adds new tests to tests and enables profiling Signed-off-by: Ricardo Quesada --- .../PerformanceNodeChildrenTest.cpp | 177 +++++++++++++----- .../PerformanceNodeChildrenTest.h | 17 +- 2 files changed, 144 insertions(+), 50 deletions(-) diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp index 90c28f9261..3687dfc35b 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp @@ -1,13 +1,49 @@ #include "PerformanceNodeChildrenTest.h" +// Enable profiles for this file +#undef CC_PROFILER_DISPLAY_TIMERS +#define CC_PROFILER_DISPLAY_TIMERS() Profiler::getInstance()->displayTimers() +#undef CC_PROFILER_PURGE_ALL +#define CC_PROFILER_PURGE_ALL() Profiler::getInstance()->releaseAllTimers() + +#undef CC_PROFILER_START +#define CC_PROFILER_START(__name__) ProfilingBeginTimingBlock(__name__) +#undef CC_PROFILER_STOP +#define CC_PROFILER_STOP(__name__) ProfilingEndTimingBlock(__name__) +#undef CC_PROFILER_RESET +#define CC_PROFILER_RESET(__name__) ProfilingResetTimingBlock(__name__) + +#undef CC_PROFILER_START_CATEGORY +#define CC_PROFILER_START_CATEGORY(__cat__, __name__) do{ if(__cat__) ProfilingBeginTimingBlock(__name__); } while(0) +#undef CC_PROFILER_STOP_CATEGORY +#define CC_PROFILER_STOP_CATEGORY(__cat__, __name__) do{ if(__cat__) ProfilingEndTimingBlock(__name__); } while(0) +#undef CC_PROFILER_RESET_CATEGORY +#define CC_PROFILER_RESET_CATEGORY(__cat__, __name__) do{ if(__cat__) ProfilingResetTimingBlock(__name__); } while(0) + +#undef CC_PROFILER_START_INSTANCE +#define CC_PROFILER_START_INSTANCE(__id__, __name__) do{ ProfilingBeginTimingBlock( String::createWithFormat("%08X - %s", __id__, __name__)->getCString() ); } while(0) +#undef CC_PROFILER_STOP_INSTANCE +#define CC_PROFILER_STOP_INSTANCE(__id__, __name__) do{ ProfilingEndTimingBlock( String::createWithFormat("%08X - %s", __id__, __name__)->getCString() ); } while(0) +#undef CC_PROFILER_RESET_INSTANCE +#define CC_PROFILER_RESET_INSTANCE(__id__, __name__) do{ ProfilingResetTimingBlock( String::createWithFormat("%08X - %s", __id__, __name__)->getCString() ); } while(0) + +static std::function createFunctions[] = +{ + CL(IterateSpriteSheetForLoop), + CL(IterateSpriteSheetCArray), + CL(IterateSpriteSheetIterator), + + CL(AddSpriteSheet), + CL(RemoveSpriteSheet), + CL(ReorderSpriteSheet), +}; + +#define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0])) + enum { kTagInfoLayer = 1, - kTagMainLayer = 2, - kTagLabelAtlas = 3, kTagBase = 20000, - - TEST_COUNT = 4, }; enum { @@ -15,7 +51,7 @@ enum { kNodesIncrease = 500, }; -static int s_nCurCase = 0; +static int g_curCase = 0; //////////////////////////////////////////////////////// // @@ -25,37 +61,42 @@ static int s_nCurCase = 0; NodeChildrenMenuLayer::NodeChildrenMenuLayer(bool bControlMenuVisible, int nMaxCases, int nCurCase) : PerformBasicLayer(bControlMenuVisible, nMaxCases, nCurCase) { +} +void NodeChildrenMenuLayer::onExitTransitionDidStart() +{ + auto director = Director::getInstance(); + auto sched = director->getScheduler(); + + sched->unscheduleSelector(SEL_SCHEDULE(&NodeChildrenMenuLayer::dumpProfilerInfo), this); +} + +void NodeChildrenMenuLayer::onEnterTransitionDidFinish() +{ + auto director = Director::getInstance(); + auto sched = director->getScheduler(); + + CC_PROFILER_PURGE_ALL(); + sched->scheduleSelector(SEL_SCHEDULE(&NodeChildrenMenuLayer::dumpProfilerInfo), this, 2, false); +} + + +void NodeChildrenMenuLayer::dumpProfilerInfo(float dt) +{ + CC_PROFILER_DISPLAY_TIMERS(); } void NodeChildrenMenuLayer::showCurrentTest() { - int nNodes = ((NodeChildrenMainScene*)getParent())->getQuantityOfNodes(); - NodeChildrenMainScene* scene = NULL; + int nodes = ((NodeChildrenMainScene*)getParent())->getQuantityOfNodes(); - switch (_curCase) - { -// case 0: -// scene = new IterateSpriteSheetFastEnum(); -// break; - case 0: - scene = new IterateSpriteSheetCArray(); - break; - case 1: - scene = new AddSpriteSheet(); - break; - case 2: - scene = new RemoveSpriteSheet(); - break; - case 3: - scene = new ReorderSpriteSheet(); - break; - } - s_nCurCase = _curCase; + auto scene = createFunctions[_curCase](); + + g_curCase = _curCase; if (scene) { - scene->initWithQuantityOfNodes(nNodes); + scene->initWithQuantityOfNodes(nodes); Director::getInstance()->replaceScene(scene); scene->release(); @@ -121,7 +162,7 @@ void NodeChildrenMainScene::initWithQuantityOfNodes(unsigned int nNodes) infoLabel->setPosition(Point(s.width/2, s.height/2-15)); addChild(infoLabel, 1, kTagInfoLayer); - auto menuLayer = new NodeChildrenMenuLayer(true, TEST_COUNT, s_nCurCase); + auto menuLayer = new NodeChildrenMenuLayer(true, MAX_LAYER, g_curCase); addChild(menuLayer); menuLayer->release(); @@ -143,7 +184,7 @@ void NodeChildrenMainScene::updateQuantityLabel() { if( quantityOfNodes != lastRenderedCount ) { - auto infoLabel = (LabelTTF *) getChildByTag(kTagInfoLayer); + auto infoLabel = static_cast( getChildByTag(kTagInfoLayer) ); char str[20] = {0}; sprintf(str, "%u nodes", quantityOfNodes); infoLabel->setString(str); @@ -173,7 +214,8 @@ void IterateSpriteSheet::updateQuantityOfNodes() { auto sprite = Sprite::createWithTexture(batchNode->getTexture(), Rect(0, 0, 32, 32)); batchNode->addChild(sprite); - sprite->setPosition(Point( CCRANDOM_0_1()*s.width, CCRANDOM_0_1()*s.height)); + sprite->setVisible(false); + sprite->setPosition(Point(-1000,-1000)); } } @@ -207,39 +249,38 @@ const char* IterateSpriteSheet::profilerName() //////////////////////////////////////////////////////// // -// IterateSpriteSheetFastEnum +// IterateSpriteSheetForLoop // //////////////////////////////////////////////////////// -void IterateSpriteSheetFastEnum::update(float dt) +void IterateSpriteSheetForLoop::update(float dt) { // iterate using fast enumeration protocol - auto pChildren = batchNode->getChildren(); - Object* pObject = NULL; + auto children = batchNode->getChildren(); - CC_PROFILER_START_INSTANCE(this, this->profilerName()); + CC_PROFILER_START(this->profilerName()); - CCARRAY_FOREACH(pChildren, pObject) + for( const auto &object : *children ) { - auto sprite = static_cast(pObject); + auto sprite = static_cast(object); sprite->setVisible(false); } - CC_PROFILER_STOP_INSTANCE(this, this->profilerName()); + CC_PROFILER_STOP(this->profilerName()); } -std::string IterateSpriteSheetFastEnum::title() +std::string IterateSpriteSheetForLoop::title() { return "A - Iterate SpriteSheet"; } -std::string IterateSpriteSheetFastEnum::subtitle() +std::string IterateSpriteSheetForLoop::subtitle() { - return "Iterate children using Fast Enum API. See console"; + return "Iterate children using C++11 range-based for loop. See console"; } -const char* IterateSpriteSheetFastEnum::profilerName() +const char* IterateSpriteSheetForLoop::profilerName() { - return "iter fast enum"; + return "Iterator: C++11 for loop"; } //////////////////////////////////////////////////////// @@ -250,14 +291,14 @@ const char* IterateSpriteSheetFastEnum::profilerName() void IterateSpriteSheetCArray::update(float dt) { // iterate using fast enumeration protocol - auto pChildren = batchNode->getChildren(); - Object* pObject = NULL; + auto children = batchNode->getChildren(); + Object* object = NULL; CC_PROFILER_START(this->profilerName()); - CCARRAY_FOREACH(pChildren, pObject) + CCARRAY_FOREACH(children, object) { - auto sprite = static_cast(pObject); + auto sprite = static_cast(object); sprite->setVisible(false); } @@ -277,9 +318,47 @@ std::string IterateSpriteSheetCArray::subtitle() const char* IterateSpriteSheetCArray::profilerName() { - return "iter c-array"; + return "Iterator: CC_ARRAY_FOREACH"; } +//////////////////////////////////////////////////////// +// +// IterateSpriteSheetIterator +// +//////////////////////////////////////////////////////// +void IterateSpriteSheetIterator::update(float dt) +{ + // iterate using fast enumeration protocol + auto children = batchNode->getChildren(); + + CC_PROFILER_START(this->profilerName()); + + for( auto it=std::begin(*children); it != std::end(*children); ++it) + { + auto sprite = static_cast(*it); + sprite->setVisible(false); + } + + CC_PROFILER_STOP(this->profilerName()); +} + + +std::string IterateSpriteSheetIterator::title() +{ + return "C - Iterate SpriteSheet"; +} + +std::string IterateSpriteSheetIterator::subtitle() +{ + return "Iterate children using begin() / end(). See console"; +} + +const char* IterateSpriteSheetIterator::profilerName() +{ + return "Iterator: begin(), end()"; +} + + //////////////////////////////////////////////////////// // // AddRemoveSpriteSheet @@ -520,7 +599,7 @@ const char* ReorderSpriteSheet::profilerName() void runNodeChildrenTest() { - IterateSpriteSheet* scene = new IterateSpriteSheetCArray(); + auto scene = createFunctions[g_curCase](); scene->initWithQuantityOfNodes(kNodesIncrease); Director::getInstance()->replaceScene(scene); diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.h b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.h index 6ac4de11d6..6e513971ea 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.h +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.h @@ -9,6 +9,11 @@ class NodeChildrenMenuLayer : public PerformBasicLayer public: NodeChildrenMenuLayer(bool bControlMenuVisible, int nMaxCases = 0, int nCurCase = 0); virtual void showCurrentTest(); + void dumpProfilerInfo(float dt); + + // overrides + virtual void onExitTransitionDidStart() override; + virtual void onEnterTransitionDidFinish() override; }; class NodeChildrenMainScene : public Scene @@ -42,7 +47,17 @@ protected: SpriteBatchNode *batchNode; }; -class IterateSpriteSheetFastEnum : public IterateSpriteSheet +class IterateSpriteSheetForLoop : public IterateSpriteSheet +{ +public: + virtual void update(float dt); + + virtual std::string title(); + virtual std::string subtitle(); + virtual const char* profilerName(); +}; + +class IterateSpriteSheetIterator : public IterateSpriteSheet { public: virtual void update(float dt); From 20167e2a1287abfa9c16d896b77519a11ec6d9b4 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Tue, 20 Aug 2013 14:18:45 -0700 Subject: [PATCH 051/126] removes unneeded spaces Signed-off-by: Ricardo Quesada --- .../TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id b/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id index 8201938a30..6dd751cebb 100644 --- a/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id +++ b/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id @@ -1 +1 @@ -a9353854e127b5c4b6a07c55f6a961d1ece1f88b \ No newline at end of file +6b5ddb2c8e2b4b8dea01e8ff068ff9a15795db69 \ No newline at end of file From f7241ea533eec277be700f2bc4069be8e41c476e Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Tue, 20 Aug 2013 16:06:04 -0700 Subject: [PATCH 052/126] Default capacity of Array is 10 plus better documentation Signed-off-by: Ricardo Quesada --- cocos2dx/cocoa/CCArray.cpp | 6 ++++-- cocos2dx/cocoa/CCArray.h | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/cocos2dx/cocoa/CCArray.cpp b/cocos2dx/cocoa/CCArray.cpp index eb80982de0..114fc1b7ec 100644 --- a/cocos2dx/cocoa/CCArray.cpp +++ b/cocos2dx/cocoa/CCArray.cpp @@ -144,7 +144,7 @@ Array* Array::createWithContentsOfFileThreadSafe(const char* fileName) bool Array::init() { - return initWithCapacity(1); + return initWithCapacity(10); } bool Array::initWithObject(Object* object) @@ -509,6 +509,8 @@ Array* Array::createWithContentsOfFileThreadSafe(const char* fileName) bool Array::init() { + CCASSERT(!data, "Array cannot be re-initialized"); + return initWithCapacity(1); } @@ -618,7 +620,7 @@ bool Array::isEqualToArray(Array* otherArray) return true; } -void Array::addObject(Object* object) +void Array::addObject(Object* object) { ccArrayAppendObjectWithResize(data, object); } diff --git a/cocos2dx/cocoa/CCArray.h b/cocos2dx/cocoa/CCArray.h index 749ddc7f46..aba86abb54 100644 --- a/cocos2dx/cocoa/CCArray.h +++ b/cocos2dx/cocoa/CCArray.h @@ -234,15 +234,15 @@ class CC_DLL Array : public Object, public Clonable { public: - /** Create an array */ + /** Creates an empty array. Default capacity is 10 */ static Array* create(); - /** Create an array with some objects */ + /** Create an array with objects */ static Array* create(Object* object, ...) CC_REQUIRES_NULL_TERMINATION; /** Create an array with one object */ static Array* createWithObject(Object* object); - /** Create an array with capacity */ + /** Create an array with a default capacity */ static Array* createWithCapacity(unsigned int capacity); - /** Create an array with an existing array */ + /** Create an array with from an existing array */ static Array* createWithArray(Array* otherArray); /** @brief Generate a Array pointer by file From f9df7cf4e517ce92bb878de7c60fab7354171cc0 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Tue, 20 Aug 2013 16:06:34 -0700 Subject: [PATCH 053/126] Uses high resolution clock for Profiling and adds another average time. Signed-off-by: Ricardo Quesada --- cocos2dx/support/CCProfiling.cpp | 44 +++++++++++++++++--------------- cocos2dx/support/CCProfiling.h | 26 +++++++++++-------- 2 files changed, 39 insertions(+), 31 deletions(-) diff --git a/cocos2dx/support/CCProfiling.cpp b/cocos2dx/support/CCProfiling.cpp index de3ea7122b..512057577a 100644 --- a/cocos2dx/support/CCProfiling.cpp +++ b/cocos2dx/support/CCProfiling.cpp @@ -24,6 +24,8 @@ THE SOFTWARE. ****************************************************************************/ #include "CCProfiling.h" +#include + using namespace std; NS_CC_BEGIN @@ -97,16 +99,19 @@ void Profiler::displayTimers() // implementation of ProfilingTimer +ProfilingTimer::ProfilingTimer() +: numberOfCalls(0) +, _averageTime1(0) +, _averageTime2(0) +, totalTime(0) +, minTime(100000000) +, maxTime(0) +{ +} + bool ProfilingTimer::initWithName(const char* timerName) { _nameStr = timerName; - numberOfCalls = 0; - _averageTime = 0.0; - totalTime = 0.0; - minTime = 10000.0; - maxTime = 0.0; - gettimeofday((struct timeval *)&_startTime, NULL); - return true; } @@ -119,32 +124,33 @@ const char* ProfilingTimer::description() const { static char s_desciption[512] = {0}; - sprintf(s_desciption, "%s ::\tavg: %fms,\tmin: %fms,\tmax: %fms,\ttotal: %.2fs,\tnr calls: %ld", _nameStr.c_str(), _averageTime, minTime, maxTime, totalTime / 1000.0, (unsigned long)numberOfCalls); + sprintf(s_desciption, "%s ::\tavg1: %dµ,\tavg2: %dµ,\tmin: %dµ,\tmax: %dµ,\ttotal: %.4fs,\tnr calls: %d", _nameStr.c_str(), _averageTime1, _averageTime2, minTime, maxTime, totalTime/1000000., numberOfCalls); return s_desciption; } void ProfilingTimer::reset() { numberOfCalls = 0; - _averageTime = 0; + _averageTime1 = 0; + _averageTime2 = 0; totalTime = 0; - minTime = 10000; + minTime = 100000000; maxTime = 0; - gettimeofday((struct timeval *)&_startTime, NULL); + _startTime = chrono::high_resolution_clock::now(); } void ProfilingBeginTimingBlock(const char *timerName) { Profiler* p = Profiler::getInstance(); - ProfilingTimer* timer = (ProfilingTimer*)p->_activeTimers->objectForKey(timerName); + ProfilingTimer* timer = static_cast( p->_activeTimers->objectForKey(timerName) ); if( ! timer ) { timer = p->createAndAddTimerWithName(timerName); } - gettimeofday(&timer->_startTime, NULL); - timer->numberOfCalls++; + + timer->_startTime = chrono::high_resolution_clock::now(); } void ProfilingEndTimingBlock(const char *timerName) @@ -154,15 +160,13 @@ void ProfilingEndTimingBlock(const char *timerName) CCASSERT(timer, "CCProfilingTimer not found"); - struct timeval currentTime; - gettimeofday(¤tTime, NULL); + auto now = chrono::high_resolution_clock::now(); - double duration = (currentTime.tv_sec*1000.0 + currentTime.tv_usec/1000.0) - - (timer->_startTime.tv_sec*1000.0 + timer->_startTime.tv_usec/1000.0); + int duration = chrono::duration_cast(now - timer->_startTime).count(); - // milliseconds - timer->_averageTime = (timer->_averageTime + duration) / 2.0f; timer->totalTime += duration; + timer->_averageTime1 = (timer->_averageTime1 + duration) / 2.0f; + timer->_averageTime2 = timer->totalTime / timer->numberOfCalls; timer->maxTime = MAX( timer->maxTime, duration); timer->minTime = MIN( timer->minTime, duration); diff --git a/cocos2dx/support/CCProfiling.h b/cocos2dx/support/CCProfiling.h index 673980e603..fa033db186 100644 --- a/cocos2dx/support/CCProfiling.h +++ b/cocos2dx/support/CCProfiling.h @@ -25,10 +25,11 @@ THE SOFTWARE. #ifndef __SUPPORT_CCPROFILING_H__ #define __SUPPORT_CCPROFILING_H__ +#include +#include #include "ccConfig.h" #include "cocoa/CCObject.h" #include "cocoa/CCDictionary.h" -#include NS_CC_BEGIN @@ -72,22 +73,25 @@ public: class ProfilingTimer : public Object { public: - bool initWithName(const char* timerName); + ProfilingTimer(); ~ProfilingTimer(void); + + bool initWithName(const char* timerName); + const char* description(void) const; - inline struct timeval * getStartTime(void) { return &_startTime; }; - inline void setAverageTime(double value) { _averageTime = value; } - inline double getAverageTime(void) { return _averageTime; } + inline const std::chrono::high_resolution_clock::time_point& getStartTime(void) { return _startTime; }; + /** resets the timer properties */ void reset(); std::string _nameStr; - struct timeval _startTime; - double _averageTime; - double minTime; - double maxTime; - double totalTime; - unsigned int numberOfCalls; + std::chrono::high_resolution_clock::time_point _startTime; + int _averageTime1; + int _averageTime2; + int minTime; + int maxTime; + long long totalTime; + int numberOfCalls; }; extern void ProfilingBeginTimingBlock(const char *timerName); From e5551b2872adb1e6300de9250f1cd7160ad17450 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Tue, 20 Aug 2013 16:06:51 -0700 Subject: [PATCH 054/126] Compiles both with std::vector and ccCArray Signed-off-by: Ricardo Quesada --- .../Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp index 3687dfc35b..1bc06d48b5 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp @@ -261,7 +261,8 @@ void IterateSpriteSheetForLoop::update(float dt) for( const auto &object : *children ) { - auto sprite = static_cast(object); + auto o = static_cast(object); + auto sprite = static_cast(o); sprite->setVisible(false); } @@ -335,7 +336,8 @@ void IterateSpriteSheetIterator::update(float dt) for( auto it=std::begin(*children); it != std::end(*children); ++it) { - auto sprite = static_cast(*it); + auto obj = static_cast(*it); + auto sprite = static_cast(obj); sprite->setVisible(false); } From cf02cb45819e0537743da76b657521d42bd23ab4 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Tue, 20 Aug 2013 18:05:35 -0700 Subject: [PATCH 055/126] Fixes names in Performance Node tests Signed-off-by: Ricardo Quesada --- .../Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp index 1bc06d48b5..e9fba85928 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp @@ -464,7 +464,7 @@ void AddSpriteSheet::update(float dt) std::string AddSpriteSheet::title() { - return "C - Add to spritesheet"; + return "D - Add to spritesheet"; } std::string AddSpriteSheet::subtitle() @@ -520,7 +520,7 @@ void RemoveSpriteSheet::update(float dt) std::string RemoveSpriteSheet::title() { - return "D - Del from spritesheet"; + return "E - Del from spritesheet"; } std::string RemoveSpriteSheet::subtitle() @@ -586,7 +586,7 @@ void ReorderSpriteSheet::update(float dt) std::string ReorderSpriteSheet::title() { - return "E - Reorder from spritesheet"; + return "F - Reorder from spritesheet"; } std::string ReorderSpriteSheet::subtitle() From 1ee7790f0eb77645d1eb6aa8e465f24cb3453e31 Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 22 Aug 2013 10:15:47 +0800 Subject: [PATCH 056/126] Initializing Array after it was constructed. --- cocos2dx/platform/CCFileUtils.cpp | 1 + cocos2dx/platform/ios/CCFileUtilsIOS.mm | 15 +++++++++------ cocos2dx/platform/mac/CCFileUtilsMac.mm | 14 ++++++++------ extensions/CCBReader/CCBAnimationManager.cpp | 13 +++++++++++++ extensions/CCBReader/CCBReader.cpp | 5 +++++ extensions/CCBReader/CCBSequenceProperty.cpp | 1 + extensions/GUI/CCScrollView/CCScrollView.cpp | 2 ++ extensions/GUI/CCScrollView/CCTableView.cpp | 3 +++ .../bindings/cocos2d_specifics.cpp.REMOVED.git-id | 2 +- .../bindings/jsb_cocos2dx_extension_manual.cpp | 1 + 10 files changed, 44 insertions(+), 13 deletions(-) diff --git a/cocos2dx/platform/CCFileUtils.cpp b/cocos2dx/platform/CCFileUtils.cpp index c14a759f64..e1a366096d 100644 --- a/cocos2dx/platform/CCFileUtils.cpp +++ b/cocos2dx/platform/CCFileUtils.cpp @@ -177,6 +177,7 @@ public: { _state = SAX_ARRAY; _array = new Array(); + _array->init(); if (_resultType == SAX_RESULT_ARRAY && _rootArray == NULL) { _rootArray = _array; diff --git a/cocos2dx/platform/ios/CCFileUtilsIOS.mm b/cocos2dx/platform/ios/CCFileUtilsIOS.mm index 519353c367..00eea5a631 100644 --- a/cocos2dx/platform/ios/CCFileUtilsIOS.mm +++ b/cocos2dx/platform/ios/CCFileUtilsIOS.mm @@ -354,15 +354,18 @@ Array* FileUtilsIOS::createArrayWithContentsOfFile(const std::string& filename) // pPath = [[NSBundle mainBundle] pathForResource:pPath ofType:pathExtension]; // fixing cannot read data using Array::createWithContentsOfFile std::string fullPath = FileUtils::getInstance()->fullPathForFilename(filename.c_str()); - NSString* pPath = [NSString stringWithUTF8String:fullPath.c_str()]; - NSArray* pArray = [NSArray arrayWithContentsOfFile:pPath]; + NSString* path = [NSString stringWithUTF8String:fullPath.c_str()]; + NSArray* array = [NSArray arrayWithContentsOfFile:path]; - Array* pRet = new Array(); - for (id value in pArray) { - addItemToArray(value, pRet); + Array* ret = new Array(); + ret->init(); + + for (id value in array) + { + addItemToArray(value, ret); } - return pRet; + return ret; } NS_CC_END diff --git a/cocos2dx/platform/mac/CCFileUtilsMac.mm b/cocos2dx/platform/mac/CCFileUtilsMac.mm index 426a42149c..6bf8e16b98 100644 --- a/cocos2dx/platform/mac/CCFileUtilsMac.mm +++ b/cocos2dx/platform/mac/CCFileUtilsMac.mm @@ -337,15 +337,17 @@ Array* FileUtilsMac::createArrayWithContentsOfFile(const std::string& filename) // pPath = [[NSBundle mainBundle] pathForResource:pPath ofType:pathExtension]; // fixing cannot read data using Array::createWithContentsOfFile std::string fullPath = FileUtils::getInstance()->fullPathForFilename(filename.c_str()); - NSString* pPath = [NSString stringWithUTF8String:fullPath.c_str()]; - NSArray* pArray = [NSArray arrayWithContentsOfFile:pPath]; + NSString* path = [NSString stringWithUTF8String:fullPath.c_str()]; + NSArray* array = [NSArray arrayWithContentsOfFile:path]; - Array* pRet = new Array(); - for (id value in pArray) { - addItemToArray(value, pRet); + Array* ret = new Array(); + ret->init(); + + for (id value in array) { + addItemToArray(value, ret); } - return pRet; + return ret; } diff --git a/extensions/CCBReader/CCBAnimationManager.cpp b/extensions/CCBReader/CCBAnimationManager.cpp index 7b6172a3dd..653aee289d 100644 --- a/extensions/CCBReader/CCBAnimationManager.cpp +++ b/extensions/CCBReader/CCBAnimationManager.cpp @@ -35,15 +35,28 @@ CCBAnimationManager::CCBAnimationManager() bool CCBAnimationManager::init() { _sequences = new Array(); + _sequences->init(); _nodeSequences = new Dictionary(); _baseValues = new Dictionary(); _documentOutletNames = new Array(); + _documentOutletNames->init(); + _documentOutletNodes = new Array(); + _documentOutletNodes->init(); + _documentCallbackNames = new Array(); + _documentCallbackNames->init(); + _documentCallbackNodes = new Array(); + _documentCallbackNodes->init(); + _documentCallbackControlEvents = new Array(); + _documentCallbackControlEvents->init(); + _keyframeCallbacks = new Array(); + _keyframeCallbacks->init(); + _keyframeCallFuncs = new Dictionary(); _target = NULL; diff --git a/extensions/CCBReader/CCBReader.cpp b/extensions/CCBReader/CCBReader.cpp index b0d98e1fa5..7397489fc9 100644 --- a/extensions/CCBReader/CCBReader.cpp +++ b/extensions/CCBReader/CCBReader.cpp @@ -154,8 +154,11 @@ const std::string& CCBReader::getCCBRootPath() const bool CCBReader::init() { _ownerOutletNodes = new Array(); + _ownerOutletNodes->init(); _ownerCallbackNodes = new Array(); + _ownerCallbackNodes->init(); _ownerOwnerCallbackControlEvents = new Array(); + _ownerOwnerCallbackControlEvents->init(); // Setup action manager CCBAnimationManager *pActionManager = new CCBAnimationManager(); @@ -278,7 +281,9 @@ Node* CCBReader::readNodeGraphFromData(Data *pData, Object *pOwner, const Size & if(_jsControlled) { _nodesWithAnimationManagers = new Array(); + _nodesWithAnimationManagers->init(); _animationManagersForNodes = new Array(); + _animationManagersForNodes->init(); } DictElement* pElement = NULL; diff --git a/extensions/CCBReader/CCBSequenceProperty.cpp b/extensions/CCBReader/CCBSequenceProperty.cpp index ca39935e57..8bb1881855 100644 --- a/extensions/CCBReader/CCBSequenceProperty.cpp +++ b/extensions/CCBReader/CCBSequenceProperty.cpp @@ -15,6 +15,7 @@ CCBSequenceProperty::CCBSequenceProperty() bool CCBSequenceProperty::init() { _keyframes = new Array(); + _keyframes->init(); return true; } diff --git a/extensions/GUI/CCScrollView/CCScrollView.cpp b/extensions/GUI/CCScrollView/CCScrollView.cpp index 64a1766b51..f4270a37b1 100644 --- a/extensions/GUI/CCScrollView/CCScrollView.cpp +++ b/extensions/GUI/CCScrollView/CCScrollView.cpp @@ -110,6 +110,8 @@ bool ScrollView::initWithViewSize(Size size, Node *container/* = NULL*/) setTouchEnabled(true); _touches = new Array(); + _touches->init(); + _delegate = NULL; _bounceable = true; _clippingToBounds = true; diff --git a/extensions/GUI/CCScrollView/CCTableView.cpp b/extensions/GUI/CCScrollView/CCTableView.cpp index e11d31805b..6e74419e3f 100644 --- a/extensions/GUI/CCScrollView/CCTableView.cpp +++ b/extensions/GUI/CCScrollView/CCTableView.cpp @@ -54,7 +54,9 @@ bool TableView::initWithViewSize(Size size, Node* container/* = NULL*/) if (ScrollView::initWithViewSize(size,container)) { _cellsUsed = new ArrayForObjectSorting(); + _cellsUsed->init(); _cellsFreed = new ArrayForObjectSorting(); + _cellsFreed->init(); _indices = new std::set(); _vordering = VerticalFillOrder::BOTTOM_UP; this->setDirection(Direction::VERTICAL); @@ -122,6 +124,7 @@ void TableView::reloadData() _indices->clear(); _cellsUsed->release(); _cellsUsed = new ArrayForObjectSorting(); + _cellsUsed->init(); this->_updateCellPositions(); this->_updateContentSize(); diff --git a/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id b/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id index 6655e24fb3..04f83fd48c 100644 --- a/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id +++ b/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id @@ -1 +1 @@ -d17c1939227c62cebcc30a071cf81b12bfa08db3 \ No newline at end of file +69358d388dd779c6334c786e53ea14243bfde00b \ No newline at end of file diff --git a/scripting/javascript/bindings/jsb_cocos2dx_extension_manual.cpp b/scripting/javascript/bindings/jsb_cocos2dx_extension_manual.cpp index 111fc16e95..abaf07a2f7 100644 --- a/scripting/javascript/bindings/jsb_cocos2dx_extension_manual.cpp +++ b/scripting/javascript/bindings/jsb_cocos2dx_extension_manual.cpp @@ -720,6 +720,7 @@ static JSBool js_cocos2dx_CCControl_addTargetWithActionForControlEvents(JSContex if (nullptr == nativeDelegateArray) { nativeDelegateArray = new Array(); + nativeDelegateArray->init(); cobj->setUserObject(nativeDelegateArray); // The reference of nativeDelegateArray is added to 2 nativeDelegateArray->release(); // Release nativeDelegateArray to make the reference to 1 } From bea62800b48072d30ef71f907c03a177f434c838 Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Thu, 22 Aug 2013 10:16:57 +0800 Subject: [PATCH 057/126] issue #2433:Modify TestLua samples and add some manual binding code --- .../project.pbxproj.REMOVED.git-id | 2 +- .../ExtensionTest/CocosBuilderTest.lua | 178 ++-- .../luaScript/ExtensionTest/ExtensionTest.lua | 112 ++- .../luaScript/ExtensionTest/WebProxyTest.lua | 48 +- scripting/lua/cocos2dx_support/CCBProxy.cpp | 65 +- scripting/lua/cocos2dx_support/CCBProxy.h | 2 +- .../lua/cocos2dx_support/CCLuaEngine.cpp | 5 +- scripting/lua/cocos2dx_support/CCLuaStack.cpp | 7 +- .../lua_cocos2dx_auto.cpp.REMOVED.git-id | 2 +- .../generated/lua_cocos2dx_auto.hpp | 1 - .../lua_cocos2dx_auto_api.js.REMOVED.git-id | 2 +- ...cocos2dx_extension_auto.cpp.REMOVED.git-id | 2 +- .../generated/lua_cocos2dx_extension_auto.hpp | 1 - .../lua_cocos2dx_extension_auto_api.js | 7 - .../lua_cocos2dx_extension_manual.cpp | 862 ++++++++++++++++++ .../lua_cocos2dx_extension_manual.h | 15 + .../{generated => }/lua_cocos2dx_manual.cpp | 239 +++-- .../{generated => }/lua_cocos2dx_manual.hpp | 0 scripting/lua/script/CCBReaderLoad.lua | 96 +- scripting/lua/script/Cocos2dConstants.lua | 57 ++ tools/bindings-generator | 2 +- tools/tolua/cocos2dx.ini | 2 +- tools/tolua/cocos2dx_extension.ini | 5 +- 23 files changed, 1370 insertions(+), 342 deletions(-) create mode 100644 scripting/lua/cocos2dx_support/lua_cocos2dx_extension_manual.cpp create mode 100644 scripting/lua/cocos2dx_support/lua_cocos2dx_extension_manual.h rename scripting/lua/cocos2dx_support/{generated => }/lua_cocos2dx_manual.cpp (91%) rename scripting/lua/cocos2dx_support/{generated => }/lua_cocos2dx_manual.hpp (100%) diff --git a/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id b/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id index 82840f3afb..6122e079d2 100644 --- a/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -23a03d1e4bd7f9adb02e324d82726175a192d237 \ No newline at end of file +1967da55fdcb71f9dd3dda53661eb4a1938803cf \ No newline at end of file diff --git a/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/CocosBuilderTest.lua b/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/CocosBuilderTest.lua index 08bde4efab..a379690f84 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/CocosBuilderTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/CocosBuilderTest.lua @@ -4,60 +4,33 @@ require "CCBReaderLoad" HelloCocosBuilderLayer = HelloCocosBuilderLayer or {} ccb["HelloCocosBuilderLayer"] = HelloCocosBuilderLayer -HelloCocosBuilderLayerOwner = HelloCocosBuilderLayerOwner or {} -ccb["HelloCocosBuilderLayerOwner"] = HelloCocosBuilderLayerOwner - TestMenusLayer = TestMenusLayer or {} ccb["TestMenusLayer"] = TestMenusLayer -TestMenusLayerOwner = TestMenusLayerOwner or {} -ccb["TestMenusLayerOwner"] = TestMenusLayerOwner - TestButtonsLayer = TestButtonsLayer or {} ccb["TestButtonsLayer"] = TestButtonsLayer -TestButtonsLayerOwner = TestButtonsLayerOwner or {} -ccb["TestButtonsLayerOwner"] = TestButtonsLayerOwner - TestHeaderLayer = TestHeaderLayer or {} ccb["TestHeaderLayer"] = TestHeaderLayer -TestHeaderLayerOwner = TestHeaderLayerOwner or {} -ccb["TestHeaderLayerOwner"] = TestHeaderLayerOwner - TestSpritesLayer = TestSpritesLayer or {} ccb["TestSpritesLayer"] = TestSpritesLayer -TestSpritesLayerOwner = TestSpritesLayerOwner or {} -ccb["TestSpritesLayerOwner"] = TestSpritesLayerOwner - TestParticleSystemsLayer = TestParticleSystemsLayer or {} ccb["TestParticleSystemsLayer"] = TestParticleSystemsLayer -TestParticleSystemsOwner = TestParticleSystemsOwner or {} -ccb["TestParticleSystemsLayerOwner"] = TestParticleSystemsLayerOwner - TestAnimationsLayer = TestAnimationsLayer or {} ccb["TestAnimationsLayer"] = TestAnimationsLayer -TestAnimationsLayerOwner = TestAnimationsLayerOwner or {} -ccb["TestAnimationsLayerOwner"] = TestAnimationsLayerOwner - TestTimelineLayer = TestTimelineLayer or {} ccb["TestTimelineLayer"] = TestTimelineLayer -TestTimelineLayerOwner = TestTimelineLayerOwner or {} -ccb["TestTimelineLayerOwner"] = TestTimelineLayerOwner - TestScrollViewsLayer = TestScrollViewsLayer or {} ccb["TestScrollViewsLayer"] = TestScrollViewsLayer -TestScrollViewsLayerOwner = TestScrollViewsLayerOwner or {} -ccb["TestScrollViewsLayerOwner"] = TestScrollViewsLayerOwner - local function onMenuItemAClicked() if nil ~= TestMenusLayer["mMenuItemStatusLabelBMFont"] then - local labelBmFt = tolua.cast(TestMenusLayer["mMenuItemStatusLabelBMFont"],"CCLabelBMFont") + local labelBmFt = tolua.cast(TestMenusLayer["mMenuItemStatusLabelBMFont"],"LabelBMFont") if nil ~= labelBmFt then labelBmFt:setString("Menu Item A clicked."); end @@ -66,7 +39,7 @@ end local function onMenuItemBClicked() if nil ~= TestMenusLayer["mMenuItemStatusLabelBMFont"] then - local labelBmFt = tolua.cast(TestMenusLayer["mMenuItemStatusLabelBMFont"],"CCLabelBMFont") + local labelBmFt = tolua.cast(TestMenusLayer["mMenuItemStatusLabelBMFont"],"LabelBMFont") if nil ~= labelBmFt then labelBmFt:setString("Menu Item B clicked."); end @@ -75,7 +48,7 @@ end local function pressedC( ... ) if nil ~= TestMenusLayer["mMenuItemStatusLabelBMFont"] then - local labelBmFt = tolua.cast(TestMenusLayer["mMenuItemStatusLabelBMFont"],"CCLabelBMFont") + local labelBmFt = tolua.cast(TestMenusLayer["mMenuItemStatusLabelBMFont"],"LabelBMFont") if nil ~= labelBmFt then labelBmFt:setString("Menu Item C clicked."); end @@ -83,12 +56,12 @@ local function pressedC( ... ) end local function onMenuTestClicked() cclog("CCBMenuTest"); - local scene = CCScene:create() - local proxy = CCBProxy:create() - local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestMenus.ccbi",proxy,true,"TestMenusLayerOwner") - local layer = tolua.cast(node,"CCLayer") - if nil ~= TestMenusLayerOwner["mTestTitleLabelTTF"] then - local ccLabelTTF = tolua.cast(TestMenusLayerOwner["mTestTitleLabelTTF"],"CCLabelTTF") + local scene = cc.Scene:create() + local proxy = cc.CCBProxy:create() + local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestMenus.ccbi",proxy,HelloCocosBuilderLayer) + local layer = tolua.cast(node,"Layer") + if nil ~= HelloCocosBuilderLayer["mTestTitleLabelTTF"] then + local ccLabelTTF = tolua.cast(HelloCocosBuilderLayer["mTestTitleLabelTTF"],"LabelTTF") if nil ~= ccLabelTTF then ccLabelTTF:setString("ccb/ccb/TestMenus.ccbi") end @@ -96,7 +69,7 @@ local function onMenuTestClicked() if nil ~= scene then scene:addChild(layer) scene:addChild(CreateBackMenuItem()) - CCDirector:getInstance():pushScene(CCTransitionFade:create(0.5, scene, Color3B(0,0,0))); + cc.Director:getInstance():pushScene(cc.TransitionFade:create(0.5, scene, cc.c3b(0,0,0))); end end @@ -105,19 +78,19 @@ TestMenusLayer["onMenuItemBClicked"] = onMenuItemBClicked TestMenusLayer["pressedC:"] = pressedC local function onBackClicked() - CCDirector:getInstance():popScene(); + cc.Director:getInstance():popScene(); end TestHeaderLayer["onBackClicked"] = onBackClicked local function onSpriteTestClicked() cclog("CCBSpriteTest"); - local scene = CCScene:create() - local proxy = CCBProxy:create() - local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestSprites.ccbi",proxy,true,"TestSpritesLayerOwner") - local layer = tolua.cast(node,"CCLayer") - if nil ~= TestSpritesLayerOwner["mTestTitleLabelTTF"] then - local ccLabelTTF = tolua.cast(TestSpritesLayerOwner["mTestTitleLabelTTF"],"CCLabelTTF") + local scene = cc.Scene:create() + local proxy = cc.CCBProxy:create() + local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestSprites.ccbi",proxy,HelloCocosBuilderLayer) + local layer = tolua.cast(node,"Layer") + if nil ~= HelloCocosBuilderLayer["mTestTitleLabelTTF"] then + local ccLabelTTF = tolua.cast(HelloCocosBuilderLayer["mTestTitleLabelTTF"],"LabelTTF") if nil ~= ccLabelTTF then ccLabelTTF:setString("ccb/ccb/TestSprites.ccbi") end @@ -125,18 +98,18 @@ local function onSpriteTestClicked() if nil ~= scene then scene:addChild(layer) scene:addChild(CreateBackMenuItem()) - CCDirector:getInstance():pushScene(CCTransitionFade:create(0.5, scene, Color3B(0,0,0))); + cc.Director:getInstance():pushScene(cc.TransitionFade:create(0.5, scene, cc.c3b(0,0,0))); end end local function onButtonTestClicked() cclog("CCBButtionTest"); - local scene = CCScene:create() - local proxy = CCBProxy:create() - local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestButtons.ccbi",proxy,true,"TestButtonsLayerOwner") - local layer = tolua.cast(node,"CCLayer") - if nil ~= TestButtonsLayerOwner["mTestTitleLabelTTF"] then - local ccLabelTTF = tolua.cast(TestButtonsLayerOwner["mTestTitleLabelTTF"],"CCLabelTTF") + local scene = cc.Scene:create() + local proxy = cc.CCBProxy:create() + local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestButtons.ccbi",proxy,HelloCocosBuilderLayer) + local layer = tolua.cast(node,"Layer") + if nil ~= HelloCocosBuilderLayer["mTestTitleLabelTTF"] then + local ccLabelTTF = tolua.cast(HelloCocosBuilderLayer["mTestTitleLabelTTF"],"LabelTTF") if nil ~= ccLabelTTF then ccLabelTTF:setString("ccb/ccb/TestButtons.ccbi") end @@ -144,12 +117,36 @@ local function onButtonTestClicked() if nil ~= scene then scene:addChild(layer) scene:addChild(CreateBackMenuItem()) - CCDirector:getInstance():pushScene(CCTransitionFade:create(0.5, scene, Color3B(0,0,0))); + cc.Director:getInstance():pushScene(cc.TransitionFade:create(0.5, scene, cc.c3b(0,0,0))); end end -local function onCCControlButtonClicked() - --print("cc") +local function onCCControlButtonClicked(sender,controlEvent) + local labelTTF = tolua.cast(TestButtonsLayer["mCCControlEventLabel"],"LabelBMFont") + + if nil == labelTTF then + return + end + + if controlEvent == cc.CONTROL_EVENTTYPE_TOUCH_DOWN then + labelTTF:setString("Touch Down.") + elseif controlEvent == cc.CONTROL_EVENTTYPE_DRAG_INSIDE then + labelTTF:setString("Touch Drag Inside.") + elseif controlEvent == cc.CONTROL_EVENTTYPE_DRAG_OUTSIDE then + labelTTF:setString("Touch Drag Outside.") + elseif controlEvent == cc.CONTROL_EVENTTYPE_DRAG_ENTER then + labelTTF:setString("Touch Drag Enter.") + elseif controlEvent == cc.CONTROL_EVENTTYPE_DRAG_EXIT then + labelTTF:setString("Touch Drag Exit.") + elseif controlEvent == cc.CONTROL_EVENTTYPE_TOUCH_UP_INSIDE then + labelTTF:setString("Touch Up Inside.") + elseif controlEvent == cc.CONTROL_EVENTTYPE_TOUCH_UP_OUTSIDE then + labelTTF:setString("Touch Up Outside.") + elseif controlEvent == cc.CONTROL_EVENTTYPE_TOUCH_CANCEL then + labelTTF:setString("Touch Cancel.") + elseif controlEvent == cc.CONTROL_EVENT_VALUECHANGED then + labelTTF:setString("Value Changed.") + end end TestButtonsLayer["onCCControlButtonClicked"] = onCCControlButtonClicked @@ -158,12 +155,12 @@ TestButtonsLayer["onCCControlButtonClicked"] = onCCControlButtonClicked local function onAnimationsTestClicked() cclog("CCBAnimationsTestTest"); - local scene = CCScene:create() - local proxy = CCBProxy:create() - local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestAnimations.ccbi",proxy,true,"TestAnimationsLayerOwner") - local layer = tolua.cast(node,"CCLayer") - if nil ~= TestAnimationsLayerOwner["mTestTitleLabelTTF"] then - local ccLabelTTF = tolua.cast(TestAnimationsLayerOwner["mTestTitleLabelTTF"],"CCLabelTTF") + local scene = cc.Scene:create() + local proxy = cc.CCBProxy:create() + local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestAnimations.ccbi",proxy,HelloCocosBuilderLayer) + local layer = tolua.cast(node,"Layer") + if nil ~= HelloCocosBuilderLayer["mTestTitleLabelTTF"] then + local ccLabelTTF = tolua.cast(HelloCocosBuilderLayer["mTestTitleLabelTTF"],"LabelTTF") if nil ~= ccLabelTTF then ccLabelTTF:setString("ccb/ccb/TestAnimations.ccbi") end @@ -171,18 +168,18 @@ local function onAnimationsTestClicked() if nil ~= scene then scene:addChild(layer) scene:addChild(CreateBackMenuItem()) - CCDirector:getInstance():pushScene(CCTransitionFade:create(0.5, scene, Color3B(0,0,0))); + cc.Director:getInstance():pushScene(cc.TransitionFade:create(0.5, scene, cc.c3b(0,0,0))); end end local function onParticleSystemTestClicked() cclog("CCBParticleSystemTest"); - local scene = CCScene:create() - local proxy = CCBProxy:create() - local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestParticleSystems.ccbi",proxy,true,"TestParticleSystemsLayer") - local layer = tolua.cast(node,"CCLayer") - if nil ~= TestParticleSystemsLayer["mTestTitleLabelTTF"] then - local ccLabelTTF = tolua.cast(TestParticleSystemsLayer["mTestTitleLabelTTF"],"CCLabelTTF") + local scene = cc.Scene:create() + local proxy = cc.CCBProxy:create() + local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestParticleSystems.ccbi",proxy,HelloCocosBuilderLayer) + local layer = tolua.cast(node,"Layer") + if nil ~= HelloCocosBuilderLayer["mTestTitleLabelTTF"] then + local ccLabelTTF = tolua.cast(HelloCocosBuilderLayer["mTestTitleLabelTTF"],"LabelTTF") if nil ~= ccLabelTTF then ccLabelTTF:setString("ccb/ccb/TestParticleSystems.ccbi") end @@ -190,7 +187,7 @@ local function onParticleSystemTestClicked() if nil ~= scene then scene:addChild(layer) scene:addChild(CreateBackMenuItem()) - CCDirector:getInstance():pushScene(CCTransitionFade:create(0.5, scene, Color3B(0,0,0))); + cc.Director:getInstance():pushScene(cc.TransitionFade:create(0.5, scene, cc.c3b(0,0,0))); end end @@ -237,12 +234,12 @@ TestAnimationsLayer["onCCControlButtonFunkyClicked"] = onCCControlButtonFunkyCli local function onScrollViewTestClicked() - local scene = CCScene:create() - local proxy = CCBProxy:create() - local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestScrollViews.ccbi",proxy,true,"TestScrollViewsLayerOwner") - local layer = tolua.cast(node,"CCLayer") - if nil ~= TestScrollViewsLayerOwner["mTestTitleLabelTTF"] then - local ccLabelTTF = tolua.cast(TestScrollViewsLayerOwner["mTestTitleLabelTTF"],"CCLabelTTF") + local scene = cc.Scene:create() + local proxy = cc.CCBProxy:create() + local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestScrollViews.ccbi",proxy,HelloCocosBuilderLayer) + local layer = tolua.cast(node,"Layer") + if nil ~= HelloCocosBuilderLayer["mTestTitleLabelTTF"] then + local ccLabelTTF = tolua.cast(HelloCocosBuilderLayer["mTestTitleLabelTTF"],"LabelTTF") if nil ~= ccLabelTTF then ccLabelTTF:setString("ccb/ccb/TestScrollViews.ccbi") end @@ -250,18 +247,18 @@ local function onScrollViewTestClicked() if nil ~= scene then scene:addChild(layer) scene:addChild(CreateBackMenuItem()) - CCDirector:getInstance():pushScene(CCTransitionFade:create(0.5, scene, Color3B(0,0,0))); + cc.Director:getInstance():pushScene(cc.TransitionFade:create(0.5, scene, cc.c3b(0,0,0))); end end local function onTimelineCallbackSoundClicked() cclog("CCBTimelineTest"); - local scene = CCScene:create() - local proxy = CCBProxy:create() - local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestTimelineCallback.ccbi",proxy,true,"TestTimelineLayerOwner") - local layer = tolua.cast(node,"CCLayer") - if nil ~= TestTimelineLayerOwner["mTestTitleLabelTTF"] then - local ccLabelTTF = tolua.cast(TestTimelineLayerOwner["mTestTitleLabelTTF"],"CCLabelTTF") + local scene = cc.Scene:create() + local proxy = cc.CCBProxy:create() + local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestTimelineCallback.ccbi",proxy,HelloCocosBuilderLayer) + local layer = tolua.cast(node,"Layer") + if nil ~= HelloCocosBuilderLayer["mTestTitleLabelTTF"] then + local ccLabelTTF = tolua.cast(HelloCocosBuilderLayer["mTestTitleLabelTTF"],"LabelTTF") if nil ~= ccLabelTTF then ccLabelTTF:setString("ccb/ccb/TestTimelineCallback.ccbi") end @@ -269,15 +266,15 @@ local function onTimelineCallbackSoundClicked() if nil ~= scene then scene:addChild(layer) scene:addChild(CreateBackMenuItem()) - CCDirector:getInstance():pushScene(CCTransitionFade:create(0.5, scene, Color3B(0,0,0))); + cc.Director:getInstance():pushScene(cc.TransitionFade:create(0.5, scene, cc.c3b(0,0,0))); end end function onCallback1() if nil ~= TestTimelineLayer["helloLabel"] then - local ccLabelTTF = tolua.cast(TestTimelineLayer["helloLabel"],"CCLabelTTF") + local ccLabelTTF = tolua.cast(TestTimelineLayer["helloLabel"],"LabelTTF") if nil ~= ccLabelTTF then - ccLabelTTF:runAction(CCRotateBy:create(1, 360)) + ccLabelTTF:runAction(cc.RotateBy:create(1, 360)) ccLabelTTF:setString("Callback 1"); end end @@ -285,9 +282,9 @@ end function onCallback2() if nil ~= TestTimelineLayer["helloLabel"] then - local ccLabelTTF = tolua.cast(TestTimelineLayer["helloLabel"],"CCLabelTTF") + local ccLabelTTF = tolua.cast(TestTimelineLayer["helloLabel"],"LabelTTF") if nil ~= ccLabelTTF then - ccLabelTTF:runAction(CCRotateBy:create(2, 360)) + ccLabelTTF:runAction(cc.RotateBy:create(2, 360)) ccLabelTTF:setString("Callback 2"); end end @@ -306,15 +303,16 @@ HelloCocosBuilderLayer["onTimelineCallbackSoundClicked"] = onTimelineCallbackSou local function HelloCCBTestMainLayer() - local proxy = CCBProxy:create() - local node = CCBReaderLoad("cocosbuilderRes/ccb/HelloCocosBuilder.ccbi",proxy,true,"HelloCocosBuilderLayerOwner") - local layer = tolua.cast(node,"CCLayer") + print(type(cc.Scene)) + local proxy = cc.CCBProxy:create() + local node = CCBReaderLoad("cocosbuilderRes/ccb/HelloCocosBuilder.ccbi",proxy,HelloCocosBuilderLayer) + local layer = tolua.cast(node,"Layer") return layer end function runCocosBuilder() cclog("HelloCCBSceneTestMain") - local scene = CCScene:create() + local scene = cc.Scene:create() scene:addChild(HelloCCBTestMainLayer()) scene:addChild(CreateBackMenuItem()) return scene diff --git a/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/ExtensionTest.lua b/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/ExtensionTest.lua index 70f68e16dc..addd092804 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/ExtensionTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/ExtensionTest.lua @@ -27,6 +27,7 @@ local testsName = "ScrollViewTest", } + --Create toMainLayr MenuItem function CreateExtensionsBasicLayerMenu(pMenu) if nil == pMenu then @@ -342,7 +343,7 @@ local function runCCControlTest() --Add the ribbon local pRibbon = cc.Scale9Sprite:create("extensions/ribbon.png", cc.rect(1, 1, 48, 55)) - pRibbon:setContentSize(cc.size(VisibleRect:getVisibleRect().size.width, 57)) + pRibbon:setContentSize(cc.size(VisibleRect:getVisibleRect().width, 57)) pRibbon:setPosition(cc.p(VisibleRect:center().x, VisibleRect:top().y - pRibbon:getContentSize().height / 2.0)) pLayer:addChild(pRibbon) @@ -384,7 +385,7 @@ local function runCCControlTest() end if nil ~= strFmt then - pDisplayValueLabel:setString(cc.String:create(strFmt):getCString()) + pDisplayValueLabel:setString(strFmt) end end --Add the slider @@ -396,7 +397,7 @@ local function runCCControlTest() pSlider:setTag(1) --When the value of the slider will change, the given selector will be call - pSlider:registerControlEventHandler(valueChanged, cc.ControlEventValueChanged) + pSlider:registerControlEventHandler(valueChanged, cc.CONTROL_EVENTTYPE_VALUE_CHANGED) local pRestrictSlider = cc.ControlSlider:create("extensions/sliderTrack.png","extensions/sliderProgress.png" ,"extensions/sliderThumb.png") pRestrictSlider:setAnchorPoint(cc.p(0.5, 1.0)) @@ -408,7 +409,7 @@ local function runCCControlTest() pRestrictSlider:setPosition(cc.p(screenSize.width / 2.0, screenSize.height / 2.0 - 24)) pRestrictSlider:setTag(2) --same with restricted - pRestrictSlider:registerControlEventHandler(valueChanged, cc.ControlEventValueChanged) + pRestrictSlider:registerControlEventHandler(valueChanged, cc.CONTROL_EVENTTYPE_VALUE_CHANGED) pLayer:addChild(pSlider) pLayer:addChild(pRestrictSlider) end @@ -435,12 +436,12 @@ local function runCCControlTest() local pPicker = tolua.cast(pSender,"ControlColourPicker") local strFmt = string.format("#%02X%02X%02X",pPicker:getColor().r, pPicker:getColor().g, pPicker:getColor().b) - pColorLabel:setString(cc.String:create(strFmt):getCString()) + pColorLabel:setString(strFmt) end local pColourPicker = cc.ControlColourPicker:create() pColourPicker:setColor(cc.c3b(37, 46, 252)) pColourPicker:setPosition(cc.p (pColourPicker:getContentSize().width / 2, 0)) - pColourPicker:registerControlEventHandler(colourValueChanged, cc.ControlEventValueChanged) + pColourPicker:registerControlEventHandler(colourValueChanged, cc.CONTROL_EVENTTYPE_VALUE_CHANGED) pNode:addChild(pColourPicker) dLayer_width = dLayer_width + pColourPicker:getContentSize().width @@ -515,7 +516,7 @@ local function runCCControlTest() ) pSwitchControl:setPosition(cc.p (dLayer_width + 10 + pSwitchControl:getContentSize().width / 2, 0)) pNode:addChild(pSwitchControl) - pSwitchControl:registerControlEventHandler(valueChanged, cc.ControlEventValueChanged) + pSwitchControl:registerControlEventHandler(valueChanged, cc.CONTROL_EVENTTYPE_VALUE_CHANGED) --Set the layer size pNode:setContentSize(cc.size(dLayer_width, 0)) @@ -536,8 +537,8 @@ local function runCCControlTest() pTitleButton:setColor(cc.c3b(159, 168, 176)) local pButton = cc.ControlButton:create(pTitleButton, pBackgroundButton) - pButton:setBackgroundSpriteForState(pBackgroundHighlightedButton, cc.ControlStateHighlighted) - pButton:setTitleColorForState(cc.c3b(255,255,255), cc.ControlStateHighlighted) + pButton:setBackgroundSpriteForState(pBackgroundHighlightedButton, cc.CONTROL_STATE_HIGH_LIGHTED ) + pButton:setTitleColorForState(cc.c3b(255,255,255), cc.CONTROL_STATE_HIGH_LIGHTED ) return pButton end @@ -548,11 +549,7 @@ local function runCCControlTest() end local screenSize = cc.Director:getInstance():getWinSize() - local strArray = cc.Array:create() - strArray:addObject(cc.String:create("Hello")) - strArray:addObject(cc.String:create("Variable")) - strArray:addObject(cc.String:create("Size")) - strArray:addObject(cc.String:create("!")) + local strArray = {"Hello", "Variable", "Size", "!"} local pNode = cc.Node:create() pLayer:addChild(pNode,1) @@ -561,11 +558,10 @@ local function runCCControlTest() local pObj = nil local i = 0 - local nLen = strArray:count() + local nLen = table.getn(strArray) for i = 0, nLen - 1 do - pObj = tolua.cast(strArray:objectAtIndex(i), "String") --Creates a button with pLayer string as title - local pButton = HvsStandardButtonWithTitle(pObj:getCString()) + local pButton = HvsStandardButtonWithTitle(strArray[i + 1]) pButton:setPosition(cc.p (dTotalWidth + pButton:getContentSize().width / 2, pButton:getContentSize().height / 2)) pNode:addChild(pButton) @@ -596,8 +592,8 @@ local function runCCControlTest() pTitleButton:setColor(cc.c3b(159, 168, 176)) local pButton = cc.ControlButton:create(pTitleButton, pBackgroundButton) - pButton:setBackgroundSpriteForState(pBackgroundHighlightedButton, cc.ControlStateHighlighted) - pButton:setTitleColorForState(cc.c3b(255,255,255), cc.ControlStateHighlighted) + pButton:setBackgroundSpriteForState(pBackgroundHighlightedButton, cc.CONTROL_STATE_HIGH_LIGHTED ) + pButton:setTitleColorForState(cc.c3b(255,255,255), cc.CONTROL_STATE_HIGH_LIGHTED ) return pButton end @@ -622,7 +618,7 @@ local function runCCControlTest() for j = 0, 2 do --Add the buttons local strFmt = string.format("%d",math.random(0,32767) % 30) - local pButton = StylingStandardButtonWithTitle(cc.String:create(strFmt):getCString()) + local pButton = StylingStandardButtonWithTitle(strFmt) pButton:setAdjustBackgroundImage(false) pButton:setPosition(cc.p (pButton:getContentSize().width / 2 + (pButton:getContentSize().width + nSpace) * i, pButton:getContentSize().height / 2 + (pButton:getContentSize().height + nSpace) * j)) @@ -672,72 +668,72 @@ local function runCCControlTest() if nil == pDisplayValueLabel then return end - pDisplayValueLabel:setString(cc.String:create("Touch Down"):getCString()) + pDisplayValueLabel:setString("Touch Down" ) end local function touchDragInsideAction() if nil == pDisplayValueLabel then return end - pDisplayValueLabel:setString(cc.String:create("Drag Inside"):getCString()) + pDisplayValueLabel:setString("Drag Inside") end local function touchDragOutsideAction() if nil == pDisplayValueLabel then return end - pDisplayValueLabel:setString(cc.String:create("Drag Outside"):getCString()) + pDisplayValueLabel:setString("Drag Outside") end local function touchDragEnterAction() if nil == pDisplayValueLabel then return end - pDisplayValueLabel:setString(cc.String:create("Drag Enter"):getCString()) + pDisplayValueLabel:setString("Drag Enter") end local function touchDragExitAction() if nil == pDisplayValueLabel then return end - pDisplayValueLabel:setString(cc.String:create("Drag Exit"):getCString()) + pDisplayValueLabel:setString("Drag Exit") end local function touchUpInsideAction() if nil == pDisplayValueLabel then return end - pDisplayValueLabel:setString(cc.String:create("Touch Up Inside."):getCString()) + pDisplayValueLabel:setString("Touch Up Inside.") end local function touchUpOutsideAction() if nil == pDisplayValueLabel then return end - pDisplayValueLabel:setString(cc.String:create("Touch Up Outside."):getCString()) + pDisplayValueLabel:setString("Touch Up Outside.") end local function touchCancelAction() if nil == pDisplayValueLabel then return end - pDisplayValueLabel:setString(cc.String:create("Touch Cancel"):getCString()) + pDisplayValueLabel:setString("Touch Cancel") end - pControlButton:setBackgroundSpriteForState(pBackgroundHighlightedButton, cc.ControlStateHighlighted) - pControlButton:setTitleColorForState(cc.c3b(255, 255, 255), cc.ControlStateHighlighted) + pControlButton:setBackgroundSpriteForState(pBackgroundHighlightedButton, cc.CONTROL_STATE_HIGH_LIGHTED ) + pControlButton:setTitleColorForState(cc.c3b(255, 255, 255), cc.CONTROL_STATE_HIGH_LIGHTED ) pControlButton:setAnchorPoint(cc.p(0.5, 1)) pControlButton:setPosition(cc.p(screenSize.width / 2.0, screenSize.height / 2.0)) - pControlButton:registerControlEventHandler(touchDownAction,cc.ControlEventTouchDown) - pControlButton:registerControlEventHandler(touchDragInsideAction,cc.ControlEventTouchDragInside) - pControlButton:registerControlEventHandler(touchDragOutsideAction,cc.ControlEventTouchDragOutside) - pControlButton:registerControlEventHandler(touchDragEnterAction,cc.ControlEventTouchDragEnter) - pControlButton:registerControlEventHandler(touchDragExitAction,cc.ControlEventTouchDragExit) - pControlButton:registerControlEventHandler(touchUpInsideAction,cc.ControlEventTouchUpInside) - pControlButton:registerControlEventHandler(touchUpOutsideAction,cc.ControlEventTouchUpOutside) - pControlButton:registerControlEventHandler(touchCancelAction,cc.ControlEventTouchCancel) + pControlButton:registerControlEventHandler(touchDownAction,cc.CONTROL_EVENTTYPE_TOUCH_DOWN ) + pControlButton:registerControlEventHandler(touchDragInsideAction,cc.CONTROL_EVENTTYPE_DRAG_INSIDE) + pControlButton:registerControlEventHandler(touchDragOutsideAction,cc.CONTROL_EVENTTYPE_DRAG_OUTSIDE) + pControlButton:registerControlEventHandler(touchDragEnterAction,cc.CONTROL_EVENTTYPE_DRAG_ENTER) + pControlButton:registerControlEventHandler(touchDragExitAction,cc.CONTROL_EVENTTYPE_DRAG_EXIT) + pControlButton:registerControlEventHandler(touchUpInsideAction,cc.CONTROL_EVENTTYPE_TOUCH_UP_INSIDE) + pControlButton:registerControlEventHandler(touchUpOutsideAction,cc.CONTROL_EVENTTYPE_TOUCH_UP_OUTSIDE) + pControlButton:registerControlEventHandler(touchCancelAction,cc.CONTROL_EVENTTYPE_TOUCH_CANCEL) pLayer:addChild(pControlButton, 1) --Add the black background @@ -780,14 +776,14 @@ local function runCCControlTest() local pControl = tolua.cast(pSender,"ControlPotentiometer") local strFmt = string.format("%0.2f",pControl:getValue()) - pDisplayValueLabel:setString(cc.String:create(strFmt):getCString()) + pDisplayValueLabel:setString(strFmt ) end local pPotentiometer = cc.ControlPotentiometer:create("extensions/potentiometerTrack.png","extensions/potentiometerProgress.png" ,"extensions/potentiometerButton.png") pPotentiometer:setPosition(cc.p (dLayer_width + 10 + pPotentiometer:getContentSize().width / 2, 0)) -- When the value of the slider will change, the given selector will be call - pPotentiometer:registerControlEventHandler(valueChanged, cc.ControlEventValueChanged) + pPotentiometer:registerControlEventHandler(valueChanged, cc.CONTROL_EVENTTYPE_VALUE_CHANGED) pNode:addChild(pPotentiometer) @@ -837,11 +833,11 @@ local function runCCControlTest() local pControl = tolua.cast(pSender,"ControlStepper") local strFmt = string.format("%0.02f",pControl:getValue() ) - pDisplayValueLabel:setString(cc.String:create(strFmt):getCString()) + pDisplayValueLabel:setString(strFmt ) end local stepper = cc.ControlStepper:create(minusSprite, plusSprite) stepper:setPosition(cc.p (layer_width + 10 + stepper:getContentSize().width / 2, 0)) - stepper:registerControlEventHandler(valueChanged, cc.ControlEventValueChanged) + stepper:registerControlEventHandler(valueChanged, cc.CONTROL_EVENTTYPE_VALUE_CHANGED) pNode:addChild(stepper) layer_width = layer_width + stepper:getContentSize().width @@ -898,8 +894,8 @@ end local function runEditBoxTest() local newScene = cc.Scene:create() local newLayer = cc.Layer:create() - local visibleOrigin = cc.EGLView:getInstance():getVisibleOrigin() - local visibleSize = cc.EGLView:getInstance():getVisibleSize() + local visibleOrigin = cc.Director:getInstance():getVisibleOrigin() + local visibleSize = cc.Director:getInstance():getVisibleSize() local pBg = cc.Sprite:create("Images/HelloWorld.png") pBg:setPosition(cc.p(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/2)) @@ -958,7 +954,7 @@ local function runEditBoxTest() EditName:setPlaceHolder("Name:") EditName:setPlaceholderFontColor(cc.c3b(255,255,255)) EditName:setMaxLength(8) - EditName:setReturnType(kKeyboardReturnTypeDone) + EditName:setReturnType(cc.KEYBOARD_RETURNTYPE_DONE ) --Handler EditName:registerScriptEditBoxHandler(editBoxTextEventHandle) newLayer:addChild(EditName) @@ -976,8 +972,8 @@ local function runEditBoxTest() EditPassword:setFontColor(cc.c3b(0,255,0)) EditPassword:setPlaceHolder("Password:") EditPassword:setMaxLength(6) - EditPassword:setInputFlag(kEditBoxInputFlagPassword) - EditPassword:setInputMode(kEditBoxInputModeSingleLine) + EditPassword:setInputFlag(cc.EDITBOX_INPUT_FLAG_PASSWORD) + EditPassword:setInputMode(cc.EDITBOX_INPUT_MODE_SINGLELINE) EditPassword:registerScriptEditBoxHandler(editBoxTextEventHandle) newLayer:addChild(EditPassword) @@ -986,7 +982,7 @@ local function runEditBoxTest() EditEmail:setPosition(cc.p(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/4)) EditEmail:setAnchorPoint(cc.p(0.5, 1.0)) EditEmail:setPlaceHolder("Email:") - EditEmail:setInputMode(kEditBoxInputModeEmailAddr) + EditEmail:setInputMode(cc.EDITBOX_INPUT_MODE_EMAILADDR) EditEmail:registerScriptEditBoxHandler(editBoxTextEventHandle) newLayer:addChild(EditEmail) newLayer:setPosition(cc.p(10, 20)) @@ -1027,12 +1023,12 @@ local function runScrollViewTest() scrollView1:setContainer(flowersprite1) scrollView1:updateInset() end - scrollView1:setDirection(kScrollViewDirectionBoth) + scrollView1:setDirection(cc.SCROLLVIEW_DIRECTION_BOTH ) scrollView1:setClippingToBounds(true) scrollView1:setBounceable(true) scrollView1:setDelegate() - scrollView1:registerScriptHandler(scrollView1DidScroll,kScrollViewScriptScroll) - scrollView1:registerScriptHandler(scrollView1DidZoom,kScrollViewScriptZoom) + scrollView1:registerScriptHandler(scrollView1DidScroll,cc.SCROLLVIEW_SCRIPT_SCROLL) + scrollView1:registerScriptHandler(scrollView1DidZoom,cc.SCROLLVIEW_SCRIPT_ZOOM) end newLayer:addChild(scrollView1) @@ -1053,12 +1049,12 @@ local function runScrollViewTest() scrollView2:setContainer(flowersprite2) scrollView2:updateInset() end - scrollView2:setDirection(kScrollViewDirectionBoth) + scrollView2:setDirection(cc.SCROLLVIEW_DIRECTION_BOTH ) scrollView2:setClippingToBounds(true) scrollView2:setBounceable(true) scrollView2:setDelegate() - scrollView2:registerScriptHandler(scrollView2DidScroll,kScrollViewScriptScroll) - scrollView2:registerScriptHandler(scrollView2DidZoom,kScrollViewScriptZoom) + scrollView2:registerScriptHandler(scrollView2DidScroll,cc.SCROLLVIEW_SCRIPT_SCROLL) + scrollView2:registerScriptHandler(scrollView2DidZoom,cc.SCROLLVIEW_SCRIPT_ZOOM) end newLayer:addChild(scrollView2) @@ -1105,13 +1101,13 @@ local function ExtensionsMainLayer() cc.MenuItemFont:setFontSize(24) local targetPlatform = cc.Application:getInstance():getTargetPlatform() local bSupportWebSocket = false - if (kTargetIphone == targetPlatform) or (kTargetIpad == targetPlatform) or (kTargetAndroid == targetPlatform) or (kTargetWindows == targetPlatform) then + if (cc.PLATFORM_OS_IPHONE == targetPlatform) or (cc.PLATFORM_OS_IPAD == targetPlatform) or (cc.PLATFORM_OS_ANDROID == targetPlatform) or (cc.PLATFORM_OS_WINDOWS == targetPlatform) then bSupportWebSocket = true end local bSupportEdit = false - if (kTargetIphone == targetPlatform) or (kTargetIpad == targetPlatform) or - (kTargetAndroid == targetPlatform) or (kTargetWindows == targetPlatform) or - (kTargetMacOS == targetPlatform) or (kTargetTizen == targetPlatform) then + if (cc.PLATFORM_OS_IPHONE == targetPlatform) or (cc.PLATFORM_OS_IPAD == targetPlatform) or + (cc.PLATFORM_OS_ANDROID == targetPlatform) or (cc.PLATFORM_OS_WINDOWS == targetPlatform) or + (cc.PLATFORM_OS_MAC == targetPlatform) or (cc.PLATFORM_OS_TIZEN == targetPlatform) then bSupportEdit = true end for i = 1, ExtensionTestEnum.TEST_MAX_COUNT do diff --git a/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/WebProxyTest.lua b/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/WebProxyTest.lua index 1bc4656e4a..a05cc996c8 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/WebProxyTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/WebProxyTest.lua @@ -1,7 +1,7 @@ local function WebSocketTestLayer() - local layer = CCLayer:create() - local winSize = CCDirector:getInstance():getWinSize() + local layer = cc.Layer:create() + local winSize = cc.Director:getInstance():getWinSize() local MARGIN = 40 local SPACE = 35 @@ -15,12 +15,12 @@ local receiveTextTimes = 0 local receiveBinaryTimes = 0 - local label = CCLabelTTF:create("WebSocket Test", "Arial", 28) - label:setPosition(CCPoint( winSize.width / 2, winSize.height - MARGIN)) + local label = cc.LabelTTF:create("WebSocket Test", "Arial", 28) + label:setPosition(cc.p( winSize.width / 2, winSize.height - MARGIN)) layer:addChild(label, 0) - local menuRequest = CCMenu:create() - menuRequest:setPosition(CCPoint(0, 0)) + local menuRequest = cc.Menu:create() + menuRequest:setPosition(cc.p(0, 0)) layer:addChild(menuRequest) --Send Text @@ -36,10 +36,10 @@ end end end - local labelSendText = CCLabelTTF:create("Send Text", "Arial", 22) - local itemSendText = CCMenuItemLabel:create(labelSendText) + local labelSendText = cc.LabelTTF:create("Send Text", "Arial", 22) + local itemSendText = cc.MenuItemLabel:create(labelSendText) itemSendText:registerScriptTapHandler(onMenuSendTextClicked) - itemSendText:setPosition(CCPoint(winSize.width / 2, winSize.height - MARGIN - SPACE)) + itemSendText:setPosition(cc.p(winSize.width / 2, winSize.height - MARGIN - SPACE)) menuRequest:addChild(itemSendText) --Send Binary @@ -54,33 +54,33 @@ end end end - local labelSendBinary = CCLabelTTF:create("Send Binary", "Arial", 22) - local itemSendBinary = CCMenuItemLabel:create(labelSendBinary) + local labelSendBinary = cc.LabelTTF:create("Send Binary", "Arial", 22) + local itemSendBinary = cc.MenuItemLabel:create(labelSendBinary) itemSendBinary:registerScriptTapHandler(onMenuSendBinaryClicked) - itemSendBinary:setPosition(CCPoint(winSize.width / 2, winSize.height - MARGIN - 2 * SPACE)) + itemSendBinary:setPosition(cc.p(winSize.width / 2, winSize.height - MARGIN - 2 * SPACE)) menuRequest:addChild(itemSendBinary) --Send Text Status Label - sendTextStatus = CCLabelTTF:create("Send Text WS is waiting...", "Arial", 14,CCSize(160, 100),kCCVerticalTextAlignmentCenter,kCCVerticalTextAlignmentTop) - sendTextStatus:setAnchorPoint(CCPoint(0, 0)) - sendTextStatus:setPosition(CCPoint(0, 25)) + sendTextStatus = cc.LabelTTF:create("Send Text WS is waiting...", "Arial", 14,cc.size(160, 100),cc.VERTICAL_TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_TOP) + sendTextStatus:setAnchorPoint(cc.p(0, 0)) + sendTextStatus:setPosition(cc.p(0, 25)) layer:addChild(sendTextStatus) --Send Binary Status Label - sendBinaryStatus = CCLabelTTF:create("Send Binary WS is waiting...", "Arial", 14, CCSize(160, 100), kCCVerticalTextAlignmentCenter, kCCVerticalTextAlignmentTop) - sendBinaryStatus:setAnchorPoint(CCPoint(0, 0)) - sendBinaryStatus:setPosition(CCPoint(160, 25)) + sendBinaryStatus = cc.LabelTTF:create("Send Binary WS is waiting...", "Arial", 14, cc.size(160, 100), cc.VERTICAL_TEXT_ALIGNMENT_CENTER, cc.VERTICAL_TEXT_ALIGNMENT_TOP) + sendBinaryStatus:setAnchorPoint(cc.p(0, 0)) + sendBinaryStatus:setPosition(cc.p(160, 25)) layer:addChild(sendBinaryStatus) --Error Label - errorStatus = CCLabelTTF:create("Error WS is waiting...", "Arial", 14, CCSize(160, 100), kCCVerticalTextAlignmentCenter, kCCVerticalTextAlignmentTop) - errorStatus:setAnchorPoint(CCPoint(0, 0)) - errorStatus:setPosition(CCPoint(320, 25)) + errorStatus = cc.LabelTTF:create("Error WS is waiting...", "Arial", 14, cc.size(160, 100), cc.VERTICAL_TEXT_ALIGNMENT_CENTER, cc.VERTICAL_TEXT_ALIGNMENT_TOP) + errorStatus:setAnchorPoint(cc.p(0, 0)) + errorStatus:setPosition(cc.p(320, 25)) layer:addChild(errorStatus) - local toMainMenu = CCMenu:create() + local toMainMenu = cc.Menu:create() CreateExtensionsBasicLayerMenu(toMainMenu) - toMainMenu:setPosition(CCPoint(0, 0)) + toMainMenu:setPosition(cc.p(0, 0)) layer:addChild(toMainMenu,10) wsSendText = WebSocket:create("ws://echo.websocket.org") @@ -196,7 +196,7 @@ end function runWebSocketTest() - local scene = CCScene:create() + local scene = cc.Scene:create() scene:addChild(WebSocketTestLayer()) return scene end diff --git a/scripting/lua/cocos2dx_support/CCBProxy.cpp b/scripting/lua/cocos2dx_support/CCBProxy.cpp index 41eb542fa0..3253acac3b 100644 --- a/scripting/lua/cocos2dx_support/CCBProxy.cpp +++ b/scripting/lua/cocos2dx_support/CCBProxy.cpp @@ -61,99 +61,106 @@ const char* CCBProxy::getNodeTypeName(Node* pNode) } if (NULL != dynamic_cast(pNode)) { - return "CCLabelTTF"; + return "LabelTTF"; } if (NULL != dynamic_cast(pNode)) { - return "CCLabelBMFont"; + return "LabelBMFont"; } if (NULL != dynamic_cast(pNode)) { - return "CCSprite"; + return "Sprite"; } if (NULL != dynamic_cast(pNode)) { - return "CCControlButton"; + return "ControlButton"; } if (NULL != dynamic_cast(pNode)) { - return "CCLayerGradient"; + return "LayerGradient"; } if (NULL != dynamic_cast(pNode)) { - return "CCLayerColor"; + return "LayerColor"; } if (NULL != dynamic_cast(pNode)) { - return "CCLayerGradient"; + return "LayerGradient"; } if (NULL != dynamic_cast(pNode)) { - return "CCMenu"; + return "Menu"; } if (NULL != dynamic_cast(pNode)) { - return "CCMenuItemAtlasFont"; + return "MenuItemAtlasFont"; } if (NULL != dynamic_cast(pNode)) { - return "CCMenuItemFont"; + return "MenuItemFont"; } if (NULL != dynamic_cast(pNode)) { - return "CCMenuItemLabel"; + return "MenuItemLabel"; } if (NULL != dynamic_cast(pNode)) { - return "CCMenuItemImage"; + return "MenuItemImage"; } if (NULL != dynamic_cast(pNode)) { - return "CCMenuItemToggle"; + return "MenuItemToggle"; } if (NULL != dynamic_cast(pNode)) { - return "CCMenuItemSprite"; + return "MenuItemSprite"; } if (NULL != dynamic_cast(pNode)) { - return "CCMenuItem"; + return "MenuItem"; } if (NULL != dynamic_cast(pNode)) { - return "CCLayer"; + return "Layer"; } if (NULL != dynamic_cast(pNode)) { - return "CCString"; + return "String"; } if (NULL != dynamic_cast(pNode)) { - return "CCParticleSystemQuad"; + return "ParticleSystemQuad"; } return "No Support"; } -void CCBProxy::setCallback(Node* pNode,int nHandle) +void CCBProxy::setCallback(Node* node,int handle, int controlEvents) { - if (NULL == pNode) { + if (nullptr == node) { return; } - if (NULL != dynamic_cast(pNode)) + if (nullptr != dynamic_cast(node)) { - MenuItem *pMenuItem = dynamic_cast(pNode); - if (NULL != pMenuItem) { - ScriptHandlerMgr::getInstance()->addObjectHandler((void*)pMenuItem, nHandle, ScriptHandlerMgr::kMenuClickHandler); + MenuItem *menuItem = dynamic_cast(node); + if (nullptr != menuItem) { + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)menuItem, handle, ScriptHandlerMgr::kMenuClickHandler); } } - else if (NULL != dynamic_cast(pNode)) + else if (NULL != dynamic_cast(node)) { - ControlButton *pBtnItem = dynamic_cast(pNode); - if (NULL != pBtnItem) { - //UNOD,need Btn Pros to addHanldeOfControlEvent - ScriptHandlerMgr::getInstance()->addObjectHandler((void*)pBtnItem, nHandle, ScriptHandlerMgr::kControlTouchUpInsideHandler); + Control* control = dynamic_cast(node); + if (nullptr != control) + { + for (int i = 0; i < kControlEventTotalNumber; i++) + { + if ((controlEvents & (1 << i))) + { + int handlerevent = ScriptHandlerMgr::kControlTouchDownHandler + i; + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)control, handle, handlerevent); + } + } } } } diff --git a/scripting/lua/cocos2dx_support/CCBProxy.h b/scripting/lua/cocos2dx_support/CCBProxy.h index b9b682c18e..9759e87f1f 100644 --- a/scripting/lua/cocos2dx_support/CCBProxy.h +++ b/scripting/lua/cocos2dx_support/CCBProxy.h @@ -17,7 +17,7 @@ public: CCBReader* createCCBReader(); Node* readCCBFromFile(const char *pszFileName,CCBReader* pCCBReader,bool bSetOwner = false); const char* getNodeTypeName(Node* pNode); - void setCallback(Node* pNode,int nHandle); + void setCallback(Node* node,int handle, int controlEvents = 0); }; class CCBLayerLoader:public LayerLoader{ diff --git a/scripting/lua/cocos2dx_support/CCLuaEngine.cpp b/scripting/lua/cocos2dx_support/CCLuaEngine.cpp index 7bd6c2a65a..3ef4419865 100644 --- a/scripting/lua/cocos2dx_support/CCLuaEngine.cpp +++ b/scripting/lua/cocos2dx_support/CCLuaEngine.cpp @@ -591,8 +591,9 @@ int LuaEngine::handlerControlEvent(void* data) if (0 != handler) { - _stack->pushObject((Object*)basicScriptData->nativeObject, "CCObject"); - ret = _stack->executeFunctionByHandler(handler, 1); + _stack->pushObject((Object*)basicScriptData->nativeObject, "Object"); + _stack->pushInt(controlEvents); + ret = _stack->executeFunctionByHandler(handler, 2); _stack->clean(); } } diff --git a/scripting/lua/cocos2dx_support/CCLuaStack.cpp b/scripting/lua/cocos2dx_support/CCLuaStack.cpp index c342250d9f..947b644b4f 100644 --- a/scripting/lua/cocos2dx_support/CCLuaStack.cpp +++ b/scripting/lua/cocos2dx_support/CCLuaStack.cpp @@ -50,6 +50,7 @@ extern "C" { #include "lua_cocos2dx_extension_auto.hpp" #include "lua_cocos2dx_manual.hpp" #include "LuaBasicConversions.h" +#include "lua_cocos2dx_extension_manual.h" namespace { int lua_print(lua_State * luastate) @@ -130,15 +131,17 @@ bool LuaStack::init(void) register_all_cocos2dx(_state); tolua_opengl_open(_state); register_all_cocos2dx_extension(_state); + register_cocos2dx_extension_CCBProxy(_state); register_all_cocos2dx_manual(_state); + register_all_cocos2dx_extension_manual(_state); #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) LuaObjcBridge::luaopen_luaoc(_state); #endif - tolua_extensions_ccb_open(_state); +// tolua_extensions_ccb_open(_state); #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) tolua_web_socket_open(_state); #endif - tolua_scroll_view_open(_state); +// tolua_scroll_view_open(_state); tolua_script_handler_mgr_open(_state); // add cocos2dx loader diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id index 58dc858cdf..eaff4b07d8 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id @@ -1 +1 @@ -e29ba39a2c542d0e15e41231b795fadbdad66af3 \ No newline at end of file +9665294361d65c1a40aa195a6d048f4a627b2065 \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.hpp b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.hpp index 9b672e575f..8033110aff 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.hpp +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.hpp @@ -2070,7 +2070,6 @@ int register_all_cocos2dx(lua_State* tolua_S); - #endif // __cocos2dx_h__ diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id index 81938e2d35..23c1ee6796 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id @@ -1 +1 @@ -171d6ef055d78d7211eb55d8a8de5eda09476d0a \ No newline at end of file +65dd9a6009e08176e2d71c2eda75f2d1319b38c2 \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id index 627a599501..7717b7c83b 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id @@ -1 +1 @@ -00379738c9ad94edf867bd46e85597812c340f29 \ No newline at end of file +99f6cd0f27234a5dc217c264746002c73b30c08e \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.hpp b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.hpp index 727217721f..a91e44ecea 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.hpp +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.hpp @@ -401,7 +401,6 @@ int register_all_cocos2dx_extension(lua_State* tolua_S); - #endif // __cocos2dx_extension_h__ diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto_api.js b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto_api.js index 5b4f3a5b7c..5d80c436a6 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto_api.js +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto_api.js @@ -1211,13 +1211,6 @@ getSequenceDuration : function () {}, */ addDocumentCallbackNode : function () {}, -/** - * @method setCallFunc - * @param {cocos2d::CallFunc*} - * @param {std::string} - */ -setCallFunc : function () {}, - /** * @method runAnimationsForSequenceNamed * @param {const char*} diff --git a/scripting/lua/cocos2dx_support/lua_cocos2dx_extension_manual.cpp b/scripting/lua/cocos2dx_support/lua_cocos2dx_extension_manual.cpp new file mode 100644 index 0000000000..619fc5ef98 --- /dev/null +++ b/scripting/lua/cocos2dx_support/lua_cocos2dx_extension_manual.cpp @@ -0,0 +1,862 @@ +#include "lua_cocos2dx_extension_manual.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" +#include "CCBProxy.h" + +USING_NS_CC; +USING_NS_CC_EXT; + +class LuaScrollViewDelegate:public Object, public ScrollViewDelegate +{ +public: + virtual ~LuaScrollViewDelegate() + {} + + virtual void scrollViewDidScroll(ScrollView* view) + { + if (nullptr != view) + { + int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)view, ScriptHandlerMgr::kScrollViewScrollHandler); + if (0 != handler) + { + CommonScriptData data(handler,""); + ScriptEvent event(kCommonEvent,(void*)&data); + ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); + } + + } + } + + virtual void scrollViewDidZoom(ScrollView* view) + { + if (nullptr != view) + { + int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)view, ScriptHandlerMgr::kScrollViewZoomHandler); + if (0 != handler) + { + CommonScriptData data(handler,""); + ScriptEvent event(kCommonEvent,(void*)&data); + ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); + } + } + } +}; + +static int tolua_cocos2dx_ScrollView_setDelegate(lua_State* tolua_S) +{ + if (nullptr == tolua_S) + return 0; + + int argc = 0; + ScrollView* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"ScrollView",0,&tolua_err)) goto tolua_lerror; +#endif + + self = (ScrollView*) tolua_tousertype(tolua_S,1,0); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) + { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2dx_ScrollView_setDelegate'\n", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (0 == argc) + { + LuaScrollViewDelegate* delegate = new LuaScrollViewDelegate(); + if (nullptr == delegate) + return 0; + + self->setUserObject(delegate); + self->setDelegate(delegate); + + delegate->release(); + + return 0; + } + + CCLOG("'setDelegate' function of ScrollView wrong number of arguments: %d, was expecting %d\n", argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'setDelegate'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2d_ScrollView_registerScriptHandler(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + ScrollView* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"ScrollView",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(tolua_S,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_ScrollView_registerScriptHandler'\n", NULL); + return 0; + } +#endif + argc = lua_gettop(tolua_S) - 1; + if (2 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err) || + !tolua_isnumber(tolua_S, 3, 0, &tolua_err) ) + { + goto tolua_lerror; + } +#endif + LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0)); + ScriptHandlerMgr::HandlerEventType handlerType = (ScriptHandlerMgr::HandlerEventType) ((int)tolua_tonumber(tolua_S,3,0) + ScriptHandlerMgr::kScrollViewScrollHandler); + + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, handlerType); + return 0; + } + + CCLOG("'registerScriptHandler' function of ScrollView has wrong number of arguments: %d, was expecting %d\n", argc, 2); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'registerScriptHandler'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2d_ScrollView_unregisterScriptHandler(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + ScrollView* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"ScrollView",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(tolua_S,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_ScrollView_unregisterScriptHandler'\n", NULL); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (1 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err)) + goto tolua_lerror; +#endif + ScriptHandlerMgr::HandlerEventType handlerType = (ScriptHandlerMgr::HandlerEventType) ((int)tolua_tonumber(tolua_S,2,0) + ScriptHandlerMgr::kScrollViewScrollHandler); + ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)self, handlerType); + return 0; + } + + CCLOG("'unregisterScriptHandler' function of ScrollView has wrong number of arguments: %d, was expecting %d\n", argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'unregisterScriptHandler'.",&tolua_err); + return 0; +#endif +} + +static void extendScrollView(lua_State* tolua_S) +{ + lua_pushstring(tolua_S, "ScrollView"); + lua_rawget(tolua_S, LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"setDelegate"); + lua_pushcfunction(tolua_S,tolua_cocos2dx_ScrollView_setDelegate ); + lua_rawset(tolua_S,-3); + lua_pushstring(tolua_S,"registerScriptHandler"); + lua_pushcfunction(tolua_S,tolua_cocos2d_ScrollView_registerScriptHandler ); + lua_rawset(tolua_S,-3); + lua_pushstring(tolua_S,"unregisterScriptHandler"); + lua_pushcfunction(tolua_S,tolua_cocos2d_ScrollView_unregisterScriptHandler ); + lua_rawset(tolua_S,-3); + } +} + +static int tolua_cocos2d_Control_registerControlEventHandler(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + Control* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"Control",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(tolua_S,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Control_registerControlEventHandler'\n", NULL); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (2 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err) || + !tolua_isnumber(tolua_S, 3, 0, &tolua_err) ) + { + goto tolua_lerror; + } +#endif + LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0)); + int controlevent = (int)tolua_tonumber(tolua_S,3,0); + for (int i = 0; i < kControlEventTotalNumber; i++) + { + if ((controlevent & (1 << i))) + { + int handlerevent = ScriptHandlerMgr::kControlTouchDownHandler + i; + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, handlerevent); + } + } + return 0; + } + + CCLOG("'registerControlEventHandler' function of Control has wrong number of arguments: %d, was expecting %d\n", argc, 2); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'registerControlEventHandler'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2d_control_unregisterControlEventHandler(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + Control* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"Control",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(tolua_S,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_control_unregisterControlEventHandler'\n", NULL); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (1 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err)) + goto tolua_lerror; +#endif + int controlevent = (int)tolua_tonumber(tolua_S,2,0); + for (int i = 0; i < kControlEventTotalNumber; i++) + { + if ((controlevent & (1 << i))) + { + int handlerevent = ScriptHandlerMgr::kControlTouchDownHandler + i; + ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)self, handlerevent); + break; + } + } + return 0; + } + + CCLOG("'unregisterControlEventHandler' function of Control has wrong number of arguments: %d, was expecting %d\n", argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'unregisterControlEventHandler'.",&tolua_err); + return 0; +#endif +} + +static void extendControl(lua_State* tolua_S) +{ + lua_pushstring(tolua_S, "Control"); + lua_rawget(tolua_S, LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"registerControlEventHandler"); + lua_pushcfunction(tolua_S,tolua_cocos2d_Control_registerControlEventHandler ); + lua_rawset(tolua_S,-3); + lua_pushstring(tolua_S,"unregisterControlEventHandler"); + lua_pushcfunction(tolua_S,tolua_cocos2d_control_unregisterControlEventHandler ); + lua_rawset(tolua_S,-3); + } +} + +static int tolua_cocos2d_EditBox_registerScriptEditBoxHandler(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + EditBox* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"EditBox",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(tolua_S,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_EditBox_registerScriptEditBoxHandler'\n", NULL); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (1 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err)) + { + goto tolua_lerror; + } +#endif + LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0)); + self->registerScriptEditBoxHandler(handler); + return 0; + } + + CCLOG("'registerScriptEditBoxHandler' function of EditBox has wrong number of arguments: %d, was expecting %d\n", argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'registerScriptEditBoxHandler'.",&tolua_err); + return 0; +#endif + +} + +static int tolua_cocos2d_EditBox_unregisterScriptEditBoxHandler(lua_State* tolua_S) +{ + + if (NULL == tolua_S) + return 0; + + int argc = 0; + EditBox* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"EditBox",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(tolua_S,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_EditBox_unregisterScriptEditBoxHandler'\n", NULL); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (0 == argc) + { + self->unregisterScriptEditBoxHandler(); + return 0; + } + + CCLOG("'unregisterScriptEditBoxHandler' function of EditBox has wrong number of arguments: %d, was expecting %d\n", argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'unregisterScriptEditBoxHandler'.",&tolua_err); + return 0; +#endif +} + +static void extendEditBox(lua_State* tolua_S) +{ + lua_pushstring(tolua_S, "EditBox"); + lua_rawget(tolua_S, LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"registerScriptEditBoxHandler"); + lua_pushcfunction(tolua_S,tolua_cocos2d_EditBox_registerScriptEditBoxHandler ); + lua_rawset(tolua_S,-3); + lua_pushstring(tolua_S,"unregisterScriptEditBoxHandler"); + lua_pushcfunction(tolua_S,tolua_cocos2d_EditBox_unregisterScriptEditBoxHandler ); + lua_rawset(tolua_S,-3); + } +} + +static int tolua_cocos2d_CCBProxy_create(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertable(tolua_S,1,"CCBProxy",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (0 == argc) + { + CCBProxy* tolua_ret = (CCBProxy*)CCBProxy::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,"CCBProxy"); + return 1; + } + + CCLOG("'create' function of CCBProxy has wrong number of arguments: %d, was expecting %d\n", argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_cocos2d_CCBProxy_createCCBReader(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + CCBProxy* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"CCBProxy",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(tolua_S,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_CCBProxy_createCCBReader'\n", NULL); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (0 == argc) + { + CCBReader* tolua_ret = (CCBReader*) self->createCCBReader(); + 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,"CCBReader"); + return 1; + } + + CCLOG("'createCCBReader' function of CCBProxy has wrong number of arguments: %d, was expecting %d\n", argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'createCCBReader'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2d_CCBProxy_readCCBFromFile(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + CCBProxy* self = nullptr; + const char* ccbFilePath = nullptr; + CCBReader* ccbReader = nullptr; + bool setOwner = false; + Node* tolua_ret = nullptr; + int ID = 0; + int* luaID = nullptr; + + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"CCBProxy",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(tolua_S,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_CCBProxy_readCCBFromFile'\n", NULL); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (2 == argc || 3 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!tolua_isstring(tolua_S, 2, 0, &tolua_err)|| + !tolua_isusertype(tolua_S,3,"CCBReader",0,&tolua_err)|| + !tolua_isboolean(tolua_S,4,1,&tolua_err ) + ) + goto tolua_lerror; +#endif + ccbFilePath = ((const char*) tolua_tostring(tolua_S,2,0)); + ccbReader = ((CCBReader*) tolua_tousertype(tolua_S,3,0)); + setOwner = (bool) tolua_toboolean(tolua_S,4,-1); + tolua_ret = (Node*) self->readCCBFromFile(ccbFilePath, ccbReader, setOwner); + ID = (tolua_ret) ? (int)tolua_ret->_ID : -1; + luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; + toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret,"Node"); + return 1; + } + + CCLOG("'readCCBFromFile' function of CCBProxy has wrong number of arguments: %d, was expecting %d\n", argc, 2); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'readCCBFromFile'.",&tolua_err); + return 0; +#endif +} + + +static int tolua_cocos2d_CCBProxy_getNodeTypeName(lua_State* tolua_S) +{ + if (nullptr == tolua_S) + return 0; + + int argc = 0; + CCBProxy* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"CCBProxy",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(tolua_S,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_CCBProxy_getNodeTypeName'\n", NULL); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (1 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"Node",0,&tolua_err)) goto tolua_lerror; +#endif + + Node* node = static_cast(tolua_tousertype(tolua_S,2,0)); + const char* tolua_ret = (const char*)self->getNodeTypeName(node); + tolua_pushstring(tolua_S,(const char*)tolua_ret); + return 1; + } + + CCLOG("'getNodeTypeName' function of CCBProxy has wrong number of arguments: %d, was expecting %d\n", argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'getNodeTypeName'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2d_CCBProxy_setCallback(lua_State* tolua_S) +{ + if (nullptr == tolua_S) + return 0; + + int argc = 0; + CCBProxy* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"CCBProxy",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(tolua_S,1,0)); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_CCBProxy_setCallback'\n", NULL); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + + if ( argc >= 2 && argc <= 3 ) + { +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,2,"Node",0,&tolua_err) || + !toluafix_isfunction(tolua_S, 3, "LUA_FUNCTION", 0, &tolua_err) || + !tolua_isnumber(tolua_S, 4, 1, &tolua_err) + ) + goto tolua_lerror; +#endif + + Node* node = ((Node*)tolua_tousertype(tolua_S,2,0)); + LUA_FUNCTION funID = ( toluafix_ref_function(tolua_S,3,0)); + int controlEvents = (int)tolua_tonumber(tolua_S, 4, 1); + self->setCallback(node, funID, controlEvents); + return 0; + } + + CCLOG("'setCallback' function of CCBProxy has wrong number of arguments: %d, was expecting %d\n", argc, 2); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'setCallback'.",&tolua_err); + return 0; +#endif +} + +int register_cocos2dx_extension_CCBProxy(lua_State* tolua_S) +{ + tolua_module(tolua_S,"cc",0); + tolua_beginmodule(tolua_S,"cc"); + tolua_usertype(tolua_S,"CCBProxy"); + tolua_cclass(tolua_S,"CCBProxy","CCBProxy","Layer",NULL); + tolua_beginmodule(tolua_S,"CCBProxy"); + tolua_function(tolua_S, "create", tolua_cocos2d_CCBProxy_create); + tolua_function(tolua_S, "createCCBReader", tolua_cocos2d_CCBProxy_createCCBReader); + tolua_function(tolua_S, "readCCBFromFile", tolua_cocos2d_CCBProxy_readCCBFromFile); + tolua_function(tolua_S, "getNodeTypeName", tolua_cocos2d_CCBProxy_getNodeTypeName); + tolua_function(tolua_S, "setCallback", tolua_cocos2d_CCBProxy_setCallback); + tolua_endmodule(tolua_S); + tolua_endmodule(tolua_S); + + uint32_t typeId = cocos2d::getHashCodeByString(typeid(CCBProxy).name()); + g_luaType[typeId] = "CCBProxy"; + return 1; +} + +static int tolua_cocos2d_CCBReader_load(lua_State* tolua_S) +{ + if (nullptr == tolua_S) + return 0; + + int argc = 0; + CCBReader* self = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"CCBReader",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(tolua_S,1,0)); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_CCBReader_load'\n", NULL); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc >= 1 && argc <= 3) + { + const char* fileName = nullptr; + std::string fileName_tmp = ""; + ok &= luaval_to_std_string(tolua_S, 2, &fileName_tmp); + fileName = fileName_tmp.c_str(); + if (!ok) + return 0; + + if (1 == argc) + { + Node* tolua_ret = (Node*) self->readNodeGraphFromFile(fileName); + int ID = (tolua_ret) ? (int)tolua_ret->_ID : -1; + int* luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; + toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret,"Node"); + return 1; + } + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S, 3, "Object", 0, &tolua_err)) + goto tolua_lerror; +#endif + Object* owner = static_cast(tolua_tousertype(tolua_S, 3, 0)); + //In lua owner always define in lua script by table, so owner is always nullptr + if (2 == argc) + { + Node* tolua_ret = (Node*) self->readNodeGraphFromFile(fileName,owner); + int ID = (tolua_ret) ? (int)tolua_ret->_ID : -1; + int* luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; + toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret,"Node"); + return 1; + } + + Size size; + ok &= luaval_to_size(tolua_S, 4, &size); + if (!ok) + return 0; + + Node* tolua_ret = (Node*) self->readNodeGraphFromFile(fileName,owner,size); + int ID = (tolua_ret) ? (int)tolua_ret->_ID : -1; + int* luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; + toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret,"Node"); + return 1; + + } + + CCLOG("'load' function of CCBReader has wrong number of arguments: %d, was expecting %d\n", argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'load'.",&tolua_err); + return 0; +#endif +} + +static void extendCCBReader(lua_State* tolua_S) +{ + lua_pushstring(tolua_S, "CCBReader"); + lua_rawget(tolua_S, LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"load"); + lua_pushcfunction(tolua_S,tolua_cocos2d_CCBReader_load ); + lua_rawset(tolua_S,-3); + } +} + + +static int tolua_cocos2d_CCBAnimationManager_setCallFuncForLuaCallbackNamed(lua_State* tolua_S) +{ + if (nullptr == tolua_S) + return 0; + + int argc = 0; + CCBAnimationManager* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"CCBAnimationManager",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(tolua_S,1,0)); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_CCBAnimationManager_setCallFuncForLuaCallbackNamed'\n", NULL); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (2 == argc) + { + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,2, "CallFunc", 0, &tolua_err) || + !tolua_isstring(tolua_S, 3, 0, &tolua_err) ) + goto tolua_lerror; +#endif + + CallFunc* pCallFunc = static_cast(tolua_tousertype(tolua_S,2,0)); + const char* keyframeCallback = ((const char*) tolua_tostring(tolua_S,3,0)); + std::string strKey = ""; + if (NULL != keyframeCallback) { + strKey = keyframeCallback; + } + self->setCallFunc(pCallFunc, strKey); + } + + CCLOG("'setCallFuncForLuaCallbackNamed' function of CCBAnimationManager has wrong number of arguments: %d, was expecting %d\n", argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'setCallFuncForLuaCallbackNamed'.",&tolua_err); + return 0; +#endif +} + +static void extendCCBAnimationManager(lua_State* tolua_S) +{ + lua_pushstring(tolua_S, "CCBAnimationManager"); + lua_rawget(tolua_S, LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"setCallFuncForLuaCallbackNamed"); + lua_pushcfunction(tolua_S,tolua_cocos2d_CCBAnimationManager_setCallFuncForLuaCallbackNamed ); + lua_rawset(tolua_S,-3); + } +} + +int register_all_cocos2dx_extension_manual(lua_State* tolua_S) +{ + extendScrollView(tolua_S); + extendControl(tolua_S); + extendEditBox(tolua_S); + extendCCBReader(tolua_S); + extendCCBAnimationManager(tolua_S); + return 0; +} \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/lua_cocos2dx_extension_manual.h b/scripting/lua/cocos2dx_support/lua_cocos2dx_extension_manual.h new file mode 100644 index 0000000000..97ea7d81cd --- /dev/null +++ b/scripting/lua/cocos2dx_support/lua_cocos2dx_extension_manual.h @@ -0,0 +1,15 @@ +#ifndef COCOS2DX_SCRIPT_LUA_COCOS2DX_SUPPORT_LUA_COCOS2DX_EXTENSION_MANUAL_H +#define COCOS2DX_SCRIPT_LUA_COCOS2DX_SUPPORT_LUA_COCOS2DX_EXTENSION_MANUAL_H + +#ifdef __cplusplus +extern "C" { +#endif +#include "tolua++.h" +#ifdef __cplusplus +} +#endif + +TOLUA_API int register_all_cocos2dx_extension_manual(lua_State* tolua_S); +TOLUA_API int register_cocos2dx_extension_CCBProxy(lua_State* tolua_S); + +#endif // #ifndef COCOS2DX_SCRIPT_LUA_COCOS2DX_SUPPORT_LUA_COCOS2DX_EXTENSION_MANUAL_H diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_manual.cpp b/scripting/lua/cocos2dx_support/lua_cocos2dx_manual.cpp similarity index 91% rename from scripting/lua/cocos2dx_support/generated/lua_cocos2dx_manual.cpp rename to scripting/lua/cocos2dx_support/lua_cocos2dx_manual.cpp index 1db8768fb8..5f8e226167 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_manual.cpp +++ b/scripting/lua/cocos2dx_support/lua_cocos2dx_manual.cpp @@ -82,7 +82,7 @@ static int tolua_cocos2d_MenuItemImage_create(lua_State* tolua_S) } while (0); - CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 0); + CCLOG("'create' has wrong number of arguments: %d, was expecting %d\n", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 @@ -123,7 +123,7 @@ static int tolua_cocos2d_MenuItemLabel_create(lua_State* tolua_S) return 1; } - CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1); + CCLOG("'create' has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 @@ -163,7 +163,7 @@ static int tolua_cocos2d_MenuItemFont_create(lua_State* tolua_S) return 1; } - CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1); + CCLOG("'create' has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 @@ -217,7 +217,7 @@ static int tolua_cocos2d_MenuItemSprite_create(lua_State* tolua_S) return 1; } - CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 3); + CCLOG("create has wrong number of arguments: %d, was expecting %d\n", argc, 3); return 0; #if COCOS2D_DEBUG >= 1 @@ -281,7 +281,7 @@ static int tolua_cocos2d_Menu_create(lua_State* tolua_S) return 1; } - CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 0); + CCLOG("create wrong number of arguments: %d, was expecting %d\n", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 @@ -325,7 +325,7 @@ static int tolua_cocos2dx_Menu_alignItemsInRows(lua_State* tolua_S) return 0; } - CCLOG("wrong number of arguments in tolua_cocos2dx_Menu_alignItemsInRows: %d, was expecting %d\n", argc, 1); + CCLOG("'alignItemsInRows' has wrong number of arguments in tolua_cocos2dx_Menu_alignItemsInRows: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 @@ -368,12 +368,12 @@ static int tolua_cocos2dx_Menu_alignItemsInColumns(lua_State* tolua_S) return 0; } - CCLOG("wrong number of arguments in tolua_cocos2dx_Menu_alignItemsInColumns: %d, was expecting %d\n", argc, 1); + CCLOG("'alignItemsInColumns' has wrong number of arguments in tolua_cocos2dx_Menu_alignItemsInColumns: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'alignItemsInRows'.\n",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'alignItemsInColumns'.\n",&tolua_err); #endif return 0; } @@ -424,7 +424,7 @@ static int tolua_cocos2d_MenuItemToggle_create(lua_State* tolua_S) return 1; } - CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1); + CCLOG("'create' has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 @@ -465,7 +465,7 @@ static int tolua_cocos2d_MenuItem_registerScriptTapHandler(lua_State* tolua_S) return 0; } - CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1); + CCLOG("'registerScriptTapHandler' has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 @@ -505,7 +505,7 @@ static int tolua_cocos2d_MenuItem_unregisterScriptTapHandler(lua_State* tolua_S) return 0; } - CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 0); + CCLOG("'unregisterScriptTapHandler' has wrong number of arguments: %d, was expecting %d\n", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 @@ -587,7 +587,7 @@ static int tolua_cocos2d_Layer_registerScriptTouchHandler(lua_State* tolua_S) return 0; } - CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1); + CCLOG("'registerScriptTouchHandler' has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 @@ -627,7 +627,7 @@ static int tolua_cocos2d_Layer_unregisterScriptTouchHandler(lua_State* tolua_S) return 0; } - CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 0); + CCLOG("'unregisterScriptTouchHandler' has wrong number of arguments: %d, was expecting %d\n", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 @@ -672,7 +672,7 @@ static int tolua_cocos2d_Layer_registerScriptKeypadHandler(lua_State* tolua_S) return 0; } - CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1); + CCLOG("'registerScriptKeypadHandler' has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 @@ -711,7 +711,7 @@ static int tolua_cocos2d_Layer_unregisterScriptKeypadHandler(lua_State* tolua_S) return 0; } - CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 0); + CCLOG("'unregisterScriptKeypadHandler' has wrong number of arguments: %d, was expecting %d\n", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 @@ -757,7 +757,7 @@ static int tolua_cocos2d_Layer_registerScriptAccelerateHandler(lua_State* tolua_ return 0; } - CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1); + CCLOG("'registerScriptAccelerateHandler' has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: @@ -796,7 +796,7 @@ static int tolua_cocos2d_Layer_unregisterScriptAccelerateHandler(lua_State* tolu return 0; } - CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 0); + CCLOG("'unregisterScriptAccelerateHandler' has wrong number of arguments: %d, was expecting %d\n", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 @@ -846,7 +846,7 @@ static int tolua_cocos2d_Scheduler_scheduleScriptFunc(lua_State* tolua_S) return 1; } - CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 3); + CCLOG("'scheduleScriptFunc' has wrong number of arguments: %d, was expecting %d\n", argc, 3); return 0; #if COCOS2D_DEBUG >= 1 @@ -893,7 +893,7 @@ static int tolua_cocos2d_Scheduler_unscheduleScriptEntry(lua_State* tolua_S) return 0; } - CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1); + CCLOG("'unscheduleScriptEntry' has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 @@ -948,7 +948,7 @@ static int tolua_cocos2d_Sequence_create(lua_State* tolua_S) toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"Sequence"); return 1; } - CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1); + CCLOG("'create' has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 @@ -987,7 +987,7 @@ static int tolua_cocos2d_CallFunc_create(lua_State* tolua_S) return 1; } - CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1); + CCLOG("'create' has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 @@ -1034,7 +1034,7 @@ static int tolua_cocos2d_Node_registerScriptHandler(lua_State* tolua_S) return 0; } - CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1); + CCLOG("'registerScriptHandler' has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 @@ -1073,7 +1073,7 @@ static int tolua_cocos2d_Node_unregisterScriptHandler(lua_State* tolua_S) return 0; } - CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 0); + CCLOG("'unregisterScriptHandler' has wrong number of arguments: %d, was expecting %d\n", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 @@ -1123,7 +1123,7 @@ static int tolua_Cocos2d_Node_scheduleUpdateWithPriorityLua(lua_State* tolua_S) return 0; } - CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 2); + CCLOG("'scheduleUpdateWithPriorityLua' has wrong number of arguments: %d, was expecting %d\n", argc, 2); return 0; #if COCOS2D_DEBUG >= 1 @@ -1162,7 +1162,7 @@ static int tolua_cocos2d_Node_unscheduleUpdate(lua_State* tolua_S) return 0; } - CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 0); + CCLOG("'unscheduleUpdate' has wrong number of arguments: %d, was expecting %d\n", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 @@ -1219,7 +1219,7 @@ static int tolua_cocos2d_Spawn_create(lua_State* tolua_S) return 1; } - CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1); + CCLOG("'create' has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 @@ -1288,7 +1288,7 @@ static int tolua_cocos2d_CardinalSplineBy_create(lua_State* tolua_S) } } - CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 3); + CCLOG("'create' has wrong number of arguments: %d, was expecting %d\n", argc, 3); return 0; #if COCOS2D_DEBUG >= 1 @@ -1352,7 +1352,7 @@ static int tolua_cocos2d_CatmullRomBy_create(lua_State* tolua_S) } } - CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 2); + CCLOG("'create' has wrong number of arguments: %d, was expecting %d\n", argc, 2); return 0; #if COCOS2D_DEBUG >= 1 @@ -1416,7 +1416,7 @@ static int tolua_cocos2d_CatmullRomTo_create(lua_State* tolua_S) } } - CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 2); + CCLOG("'create' has wrong number of arguments: %d, was expecting %d\n", argc, 2); return 0; #if COCOS2D_DEBUG >= 1 @@ -1476,7 +1476,7 @@ static int tolua_cocos2d_BezierBy_create(lua_State* tolua_S) } } - CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 2); + CCLOG("'create' has wrong number of arguments: %d, was expecting %d\n", argc, 2); return 0; #if COCOS2D_DEBUG >= 1 @@ -1536,7 +1536,7 @@ static int tolua_cocos2d_BezierTo_create(lua_State* tolua_S) } } - CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 2); + CCLOG("'create' has wrong number of arguments: %d, was expecting %d\n", argc, 2); return 0; #if COCOS2D_DEBUG >= 1 @@ -1629,7 +1629,7 @@ static int tolua_cocos2d_DrawNode_drawPolygon(lua_State* tolua_S) } } - CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 5); + CCLOG("'drawPolygon' has wrong number of arguments: %d, was expecting %d\n", argc, 5); return 0; #if COCOS2D_DEBUG >= 1 @@ -1672,7 +1672,7 @@ static int tolua_cocos2dx_setBlendFunc(lua_State* tolua_S,const char* className) } - CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 2); + CCLOG("'setBlendFunc' has wrong number of arguments: %d, was expecting %d\n", argc, 2); return 0; #if COCOS2D_DEBUG >= 1 @@ -1729,7 +1729,7 @@ static int tolua_cocos2dx_LayerMultiplex_create(lua_State* tolua_S) } } - CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1); + CCLOG("'create' has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 @@ -1775,7 +1775,7 @@ static int tolua_cocos2dx_Camera_getCenterXYZ(lua_State* tolua_S) return 3; } - CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 0); + CCLOG("'getCenterXYZ' has wrong number of arguments: %d, was expecting %d\n", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 @@ -1820,7 +1820,7 @@ static int tolua_cocos2dx_Camera_getEyeXYZ(lua_State* tolua_S) return 3; } - CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 0); + CCLOG("'getEyeXYZ' has wrong number of arguments: %d, was expecting %d\n", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 @@ -1865,7 +1865,7 @@ static int tolua_cocos2dx_Camera_getUpXYZ(lua_State* tolua_S) return 3; } - CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 0); + CCLOG("'getUpXYZ' has wrong number of arguments: %d, was expecting %d\n", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 @@ -1918,7 +1918,7 @@ static int tolua_cocos2dx_FileUtils_getStringFromFile(lua_State* tolua_S) } } - CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 1); + CCLOG("'getStringFromFile' has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 @@ -1949,7 +1949,7 @@ static int tolua_cocos2dx_UserDefault_getInstance(lua_State* tolua_S) return 1; } - CCLOG("wrong number of arguments: %d, was expecting %d\n", argc, 0); + CCLOG("'getInstance' has wrong number of arguments: %d, was expecting %d\n", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 @@ -2245,11 +2245,8 @@ static void extendTexture2D(lua_State* tolua_S) } } -int register_all_cocos2dx_manual(lua_State* tolua_S) +static void extendMenuItem(lua_State* tolua_S) { - if (NULL == tolua_S) - return 0; - lua_pushstring(tolua_S,"MenuItem"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) @@ -2261,7 +2258,10 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) lua_pushcfunction(tolua_S,tolua_cocos2d_MenuItem_unregisterScriptTapHandler); lua_rawset(tolua_S, -3); } - +} + +static void extendMenuItemImage(lua_State* tolua_S) +{ lua_pushstring(tolua_S,"MenuItemImage"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) @@ -2270,7 +2270,10 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) lua_pushcfunction(tolua_S,tolua_cocos2d_MenuItemImage_create); lua_rawset(tolua_S,-3); } - +} + +static void extendMenuItemLabel(lua_State* tolua_S) +{ lua_pushstring(tolua_S, "MenuItemLabel"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) @@ -2279,7 +2282,10 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) lua_pushcfunction(tolua_S,tolua_cocos2d_MenuItemLabel_create); lua_rawset(tolua_S,-3); } - +} + +static void extendMenuItemFont(lua_State* tolua_S) +{ lua_pushstring(tolua_S, "MenuItemFont"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) @@ -2288,7 +2294,10 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) lua_pushcfunction(tolua_S,tolua_cocos2d_MenuItemFont_create); lua_rawset(tolua_S,-3); } - +} + +static void extendMenuItemSprite(lua_State* tolua_S) +{ lua_pushstring(tolua_S, "MenuItemSprite"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) @@ -2297,7 +2306,10 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) lua_pushcfunction(tolua_S,tolua_cocos2d_MenuItemSprite_create); lua_rawset(tolua_S,-3); } - +} + +static void extendMenuItemToggle(lua_State* tolua_S) +{ lua_pushstring(tolua_S, "MenuItemToggle"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) @@ -2306,7 +2318,10 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) lua_pushcfunction(tolua_S,tolua_cocos2d_MenuItemToggle_create); lua_rawset(tolua_S,-3); } +} +static void extendMenu(lua_State* tolua_S) +{ lua_pushstring(tolua_S, "Menu"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S, -1)) @@ -2321,7 +2336,10 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) lua_pushcfunction(tolua_S,tolua_cocos2dx_Menu_alignItemsInColumns); lua_rawset(tolua_S,-3); } - +} + +static void extendNode(lua_State* tolua_S) +{ lua_pushstring(tolua_S,"Node"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) @@ -2339,7 +2357,10 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) lua_pushcfunction(tolua_S,tolua_cocos2d_Node_unscheduleUpdate); lua_rawset(tolua_S, -3); } - +} + +static void extendLayer(lua_State* tolua_S) +{ lua_pushstring(tolua_S,"Layer"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) @@ -2363,7 +2384,10 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) lua_pushcfunction(tolua_S, tolua_cocos2d_Layer_unregisterScriptAccelerateHandler); lua_rawset(tolua_S, -3); } - +} + +static void extendScheduler(lua_State* tolua_S) +{ lua_pushstring(tolua_S,"Scheduler"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) @@ -2375,7 +2399,10 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) lua_pushcfunction(tolua_S,tolua_cocos2d_Scheduler_unscheduleScriptEntry); lua_rawset(tolua_S, -3); } - +} + +static void extendSequence(lua_State* tolua_S) +{ lua_pushstring(tolua_S,"Sequence"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) @@ -2384,7 +2411,10 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) lua_pushcfunction(tolua_S,tolua_cocos2d_Sequence_create); lua_rawset(tolua_S,-3); } - +} + +static void extendCallFunc(lua_State* tolua_S) +{ lua_pushstring(tolua_S,"CallFunc"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) @@ -2393,7 +2423,10 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) lua_pushcfunction(tolua_S,tolua_cocos2d_CallFunc_create); lua_rawset(tolua_S,-3); } - +} + +static void extendSpawn(lua_State* tolua_S) +{ lua_pushstring(tolua_S,"Spawn"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) @@ -2402,7 +2435,10 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) lua_pushcfunction(tolua_S,tolua_cocos2d_Spawn_create); lua_rawset(tolua_S,-3); } - +} + +static void extendCardinalSplineBy(lua_State* tolua_S) +{ lua_pushstring(tolua_S,"CardinalSplineBy"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) @@ -2411,7 +2447,10 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) lua_pushcfunction(tolua_S,tolua_cocos2d_CardinalSplineBy_create); lua_rawset(tolua_S,-3); } - +} + +static void extendCatmullRomBy(lua_State* tolua_S) +{ lua_pushstring(tolua_S,"CatmullRomBy"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) @@ -2420,7 +2459,10 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) lua_pushcfunction(tolua_S,tolua_cocos2d_CatmullRomBy_create); lua_rawset(tolua_S,-3); } - +} + +static void extendCatmullRomTo(lua_State* tolua_S) +{ lua_pushstring(tolua_S,"CatmullRomTo"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) @@ -2429,7 +2471,10 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) lua_pushcfunction(tolua_S,tolua_cocos2d_CatmullRomTo_create); lua_rawset(tolua_S,-3); } - +} + +static void extendBezierBy(lua_State* tolua_S) +{ lua_pushstring(tolua_S,"BezierBy"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) @@ -2438,7 +2483,10 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) lua_pushcfunction(tolua_S,tolua_cocos2d_BezierBy_create); lua_rawset(tolua_S,-3); } - +} + +static void extendBezierTo(lua_State* tolua_S) +{ lua_pushstring(tolua_S,"BezierTo"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) @@ -2447,7 +2495,10 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) lua_pushcfunction(tolua_S,tolua_cocos2d_BezierTo_create); lua_rawset(tolua_S,-3); } - +} + +static void extendDrawNode(lua_State* tolua_S) +{ lua_pushstring(tolua_S,"DrawNode"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) @@ -2456,7 +2507,10 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) lua_pushcfunction(tolua_S,tolua_cocos2d_DrawNode_drawPolygon); lua_rawset(tolua_S,-3); } - +} + +static void extendSprite(lua_State* tolua_S) +{ lua_pushstring(tolua_S,"Sprite"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) @@ -2465,7 +2519,10 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) lua_pushcfunction(tolua_S,tolua_cocos2dx_Sprite_setBlendFunc); lua_rawset(tolua_S,-3); } - +} + +static void extendLayerColor(lua_State* tolua_S) +{ lua_pushstring(tolua_S,"LayerColor"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) @@ -2474,7 +2531,10 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) lua_pushcfunction(tolua_S,tolua_cocos2dx_LayerColor_setBlendFunc); lua_rawset(tolua_S,-3); } - +} + +static void extendLayerMultiplex(lua_State* tolua_S) +{ lua_pushstring(tolua_S,"LayerMultiplex"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) @@ -2483,7 +2543,10 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) lua_pushcfunction(tolua_S,tolua_cocos2dx_LayerMultiplex_create); lua_rawset(tolua_S,-3); } - +} + +static void extendParticleSystem(lua_State* tolua_S) +{ lua_pushstring(tolua_S,"ParticleSystem"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) @@ -2492,7 +2555,10 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) lua_pushcfunction(tolua_S,tolua_cocos2dx_ParticleSystem_setBlendFunc); lua_rawset(tolua_S,-3); } - +} + +static void extendCamera(lua_State* tolua_S) +{ lua_pushstring(tolua_S, "Camera"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) @@ -2509,7 +2575,10 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) lua_pushcfunction(tolua_S,tolua_cocos2dx_Camera_getEyeXYZ ); lua_rawset(tolua_S,-3); } - +} + +static void extendFileUtils(lua_State* tolua_S) +{ lua_pushstring(tolua_S, "FileUtils"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) @@ -2518,7 +2587,10 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) lua_pushcfunction(tolua_S,tolua_cocos2dx_FileUtils_getStringFromFile ); lua_rawset(tolua_S,-3); } - +} + +static void extendUserDefault(lua_State* tolua_S) +{ lua_pushstring(tolua_S, "UserDefault"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) @@ -2527,7 +2599,40 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) lua_pushcfunction(tolua_S,tolua_cocos2dx_UserDefault_getInstance ); lua_rawset(tolua_S,-3); } +} + + +int register_all_cocos2dx_manual(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + extendNode(tolua_S); + extendLayer(tolua_S); + extendMenuItem(tolua_S); + extendMenuItemImage(tolua_S); + extendMenuItemLabel(tolua_S); + extendMenuItemFont(tolua_S); + extendMenuItemSprite(tolua_S); + extendMenuItemToggle(tolua_S); + extendMenu(tolua_S); + extendScheduler(tolua_S); + extendSequence(tolua_S); + extendCallFunc(tolua_S); + extendSpawn(tolua_S); + extendCardinalSplineBy(tolua_S); + extendCatmullRomBy(tolua_S); + extendCatmullRomTo(tolua_S); + extendBezierBy(tolua_S); + extendBezierTo(tolua_S); + extendDrawNode(tolua_S); + extendSprite(tolua_S); + extendLayerColor(tolua_S); + extendLayerMultiplex(tolua_S); + extendParticleSystem(tolua_S); + extendCamera(tolua_S); + extendFileUtils(tolua_S); + extendUserDefault(tolua_S); extendGLProgram(tolua_S); extendTexture2D(tolua_S); diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_manual.hpp b/scripting/lua/cocos2dx_support/lua_cocos2dx_manual.hpp similarity index 100% rename from scripting/lua/cocos2dx_support/generated/lua_cocos2dx_manual.hpp rename to scripting/lua/cocos2dx_support/lua_cocos2dx_manual.hpp diff --git a/scripting/lua/script/CCBReaderLoad.lua b/scripting/lua/script/CCBReaderLoad.lua index fdd06d7d37..3919dfce6e 100644 --- a/scripting/lua/script/CCBReaderLoad.lua +++ b/scripting/lua/script/CCBReaderLoad.lua @@ -1,54 +1,49 @@ ccb = ccb or {} -function CCBReaderLoad(strFilePath,proxy,bSetOwner,strOwnerName) +function CCBReaderLoad(strFilePath,proxy,owner) if nil == proxy then return end local ccbReader = proxy:createCCBReader() - local node = proxy:readCCBFromFile(strFilePath,ccbReader,bSetOwner) - local owner = ccbReader:getOwner() + local node = ccbReader:load(strFilePath) local rootName = "" --owner set in readCCBFromFile is proxy if nil ~= owner then - --Callbacks - local ownerCallbackNames = tolua.cast(ccbReader:getOwnerCallbackNames(),"CCArray") - local ownerCallbackNodes = tolua.cast(ccbReader:getOwnerCallbackNodes(),"CCArray") + local ownerCallbackNames = ccbReader:getOwnerCallbackNames() + local ownerCallbackNodes = ccbReader:getOwnerCallbackNodes() + local ownerCallbackControlEvents = ccbReader:getOwnerCallbackControlEvents() local i = 1 - for i = 1,ownerCallbackNames:count() do - local callbackName = tolua.cast(ownerCallbackNames:objectAtIndex(i - 1),"CCString") - local callbackNode = tolua.cast(ownerCallbackNodes:objectAtIndex(i - 1),"CCNode") - if "" ~= strOwnerName and nil ~= ccb[strOwnerName] then - local cbName = callbackName:getCString() - if "function" == type(ccb[strOwnerName][cbName]) then - proxy:setCallback(callbackNode,ccb[strOwnerName][cbName]) - else - print("WARNING: Cannot found lua function [" .. strOwnerName .. "." .. cbName .. "] for owner selector") - end + for i = 1,table.getn(ownerCallbackNames) do + local callbackName = ownerCallbackNames[i] + local callbackNode = tolua.cast(ownerCallbackNodes[i],"Node") + + if "function" == type(owner[callbackName]) then + proxy:setCallback(callbackNode, owner[callbackName], ownerCallbackControlEvents[i]) + else + print("Warning: Cannot find owner's lua function:" .. ":" .. callbackName .. " for ownerVar selector") end + end --Variables - local ownerOutletNames = tolua.cast(ccbReader:getOwnerOutletNames(),"CCArray") - local ownerOutletNodes = tolua.cast(ccbReader:getOwnerOutletNodes(),"CCArray") + local ownerOutletNames = ccbReader:getOwnerOutletNames() + local ownerOutletNodes = ccbReader:getOwnerOutletNodes() - for i = 1, ownerOutletNames:count() do - local outletName = tolua.cast(ownerOutletNames:objectAtIndex(i - 1),"CCString") - local outletNode = tolua.cast(ownerOutletNodes:objectAtIndex(i - 1),"CCNode") - - if "" ~= strOwnerName and nil ~= ccb[strOwnerName] then - ccb[strOwnerName][outletName:getCString()] = tolua.cast(outletNode, proxy:getNodeTypeName(outletNode)) - end + for i = 1, table.getn(ownerOutletNames) do + local outletName = ownerOutletNames[i] + local outletNode = tolua.cast(ownerOutletNodes[i],"Node") + owner[outletName] = outletNode end end - local nodesWithAnimationManagers = tolua.cast(ccbReader:getNodesWithAnimationManagers(),"CCArray") - local animationManagersForNodes = tolua.cast(ccbReader:getAnimationManagersForNodes(),"CCArray") + local nodesWithAnimationManagers = ccbReader:getNodesWithAnimationManagers() + local animationManagersForNodes = ccbReader:getAnimationManagersForNodes() - for i = 1 , nodesWithAnimationManagers:count() do - local innerNode = tolua.cast(nodesWithAnimationManagers:objectAtIndex(i - 1),"CCNode") - local animationManager = tolua.cast(animationManagersForNodes:objectAtIndex(i - 1),"CCBAnimationManager") + for i = 1 , table.getn(nodesWithAnimationManagers) do + local innerNode = tolua.cast(nodesWithAnimationManagers[i], "Node") + local animationManager = tolua.cast(animationManagersForNodes[i], "CCBAnimationManager") local documentControllerName = animationManager:getDocumentControllerName() if "" == documentControllerName then @@ -58,33 +53,32 @@ function CCBReaderLoad(strFilePath,proxy,bSetOwner,strOwnerName) end --Callbacks - local documentCallbackNames = tolua.cast(animationManager:getDocumentCallbackNames(),"CCArray") - local documentCallbackNodes = tolua.cast(animationManager:getDocumentCallbackNodes(),"CCArray") + local documentCallbackNames = animationManager:getDocumentCallbackNames() + local documentCallbackNodes = animationManager:getDocumentCallbackNodes() + local documentCallbackControlEvents = animationManager:getDocumentCallbackControlEvents() - for i = 1,documentCallbackNames:count() do - local callbackName = tolua.cast(documentCallbackNames:objectAtIndex(i - 1),"CCString") - local callbackNode = tolua.cast(documentCallbackNodes:objectAtIndex(i - 1),"CCNode") + for i = 1,table.getn(documentCallbackNames) do + local callbackName = documentCallbackNames[i] + local callbackNode = tolua.cast(documentCallbackNodes[i],"Node") if "" ~= documentControllerName and nil ~= ccb[documentControllerName] then - --proxy:setCallback(callbackNode,ccb[documentControllerName][callbackName:getCString()]) - local cbName = callbackName:getCString() - if "function" == type(ccb[documentControllerName][cbName]) then - proxy:setCallback(callbackNode,ccb[documentControllerName][cbName]) + if "function" == type(ccb[documentControllerName][callbackName]) then + proxy:setCallback(callbackNode, ccb[documentControllerName][callbackName], documentCallbackControlEvents[i]) else - print("WARNING: Cannot found lua function [" .. documentControllerName .. "." .. cbName .. "] for docRoot selector") + print("Warning: Cannot found lua function [" .. documentControllerName .. ":" .. callbackName .. "] for docRoot selector") end end end --Variables - local documentOutletNames = tolua.cast(animationManager:getDocumentOutletNames(),"CCArray") - local documentOutletNodes = tolua.cast(animationManager:getDocumentOutletNodes(),"CCArray") - - for i = 1, documentOutletNames:count() do - local outletName = tolua.cast(documentOutletNames:objectAtIndex(i - 1),"CCString") - local outletNode = tolua.cast(documentOutletNodes:objectAtIndex(i - 1),"CCNode") + local documentOutletNames = animationManager:getDocumentOutletNames() + local documentOutletNodes = animationManager:getDocumentOutletNodes() + for i = 1, table.getn(documentOutletNames) do + local outletName = documentOutletNames[i] + local outletNode = tolua.cast(documentOutletNodes[i],"Node") + if nil ~= ccb[documentControllerName] then - ccb[documentControllerName][outletName:getCString()] = tolua.cast(outletNode, proxy:getNodeTypeName(outletNode)) + ccb[documentControllerName][outletName] = tolua.cast(outletNode, proxy:getNodeTypeName(outletNode)) end end --[[ @@ -94,18 +88,18 @@ function CCBReaderLoad(strFilePath,proxy,bSetOwner,strOwnerName) --Setup timeline callbacks local keyframeCallbacks = animationManager:getKeyframeCallbacks() - for i = 1 , keyframeCallbacks:count() do - local callbackCombine = tolua.cast(keyframeCallbacks:objectAtIndex(i - 1),"CCString"):getCString() + for i = 1 , table.getn(keyframeCallbacks) do + local callbackCombine = keyframeCallbacks[i] local beignIndex,endIndex = string.find(callbackCombine,":") local callbackType = tonumber(string.sub(callbackCombine,1,beignIndex - 1)) local callbackName = string.sub(callbackCombine,endIndex + 1, -1) --Document callback if 1 == callbackType and nil ~= ccb[documentControllerName] then - local callfunc = CCCallFunc:create(ccb[documentControllerName][callbackName]) + local callfunc = cc.CallFunc:create(ccb[documentControllerName][callbackName]) animationManager:setCallFuncForLuaCallbackNamed(callfunc, callbackCombine); elseif 2 == callbackType and nil ~= owner then --Owner callback - local callfunc = CCCallFunc:create(ccb[strOwnerName][callbackName]) + local callfunc = cc.CallFunc:create(owner[callbackName])--need check animationManager:setCallFuncForLuaCallbackNamed(callfunc, callbackCombine) end end diff --git a/scripting/lua/script/Cocos2dConstants.lua b/scripting/lua/script/Cocos2dConstants.lua index e363efaca6..98ebda3156 100644 --- a/scripting/lua/script/Cocos2dConstants.lua +++ b/scripting/lua/script/Cocos2dConstants.lua @@ -172,3 +172,60 @@ cc.UNIFORM_RANDOM01_S = 'CC_Random01' cc.UNIFORM_SAMPLER_S = 'CC_Texture0' cc.UNIFORM_SIN_TIME_S = 'CC_SinTime' cc.UNIFORM_TIME_S = 'CC_Time' + +cc.PLATFORM_OS_WINDOWS = 0 +cc.PLATFORM_OS_LINUX = 1 +cc.PLATFORM_OS_MAC = 2 +cc.PLATFORM_OS_ANDROID = 3 +cc.PLATFORM_OS_IPHONE = 4 +cc.PLATFORM_OS_IPAD = 5 +cc.PLATFORM_OS_BLACKBERRY = 6 +cc.PLATFORM_OS_NACL = 7 +cc.PLATFORM_OS_EMSCRIPTEN = 8 +cc.PLATFORM_OS_TIZEN = 9 + +cc.SCROLLVIEW_SCRIPT_SCROLL = 0 +cc.SCROLLVIEW_SCRIPT_ZOOM = 1 + +cc.SCROLLVIEW_DIRECTION_NONE = -1 +cc.SCROLLVIEW_DIRECTION_HORIZONTAL = 0 +cc.SCROLLVIEW_DIRECTION_VERTICAL = 1 +cc.SCROLLVIEW_DIRECTION_BOTH = 2 + +cc.CONTROL_EVENTTYPE_TOUCH_DOWN = 1 +cc.CONTROL_EVENTTYPE_DRAG_INSIDE = 2 +cc.CONTROL_EVENTTYPE_DRAG_OUTSIDE = 4 +cc.CONTROL_EVENTTYPE_DRAG_ENTER = 8 +cc.CONTROL_EVENTTYPE_DRAG_EXIT = 16 +cc.CONTROL_EVENTTYPE_TOUCH_UP_INSIDE = 32 +cc.CONTROL_EVENTTYPE_TOUCH_UP_OUTSIDE = 64 +cc.CONTROL_EVENTTYPE_TOUCH_CANCEL = 128 +cc.CONTROL_EVENTTYPE_VALUE_CHANGED = 256 + +cc.CONTROL_STATE_NORMAL = 1 +cc.CONTROL_STATE_HIGH_LIGHTED = 2 +cc.CONTROL_STATE_DISABLED = 4 +cc.CONTROL_STATE_SELECTED = 8 + + +cc.KEYBOARD_RETURNTYPE_DEFAULT = 0 +cc.KEYBOARD_RETURNTYPE_DONE = 1 +cc.KEYBOARD_RETURNTYPE_SEND = 2 +cc.KEYBOARD_RETURNTYPE_SEARCH = 3 +cc.KEYBOARD_RETURNTYPE_GO = 4 + + +cc.EDITBOX_INPUT_MODE_ANY = 0 +cc.EDITBOX_INPUT_MODE_EMAILADDR = 1 +cc.EDITBOX_INPUT_MODE_NUMERIC = 2 +cc.EDITBOX_INPUT_MODE_PHONENUMBER = 3 +cc.EDITBOX_INPUT_MODE_URL = 4 +cc.EDITBOX_INPUT_MODE_DECIMAL = 5 +cc.EDITBOX_INPUT_MODE_SINGLELINE = 6 + + +cc.EDITBOX_INPUT_FLAG_PASSWORD = 0 +cc.EDITBOX_INPUT_FLAG_SENSITIVE = 1 +cc.EDITBOX_INPUT_FLAG_INITIAL_CAPS_WORD = 2 +cc.EDITBOX_INPUT_FLAG_INITIAL_CAPS_SENTENCE = 3 +cc.EDITBOX_INPUT_FLAG_INITIAL_CAPS_ALL_CHARACTERS = 4 diff --git a/tools/bindings-generator b/tools/bindings-generator index 2a8d5c63d3..eb2e212426 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit 2a8d5c63d31a823ad2c2d4b7486117b4bb3ae86a +Subproject commit eb2e2124260b7bc1ebd27c0872aaf4e95ead93db diff --git a/tools/tolua/cocos2dx.ini b/tools/tolua/cocos2dx.ini index 278b930c3a..304af16ebe 100644 --- a/tools/tolua/cocos2dx.ini +++ b/tools/tolua/cocos2dx.ini @@ -79,7 +79,7 @@ skip = Node::[setGLServerState description getUserObject .*UserData getGLServerS Array::[*], Range::[*], NotificationObserver::[*], - Image::[initWithString initWithImageData], + Image::[initWithString initWithImageData initWithRawData], Sequence::[create], Spawn::[create], GLProgram::[getProgram setUniformLocationWith2f.* setUniformLocationWith1f.* setUniformLocationWith3f.* setUniformLocationWith4f.*], diff --git a/tools/tolua/cocos2dx_extension.ini b/tools/tolua/cocos2dx_extension.ini index f9688a8765..62ccd46dd3 100644 --- a/tools/tolua/cocos2dx_extension.ini +++ b/tools/tolua/cocos2dx_extension.ini @@ -36,7 +36,7 @@ classes = CCBReader.* CCBAnimationManager.* Scale9Sprite Control.* ControlButton # functions from all classes. skip = CCBReader::[^CCBReader$ addOwnerCallbackName isJSControlled readByte getCCBMemberVariableAssigner readFloat getCCBSelectorResolver toLowerCase lastPathComponent deletePathExtension endsWith concat getResolutionScale getAnimatedProperties readBool readInt addOwnerCallbackNode addDocumentCallbackName readCachedString readNodeGraphFromData addDocumentCallbackNode getLoadedSpriteSheet initWithData readFileWithCleanUp getOwner$ readNodeGraphFromFile createSceneWithNodeGraphFromFile getAnimationManagers$ setAnimationManagers], - CCBAnimationManager::[setAnimationCompletedCallback], + CCBAnimationManager::[setAnimationCompletedCallback setCallFunc], ScrollView::[(g|s)etDelegate$], .*Delegate::[*], .*Loader.*::[*], @@ -47,8 +47,7 @@ skip = CCBReader::[^CCBReader$ addOwnerCallbackName isJSControlled readByte getC ControlUtils::[*], ControlSwitchSprite::[*] -rename_functions = CCBReader::[getAnimationManager=getActionManager setAnimationManager=setActionManager], - CCBAnimationManager::[setCallFunc=setCallFuncForJSCallbackNamed] +rename_functions = CCBReader::[getAnimationManager=getActionManager setAnimationManager=setActionManager] rename_classes = CCBReader::_Reader, CCBAnimationManager::AnimationManager From 3476a843e28704a4bc4a646494e1046fc6bce2ef Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 22 Aug 2013 10:18:59 +0800 Subject: [PATCH 058/126] Array can be use in stl::sort() when not using vector inside --- cocos2dx/cocoa/CCArray.h | 93 +++++++++++++++---- .../touch_dispatcher/CCTouchDispatcher.cpp | 9 +- 2 files changed, 78 insertions(+), 24 deletions(-) diff --git a/cocos2dx/cocoa/CCArray.h b/cocos2dx/cocoa/CCArray.h index aba86abb54..ba8ba50da3 100644 --- a/cocos2dx/cocoa/CCArray.h +++ b/cocos2dx/cocoa/CCArray.h @@ -50,10 +50,10 @@ class RCPtr public: //Construct using a C pointer //e.g. RCPtr< T > x = new T(); - RCPtr(T* ptr = NULL) + RCPtr(T* ptr = nullptr) : _ptr(ptr) { - if(ptr != NULL) {ptr->retain();} + if(ptr != nullptr) {ptr->retain();} } //Copy constructor @@ -69,13 +69,13 @@ public: : _ptr(ptr._ptr) { // printf("Array: Move Constructor: %p\n", this); - ptr._ptr = NULL; + ptr._ptr = nullptr; } ~RCPtr() { // printf("Array: Destructor: %p\n", this); - if(_ptr != NULL) {_ptr->release();} + if(_ptr != nullptr) {_ptr->release();} } //Assign a pointer @@ -87,8 +87,8 @@ public: //The following grab and release operations have to be performed //in that order to handle the case where ptr == _ptr //(See comment below by David Garlisch) - if(ptr != NULL) {ptr->retain();} - if(_ptr != NULL) {_ptr->release();} + if(ptr != nullptr) {ptr->retain();} + if(_ptr != nullptr) {_ptr->release();} _ptr = ptr; return (*this); } @@ -113,7 +113,7 @@ public: T* operator->() const {return _ptr;} //x->member T &operator*() const {return *_ptr;} //*x, (*x).member explicit operator T*() const {return _ptr;} //T* y = x; - explicit operator bool() const {return _ptr != NULL;} //if(x) {/*x is not NULL*/} + explicit operator bool() const {return _ptr != nullptr;} //if(x) {/*x is not NULL*/} bool operator==(const RCPtr &ptr) {return _ptr == ptr._ptr;} bool operator==(const T *ptr) {return _ptr == ptr;} @@ -273,7 +273,8 @@ public: // Querying an Array /** Returns element count of the array */ - unsigned int count() const { + unsigned int count() const + { #if CC_USE_ARRAY_VECTOR return data.size(); #else @@ -281,7 +282,8 @@ public: #endif } /** Returns capacity of the array */ - unsigned int capacity() const { + unsigned int capacity() const + { #if CC_USE_ARRAY_VECTOR return data.capacity(); #else @@ -293,7 +295,8 @@ public: CC_DEPRECATED_ATTRIBUTE int indexOfObject(Object* object) const { return getIndexOfObject(object); } /** Returns an element with a certain index */ - Object* getObjectAtIndex(int index) { + Object* getObjectAtIndex(int index) + { CCASSERT(index>=0 && index < count(), "index out of range in objectAtIndex()"); #if CC_USE_ARRAY_VECTOR return data[index].get(); @@ -303,12 +306,14 @@ public: } CC_DEPRECATED_ATTRIBUTE Object* objectAtIndex(int index) { return getObjectAtIndex(index); } /** Returns the last element of the array */ - Object* getLastObject() { + Object* getLastObject() + { #if CC_USE_ARRAY_VECTOR return data.back().get(); #else - if( data->num > 0 ) + if(data->num > 0) return data->arr[data->num-1]; + return nullptr; #endif } @@ -331,7 +336,8 @@ public: /** sets a certain object at a certain index */ void setObject(Object* object, int index); /** sets a certain object at a certain index without retaining. Use it with caution */ - void fastSetObject(Object* object, int index) { + void fastSetObject(Object* object, int index) + { #if CC_USE_ARRAY_VECTOR setObject(object, index); #else @@ -340,12 +346,13 @@ public: #endif } - void swap( int indexOne, int indexTwo ) { + void swap( int indexOne, int indexTwo ) + { CCASSERT(indexOne >=0 && indexOne < count() && indexTwo >= 0 && indexTwo < count(), "Invalid indices"); #if CC_USE_ARRAY_VECTOR - std::swap( data[indexOne], data[indexTwo] ); + std::swap(data[indexOne], data[indexTwo]); #else - std::swap( data->arr[indexOne], data->arr[indexTwo] ); + std::swap(data->arr[indexOne], data->arr[indexTwo]); #endif } @@ -398,7 +405,7 @@ public: const_iterator cend() { return data.cend(); } #else - class ArrayIterator : public std::iterator + class ArrayIterator : public std::iterator { public: ArrayIterator(int index, Array *array) : _index(index), _parent(array) {} @@ -412,13 +419,59 @@ public: ArrayIterator operator++(int dummy) { ArrayIterator tmp(*this); - (*this)++; + ++_index; return tmp; } + + ArrayIterator& operator--() + { + --_index; + return *this; + } + ArrayIterator operator--(int dummy) + { + ArrayIterator tmp(*this); + --_index; + return tmp; + } + + int operator-(const ArrayIterator& rhs) const + { + return _index - rhs._index; + } + ArrayIterator operator-(int d) + { + _index -= d; + return *this; + } + const ArrayIterator& operator-=(int d) + { + _index -= d; + return *this; + } + + ArrayIterator operator+(int d) + { + _index += d; + return *this; + } + + const ArrayIterator& operator+=(int d) + { + _index += d; + return *this; + } + + // add these function to make compiler happy when using std::sort(), it is meaningless + bool operator>=(const ArrayIterator& rhs) const { return false; } + bool operator<=(const ArrayIterator& rhs) const { return false; } + bool operator>(const ArrayIterator& rhs) const { return false; } + bool operator<(const ArrayIterator& rhs) const { return false; } + bool operator==(const ArrayIterator& rhs) { return _index == rhs._index; } bool operator!=(const ArrayIterator& rhs) { return _index != rhs._index; } - Object* operator*() { return _parent->getObjectAtIndex(_index); } - Object* operator->() { return _parent->getObjectAtIndex(_index); } + reference operator*() { return _parent->data->arr[_index]; } + value_type operator->() { return _parent->data->arr[_index];; } private: int _index; diff --git a/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp b/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp index 8d070abba4..67c7a619b0 100644 --- a/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp +++ b/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp @@ -24,6 +24,8 @@ THE SOFTWARE. ****************************************************************************/ #include "CCTouchDispatcher.h" + +#include #include "CCTouchHandler.h" #include "cocoa/CCArray.h" #include "cocoa/CCSet.h" @@ -31,14 +33,13 @@ THE SOFTWARE. #include "textures/CCTexture2D.h" #include "support/data_support/ccCArray.h" #include "ccMacros.h" -#include NS_CC_BEGIN /** * Used for sort */ -#if 0 +#if CC_USE_ARRAY_VECTOR static int less(const RCPtr& p1, const RCPtr& p2) { Object *o1, *o2; @@ -306,8 +307,8 @@ TouchHandler* TouchDispatcher::findHandler(Array* pArray, TouchDelegate *pDelega void TouchDispatcher::rearrangeHandlers(Array *array) { - std::sort(array->data->arr, array->data->arr + array->data->num, less); -// std::sort( std::begin(*array), std::end(*array), less); +// std::sort(array->data->arr, array->data->arr + array->data->num, less); + std::sort( std::begin(*array), std::end(*array), less); } void TouchDispatcher::setPriority(int nPriority, TouchDelegate *pDelegate) From 8489514d732408702e63a5da113e5a6a70eadde1 Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Thu, 22 Aug 2013 10:28:33 +0800 Subject: [PATCH 059/126] issue #2433:Add a newline --- .../lua/cocos2dx_support/lua_cocos2dx_extension_manual.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripting/lua/cocos2dx_support/lua_cocos2dx_extension_manual.cpp b/scripting/lua/cocos2dx_support/lua_cocos2dx_extension_manual.cpp index 619fc5ef98..7a4b325aaf 100644 --- a/scripting/lua/cocos2dx_support/lua_cocos2dx_extension_manual.cpp +++ b/scripting/lua/cocos2dx_support/lua_cocos2dx_extension_manual.cpp @@ -859,4 +859,4 @@ int register_all_cocos2dx_extension_manual(lua_State* tolua_S) extendCCBReader(tolua_S); extendCCBAnimationManager(tolua_S); return 0; -} \ No newline at end of file +} From 2de8963a0adcb2de17d5fc7067de7399a750c3c7 Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 22 Aug 2013 10:45:47 +0800 Subject: [PATCH 060/126] fix warnings caused by deprecating some functions of Array --- cocos2dx/CCDirector.cpp | 6 +- cocos2dx/CCScheduler.cpp | 4 +- cocos2dx/actions/CCActionInterval.cpp | 10 +-- cocos2dx/cocoa/CCArray.cpp | 70 ++++++++----------- cocos2dx/cocoa/CCArray.h | 2 +- cocos2dx/cocoa/CCAutoreleasePool.cpp | 4 +- cocos2dx/cocoa/CCDictionary.cpp | 2 +- cocos2dx/label_nodes/CCLabel.cpp | 2 +- .../CCLayer.cpp | 12 ++-- cocos2dx/menu_nodes/CCMenuItem.cpp | 12 ++-- .../particle_nodes/CCParticleBatchNode.cpp | 10 +-- cocos2dx/sprite_nodes/CCSprite.cpp | 2 +- cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp | 14 ++-- .../tilemap_parallax_nodes/CCTMXXMLParser.cpp | 26 +++---- extensions/CCArmature/CCBone.cpp | 4 +- extensions/CCArmature/datas/CCDatas.cpp | 6 +- .../CCArmature/display/CCDisplayManager.cpp | 6 +- extensions/CCBReader/CCBAnimationManager.cpp | 56 +++++++-------- extensions/CCBReader/CCNodeLoader.cpp | 8 +-- extensions/GUI/CCScrollView/CCScrollView.cpp | 14 ++-- extensions/GUI/CCScrollView/CCSorting.cpp | 6 +- extensions/GUI/CCScrollView/CCTableView.cpp | 14 ++-- extensions/network/HttpClient.cpp | 4 +- .../Classes/ParticleTest/ParticleTest.cpp | 4 +- .../PerformanceNodeChildrenTest.cpp | 8 +-- .../SpriteTest/SpriteTest.cpp.REMOVED.git-id | 2 +- .../Classes/TextInputTest/TextInputTest.cpp | 2 +- .../javascript/bindings/ScriptingCore.cpp | 8 +-- .../cocos2d_specifics.cpp.REMOVED.git-id | 2 +- 29 files changed, 154 insertions(+), 166 deletions(-) diff --git a/cocos2dx/CCDirector.cpp b/cocos2dx/CCDirector.cpp index 4de921cdd8..1c9f312302 100644 --- a/cocos2dx/CCDirector.cpp +++ b/cocos2dx/CCDirector.cpp @@ -622,7 +622,7 @@ void Director::popScene(void) else { _sendCleanupToScene = true; - _nextScene = (Scene*)_scenesStack->objectAtIndex(c - 1); + _nextScene = (Scene*)_scenesStack->getObjectAtIndex(c - 1); } } @@ -650,7 +650,7 @@ void Director::popToSceneStackLevel(int level) // pop stack until reaching desired level while (c > level) { - Scene *current = (Scene*)_scenesStack->lastObject(); + Scene *current = (Scene*)_scenesStack->getLastObject(); if (current->isRunning()) { @@ -663,7 +663,7 @@ void Director::popToSceneStackLevel(int level) --c; } - _nextScene = (Scene*)_scenesStack->lastObject(); + _nextScene = (Scene*)_scenesStack->getLastObject(); _sendCleanupToScene = false; } diff --git a/cocos2dx/CCScheduler.cpp b/cocos2dx/CCScheduler.cpp index fbfcc3b529..5b8956ba8d 100644 --- a/cocos2dx/CCScheduler.cpp +++ b/cocos2dx/CCScheduler.cpp @@ -687,7 +687,7 @@ void Scheduler::unscheduleScriptEntry(unsigned int uScheduleScriptEntryID) { for (int i = _scriptHandlerEntries->count() - 1; i >= 0; i--) { - SchedulerScriptHandlerEntry* pEntry = static_cast(_scriptHandlerEntries->objectAtIndex(i)); + SchedulerScriptHandlerEntry* pEntry = static_cast(_scriptHandlerEntries->getObjectAtIndex(i)); if (pEntry->getEntryId() == (int)uScheduleScriptEntryID) { pEntry->markedForDeletion(); @@ -909,7 +909,7 @@ void Scheduler::update(float dt) { for (int i = _scriptHandlerEntries->count() - 1; i >= 0; i--) { - SchedulerScriptHandlerEntry* pEntry = static_cast(_scriptHandlerEntries->objectAtIndex(i)); + SchedulerScriptHandlerEntry* pEntry = static_cast(_scriptHandlerEntries->getObjectAtIndex(i)); if (pEntry->isMarkedForDeletion()) { _scriptHandlerEntries->removeObjectAtIndex(i); diff --git a/cocos2dx/actions/CCActionInterval.cpp b/cocos2dx/actions/CCActionInterval.cpp index f9c384e1f3..7f64a56214 100644 --- a/cocos2dx/actions/CCActionInterval.cpp +++ b/cocos2dx/actions/CCActionInterval.cpp @@ -206,13 +206,13 @@ Sequence* Sequence::create(Array* arrayOfActions) unsigned int count = arrayOfActions->count(); CC_BREAK_IF(count == 0); - FiniteTimeAction* prev = static_cast( arrayOfActions->objectAtIndex(0) ); + FiniteTimeAction* prev = static_cast(arrayOfActions->getObjectAtIndex(0)); if (count > 1) { for (unsigned int i = 1; i < count; ++i) { - prev = createWithTwoActions(prev, static_cast( arrayOfActions->objectAtIndex(i)) ); + prev = createWithTwoActions(prev, static_cast(arrayOfActions->getObjectAtIndex(i))); } } else @@ -578,12 +578,12 @@ Spawn* Spawn::create(Array *arrayOfActions) { unsigned int count = arrayOfActions->count(); CC_BREAK_IF(count == 0); - FiniteTimeAction* prev = static_cast( arrayOfActions->objectAtIndex(0) ); + FiniteTimeAction* prev = static_cast(arrayOfActions->getObjectAtIndex(0)); if (count > 1) { for (unsigned int i = 1; i < arrayOfActions->count(); ++i) { - prev = createWithTwoActions(prev, static_cast( arrayOfActions->objectAtIndex(i)) ); + prev = createWithTwoActions(prev, static_cast(arrayOfActions->getObjectAtIndex(i))); } } else @@ -2107,7 +2107,7 @@ void Animate::update(float t) float splitTime = _splitTimes->at(i); if( splitTime <= t ) { - AnimationFrame* frame = static_cast(frames->objectAtIndex(i)); + AnimationFrame* frame = static_cast(frames->getObjectAtIndex(i)); frameToDisplay = frame->getSpriteFrame(); static_cast(_target)->setDisplayFrame(frameToDisplay); diff --git a/cocos2dx/cocoa/CCArray.cpp b/cocos2dx/cocoa/CCArray.cpp index 114fc1b7ec..2220319f0a 100644 --- a/cocos2dx/cocoa/CCArray.cpp +++ b/cocos2dx/cocoa/CCArray.cpp @@ -90,7 +90,7 @@ Array* Array::create(Object* object, ...) { array->addObject(object); Object *i = va_arg(args, Object*); - while(i) + while (i) { array->addObject(i); i = va_arg(args, Object*); @@ -129,12 +129,12 @@ Array* Array::createWithCapacity(unsigned int capacity) Array* Array::createWithContentsOfFile(const char* fileName) { - Array* pRet = Array::createWithContentsOfFileThreadSafe(fileName); - if (pRet != NULL) + Array* ret = Array::createWithContentsOfFileThreadSafe(fileName); + if (ret != nullptr) { pRet->autorelease(); } - return pRet; + return ret; } Array* Array::createWithContentsOfFileThreadSafe(const char* fileName) @@ -163,7 +163,7 @@ bool Array::initWithObjects(Object* object, ...) bool ret = false; do { - CC_BREAK_IF(object == NULL); + CC_BREAK_IF(object == nullptr); va_list args; va_start(args, object); @@ -172,7 +172,7 @@ bool Array::initWithObjects(Object* object, ...) { this->addObject(object); Object* i = va_arg(args, Object*); - while(i) + while (i) { this->addObject(i); i = va_arg(args, Object*); @@ -200,10 +200,6 @@ bool Array::initWithArray(Array* otherArray) int Array::getIndexOfObject(Object* object) const { -// auto it = std::find(data.begin(), data.end(), object ); -// if( it == data.end() ) -// return -1; -// return it - std::begin(data); auto it = data.begin(); for (int i = 0; it != data.end(); ++it, ++i) @@ -239,7 +235,7 @@ Object* Array::getRandomObject() bool Array::containsObject(Object* object) const { int i = this->getIndexOfObject(object); - return (i >=0 ); + return (i >=0); } bool Array::isEqualToArray(Array* otherArray) @@ -282,14 +278,6 @@ void Array::removeLastObject(bool releaseObj) void Array::removeObject(Object* object, bool releaseObj /* ignored */) { -// auto begin = data.begin(); -// auto end = data.end(); -// -// auto it = std::find( begin, end, object); -// if( it != end ) { -// data.erase(it); -// } - auto it = data.begin(); for (; it != data.end(); ++it) { @@ -344,7 +332,6 @@ void Array::exchangeObjectAtIndex(unsigned int index1, unsigned int index2) void Array::replaceObjectAtIndex(unsigned int index, Object* object, bool releaseObject /* ignored */) { -// auto obj = data[index]; data[index] = object; } @@ -368,9 +355,9 @@ Array* Array::clone() const ret->autorelease(); ret->initWithCapacity(this->data.size() > 0 ? this->data.size() : 1); - Object* obj = NULL; - Object* tmpObj = NULL; - Clonable* clonable = NULL; + Object* obj = nullptr; + Object* tmpObj = nullptr; + Clonable* clonable = nullptr; CCARRAY_FOREACH(this, obj) { clonable = dynamic_cast(obj); @@ -402,13 +389,13 @@ void Array::acceptVisitor(DataVisitor &visitor) #else Array::Array() -: data(NULL) +: data(nullptr) { // init(); } Array::Array(unsigned int capacity) -: data(NULL) +: data(nullptr) { initWithCapacity(capacity); } @@ -455,7 +442,7 @@ Array* Array::create(Object* object, ...) { array->addObject(object); Object *i = va_arg(args, Object*); - while(i) + while (i) { array->addObject(i); i = va_arg(args, Object*); @@ -494,12 +481,12 @@ Array* Array::createWithCapacity(unsigned int capacity) Array* Array::createWithContentsOfFile(const char* fileName) { - Array* pRet = Array::createWithContentsOfFileThreadSafe(fileName); - if (pRet != NULL) + Array* ret = Array::createWithContentsOfFileThreadSafe(fileName); + if (ret != nullptr) { - pRet->autorelease(); + ret->autorelease(); } - return pRet; + return ret; } Array* Array::createWithContentsOfFileThreadSafe(const char* fileName) @@ -534,7 +521,7 @@ bool Array::initWithObjects(Object* object, ...) bool ret = false; do { - CC_BREAK_IF(object == NULL); + CC_BREAK_IF(object == nullptr); va_list args; va_start(args, object); @@ -543,7 +530,7 @@ bool Array::initWithObjects(Object* object, ...) { this->addObject(object); Object* i = va_arg(args, Object*); - while(i) + while (i) { this->addObject(i); i = va_arg(args, Object*); @@ -588,9 +575,9 @@ int Array::getIndexOfObject(Object* object) const Object* Array::getRandomObject() { - if (data->num==0) + if (data->num == 0) { - return NULL; + return nullptr; } float r = CCRANDOM_0_1(); @@ -639,7 +626,8 @@ void Array::setObject(Object* object, int index) { CCASSERT(index>=0 && index < count(), "Invalid index"); - if( object != data->arr[index] ) { + if (object != data->arr[index]) + { data->arr[index]->release(); data->arr[index] = object; object->retain(); @@ -685,13 +673,13 @@ void Array::fastRemoveObject(Object* object) void Array::exchangeObject(Object* object1, Object* object2) { unsigned int index1 = ccArrayGetIndexOfObject(data, object1); - if(index1 == UINT_MAX) + if (index1 == UINT_MAX) { return; } unsigned int index2 = ccArrayGetIndexOfObject(data, object2); - if(index2 == UINT_MAX) + if (index2 == UINT_MAX) { return; } @@ -721,7 +709,7 @@ void Array::reverseObjects() for (int i = 0; i < count ; i++) { ccArraySwapObjectsAtIndexes(data, i, maxIndex); - maxIndex--; + --maxIndex; } } } @@ -742,9 +730,9 @@ Array* Array::clone() const ret->autorelease(); ret->initWithCapacity(this->data->num > 0 ? this->data->num : 1); - Object* obj = NULL; - Object* tmpObj = NULL; - Clonable* clonable = NULL; + Object* obj = nullptr; + Object* tmpObj = nullptr; + Clonable* clonable = nullptr; CCARRAY_FOREACH(this, obj) { clonable = dynamic_cast(obj); diff --git a/cocos2dx/cocoa/CCArray.h b/cocos2dx/cocoa/CCArray.h index ba8ba50da3..1ca34a46a5 100644 --- a/cocos2dx/cocoa/CCArray.h +++ b/cocos2dx/cocoa/CCArray.h @@ -297,7 +297,7 @@ public: /** Returns an element with a certain index */ Object* getObjectAtIndex(int index) { - CCASSERT(index>=0 && index < count(), "index out of range in objectAtIndex()"); + CCASSERT(index>=0 && index < count(), "index out of range in getObjectAtIndex()"); #if CC_USE_ARRAY_VECTOR return data[index].get(); #else diff --git a/cocos2dx/cocoa/CCAutoreleasePool.cpp b/cocos2dx/cocoa/CCAutoreleasePool.cpp index fba96dced5..a62b46f192 100644 --- a/cocos2dx/cocoa/CCAutoreleasePool.cpp +++ b/cocos2dx/cocoa/CCAutoreleasePool.cpp @@ -165,10 +165,10 @@ void PoolManager::pop() // if(nCount > 1) // { -// _curReleasePool = _releasePoolStack->objectAtIndex(nCount - 2); +// _curReleasePool = _releasePoolStack->getObjectAtIndex(nCount - 2); // return; // } - _curReleasePool = (AutoreleasePool*)_releasePoolStack->objectAtIndex(nCount - 2); + _curReleasePool = (AutoreleasePool*)_releasePoolStack->getObjectAtIndex(nCount - 2); } /*_curReleasePool = NULL;*/ diff --git a/cocos2dx/cocoa/CCDictionary.cpp b/cocos2dx/cocoa/CCDictionary.cpp index f7412a4fff..6a79b8f929 100644 --- a/cocos2dx/cocoa/CCDictionary.cpp +++ b/cocos2dx/cocoa/CCDictionary.cpp @@ -340,7 +340,7 @@ Object* Dictionary::randomObject() return NULL; } - Object* key = allKeys()->randomObject(); + Object* key = allKeys()->getRandomObject(); if (_dictType == kDictInt) { diff --git a/cocos2dx/label_nodes/CCLabel.cpp b/cocos2dx/label_nodes/CCLabel.cpp index 345c62c138..4af7aff109 100644 --- a/cocos2dx/label_nodes/CCLabel.cpp +++ b/cocos2dx/label_nodes/CCLabel.cpp @@ -444,7 +444,7 @@ Sprite * Label::getSprite() { if (_spriteArrayCache.count()) { - Sprite *retSprite = (Sprite *) _spriteArrayCache.lastObject(); + Sprite *retSprite = (Sprite *) _spriteArrayCache.getLastObject(); _spriteArrayCache.removeLastObject(); return retSprite; } diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp index e9f968f54a..8416ae57f1 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp @@ -1088,7 +1088,7 @@ bool LayerMultiplex::initWithLayers(Layer *layer, va_list params) } _enabledLayer = 0; - this->addChild((Node*)_layers->objectAtIndex(_enabledLayer)); + this->addChild((Node*)_layers->getObjectAtIndex(_enabledLayer)); return true; } @@ -1104,7 +1104,7 @@ bool LayerMultiplex::initWithArray(Array* arrayOfLayers) _layers->retain(); _enabledLayer = 0; - this->addChild((Node*)_layers->objectAtIndex(_enabledLayer)); + this->addChild((Node*)_layers->getObjectAtIndex(_enabledLayer)); return true; } return false; @@ -1114,25 +1114,25 @@ void LayerMultiplex::switchTo(unsigned int n) { CCASSERT( n < _layers->count(), "Invalid index in MultiplexLayer switchTo message" ); - this->removeChild((Node*)_layers->objectAtIndex(_enabledLayer), true); + this->removeChild((Node*)_layers->getObjectAtIndex(_enabledLayer), true); _enabledLayer = n; - this->addChild((Node*)_layers->objectAtIndex(n)); + this->addChild((Node*)_layers->getObjectAtIndex(n)); } void LayerMultiplex::switchToAndReleaseMe(unsigned int n) { CCASSERT( n < _layers->count(), "Invalid index in MultiplexLayer switchTo message" ); - this->removeChild((Node*)_layers->objectAtIndex(_enabledLayer), true); + this->removeChild((Node*)_layers->getObjectAtIndex(_enabledLayer), true); //[layers replaceObjectAtIndex:enabledLayer withObject:[NSNull null]]; _layers->replaceObjectAtIndex(_enabledLayer, NULL); _enabledLayer = n; - this->addChild((Node*)_layers->objectAtIndex(n)); + this->addChild((Node*)_layers->getObjectAtIndex(n)); } NS_CC_END diff --git a/cocos2dx/menu_nodes/CCMenuItem.cpp b/cocos2dx/menu_nodes/CCMenuItem.cpp index 37747938e9..5542d58282 100644 --- a/cocos2dx/menu_nodes/CCMenuItem.cpp +++ b/cocos2dx/menu_nodes/CCMenuItem.cpp @@ -808,7 +808,7 @@ MenuItemToggle * MenuItemToggle::createWithTarget(Object* target, SEL_MenuHandle for (unsigned int z=0; z < menuItems->count(); z++) { - MenuItem* menuItem = (MenuItem*)menuItems->objectAtIndex(z); + MenuItem* menuItem = (MenuItem*)menuItems->getObjectAtIndex(z); pRet->_subItems->addObject(menuItem); } @@ -826,7 +826,7 @@ MenuItemToggle * MenuItemToggle::createWithCallback(const ccMenuCallback &callba for (unsigned int z=0; z < menuItems->count(); z++) { - MenuItem* menuItem = (MenuItem*)menuItems->objectAtIndex(z); + MenuItem* menuItem = (MenuItem*)menuItems->getObjectAtIndex(z); pRet->_subItems->addObject(menuItem); } @@ -939,7 +939,7 @@ void MenuItemToggle::setSelectedIndex(unsigned int index) currentItem->removeFromParentAndCleanup(false); } - MenuItem* item = (MenuItem*)_subItems->objectAtIndex(_selectedIndex); + MenuItem* item = (MenuItem*)_subItems->getObjectAtIndex(_selectedIndex); this->addChild(item, 0, kCurrentItem); Size s = item->getContentSize(); this->setContentSize(s); @@ -950,13 +950,13 @@ void MenuItemToggle::setSelectedIndex(unsigned int index) void MenuItemToggle::selected() { MenuItem::selected(); - static_cast(_subItems->objectAtIndex(_selectedIndex))->selected(); + static_cast(_subItems->getObjectAtIndex(_selectedIndex))->selected(); } void MenuItemToggle::unselected() { MenuItem::unselected(); - static_cast(_subItems->objectAtIndex(_selectedIndex))->unselected(); + static_cast(_subItems->getObjectAtIndex(_selectedIndex))->unselected(); } void MenuItemToggle::activate() @@ -989,7 +989,7 @@ void MenuItemToggle::setEnabled(bool enabled) MenuItem* MenuItemToggle::getSelectedItem() { - return static_cast(_subItems->objectAtIndex(_selectedIndex)); + return static_cast(_subItems->getObjectAtIndex(_selectedIndex)); } NS_CC_END diff --git a/cocos2dx/particle_nodes/CCParticleBatchNode.cpp b/cocos2dx/particle_nodes/CCParticleBatchNode.cpp index deb3a8f401..88c904539f 100644 --- a/cocos2dx/particle_nodes/CCParticleBatchNode.cpp +++ b/cocos2dx/particle_nodes/CCParticleBatchNode.cpp @@ -186,7 +186,7 @@ void ParticleBatchNode::addChild(Node * aChild, int zOrder, int tag) if (pos != 0) { - ParticleSystem* p = (ParticleSystem*)_children->objectAtIndex(pos-1); + ParticleSystem* p = (ParticleSystem*)_children->getObjectAtIndex(pos-1); atlasIndex = p->getAtlasIndex() + p->getTotalParticles(); } @@ -274,7 +274,7 @@ void ParticleBatchNode::reorderChild(Node * aChild, int zOrder) int newAtlasIndex = 0; for( unsigned int i=0;i < _children->count();i++) { - ParticleSystem* pNode = (ParticleSystem*)_children->objectAtIndex(i); + ParticleSystem* pNode = (ParticleSystem*)_children->getObjectAtIndex(i); if( pNode == child ) { newAtlasIndex = child->getAtlasIndex(); @@ -302,7 +302,7 @@ void ParticleBatchNode::getCurrentIndex(unsigned int* oldIndex, unsigned int* ne for( unsigned int i=0; i < count; i++ ) { - Node* pNode = (Node *)_children->objectAtIndex(i); + Node* pNode = (Node *)_children->getObjectAtIndex(i); // new index if( pNode->getZOrder() > z && ! foundNewIdx ) @@ -349,7 +349,7 @@ unsigned int ParticleBatchNode::searchNewPositionInChildrenForZ(int z) for( unsigned int i=0; i < count; i++ ) { - Node *child = (Node *)_children->objectAtIndex(i); + Node *child = (Node *)_children->getObjectAtIndex(i); if (child->getZOrder() > z) { return i; @@ -385,7 +385,7 @@ void ParticleBatchNode::removeChild(Node* aChild, bool cleanup) void ParticleBatchNode::removeChildAtIndex(unsigned int index, bool doCleanup) { - removeChild((ParticleSystem *)_children->objectAtIndex(index),doCleanup); + removeChild((ParticleSystem *)_children->getObjectAtIndex(index),doCleanup); } void ParticleBatchNode::removeAllChildrenWithCleanup(bool doCleanup) diff --git a/cocos2dx/sprite_nodes/CCSprite.cpp b/cocos2dx/sprite_nodes/CCSprite.cpp index be7447fc4b..5d4859c34e 100644 --- a/cocos2dx/sprite_nodes/CCSprite.cpp +++ b/cocos2dx/sprite_nodes/CCSprite.cpp @@ -989,7 +989,7 @@ void Sprite::setDisplayFrameWithAnimationName(const char *animationName, int fra CCASSERT(a, "CCSprite#setDisplayFrameWithAnimationName: Frame not found"); - AnimationFrame* frame = static_cast( a->getFrames()->objectAtIndex(frameIndex) ); + AnimationFrame* frame = static_cast( a->getFrames()->getObjectAtIndex(frameIndex) ); CCASSERT(frame, "CCSprite#setDisplayFrame. Invalid frame"); diff --git a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp index a79feb2402..de63c8f81b 100644 --- a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp @@ -226,7 +226,7 @@ void SpriteBatchNode::removeChild(Node *child, bool cleanup) void SpriteBatchNode::removeChildAtIndex(unsigned int uIndex, bool bDoCleanup) { - removeChild((Sprite*)(_children->objectAtIndex(uIndex)), bDoCleanup); + removeChild((Sprite*)(_children->getObjectAtIndex(uIndex)), bDoCleanup); } void SpriteBatchNode::removeAllChildrenWithCleanup(bool bCleanup) @@ -470,7 +470,7 @@ unsigned int SpriteBatchNode::highestAtlasIndexInChild(Sprite *pSprite) } else { - return highestAtlasIndexInChild((Sprite*)(children->lastObject())); + return highestAtlasIndexInChild((Sprite*)(children->getLastObject())); } } @@ -484,14 +484,14 @@ unsigned int SpriteBatchNode::lowestAtlasIndexInChild(Sprite *pSprite) } else { - return lowestAtlasIndexInChild((Sprite*)(children->objectAtIndex(0))); + return lowestAtlasIndexInChild((Sprite*)(children->getObjectAtIndex(0))); } } unsigned int SpriteBatchNode::atlasIndexForChild(Sprite *sprite, int nZ) { Array *pBrothers = sprite->getParent()->getChildren(); - unsigned int uChildIndex = pBrothers->indexOfObject(sprite); + unsigned int uChildIndex = pBrothers->getIndexOfObject(sprite); // ignore parent Z if parent is spriteSheet bool bIgnoreParent = (SpriteBatchNode*)(sprite->getParent()) == this; @@ -499,7 +499,7 @@ unsigned int SpriteBatchNode::atlasIndexForChild(Sprite *sprite, int nZ) if (uChildIndex > 0 && uChildIndex < UINT_MAX) { - pPrevious = (Sprite*)(pBrothers->objectAtIndex(uChildIndex - 1)); + pPrevious = (Sprite*)(pBrothers->getObjectAtIndex(uChildIndex - 1)); } // first child of the sprite sheet @@ -622,7 +622,7 @@ void SpriteBatchNode::removeSpriteFromAtlas(Sprite *sprite) // Cleanup sprite. It might be reused (issue #569) sprite->setBatchNode(NULL); - unsigned int uIndex = _descendants->indexOfObject(sprite); + unsigned int uIndex = _descendants->getIndexOfObject(sprite); if (uIndex != UINT_MAX) { _descendants->removeObjectAtIndex(uIndex); @@ -632,7 +632,7 @@ void SpriteBatchNode::removeSpriteFromAtlas(Sprite *sprite) for(; uIndex < count; ++uIndex) { - Sprite* s = (Sprite*)(_descendants->objectAtIndex(uIndex)); + Sprite* s = (Sprite*)(_descendants->getObjectAtIndex(uIndex)); s->setAtlasIndex( s->getAtlasIndex() - 1 ); } } diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp b/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp index f1f3bc7f14..940b3557e6 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp @@ -332,7 +332,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) { if (pTMXMapInfo->getParentElement() == TMXPropertyLayer) { - TMXLayerInfo* layer = (TMXLayerInfo*)pTMXMapInfo->getLayers()->lastObject(); + TMXLayerInfo* layer = (TMXLayerInfo*)pTMXMapInfo->getLayers()->getLastObject(); Size layerSize = layer->_layerSize; unsigned int gid = (unsigned int)atoi(valueForKey("gid", attributeDict)); int tilesAmount = layerSize.width*layerSize.height; @@ -366,7 +366,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) } else { - TMXTilesetInfo* info = (TMXTilesetInfo*)pTMXMapInfo->getTilesets()->lastObject(); + TMXTilesetInfo* info = (TMXTilesetInfo*)pTMXMapInfo->getTilesets()->getLastObject(); Dictionary *dict = new Dictionary(); pTMXMapInfo->setParentGID(info->_firstGid + atoi(valueForKey("id", attributeDict))); pTMXMapInfo->getTileProperties()->setObject(dict, pTMXMapInfo->getParentGID()); @@ -427,7 +427,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) } else if (elementName == "image") { - TMXTilesetInfo* tileset = (TMXTilesetInfo*)pTMXMapInfo->getTilesets()->lastObject(); + TMXTilesetInfo* tileset = (TMXTilesetInfo*)pTMXMapInfo->getTilesets()->getLastObject(); // build full path std::string imagename = valueForKey("source", attributeDict); @@ -451,7 +451,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) { pTMXMapInfo->setLayerAttribs(pTMXMapInfo->getLayerAttribs() | TMXLayerAttribNone); - TMXLayerInfo* layer = (TMXLayerInfo*)pTMXMapInfo->getLayers()->lastObject(); + TMXLayerInfo* layer = (TMXLayerInfo*)pTMXMapInfo->getLayers()->getLastObject(); Size layerSize = layer->_layerSize; int tilesAmount = layerSize.width*layerSize.height; @@ -497,7 +497,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) else if (elementName == "object") { char buffer[32] = {0}; - TMXObjectGroup* objectGroup = (TMXObjectGroup*)pTMXMapInfo->getObjectGroups()->lastObject(); + TMXObjectGroup* objectGroup = (TMXObjectGroup*)pTMXMapInfo->getObjectGroups()->getLastObject(); // The value for "type" was blank or not a valid class name // Create an instance of TMXObjectInfo to store the object and its properties @@ -569,7 +569,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) else if ( pTMXMapInfo->getParentElement() == TMXPropertyLayer ) { // The parent element is the last layer - TMXLayerInfo* layer = (TMXLayerInfo*)pTMXMapInfo->getLayers()->lastObject(); + TMXLayerInfo* layer = (TMXLayerInfo*)pTMXMapInfo->getLayers()->getLastObject(); String *value = new String(valueForKey("value", attributeDict)); std::string key = valueForKey("name", attributeDict); // Add the property to the layer @@ -580,7 +580,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) else if ( pTMXMapInfo->getParentElement() == TMXPropertyObjectGroup ) { // The parent element is the last object group - TMXObjectGroup* objectGroup = (TMXObjectGroup*)pTMXMapInfo->getObjectGroups()->lastObject(); + TMXObjectGroup* objectGroup = (TMXObjectGroup*)pTMXMapInfo->getObjectGroups()->getLastObject(); String *value = new String(valueForKey("value", attributeDict)); const char* key = valueForKey("name", attributeDict); objectGroup->getProperties()->setObject(value, key); @@ -590,8 +590,8 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) else if ( pTMXMapInfo->getParentElement() == TMXPropertyObject ) { // The parent element is the last object - TMXObjectGroup* objectGroup = (TMXObjectGroup*)pTMXMapInfo->getObjectGroups()->lastObject(); - Dictionary* dict = (Dictionary*)objectGroup->getObjects()->lastObject(); + TMXObjectGroup* objectGroup = (TMXObjectGroup*)pTMXMapInfo->getObjectGroups()->getLastObject(); + Dictionary* dict = (Dictionary*)objectGroup->getObjects()->getLastObject(); const char* propertyName = valueForKey("name", attributeDict); String *propertyValue = new String(valueForKey("value", attributeDict)); @@ -611,8 +611,8 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) else if (elementName == "polygon") { // find parent object's dict and add polygon-points to it - TMXObjectGroup* objectGroup = (TMXObjectGroup*)_objectGroups->lastObject(); - Dictionary* dict = (Dictionary*)objectGroup->getObjects()->lastObject(); + TMXObjectGroup* objectGroup = (TMXObjectGroup*)_objectGroups->getLastObject(); + Dictionary* dict = (Dictionary*)objectGroup->getObjects()->getLastObject(); // get points value string const char* value = valueForKey("points", attributeDict); @@ -690,7 +690,7 @@ void TMXMapInfo::endElement(void *ctx, const char *name) { pTMXMapInfo->setStoringCharacters(false); - TMXLayerInfo* layer = (TMXLayerInfo*)pTMXMapInfo->getLayers()->lastObject(); + TMXLayerInfo* layer = (TMXLayerInfo*)pTMXMapInfo->getLayers()->getLastObject(); std::string currentString = pTMXMapInfo->getCurrentString(); unsigned char *buffer; @@ -733,7 +733,7 @@ void TMXMapInfo::endElement(void *ctx, const char *name) } else if (pTMXMapInfo->getLayerAttribs() & TMXLayerAttribNone) { - TMXLayerInfo* layer = (TMXLayerInfo*)pTMXMapInfo->getLayers()->lastObject(); + TMXLayerInfo* layer = (TMXLayerInfo*)pTMXMapInfo->getLayers()->getLastObject(); Size layerSize = layer->_layerSize; int tilesAmount = layerSize.width * layerSize.height; diff --git a/extensions/CCArmature/CCBone.cpp b/extensions/CCArmature/CCBone.cpp index ea0c8dca29..4361339ed9 100644 --- a/extensions/CCArmature/CCBone.cpp +++ b/extensions/CCArmature/CCBone.cpp @@ -230,7 +230,7 @@ void Bone::addChildBone(Bone *child) childrenAlloc(); } - if (_children->indexOfObject(child) == UINT_MAX) + if (_children->getIndexOfObject(child) == UINT_MAX) { _children->addObject(child); child->setParentBone(this); @@ -239,7 +239,7 @@ void Bone::addChildBone(Bone *child) void Bone::removeChildBone(Bone *bone, bool recursion) { - if ( _children->indexOfObject(bone) != UINT_MAX ) + if ( _children->getIndexOfObject(bone) != UINT_MAX ) { if(recursion) { diff --git a/extensions/CCArmature/datas/CCDatas.cpp b/extensions/CCArmature/datas/CCDatas.cpp index 9966d9fbe0..ba50cb80d0 100644 --- a/extensions/CCArmature/datas/CCDatas.cpp +++ b/extensions/CCArmature/datas/CCDatas.cpp @@ -224,7 +224,7 @@ void BoneData::addDisplayData(DisplayData *displayData) DisplayData *BoneData::getDisplayData(int index) { - return (DisplayData *)displayDataList.objectAtIndex(index); + return (DisplayData *)displayDataList.getObjectAtIndex(index); } ArmatureData::ArmatureData() @@ -301,7 +301,7 @@ void MovementBoneData::addFrameData(FrameData *frameData) FrameData *MovementBoneData::getFrameData(int index) { - return (FrameData *)frameList.objectAtIndex(index); + return (FrameData *)frameList.getObjectAtIndex(index); } @@ -406,7 +406,7 @@ void TextureData::addContourData(ContourData *contourData) ContourData *TextureData::getContourData(int index) { - return (ContourData *)contourDataList.objectAtIndex(index); + return (ContourData *)contourDataList.getObjectAtIndex(index); } diff --git a/extensions/CCArmature/display/CCDisplayManager.cpp b/extensions/CCArmature/display/CCDisplayManager.cpp index 7fd43f82c8..3fa223629a 100644 --- a/extensions/CCArmature/display/CCDisplayManager.cpp +++ b/extensions/CCArmature/display/CCDisplayManager.cpp @@ -92,7 +92,7 @@ void DisplayManager::addDisplay(DisplayData *displayData, int index) if(index >= 0 && (unsigned int)index < _decoDisplayList->count()) { - decoDisplay = (DecorativeDisplay *)_decoDisplayList->objectAtIndex(index); + decoDisplay = (DecorativeDisplay *)_decoDisplayList->getObjectAtIndex(index); } else { @@ -145,7 +145,7 @@ void DisplayManager::changeDisplayByIndex(int index, bool force) } - DecorativeDisplay *decoDisplay = (DecorativeDisplay *)_decoDisplayList->objectAtIndex(_displayIndex); + DecorativeDisplay *decoDisplay = (DecorativeDisplay *)_decoDisplayList->getObjectAtIndex(_displayIndex); setCurrentDecorativeDisplay(decoDisplay); } @@ -210,7 +210,7 @@ DecorativeDisplay *DisplayManager::getCurrentDecorativeDisplay() DecorativeDisplay *DisplayManager::getDecorativeDisplayByIndex( int index) { - return (DecorativeDisplay *)_decoDisplayList->objectAtIndex(index); + return (DecorativeDisplay *)_decoDisplayList->getObjectAtIndex(index); } void DisplayManager::initDisplayList(BoneData *boneData) diff --git a/extensions/CCBReader/CCBAnimationManager.cpp b/extensions/CCBReader/CCBAnimationManager.cpp index 7b6172a3dd..da1a443a71 100644 --- a/extensions/CCBReader/CCBAnimationManager.cpp +++ b/extensions/CCBReader/CCBAnimationManager.cpp @@ -359,12 +359,12 @@ ActionInterval* CCBAnimationManager::getAction(CCBKeyframe *pKeyframe0, CCBKeyfr { // Get position type Array *array = static_cast(getBaseValue(pNode, propName)); - CCBReader::PositionType type = (CCBReader::PositionType)((CCBValue*)array->objectAtIndex(2))->getIntValue(); + CCBReader::PositionType type = (CCBReader::PositionType)((CCBValue*)array->getObjectAtIndex(2))->getIntValue(); // Get relative position Array *value = static_cast(pKeyframe1->getValue()); - float x = ((CCBValue*)value->objectAtIndex(0))->getFloatValue(); - float y = ((CCBValue*)value->objectAtIndex(1))->getFloatValue(); + float x = ((CCBValue*)value->getObjectAtIndex(0))->getFloatValue(); + float y = ((CCBValue*)value->getObjectAtIndex(1))->getFloatValue(); Size containerSize = getContainerSize(pNode->getParent()); @@ -376,12 +376,12 @@ ActionInterval* CCBAnimationManager::getAction(CCBKeyframe *pKeyframe0, CCBKeyfr { // Get position type Array *array = (Array*)getBaseValue(pNode, propName); - CCBReader::ScaleType type = (CCBReader::ScaleType)((CCBValue*)array->objectAtIndex(2))->getIntValue(); + CCBReader::ScaleType type = (CCBReader::ScaleType)((CCBValue*)array->getObjectAtIndex(2))->getIntValue(); // Get relative scale Array *value = (Array*)pKeyframe1->getValue(); - float x = ((CCBValue*)value->objectAtIndex(0))->getFloatValue(); - float y = ((CCBValue*)value->objectAtIndex(1))->getFloatValue(); + float x = ((CCBValue*)value->getObjectAtIndex(0))->getFloatValue(); + float y = ((CCBValue*)value->getObjectAtIndex(1))->getFloatValue(); if (type == CCBReader::ScaleType::MULTIPLY_RESOLUTION) { @@ -396,8 +396,8 @@ ActionInterval* CCBAnimationManager::getAction(CCBKeyframe *pKeyframe0, CCBKeyfr { // Get relative skew Array *value = (Array*)pKeyframe1->getValue(); - float x = ((CCBValue*)value->objectAtIndex(0))->getFloatValue(); - float y = ((CCBValue*)value->objectAtIndex(1))->getFloatValue(); + float x = ((CCBValue*)value->getObjectAtIndex(0))->getFloatValue(); + float y = ((CCBValue*)value->getObjectAtIndex(1))->getFloatValue(); return SkewTo::create(duration, x, y); } @@ -432,12 +432,12 @@ void CCBAnimationManager::setAnimatedProperty(const char *propName, Node *pNode, { // Get position type Array *array = (Array*)getBaseValue(pNode, propName); - CCBReader::PositionType type = (CCBReader::PositionType)((CCBValue*)array->objectAtIndex(2))->getIntValue(); + CCBReader::PositionType type = (CCBReader::PositionType)((CCBValue*)array->getObjectAtIndex(2))->getIntValue(); // Get relative position Array *value = (Array*)pValue; - float x = ((CCBValue*)value->objectAtIndex(0))->getFloatValue(); - float y = ((CCBValue*)value->objectAtIndex(1))->getFloatValue(); + float x = ((CCBValue*)value->getObjectAtIndex(0))->getFloatValue(); + float y = ((CCBValue*)value->getObjectAtIndex(1))->getFloatValue(); pNode->setPosition(getAbsolutePosition(Point(x,y), type, getContainerSize(pNode->getParent()), propName)); } @@ -445,12 +445,12 @@ void CCBAnimationManager::setAnimatedProperty(const char *propName, Node *pNode, { // Get scale type Array *array = (Array*)getBaseValue(pNode, propName); - CCBReader::ScaleType type = (CCBReader::ScaleType)((CCBValue*)array->objectAtIndex(2))->getIntValue(); + CCBReader::ScaleType type = (CCBReader::ScaleType)((CCBValue*)array->getObjectAtIndex(2))->getIntValue(); // Get relative scale Array *value = (Array*)pValue; - float x = ((CCBValue*)value->objectAtIndex(0))->getFloatValue(); - float y = ((CCBValue*)value->objectAtIndex(1))->getFloatValue(); + float x = ((CCBValue*)value->getObjectAtIndex(0))->getFloatValue(); + float y = ((CCBValue*)value->getObjectAtIndex(1))->getFloatValue(); setRelativeScale(pNode, x, y, type, propName); } @@ -458,8 +458,8 @@ void CCBAnimationManager::setAnimatedProperty(const char *propName, Node *pNode, { // Get relative scale Array *value = (Array*)pValue; - float x = ((CCBValue*)value->objectAtIndex(0))->getFloatValue(); - float y = ((CCBValue*)value->objectAtIndex(1))->getFloatValue(); + float x = ((CCBValue*)value->getObjectAtIndex(0))->getFloatValue(); + float y = ((CCBValue*)value->getObjectAtIndex(1))->getFloatValue(); pNode->setSkewX(x); pNode->setSkewY(y); @@ -524,7 +524,7 @@ void CCBAnimationManager::setFirstFrame(Node *pNode, CCBSequenceProperty *pSeqPr else { // Use first keyframe - CCBKeyframe *keyframe = (CCBKeyframe*)keyframes->objectAtIndex(0); + CCBKeyframe *keyframe = (CCBKeyframe*)keyframes->getObjectAtIndex(0); setAnimatedProperty(pSeqProp->getName(), pNode, keyframe->getValue(), fTweenDuration); } } @@ -610,7 +610,7 @@ Object* CCBAnimationManager::actionForCallbackChannel(CCBSequenceProperty* chann for (int i = 0; i < numKeyframes; ++i) { - CCBKeyframe *keyframe = (CCBKeyframe*)keyframes->objectAtIndex(i); + CCBKeyframe *keyframe = (CCBKeyframe*)keyframes->getObjectAtIndex(i); float timeSinceLastKeyframe = keyframe->getTime() - lastKeyframeTime; lastKeyframeTime = keyframe->getTime(); if(timeSinceLastKeyframe > 0) { @@ -618,8 +618,8 @@ Object* CCBAnimationManager::actionForCallbackChannel(CCBSequenceProperty* chann } Array* keyVal = static_cast(keyframe->getValue()); - std::string selectorName = static_cast(keyVal->objectAtIndex(0))->getCString(); - CCBReader::TargetType selectorTarget = (CCBReader::TargetType)atoi(static_cast(keyVal->objectAtIndex(1))->getCString()); + std::string selectorName = static_cast(keyVal->getObjectAtIndex(0))->getCString(); + CCBReader::TargetType selectorTarget = (CCBReader::TargetType)atoi(static_cast(keyVal->getObjectAtIndex(1))->getCString()); if(_jsControlled) { String* callbackName = String::createWithFormat("%d:%s", selectorTarget, selectorName.c_str()); @@ -683,7 +683,7 @@ Object* CCBAnimationManager::actionForSoundChannel(CCBSequenceProperty* channel) for (int i = 0; i < numKeyframes; ++i) { - CCBKeyframe *keyframe = (CCBKeyframe*)keyframes->objectAtIndex(i); + CCBKeyframe *keyframe = (CCBKeyframe*)keyframes->getObjectAtIndex(i); float timeSinceLastKeyframe = keyframe->getTime() - lastKeyframeTime; lastKeyframeTime = keyframe->getTime(); if(timeSinceLastKeyframe > 0) { @@ -692,18 +692,18 @@ Object* CCBAnimationManager::actionForSoundChannel(CCBSequenceProperty* channel) stringstream ss (stringstream::in | stringstream::out); Array* keyVal = (Array*)keyframe->getValue(); - std::string soundFile = ((String *)keyVal->objectAtIndex(0))->getCString(); + std::string soundFile = ((String *)keyVal->getObjectAtIndex(0))->getCString(); float pitch, pan, gain; - ss << ((String *)keyVal->objectAtIndex(1))->getCString(); + ss << ((String *)keyVal->getObjectAtIndex(1))->getCString(); ss >> pitch; ss.flush(); - ss << ((String *)keyVal->objectAtIndex(2))->getCString(); + ss << ((String *)keyVal->getObjectAtIndex(2))->getCString(); ss >> pan; ss.flush(); - ss << ((String *)keyVal->objectAtIndex(3))->getCString(); + ss << ((String *)keyVal->getObjectAtIndex(3))->getCString(); ss >> gain; ss.flush(); @@ -727,7 +727,7 @@ void CCBAnimationManager::runAction(Node *pNode, CCBSequenceProperty *pSeqProp, // Make an animation! Array *actions = Array::create(); - CCBKeyframe *keyframeFirst = (CCBKeyframe*)keyframes->objectAtIndex(0); + CCBKeyframe *keyframeFirst = (CCBKeyframe*)keyframes->getObjectAtIndex(0); float timeFirst = keyframeFirst->getTime() + fTweenDuration; if (timeFirst > 0) @@ -737,8 +737,8 @@ void CCBAnimationManager::runAction(Node *pNode, CCBSequenceProperty *pSeqProp, for (int i = 0; i < numKeyframes - 1; ++i) { - CCBKeyframe *kf0 = (CCBKeyframe*)keyframes->objectAtIndex(i); - CCBKeyframe *kf1 = (CCBKeyframe*)keyframes->objectAtIndex(i+1); + CCBKeyframe *kf0 = (CCBKeyframe*)keyframes->getObjectAtIndex(i); + CCBKeyframe *kf1 = (CCBKeyframe*)keyframes->getObjectAtIndex(i+1); ActionInterval *action = getAction(kf0, kf1, pSeqProp->getName(), pNode); if (action) diff --git a/extensions/CCBReader/CCNodeLoader.cpp b/extensions/CCBReader/CCNodeLoader.cpp index 2c6ec045f8..666286ea80 100644 --- a/extensions/CCBReader/CCNodeLoader.cpp +++ b/extensions/CCBReader/CCNodeLoader.cpp @@ -967,8 +967,8 @@ Node * NodeLoader::parsePropTypeCCBFile(Node * pNode, Node * pParent, CCBReader for (int i = 0 ; i < nCount; i++) { - pCCBReader->addOwnerCallbackName((dynamic_cast(ownerCallbackNames->objectAtIndex(i)))->getCString()); - pCCBReader->addOwnerCallbackNode(dynamic_cast(ownerCallbackNodes->objectAtIndex(i)) ); + pCCBReader->addOwnerCallbackName((dynamic_cast(ownerCallbackNames->getObjectAtIndex(i)))->getCString()); + pCCBReader->addOwnerCallbackNode(dynamic_cast(ownerCallbackNodes->getObjectAtIndex(i)) ); } } //set variables @@ -982,8 +982,8 @@ Node * NodeLoader::parsePropTypeCCBFile(Node * pNode, Node * pParent, CCBReader for (int i = 0 ; i < nCount; i++) { - pCCBReader->addOwnerOutletName((static_cast(ownerOutletNames->objectAtIndex(i)))->getCString()); - pCCBReader->addOwnerOutletNode(static_cast(ownerOutletNodes->objectAtIndex(i))); + pCCBReader->addOwnerOutletName((static_cast(ownerOutletNames->getObjectAtIndex(i)))->getCString()); + pCCBReader->addOwnerOutletNode(static_cast(ownerOutletNodes->getObjectAtIndex(i))); } } } diff --git a/extensions/GUI/CCScrollView/CCScrollView.cpp b/extensions/GUI/CCScrollView/CCScrollView.cpp index 64a1766b51..11d5b7ece5 100644 --- a/extensions/GUI/CCScrollView/CCScrollView.cpp +++ b/extensions/GUI/CCScrollView/CCScrollView.cpp @@ -626,11 +626,11 @@ bool ScrollView::ccTouchBegan(Touch* touch, Event* event) } else if (_touches->count() == 2) { - _touchPoint = (this->convertTouchToNodeSpace((Touch*)_touches->objectAtIndex(0)).getMidpoint( - this->convertTouchToNodeSpace((Touch*)_touches->objectAtIndex(1)))); + _touchPoint = (this->convertTouchToNodeSpace((Touch*)_touches->getObjectAtIndex(0)).getMidpoint( + this->convertTouchToNodeSpace((Touch*)_touches->getObjectAtIndex(1)))); - _touchLength = _container->convertTouchToNodeSpace((Touch*)_touches->objectAtIndex(0)).getDistance( - _container->convertTouchToNodeSpace((Touch*)_touches->objectAtIndex(1))); + _touchLength = _container->convertTouchToNodeSpace((Touch*)_touches->getObjectAtIndex(0)).getDistance( + _container->convertTouchToNodeSpace((Touch*)_touches->getObjectAtIndex(1))); _dragging = false; } @@ -654,7 +654,7 @@ void ScrollView::ccTouchMoved(Touch* touch, Event* event) frame = getViewRect(); - newPoint = this->convertTouchToNodeSpace((Touch*)_touches->objectAtIndex(0)); + newPoint = this->convertTouchToNodeSpace((Touch*)_touches->getObjectAtIndex(0)); moveDistance = newPoint - _touchPoint; float dis = 0.0f; @@ -711,8 +711,8 @@ void ScrollView::ccTouchMoved(Touch* touch, Event* event) } else if (_touches->count() == 2 && !_dragging) { - const float len = _container->convertTouchToNodeSpace((Touch*)_touches->objectAtIndex(0)).getDistance( - _container->convertTouchToNodeSpace((Touch*)_touches->objectAtIndex(1))); + const float len = _container->convertTouchToNodeSpace((Touch*)_touches->getObjectAtIndex(0)).getDistance( + _container->convertTouchToNodeSpace((Touch*)_touches->getObjectAtIndex(1))); this->setZoomScale(this->getZoomScale()*len/_touchLength); } } diff --git a/extensions/GUI/CCScrollView/CCSorting.cpp b/extensions/GUI/CCScrollView/CCSorting.cpp index 7a82b768b4..19513d25f0 100644 --- a/extensions/GUI/CCScrollView/CCSorting.cpp +++ b/extensions/GUI/CCScrollView/CCSorting.cpp @@ -80,7 +80,7 @@ void ArrayForObjectSorting::removeSortedObject(SortableObject* object) idx = this->indexOfSortedObject(object); if (idx < this->count() && idx != CC_INVALID_INDEX) { - foundObj = dynamic_cast(this->objectAtIndex(idx)); + foundObj = dynamic_cast(this->getObjectAtIndex(idx)); if(foundObj->getObjectID() == object->getObjectID()) { this->removeObjectAtIndex(idx); @@ -96,7 +96,7 @@ void ArrayForObjectSorting::setObjectID_ofSortedObject(unsigned int tag, Sortabl idx = this->indexOfSortedObject(object); if (idx < this->count() && idx != CC_INVALID_INDEX) { - foundObj = dynamic_cast(this->objectAtIndex(idx)); + foundObj = dynamic_cast(this->getObjectAtIndex(idx)); Object* pObj = dynamic_cast(foundObj); pObj->retain(); @@ -130,7 +130,7 @@ SortableObject* ArrayForObjectSorting::objectWithObjectID(unsigned int tag) if (idx < this->count() && idx != CC_INVALID_INDEX) { - foundObj = dynamic_cast(this->objectAtIndex(idx)); + foundObj = dynamic_cast(this->getObjectAtIndex(idx)); if (foundObj->getObjectID() != tag) { foundObj = NULL; } diff --git a/extensions/GUI/CCScrollView/CCTableView.cpp b/extensions/GUI/CCScrollView/CCTableView.cpp index e11d31805b..fc2b8c7925 100644 --- a/extensions/GUI/CCScrollView/CCTableView.cpp +++ b/extensions/GUI/CCScrollView/CCTableView.cpp @@ -187,7 +187,7 @@ void TableView::insertCellAtIndex(unsigned int idx) newIdx = _cellsUsed->indexOfSortedObject(cell); for (unsigned int i=newIdx; i<_cellsUsed->count(); i++) { - cell = (TableViewCell*)_cellsUsed->objectAtIndex(i); + cell = (TableViewCell*)_cellsUsed->getObjectAtIndex(i); this->_setIndexForCell(cell->getIdx()+1, cell); } } @@ -234,7 +234,7 @@ void TableView::removeCellAtIndex(unsigned int idx) // [_indices shiftIndexesStartingAtIndex:idx+1 by:-1]; for (unsigned int i=_cellsUsed->count()-1; i > newIdx; i--) { - cell = (TableViewCell*)_cellsUsed->objectAtIndex(i); + cell = (TableViewCell*)_cellsUsed->getObjectAtIndex(i); this->_setIndexForCell(cell->getIdx()-1, cell); } } @@ -246,7 +246,7 @@ TableViewCell *TableView::dequeueCell() if (_cellsFreed->count() == 0) { cell = NULL; } else { - cell = (TableViewCell*)_cellsFreed->objectAtIndex(0); + cell = (TableViewCell*)_cellsFreed->getObjectAtIndex(0); cell->retain(); _cellsFreed->removeObjectAtIndex(0); cell->autorelease(); @@ -510,7 +510,7 @@ void TableView::scrollViewDidScroll(ScrollView* view) if (_cellsUsed->count() > 0) { - TableViewCell* cell = (TableViewCell*)_cellsUsed->objectAtIndex(0); + TableViewCell* cell = (TableViewCell*)_cellsUsed->getObjectAtIndex(0); idx = cell->getIdx(); while(idx _moveCellOutOfSight(cell); if (_cellsUsed->count() > 0) { - cell = (TableViewCell*)_cellsUsed->objectAtIndex(0); + cell = (TableViewCell*)_cellsUsed->getObjectAtIndex(0); idx = cell->getIdx(); } else @@ -529,7 +529,7 @@ void TableView::scrollViewDidScroll(ScrollView* view) } if (_cellsUsed->count() > 0) { - TableViewCell *cell = (TableViewCell*)_cellsUsed->lastObject(); + TableViewCell *cell = (TableViewCell*)_cellsUsed->getLastObject(); idx = cell->getIdx(); while(idx <= maxIdx && idx > endIdx) @@ -537,7 +537,7 @@ void TableView::scrollViewDidScroll(ScrollView* view) this->_moveCellOutOfSight(cell); if (_cellsUsed->count() > 0) { - cell = (TableViewCell*)_cellsUsed->lastObject(); + cell = (TableViewCell*)_cellsUsed->getLastObject(); idx = cell->getIdx(); } diff --git a/extensions/network/HttpClient.cpp b/extensions/network/HttpClient.cpp index 17c9f2057c..025f058e99 100644 --- a/extensions/network/HttpClient.cpp +++ b/extensions/network/HttpClient.cpp @@ -114,7 +114,7 @@ static void networkThread(void) if (0 != s_requestQueue->count()) { - request = dynamic_cast(s_requestQueue->objectAtIndex(0)); + request = dynamic_cast(s_requestQueue->getObjectAtIndex(0)); s_requestQueue->removeObjectAtIndex(0); } @@ -485,7 +485,7 @@ void HttpClient::dispatchResponseCallbacks(float delta) if (s_responseQueue->count()) { - response = dynamic_cast(s_responseQueue->objectAtIndex(0)); + response = dynamic_cast(s_responseQueue->getObjectAtIndex(0)); s_responseQueue->removeObjectAtIndex(0); } diff --git a/samples/Cpp/TestCpp/Classes/ParticleTest/ParticleTest.cpp b/samples/Cpp/TestCpp/Classes/ParticleTest/ParticleTest.cpp index 54589542f8..70cfa52f94 100644 --- a/samples/Cpp/TestCpp/Classes/ParticleTest/ParticleTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ParticleTest/ParticleTest.cpp @@ -1649,7 +1649,7 @@ void AddAndDeleteParticleSystems::removeSystem(float dt) { CCLOG("remove random system"); unsigned int uRand = rand() % (nChildrenCount - 1); - _batchNode->removeChild((Node*)_batchNode->getChildren()->objectAtIndex(uRand), true); + _batchNode->removeChild((Node*)_batchNode->getChildren()->getObjectAtIndex(uRand), true); auto particleSystem = ParticleSystemQuad::create("Particles/Spiral.plist"); //add new @@ -1796,7 +1796,7 @@ void ReorderParticleSystems::onEnter() void ReorderParticleSystems::reorderSystem(float time) { - auto system = (ParticleSystem*)_batchNode->getChildren()->objectAtIndex(1); + auto system = (ParticleSystem*)_batchNode->getChildren()->getObjectAtIndex(1); _batchNode->reorderChild(system, system->getZOrder() - 1); } diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp index e9fba85928..b1e79e3912 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp @@ -445,7 +445,7 @@ void AddSpriteSheet::update(float dt) for( int i=0; i < totalToAdd;i++ ) { - batchNode->addChild((Node*) (sprites->objectAtIndex(i)), zs[i], kTagBase+i); + batchNode->addChild((Node*) (sprites->getObjectAtIndex(i)), zs[i], kTagBase+i); } batchNode->sortAllChildren(); @@ -503,7 +503,7 @@ void RemoveSpriteSheet::update(float dt) // add them with random Z (very important!) for( int i=0; i < totalToAdd;i++ ) { - batchNode->addChild((Node*) (sprites->objectAtIndex(i)), CCRANDOM_MINUS1_1() * 50, kTagBase+i); + batchNode->addChild((Node*) (sprites->getObjectAtIndex(i)), CCRANDOM_MINUS1_1() * 50, kTagBase+i); } // remove them @@ -559,7 +559,7 @@ void ReorderSpriteSheet::update(float dt) // add them with random Z (very important!) for( int i=0; i < totalToAdd;i++ ) { - batchNode->addChild((Node*) (sprites->objectAtIndex(i)), CCRANDOM_MINUS1_1() * 50, kTagBase+i); + batchNode->addChild((Node*) (sprites->getObjectAtIndex(i)), CCRANDOM_MINUS1_1() * 50, kTagBase+i); } batchNode->sortAllChildren(); @@ -569,7 +569,7 @@ void ReorderSpriteSheet::update(float dt) for( int i=0;i < totalToAdd;i++) { - auto node = (Node*) (batchNode->getChildren()->objectAtIndex(i)); + auto node = (Node*) (batchNode->getChildren()->getObjectAtIndex(i)); batchNode->reorderChild(node, CCRANDOM_MINUS1_1() * 50); } diff --git a/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id b/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id index 6dd751cebb..adcf29b25a 100644 --- a/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id +++ b/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id @@ -1 +1 @@ -6b5ddb2c8e2b4b8dea01e8ff068ff9a15795db69 \ No newline at end of file +7b8ff30c1fc482c4d7485032c73c1145a60168b4 \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Classes/TextInputTest/TextInputTest.cpp b/samples/Cpp/TestCpp/Classes/TextInputTest/TextInputTest.cpp index b373f5223f..e83c86c9cd 100644 --- a/samples/Cpp/TestCpp/Classes/TextInputTest/TextInputTest.cpp +++ b/samples/Cpp/TestCpp/Classes/TextInputTest/TextInputTest.cpp @@ -166,7 +166,7 @@ void KeyboardNotificationLayer::keyboardWillShow(IMEKeyboardNotificationInfo& in Point pos; for (int i = 0; i < count; ++i) { - node = (Node*)children->objectAtIndex(i); + node = (Node*)children->getObjectAtIndex(i); pos = node->getPosition(); pos.y += adjustVert; node->setPosition(pos); diff --git a/scripting/javascript/bindings/ScriptingCore.cpp b/scripting/javascript/bindings/ScriptingCore.cpp index 33d403fdfa..bac1593fe1 100644 --- a/scripting/javascript/bindings/ScriptingCore.cpp +++ b/scripting/javascript/bindings/ScriptingCore.cpp @@ -722,8 +722,8 @@ void ScriptingCore::pauseSchedulesAndActions(js_proxy_t* p) Node* node = (Node*)p->ptr; for(unsigned int i = 0; i < arr->count(); ++i) { - if (arr->objectAtIndex(i)) { - node->getScheduler()->pauseTarget(arr->objectAtIndex(i)); + if (arr->getObjectAtIndex(i)) { + node->getScheduler()->pauseTarget(arr->getObjectAtIndex(i)); } } } @@ -736,8 +736,8 @@ void ScriptingCore::resumeSchedulesAndActions(js_proxy_t* p) Node* node = (Node*)p->ptr; for(unsigned int i = 0; i < arr->count(); ++i) { - if (!arr->objectAtIndex(i)) continue; - node->getScheduler()->resumeTarget(arr->objectAtIndex(i)); + if (!arr->getObjectAtIndex(i)) continue; + node->getScheduler()->resumeTarget(arr->getObjectAtIndex(i)); } } diff --git a/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id b/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id index 6655e24fb3..75e13bfb22 100644 --- a/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id +++ b/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id @@ -1 +1 @@ -d17c1939227c62cebcc30a071cf81b12bfa08db3 \ No newline at end of file +c89d590602b0d7e1d6a9f556da352dd33af7ea72 \ No newline at end of file From f0a2f6cbf898da537ab605559c4e4078731101bf Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Wed, 21 Aug 2013 20:02:50 -0700 Subject: [PATCH 061/126] purge profiler data one + or - is pressed Signed-off-by: Ricardo Quesada --- .../Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp index e9fba85928..0ad855b9c0 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp @@ -140,6 +140,8 @@ void NodeChildrenMainScene::initWithQuantityOfNodes(unsigned int nNodes) updateQuantityLabel(); updateQuantityOfNodes(); + + CC_PROFILER_PURGE_ALL(); }); decrease->setColor(Color3B(0,200,20)); auto increase = MenuItemFont::create(" + ", [&](Object *sender) { @@ -149,6 +151,8 @@ void NodeChildrenMainScene::initWithQuantityOfNodes(unsigned int nNodes) updateQuantityLabel(); updateQuantityOfNodes(); + + CC_PROFILER_PURGE_ALL(); }); increase->setColor(Color3B(0,200,20)); From 4dc18029b78cb696381cc1e4d9158ec995953fee Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Wed, 21 Aug 2013 20:03:45 -0700 Subject: [PATCH 062/126] Removed Iterator class There is no need to implement `Array::Iterator`. It is replaced by returning `end()` and `begin()` Signed-off-by: Ricardo Quesada --- cocos2dx/cocoa/CCArray.h | 47 +++++----------------------------------- 1 file changed, 6 insertions(+), 41 deletions(-) diff --git a/cocos2dx/cocoa/CCArray.h b/cocos2dx/cocoa/CCArray.h index aba86abb54..a7584c2326 100644 --- a/cocos2dx/cocoa/CCArray.h +++ b/cocos2dx/cocoa/CCArray.h @@ -397,53 +397,18 @@ public: const_iterator cbegin() { return data.cbegin(); } const_iterator cend() { return data.cend(); } -#else - class ArrayIterator : public std::iterator - { - public: - ArrayIterator(int index, Array *array) : _index(index), _parent(array) {} - ArrayIterator(const ArrayIterator& arrayIterator) : _index(arrayIterator._index), _parent(arrayIterator._parent) {} - - ArrayIterator& operator++() - { - ++_index; - return *this; - } - ArrayIterator operator++(int dummy) - { - ArrayIterator tmp(*this); - (*this)++; - return tmp; - } - bool operator==(const ArrayIterator& rhs) { return _index == rhs._index; } - bool operator!=(const ArrayIterator& rhs) { return _index != rhs._index; } - Object* operator*() { return _parent->getObjectAtIndex(_index); } - Object* operator->() { return _parent->getObjectAtIndex(_index); } - - private: - int _index; - Array *_parent; - }; - - // functions for range-based loop - typedef ArrayIterator iterator; - typedef ArrayIterator const_iterator; - iterator begin(); - iterator end(); - -#endif - - - -public: -#if CC_USE_ARRAY_VECTOR std::vector> data; + #else + Object** begin() { return &data->arr[0]; } + Object** end() { return &data->arr[data->num]; } + ccArray* data; + #endif +//protected: Array(); - Array(unsigned int capacity); }; // end of data_structure group From 967eb4b08fd159533d21e8be6594ee527121d41b Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Wed, 21 Aug 2013 20:04:30 -0700 Subject: [PATCH 063/126] Adds more asserts The instance methods cannot be used if the instance was not `init()` Signed-off-by: Ricardo Quesada --- cocos2dx/cocoa/CCArray.cpp | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/cocos2dx/cocoa/CCArray.cpp b/cocos2dx/cocoa/CCArray.cpp index 114fc1b7ec..b5d9755450 100644 --- a/cocos2dx/cocoa/CCArray.cpp +++ b/cocos2dx/cocoa/CCArray.cpp @@ -360,6 +360,7 @@ void Array::reduceMemoryFootprint() Array::~Array() { + CCLOGINFO("deallocing Array: %p - len: %d", this, count() ); } Array* Array::clone() const @@ -407,12 +408,6 @@ Array::Array() // init(); } -Array::Array(unsigned int capacity) -: data(NULL) -{ - initWithCapacity(capacity); -} - Array* Array::create() { Array* array = new Array(); @@ -622,16 +617,19 @@ bool Array::isEqualToArray(Array* otherArray) void Array::addObject(Object* object) { + CCASSERT(data, "Array not initialized"); ccArrayAppendObjectWithResize(data, object); } void Array::addObjectsFromArray(Array* otherArray) { + CCASSERT(data, "Array not initialized"); ccArrayAppendArrayWithResize(data, otherArray->data); } void Array::insertObject(Object* object, int index) { + CCASSERT(data, "Array not initialized"); ccArrayInsertObjectAtIndex(data, object, index); } @@ -733,6 +731,8 @@ void Array::reduceMemoryFootprint() Array::~Array() { + CCLOGINFO("deallocing Array: %p - len: %d", this, count() ); + ccArrayFree(data); } @@ -769,16 +769,6 @@ void Array::acceptVisitor(DataVisitor &visitor) visitor.visit(this); } -Array::iterator Array::begin() -{ - return Array::ArrayIterator(0, this); -} - -Array::iterator Array::end() -{ - return Array::ArrayIterator(count(), this); -} - #endif // uses ccArray NS_CC_END From 4104cdc20e9c43020b36aef4d8f6591a77e20ec1 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Wed, 21 Aug 2013 20:05:06 -0700 Subject: [PATCH 064/126] Better destructors logs Signed-off-by: Ricardo Quesada --- cocos2dx/CCDirector.cpp | 2 +- cocos2dx/actions/CCAction.cpp | 2 +- cocos2dx/actions/CCActionCatmullRom.cpp | 2 + cocos2dx/actions/CCActionManager.cpp | 2 +- cocos2dx/base_nodes/CCNode.cpp | 2 +- cocos2dx/cocoa/CCAutoreleasePool.cpp | 2 + cocos2dx/cocoa/CCData.cpp | 26 ++++++++++++ cocos2dx/cocoa/CCData.h | 23 +++++++++++ cocos2dx/cocoa/CCDictionary.cpp | 3 +- cocos2dx/cocoa/CCInteger.h | 40 ++++++++++++++++--- cocos2dx/cocoa/CCString.cpp | 28 ++++++++++++- cocos2dx/effects/CCGrabber.cpp | 2 +- cocos2dx/effects/CCGrid.cpp | 2 +- cocos2dx/label_nodes/CCLabelBMFont.cpp | 2 +- cocos2dx/platform/ios/CCES2Renderer.m | 3 +- cocos2dx/platform/mac/CCDirectorCaller.mm | 2 +- cocos2dx/platform/mac/CCEGLView.mm | 2 +- cocos2dx/platform/mac/EAGLView.mm | 2 +- cocos2dx/shaders/CCGLProgram.cpp | 2 +- cocos2dx/sprite_nodes/CCAnimation.cpp | 4 +- cocos2dx/sprite_nodes/CCSpriteFrame.cpp | 2 +- cocos2dx/textures/CCTexture2D.cpp | 2 +- cocos2dx/textures/CCTextureAtlas.cpp | 2 +- .../tilemap_parallax_nodes/CCTMXXMLParser.cpp | 2 +- .../external_tool/CCTexture2DMutable.cpp | 2 +- 25 files changed, 136 insertions(+), 27 deletions(-) diff --git a/cocos2dx/CCDirector.cpp b/cocos2dx/CCDirector.cpp index 4de921cdd8..f2604b8989 100644 --- a/cocos2dx/CCDirector.cpp +++ b/cocos2dx/CCDirector.cpp @@ -168,7 +168,7 @@ bool Director::init(void) Director::~Director(void) { - CCLOG("cocos2d: deallocing Director %p", this); + CCLOGINFO("deallocing Director: %p", this); CC_SAFE_RELEASE(_FPSLabel); CC_SAFE_RELEASE(_SPFLabel); diff --git a/cocos2dx/actions/CCAction.cpp b/cocos2dx/actions/CCAction.cpp index f94e25bf0b..78b60dafae 100644 --- a/cocos2dx/actions/CCAction.cpp +++ b/cocos2dx/actions/CCAction.cpp @@ -43,7 +43,7 @@ Action::Action() Action::~Action() { - CCLOGINFO("cocos2d: deallocing"); + CCLOGINFO("deallocing Action: %p - tag: %i", this, _tag); } const char* Action::description() const diff --git a/cocos2dx/actions/CCActionCatmullRom.cpp b/cocos2dx/actions/CCActionCatmullRom.cpp index c00da9adab..d36a568c0d 100644 --- a/cocos2dx/actions/CCActionCatmullRom.cpp +++ b/cocos2dx/actions/CCActionCatmullRom.cpp @@ -89,6 +89,8 @@ PointArray* PointArray::clone() const PointArray::~PointArray() { + CCLOGINFO("deallocing PointArray: %p", this); + vector::iterator iter; for (iter = _controlPoints->begin(); iter != _controlPoints->end(); ++iter) { diff --git a/cocos2dx/actions/CCActionManager.cpp b/cocos2dx/actions/CCActionManager.cpp index d3b1feff7c..55e87d637b 100644 --- a/cocos2dx/actions/CCActionManager.cpp +++ b/cocos2dx/actions/CCActionManager.cpp @@ -58,7 +58,7 @@ ActionManager::ActionManager(void) ActionManager::~ActionManager(void) { - CCLOGINFO("cocos2d: deallocing %p", this); + CCLOGINFO("deallocing ActionManager: %p", this); removeAllActions(); } diff --git a/cocos2dx/base_nodes/CCNode.cpp b/cocos2dx/base_nodes/CCNode.cpp index 5a13af9c15..86aa58849d 100644 --- a/cocos2dx/base_nodes/CCNode.cpp +++ b/cocos2dx/base_nodes/CCNode.cpp @@ -105,7 +105,7 @@ Node::Node(void) Node::~Node() { - CCLOGINFO( "cocos2d: deallocing: %p", this ); + CCLOGINFO( "deallocing Node: %p - tag: %i", this, _tag ); if (_updateScriptHandler) { diff --git a/cocos2dx/cocoa/CCAutoreleasePool.cpp b/cocos2dx/cocoa/CCAutoreleasePool.cpp index fba96dced5..3c4bb25cb7 100644 --- a/cocos2dx/cocoa/CCAutoreleasePool.cpp +++ b/cocos2dx/cocoa/CCAutoreleasePool.cpp @@ -36,6 +36,7 @@ AutoreleasePool::AutoreleasePool() AutoreleasePool::~AutoreleasePool() { + CCLOGINFO("deallocing AutoreleasePool: %p", this); CC_SAFE_DELETE(_managedObjectArray); } @@ -113,6 +114,7 @@ PoolManager::PoolManager() PoolManager::~PoolManager() { + CCLOGINFO("deallocing PoolManager: %p", this); finalize(); // we only release the last autorelease pool here diff --git a/cocos2dx/cocoa/CCData.cpp b/cocos2dx/cocoa/CCData.cpp index ef262a60f9..1c42a12ee5 100644 --- a/cocos2dx/cocoa/CCData.cpp +++ b/cocos2dx/cocoa/CCData.cpp @@ -1,5 +1,30 @@ +/**************************************************************************** + Copyright (c) 2010-2012 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + #include #include "CCData.h" +#include "platform/CCCommon.h" NS_CC_BEGIN @@ -19,6 +44,7 @@ Data::Data(Data *pData) Data::~Data() { + CCLOGINFO("deallocing Data: %p", this); CC_SAFE_DELETE_ARRAY(_bytes); } diff --git a/cocos2dx/cocoa/CCData.h b/cocos2dx/cocoa/CCData.h index ee2be4805b..3ed90f44d5 100644 --- a/cocos2dx/cocoa/CCData.h +++ b/cocos2dx/cocoa/CCData.h @@ -1,3 +1,26 @@ +/**************************************************************************** + Copyright (c) 2010-2012 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ #ifndef __CCDATA_H__ #define __CCDATA_H__ diff --git a/cocos2dx/cocoa/CCDictionary.cpp b/cocos2dx/cocoa/CCDictionary.cpp index f7412a4fff..8a4022e691 100644 --- a/cocos2dx/cocoa/CCDictionary.cpp +++ b/cocos2dx/cocoa/CCDictionary.cpp @@ -63,7 +63,7 @@ DictElement::DictElement(intptr_t iKey, Object* pObject) DictElement::~DictElement() { - + CCLOGINFO("deallocing DictElement: %p", this); } // ----------------------------------------------------------------------- @@ -78,6 +78,7 @@ Dictionary::Dictionary() Dictionary::~Dictionary() { + CCLOGINFO("deallocing Dictionary: %p", this); removeAllObjects(); } diff --git a/cocos2dx/cocoa/CCInteger.h b/cocos2dx/cocoa/CCInteger.h index 9a80b00cff..42b1abf969 100644 --- a/cocos2dx/cocoa/CCInteger.h +++ b/cocos2dx/cocoa/CCInteger.h @@ -1,7 +1,32 @@ +/**************************************************************************** + Copyright (c) 2010-2012 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + #ifndef __CCINTEGER_H__ #define __CCINTEGER_H__ #include "CCObject.h" +#include "platform/CCCommon.h" NS_CC_BEGIN @@ -13,10 +38,6 @@ NS_CC_BEGIN class CC_DLL Integer : public Object, public Clonable { public: - Integer(int v) - : _value(v) {} - int getValue() const {return _value;} - static Integer* create(int v) { Integer* pRet = new Integer(v); @@ -24,10 +45,19 @@ public: return pRet; } + Integer(int v) + : _value(v) {} + int getValue() const {return _value;} + + virtual ~Integer() { + CCLOGINFO("deallocing ~Integer: %p", this); + } + /* override functions */ virtual void acceptVisitor(DataVisitor &visitor) { visitor.visit(this); } - Integer* clone() const + // overrides + virtual Integer* clone() const override { return Integer::create(_value); } diff --git a/cocos2dx/cocoa/CCString.cpp b/cocos2dx/cocoa/CCString.cpp index cbbb86678e..f9962b1ba4 100644 --- a/cocos2dx/cocoa/CCString.cpp +++ b/cocos2dx/cocoa/CCString.cpp @@ -1,3 +1,27 @@ +/**************************************************************************** + Copyright (c) 2010-2012 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + #include "CCString.h" #include "platform/CCFileUtils.h" #include "ccMacros.h" @@ -26,7 +50,9 @@ String::String(const String& str) {} String::~String() -{ +{ + CCLOGINFO("deallocing String: %p", this); + _string.clear(); } diff --git a/cocos2dx/effects/CCGrabber.cpp b/cocos2dx/effects/CCGrabber.cpp index 656a4ea6f8..ad07a7e99e 100644 --- a/cocos2dx/effects/CCGrabber.cpp +++ b/cocos2dx/effects/CCGrabber.cpp @@ -93,7 +93,7 @@ void Grabber::afterRender(cocos2d::Texture2D *texture) Grabber::~Grabber() { - CCLOGINFO("cocos2d: deallocing %p", this); + CCLOGINFO("deallocing Grabber: %p", this); glDeleteFramebuffers(1, &_FBO); } diff --git a/cocos2dx/effects/CCGrid.cpp b/cocos2dx/effects/CCGrid.cpp index 98ec059928..60302e0312 100644 --- a/cocos2dx/effects/CCGrid.cpp +++ b/cocos2dx/effects/CCGrid.cpp @@ -148,7 +148,7 @@ bool GridBase::initWithSize(const Size& gridSize) GridBase::~GridBase(void) { - CCLOGINFO("cocos2d: deallocing %p", this); + CCLOGINFO("deallocing GridBase: %p", this); //TODO: ? why 2.0 comments this line setActive(false); CC_SAFE_RELEASE(_texture); diff --git a/cocos2dx/label_nodes/CCLabelBMFont.cpp b/cocos2dx/label_nodes/CCLabelBMFont.cpp index a804be5474..7de42a3519 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.cpp +++ b/cocos2dx/label_nodes/CCLabelBMFont.cpp @@ -140,7 +140,7 @@ CCBMFontConfiguration::CCBMFontConfiguration() CCBMFontConfiguration::~CCBMFontConfiguration() { - CCLOGINFO( "cocos2d: deallocing CCBMFontConfiguration %p", this ); + CCLOGINFO( "deallocing CCBMFontConfiguration: %p", this ); this->purgeFontDefDictionary(); this->purgeKerningDictionary(); _atlasName.clear(); diff --git a/cocos2dx/platform/ios/CCES2Renderer.m b/cocos2dx/platform/ios/CCES2Renderer.m index 5a0ac248cb..9b8274e6b2 100644 --- a/cocos2dx/platform/ios/CCES2Renderer.m +++ b/cocos2dx/platform/ios/CCES2Renderer.m @@ -33,7 +33,6 @@ #import "CCES2Renderer.h" #import "OpenGL_Internal.h" - @implementation CCES2Renderer @synthesize context=context_; @@ -207,7 +206,7 @@ - (void)dealloc { - NSLog(@"cocos2d: deallocing %@", self); +// CCLOGINFO("deallocing CCES2Renderer: %p", self); // Tear down GL if (defaultFramebuffer_) { diff --git a/cocos2dx/platform/mac/CCDirectorCaller.mm b/cocos2dx/platform/mac/CCDirectorCaller.mm index ebb798b78d..83d9689470 100644 --- a/cocos2dx/platform/mac/CCDirectorCaller.mm +++ b/cocos2dx/platform/mac/CCDirectorCaller.mm @@ -59,7 +59,7 @@ static id s_sharedDirectorCaller; -(void) dealloc { s_sharedDirectorCaller = nil; - CCLOG("cocos2d: deallocing DirectorCaller %p", self); + CCLOGINFO("deallocing DirectorCaller: %p", self); if (displayLink) { CVDisplayLinkRelease(displayLink); } diff --git a/cocos2dx/platform/mac/CCEGLView.mm b/cocos2dx/platform/mac/CCEGLView.mm index e0cb564e8d..de2df4da85 100644 --- a/cocos2dx/platform/mac/CCEGLView.mm +++ b/cocos2dx/platform/mac/CCEGLView.mm @@ -53,7 +53,7 @@ EGLView::EGLView(void) EGLView::~EGLView(void) { - CCLOG("cocos2d: deallocing EGLView %p", this); + CCLOGINFO("deallocing EGLView: %p", this); s_sharedView = NULL; } diff --git a/cocos2dx/platform/mac/EAGLView.mm b/cocos2dx/platform/mac/EAGLView.mm index a52ec3f42f..2bc17be1f1 100644 --- a/cocos2dx/platform/mac/EAGLView.mm +++ b/cocos2dx/platform/mac/EAGLView.mm @@ -201,7 +201,7 @@ static CCEAGLView *view; - (void) dealloc { - CCLOGINFO(@"cocos2d: deallocing CCEAGLView %@", self); + CCLOGINFO("deallocing CCEAGLView: %p", self); [super dealloc]; } diff --git a/cocos2dx/shaders/CCGLProgram.cpp b/cocos2dx/shaders/CCGLProgram.cpp index 36a680b809..20d4a0899a 100644 --- a/cocos2dx/shaders/CCGLProgram.cpp +++ b/cocos2dx/shaders/CCGLProgram.cpp @@ -82,7 +82,7 @@ GLProgram::GLProgram() GLProgram::~GLProgram() { - CCLOGINFO("cocos2d: %s %d deallocing %p", __FUNCTION__, __LINE__, this); + CCLOGINFO("%s %d deallocing GLProgram: %p", __FUNCTION__, __LINE__, this); // there is no need to delete the shaders. They should have been already deleted. CCASSERT(_vertShader == 0, "Vertex Shaders should have been already deleted"); diff --git a/cocos2dx/sprite_nodes/CCAnimation.cpp b/cocos2dx/sprite_nodes/CCAnimation.cpp index 50dda491af..ea6b36a9e6 100644 --- a/cocos2dx/sprite_nodes/CCAnimation.cpp +++ b/cocos2dx/sprite_nodes/CCAnimation.cpp @@ -50,7 +50,7 @@ bool AnimationFrame::initWithSpriteFrame(SpriteFrame* spriteFrame, float delayUn AnimationFrame::~AnimationFrame() { - CCLOGINFO( "cocos2d: deallocing %p", this); + CCLOGINFO( "deallocing AnimationFrame: %p", this); CC_SAFE_RELEASE(_spriteFrame); CC_SAFE_RELEASE(_userInfo); @@ -159,7 +159,7 @@ Animation::Animation() Animation::~Animation(void) { - CCLOGINFO("cocos2d, deallocing %p", this); + CCLOGINFO("deallocing Animation: %p", this); CC_SAFE_RELEASE(_frames); } diff --git a/cocos2dx/sprite_nodes/CCSpriteFrame.cpp b/cocos2dx/sprite_nodes/CCSpriteFrame.cpp index 273c0ad59e..2bdd9b030e 100644 --- a/cocos2dx/sprite_nodes/CCSpriteFrame.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteFrame.cpp @@ -116,7 +116,7 @@ bool SpriteFrame::initWithTextureFilename(const char* filename, const Rect& rect SpriteFrame::~SpriteFrame(void) { - CCLOGINFO("cocos2d: deallocing %p", this); + CCLOGINFO("deallocing SpriteFrame: %p", this); CC_SAFE_RELEASE(_texture); } diff --git a/cocos2dx/textures/CCTexture2D.cpp b/cocos2dx/textures/CCTexture2D.cpp index 438b08cb47..19b910e10c 100644 --- a/cocos2dx/textures/CCTexture2D.cpp +++ b/cocos2dx/textures/CCTexture2D.cpp @@ -437,7 +437,7 @@ Texture2D::~Texture2D() VolatileTexture::removeTexture(this); #endif - CCLOGINFO("cocos2d: deallocing Texture2D %u.", _name); + CCLOGINFO("deallocing Texture2D: %p - id=%u", this, _name); CC_SAFE_RELEASE(_shaderProgram); if(_name) diff --git a/cocos2dx/textures/CCTextureAtlas.cpp b/cocos2dx/textures/CCTextureAtlas.cpp index f3b302bf75..239294e7a3 100644 --- a/cocos2dx/textures/CCTextureAtlas.cpp +++ b/cocos2dx/textures/CCTextureAtlas.cpp @@ -53,7 +53,7 @@ TextureAtlas::TextureAtlas() TextureAtlas::~TextureAtlas() { - CCLOGINFO("cocos2d: TextureAtlas deallocing %p.", this); + CCLOGINFO("deallocing TextureAtlas: %p", this); CC_SAFE_FREE(_quads); CC_SAFE_FREE(_indices); diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp b/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp index f1f3bc7f14..415dd8dcbb 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp @@ -93,7 +93,7 @@ TMXTilesetInfo::TMXTilesetInfo() TMXTilesetInfo::~TMXTilesetInfo() { - CCLOGINFO("cocos2d: deallocing: %p", this); + CCLOGINFO("deallocing TMXTilesetInfo: %p", this); } Rect TMXTilesetInfo::rectForGID(unsigned int gid) diff --git a/extensions/CCArmature/external_tool/CCTexture2DMutable.cpp b/extensions/CCArmature/external_tool/CCTexture2DMutable.cpp index 53a7efd747..b9cf9084b2 100644 --- a/extensions/CCArmature/external_tool/CCTexture2DMutable.cpp +++ b/extensions/CCArmature/external_tool/CCTexture2DMutable.cpp @@ -299,7 +299,7 @@ Texture2DMutable::Texture2DMutable(void) Texture2DMutable::~Texture2DMutable(void) { - CCLOGINFO("cocos2d: deallocing %p", this); + CCLOGINFO("deallocing Texture2DMutable: %p", this); CC_SAFE_DELETE(image_); From 2e221ee6cca5f6a2d7d81f1b53b6c0a4939c4229 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Wed, 21 Aug 2013 20:12:09 -0700 Subject: [PATCH 065/126] Array & Dictionary fixes In many places `Dictionary` and `Array` are not being initialized. In fact `Dictionary` doesn't have the `init()` method creating potential leaks. Also in objects like `Armature` and the new `LabelTTF`, the `Array` object is not being used a pointer. So it doesn't use the 2 phase initialization, creating potential leaks. This patch fixes all those issues. Signed-off-by: Ricardo Quesada --- cocos2dx/CCDirector.cpp | 2 +- cocos2dx/cocoa/CCDictionary.cpp | 17 +++-- cocos2dx/cocoa/CCDictionary.h | 4 +- cocos2dx/label_nodes/CCLabel.cpp | 76 +++++++++++-------- cocos2dx/label_nodes/CCLabel.h | 4 +- cocos2dx/label_nodes/CCLabelBMFont.cpp | 1 + cocos2dx/platform/CCAccelerometerDelegate.h | 2 +- cocos2dx/platform/CCImageCommon_cpp.h | 2 +- cocos2dx/platform/CCSAXParser.h | 2 +- cocos2dx/platform/CCThread.h | 2 +- cocos2dx/platform/ios/CCCommon.mm | 2 +- cocos2dx/platform/ios/CCFileUtilsIOS.mm | 4 +- cocos2dx/platform/ios/CCImage.mm | 2 +- cocos2dx/platform/mac/CCFileUtilsMac.mm | 37 ++++----- cocos2dx/shaders/CCShaderCache.cpp | 6 +- cocos2dx/sprite_nodes/CCAnimationCache.cpp | 5 +- cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp | 2 + cocos2dx/support/CCProfiling.cpp | 1 + cocos2dx/textures/CCTextureCache.cpp | 7 +- .../CCTMXObjectGroup.cpp | 3 +- .../tilemap_parallax_nodes/CCTMXXMLParser.cpp | 27 ++++--- .../tilemap_parallax_nodes/CCTileMapAtlas.cpp | 1 + .../touch_dispatcher/CCTouchDispatcher.cpp | 4 +- extensions/CCArmature/CCArmature.cpp | 15 ++-- .../animation/CCArmatureAnimation.cpp | 6 +- extensions/CCArmature/animation/CCTween.cpp | 6 +- extensions/CCArmature/datas/CCDatas.cpp | 65 +++++++++++----- extensions/CCArmature/datas/CCDatas.h | 16 ++-- .../CCArmature/display/CCDisplayFactory.cpp | 4 +- .../CCArmature/display/CCDisplayManager.cpp | 4 +- .../CCArmature/physics/CCColliderDetector.cpp | 8 +- .../utils/CCArmatureDataManager.cpp | 20 ++--- .../CCArmature/utils/CCDataReaderHelper.cpp | 6 +- .../utils/CCSpriteFrameCacheHelper.cpp | 1 + extensions/CCBReader/CCBAnimationManager.cpp | 24 ++++-- extensions/CCBReader/CCBReader.cpp | 15 ++-- extensions/CCBReader/CCBSequenceProperty.cpp | 3 +- extensions/CCBReader/CCNodeLoader.cpp | 1 + .../GUI/CCControlExtension/CCControl.cpp | 3 +- extensions/GUI/CCScrollView/CCScrollView.cpp | 6 +- extensions/network/SocketIO.cpp | 4 +- .../ComponentsTest/ProjectileController.cpp | 4 +- .../ComponentsTest/SceneController.cpp | 22 ++---- 43 files changed, 262 insertions(+), 184 deletions(-) diff --git a/cocos2dx/CCDirector.cpp b/cocos2dx/CCDirector.cpp index f2604b8989..94df1ae4f3 100644 --- a/cocos2dx/CCDirector.cpp +++ b/cocos2dx/CCDirector.cpp @@ -115,7 +115,7 @@ bool Director::init(void) _notificationNode = nullptr; _scenesStack = new Array(); - _scenesStack->init(); + _scenesStack->initWithCapacity(15); // projection delegate if "Custom" projection is used _projectionDelegate = nullptr; diff --git a/cocos2dx/cocoa/CCDictionary.cpp b/cocos2dx/cocoa/CCDictionary.cpp index 8a4022e691..96156f8c1c 100644 --- a/cocos2dx/cocoa/CCDictionary.cpp +++ b/cocos2dx/cocoa/CCDictionary.cpp @@ -359,12 +359,18 @@ Object* Dictionary::randomObject() Dictionary* Dictionary::create() { - Dictionary* pRet = new Dictionary(); - if (pRet != NULL) + Dictionary* ret = new Dictionary(); + if (ret && ret->init() ) { - pRet->autorelease(); + ret->autorelease(); } - return pRet; + return ret; +} + +bool Dictionary::init() +{ + retain(); + return true; } Dictionary* Dictionary::createWithDictionary(Dictionary* srcDict) @@ -396,8 +402,7 @@ bool Dictionary::writeToFile(const char *fullPath) Dictionary* Dictionary::clone() const { - Dictionary* newDict = new Dictionary(); - newDict->autorelease(); + Dictionary* newDict = Dictionary::create(); DictElement* element = NULL; Object* tmpObj = NULL; diff --git a/cocos2dx/cocoa/CCDictionary.h b/cocos2dx/cocoa/CCDictionary.h index c7edbad0ae..a1164ea594 100644 --- a/cocos2dx/cocoa/CCDictionary.h +++ b/cocos2dx/cocoa/CCDictionary.h @@ -172,7 +172,7 @@ public: class CC_DLL Dictionary : public Object, public Clonable { public: - /** + /** * The constructor of Dictionary. */ Dictionary(); @@ -182,6 +182,8 @@ public: */ ~Dictionary(); + /** Initializes the dictionary. It returns true if the initializations was successful. */ + bool init(); /** * Get the count of elements in Dictionary. * diff --git a/cocos2dx/label_nodes/CCLabel.cpp b/cocos2dx/label_nodes/CCLabel.cpp index 345c62c138..036996dd2c 100644 --- a/cocos2dx/label_nodes/CCLabel.cpp +++ b/cocos2dx/label_nodes/CCLabel.cpp @@ -31,13 +31,13 @@ NS_CC_BEGIN Label* Label::createWithTTF( const char* label, const char* fontFilePath, int fontSize, int lineSize, TextHAlignment alignment, GlyphCollection glyphs, const char *customGlyphs ) { - FontAtlas *tempAtlas = FontAtlasCache::getFontAtlasTTF(fontFilePath, fontSize, glyphs, customGlyphs); + FontAtlas *tmpAtlas = FontAtlasCache::getFontAtlasTTF(fontFilePath, fontSize, glyphs, customGlyphs); - if (!tempAtlas) + if (!tmpAtlas) return nullptr; // create the actual label - Label* templabel = Label::createWithAtlas(tempAtlas, alignment, lineSize); + Label* templabel = Label::createWithAtlas(tmpAtlas, alignment, lineSize); if (templabel) { @@ -53,12 +53,12 @@ Label* Label::createWithTTF( const char* label, const char* fontFilePath, int fo Label* Label::createWithBMFont( const char* label, const char* bmfontFilePath, TextHAlignment alignment, int lineSize) { - FontAtlas *tempAtlas = FontAtlasCache::getFontAtlasFNT(bmfontFilePath); + FontAtlas *tmpAtlas = FontAtlasCache::getFontAtlasFNT(bmfontFilePath); - if (!tempAtlas) + if (!tmpAtlas) return 0; - Label* templabel = Label::createWithAtlas(tempAtlas, alignment, lineSize); + Label* templabel = Label::createWithAtlas(tmpAtlas, alignment, lineSize); if (templabel) { @@ -73,9 +73,9 @@ Label* Label::createWithBMFont( const char* label, const char* bmfontFilePath, T return 0; } -Label* Label::createWithAtlas(FontAtlas *pAtlas, TextHAlignment alignment, int lineSize) +Label* Label::createWithAtlas(FontAtlas *atlas, TextHAlignment alignment, int lineSize) { - Label *ret = new Label(pAtlas, alignment); + Label *ret = new Label(atlas, alignment); if (!ret) return 0; @@ -94,24 +94,28 @@ Label* Label::createWithAtlas(FontAtlas *pAtlas, TextHAlignment alignment, int l return ret; } -Label::Label(FontAtlas *pAtlas, TextHAlignment alignment): _currentUTF8String(0), -_originalUTF8String(0), -_fontAtlas(pAtlas), -_alignment(alignment), -_lineBreakWithoutSpaces(false), -_advances(0), -_displayedColor(Color3B::WHITE), -_realColor(Color3B::WHITE), -_cascadeColorEnabled(true), -_cascadeOpacityEnabled(true), -_displayedOpacity(255), -_realOpacity(255), -_isOpacityModifyRGB(false) +Label::Label(FontAtlas *atlas, TextHAlignment alignment) +: _currentUTF8String(0) +, _originalUTF8String(0) +, _fontAtlas(atlas) +, _alignment(alignment) +, _lineBreakWithoutSpaces(false) +, _advances(0) +, _displayedColor(Color3B::WHITE) +, _realColor(Color3B::WHITE) +, _cascadeColorEnabled(true) +, _cascadeOpacityEnabled(true) +, _displayedOpacity(255) +, _realOpacity(255) +, _isOpacityModifyRGB(false) { } Label::~Label() { + CC_SAFE_RELEASE(_spriteArray); + CC_SAFE_RELEASE(_spriteArrayCache); + if (_currentUTF8String) delete [] _currentUTF8String; @@ -124,6 +128,12 @@ Label::~Label() bool Label::init() { + _spriteArray = Array::createWithCapacity(30); + _spriteArrayCache = Array::createWithCapacity(30); + + _spriteArray->retain(); + _spriteArrayCache->retain(); + return true; } @@ -253,12 +263,12 @@ void Label::alignText() void Label::hideAllLetters() { Object* Obj = NULL; - CCARRAY_FOREACH(&_spriteArray, Obj) + CCARRAY_FOREACH(_spriteArray, Obj) { ((Sprite *)Obj)->setVisible(false); } - CCARRAY_FOREACH(&_spriteArrayCache, Obj) + CCARRAY_FOREACH(_spriteArrayCache, Obj) { ((Sprite *)Obj)->setVisible(false); } @@ -431,21 +441,21 @@ Sprite * Label::updateSpriteForLetter(Sprite *spriteToUpdate, unsigned short int void Label::moveAllSpritesToCache() { Object* pObj = NULL; - CCARRAY_FOREACH(&_spriteArray, pObj) + CCARRAY_FOREACH(_spriteArray, pObj) { ((Sprite *)pObj)->removeFromParent(); - _spriteArrayCache.addObject(pObj); + _spriteArrayCache->addObject(pObj); } - _spriteArray.removeAllObjects(); + _spriteArray->removeAllObjects(); } Sprite * Label::getSprite() { - if (_spriteArrayCache.count()) + if (_spriteArrayCache->count()) { - Sprite *retSprite = (Sprite *) _spriteArrayCache.lastObject(); - _spriteArrayCache.removeLastObject(); + Sprite *retSprite = static_cast( _spriteArrayCache->lastObject() ); + _spriteArrayCache->removeLastObject(); return retSprite; } else @@ -460,7 +470,7 @@ Sprite * Label::getSprite() Sprite * Label::getSpriteChild(int ID) { Object* pObj = NULL; - CCARRAY_FOREACH(&_spriteArray, pObj) + CCARRAY_FOREACH(_spriteArray, pObj) { Sprite *pSprite = (Sprite *)pObj; if ( pSprite->getTag() == ID) @@ -471,9 +481,9 @@ Sprite * Label::getSpriteChild(int ID) return 0; } -Array * Label::getChildrenLetters() +Array* Label::getChildrenLetters() { - return &_spriteArray; + return _spriteArray; } Sprite * Label::getSpriteForChar(unsigned short int theChar, int spriteIndexHint) @@ -493,7 +503,7 @@ Sprite * Label::getSpriteForChar(unsigned short int theChar, int spriteIndexHint if (retSprite) retSprite->setTag(spriteIndexHint); - _spriteArray.addObject(retSprite); + _spriteArray->addObject(retSprite); } // the sprite is now visible diff --git a/cocos2dx/label_nodes/CCLabel.h b/cocos2dx/label_nodes/CCLabel.h index fe1d16b742..7bb14c081b 100644 --- a/cocos2dx/label_nodes/CCLabel.h +++ b/cocos2dx/label_nodes/CCLabel.h @@ -139,8 +139,8 @@ private: Sprite * getSpriteForLetter(unsigned short int newLetter); Sprite * updateSpriteForLetter(Sprite *spriteToUpdate, unsigned short int newLetter); - Array _spriteArray; - Array _spriteArrayCache; + Array * _spriteArray; + Array * _spriteArrayCache; float _commonLineHeight; bool _lineBreakWithoutSpaces; float _width; diff --git a/cocos2dx/label_nodes/CCLabelBMFont.cpp b/cocos2dx/label_nodes/CCLabelBMFont.cpp index 7de42a3519..905510525a 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.cpp +++ b/cocos2dx/label_nodes/CCLabelBMFont.cpp @@ -69,6 +69,7 @@ CCBMFontConfiguration* FNTConfigLoadFile( const char *fntFile) if( s_pConfigurations == NULL ) { s_pConfigurations = new Dictionary(); + s_pConfigurations->init(); } pRet = static_cast( s_pConfigurations->objectForKey(fntFile) ); diff --git a/cocos2dx/platform/CCAccelerometerDelegate.h b/cocos2dx/platform/CCAccelerometerDelegate.h index f0533b40e3..75333b5f29 100644 --- a/cocos2dx/platform/CCAccelerometerDelegate.h +++ b/cocos2dx/platform/CCAccelerometerDelegate.h @@ -25,7 +25,7 @@ THE SOFTWARE. #ifndef __CCACCELEROMETER_DELEGATE_H__ #define __CCACCELEROMETER_DELEGATE_H__ -#include "CCCommon.h" +#include "platform/CCCommon.h" NS_CC_BEGIN /** diff --git a/cocos2dx/platform/CCImageCommon_cpp.h b/cocos2dx/platform/CCImageCommon_cpp.h index cb4a79e349..f77ee5c352 100644 --- a/cocos2dx/platform/CCImageCommon_cpp.h +++ b/cocos2dx/platform/CCImageCommon_cpp.h @@ -51,7 +51,7 @@ extern "C" #endif #include "ccMacros.h" -#include "CCCommon.h" +#include "platform/CCCommon.h" #include "CCStdC.h" #include "CCFileUtils.h" #include "CCConfiguration.h" diff --git a/cocos2dx/platform/CCSAXParser.h b/cocos2dx/platform/CCSAXParser.h index 745fe7fd89..9888e6a16a 100644 --- a/cocos2dx/platform/CCSAXParser.h +++ b/cocos2dx/platform/CCSAXParser.h @@ -25,7 +25,7 @@ #define __CCSAXPARSER_H__ #include "CCPlatformConfig.h" -#include "CCCommon.h" +#include "platform/CCCommon.h" NS_CC_BEGIN diff --git a/cocos2dx/platform/CCThread.h b/cocos2dx/platform/CCThread.h index fa9cdb911c..1b3e9f0e29 100644 --- a/cocos2dx/platform/CCThread.h +++ b/cocos2dx/platform/CCThread.h @@ -25,7 +25,7 @@ THE SOFTWARE. #ifndef __CC_PLATFORM_THREAD_H__ #define __CC_PLATFORM_THREAD_H__ -#include "CCCommon.h" +#include "platform/CCCommon.h" #include "CCPlatformMacros.h" NS_CC_BEGIN diff --git a/cocos2dx/platform/ios/CCCommon.mm b/cocos2dx/platform/ios/CCCommon.mm index 1d029a5b3a..b99707ee7d 100644 --- a/cocos2dx/platform/ios/CCCommon.mm +++ b/cocos2dx/platform/ios/CCCommon.mm @@ -22,7 +22,7 @@ THE SOFTWARE. ****************************************************************************/ -#include "CCCommon.h" +#include "platform/CCCommon.h" #include #include diff --git a/cocos2dx/platform/ios/CCFileUtilsIOS.mm b/cocos2dx/platform/ios/CCFileUtilsIOS.mm index 519353c367..54e0045ab0 100644 --- a/cocos2dx/platform/ios/CCFileUtilsIOS.mm +++ b/cocos2dx/platform/ios/CCFileUtilsIOS.mm @@ -65,6 +65,7 @@ static void addItemToArray(id item, Array *pArray) // add dictionary value into array if ([item isKindOfClass:[NSDictionary class]]) { Dictionary* pDictItem = new Dictionary(); + pDictItem->init(); for (id subKey in [item allKeys]) { id subValue = [item objectForKey:subKey]; addValueToDict(subKey, subValue, pDictItem); @@ -130,6 +131,7 @@ static void addValueToDict(id key, id value, Dictionary* pDict) // the value is a new dictionary if ([value isKindOfClass:[NSDictionary class]]) { Dictionary* pSubDict = new Dictionary(); + pSubDict->init(); for (id subKey in [value allKeys]) { id subValue = [value objectForKey:subKey]; addValueToDict(subKey, subValue, pSubDict); @@ -314,7 +316,7 @@ Dictionary* FileUtilsIOS::createDictionaryWithContentsOfFile(const std::string& if (pDict != nil) { - Dictionary* pRet = new Dictionary(); + Dictionary* pRet = Dictionary::create(); for (id key in [pDict allKeys]) { id value = [pDict objectForKey:key]; addValueToDict(key, value, pRet); diff --git a/cocos2dx/platform/ios/CCImage.mm b/cocos2dx/platform/ios/CCImage.mm index 0f4a3ec33d..28cef6faef 100644 --- a/cocos2dx/platform/ios/CCImage.mm +++ b/cocos2dx/platform/ios/CCImage.mm @@ -25,7 +25,7 @@ THE SOFTWARE. #import "CCImage.h" #import "CCFileUtils.h" -#import "CCCommon.h" +#import "platform/CCCommon.h" #import #import diff --git a/cocos2dx/platform/mac/CCFileUtilsMac.mm b/cocos2dx/platform/mac/CCFileUtilsMac.mm index 426a42149c..6535b05119 100644 --- a/cocos2dx/platform/mac/CCFileUtilsMac.mm +++ b/cocos2dx/platform/mac/CCFileUtilsMac.mm @@ -38,13 +38,13 @@ NS_CC_BEGIN static void addValueToDict(id key, id value, Dictionary* pDict); static void addObjectToNSDict(const char*key, Object* object, NSMutableDictionary *dict); -static void addItemToArray(id item, Array *pArray) +static void addItemToArray(id item, Array *array) { // add string value into array if ([item isKindOfClass:[NSString class]]) { String* pValue = new String([item UTF8String]); - pArray->addObject(pValue); + array->addObject(pValue); pValue->release(); return; } @@ -54,7 +54,7 @@ static void addItemToArray(id item, Array *pArray) NSString* pStr = [item stringValue]; String* pValue = new String([pStr UTF8String]); - pArray->addObject(pValue); + array->addObject(pValue); pValue->release(); return; } @@ -62,24 +62,25 @@ static void addItemToArray(id item, Array *pArray) // add dictionary value into array if ([item isKindOfClass:[NSDictionary class]]) { Dictionary* pDictItem = new Dictionary(); + pDictItem->init(); for (id subKey in [item allKeys]) { id subValue = [item objectForKey:subKey]; addValueToDict(subKey, subValue, pDictItem); } - pArray->addObject(pDictItem); + array->addObject(pDictItem); pDictItem->release(); return; } // add array value into array if ([item isKindOfClass:[NSArray class]]) { - Array *pArrayItem = new Array(); - pArrayItem->init(); + Array *arrayItem = new Array(); + arrayItem->initWithCapacity( [item count] ); for (id subItem in item) { - addItemToArray(subItem, pArrayItem); + addItemToArray(subItem, arrayItem); } - pArray->addObject(pArrayItem); - pArrayItem->release(); + array->addObject(arrayItem); + arrayItem->release(); return; } } @@ -157,13 +158,13 @@ static void addValueToDict(id key, id value, Dictionary* pDict) // the value is a array if ([value isKindOfClass:[NSArray class]]) { - Array *pArray = new Array(); - pArray->init(); + Array *array = new Array(); + array->initWithCapacity([value count]); for (id item in value) { - addItemToArray(item, pArray); + addItemToArray(item, array); } - pDict->setObject(pArray, pKey.c_str()); - pArray->release(); + pDict->setObject(array, pKey.c_str()); + array->release(); return; } } @@ -304,7 +305,7 @@ Dictionary* FileUtilsMac::createDictionaryWithContentsOfFile(const std::string& NSString* pPath = [NSString stringWithUTF8String:fullPath.c_str()]; NSDictionary* pDict = [NSDictionary dictionaryWithContentsOfFile:pPath]; - Dictionary* pRet = new Dictionary(); + Dictionary* pRet = Dictionary::create(); for (id key in [pDict allKeys]) { id value = [pDict objectForKey:key]; addValueToDict(key, value, pRet); @@ -338,10 +339,10 @@ Array* FileUtilsMac::createArrayWithContentsOfFile(const std::string& filename) // fixing cannot read data using Array::createWithContentsOfFile std::string fullPath = FileUtils::getInstance()->fullPathForFilename(filename.c_str()); NSString* pPath = [NSString stringWithUTF8String:fullPath.c_str()]; - NSArray* pArray = [NSArray arrayWithContentsOfFile:pPath]; + NSArray* array = [NSArray arrayWithContentsOfFile:pPath]; - Array* pRet = new Array(); - for (id value in pArray) { + Array* pRet = Array::createWithCapacity( [array count] ); + for (id value in array) { addItemToArray(value, pRet); } diff --git a/cocos2dx/shaders/CCShaderCache.cpp b/cocos2dx/shaders/CCShaderCache.cpp index 2377cb02f0..82c20362d0 100644 --- a/cocos2dx/shaders/CCShaderCache.cpp +++ b/cocos2dx/shaders/CCShaderCache.cpp @@ -83,13 +83,15 @@ ShaderCache::ShaderCache() ShaderCache::~ShaderCache() { - CCLOGINFO("cocos2d deallocing %p", this); + CCLOGINFO("deallocing ShaderCache: %p", this); _programs->release(); } bool ShaderCache::init() { - _programs = new Dictionary(); + _programs = Dictionary::create(); + _programs->retain(); + loadDefaultShaders(); return true; } diff --git a/cocos2dx/sprite_nodes/CCAnimationCache.cpp b/cocos2dx/sprite_nodes/CCAnimationCache.cpp index eab077454b..9e8a850c94 100644 --- a/cocos2dx/sprite_nodes/CCAnimationCache.cpp +++ b/cocos2dx/sprite_nodes/CCAnimationCache.cpp @@ -55,7 +55,8 @@ void AnimationCache::destroyInstance() bool AnimationCache::init() { - _animations = new Dictionary(); + _animations = new Dictionary; + _animations->init(); return true; } @@ -66,7 +67,7 @@ AnimationCache::AnimationCache() AnimationCache::~AnimationCache() { - CCLOGINFO("cocos2d: deallocing %p", this); + CCLOGINFO("deallocing AnimationCache: %p", this); CC_SAFE_RELEASE(_animations); } diff --git a/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp b/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp index 202df05c70..ddf235c933 100644 --- a/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp @@ -64,7 +64,9 @@ void SpriteFrameCache::destroyInstance() bool SpriteFrameCache::init(void) { _spriteFrames= new Dictionary(); + _spriteFrames->init(); _spriteFramesAliases = new Dictionary(); + _spriteFramesAliases->init(); _loadedFileNames = new std::set(); return true; } diff --git a/cocos2dx/support/CCProfiling.cpp b/cocos2dx/support/CCProfiling.cpp index 512057577a..87468c92bf 100644 --- a/cocos2dx/support/CCProfiling.cpp +++ b/cocos2dx/support/CCProfiling.cpp @@ -79,6 +79,7 @@ void Profiler::releaseAllTimers() bool Profiler::init() { _activeTimers = new Dictionary(); + _activeTimers->init(); return true; } diff --git a/cocos2dx/textures/CCTextureCache.cpp b/cocos2dx/textures/CCTextureCache.cpp index d7690973fe..1f11b60eba 100644 --- a/cocos2dx/textures/CCTextureCache.cpp +++ b/cocos2dx/textures/CCTextureCache.cpp @@ -72,14 +72,17 @@ TextureCache::TextureCache() , _imageInfoQueue(nullptr) , _needQuit(false) , _asyncRefCount(0) -, _textures(new Dictionary()) { CCASSERT(_sharedTextureCache == nullptr, "Attempted to allocate a second instance of a singleton."); + + _textures = new Dictionary(); + _textures->init(); + } TextureCache::~TextureCache() { - CCLOGINFO("cocos2d: deallocing TextureCache: %p", this); + CCLOGINFO("deallocing TextureCache: %p", this); CC_SAFE_RELEASE(_textures); diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXObjectGroup.cpp b/cocos2dx/tilemap_parallax_nodes/CCTMXObjectGroup.cpp index b4652873a4..b232b2f807 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXObjectGroup.cpp +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXObjectGroup.cpp @@ -38,11 +38,12 @@ TMXObjectGroup::TMXObjectGroup() _objects = Array::create(); _objects->retain(); _properties = new Dictionary(); + _properties->init(); } TMXObjectGroup::~TMXObjectGroup() { - CCLOGINFO( "cocos2d: deallocing: %p", this); + CCLOGINFO("deallocing TMXObjectGroup: %p", this); CC_SAFE_RELEASE(_objects); CC_SAFE_RELEASE(_properties); } diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp b/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp index 415dd8dcbb..c02f1ebd6c 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp @@ -56,12 +56,13 @@ TMXLayerInfo::TMXLayerInfo() , _maxGID(0) , _offset(Point::ZERO) { - _properties= new Dictionary();; + _properties = new Dictionary(); + _properties->init(); } TMXLayerInfo::~TMXLayerInfo() { - CCLOGINFO("cocos2d: deallocing: %p", this); + CCLOGINFO("deallocing TMXLayerInfo: %p", this); CC_SAFE_RELEASE(_properties); if( _ownTiles && _tiles ) { @@ -157,7 +158,9 @@ void TMXMapInfo::internalInit(const char* tmxFileName, const char* resourcePath) _objectGroups->retain(); _properties = new Dictionary(); + _properties->init(); _tileProperties = new Dictionary(); + _tileProperties->init(); // tmp vars _currentString = ""; @@ -194,7 +197,7 @@ TMXMapInfo::TMXMapInfo() TMXMapInfo::~TMXMapInfo() { - CCLOGINFO("cocos2d: deallocing: %p", this); + CCLOGINFO("deallocing TMXMapInfo: %p", this); CC_SAFE_RELEASE(_tilesets); CC_SAFE_RELEASE(_layers); CC_SAFE_RELEASE(_properties); @@ -368,6 +371,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) { TMXTilesetInfo* info = (TMXTilesetInfo*)pTMXMapInfo->getTilesets()->lastObject(); Dictionary *dict = new Dictionary(); + dict->init(); pTMXMapInfo->setParentGID(info->_firstGid + atoi(valueForKey("id", attributeDict))); pTMXMapInfo->getTileProperties()->setObject(dict, pTMXMapInfo->getParentGID()); CC_SAFE_RELEASE(dict); @@ -502,6 +506,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) // The value for "type" was blank or not a valid class name // Create an instance of TMXObjectInfo to store the object and its properties Dictionary *dict = new Dictionary(); + dict->init(); // Parse everything automatically const char* pArray[] = {"name", "type", "width", "height", "gid"}; @@ -618,7 +623,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) const char* value = valueForKey("points", attributeDict); if(value) { - Array* pPointsArray = new Array; + Array* pointsArray = Array::createWithCapacity(10); // parse points string into a space-separated set of points stringstream pointsStream(value); @@ -630,7 +635,8 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) string xStr,yStr; char buffer[32] = {0}; - Dictionary* pPointDict = new Dictionary; + Dictionary* pointDict = new Dictionary; + pointDict->init(); // set x if(std::getline(pointStream, xStr, ',')) @@ -639,7 +645,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) sprintf(buffer, "%d", x); String* pStr = new String(buffer); pStr->autorelease(); - pPointDict->setObject(pStr, "x"); + pointDict->setObject(pStr, "x"); } // set y @@ -649,16 +655,15 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) sprintf(buffer, "%d", y); String* pStr = new String(buffer); pStr->autorelease(); - pPointDict->setObject(pStr, "y"); + pointDict->setObject(pStr, "y"); } // add to points array - pPointsArray->addObject(pPointDict); - pPointDict->release(); + pointsArray->addObject(pointDict); + pointDict->release(); } - dict->setObject(pPointsArray, "points"); - pPointsArray->release(); + dict->setObject(pointsArray, "points"); } } else if (elementName == "polyline") diff --git a/cocos2dx/tilemap_parallax_nodes/CCTileMapAtlas.cpp b/cocos2dx/tilemap_parallax_nodes/CCTileMapAtlas.cpp index 8adfec66de..0863c2f097 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTileMapAtlas.cpp +++ b/cocos2dx/tilemap_parallax_nodes/CCTileMapAtlas.cpp @@ -56,6 +56,7 @@ bool TileMapAtlas::initWithTileFile(const char *tile, const char *mapFile, int t if( AtlasNode::initWithTileFile(tile, tileWidth, tileHeight, _itemsToRender) ) { _posToAtlasIndex = new Dictionary(); + _posToAtlasIndex->init(); this->updateAtlasValues(); this->setContentSize(Size((float)(_TGAInfo->width*_itemWidth), (float)(_TGAInfo->height*_itemHeight))); diff --git a/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp b/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp index 8d070abba4..50f5a1f317 100644 --- a/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp +++ b/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp @@ -306,8 +306,8 @@ TouchHandler* TouchDispatcher::findHandler(Array* pArray, TouchDelegate *pDelega void TouchDispatcher::rearrangeHandlers(Array *array) { - std::sort(array->data->arr, array->data->arr + array->data->num, less); -// std::sort( std::begin(*array), std::end(*array), less); +// std::sort(array->data->arr, array->data->arr + array->data->num, less); + std::sort( std::begin(*array), std::end(*array), less); } void TouchDispatcher::setPriority(int nPriority, TouchDelegate *pDelegate) diff --git a/extensions/CCArmature/CCArmature.cpp b/extensions/CCArmature/CCArmature.cpp index b29ab69a3b..d9186e9e6d 100644 --- a/extensions/CCArmature/CCArmature.cpp +++ b/extensions/CCArmature/CCArmature.cpp @@ -84,10 +84,12 @@ Armature::Armature() Armature::~Armature(void) { + CCLOGINFO("deallocing Armature: %p", this); + if(NULL != _boneDic) { _boneDic->removeAllObjects(); - CC_SAFE_DELETE(_boneDic); + CC_SAFE_RELEASE(_boneDic); } if (NULL != _topBoneList) { @@ -115,12 +117,13 @@ bool Armature::init(const char *name) _animation = new ArmatureAnimation(); _animation->init(this); - CC_SAFE_DELETE(_boneDic); + CC_SAFE_RELEASE(_boneDic); _boneDic = new Dictionary(); + _boneDic->init(); CC_SAFE_DELETE(_topBoneList); - _topBoneList = new Array(); - _topBoneList->init(); + _topBoneList = Array::create(); + _topBoneList->retain(); _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; @@ -145,7 +148,7 @@ bool Armature::init(const char *name) DictElement *_element = NULL; - Dictionary *boneDataDic = &armatureData->boneDataDic; + Dictionary *boneDataDic = armatureData->boneDataDic; CCDICT_FOREACH(boneDataDic, _element) { Bone *bone = createBone(_element->getStrKey()); @@ -158,7 +161,7 @@ bool Armature::init(const char *name) CC_BREAK_IF(!movData); MovementBoneData *movBoneData = movData->getMovementBoneData(bone->getName().c_str()); - CC_BREAK_IF(!movBoneData || movBoneData->frameList.count() <= 0); + CC_BREAK_IF(!movBoneData || movBoneData->frameList->count() <= 0); FrameData *frameData = movBoneData->getFrameData(0); CC_BREAK_IF(!frameData); diff --git a/extensions/CCArmature/animation/CCArmatureAnimation.cpp b/extensions/CCArmature/animation/CCArmatureAnimation.cpp index 13b585b71a..c944a477eb 100644 --- a/extensions/CCArmature/animation/CCArmatureAnimation.cpp +++ b/extensions/CCArmature/animation/CCArmatureAnimation.cpp @@ -57,6 +57,8 @@ ArmatureAnimation::ArmatureAnimation() ArmatureAnimation::~ArmatureAnimation(void) { + CCLOGINFO("deallocing ArmatureAnimation: %p", this); + CC_SAFE_RELEASE_NULL(_tweenList); CC_SAFE_RELEASE_NULL(_animationData); } @@ -185,10 +187,10 @@ void ArmatureAnimation::play(const char *animationName, int durationTo, int dura CCDICT_FOREACH(dict, element) { Bone *bone = (Bone *)element->getObject(); - movementBoneData = (MovementBoneData *)_movementData->movBoneDataDic.objectForKey(bone->getName()); + movementBoneData = (MovementBoneData *)_movementData->movBoneDataDic->objectForKey(bone->getName()); Tween *tween = bone->getTween(); - if(movementBoneData && movementBoneData->frameList.count() > 0) + if(movementBoneData && movementBoneData->frameList->count() > 0) { _tweenList->addObject(tween); tween->play(movementBoneData, durationTo, durationTween, loop, tweenEasing); diff --git a/extensions/CCArmature/animation/CCTween.cpp b/extensions/CCArmature/animation/CCTween.cpp index 0aafdd29d8..07ae27dded 100644 --- a/extensions/CCArmature/animation/CCTween.cpp +++ b/extensions/CCArmature/animation/CCTween.cpp @@ -110,7 +110,7 @@ void Tween::play(MovementBoneData *movementBoneData, int durationTo, int duratio setMovementBoneData(movementBoneData); - if (_movementBoneData->frameList.count() == 1) + if (_movementBoneData->frameList->count() == 1) { _loopType = SINGLE_FRAME; FrameData *_nextKeyFrame = _movementBoneData->getFrameData(0); @@ -128,7 +128,7 @@ void Tween::play(MovementBoneData *movementBoneData, int durationTo, int duratio _rawDuration = _movementBoneData->duration; _fromIndex = _toIndex = 0; } - else if (_movementBoneData->frameList.count() > 1) + else if (_movementBoneData->frameList->count() > 1) { if (loop) { @@ -383,7 +383,7 @@ float Tween::updateFrameData(float currentPrecent, bool activeFrame) * Get frame length, if _toIndex >= _length, then set _toIndex to 0, start anew. * _toIndex is next index will play */ - int length = _movementBoneData->frameList.count(); + int length = _movementBoneData->frameList->count(); do { betweenDuration = _movementBoneData->getFrameData(_toIndex)->duration; diff --git a/extensions/CCArmature/datas/CCDatas.cpp b/extensions/CCArmature/datas/CCDatas.cpp index 9966d9fbe0..d08866ceb4 100644 --- a/extensions/CCArmature/datas/CCDatas.cpp +++ b/extensions/CCArmature/datas/CCDatas.cpp @@ -209,22 +209,24 @@ BoneData::BoneData(void) BoneData::~BoneData(void) { + CC_SAFE_RELEASE(displayDataList); } bool BoneData::init() { - displayDataList.init(); + displayDataList = new Array; + displayDataList->init(); return true; } void BoneData::addDisplayData(DisplayData *displayData) { - displayDataList.addObject(displayData); + displayDataList->addObject(displayData); } DisplayData *BoneData::getDisplayData(int index) { - return (DisplayData *)displayDataList.objectAtIndex(index); + return static_cast( displayDataList->objectAtIndex(index) ); } ArmatureData::ArmatureData() @@ -233,22 +235,30 @@ ArmatureData::ArmatureData() ArmatureData::~ArmatureData() { + CC_SAFE_RELEASE(boneList); + CC_SAFE_RELEASE(boneDataDic); } bool ArmatureData::init() { - return boneList.init(); + boneList = new Array; + boneList->init(); + + boneDataDic = new Dictionary; + boneDataDic->init(); + + return true; } void ArmatureData::addBoneData(BoneData *boneData) { - boneDataDic.setObject(boneData, boneData->name); - boneList.addObject(boneData); + boneDataDic->setObject(boneData, boneData->name); + boneList->addObject(boneData); } BoneData *ArmatureData::getBoneData(const char *boneName) { - return (BoneData *)boneDataDic.objectForKey(boneName); + return static_cast( boneDataDic->objectForKey(boneName) ); } FrameData::FrameData(void) @@ -282,30 +292,31 @@ MovementBoneData::MovementBoneData() , duration(0) , name("") { + frameList = new Array; + frameList->init(); } MovementBoneData::~MovementBoneData(void) { + CC_SAFE_RELEASE(frameList); } bool MovementBoneData::init() { - return frameList.init(); + return true; } void MovementBoneData::addFrameData(FrameData *frameData) { - frameList.addObject(frameData); + frameList->addObject(frameData); duration += frameData->duration; } FrameData *MovementBoneData::getFrameData(int index) { - return (FrameData *)frameList.objectAtIndex(index); + return static_cast( frameList->objectAtIndex(index) ); } - - MovementData::MovementData(void) : name("") , duration(0) @@ -314,30 +325,36 @@ MovementData::MovementData(void) , loop(true) , tweenEasing(Linear) { + movBoneDataDic = new Dictionary; + movBoneDataDic->init(); } MovementData::~MovementData(void) { + CC_SAFE_RELEASE(movBoneDataDic); } void MovementData::addMovementBoneData(MovementBoneData *movBoneData) { - movBoneDataDic.setObject(movBoneData, movBoneData->name); + movBoneDataDic->setObject(movBoneData, movBoneData->name); } MovementBoneData *MovementData::getMovementBoneData(const char *boneName) { - return (MovementBoneData *)movBoneDataDic.objectForKey(boneName); + return static_cast( movBoneDataDic->objectForKey(boneName) ); } AnimationData::AnimationData(void) { + movementDataDic = new Dictionary; + movementDataDic->init(); } AnimationData::~AnimationData(void) { + CC_SAFE_RELEASE(movementDataDic); } void AnimationData::release() @@ -352,33 +369,36 @@ void AnimationData::retain() void AnimationData::addMovement(MovementData *movData) { - movementDataDic.setObject(movData, movData->name); + movementDataDic->setObject(movData, movData->name); movementNames.push_back(movData->name); } MovementData *AnimationData::getMovement(const char *movementName) { - return (MovementData *)movementDataDic.objectForKey(movementName); + return (MovementData *)movementDataDic->objectForKey(movementName); } int AnimationData::getMovementCount() { - return movementDataDic.count(); + return movementDataDic->count(); } ContourData::ContourData() { + vertexList = new Array; + vertexList->init(); } ContourData::~ContourData() { + CC_SAFE_RELEASE(vertexList); } bool ContourData::init() { - return vertexList.init(); + return true; } TextureData::TextureData() @@ -388,25 +408,28 @@ TextureData::TextureData() , pivotY(0.5f) , name("") { + contourDataList = new Array; + contourDataList->init(); } TextureData::~TextureData() { + CC_SAFE_RELEASE(contourDataList); } bool TextureData::init() { - return contourDataList.init(); + return true; } void TextureData::addContourData(ContourData *contourData) { - contourDataList.addObject(contourData); + contourDataList->addObject(contourData); } ContourData *TextureData::getContourData(int index) { - return (ContourData *)contourDataList.objectAtIndex(index); + return static_cast( contourDataList->objectAtIndex(index) ); } diff --git a/extensions/CCArmature/datas/CCDatas.h b/extensions/CCArmature/datas/CCDatas.h index 186314267f..5a2055ab1b 100644 --- a/extensions/CCArmature/datas/CCDatas.h +++ b/extensions/CCArmature/datas/CCDatas.h @@ -244,7 +244,7 @@ public: public: std::string name; //! the bone's name std::string parentName; //! the bone parent's name - Array displayDataList; //! save DisplayData informations for the Bone + Array *displayDataList; //! save DisplayData informations for the Bone }; @@ -266,8 +266,8 @@ public: BoneData *getBoneData(const char *boneName); public: std::string name; - Dictionary boneDataDic; - Array boneList; + Dictionary *boneDataDic; + Array *boneList; }; @@ -318,7 +318,7 @@ public: float duration; //! this Bone in this movement will last _duration frames std::string name; //! bone name - Array frameList; + Array *frameList; }; @@ -363,7 +363,7 @@ public: * Dictionary to save movment bone data. * Key type is std::string, value type is MovementBoneData *. */ - Dictionary movBoneDataDic; + Dictionary *movBoneDataDic; }; @@ -388,7 +388,7 @@ public: int getMovementCount(); public: std::string name; - Dictionary movementDataDic; + Dictionary *movementDataDic; std::vector movementNames; }; @@ -418,7 +418,7 @@ public: virtual bool init(); public: - Array vertexList; //! Save contour vertex info, vertex saved in a Point + Array *vertexList; //! Save contour vertex info, vertex saved in a Point }; @@ -449,7 +449,7 @@ public: std::string name; //! The texture's name - Array contourDataList; + Array *contourDataList; }; diff --git a/extensions/CCArmature/display/CCDisplayFactory.cpp b/extensions/CCArmature/display/CCDisplayFactory.cpp index e749ed7642..923c0dff2f 100644 --- a/extensions/CCArmature/display/CCDisplayFactory.cpp +++ b/extensions/CCArmature/display/CCDisplayFactory.cpp @@ -153,12 +153,12 @@ void DisplayFactory::createSpriteDisplay(Bone *bone, DecorativeDisplay *decoDisp decoDisplay->setDisplay(skin); #if ENABLE_PHYSICS_DETECT - if (textureData && textureData->contourDataList.count() > 0) + if (textureData && textureData->contourDataList->count() > 0) { //! create ContourSprite ColliderDetector *colliderDetector = ColliderDetector::create(bone); - colliderDetector->addContourDataList(&textureData->contourDataList); + colliderDetector->addContourDataList(textureData->contourDataList); decoDisplay->setColliderDetector(colliderDetector); } diff --git a/extensions/CCArmature/display/CCDisplayManager.cpp b/extensions/CCArmature/display/CCDisplayManager.cpp index 7fd43f82c8..41610767d4 100644 --- a/extensions/CCArmature/display/CCDisplayManager.cpp +++ b/extensions/CCArmature/display/CCDisplayManager.cpp @@ -210,7 +210,7 @@ DecorativeDisplay *DisplayManager::getCurrentDecorativeDisplay() DecorativeDisplay *DisplayManager::getDecorativeDisplayByIndex( int index) { - return (DecorativeDisplay *)_decoDisplayList->objectAtIndex(index); + return static_cast( _decoDisplayList->objectAtIndex(index) ); } void DisplayManager::initDisplayList(BoneData *boneData) @@ -222,7 +222,7 @@ void DisplayManager::initDisplayList(BoneData *boneData) CS_RETURN_IF(!boneData); Object *object = NULL; - Array *displayDataList = &boneData->displayDataList; + Array *displayDataList = boneData->displayDataList; CCARRAY_FOREACH(displayDataList, object) { DisplayData *displayData = static_cast(object); diff --git a/extensions/CCArmature/physics/CCColliderDetector.cpp b/extensions/CCArmature/physics/CCColliderDetector.cpp index 207f3b34ff..d146650af6 100644 --- a/extensions/CCArmature/physics/CCColliderDetector.cpp +++ b/extensions/CCArmature/physics/CCColliderDetector.cpp @@ -93,10 +93,10 @@ bool ColliderDetector::init(Bone *bone) void ColliderDetector::addContourData(ContourData *contourData) { - const Array *array = &contourData->vertexList; + const Array *array = contourData->vertexList; Object *object = NULL; - b2Vec2 *b2bv = new b2Vec2[contourData->vertexList.count()]; + b2Vec2 *b2bv = new b2Vec2[contourData->vertexList->count()]; int i = 0; CCARRAY_FOREACH(array, object) @@ -107,7 +107,7 @@ void ColliderDetector::addContourData(ContourData *contourData) } b2PolygonShape polygon; - polygon.Set(b2bv, contourData->vertexList.count()); + polygon.Set(b2bv, contourData->vertexList->count()); CC_SAFE_DELETE(b2bv); @@ -183,7 +183,7 @@ void ColliderDetector::updateTransform(AffineTransform &t) b2PolygonShape *shape = (b2PolygonShape *)body->GetFixtureList()->GetShape(); //! update every vertex - const Array *array = &contourData->vertexList; + const Array *array = contourData->vertexList; Object *object = NULL; int i = 0; CCARRAY_FOREACH(array, object) diff --git a/extensions/CCArmature/utils/CCArmatureDataManager.cpp b/extensions/CCArmature/utils/CCArmatureDataManager.cpp index 7d97d97813..3153fe05f8 100644 --- a/extensions/CCArmature/utils/CCArmatureDataManager.cpp +++ b/extensions/CCArmature/utils/CCArmatureDataManager.cpp @@ -57,11 +57,13 @@ ArmatureDataManager::ArmatureDataManager(void) ArmatureDataManager::~ArmatureDataManager(void) { + CCLOGINFO("deallocing ArmatureDataManager: %p", this); + removeAll(); - CC_SAFE_DELETE(_animationDatas); - CC_SAFE_DELETE(_armarureDatas); - CC_SAFE_DELETE(_textureDatas); + CC_SAFE_RELEASE(_animationDatas); + CC_SAFE_RELEASE(_armarureDatas); + CC_SAFE_RELEASE(_textureDatas); } void ArmatureDataManager::purgeArmatureSystem() @@ -77,17 +79,17 @@ bool ArmatureDataManager::init() bool bRet = false; do { - _armarureDatas = Dictionary::create(); + _armarureDatas = new Dictionary; CCASSERT(_armarureDatas, "create ArmatureDataManager::_armarureDatas fail!"); - _armarureDatas->retain(); + _armarureDatas->init(); - _animationDatas = Dictionary::create(); + _animationDatas = new Dictionary; CCASSERT(_animationDatas, "create ArmatureDataManager::_animationDatas fail!"); - _animationDatas->retain(); + _animationDatas->init(); - _textureDatas = Dictionary::create(); + _textureDatas = new Dictionary; CCASSERT(_textureDatas, "create ArmatureDataManager::_textureDatas fail!"); - _textureDatas->retain(); + _textureDatas->init(); bRet = true; } diff --git a/extensions/CCArmature/utils/CCDataReaderHelper.cpp b/extensions/CCArmature/utils/CCDataReaderHelper.cpp index 290d3a9dd0..f0c33086f3 100644 --- a/extensions/CCArmature/utils/CCDataReaderHelper.cpp +++ b/extensions/CCArmature/utils/CCDataReaderHelper.cpp @@ -785,7 +785,7 @@ ContourData *DataReaderHelper::decodeContour(tinyxml2::XMLElement *contourXML) vertexDataXML->QueryFloatAttribute(A_Y, &vertex->y); vertex->y = -vertex->y; - contourData->vertexList.addObject(vertex); + contourData->vertexList->addObject(vertex); vertexDataXML = vertexDataXML->NextSiblingElement(CONTOUR_VERTEX); } @@ -1079,7 +1079,7 @@ TextureData *DataReaderHelper::decodeTexture(cs::CSJsonDictionary &json) for (int i = 0; i < length; i++) { cs::CSJsonDictionary *dic = json.getSubItemFromArray(CONTOUR_DATA, i); - textureData->contourDataList.addObject(decodeContour(*dic)); + textureData->contourDataList->addObject(decodeContour(*dic)); delete dic; } @@ -1101,7 +1101,7 @@ ContourData *DataReaderHelper::decodeContour(cs::CSJsonDictionary &json) vertex->x = dic->getItemFloatValue(A_X, 0); vertex->y = dic->getItemFloatValue(A_Y, 0); - contourData->vertexList.addObject(vertex); + contourData->vertexList->addObject(vertex); vertex->release(); delete dic; diff --git a/extensions/CCArmature/utils/CCSpriteFrameCacheHelper.cpp b/extensions/CCArmature/utils/CCSpriteFrameCacheHelper.cpp index 36fc52cb9a..297cbd6046 100644 --- a/extensions/CCArmature/utils/CCSpriteFrameCacheHelper.cpp +++ b/extensions/CCArmature/utils/CCSpriteFrameCacheHelper.cpp @@ -173,6 +173,7 @@ TextureAtlas *SpriteFrameCacheHelper::getTextureAtlas(const char *displayName) SpriteFrameCacheHelper::SpriteFrameCacheHelper() { _display2TextureAtlas = new Dictionary(); + _display2TextureAtlas->init(); } SpriteFrameCacheHelper::~SpriteFrameCacheHelper() diff --git a/extensions/CCBReader/CCBAnimationManager.cpp b/extensions/CCBReader/CCBAnimationManager.cpp index 7b6172a3dd..b2249c3871 100644 --- a/extensions/CCBReader/CCBAnimationManager.cpp +++ b/extensions/CCBReader/CCBAnimationManager.cpp @@ -34,17 +34,27 @@ CCBAnimationManager::CCBAnimationManager() bool CCBAnimationManager::init() { - _sequences = new Array(); + _sequences = Array::createWithCapacity(15); + _sequences->retain(); _nodeSequences = new Dictionary(); + _nodeSequences->init(); _baseValues = new Dictionary(); + _baseValues->init(); - _documentOutletNames = new Array(); - _documentOutletNodes = new Array(); - _documentCallbackNames = new Array(); - _documentCallbackNodes = new Array(); - _documentCallbackControlEvents = new Array(); - _keyframeCallbacks = new Array(); + _documentOutletNames = Array::createWithCapacity(5); + _documentOutletNames->retain(); + _documentOutletNodes = Array::createWithCapacity(5); + _documentOutletNodes->retain(); + _documentCallbackNames = Array::createWithCapacity(5); + _documentCallbackNames->retain(); + _documentCallbackNodes = Array::createWithCapacity(5); + _documentCallbackNodes->retain(); + _documentCallbackControlEvents = Array::createWithCapacity(5); + _documentCallbackControlEvents->retain(); + _keyframeCallbacks = Array::createWithCapacity(5); + _keyframeCallbacks->retain(); _keyframeCallFuncs = new Dictionary(); + _keyframeCallFuncs->init(); _target = NULL; _animationCompleteCallbackFunc = NULL; diff --git a/extensions/CCBReader/CCBReader.cpp b/extensions/CCBReader/CCBReader.cpp index b0d98e1fa5..ff4d49a024 100644 --- a/extensions/CCBReader/CCBReader.cpp +++ b/extensions/CCBReader/CCBReader.cpp @@ -153,9 +153,12 @@ const std::string& CCBReader::getCCBRootPath() const bool CCBReader::init() { - _ownerOutletNodes = new Array(); - _ownerCallbackNodes = new Array(); - _ownerOwnerCallbackControlEvents = new Array(); + _ownerOutletNodes = Array::create(); + _ownerOutletNodes->retain(); + _ownerCallbackNodes = Array::create(); + _ownerCallbackNodes->retain(); + _ownerOwnerCallbackControlEvents = Array::create(); + _ownerOwnerCallbackControlEvents->retain(); // Setup action manager CCBAnimationManager *pActionManager = new CCBAnimationManager(); @@ -277,8 +280,10 @@ Node* CCBReader::readNodeGraphFromData(Data *pData, Object *pOwner, const Size & // Assign actionManagers to userObject if(_jsControlled) { - _nodesWithAnimationManagers = new Array(); - _animationManagersForNodes = new Array(); + _nodesWithAnimationManagers = Array::create(); + _nodesWithAnimationManagers->retain(); + _animationManagersForNodes = Array::create(); + _animationManagersForNodes->retain(); } DictElement* pElement = NULL; diff --git a/extensions/CCBReader/CCBSequenceProperty.cpp b/extensions/CCBReader/CCBSequenceProperty.cpp index ca39935e57..607184dd51 100644 --- a/extensions/CCBReader/CCBSequenceProperty.cpp +++ b/extensions/CCBReader/CCBSequenceProperty.cpp @@ -14,7 +14,8 @@ CCBSequenceProperty::CCBSequenceProperty() bool CCBSequenceProperty::init() { - _keyframes = new Array(); + _keyframes = Array::createWithCapacity(5); + _keyframes->retain(); return true; } diff --git a/extensions/CCBReader/CCNodeLoader.cpp b/extensions/CCBReader/CCNodeLoader.cpp index 2c6ec045f8..7feb803755 100644 --- a/extensions/CCBReader/CCNodeLoader.cpp +++ b/extensions/CCBReader/CCNodeLoader.cpp @@ -11,6 +11,7 @@ NS_CC_EXT_BEGIN NodeLoader::NodeLoader() { _customProperties = new Dictionary(); + _customProperties->init(); } NodeLoader::~NodeLoader() diff --git a/extensions/GUI/CCControlExtension/CCControl.cpp b/extensions/GUI/CCControlExtension/CCControl.cpp index 2d43412907..3424fcde93 100644 --- a/extensions/GUI/CCControlExtension/CCControl.cpp +++ b/extensions/GUI/CCControlExtension/CCControl.cpp @@ -78,7 +78,8 @@ bool Control::init() // Set the touch dispatcher priority by default to 1 this->setTouchPriority(1); // Initialise the tables - _dispatchTable = new Dictionary(); + _dispatchTable = new Dictionary(); + _dispatchTable->init(); return true; } diff --git a/extensions/GUI/CCScrollView/CCScrollView.cpp b/extensions/GUI/CCScrollView/CCScrollView.cpp index 64a1766b51..b277d9f6df 100644 --- a/extensions/GUI/CCScrollView/CCScrollView.cpp +++ b/extensions/GUI/CCScrollView/CCScrollView.cpp @@ -109,7 +109,8 @@ bool ScrollView::initWithViewSize(Size size, Node *container/* = NULL*/) this->setViewSize(size); setTouchEnabled(true); - _touches = new Array(); + _touches = Array::create(); + _touches->retain(); _delegate = NULL; _bounceable = true; _clippingToBounds = true; @@ -183,7 +184,8 @@ void ScrollView::setTouchEnabled(bool e) { _dragging = false; _touchMoved = false; - if(_touches)_touches->removeAllObjects(); + if(_touches) + _touches->removeAllObjects(); } } diff --git a/extensions/network/SocketIO.cpp b/extensions/network/SocketIO.cpp index 3921e3cdcd..7510ce8d74 100644 --- a/extensions/network/SocketIO.cpp +++ b/extensions/network/SocketIO.cpp @@ -107,7 +107,7 @@ SIOClientImpl::~SIOClientImpl() { if (_connected) disconnect(); - CC_SAFE_DELETE(_clients); + CC_SAFE_RELEASE(_clients); CC_SAFE_DELETE(_ws); } @@ -600,7 +600,7 @@ SocketIO::SocketIO() SocketIO::~SocketIO(void) { - CC_SAFE_DELETE(_sockets); + CC_SAFE_RELEASE(_sockets); delete _inst; } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/ProjectileController.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/ProjectileController.cpp index 12eec899ec..3061326118 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/ProjectileController.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/ProjectileController.cpp @@ -45,7 +45,7 @@ void ProjectileController::update(float delta) projectile->getContentSize().width, projectile->getContentSize().height); - auto targetsToDelete =new Array; + auto targetsToDelete = Array::createWithCapacity(20); Object* jt = NULL; CCARRAY_FOREACH(_targets, jt) { @@ -71,8 +71,6 @@ void ProjectileController::update(float delta) bool isDied = targetsToDelete->count() > 0; - targetsToDelete->release(); - if (isDied) { die(); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/SceneController.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/SceneController.cpp index c4d0bf7ef4..811423517d 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/SceneController.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/SceneController.cpp @@ -18,17 +18,8 @@ SceneController::SceneController(void) SceneController::~SceneController(void) { - if (_targets) - { - _targets->release(); - _targets = NULL; - } - - if (_projectiles) - { - _projectiles->release(); - _projectiles = NULL; - } + CC_SAFE_RELEASE(_targets); + CC_SAFE_RELEASE(_projectiles); } bool SceneController::init() @@ -40,8 +31,11 @@ void SceneController::onEnter() { _fAddTargetTime = 1.0f; - _targets = new Array; - _projectiles = new Array; + _targets = Array::createWithCapacity(10); + _projectiles = Array::createWithCapacity(10); + + _targets->retain(); + _projectiles->retain(); ((ComAudio*)(_owner->getComponent("Audio")))->playBackgroundMusic("background-music-aac.wav", true); ((ComAttribute*)(_owner->getComponent("ComAttribute")))->setInt("KillCount", 0); @@ -49,8 +43,6 @@ void SceneController::onEnter() void SceneController::onExit() { - - } void SceneController::update(float delta) From 7bd502506438538e871ac8656497d58bf9b44e8a Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 21 Aug 2013 20:27:31 -0700 Subject: [PATCH 066/126] [NaCL] Add missing include of This was previously included by nacl_io.h but upstrean changes in NaCl removed this. --- cocos2dx/platform/nacl/CCInstance.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/cocos2dx/platform/nacl/CCInstance.cpp b/cocos2dx/platform/nacl/CCInstance.cpp index 44ef996c0f..3741b1d665 100644 --- a/cocos2dx/platform/nacl/CCInstance.cpp +++ b/cocos2dx/platform/nacl/CCInstance.cpp @@ -37,6 +37,7 @@ THE SOFTWARE. #include #include #include +#include #include USING_NS_CC; From da566a3c16e93801b6cb05ef0050c198d8ebffac Mon Sep 17 00:00:00 2001 From: boyu0 Date: Thu, 22 Aug 2013 11:49:34 +0800 Subject: [PATCH 067/126] issue #2434: add android_generator and generate cocos2dx, extensions and TestCpp's android.mk files add PathUtils.py for python library. --- cocos2dx/Android.mk | 56 ++++----- extensions/Android.mk | 106 ++++++++++++++++- samples/Cpp/TestCpp/Android.mk | 108 +++++++++++++++++- tools/android_generator/android_generator.py | 44 +++++++ tools/android_generator/cocos2d_template.mk | 55 +++++++++ tools/android_generator/cpptest_template.mk | 30 +++++ .../android_generator/extensions_template.mk | 39 +++++++ tools/pylib/PathUtils.py | 86 ++++++++++++++ tools/pylib/__init__.py | 0 9 files changed, 494 insertions(+), 30 deletions(-) create mode 100644 tools/android_generator/android_generator.py create mode 100644 tools/android_generator/cocos2d_template.mk create mode 100644 tools/android_generator/cpptest_template.mk create mode 100644 tools/android_generator/extensions_template.mk create mode 100644 tools/pylib/PathUtils.py create mode 100644 tools/pylib/__init__.py diff --git a/cocos2dx/Android.mk b/cocos2dx/Android.mk index f6f4798c82..1db2781a63 100644 --- a/cocos2dx/Android.mk +++ b/cocos2dx/Android.mk @@ -7,12 +7,14 @@ LOCAL_MODULE := cocos2dx_static LOCAL_MODULE_FILENAME := libcocos2d LOCAL_SRC_FILES := \ +CCCamera.cpp \ CCConfiguration.cpp \ CCDeprecated.cpp \ -CCScheduler.cpp \ -CCCamera.cpp \ +CCDirector.cpp \ ccFPSImages.c \ +CCScheduler.cpp \ ccTypes.cpp \ +cocos2d.cpp \ actions/CCAction.cpp \ actions/CCActionCamera.cpp \ actions/CCActionCatmullRom.cpp \ @@ -29,18 +31,16 @@ actions/CCActionTween.cpp \ base_nodes/CCAtlasNode.cpp \ base_nodes/CCNode.cpp \ cocoa/CCAffineTransform.cpp \ -cocoa/CCGeometry.cpp \ +cocoa/CCArray.cpp \ cocoa/CCAutoreleasePool.cpp \ +cocoa/CCData.cpp \ +cocoa/CCDataVisitor.cpp \ cocoa/CCDictionary.cpp \ +cocoa/CCGeometry.cpp \ cocoa/CCNS.cpp \ cocoa/CCObject.cpp \ cocoa/CCSet.cpp \ cocoa/CCString.cpp \ -cocoa/CCArray.cpp \ -cocoa/CCDataVisitor.cpp \ -cocoa/CCData.cpp \ -cocos2d.cpp \ -CCDirector.cpp \ draw_nodes/CCDrawingPrimitives.cpp \ draw_nodes/CCDrawNode.cpp \ effects/CCGrabber.cpp \ @@ -58,9 +58,9 @@ kazmath/src/vec3.c \ kazmath/src/vec4.c \ kazmath/src/GL/mat4stack.c \ kazmath/src/GL/matrix.c \ +keyboard_dispatcher/CCKeyboardDispatcher.cpp \ keypad_dispatcher/CCKeypadDelegate.cpp \ keypad_dispatcher/CCKeypadDispatcher.cpp \ -keyboard_dispatcher/CCKeyboardDispatcher.cpp \ label_nodes/CCFont.cpp \ label_nodes/CCFontAtlas.cpp \ label_nodes/CCFontAtlasCache.cpp \ @@ -71,13 +71,13 @@ label_nodes/CCFontFreeType.cpp \ label_nodes/CCLabel.cpp \ label_nodes/CCLabelAtlas.cpp \ label_nodes/CCLabelBMFont.cpp \ -label_nodes/CCLabelTTF.cpp \ label_nodes/CCLabelTextFormatter.cpp \ +label_nodes/CCLabelTTF.cpp \ label_nodes/CCTextImage.cpp \ layers_scenes_transitions_nodes/CCLayer.cpp \ layers_scenes_transitions_nodes/CCScene.cpp \ -layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp \ layers_scenes_transitions_nodes/CCTransition.cpp \ +layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp \ layers_scenes_transitions_nodes/CCTransitionProgress.cpp \ menu_nodes/CCMenu.cpp \ menu_nodes/CCMenuItem.cpp \ @@ -85,58 +85,58 @@ misc_nodes/CCClippingNode.cpp \ misc_nodes/CCMotionStreak.cpp \ misc_nodes/CCProgressTimer.cpp \ misc_nodes/CCRenderTexture.cpp \ +particle_nodes/CCParticleBatchNode.cpp \ particle_nodes/CCParticleExamples.cpp \ particle_nodes/CCParticleSystem.cpp \ -particle_nodes/CCParticleBatchNode.cpp \ particle_nodes/CCParticleSystemQuad.cpp \ +platform/CCEGLViewProtocol.cpp \ +platform/CCFileUtils.cpp \ platform/CCSAXParser.cpp \ platform/CCThread.cpp \ -platform/CCFileUtils.cpp \ -platform/CCEGLViewProtocol.cpp \ +platform/third_party/common/atitc/atitc.cpp \ +platform/third_party/common/etc/etc1.cpp \ +platform/third_party/common/s3tc/s3tc.cpp \ script_support/CCScriptSupport.cpp \ -shaders/ccShaders.cpp \ shaders/CCGLProgram.cpp \ shaders/ccGLStateCache.cpp \ shaders/CCShaderCache.cpp \ +shaders/ccShaders.cpp \ sprite_nodes/CCAnimation.cpp \ sprite_nodes/CCAnimationCache.cpp \ sprite_nodes/CCSprite.cpp \ sprite_nodes/CCSpriteBatchNode.cpp \ sprite_nodes/CCSpriteFrame.cpp \ sprite_nodes/CCSpriteFrameCache.cpp \ -support/ccUTF8.cpp \ +support/base64.cpp \ support/CCNotificationCenter.cpp \ support/CCProfiling.cpp \ -support/TransformUtils.cpp \ -support/user_default/CCUserDefaultAndroid.cpp \ -support/base64.cpp \ +support/ccUTF8.cpp \ support/ccUtils.cpp \ support/CCVertex.cpp \ +support/TransformUtils.cpp \ +support/component/CCComponent.cpp \ +support/component/CCComponentContainer.cpp \ support/data_support/ccCArray.cpp \ support/image_support/TGAlib.cpp \ support/tinyxml2/tinyxml2.cpp \ -support/zip_support/ZipUtils.cpp \ +support/user_default/CCUserDefaultAndroid.cpp \ support/zip_support/ioapi.cpp \ support/zip_support/unzip.cpp \ -support/component/CCComponent.cpp \ -support/component/CCComponentContainer.cpp \ +support/zip_support/ZipUtils.cpp \ text_input_node/CCIMEDispatcher.cpp \ text_input_node/CCTextFieldTTF.cpp \ textures/CCTexture2D.cpp \ textures/CCTextureAtlas.cpp \ textures/CCTextureCache.cpp \ -platform/third_party/common/etc/etc1.cpp \ -platform/third_party/common/s3tc/s3tc.cpp \ -platform/third_party/common/atitc/atitc.cpp \ tilemap_parallax_nodes/CCParallaxNode.cpp \ +tilemap_parallax_nodes/CCTileMapAtlas.cpp \ tilemap_parallax_nodes/CCTMXLayer.cpp \ tilemap_parallax_nodes/CCTMXObjectGroup.cpp \ tilemap_parallax_nodes/CCTMXTiledMap.cpp \ tilemap_parallax_nodes/CCTMXXMLParser.cpp \ -tilemap_parallax_nodes/CCTileMapAtlas.cpp \ +touch_dispatcher/CCTouch.cpp \ touch_dispatcher/CCTouchDispatcher.cpp \ -touch_dispatcher/CCTouchHandler.cpp \ -touch_dispatcher/CCTouch.cpp +touch_dispatcher/CCTouchHandler.cpp LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) \ $(LOCAL_PATH)/include \ diff --git a/extensions/Android.mk b/extensions/Android.mk index e62a64a1b8..e90edc34c2 100644 --- a/extensions/Android.mk +++ b/extensions/Android.mk @@ -8,7 +8,111 @@ LOCAL_MODULE_FILENAME := libextension dirs := $(shell find $(LOCAL_PATH) -type d -print) find_files = $(subst $(LOCAL_PATH)/,,$(wildcard $(dir)/*.cpp)) -LOCAL_SRC_FILES := $(foreach dir, $(dirs), $(find_files)) +LOCAL_SRC_FILES := \ +CCDeprecated-ext.cpp \ +AssetsManager/AssetsManager.cpp \ +CCArmature/CCArmature.cpp \ +CCArmature/CCBone.cpp \ +CCArmature/animation/CCArmatureAnimation.cpp \ +CCArmature/animation/CCProcessBase.cpp \ +CCArmature/animation/CCTween.cpp \ +CCArmature/datas/CCDatas.cpp \ +CCArmature/display/CCBatchNode.cpp \ +CCArmature/display/CCDecorativeDisplay.cpp \ +CCArmature/display/CCDisplayFactory.cpp \ +CCArmature/display/CCDisplayManager.cpp \ +CCArmature/display/CCShaderNode.cpp \ +CCArmature/display/CCSkin.cpp \ +CCArmature/external_tool/CCTexture2DMutable.cpp \ +CCArmature/external_tool/GLES-Render.cpp \ +CCArmature/external_tool/Json/CSContentJsonDictionary.cpp \ +CCArmature/external_tool/Json/lib_json/json_reader.cpp \ +CCArmature/external_tool/Json/lib_json/json_value.cpp \ +CCArmature/external_tool/Json/lib_json/json_writer.cpp \ +CCArmature/physics/CCColliderDetector.cpp \ +CCArmature/physics/CCPhysicsWorld.cpp \ +CCArmature/utils/CCArmatureDataManager.cpp \ +CCArmature/utils/CCDataReaderHelper.cpp \ +CCArmature/utils/CCSpriteFrameCacheHelper.cpp \ +CCArmature/utils/CCTransformHelp.cpp \ +CCArmature/utils/CCTweenFunction.cpp \ +CCArmature/utils/CCUtilMath.cpp \ +CCBReader/CCBAnimationManager.cpp \ +CCBReader/CCBFileLoader.cpp \ +CCBReader/CCBKeyframe.cpp \ +CCBReader/CCBReader.cpp \ +CCBReader/CCBSequence.cpp \ +CCBReader/CCBSequenceProperty.cpp \ +CCBReader/CCBValue.cpp \ +CCBReader/CCControlButtonLoader.cpp \ +CCBReader/CCControlLoader.cpp \ +CCBReader/CCLabelBMFontLoader.cpp \ +CCBReader/CCLabelTTFLoader.cpp \ +CCBReader/CCLayerColorLoader.cpp \ +CCBReader/CCLayerGradientLoader.cpp \ +CCBReader/CCLayerLoader.cpp \ +CCBReader/CCMenuItemImageLoader.cpp \ +CCBReader/CCMenuItemLoader.cpp \ +CCBReader/CCNode+CCBRelativePositioning.cpp \ +CCBReader/CCNodeLoader.cpp \ +CCBReader/CCNodeLoaderLibrary.cpp \ +CCBReader/CCParticleSystemQuadLoader.cpp \ +CCBReader/CCScale9SpriteLoader.cpp \ +CCBReader/CCScrollViewLoader.cpp \ +CCBReader/CCSpriteLoader.cpp \ +Components/CCComAttribute.cpp \ +Components/CCComAudio.cpp \ +Components/CCComController.cpp \ +Components/CCInputDelegate.cpp \ +GUI/CCControlExtension/CCControl.cpp \ +GUI/CCControlExtension/CCControlButton.cpp \ +GUI/CCControlExtension/CCControlColourPicker.cpp \ +GUI/CCControlExtension/CCControlHuePicker.cpp \ +GUI/CCControlExtension/CCControlPotentiometer.cpp \ +GUI/CCControlExtension/CCControlSaturationBrightnessPicker.cpp \ +GUI/CCControlExtension/CCControlSlider.cpp \ +GUI/CCControlExtension/CCControlStepper.cpp \ +GUI/CCControlExtension/CCControlSwitch.cpp \ +GUI/CCControlExtension/CCControlUtils.cpp \ +GUI/CCControlExtension/CCInvocation.cpp \ +GUI/CCControlExtension/CCScale9Sprite.cpp \ +GUI/CCEditBox/CCEditBox.cpp \ +GUI/CCEditBox/CCEditBoxImplAndroid.cpp \ +GUI/CCEditBox/CCEditBoxImplNone.cpp \ +GUI/CCEditBox/CCEditBoxImplTizen.cpp \ +GUI/CCEditBox/CCEditBoxImplWin.cpp \ +GUI/CCScrollView/CCScrollView.cpp \ +GUI/CCScrollView/CCSorting.cpp \ +GUI/CCScrollView/CCTableView.cpp \ +GUI/CCScrollView/CCTableViewCell.cpp \ +LocalStorage/LocalStorage.cpp \ +LocalStorage/LocalStorageAndroid.cpp \ +network/HttpClient.cpp \ +network/SocketIO.cpp \ +network/WebSocket.cpp \ +physics_nodes/CCPhysicsDebugNode.cpp \ +physics_nodes/CCPhysicsSprite.cpp \ +spine/Animation.cpp \ +spine/AnimationState.cpp \ +spine/AnimationStateData.cpp \ +spine/Atlas.cpp \ +spine/AtlasAttachmentLoader.cpp \ +spine/Attachment.cpp \ +spine/AttachmentLoader.cpp \ +spine/Bone.cpp \ +spine/BoneData.cpp \ +spine/CCSkeleton.cpp \ +spine/CCSkeletonAnimation.cpp \ +spine/extension.cpp \ +spine/Json.cpp \ +spine/RegionAttachment.cpp \ +spine/Skeleton.cpp \ +spine/SkeletonData.cpp \ +spine/SkeletonJson.cpp \ +spine/Skin.cpp \ +spine/Slot.cpp \ +spine/SlotData.cpp \ +spine/spine-cocos2dx.cpp LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static diff --git a/samples/Cpp/TestCpp/Android.mk b/samples/Cpp/TestCpp/Android.mk index cf94bbed6d..a59eee0b5a 100644 --- a/samples/Cpp/TestCpp/Android.mk +++ b/samples/Cpp/TestCpp/Android.mk @@ -9,7 +9,113 @@ LOCAL_MODULE_FILENAME := libtestcppcommon dirs := $(shell find $(LOCAL_PATH)/Classes -type d -print) find_files = $(subst $(LOCAL_PATH)/,,$(wildcard $(dir)/*.cpp)) -LOCAL_SRC_FILES := $(foreach dir, $(dirs), $(find_files)) +LOCAL_SRC_FILES := \ +Classes/AppDelegate.cpp \ +Classes/BaseTest.cpp \ +Classes/controller.cpp \ +Classes/testBasic.cpp \ +Classes/VisibleRect.cpp \ +Classes/AccelerometerTest/AccelerometerTest.cpp \ +Classes/ActionManagerTest/ActionManagerTest.cpp \ +Classes/ActionsEaseTest/ActionsEaseTest.cpp \ +Classes/ActionsProgressTest/ActionsProgressTest.cpp \ +Classes/ActionsTest/ActionsTest.cpp \ +Classes/Box2DTest/Box2dTest.cpp \ +Classes/Box2DTestBed/Box2dView.cpp \ +Classes/Box2DTestBed/GLES-Render.cpp \ +Classes/Box2DTestBed/Test.cpp \ +Classes/Box2DTestBed/TestEntries.cpp \ +Classes/BugsTest/Bug-1159.cpp \ +Classes/BugsTest/Bug-1174.cpp \ +Classes/BugsTest/Bug-350.cpp \ +Classes/BugsTest/Bug-422.cpp \ +Classes/BugsTest/Bug-624.cpp \ +Classes/BugsTest/Bug-886.cpp \ +Classes/BugsTest/Bug-899.cpp \ +Classes/BugsTest/Bug-914.cpp \ +Classes/BugsTest/BugsTest.cpp \ +Classes/BugsTest/Bug-458/Bug-458.cpp \ +Classes/BugsTest/Bug-458/QuestionContainerSprite.cpp \ +Classes/ChipmunkTest/ChipmunkTest.cpp \ +Classes/ClickAndMoveTest/ClickAndMoveTest.cpp \ +Classes/ClippingNodeTest/ClippingNodeTest.cpp \ +Classes/CocosDenshionTest/CocosDenshionTest.cpp \ +Classes/ConfigurationTest/ConfigurationTest.cpp \ +Classes/CurlTest/CurlTest.cpp \ +Classes/CurrentLanguageTest/CurrentLanguageTest.cpp \ +Classes/DataVisitorTest/DataVisitorTest.cpp \ +Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp \ +Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp \ +Classes/EffectsTest/EffectsTest.cpp \ +Classes/ExtensionsTest/ExtensionsTest.cpp \ +Classes/ExtensionsTest/ArmatureTest/ArmatureScene.cpp \ +Classes/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp \ +Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.cpp \ +Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.cpp \ +Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp \ +Classes/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.cpp \ +Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.cpp \ +Classes/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.cpp \ +Classes/ExtensionsTest/ComponentsTest/ComponentsTestScene.cpp \ +Classes/ExtensionsTest/ComponentsTest/EnemyController.cpp \ +Classes/ExtensionsTest/ComponentsTest/GameOverScene.cpp \ +Classes/ExtensionsTest/ComponentsTest/PlayerController.cpp \ +Classes/ExtensionsTest/ComponentsTest/ProjectileController.cpp \ +Classes/ExtensionsTest/ComponentsTest/SceneController.cpp \ +Classes/ExtensionsTest/ControlExtensionTest/CCControlScene.cpp \ +Classes/ExtensionsTest/ControlExtensionTest/CCControlSceneManager.cpp \ +Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp \ +Classes/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp \ +Classes/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.cpp \ +Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp \ +Classes/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.cpp \ +Classes/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp \ +Classes/ExtensionsTest/EditBoxTest/EditBoxTest.cpp \ +Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp \ +Classes/ExtensionsTest/NetworkTest/SocketIOTest.cpp \ +Classes/ExtensionsTest/NetworkTest/WebSocketTest.cpp \ +Classes/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.cpp \ +Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp \ +Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.cpp \ +Classes/ExtensionsTest/TableViewTest/TableViewTestScene.cpp \ +Classes/FileUtilsTest/FileUtilsTest.cpp \ +Classes/FontTest/FontTest.cpp \ +Classes/IntervalTest/IntervalTest.cpp \ +Classes/KeyboardTest/KeyboardTest.cpp \ +Classes/KeypadTest/KeypadTest.cpp \ +Classes/LabelTest/LabelTest.cpp \ +Classes/LabelTest/LabelTestNew.cpp \ +Classes/LayerTest/LayerTest.cpp \ +Classes/MenuTest/MenuTest.cpp \ +Classes/MotionStreakTest/MotionStreakTest.cpp \ +Classes/MutiTouchTest/MutiTouchTest.cpp \ +Classes/NodeTest/NodeTest.cpp \ +Classes/ParallaxTest/ParallaxTest.cpp \ +Classes/ParticleTest/ParticleTest.cpp \ +Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp \ +Classes/PerformanceTest/PerformanceParticleTest.cpp \ +Classes/PerformanceTest/PerformanceSpriteTest.cpp \ +Classes/PerformanceTest/PerformanceTest.cpp \ +Classes/PerformanceTest/PerformanceTextureTest.cpp \ +Classes/PerformanceTest/PerformanceTouchesTest.cpp \ +Classes/RenderTextureTest/RenderTextureTest.cpp \ +Classes/RotateWorldTest/RotateWorldTest.cpp \ +Classes/SceneTest/SceneTest.cpp \ +Classes/SchedulerTest/SchedulerTest.cpp \ +Classes/ShaderTest/ShaderTest.cpp \ +Classes/SpineTest/SpineTest.cpp \ +Classes/SpriteTest/SpriteTest.cpp \ +Classes/TextInputTest/TextInputTest.cpp \ +Classes/Texture2dTest/Texture2dTest.cpp \ +Classes/TextureCacheTest/TextureCacheTest.cpp \ +Classes/TexturePackerEncryptionTest/TextureAtlasEncryptionTest.cpp \ +Classes/TileMapTest/TileMapTest.cpp \ +Classes/TouchesTest/Ball.cpp \ +Classes/TouchesTest/Paddle.cpp \ +Classes/TouchesTest/TouchesTest.cpp \ +Classes/TransitionsTest/TransitionsTest.cpp \ +Classes/UserDefaultTest/UserDefaultTest.cpp \ +Classes/ZwoptexTest/ZwoptexTest.cpp LOCAL_C_INCLUDES := $(LOCAL_PATH)/Classes diff --git a/tools/android_generator/android_generator.py b/tools/android_generator/android_generator.py new file mode 100644 index 0000000000..2eefcd54e7 --- /dev/null +++ b/tools/android_generator/android_generator.py @@ -0,0 +1,44 @@ +#!/usr/bin/python + +import sys +import os +import os.path +import cStringIO + +sys.path.append(os.path.abspath("../pylib")) +import PathUtils + +COCOS_ROOT = "../../" + +COCOS_ROOT = os.path.abspath(os.path.join(os.curdir, COCOS_ROOT)) + +def gen_android_mk(tplfile, outfile, pathes, suffix = ("cpp",), exclude = ()): + "" + utils = PathUtils.PathUtils(os.path.abspath(COCOS_ROOT)) + filelst = utils.find_files(pathes, suffix, exclude) + + filestr = cStringIO.StringIO() + for filename in filelst: + filestr.write(' \\\n') + filestr.write(os.path.relpath(filename, os.path.dirname(os.path.join(COCOS_ROOT, outfile)))) + + file = open(tplfile) + template = file.read() + file.close() + + file = open(os.path.join(COCOS_ROOT, outfile), "w") + print >>file, template %(filestr.getvalue()) + file.close() + + filestr.close() + +def main(): + #generate cocos2d + gen_android_mk("./cocos2d_template.mk", "cocos2dx/Android.mk", ["cocos2dx/"], ["c", "cpp"], ["cocos2dx/platform/android", "cocos2dx/platform/emscripten", "cocos2dx/platform/ios", "cocos2dx/platform/linux", "cocos2dx/platform/mac", "cocos2dx/platform/nacl", "cocos2dx/platform/qt5", "cocos2dx/platform/tizen", "cocos2dx/platform/win32", "cocos2dx/label_nodes/CCFontCache.cpp", "cocos2dx/base_nodes/CCGLBufferedNode.cpp","cocos2dx/support/user_default/CCUserDefault.cpp"]) + #generate cpptest + gen_android_mk("./cpptest_template.mk", "samples/Cpp/TestCpp/Android.mk", ["samples/Cpp/TestCpp/Classes"]) + #generate extensions + gen_android_mk("./extensions_template.mk", "extensions/Android.mk", ["extensions/"], ["cpp"], ["extensions/proj.win32", "extensions/proj.emscripten", "extensions/proj.ios", "extensions/proj.linux", "extensions/proj.mac", "extensions/proj.nacl", "extensions/proj.qt5", "extensions/proj.tizen", ]) + +if __name__ == "__main__": + sys.exit(main()) \ No newline at end of file diff --git a/tools/android_generator/cocos2d_template.mk b/tools/android_generator/cocos2d_template.mk new file mode 100644 index 0000000000..9d8f13bd30 --- /dev/null +++ b/tools/android_generator/cocos2d_template.mk @@ -0,0 +1,55 @@ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := cocos2dx_static + +LOCAL_MODULE_FILENAME := libcocos2d + +LOCAL_SRC_FILES :=%s + +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) \ + $(LOCAL_PATH)/include \ + $(LOCAL_PATH)/kazmath/include \ + $(LOCAL_PATH)/platform/android \ + $(LOCAL_PATH)/platform/third_party/common/etc \ + $(LOCAL_PATH)/platform/third_party/common/s3tc \ + $(LOCAL_PATH)/platform/third_party/common/atitc + +LOCAL_C_INCLUDES := $(LOCAL_PATH) \ + $(LOCAL_PATH)/include \ + $(LOCAL_PATH)/kazmath/include \ + $(LOCAL_PATH)/platform/android \ + $(LOCAL_PATH)/platform/third_party/common/etc \ + $(LOCAL_PATH)/platform/third_party/common/s3tc \ + $(LOCAL_PATH)/platform/third_party/common/atitc + + +LOCAL_LDLIBS := -lGLESv2 \ + -llog \ + -lz \ + -landroid + +LOCAL_EXPORT_LDLIBS := -lGLESv2 \ + -llog \ + -lz \ + -landroid + +LOCAL_WHOLE_STATIC_LIBRARIES := cocos_libpng_static +LOCAL_WHOLE_STATIC_LIBRARIES += cocos_jpeg_static +LOCAL_WHOLE_STATIC_LIBRARIES += cocos_libxml2_static +LOCAL_WHOLE_STATIC_LIBRARIES += cocos_libtiff_static +LOCAL_WHOLE_STATIC_LIBRARIES += cocos_libwebp_static +LOCAL_WHOLE_STATIC_LIBRARIES += cocos_freetype2_static + +# define the macro to compile through support/zip_support/ioapi.c +LOCAL_CFLAGS := -Wno-psabi -DUSE_FILE32API +LOCAL_EXPORT_CFLAGS := -Wno-psabi -DUSE_FILE32API + +include $(BUILD_STATIC_LIBRARY) + +$(call import-module,libjpeg) +$(call import-module,libpng) +$(call import-module,libtiff) +$(call import-module,libwebp) +$(call import-module,libfreetype2) \ No newline at end of file diff --git a/tools/android_generator/cpptest_template.mk b/tools/android_generator/cpptest_template.mk new file mode 100644 index 0000000000..0697c3eef4 --- /dev/null +++ b/tools/android_generator/cpptest_template.mk @@ -0,0 +1,30 @@ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := cocos_testcpp_common + +LOCAL_MODULE_FILENAME := libtestcppcommon + +dirs := $(shell find $(LOCAL_PATH)/Classes -type d -print) +find_files = $(subst $(LOCAL_PATH)/,,$(wildcard $(dir)/*.cpp)) + +LOCAL_SRC_FILES := %s + +LOCAL_C_INCLUDES := $(LOCAL_PATH)/Classes + +LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static +LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static +LOCAL_WHOLE_STATIC_LIBRARIES += box2d_static +LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static +LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static + +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) + +include $(BUILD_STATIC_LIBRARY) + +$(call import-module,CocosDenshion/android) +$(call import-module,external/Box2D) +$(call import-module,external/chipmunk) +$(call import-module,cocos2dx) +$(call import-module,extensions) \ No newline at end of file diff --git a/tools/android_generator/extensions_template.mk b/tools/android_generator/extensions_template.mk new file mode 100644 index 0000000000..3bb032ee06 --- /dev/null +++ b/tools/android_generator/extensions_template.mk @@ -0,0 +1,39 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_MODULE := cocos_extension_static + +LOCAL_MODULE_FILENAME := libextension + +dirs := $(shell find $(LOCAL_PATH) -type d -print) +find_files = $(subst $(LOCAL_PATH)/,,$(wildcard $(dir)/*.cpp)) + +LOCAL_SRC_FILES :=%s + +LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static +LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static +LOCAL_WHOLE_STATIC_LIBRARIES += cocos_curl_static +LOCAL_WHOLE_STATIC_LIBRARIES += box2d_static +LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static +LOCAL_WHOLE_STATIC_LIBRARIES += libwebsockets_static + +LOCAL_CXXFLAGS += -fexceptions + +LOCAL_CFLAGS += -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 +LOCAL_EXPORT_CFLAGS += -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 + +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) \ + $(LOCAL_PATH)/CCBReader \ + $(LOCAL_PATH)/GUI/CCControlExtension \ + $(LOCAL_PATH)/GUI/CCScrollView \ + $(LOCAL_PATH)/network \ + $(LOCAL_PATH)/LocalStorage + +include $(BUILD_STATIC_LIBRARY) + +$(call import-module,cocos2dx) +$(call import-module,CocosDenshion/android) +$(call import-module,cocos2dx/platform/third_party/android/prebuilt/libcurl) +$(call import-module,external/Box2D) +$(call import-module,external/chipmunk) +$(call import-module,external/libwebsockets/android) \ No newline at end of file diff --git a/tools/pylib/PathUtils.py b/tools/pylib/PathUtils.py new file mode 100644 index 0000000000..abac8cf829 --- /dev/null +++ b/tools/pylib/PathUtils.py @@ -0,0 +1,86 @@ +#!/usr/bin.python +''' some common path and file operation ''' +import os.path +import re +import types +import fileinput +import cStringIO + + +class PathUtils: + + def __init__(self, root): + self.__root = root + + def __check_file_matchs(self, filePath): + + #normalize the path + realFilePath = os.path.abspath(filePath) + + if not os.path.isfile(realFilePath): + return False + + curDir, fileName = os.path.split(realFilePath) + + # check dir is exclude or not + for dir in self.__exclude: + dir = os.path.abspath(os.path.join(self.__root, dir)) + if os.path.isdir(dir) and os.path.isdir(curDir[:len(dir)]): + if os.path.samefile(dir, curDir[:len(dir)]): + return False + + if self.__rep.match(fileName): + # check file is exclude or not + for file in self.__exclude: + if os.path.isfile(os.path.join(self.__root, file)): + if os.path.samefile(realFilePath, os.path.join(self.__root, file)): + return False + + return True + + return False + + + def __walk_collect_files(self, lst, dirname, names): + for name in names: + if self.__check_file_matchs(os.path.join(dirname, name)): + if type(lst) is types.ListType: + lst += [os.path.abspath(os.path.join(dirname, name))] + + def set_root(self, root): + "set the root path" + self._root = root + + def find_files(self, pathes, suffixes = [], exclude = []): + "find files in pathes(a list) with suffixes. It will not collect files your specified in exclude. all of these pathes passed in must be relative to root" + lst = [] + + # rep generate with params to search the files + repStr = cStringIO.StringIO() + repStr.write(".+") + for i, suffix in enumerate(suffixes): + if i == 0: + repStr.write("\.(?:(?:") + else: + repStr.write("|(?:") + + repStr.write(suffix) + + if i == len(suffixes) - 1: + repStr.write("))$") + else: + repStr.write(")") + + self.__rep = re.compile(repStr.getvalue()) + repStr.close() + self.__exclude = exclude + + # find files + for path in pathes: + path = os.path.join(self.__root, path) + if os.path.isdir(path): + os.path.walk(path, self.__walk_collect_files, lst) + else: + lst += [os.path.abspath(path)] + + return lst diff --git a/tools/pylib/__init__.py b/tools/pylib/__init__.py new file mode 100644 index 0000000000..e69de29bb2 From 29d0bab0d3d7285107f0171f14ba7486e0a716a7 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Wed, 21 Aug 2013 21:12:32 -0700 Subject: [PATCH 068/126] fixes memory leak! and double-autorelease on Dicts (on mac) --- cocos2dx/cocoa/CCDictionary.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/cocos2dx/cocoa/CCDictionary.cpp b/cocos2dx/cocoa/CCDictionary.cpp index 96156f8c1c..d2ff1b2d86 100644 --- a/cocos2dx/cocoa/CCDictionary.cpp +++ b/cocos2dx/cocoa/CCDictionary.cpp @@ -369,7 +369,6 @@ Dictionary* Dictionary::create() bool Dictionary::init() { - retain(); return true; } @@ -390,9 +389,7 @@ void Dictionary::acceptVisitor(DataVisitor &visitor) Dictionary* Dictionary::createWithContentsOfFile(const char *pFileName) { - Dictionary* pRet = createWithContentsOfFileThreadSafe(pFileName); - pRet->autorelease(); - return pRet; + return createWithContentsOfFileThreadSafe(pFileName); } bool Dictionary::writeToFile(const char *fullPath) From 0e3d0febc7aee2af63eeeb5e02feccbedff7d487 Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Thu, 22 Aug 2013 13:39:05 +0800 Subject: [PATCH 069/126] issue #2433:Modify platform config --- scripting/lua/proj.android/Android.mk | 5 +++ scripting/lua/proj.emscripten/Makefile | 7 +++- scripting/lua/proj.linux/Makefile | 7 +++- scripting/lua/proj.qt5/lua.pro | 1 + scripting/lua/proj.win32/liblua.vcxproj | 12 ++++++- .../lua/proj.win32/liblua.vcxproj.filters | 33 +++++++++++++++++++ 6 files changed, 62 insertions(+), 3 deletions(-) diff --git a/scripting/lua/proj.android/Android.mk b/scripting/lua/proj.android/Android.mk index 34ee333ad3..ed6186dc20 100644 --- a/scripting/lua/proj.android/Android.mk +++ b/scripting/lua/proj.android/Android.mk @@ -17,6 +17,11 @@ LOCAL_SRC_FILES := ../cocos2dx_support/CCLuaBridge.cpp \ ../cocos2dx_support/LuaOpengl.cpp \ ../cocos2dx_support/LuaScrollView.cpp \ ../cocos2dx_support/LuaScriptHandlerMgr.cpp \ + ../cocos2dx_support/LuaBasicConversions.cpp \ + ../cocos2dx_support/generated/lua_cocos2dx_auto.cpp \ + ../cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp \ + ../cocos2dx_support/lua_cocos2dx_manual.cpp \ + ../cocos2dx_support/lua_cocos2dx_extension_manual.cpp \ ../tolua/tolua_event.c \ ../tolua/tolua_is.c \ ../tolua/tolua_map.c \ diff --git a/scripting/lua/proj.emscripten/Makefile b/scripting/lua/proj.emscripten/Makefile index 794d1ee6bb..1c052e6d28 100644 --- a/scripting/lua/proj.emscripten/Makefile +++ b/scripting/lua/proj.emscripten/Makefile @@ -49,7 +49,12 @@ SOURCES = ../lua/lapi.o \ ../cocos2dx_support/Lua_extensions_CCB.cpp \ ../cocos2dx_support/LuaOpengl.cpp \ ../cocos2dx_support/LuaScrollView.cpp \ - ../cocos2dx_support/LuaScriptHandlerMgr.cpp + ../cocos2dx_support/LuaScriptHandlerMgr.cpp \ + ../cocos2dx_support/LuaBasicConversions.cpp \ + ../cocos2dx_support/generated/lua_cocos2dx_auto.cpp \ + ../cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp \ + ../cocos2dx_support/lua_cocos2dx_manual.cpp \ + ../cocos2dx_support/lua_cocos2dx_extension_manual.cpp include ../../../cocos2dx/proj.emscripten/cocos2dx.mk diff --git a/scripting/lua/proj.linux/Makefile b/scripting/lua/proj.linux/Makefile index d1d9149d53..f8bb757e35 100644 --- a/scripting/lua/proj.linux/Makefile +++ b/scripting/lua/proj.linux/Makefile @@ -49,7 +49,12 @@ SOURCES = ../lua/lapi.o \ ../cocos2dx_support/Lua_extensions_CCB.cpp \ ../cocos2dx_support/LuaOpengl.cpp \ ../cocos2dx_support/LuaScrollView.cpp \ - ../cocos2dx_support/LuaScriptHandlerMgr.cpp + ../cocos2dx_support/LuaScriptHandlerMgr.cpp \ + ../cocos2dx_support/LuaBasicConversions.cpp \ + ../cocos2dx_support/generated/lua_cocos2dx_auto.cpp \ + ../cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp \ + ../cocos2dx_support/lua_cocos2dx_manual.cpp \ + ../cocos2dx_support/lua_cocos2dx_extension_manual.cpp include ../../../cocos2dx/proj.linux/cocos2dx.mk diff --git a/scripting/lua/proj.qt5/lua.pro b/scripting/lua/proj.qt5/lua.pro index 6af3270aeb..67f570d687 100644 --- a/scripting/lua/proj.qt5/lua.pro +++ b/scripting/lua/proj.qt5/lua.pro @@ -9,6 +9,7 @@ SOURCES += $$files(../lua/*.c) SOURCES += $$files(../tolua/*.c) SOURCES += $$files(../cocos2dx_support/*.c) SOURCES += $$files(../cocos2dx_support/*.cpp) +SOURCES += $$files(../cocos2dx_support/generated/*.cpp) DEFINES += CC_TARGET_OS_MAC diff --git a/scripting/lua/proj.win32/liblua.vcxproj b/scripting/lua/proj.win32/liblua.vcxproj index 244e64191c..fee462e804 100644 --- a/scripting/lua/proj.win32/liblua.vcxproj +++ b/scripting/lua/proj.win32/liblua.vcxproj @@ -62,7 +62,7 @@ Disabled - $(ProjectDir)..\..\..\cocos2dx;$(ProjectDir)..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32\pthread;$(ProjectDir)..\..\..\CocosDenshion\include;$(ProjectDir)..\..\..\extensions;$(ProjectDir)..\..\..\extensions\network;$(ProjectDir)..\..\..\external\libwebsockets\win32\include;$(ProjectDir)..\tolua;$(ProjectDir)..\luajit\include;%(AdditionalIncludeDirectories) + $(ProjectDir)..\..\..\cocos2dx;$(ProjectDir)..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32\pthread;$(ProjectDir)..\..\..\CocosDenshion\include;$(ProjectDir)..\..\..\extensions;$(ProjectDir)..\..\..\extensions\network;$(ProjectDir)..\..\..\external\libwebsockets\win32\include;$(ProjectDir)..\tolua;$(ProjectDir)..\luajit\include;$(ProjectDir)..\cocos2dx_support\generated;$(ProjectDir)..\cocos2dx_support;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;_DEBUG;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false EnableFastChecks @@ -128,10 +128,15 @@ xcopy /Y /Q "$(ProjectDir)..\luajit\win32\*.*" "$(OutDir)" + + + + + @@ -148,10 +153,15 @@ xcopy /Y /Q "$(ProjectDir)..\luajit\win32\*.*" "$(OutDir)" + + + + + diff --git a/scripting/lua/proj.win32/liblua.vcxproj.filters b/scripting/lua/proj.win32/liblua.vcxproj.filters index 9a30acb82f..0c50a3c7f7 100644 --- a/scripting/lua/proj.win32/liblua.vcxproj.filters +++ b/scripting/lua/proj.win32/liblua.vcxproj.filters @@ -13,6 +13,9 @@ {b7025611-420a-4414-b567-f7496eec5f57} + + {19f563f0-e0ff-4500-890b-1755841d4ddb} + @@ -69,6 +72,21 @@ cocos2dx_support + + cocos2dx_support + + + cocos2dx_support + + + cocos2dx_support + + + cocos2dx_support\generated + + + cocos2dx_support\generated + @@ -128,5 +146,20 @@ cocos2dx_support + + cocos2dx_support + + + cocos2dx_support + + + cocos2dx_support + + + cocos2dx_support\generated + + + cocos2dx_support\generated + \ No newline at end of file From ad23ec4a0f793cee71ae034931abe43815b95856 Mon Sep 17 00:00:00 2001 From: boyu0 Date: Thu, 22 Aug 2013 13:40:57 +0800 Subject: [PATCH 070/126] #closed #2434: refactor LocalVarToAuto.py to use the PathUtils and fix some errors --- .../Classes/Texture2dTest/Texture2dTest.cpp | 12 +- tools/android_generator/android_generator.py | 8 +- tools/localvartoauto/LocalVarToAuto.py | 336 +++++++----------- tools/pylib/PathUtils.py | 2 +- 4 files changed, 151 insertions(+), 207 deletions(-) diff --git a/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp b/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp index 161810ad64..8184bc1467 100644 --- a/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp +++ b/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp @@ -2072,9 +2072,9 @@ std::string TextureS3TCDxt5::subtitle() //Implement of ATITC TextureATITCRGB::TextureATITCRGB() { - Sprite *sprite = Sprite::create("Images/test_256x256_ATC_RGB_mipmaps.ktx"); + auto sprite = Sprite::create("Images/test_256x256_ATC_RGB_mipmaps.ktx"); - Size size = Director::getInstance()->getWinSize(); + auto size = Director::getInstance()->getWinSize(); sprite->setPosition(Point(size.width / 2, size.height / 2)); addChild(sprite); @@ -2090,9 +2090,9 @@ std::string TextureATITCRGB::subtitle() TextureATITCExplicit::TextureATITCExplicit() { - Sprite *sprite = Sprite::create("Images/test_256x256_ATC_RGBA_Explicit_mipmaps.ktx"); + auto sprite = Sprite::create("Images/test_256x256_ATC_RGBA_Explicit_mipmaps.ktx"); - Size size = Director::getInstance()->getWinSize(); + auto size = Director::getInstance()->getWinSize(); sprite->setPosition(Point(size.width / 2, size.height / 2)); addChild(sprite); @@ -2108,9 +2108,9 @@ std::string TextureATITCExplicit::subtitle() TextureATITCInterpolated::TextureATITCInterpolated() { - Sprite *sprite = Sprite::create("Images/test_256x256_ATC_RGBA_Interpolated_mipmaps.ktx"); + auto sprite = Sprite::create("Images/test_256x256_ATC_RGBA_Interpolated_mipmaps.ktx"); - Size size = Director::getInstance()->getWinSize(); + auto size = Director::getInstance()->getWinSize(); sprite->setPosition(Point(size.width / 2, size.height /2)); addChild(sprite); diff --git a/tools/android_generator/android_generator.py b/tools/android_generator/android_generator.py index 2eefcd54e7..188591af4e 100644 --- a/tools/android_generator/android_generator.py +++ b/tools/android_generator/android_generator.py @@ -5,8 +5,12 @@ import os import os.path import cStringIO -sys.path.append(os.path.abspath("../pylib")) -import PathUtils +try: + import PathUtils +except ImportError, e: + import os.path + sys.path.append(os.path.abspath("../pylib")) + import PathUtils COCOS_ROOT = "../../" diff --git a/tools/localvartoauto/LocalVarToAuto.py b/tools/localvartoauto/LocalVarToAuto.py index fa8eddfeee..655980d335 100755 --- a/tools/localvartoauto/LocalVarToAuto.py +++ b/tools/localvartoauto/LocalVarToAuto.py @@ -32,12 +32,20 @@ # ANOTHER_A_NAME* a = new A(); # We will not convert it to auto for you. +import sys import os.path import re import types import fileinput import cStringIO +try: + import PathUtils +except ImportError, e: + import os.path + sys.path.append(os.path.abspath("../pylib")) + import PathUtils + # The cocos root entry. We will aspect it as parent dictionary, all other file or dictionary # relative path are base on this. COCOS_ROOT = "../../" @@ -48,8 +56,6 @@ CXX_DIR = ("Samples",) # The dictionaries and files with class declaration you don't want to search, you can exclude some third party # dictionaries in here EXCLUDE = ("cocos2dx/platform/third_party/",) -# The extra dictionaries and files with class declaration. You can add some extra .h files in it -INCLUDE = () # The macroes use with declare class, like "class CC_DLL A{}" MACROES_WITH_CLASS = ("CC_DLL",) # The strings represent the null pointer, because you set a point to null, we will not change that @@ -57,218 +63,152 @@ MACROES_WITH_CLASS = ("CC_DLL",) NULL_PTR = ("0", "NULL", "nullptr") # normalize the path -COCOS_ROOT = os.path.abspath(COCOS_ROOT) - -def check_file_match_rep(repString, filePath): - '''Check the file with filepath is match the repstring or not. - Return True if match, return False if not. - NOTE: it will check the EXCLUDE files and directories, if the file is in the EXCLUDE directories - or is a EXCLUDE file, it will return False.''' - - #normalize the path - realFilePath = os.path.abspath(filePath) - - if not os.path.isfile(realFilePath): - return False - - rep = re.compile(repString) - curDir, fileName = os.path.split(realFilePath) - - # check dir is exclude or not - for dir in EXCLUDE: - dir = os.path.abspath(os.path.join(COCOS_ROOT, dir)) - if os.path.isdir(dir) and os.path.isdir(curDir[:len(dir)]): - if os.path.samefile(dir, curDir[:len(dir)]): - return False - - if rep.match(fileName): - # check file is exclude or not - for file in EXCLUDE: - if os.path.isfile(os.path.join(COCOS_ROOT, file)): - if os.path.samefile(realFilePath, os.path.join(COCOS_ROOT, file)): - return False - - return True - - return False - -def walk_collect_h_files(lst, dirname, names): - "collect *.h files and insert into lst" - - for name in names: - if check_file_match_rep(".*\.h$", os.path.join(dirname, name)): - if type(lst) is types.ListType: - lst += [os.path.relpath(os.path.abspath(os.path.join(dirname, name)), COCOS_ROOT)] - -def walk_collect_cxx_files(lst, dirname, names): - "collect *.cpp and *.mm files and insert into lst" - - for name in names: - if check_file_match_rep(".*\.(?:cpp)|(?:mm)$", os.path.join(dirname, name)): - if type(lst) is types.ListType: - lst += [os.path.relpath(os.path.abspath(os.path.join(dirname, name)), COCOS_ROOT)] +COCOS_ROOT = os.path.abspath(os.path.join(os.curdir, COCOS_ROOT)) def collect_class_name(filename, st): - "collect all class name appear in the file" + "collect all class name appear in the file" - #generate the rep - if not hasattr(collect_class_name, "rep"): - repString = cStringIO.StringIO() - repString.write("(?:\s+|^)class\s+") - for word in MACROES_WITH_CLASS: - repString.write(word + "\s+") - repString.write("(?P\w+)") + #generate the rep + if not hasattr(collect_class_name, "rep"): + repString = cStringIO.StringIO() + repString.write("(?:\s+|^)class\s+") + for word in MACROES_WITH_CLASS: + repString.write(word + "\s+") + repString.write("(?P\w+)") - collect_class_name.rep = re.compile(repString.getvalue()) - repString.close() + collect_class_name.rep = re.compile(repString.getvalue()) + repString.close() - f = open(os.path.join(COCOS_ROOT, filename)) - try: - for line in f: - res = collect_class_name.rep.match(line) - if res: - if type(st) == type(set()): - st.add(res.group("cls_name")) - finally: - f.close() + f = open(os.path.join(COCOS_ROOT, filename)) + try: + for line in f: + res = collect_class_name.rep.match(line) + if res: + if type(st) == type(set()): + st.add(res.group("cls_name")) + finally: + f.close() def change_local_classvarname_to_auto(filename, rep, change): - "change all local class variable name to auto" - f = open(filename) + "change all local class variable name to auto" + f = open(filename) - content = None - changed = False - # read the file, change it, and save it to content - try: - content = cStringIO.StringIO() - changed = False - - for line in f: - i = 0 - #start to replace - while True: - result = rep.match(line, i) - # founded - if result: - changed = True - #find the matched string where to start - startIndex = line.index(result.group(0)) - #replace the change part - line = line.replace(result.group(change), "auto ", startIndex) - i += 1 - else: - break - #write the result to content - content.write(line) - finally: - f.close() - if changed: - f = open(filename, "w") - f.write(content.getvalue()) - f.close() - content.close() + content = None + changed = False + # read the file, change it, and save it to content + try: + content = cStringIO.StringIO() + changed = False + + for line in f: + i = 0 + #start to replace + while True: + result = rep.match(line, i) + # founded + if result: + changed = True + #find the matched string where to start + startIndex = line.index(result.group(0)) + #replace the change part + line = line.replace(result.group(change), "auto ", startIndex) + i += 1 + else: + break + #write the result to content + content.write(line) + finally: + f.close() + if changed: + f = open(filename, "w") + f.write(content.getvalue()) + f.close() + content.close() def main(): - print ".......VARIABLES......." - print "COCOS_ROOT:", - print COCOS_ROOT - print "H_DIR:", - print H_DIR - print "CXX_DIR:", - print CXX_DIR - print "EXCLUDE:", - print EXCLUDE - print "INCLUDE:", - print INCLUDE - print ".......VARIABLES END......" + print ".......VARIABLES......." + print "COCOS_ROOT:", + print COCOS_ROOT + print "H_DIR:", + print H_DIR + print "CXX_DIR:", + print CXX_DIR + print "EXCLUDE:", + print EXCLUDE + print ".......VARIABLES END......" + + utils = PathUtils.PathUtils(COCOS_ROOT) + # save the .h file for search + hfiles = utils.find_files(H_DIR, ("h",), EXCLUDE) + # save the .cpp and .mm file for search + cxxfiles = utils.find_files(CXX_DIR, ("cpp", "mm")) + + print "search class declarations" + # the class set, ignore the namespace + classes = set() + for file in hfiles: + collect_class_name(file, classes) + print "search end" + + # generate example rep: + # (\W+|^)(?P\S*(?:Class1|Class2|class3)\s*(?:\*+|\s+)\s*)\w+\s*=(?!\s*(?:0|NULL|nullptr)\s*\W) + # examples: + # Class1* c = new Class1() ; //match + # Class1* c; //not match + # Class1* c = nullptr; //not match + # Class1* c = nullptrabc; //match + # Class1 c; //not match + # Class1 c = Class1(); //match + def gen_rep(keyWord): + s = cStringIO.StringIO() + s.write("(?:\W+|^)(?P<") + s.write(keyWord) + s.write(">(?:") + + # add classes want to match + first = True + for cls in classes: + if first: + first = False + else: + s.write("|") + + s.write(cls) + + s.write(")\s*(?:\*+|\s+)\s*)\w+\s*=(?!\s*(?:") + + # let nullptr assignment not to convert + first = True + for nullptr in NULL_PTR: + if first: + first = False + else: + s.write("|") + + s.write(nullptr) + + s.write(")\s*\W)") + + result = s.getvalue() + s.close() + + print "generated regular expression is:" + print result + return re.compile(result) - # save the .h file for search - hfiles = [] - # save the .cpp and .mm file for search - cxxfiles = [] - - print "search .h files..." - for dir in H_DIR: - os.path.walk(os.path.join(COCOS_ROOT, dir), walk_collect_h_files, hfiles) - - for dir in INCLUDE: - if os.path.isdir(os.path.join(COCOS_ROOT, dir)): - os.path.walk(os.path.join(COCOS_ROOT, dir), walk_collect_h_files, hfiles) - else: - hfiles += [dir] - print "search end" - - print "search .cxx files..." - for dir in CXX_DIR: - os.path.walk(os.path.join(COCOS_ROOT, dir), walk_collect_cxx_files, cxxfiles) - print "search end" - - print "search class declarations" - # the class set, ignore the namespace - classes = set() - for file in hfiles: - collect_class_name(file, classes) - print "search end" - - # generate example rep: - # (\W+|^)(?P\S*(?:Class1|Class2|class3)\s*(?:\*+|\s+)\s*)\w+\s*=(?!\s*(?:0|NULL|nullptr)\s*\W) - # examples: - # Class1* c = new Class1() ; //match - # Class1* c; //not match - # Class1* c = nullptr; //not match - # Class1* c = nullptrabc; //match - # Class1 c; //not match - # Class1 c = Class1(); //match - def gen_rep(keyWord): - s = cStringIO.StringIO() - s.write("(?:\W+|^)(?P<") - s.write(keyWord) - s.write(">\S*(?:") - - # add classes want to match - first = True - for cls in classes: - if first: - first = False - else: - s.write("|") - - s.write(cls) - - s.write(")\s*(?:\*+|\s+)\s*)\w+\s*=(?!\s*(?:") - - # let nullptr assignment not to convert - first = True - for nullptr in NULL_PTR: - if first: - first = False - else: - s.write("|") - - s.write(nullptr) - - s.write(")\s*\W)") - - result = s.getvalue() - s.close() - - print "generated regular expression is:" - print result - return re.compile(result) - - repWord = "change" - rep = gen_rep(repWord) + repWord = "change" + rep = gen_rep(repWord) - print "scan and edit the .cxx files..." - # scan the cxx files - for file in cxxfiles: - change_local_classvarname_to_auto(os.path.join(COCOS_ROOT, file), rep, repWord) + print "scan and edit the .cxx files..." + # scan the cxx files + for file in cxxfiles: + change_local_classvarname_to_auto(os.path.join(COCOS_ROOT, file), rep, repWord) - print "success!" + print "success!" if __name__ == "__main__": - main() + main() diff --git a/tools/pylib/PathUtils.py b/tools/pylib/PathUtils.py index abac8cf829..12237a1e5e 100644 --- a/tools/pylib/PathUtils.py +++ b/tools/pylib/PathUtils.py @@ -51,7 +51,7 @@ class PathUtils: "set the root path" self._root = root - def find_files(self, pathes, suffixes = [], exclude = []): + def find_files(self, pathes, suffixes = (), exclude = ()): "find files in pathes(a list) with suffixes. It will not collect files your specified in exclude. all of these pathes passed in must be relative to root" lst = [] From de68d35f4b73695469a95c6b6ab96f9d27ee50b6 Mon Sep 17 00:00:00 2001 From: boyu0 Date: Thu, 22 Aug 2013 13:49:22 +0800 Subject: [PATCH 071/126] closed #2434: change name "android_generator" to "android_mk_generator --- .../android_mk_generator.py} | 0 .../cocos2d_template.mk | 0 .../cpptest_template.mk | 0 .../extensions_template.mk | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename tools/{android_generator/android_generator.py => android_mk_generator/android_mk_generator.py} (100%) rename tools/{android_generator => android_mk_generator}/cocos2d_template.mk (100%) rename tools/{android_generator => android_mk_generator}/cpptest_template.mk (100%) rename tools/{android_generator => android_mk_generator}/extensions_template.mk (100%) diff --git a/tools/android_generator/android_generator.py b/tools/android_mk_generator/android_mk_generator.py similarity index 100% rename from tools/android_generator/android_generator.py rename to tools/android_mk_generator/android_mk_generator.py diff --git a/tools/android_generator/cocos2d_template.mk b/tools/android_mk_generator/cocos2d_template.mk similarity index 100% rename from tools/android_generator/cocos2d_template.mk rename to tools/android_mk_generator/cocos2d_template.mk diff --git a/tools/android_generator/cpptest_template.mk b/tools/android_mk_generator/cpptest_template.mk similarity index 100% rename from tools/android_generator/cpptest_template.mk rename to tools/android_mk_generator/cpptest_template.mk diff --git a/tools/android_generator/extensions_template.mk b/tools/android_mk_generator/extensions_template.mk similarity index 100% rename from tools/android_generator/extensions_template.mk rename to tools/android_mk_generator/extensions_template.mk From 83f7835708d3d01c8243c7d29f4efbc71b29a634 Mon Sep 17 00:00:00 2001 From: boyu0 Date: Thu, 22 Aug 2013 14:03:25 +0800 Subject: [PATCH 072/126] issue #2434: Delete unused method dirs and find_files in Android.mk template --- extensions/Android.mk | 3 --- samples/Cpp/TestCpp/Android.mk | 3 --- tools/android_mk_generator/cpptest_template.mk | 3 --- tools/android_mk_generator/extensions_template.mk | 3 --- 4 files changed, 12 deletions(-) diff --git a/extensions/Android.mk b/extensions/Android.mk index e90edc34c2..bead6fce42 100644 --- a/extensions/Android.mk +++ b/extensions/Android.mk @@ -5,9 +5,6 @@ LOCAL_MODULE := cocos_extension_static LOCAL_MODULE_FILENAME := libextension -dirs := $(shell find $(LOCAL_PATH) -type d -print) -find_files = $(subst $(LOCAL_PATH)/,,$(wildcard $(dir)/*.cpp)) - LOCAL_SRC_FILES := \ CCDeprecated-ext.cpp \ AssetsManager/AssetsManager.cpp \ diff --git a/samples/Cpp/TestCpp/Android.mk b/samples/Cpp/TestCpp/Android.mk index a59eee0b5a..e892df47f1 100644 --- a/samples/Cpp/TestCpp/Android.mk +++ b/samples/Cpp/TestCpp/Android.mk @@ -6,9 +6,6 @@ LOCAL_MODULE := cocos_testcpp_common LOCAL_MODULE_FILENAME := libtestcppcommon -dirs := $(shell find $(LOCAL_PATH)/Classes -type d -print) -find_files = $(subst $(LOCAL_PATH)/,,$(wildcard $(dir)/*.cpp)) - LOCAL_SRC_FILES := \ Classes/AppDelegate.cpp \ Classes/BaseTest.cpp \ diff --git a/tools/android_mk_generator/cpptest_template.mk b/tools/android_mk_generator/cpptest_template.mk index 0697c3eef4..1fac8ab4a1 100644 --- a/tools/android_mk_generator/cpptest_template.mk +++ b/tools/android_mk_generator/cpptest_template.mk @@ -6,9 +6,6 @@ LOCAL_MODULE := cocos_testcpp_common LOCAL_MODULE_FILENAME := libtestcppcommon -dirs := $(shell find $(LOCAL_PATH)/Classes -type d -print) -find_files = $(subst $(LOCAL_PATH)/,,$(wildcard $(dir)/*.cpp)) - LOCAL_SRC_FILES := %s LOCAL_C_INCLUDES := $(LOCAL_PATH)/Classes diff --git a/tools/android_mk_generator/extensions_template.mk b/tools/android_mk_generator/extensions_template.mk index 3bb032ee06..8c8a1daff1 100644 --- a/tools/android_mk_generator/extensions_template.mk +++ b/tools/android_mk_generator/extensions_template.mk @@ -5,9 +5,6 @@ LOCAL_MODULE := cocos_extension_static LOCAL_MODULE_FILENAME := libextension -dirs := $(shell find $(LOCAL_PATH) -type d -print) -find_files = $(subst $(LOCAL_PATH)/,,$(wildcard $(dir)/*.cpp)) - LOCAL_SRC_FILES :=%s LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static From 5f6d9815ca6d3b0ab3660c6da552d1d4cfde649d Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Thu, 22 Aug 2013 15:06:34 +0800 Subject: [PATCH 073/126] issue #2433:Modify platform config and some test samples --- .../CurrentLanguageTest.lua | 24 +++++++++---------- scripting/lua/cocos2dx_support/CCLuaStack.cpp | 2 +- .../lua_cocos2dx_auto.cpp.REMOVED.git-id | 2 +- .../lua_cocos2dx_auto_api.js.REMOVED.git-id | 2 +- scripting/lua/proj.android/Android.mk | 7 ++++-- scripting/lua/proj.emscripten/Makefile | 4 ++-- scripting/lua/proj.linux/Makefile | 2 +- scripting/lua/proj.qt5/lua.pro | 2 ++ scripting/lua/script/Cocos2dConstants.lua | 13 ++++++++++ tools/tolua/cocos2dx.ini | 3 ++- 10 files changed, 40 insertions(+), 21 deletions(-) diff --git a/samples/Lua/TestLua/Resources/luaScript/CurrentLanguageTest/CurrentLanguageTest.lua b/samples/Lua/TestLua/Resources/luaScript/CurrentLanguageTest/CurrentLanguageTest.lua index 53812a5108..b89f7da164 100644 --- a/samples/Lua/TestLua/Resources/luaScript/CurrentLanguageTest/CurrentLanguageTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/CurrentLanguageTest/CurrentLanguageTest.lua @@ -9,29 +9,29 @@ local function CurrentLanguageTest() local currentLanguageType = cc.Application:getInstance():getCurrentLanguage() - if currentLanguageType == kLanguageEnglish then + if currentLanguageType == cc.LANGUAGE_ENGLISH then labelLanguage:setString("current language is English") - elseif currentLanguageType == kLanguageChinese then + elseif currentLanguageType == cc.LANGUAGE_CHINESE then labelLanguage:setString("current language is Chinese") - elseif currentLanguageType == kLanguageFrench then + elseif currentLanguageType == cc.LANGUAGE_FRENCH then labelLanguage:setString("current language is French") - elseif currentLanguageType == kLanguageGerman then + elseif currentLanguageType == cc.LANGUAGE_GERMAN then labelLanguage:setString("current language is German") - elseif currentLanguageType == kLanguageItalian then + elseif currentLanguageType == cc.LANGUAGE_ITALIAN then labelLanguage:setString("current language is Italian") - elseif currentLanguageType == kLanguageRussian then + elseif currentLanguageType == cc.LANGUAGE_RUSSIAN then labelLanguage:setString("current language is Russian") - elseif currentLanguageType == kLanguageSpanish then + elseif currentLanguageType == cc.LANGUAGE_SPANISH then labelLanguage:setString("current language is Spanish") - elseif currentLanguageType == kLanguageKorean then + elseif currentLanguageType == cc.LANGUAGE_KOREAN then labelLanguage:setString("current language is Korean") - elseif currentLanguageType == kLanguageJapanese then + elseif currentLanguageType == cc.LANGUAGE_JAPANESE then labelLanguage:setString("current language is Japanese") - elseif currentLanguageType == kLanguageHungarian then + elseif currentLanguageType == cc.LANGUAGE_HUNGARIAN then labelLanguage:setString("current language is Hungarian") - elseif currentLanguageType == kLanguagePortuguese then + elseif currentLanguageType == cc.LANGUAGE_PORTUGUESE then labelLanguage:setString("current language is Portuguese") - elseif currentLanguageType == kLanguageArabic then + elseif currentLanguageType == cc.LANGUAGE_ARABIC then labelLanguage:setString("current language is Arabic") end ret:addChild(labelLanguage) diff --git a/scripting/lua/cocos2dx_support/CCLuaStack.cpp b/scripting/lua/cocos2dx_support/CCLuaStack.cpp index 947b644b4f..143534d437 100644 --- a/scripting/lua/cocos2dx_support/CCLuaStack.cpp +++ b/scripting/lua/cocos2dx_support/CCLuaStack.cpp @@ -129,9 +129,9 @@ bool LuaStack::init(void) luaL_register(_state, "_G", global_functions); g_luaType.clear(); register_all_cocos2dx(_state); - tolua_opengl_open(_state); register_all_cocos2dx_extension(_state); register_cocos2dx_extension_CCBProxy(_state); + tolua_opengl_open(_state); register_all_cocos2dx_manual(_state); register_all_cocos2dx_extension_manual(_state); #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id index eaff4b07d8..50f2ae2029 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id @@ -1 +1 @@ -9665294361d65c1a40aa195a6d048f4a627b2065 \ No newline at end of file +e4cde349657e805611bb37bf5123dac55dad4381 \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id index 23c1ee6796..5f8959c762 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id @@ -1 +1 @@ -65dd9a6009e08176e2d71c2eda75f2d1319b38c2 \ No newline at end of file +f36d9af5f8cb5dd623c2963b6c433e90bbad9570 \ No newline at end of file diff --git a/scripting/lua/proj.android/Android.mk b/scripting/lua/proj.android/Android.mk index ed6186dc20..0b6cb93bd9 100644 --- a/scripting/lua/proj.android/Android.mk +++ b/scripting/lua/proj.android/Android.mk @@ -31,7 +31,7 @@ LOCAL_SRC_FILES := ../cocos2dx_support/CCLuaBridge.cpp \ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../luajit/include \ $(LOCAL_PATH)/../tolua \ - $(LOCAL_PATH)/../cocos2dx_support + $(LOCAL_PATH)/../cocos2dx_support LOCAL_C_INCLUDES := $(LOCAL_PATH)/ \ @@ -43,7 +43,10 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/ \ $(LOCAL_PATH)/../../../cocos2dx/platform/android \ $(LOCAL_PATH)/../../../cocos2dx/kazmath/include \ $(LOCAL_PATH)/../../../CocosDenshion/include \ - $(LOCAL_PATH)/../../../extensions + $(LOCAL_PATH)/../../../extensions \ + $(LOCAL_PATH)/../cocos2dx_support \ + $(LOCAL_PATH)/../cocos2dx_support/generated + LOCAL_WHOLE_STATIC_LIBRARIES := luajit_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static diff --git a/scripting/lua/proj.emscripten/Makefile b/scripting/lua/proj.emscripten/Makefile index 1c052e6d28..7e3af98d23 100644 --- a/scripting/lua/proj.emscripten/Makefile +++ b/scripting/lua/proj.emscripten/Makefile @@ -1,7 +1,7 @@ TARGET = liblua.so -INCLUDES += -I.. -I../lua -I../tolua \ - -I../Classes -I../../../CocosDenshion/include -I../../../extensions +INCLUDES += -I.. -I../lua -I../tolua -I../cocos2dx_support -I../cocos2dx_support/generated \ + -I../Classes -I../../../CocosDenshion/include -I../../../extensions SOURCES = ../lua/lapi.o \ ../lua/lauxlib.c \ diff --git a/scripting/lua/proj.linux/Makefile b/scripting/lua/proj.linux/Makefile index f8bb757e35..29042d516f 100644 --- a/scripting/lua/proj.linux/Makefile +++ b/scripting/lua/proj.linux/Makefile @@ -1,6 +1,6 @@ TARGET = liblua.so -INCLUDES += -I.. -I../lua -I../tolua \ +INCLUDES += -I.. -I../lua -I../tolua -I../cocos2dx_support -I../cocos2dx_support/generated \ -I../Classes -I../../../CocosDenshion/include -I../../../extensions -I../../../external/chipmunk/include/chipmunk SOURCES = ../lua/lapi.o \ diff --git a/scripting/lua/proj.qt5/lua.pro b/scripting/lua/proj.qt5/lua.pro index 67f570d687..c6a146d36e 100644 --- a/scripting/lua/proj.qt5/lua.pro +++ b/scripting/lua/proj.qt5/lua.pro @@ -24,6 +24,8 @@ INCLUDEPATH += ../../../cocos2dx/include INCLUDEPATH += ../../../cocos2dx INCLUDEPATH += ../../../cocos2dx/platform/qt5 INCLUDEPATH += ../../../cocos2dx/kazmath/include +INCLUDEPATH += ../cocos2dx_support +INCLUDEPATH += ../cocos2dx_support/generated # XXX SHAREDLIBS += -lextension diff --git a/scripting/lua/script/Cocos2dConstants.lua b/scripting/lua/script/Cocos2dConstants.lua index 98ebda3156..870f7bad5d 100644 --- a/scripting/lua/script/Cocos2dConstants.lua +++ b/scripting/lua/script/Cocos2dConstants.lua @@ -229,3 +229,16 @@ cc.EDITBOX_INPUT_FLAG_SENSITIVE = 1 cc.EDITBOX_INPUT_FLAG_INITIAL_CAPS_WORD = 2 cc.EDITBOX_INPUT_FLAG_INITIAL_CAPS_SENTENCE = 3 cc.EDITBOX_INPUT_FLAG_INITIAL_CAPS_ALL_CHARACTERS = 4 + +cc.LANGUAGE_ENGLISH = 0 +cc.LANGUAGE_CHINESE = 1 +cc.LANGUAGE_FRENCH = 2 +cc.LANGUAGE_ITALIAN = 3 +cc.LANGUAGE_GERMAN = 4 +cc.LANGUAGE_SPANISH = 5 +cc.LANGUAGE_RUSSIAN = 6 +cc.LANGUAGE_KOREAN = 7 +cc.LANGUAGE_JAPANESE = 8 +cc.LANGUAGE_HUNGARIAN = 9 +cc.LANGUAGE_PORTUGUESE = 10 +cc.LANGUAGE_ARABIC = 11 diff --git a/tools/tolua/cocos2dx.ini b/tools/tolua/cocos2dx.ini index 304af16ebe..abbf927ec7 100644 --- a/tools/tolua/cocos2dx.ini +++ b/tools/tolua/cocos2dx.ini @@ -123,7 +123,8 @@ rename_functions = SpriteFrameCache::[addSpriteFramesWithFile=addSpriteFrames ge Camera::[setUpXYZ=setUp setEyeXYZ=setEye setCenterXYZ=setCenter], TMXTiledMap::[layerNamed=getLayer objectGroupNamed=getObjectGroup propertyNamed=getProperty], ShaderCache::[programForKey=getProgram], - FileUtils::[loadFilenameLookupDictionaryFromFile=loadFilenameLookup] + FileUtils::[loadFilenameLookupDictionaryFromFile=loadFilenameLookup], + Director::[end=endToLua] rename_classes = ParticleSystemQuad::ParticleSystem, SimpleAudioEngine::AudioEngine From 9e34aae075ead1d50ab858ccdce14d677ec4abd6 Mon Sep 17 00:00:00 2001 From: boyu0 Date: Thu, 22 Aug 2013 16:45:40 +0800 Subject: [PATCH 074/126] closed #2434: Use the origin android.mk files instead use templates --- samples/Cpp/TestCpp/Android.mk | 2 +- .../android_mk_generator.py | 70 +++++++++++++------ .../android_mk_generator/cocos2d_template.mk | 55 --------------- tools/android_mk_generator/config.py | 16 +++++ .../android_mk_generator/cpptest_template.mk | 27 ------- .../extensions_template.mk | 36 ---------- 6 files changed, 66 insertions(+), 140 deletions(-) delete mode 100644 tools/android_mk_generator/cocos2d_template.mk create mode 100644 tools/android_mk_generator/config.py delete mode 100644 tools/android_mk_generator/cpptest_template.mk delete mode 100644 tools/android_mk_generator/extensions_template.mk diff --git a/samples/Cpp/TestCpp/Android.mk b/samples/Cpp/TestCpp/Android.mk index e892df47f1..e3036d7e67 100644 --- a/samples/Cpp/TestCpp/Android.mk +++ b/samples/Cpp/TestCpp/Android.mk @@ -6,7 +6,7 @@ LOCAL_MODULE := cocos_testcpp_common LOCAL_MODULE_FILENAME := libtestcppcommon -LOCAL_SRC_FILES := \ +LOCAL_SRC_FILES := \ Classes/AppDelegate.cpp \ Classes/BaseTest.cpp \ Classes/controller.cpp \ diff --git a/tools/android_mk_generator/android_mk_generator.py b/tools/android_mk_generator/android_mk_generator.py index 188591af4e..3aabfae992 100644 --- a/tools/android_mk_generator/android_mk_generator.py +++ b/tools/android_mk_generator/android_mk_generator.py @@ -4,45 +4,73 @@ import sys import os import os.path import cStringIO +import re try: import PathUtils except ImportError, e: - import os.path - sys.path.append(os.path.abspath("../pylib")) + sys.path.append(os.path.abspath(os.path.join(os.curdir, "../pylib"))) import PathUtils COCOS_ROOT = "../../" COCOS_ROOT = os.path.abspath(os.path.join(os.curdir, COCOS_ROOT)) -def gen_android_mk(tplfile, outfile, pathes, suffix = ("cpp",), exclude = ()): - "" - utils = PathUtils.PathUtils(os.path.abspath(COCOS_ROOT)) +def gen_android_mk(mkfile, pathes, suffix = ("c", "cpp",), exclude = ()): + utils = PathUtils.PathUtils(COCOS_ROOT) filelst = utils.find_files(pathes, suffix, exclude) - filestr = cStringIO.StringIO() + # generate file list string + filestrio = cStringIO.StringIO() for filename in filelst: - filestr.write(' \\\n') - filestr.write(os.path.relpath(filename, os.path.dirname(os.path.join(COCOS_ROOT, outfile)))) + filestrio.write(' \\\n') + filestrio.write(os.path.relpath(filename, os.path.dirname(os.path.join(COCOS_ROOT, mkfile)))) + filestrio.write('\n') + + # read mk file + file = open(os.path.join(COCOS_ROOT, mkfile)) + mkstrio = cStringIO.StringIO() + rep = re.compile("\s*LOCAL_SRC_FILES\s*:=") + try: + # read lines before encounter "LOCAL_EXPORT_C_INCLUDES" + for line in file: + if rep.match(line): + mkstrio.write("LOCAL_SRC_FILES :=") + break + else: + mkstrio.write(line) + #mkstrio.write('\n') - file = open(tplfile) - template = file.read() + # write file list + mkstrio.write(filestrio.getvalue()) + + # write remaining lines + delete = True if line[len(line) - 2] == '\\' else False + for line in file: + if delete: + delete = True if line[len(line) - 2] == '\\' else False + else: + mkstrio.write(line) +#mkstrio.write('\n') + finally: + file.close() + + + + file = open(os.path.join(COCOS_ROOT, mkfile), "w") + file.write(mkstrio.getvalue()) file.close() - file = open(os.path.join(COCOS_ROOT, outfile), "w") - print >>file, template %(filestr.getvalue()) - file.close() - - filestr.close() + filestrio.close() + mkstrio.close() def main(): - #generate cocos2d - gen_android_mk("./cocos2d_template.mk", "cocos2dx/Android.mk", ["cocos2dx/"], ["c", "cpp"], ["cocos2dx/platform/android", "cocos2dx/platform/emscripten", "cocos2dx/platform/ios", "cocos2dx/platform/linux", "cocos2dx/platform/mac", "cocos2dx/platform/nacl", "cocos2dx/platform/qt5", "cocos2dx/platform/tizen", "cocos2dx/platform/win32", "cocos2dx/label_nodes/CCFontCache.cpp", "cocos2dx/base_nodes/CCGLBufferedNode.cpp","cocos2dx/support/user_default/CCUserDefault.cpp"]) - #generate cpptest - gen_android_mk("./cpptest_template.mk", "samples/Cpp/TestCpp/Android.mk", ["samples/Cpp/TestCpp/Classes"]) - #generate extensions - gen_android_mk("./extensions_template.mk", "extensions/Android.mk", ["extensions/"], ["cpp"], ["extensions/proj.win32", "extensions/proj.emscripten", "extensions/proj.ios", "extensions/proj.linux", "extensions/proj.mac", "extensions/proj.nacl", "extensions/proj.qt5", "extensions/proj.tizen", ]) + config = open("./config.py") + params = eval(config.read()) + config.close() + + for param in params: + gen_android_mk(**param) if __name__ == "__main__": sys.exit(main()) \ No newline at end of file diff --git a/tools/android_mk_generator/cocos2d_template.mk b/tools/android_mk_generator/cocos2d_template.mk deleted file mode 100644 index 9d8f13bd30..0000000000 --- a/tools/android_mk_generator/cocos2d_template.mk +++ /dev/null @@ -1,55 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := cocos2dx_static - -LOCAL_MODULE_FILENAME := libcocos2d - -LOCAL_SRC_FILES :=%s - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) \ - $(LOCAL_PATH)/include \ - $(LOCAL_PATH)/kazmath/include \ - $(LOCAL_PATH)/platform/android \ - $(LOCAL_PATH)/platform/third_party/common/etc \ - $(LOCAL_PATH)/platform/third_party/common/s3tc \ - $(LOCAL_PATH)/platform/third_party/common/atitc - -LOCAL_C_INCLUDES := $(LOCAL_PATH) \ - $(LOCAL_PATH)/include \ - $(LOCAL_PATH)/kazmath/include \ - $(LOCAL_PATH)/platform/android \ - $(LOCAL_PATH)/platform/third_party/common/etc \ - $(LOCAL_PATH)/platform/third_party/common/s3tc \ - $(LOCAL_PATH)/platform/third_party/common/atitc - - -LOCAL_LDLIBS := -lGLESv2 \ - -llog \ - -lz \ - -landroid - -LOCAL_EXPORT_LDLIBS := -lGLESv2 \ - -llog \ - -lz \ - -landroid - -LOCAL_WHOLE_STATIC_LIBRARIES := cocos_libpng_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos_jpeg_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos_libxml2_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos_libtiff_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos_libwebp_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos_freetype2_static - -# define the macro to compile through support/zip_support/ioapi.c -LOCAL_CFLAGS := -Wno-psabi -DUSE_FILE32API -LOCAL_EXPORT_CFLAGS := -Wno-psabi -DUSE_FILE32API - -include $(BUILD_STATIC_LIBRARY) - -$(call import-module,libjpeg) -$(call import-module,libpng) -$(call import-module,libtiff) -$(call import-module,libwebp) -$(call import-module,libfreetype2) \ No newline at end of file diff --git a/tools/android_mk_generator/config.py b/tools/android_mk_generator/config.py new file mode 100644 index 0000000000..3def00ef10 --- /dev/null +++ b/tools/android_mk_generator/config.py @@ -0,0 +1,16 @@ +[ +{ + 'mkfile' : 'cocos2dx/Android.mk', + 'pathes' : ("cocos2dx/",), + 'exclude' : ("cocos2dx/platform/android", "cocos2dx/platform/emscripten", "cocos2dx/platform/ios", "cocos2dx/platform/linux", "cocos2dx/platform/mac", "cocos2dx/platform/nacl", "cocos2dx/platform/qt5", "cocos2dx/platform/tizen", "cocos2dx/platform/win32", "cocos2dx/label_nodes/CCFontCache.cpp", "cocos2dx/base_nodes/CCGLBufferedNode.cpp","cocos2dx/support/user_default/CCUserDefault.cpp") +}, +{ + 'mkfile' : 'samples/Cpp/TestCpp/Android.mk', + 'pathes' : ("samples/Cpp/TestCpp/Classes",), +}, +{ + 'mkfile' : 'extensions/Android.mk', + 'pathes' : ("extensions/",), + 'exclude' : ("extensions/proj.win32", "extensions/proj.emscripten", "extensions/proj.ios", "extensions/proj.linux", "extensions/proj.mac", "extensions/proj.nacl", "extensions/proj.qt5", "extensions/proj.tizen") +}, +] \ No newline at end of file diff --git a/tools/android_mk_generator/cpptest_template.mk b/tools/android_mk_generator/cpptest_template.mk deleted file mode 100644 index 1fac8ab4a1..0000000000 --- a/tools/android_mk_generator/cpptest_template.mk +++ /dev/null @@ -1,27 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := cocos_testcpp_common - -LOCAL_MODULE_FILENAME := libtestcppcommon - -LOCAL_SRC_FILES := %s - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/Classes - -LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static -LOCAL_WHOLE_STATIC_LIBRARIES += box2d_static -LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) - -include $(BUILD_STATIC_LIBRARY) - -$(call import-module,CocosDenshion/android) -$(call import-module,external/Box2D) -$(call import-module,external/chipmunk) -$(call import-module,cocos2dx) -$(call import-module,extensions) \ No newline at end of file diff --git a/tools/android_mk_generator/extensions_template.mk b/tools/android_mk_generator/extensions_template.mk deleted file mode 100644 index 8c8a1daff1..0000000000 --- a/tools/android_mk_generator/extensions_template.mk +++ /dev/null @@ -1,36 +0,0 @@ -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE := cocos_extension_static - -LOCAL_MODULE_FILENAME := libextension - -LOCAL_SRC_FILES :=%s - -LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos_curl_static -LOCAL_WHOLE_STATIC_LIBRARIES += box2d_static -LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static -LOCAL_WHOLE_STATIC_LIBRARIES += libwebsockets_static - -LOCAL_CXXFLAGS += -fexceptions - -LOCAL_CFLAGS += -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -LOCAL_EXPORT_CFLAGS += -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) \ - $(LOCAL_PATH)/CCBReader \ - $(LOCAL_PATH)/GUI/CCControlExtension \ - $(LOCAL_PATH)/GUI/CCScrollView \ - $(LOCAL_PATH)/network \ - $(LOCAL_PATH)/LocalStorage - -include $(BUILD_STATIC_LIBRARY) - -$(call import-module,cocos2dx) -$(call import-module,CocosDenshion/android) -$(call import-module,cocos2dx/platform/third_party/android/prebuilt/libcurl) -$(call import-module,external/Box2D) -$(call import-module,external/chipmunk) -$(call import-module,external/libwebsockets/android) \ No newline at end of file From 02649a1329c77989b6090a04b29e47d6ae1ba6d8 Mon Sep 17 00:00:00 2001 From: boyu0 Date: Thu, 22 Aug 2013 17:47:49 +0800 Subject: [PATCH 075/126] closed #2434: Use android_mk_generator.py to generate Box2D and chipmunk's Android.mk file --- external/Box2D/Android.mk | 50 +++++++++++++++++++++++++--- external/chipmunk/Android.mk | 34 ++++++++++++++++--- tools/android_mk_generator/config.py | 8 +++++ 3 files changed, 84 insertions(+), 8 deletions(-) diff --git a/external/Box2D/Android.mk b/external/Box2D/Android.mk index 21115fbd6a..c366750c01 100644 --- a/external/Box2D/Android.mk +++ b/external/Box2D/Android.mk @@ -6,10 +6,52 @@ LOCAL_MODULE := box2d_static LOCAL_MODULE_FILENAME := libbox2d -dirs := $(shell find $(LOCAL_PATH) -type d -print) -find_files = $(subst $(LOCAL_PATH)/,,$(wildcard $(dir)/*.cpp)) - -LOCAL_SRC_FILES := $(foreach dir, $(dirs), $(find_files)) +LOCAL_SRC_FILES := \ +Collision/b2BroadPhase.cpp \ +Collision/b2CollideCircle.cpp \ +Collision/b2CollideEdge.cpp \ +Collision/b2CollidePolygon.cpp \ +Collision/b2Collision.cpp \ +Collision/b2Distance.cpp \ +Collision/b2DynamicTree.cpp \ +Collision/b2TimeOfImpact.cpp \ +Collision/Shapes/b2ChainShape.cpp \ +Collision/Shapes/b2CircleShape.cpp \ +Collision/Shapes/b2EdgeShape.cpp \ +Collision/Shapes/b2PolygonShape.cpp \ +Common/b2BlockAllocator.cpp \ +Common/b2Draw.cpp \ +Common/b2Math.cpp \ +Common/b2Settings.cpp \ +Common/b2StackAllocator.cpp \ +Common/b2Timer.cpp \ +Dynamics/b2Body.cpp \ +Dynamics/b2ContactManager.cpp \ +Dynamics/b2Fixture.cpp \ +Dynamics/b2Island.cpp \ +Dynamics/b2World.cpp \ +Dynamics/b2WorldCallbacks.cpp \ +Dynamics/Contacts/b2ChainAndCircleContact.cpp \ +Dynamics/Contacts/b2ChainAndPolygonContact.cpp \ +Dynamics/Contacts/b2CircleContact.cpp \ +Dynamics/Contacts/b2Contact.cpp \ +Dynamics/Contacts/b2ContactSolver.cpp \ +Dynamics/Contacts/b2EdgeAndCircleContact.cpp \ +Dynamics/Contacts/b2EdgeAndPolygonContact.cpp \ +Dynamics/Contacts/b2PolygonAndCircleContact.cpp \ +Dynamics/Contacts/b2PolygonContact.cpp \ +Dynamics/Joints/b2DistanceJoint.cpp \ +Dynamics/Joints/b2FrictionJoint.cpp \ +Dynamics/Joints/b2GearJoint.cpp \ +Dynamics/Joints/b2Joint.cpp \ +Dynamics/Joints/b2MouseJoint.cpp \ +Dynamics/Joints/b2PrismaticJoint.cpp \ +Dynamics/Joints/b2PulleyJoint.cpp \ +Dynamics/Joints/b2RevoluteJoint.cpp \ +Dynamics/Joints/b2RopeJoint.cpp \ +Dynamics/Joints/b2WeldJoint.cpp \ +Dynamics/Joints/b2WheelJoint.cpp \ +Rope/b2Rope.cpp LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/.. diff --git a/external/chipmunk/Android.mk b/external/chipmunk/Android.mk index 8c90fe8f06..e8441cd0d7 100644 --- a/external/chipmunk/Android.mk +++ b/external/chipmunk/Android.mk @@ -6,10 +6,36 @@ LOCAL_MODULE := chipmunk_static LOCAL_MODULE_FILENAME := libchipmunk -dirs := $(shell find $(LOCAL_PATH) -type d -print) -find_files = $(subst $(LOCAL_PATH)/,,$(wildcard $(dir)/*.c)) - -LOCAL_SRC_FILES := $(foreach dir, $(dirs), $(find_files)) +LOCAL_SRC_FILES := \ +src/chipmunk.c \ +src/cpArbiter.c \ +src/cpArray.c \ +src/cpBB.c \ +src/cpBBTree.c \ +src/cpBody.c \ +src/cpCollision.c \ +src/cpHashSet.c \ +src/cpPolyShape.c \ +src/cpShape.c \ +src/cpSpace.c \ +src/cpSpaceComponent.c \ +src/cpSpaceHash.c \ +src/cpSpaceQuery.c \ +src/cpSpaceStep.c \ +src/cpSpatialIndex.c \ +src/cpSweep1D.c \ +src/cpVect.c \ +src/constraints/cpConstraint.c \ +src/constraints/cpDampedRotarySpring.c \ +src/constraints/cpDampedSpring.c \ +src/constraints/cpGearJoint.c \ +src/constraints/cpGrooveJoint.c \ +src/constraints/cpPinJoint.c \ +src/constraints/cpPivotJoint.c \ +src/constraints/cpRatchetJoint.c \ +src/constraints/cpRotaryLimitJoint.c \ +src/constraints/cpSimpleMotor.c \ +src/constraints/cpSlideJoint.c LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include/chipmunk diff --git a/tools/android_mk_generator/config.py b/tools/android_mk_generator/config.py index 3def00ef10..968f55438d 100644 --- a/tools/android_mk_generator/config.py +++ b/tools/android_mk_generator/config.py @@ -13,4 +13,12 @@ 'pathes' : ("extensions/",), 'exclude' : ("extensions/proj.win32", "extensions/proj.emscripten", "extensions/proj.ios", "extensions/proj.linux", "extensions/proj.mac", "extensions/proj.nacl", "extensions/proj.qt5", "extensions/proj.tizen") }, +{ + 'mkfile' : 'external/Box2D/Android.mk', + 'pathes' : ("external/Box2D/",), +}, +{ + 'mkfile' : 'external/chipmunk/Android.mk', + 'pathes' : ("external/chipmunk/",), +}, ] \ No newline at end of file From ca78d2d1299801c8e358430d06421ab79d605b8c Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 22 Aug 2013 18:16:50 +0800 Subject: [PATCH 076/126] closed #2650: Remove ccTypeInfo since we could get the hash value from *typeid(T).hash_code()* if using c++11. --- CocosDenshion/include/SimpleAudioEngine.h | 26 +-------- .../project.pbxproj.REMOVED.git-id | 2 +- cocos2dx/CCDirector.h | 7 +-- cocos2dx/actions/CCActionInstant.h | 20 +------ cocos2dx/include/ccTypeInfo.h | 57 ------------------- cocos2dx/platform/CCFileUtils.h | 12 +--- .../platform/android/CCFileUtilsAndroid.h | 1 - .../emscripten/CCFileUtilsEmscripten.h | 1 - cocos2dx/platform/ios/CCFileUtilsIOS.h | 1 - cocos2dx/platform/linux/CCFileUtilsLinux.h | 1 - cocos2dx/platform/mac/CCFileUtilsMac.h | 1 - cocos2dx/platform/qt5/CCFileUtilsQt5.cpp | 1 - cocos2dx/platform/tizen/CCFileUtilsTizen.h | 1 - cocos2dx/platform/win32/CCFileUtilsWin32.h | 1 - .../javascript/bindings/cocos2d_specifics.hpp | 9 +-- .../bindings/spidermonkey_specifics.h | 2 +- 16 files changed, 9 insertions(+), 134 deletions(-) delete mode 100644 cocos2dx/include/ccTypeInfo.h diff --git a/CocosDenshion/include/SimpleAudioEngine.h b/CocosDenshion/include/SimpleAudioEngine.h index 2960382c85..cd289b8437 100644 --- a/CocosDenshion/include/SimpleAudioEngine.h +++ b/CocosDenshion/include/SimpleAudioEngine.h @@ -42,26 +42,6 @@ THE SOFTWARE. namespace CocosDenshion { -class TypeInfo -{ -public: - virtual long getClassTypeInfo() = 0; -}; - -static inline unsigned int getHashCodeByString(const char *key) -{ - unsigned int len = strlen(key); - const char *end=key+len; - unsigned int hash; - - for (hash = 0; key < end; key++) - { - hash *= 16777619; - hash ^= (unsigned int) (unsigned char) toupper(*key); - } - return (hash); -} - /** @class SimpleAudioEngine @brief Offers a VERY simple interface to play background music & sound effects. @@ -69,7 +49,7 @@ static inline unsigned int getHashCodeByString(const char *key) to release allocated resources. */ -class EXPORT_DLL SimpleAudioEngine : public TypeInfo +class EXPORT_DLL SimpleAudioEngine { public: /** @@ -90,10 +70,6 @@ protected: public: - virtual long getClassTypeInfo() { - return getHashCodeByString(typeid(CocosDenshion::SimpleAudioEngine).name()); - } - /** @brief Preload background music @param pszFilePath The path of the background music file. diff --git a/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id b/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id index 8329895e0b..93daa54df6 100644 --- a/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -b7815826ba065f201f8241cc2f4ce8c18973969d \ No newline at end of file +530264983c51672ffb213e87cbf1a2743867630d \ No newline at end of file diff --git a/cocos2dx/CCDirector.h b/cocos2dx/CCDirector.h index 4001f82804..fb84d2560b 100644 --- a/cocos2dx/CCDirector.h +++ b/cocos2dx/CCDirector.h @@ -36,7 +36,6 @@ THE SOFTWARE. #include "CCGL.h" #include "kazmath/mat4.h" #include "label_nodes/CCLabelAtlas.h" -#include "ccTypeInfo.h" NS_CC_BEGIN @@ -79,7 +78,7 @@ and when to execute the Scenes. - GL_COLOR_ARRAY is enabled - GL_TEXTURE_COORD_ARRAY is enabled */ -class CC_DLL Director : public Object, public TypeInfo +class CC_DLL Director : public Object { public: /** @typedef ccDirectorProjection @@ -109,10 +108,6 @@ public: Director(void); virtual ~Director(void); virtual bool init(void); - virtual long getClassTypeInfo() { - static const long id = cocos2d::getHashCodeByString(typeid(cocos2d::Director).name()); - return id; - } // attribute diff --git a/cocos2dx/actions/CCActionInstant.h b/cocos2dx/actions/CCActionInstant.h index aaf8998dda..43b1970bb8 100644 --- a/cocos2dx/actions/CCActionInstant.h +++ b/cocos2dx/actions/CCActionInstant.h @@ -31,7 +31,6 @@ THE SOFTWARE. #include #include "CCStdC.h" -#include "ccTypeInfo.h" #include "CCAction.h" NS_CC_BEGIN @@ -297,7 +296,7 @@ protected: @brief Calls a 'callback' with the node as the first argument N means Node */ -class CC_DLL CallFuncN : public CallFunc, public TypeInfo +class CC_DLL CallFuncN : public CallFunc { public: /** creates the action with the callback of type std::function. @@ -325,11 +324,6 @@ public: */ CC_DEPRECATED_ATTRIBUTE bool initWithTarget(Object* pSelectorTarget, SEL_CallFuncN selector); - virtual long getClassTypeInfo() { - static const long id = cocos2d::getHashCodeByString(typeid(cocos2d::CallFunc).name()); - return id; - } - // // Overrides // @@ -353,11 +347,6 @@ public: /** creates the action with the callback and the data to pass as an argument */ CC_DEPRECATED_ATTRIBUTE static __CCCallFuncND * create(Object* selectorTarget, SEL_CallFuncND selector, void* d); - virtual long getClassTypeInfo() { - static const long id = cocos2d::getHashCodeByString(typeid(cocos2d::CallFunc).name()); - return id; - } - protected: /** initializes the action with the callback and the data to pass as an argument */ bool initWithTarget(Object* selectorTarget, SEL_CallFuncND selector, void* d); @@ -382,7 +371,7 @@ protected: @since v0.99.5 */ -class CC_DLL __CCCallFuncO : public CallFunc, public TypeInfo +class CC_DLL __CCCallFuncO : public CallFunc { public: /** creates the action with the callback @@ -394,11 +383,6 @@ public: __CCCallFuncO(); virtual ~__CCCallFuncO(); - virtual long getClassTypeInfo() { - static const long id = cocos2d::getHashCodeByString(typeid(cocos2d::CallFunc).name()); - return id; - } - protected: /** initializes the action with the callback diff --git a/cocos2dx/include/ccTypeInfo.h b/cocos2dx/include/ccTypeInfo.h deleted file mode 100644 index c1d07db68d..0000000000 --- a/cocos2dx/include/ccTypeInfo.h +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -Copyright (c) 2012 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -#ifndef cocos2dx_ccTypeInfo_h -#define cocos2dx_ccTypeInfo_h - -#include "platform/CCPlatformMacros.h" - -#include -#include -#include - -NS_CC_BEGIN - -class TypeInfo -{ -public: - virtual long getClassTypeInfo() = 0; -}; - -static inline unsigned int getHashCodeByString(const char *key) -{ - size_t len = strlen(key); - const char *end=key+len; - unsigned int hash; - - for (hash = 0; key < end; key++) - { - hash *= 16777619; - hash ^= (unsigned int) (unsigned char) toupper(*key); - } - return (hash); -} -NS_CC_END - -#endif diff --git a/cocos2dx/platform/CCFileUtils.h b/cocos2dx/platform/CCFileUtils.h index c0b0baca41..709e3cdf86 100644 --- a/cocos2dx/platform/CCFileUtils.h +++ b/cocos2dx/platform/CCFileUtils.h @@ -29,7 +29,6 @@ THE SOFTWARE. #include #include "CCPlatformMacros.h" #include "ccTypes.h" -#include "ccTypeInfo.h" NS_CC_BEGIN @@ -41,20 +40,11 @@ class Array; */ //! @brief Helper class to handle file operations -class CC_DLL FileUtils : public TypeInfo +class CC_DLL FileUtils { friend class Array; friend class Dictionary; public: - /** - * Returns an unique ID for this class. - * @note It's only used for JSBindings now. - * @return The unique ID for this class. - */ - virtual long getClassTypeInfo() { - static const long id = cocos2d::getHashCodeByString(typeid(cocos2d::FileUtils).name()); - return id; - } /** * Gets the instance of FileUtils. diff --git a/cocos2dx/platform/android/CCFileUtilsAndroid.h b/cocos2dx/platform/android/CCFileUtilsAndroid.h index 76b437e489..8bf3b4d7a0 100644 --- a/cocos2dx/platform/android/CCFileUtilsAndroid.h +++ b/cocos2dx/platform/android/CCFileUtilsAndroid.h @@ -27,7 +27,6 @@ #include "platform/CCFileUtils.h" #include "platform/CCPlatformMacros.h" #include "ccTypes.h" -#include "ccTypeInfo.h" #include #include #include "jni.h" diff --git a/cocos2dx/platform/emscripten/CCFileUtilsEmscripten.h b/cocos2dx/platform/emscripten/CCFileUtilsEmscripten.h index 8302393c8b..e6ec10f82c 100644 --- a/cocos2dx/platform/emscripten/CCFileUtilsEmscripten.h +++ b/cocos2dx/platform/emscripten/CCFileUtilsEmscripten.h @@ -27,7 +27,6 @@ #include "platform/CCFileUtils.h" #include "platform/CCPlatformMacros.h" #include "ccTypes.h" -#include "ccTypeInfo.h" #include #include diff --git a/cocos2dx/platform/ios/CCFileUtilsIOS.h b/cocos2dx/platform/ios/CCFileUtilsIOS.h index e91109ee02..d48ad765f5 100644 --- a/cocos2dx/platform/ios/CCFileUtilsIOS.h +++ b/cocos2dx/platform/ios/CCFileUtilsIOS.h @@ -29,7 +29,6 @@ #include #include "CCPlatformMacros.h" #include "ccTypes.h" -#include "ccTypeInfo.h" NS_CC_BEGIN diff --git a/cocos2dx/platform/linux/CCFileUtilsLinux.h b/cocos2dx/platform/linux/CCFileUtilsLinux.h index 473fc78cc8..23552c3837 100644 --- a/cocos2dx/platform/linux/CCFileUtilsLinux.h +++ b/cocos2dx/platform/linux/CCFileUtilsLinux.h @@ -27,7 +27,6 @@ #include "platform/CCFileUtils.h" #include "platform/CCPlatformMacros.h" #include "ccTypes.h" -#include "ccTypeInfo.h" #include #include diff --git a/cocos2dx/platform/mac/CCFileUtilsMac.h b/cocos2dx/platform/mac/CCFileUtilsMac.h index b796f3cdbc..59027609a8 100644 --- a/cocos2dx/platform/mac/CCFileUtilsMac.h +++ b/cocos2dx/platform/mac/CCFileUtilsMac.h @@ -29,7 +29,6 @@ #include #include "CCPlatformMacros.h" #include "ccTypes.h" -#include "ccTypeInfo.h" NS_CC_BEGIN /** diff --git a/cocos2dx/platform/qt5/CCFileUtilsQt5.cpp b/cocos2dx/platform/qt5/CCFileUtilsQt5.cpp index a0a6d3978f..6c5f0f7653 100644 --- a/cocos2dx/platform/qt5/CCFileUtilsQt5.cpp +++ b/cocos2dx/platform/qt5/CCFileUtilsQt5.cpp @@ -31,7 +31,6 @@ #include "platform/CCPlatformMacros.h" #include "platform/CCCommon.h" #include "ccTypes.h" -#include "ccTypeInfo.h" #include "ccMacros.h" #include diff --git a/cocos2dx/platform/tizen/CCFileUtilsTizen.h b/cocos2dx/platform/tizen/CCFileUtilsTizen.h index ec6ac1cff7..b1c25b32ab 100644 --- a/cocos2dx/platform/tizen/CCFileUtilsTizen.h +++ b/cocos2dx/platform/tizen/CCFileUtilsTizen.h @@ -29,7 +29,6 @@ THE SOFTWARE. #include "platform/CCFileUtils.h" #include "platform/CCPlatformMacros.h" #include "ccTypes.h" -#include "ccTypeInfo.h" #include #include diff --git a/cocos2dx/platform/win32/CCFileUtilsWin32.h b/cocos2dx/platform/win32/CCFileUtilsWin32.h index 5feebddd6b..6d6ae12e9f 100644 --- a/cocos2dx/platform/win32/CCFileUtilsWin32.h +++ b/cocos2dx/platform/win32/CCFileUtilsWin32.h @@ -27,7 +27,6 @@ #include "platform/CCFileUtils.h" #include "platform/CCPlatformMacros.h" #include "ccTypes.h" -#include "ccTypeInfo.h" #include #include diff --git a/scripting/javascript/bindings/cocos2d_specifics.hpp b/scripting/javascript/bindings/cocos2d_specifics.hpp index 8501a71b92..c91807a11b 100644 --- a/scripting/javascript/bindings/cocos2d_specifics.hpp +++ b/scripting/javascript/bindings/cocos2d_specifics.hpp @@ -40,15 +40,10 @@ extern callfuncTarget_proxy_t *_callfuncTarget_native_ht; template inline js_type_class_t *js_get_type_from_native(T* native_obj) { js_type_class_t *typeProxy; - long typeId = cocos2d::getHashCodeByString(typeid(*native_obj).name()); + long typeId = typeid(*native_obj).hash_code(); HASH_FIND_INT(_js_global_type_ht, &typeId, typeProxy); if (!typeProxy) { - cocos2d::TypeInfo *typeInfo = dynamic_cast(native_obj); - if (typeInfo) { - typeId = typeInfo->getClassTypeInfo(); - } else { - typeId = cocos2d::getHashCodeByString(typeid(T).name()); - } + typeId = typeid(T).hash_code(); HASH_FIND_INT(_js_global_type_ht, &typeId, typeProxy); } return typeProxy; diff --git a/scripting/javascript/bindings/spidermonkey_specifics.h b/scripting/javascript/bindings/spidermonkey_specifics.h index d2b90398b1..6cb006b358 100644 --- a/scripting/javascript/bindings/spidermonkey_specifics.h +++ b/scripting/javascript/bindings/spidermonkey_specifics.h @@ -37,7 +37,7 @@ class TypeTest But the return string from typeid(*native_obj).name() is the same string, so we must convert the string to hash id to make sure we can get unique id. */ // static const long id = reinterpret_cast(typeid( DERIVED ).name()); - static const long id = cocos2d::getHashCodeByString(typeid( DERIVED ).name()); + static const long id = typeid( DERIVED ).hash_code(); return id; } From c4735af1ef777d63bfd9acc747fb6be0125f7e96 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Thu, 22 Aug 2013 17:19:07 -0700 Subject: [PATCH 077/126] Adds more constants to Color Adds more constants for Colors, in particular to `Color4B` and `Color4F` Signed-off-by: Ricardo Quesada --- cocos2dx/ccTypes.cpp | 32 ++++++++--- cocos2dx/include/ccTypes.h | 20 +++++++ cocos2dx/sprite_nodes/CCSprite.cpp | 85 +++++++++++++++--------------- 3 files changed, 88 insertions(+), 49 deletions(-) diff --git a/cocos2dx/ccTypes.cpp b/cocos2dx/ccTypes.cpp index 4b752b9310..99346e1464 100644 --- a/cocos2dx/ccTypes.cpp +++ b/cocos2dx/ccTypes.cpp @@ -26,6 +26,13 @@ NS_CC_BEGIN +Color4B::Color4B(const Color4F &color4F) +: r((GLubyte)(color4F.r * 255.0f)), +g((GLubyte)(color4F.g * 255.0f)), +b((GLubyte)(color4F.b * 255.0f)), +a((GLubyte)(color4F.a * 255.0f)) +{} + const Color3B Color3B::WHITE(255,255,255); const Color3B Color3B::YELLOW(255,255,0); const Color3B Color3B::GREEN(0,255,0); @@ -36,12 +43,25 @@ const Color3B Color3B::BLACK(0,0,0); const Color3B Color3B::ORANGE(255,127,0); const Color3B Color3B::GRAY(166,166,166); -Color4B::Color4B(const Color4F &color4F) -: r((GLubyte)(color4F.r * 255.0f)), - g((GLubyte)(color4F.g * 255.0f)), - b((GLubyte)(color4F.b * 255.0f)), - a((GLubyte)(color4F.a * 255.0f)) -{} +const Color4B Color4B::WHITE(255,255,255,255); +const Color4B Color4B::YELLOW(255,255,0,255); +const Color4B Color4B::GREEN(0,255,0,255); +const Color4B Color4B::BLUE(0,0,255,255); +const Color4B Color4B::RED(255,0,0,255); +const Color4B Color4B::MAGENTA(255,0,255,255); +const Color4B Color4B::BLACK(0,0,0,255); +const Color4B Color4B::ORANGE(255,127,0,255); +const Color4B Color4B::GRAY(166,166,166,255); + +const Color4F Color4F::WHITE(1,1,1,1); +const Color4F Color4F::YELLOW(1,1,0,1); +const Color4F Color4F::GREEN(0,1,0,1); +const Color4F Color4F::BLUE(0,0,1,1); +const Color4F Color4F::RED(1,0,0,1); +const Color4F Color4F::MAGENTA(1,0,1,1); +const Color4F Color4F::BLACK(0,0,0,1); +const Color4F Color4F::ORANGE(1,0.5,0,1); +const Color4F Color4F::GRAY(0.65,0.65,0.65,1); const BlendFunc BlendFunc::DISABLE = {GL_ONE, GL_ZERO}; const BlendFunc BlendFunc::ALPHA_PREMULTIPLIED = {GL_ONE, GL_ONE_MINUS_SRC_ALPHA}; diff --git a/cocos2dx/include/ccTypes.h b/cocos2dx/include/ccTypes.h index 2f7f7203e5..5487765801 100644 --- a/cocos2dx/include/ccTypes.h +++ b/cocos2dx/include/ccTypes.h @@ -92,6 +92,16 @@ struct Color4B GLubyte g; GLubyte b; GLubyte a; + + const static Color4B WHITE; + const static Color4B YELLOW; + const static Color4B BLUE; + const static Color4B GREEN; + const static Color4B RED; + const static Color4B MAGENTA; + const static Color4B BLACK; + const static Color4B ORANGE; + const static Color4B GRAY; }; @@ -135,6 +145,16 @@ struct Color4F GLfloat g; GLfloat b; GLfloat a; + + const static Color4F WHITE; + const static Color4F YELLOW; + const static Color4F BLUE; + const static Color4F GREEN; + const static Color4F RED; + const static Color4F MAGENTA; + const static Color4F BLACK; + const static Color4F ORANGE; + const static Color4F GRAY; }; /** A vertex composed of 2 floats: x, y diff --git a/cocos2dx/sprite_nodes/CCSprite.cpp b/cocos2dx/sprite_nodes/CCSprite.cpp index 5d4859c34e..63d2da8f2b 100644 --- a/cocos2dx/sprite_nodes/CCSprite.cpp +++ b/cocos2dx/sprite_nodes/CCSprite.cpp @@ -104,10 +104,10 @@ Sprite* Sprite::create(const char *filename, const Rect& rect) return NULL; } -Sprite* Sprite::createWithSpriteFrame(SpriteFrame *pSpriteFrame) +Sprite* Sprite::createWithSpriteFrame(SpriteFrame *spriteFrame) { Sprite *sprite = new Sprite(); - if (pSpriteFrame && sprite && sprite->initWithSpriteFrame(pSpriteFrame)) + if (spriteFrame && sprite && sprite->initWithSpriteFrame(spriteFrame)) { sprite->autorelease(); return sprite; @@ -118,26 +118,26 @@ Sprite* Sprite::createWithSpriteFrame(SpriteFrame *pSpriteFrame) Sprite* Sprite::createWithSpriteFrameName(const char *spriteFrameName) { - SpriteFrame *pFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(spriteFrameName); + SpriteFrame *frame = SpriteFrameCache::getInstance()->getSpriteFrameByName(spriteFrameName); #if COCOS2D_DEBUG > 0 char msg[256] = {0}; sprintf(msg, "Invalid spriteFrameName: %s", spriteFrameName); - CCASSERT(pFrame != NULL, msg); + CCASSERT(frame != NULL, msg); #endif - return createWithSpriteFrame(pFrame); + return createWithSpriteFrame(frame); } Sprite* Sprite::create() { - Sprite *pSprite = new Sprite(); - if (pSprite && pSprite->init()) + Sprite *sprite = new Sprite(); + if (sprite && sprite->init()) { - pSprite->autorelease(); - return pSprite; + sprite->autorelease(); + return sprite; } - CC_SAFE_DELETE(pSprite); + CC_SAFE_DELETE(sprite); return NULL; } @@ -174,11 +174,10 @@ bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect, bool rotated) memset(&_quad, 0, sizeof(_quad)); // Atlas: Color - Color4B tmpColor(255, 255, 255, 255); - _quad.bl.colors = tmpColor; - _quad.br.colors = tmpColor; - _quad.tl.colors = tmpColor; - _quad.tr.colors = tmpColor; + _quad.bl.colors = Color4B::WHITE; + _quad.br.colors = Color4B::WHITE; + _quad.tl.colors = Color4B::WHITE; + _quad.tr.colors = Color4B::WHITE; // shader program setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); @@ -248,12 +247,12 @@ bool Sprite::initWithFile(const char *filename, const Rect& rect) return false; } -bool Sprite::initWithSpriteFrame(SpriteFrame *pSpriteFrame) +bool Sprite::initWithSpriteFrame(SpriteFrame *spriteFrame) { - CCASSERT(pSpriteFrame != NULL, ""); + CCASSERT(spriteFrame != NULL, ""); - bool bRet = initWithTexture(pSpriteFrame->getTexture(), pSpriteFrame->getRect()); - setDisplayFrame(pSpriteFrame); + bool bRet = initWithTexture(spriteFrame->getTexture(), spriteFrame->getRect()); + setDisplayFrame(spriteFrame); return bRet; } @@ -262,8 +261,8 @@ bool Sprite::initWithSpriteFrameName(const char *spriteFrameName) { CCASSERT(spriteFrameName != NULL, ""); - SpriteFrame *pFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(spriteFrameName); - return initWithSpriteFrame(pFrame); + SpriteFrame *frame = SpriteFrameCache::getInstance()->getSpriteFrameByName(spriteFrameName); + return initWithSpriteFrame(frame); } // XXX: deprecated @@ -293,8 +292,8 @@ Sprite* Sprite::initWithCGImage(CGImageRef pImage, const char *pszKey) */ Sprite::Sprite(void) -: _shouldBeHidden(false), -_texture(NULL) +: _shouldBeHidden(false) +, _texture(NULL) { } @@ -453,7 +452,7 @@ void Sprite::updateTransform(void) if( isDirty() ) { // If it is not visible, or one of its ancestors is not visible, then do nothing: - if( !_visible || ( _parent && _parent != _batchNode && ((Sprite*)_parent)->_shouldBeHidden) ) + if( !_visible || ( _parent && _parent != _batchNode && static_cast(_parent)->_shouldBeHidden) ) { _quad.br.vertices = _quad.tl.vertices = _quad.tr.vertices = _quad.bl.vertices = Vertex3F(0,0,0); _shouldBeHidden = true; @@ -469,7 +468,7 @@ void Sprite::updateTransform(void) else { CCASSERT( dynamic_cast(_parent), "Logic error in Sprite. Parent must be a Sprite"); - _transformToBatch = AffineTransformConcat( getNodeToParentTransform() , ((Sprite*)_parent)->_transformToBatch ); + _transformToBatch = AffineTransformConcat( getNodeToParentTransform() , static_cast(_parent)->_transformToBatch ); } // @@ -659,25 +658,25 @@ void Sprite::reorderChild(Node *child, int zOrder) Node::reorderChild(child, zOrder); } -void Sprite::removeChild(Node *child, bool bCleanup) +void Sprite::removeChild(Node *child, bool cleanup) { if (_batchNode) { _batchNode->removeSpriteFromAtlas((Sprite*)(child)); } - Node::removeChild(child, bCleanup); + Node::removeChild(child, cleanup); } -void Sprite::removeAllChildrenWithCleanup(bool bCleanup) +void Sprite::removeAllChildrenWithCleanup(bool cleanup) { if (_batchNode) { - Object* pObject = NULL; - CCARRAY_FOREACH(_children, pObject) + Object* object = NULL; + CCARRAY_FOREACH(_children, object) { - Sprite* child = dynamic_cast(pObject); + Sprite* child = dynamic_cast(object); if (child) { _batchNode->removeSpriteFromAtlas(child); @@ -685,7 +684,7 @@ void Sprite::removeAllChildrenWithCleanup(bool bCleanup) } } - Node::removeAllChildrenWithCleanup(bCleanup); + Node::removeAllChildrenWithCleanup(cleanup); _hasChildren = false; } @@ -736,11 +735,11 @@ void Sprite::setReorderChildDirtyRecursively(void) if ( ! _reorderChildDirty ) { _reorderChildDirty = true; - Node* pNode = (Node*)_parent; - while (pNode && pNode != _batchNode) + Node* node = static_cast(_parent); + while (node && node != _batchNode) { - ((Sprite*)pNode)->setReorderChildDirtyRecursively(); - pNode=pNode->getParent(); + static_cast(node)->setReorderChildDirtyRecursively(); + node=node->getParent(); } } } @@ -753,10 +752,10 @@ void Sprite::setDirtyRecursively(bool bValue) // recursively set dirty if (_hasChildren) { - Object* pObject = NULL; - CCARRAY_FOREACH(_children, pObject) + Object* object = NULL; + CCARRAY_FOREACH(_children, object) { - Sprite* child = dynamic_cast(pObject); + Sprite* child = dynamic_cast(object); if (child) { child->setDirtyRecursively(true); @@ -996,13 +995,13 @@ void Sprite::setDisplayFrameWithAnimationName(const char *animationName, int fra setDisplayFrame(frame->getSpriteFrame()); } -bool Sprite::isFrameDisplayed(SpriteFrame *pFrame) const +bool Sprite::isFrameDisplayed(SpriteFrame *frame) const { - Rect r = pFrame->getRect(); + Rect r = frame->getRect(); return (r.equals(_rect) && - pFrame->getTexture()->getName() == _texture->getName() && - pFrame->getOffset().equals(_unflippedOffsetPositionFromCenter)); + frame->getTexture()->getName() == _texture->getName() && + frame->getOffset().equals(_unflippedOffsetPositionFromCenter)); } SpriteFrame* Sprite::displayFrame(void) From 38bfadf7f3a145ce1a78165b4943e2a55fee8f9b Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Thu, 22 Aug 2013 18:21:52 -0700 Subject: [PATCH 078/126] Adds 2 new performance tests Invocation with `for_each()` and using `arrayMakeObjectsPerformSelector` Signed-off-by: Ricardo Quesada --- cocos2dx/support/CCProfiling.cpp | 2 +- .../PerformanceNodeChildrenTest.cpp | 74 +++++++++++++++++++ .../PerformanceNodeChildrenTest.h | 24 ++++++ 3 files changed, 99 insertions(+), 1 deletion(-) diff --git a/cocos2dx/support/CCProfiling.cpp b/cocos2dx/support/CCProfiling.cpp index 87468c92bf..66a2d73634 100644 --- a/cocos2dx/support/CCProfiling.cpp +++ b/cocos2dx/support/CCProfiling.cpp @@ -125,7 +125,7 @@ const char* ProfilingTimer::description() const { static char s_desciption[512] = {0}; - sprintf(s_desciption, "%s ::\tavg1: %dµ,\tavg2: %dµ,\tmin: %dµ,\tmax: %dµ,\ttotal: %.4fs,\tnr calls: %d", _nameStr.c_str(), _averageTime1, _averageTime2, minTime, maxTime, totalTime/1000000., numberOfCalls); + sprintf(s_desciption, "%s ::\tavg1: %dµ,\tavg2: %dµ,\tmin: %dµ,\tmax: %dµ,\ttotal: %.2fs,\tnr calls: %d", _nameStr.c_str(), _averageTime1, _averageTime2, minTime, maxTime, totalTime/1000000., numberOfCalls); return s_desciption; } diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp index b13de9cbbc..65756232c3 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp @@ -33,6 +33,9 @@ static std::function createFunctions[] = CL(IterateSpriteSheetCArray), CL(IterateSpriteSheetIterator), + CL(CallFuncsSpriteSheetForEach), + CL(CallFuncsSpriteSheetCMacro), + CL(AddSpriteSheet), CL(RemoveSpriteSheet), CL(ReorderSpriteSheet), @@ -364,7 +367,78 @@ const char* IterateSpriteSheetIterator::profilerName() return "Iterator: begin(), end()"; } +//////////////////////////////////////////////////////// +// +// CallFuncsSpriteSheetForEach +// +//////////////////////////////////////////////////////// +void CallFuncsSpriteSheetForEach::update(float dt) +{ + // iterate using fast enumeration protocol + auto children = batchNode->getChildren(); + CC_PROFILER_START(this->profilerName()); + + std::for_each(std::begin(*children), std::end(*children), [](Object* obj) { + static_cast(obj)->getPosition(); + }); + + CC_PROFILER_STOP(this->profilerName()); +} + + +std::string CallFuncsSpriteSheetForEach::title() +{ + return "D - 'map' functional call"; +} + +std::string CallFuncsSpriteSheetForEach::subtitle() +{ + return "Using 'std::for_each()'. See console"; +} + +const char* CallFuncsSpriteSheetForEach::profilerName() +{ + static char _name[256]; + snprintf(_name, sizeof(_name)-1, "Map: std::for_each(%d)", quantityOfNodes); + return _name; + +} + +//////////////////////////////////////////////////////// +// +// CallFuncsSpriteSheetCMacro +// +//////////////////////////////////////////////////////// +void CallFuncsSpriteSheetCMacro::update(float dt) +{ + // iterate using fast enumeration protocol + auto children = batchNode->getChildren(); + + CC_PROFILER_START(this->profilerName()); + + arrayMakeObjectsPerformSelector(children, getPosition, Node*); + + CC_PROFILER_STOP(this->profilerName()); +} + + +std::string CallFuncsSpriteSheetCMacro::title() +{ + return "E - 'map' functional call"; +} + +std::string CallFuncsSpriteSheetCMacro::subtitle() +{ + return "Using 'arrayMakeObjectsPerformSelector'. See console"; +} + +const char* CallFuncsSpriteSheetCMacro::profilerName() +{ + static char _name[256]; + snprintf(_name, sizeof(_name)-1, "Map: arrayMakeObjectsPerformSelector(%d)", quantityOfNodes); + return _name; +} //////////////////////////////////////////////////////// // // AddRemoveSpriteSheet diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.h b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.h index 6e513971ea..e501677267 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.h +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.h @@ -94,6 +94,30 @@ protected: #endif }; +/// + +class CallFuncsSpriteSheetForEach : public IterateSpriteSheet +{ +public: + virtual void update(float dt); + + virtual std::string title(); + virtual std::string subtitle(); + virtual const char* profilerName(); +}; + +class CallFuncsSpriteSheetCMacro : public IterateSpriteSheet +{ +public: + virtual void update(float dt); + + virtual std::string title(); + virtual std::string subtitle(); + virtual const char* profilerName(); +}; + +/// + class AddSpriteSheet : public AddRemoveSpriteSheet { public: From 055c566bc9f841b72cc98a85fd0afa23a6624c1d Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Thu, 22 Aug 2013 19:30:20 -0700 Subject: [PATCH 079/126] Adds missing #include --- .../Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp index 65756232c3..ed3a5e0021 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp @@ -1,5 +1,7 @@ #include "PerformanceNodeChildrenTest.h" +#include + // Enable profiles for this file #undef CC_PROFILER_DISPLAY_TIMERS #define CC_PROFILER_DISPLAY_TIMERS() Profiler::getInstance()->displayTimers() From 6ed43811feaf2d48b880fab4fe0049b052559ccd Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 23 Aug 2013 11:24:50 +0800 Subject: [PATCH 080/126] issue #2483: Updating VS projects to use the correct library (mozjs-23.0.lib). --- .../AssetsManagerTest/proj.win32/AssetsManagerTest.vcxproj | 4 ++-- .../Javascript/CocosDragonJS/proj.win32/CocosDragonJS.vcxproj | 4 ++-- .../Javascript/CrystalCraze/proj.win32/CrystalCraze.vcxproj | 4 ++-- .../Javascript/MoonWarriors/proj.win32/MoonWarriors.vcxproj | 4 ++-- .../TestJavascript/proj.win32/TestJavascript.vcxproj | 4 ++-- .../WatermelonWithMe/proj.win32/WatermelonWithMe.vcxproj | 4 ++-- template/multi-platform-js/proj.win32/HelloJavascript.vcxproj | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/samples/Cpp/AssetsManagerTest/proj.win32/AssetsManagerTest.vcxproj b/samples/Cpp/AssetsManagerTest/proj.win32/AssetsManagerTest.vcxproj index 0d2bb4c9fb..93de6b0663 100644 --- a/samples/Cpp/AssetsManagerTest/proj.win32/AssetsManagerTest.vcxproj +++ b/samples/Cpp/AssetsManagerTest/proj.win32/AssetsManagerTest.vcxproj @@ -100,7 +100,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\li - libcocos2d.lib;libExtensions.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;mozjs.lib;ws2_32.lib;sqlite3.lib;libcurl_imp.lib;%(AdditionalDependencies) + libcocos2d.lib;libExtensions.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;mozjs-23.0.lib;ws2_32.lib;sqlite3.lib;libcurl_imp.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) true Windows @@ -155,7 +155,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\li - libcocos2d.lib;libExtensions.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;mozjs.lib;ws2_32.lib;sqlite3.lib;libcurl_imp.lib;%(AdditionalDependencies) + libcocos2d.lib;libExtensions.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;mozjs-23.0.lib;ws2_32.lib;sqlite3.lib;libcurl_imp.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) Windows MachineX86 diff --git a/samples/Javascript/CocosDragonJS/proj.win32/CocosDragonJS.vcxproj b/samples/Javascript/CocosDragonJS/proj.win32/CocosDragonJS.vcxproj index 90d01b475c..76021134e8 100644 --- a/samples/Javascript/CocosDragonJS/proj.win32/CocosDragonJS.vcxproj +++ b/samples/Javascript/CocosDragonJS/proj.win32/CocosDragonJS.vcxproj @@ -100,7 +100,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\li - libcocos2d.lib;libExtensions.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;libcurl_imp.lib;mozjs.lib;ws2_32.lib;sqlite3.lib;%(AdditionalDependencies) + libcocos2d.lib;libExtensions.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;libcurl_imp.lib;mozjs-23.0.lib;ws2_32.lib;sqlite3.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) true Windows @@ -155,7 +155,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\li - libcocos2d.lib;libExtensions.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;libcurl_imp.lib;mozjs.lib;ws2_32.lib;sqlite3.lib;%(AdditionalDependencies) + libcocos2d.lib;libExtensions.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;libcurl_imp.lib;mozjs-23.0.lib;ws2_32.lib;sqlite3.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) Windows MachineX86 diff --git a/samples/Javascript/CrystalCraze/proj.win32/CrystalCraze.vcxproj b/samples/Javascript/CrystalCraze/proj.win32/CrystalCraze.vcxproj index 6c6005b2a2..ab6776d024 100644 --- a/samples/Javascript/CrystalCraze/proj.win32/CrystalCraze.vcxproj +++ b/samples/Javascript/CrystalCraze/proj.win32/CrystalCraze.vcxproj @@ -100,7 +100,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\li - libcocos2d.lib;libExtensions.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;libcurl_imp.lib;mozjs.lib;ws2_32.lib;sqlite3.lib;%(AdditionalDependencies) + libcocos2d.lib;libExtensions.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;libcurl_imp.lib;mozjs-23.0.lib;ws2_32.lib;sqlite3.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) true Windows @@ -155,7 +155,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\li - libcocos2d.lib;libExtensions.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;libcurl_imp.lib;mozjs.lib;ws2_32.lib;sqlite3.lib;%(AdditionalDependencies) + libcocos2d.lib;libExtensions.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;libcurl_imp.lib;mozjs-23.0.lib;ws2_32.lib;sqlite3.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) Windows MachineX86 diff --git a/samples/Javascript/MoonWarriors/proj.win32/MoonWarriors.vcxproj b/samples/Javascript/MoonWarriors/proj.win32/MoonWarriors.vcxproj index 1a33afd41e..6824c22522 100644 --- a/samples/Javascript/MoonWarriors/proj.win32/MoonWarriors.vcxproj +++ b/samples/Javascript/MoonWarriors/proj.win32/MoonWarriors.vcxproj @@ -100,7 +100,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\li - libcocos2d.lib;libExtensions.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;libcurl_imp.lib;mozjs.lib;ws2_32.lib;sqlite3.lib;%(AdditionalDependencies) + libcocos2d.lib;libExtensions.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;libcurl_imp.lib;mozjs-23.0.lib;ws2_32.lib;sqlite3.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) true Windows @@ -153,7 +153,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\li - libcocos2d.lib;libExtensions.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;libcurl_imp.lib;mozjs.lib;ws2_32.lib;sqlite3.lib;%(AdditionalDependencies) + libcocos2d.lib;libExtensions.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;libcurl_imp.lib;mozjs-23.0.lib;ws2_32.lib;sqlite3.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) Windows MachineX86 diff --git a/samples/Javascript/TestJavascript/proj.win32/TestJavascript.vcxproj b/samples/Javascript/TestJavascript/proj.win32/TestJavascript.vcxproj index 7acb604f56..da3b2b9fe0 100644 --- a/samples/Javascript/TestJavascript/proj.win32/TestJavascript.vcxproj +++ b/samples/Javascript/TestJavascript/proj.win32/TestJavascript.vcxproj @@ -101,7 +101,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\libwebsockets\win32\lib\*.*" "$(O - libcocos2d.lib;libExtensions.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;libcurl_imp.lib;mozjs.lib;ws2_32.lib;sqlite3.lib;websockets.lib;%(AdditionalDependencies) + libcocos2d.lib;libExtensions.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;libcurl_imp.lib;mozjs-23.0.lib;ws2_32.lib;sqlite3.lib;websockets.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) true Windows @@ -157,7 +157,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\libwebsockets\win32\lib\*.*" "$(O - libcocos2d.lib;libExtensions.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;libcurl_imp.lib;mozjs.lib;ws2_32.lib;sqlite3.lib;websockets.lib;%(AdditionalDependencies) + libcocos2d.lib;libExtensions.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;libcurl_imp.lib;mozjs-23.0.lib;ws2_32.lib;sqlite3.lib;websockets.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) Windows MachineX86 diff --git a/samples/Javascript/WatermelonWithMe/proj.win32/WatermelonWithMe.vcxproj b/samples/Javascript/WatermelonWithMe/proj.win32/WatermelonWithMe.vcxproj index 70d294578d..9601ebb7f1 100644 --- a/samples/Javascript/WatermelonWithMe/proj.win32/WatermelonWithMe.vcxproj +++ b/samples/Javascript/WatermelonWithMe/proj.win32/WatermelonWithMe.vcxproj @@ -100,7 +100,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\li - libcocos2d.lib;libExtensions.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;libcurl_imp.lib;mozjs.lib;ws2_32.lib;sqlite3.lib;%(AdditionalDependencies) + libcocos2d.lib;libExtensions.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;libcurl_imp.lib;mozjs-23.0.lib;ws2_32.lib;sqlite3.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) true Windows @@ -155,7 +155,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\li - libcocos2d.lib;libExtensions.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;libcurl_imp.lib;mozjs.lib;ws2_32.lib;sqlite3.lib;%(AdditionalDependencies) + libcocos2d.lib;libExtensions.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;libcurl_imp.lib;mozjs-23.0.lib;ws2_32.lib;sqlite3.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) Windows MachineX86 diff --git a/template/multi-platform-js/proj.win32/HelloJavascript.vcxproj b/template/multi-platform-js/proj.win32/HelloJavascript.vcxproj index ea34a02ce7..9a800ef063 100644 --- a/template/multi-platform-js/proj.win32/HelloJavascript.vcxproj +++ b/template/multi-platform-js/proj.win32/HelloJavascript.vcxproj @@ -100,7 +100,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\scripting\javascript\spidermonkey-win32\lib\* xcopy /Y /Q "$(ProjectDir)..\..\..\external\libwebsockets\win32\lib\*.*" "$(OutDir)" - libcocos2d.lib;libExtensions.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;libcurl_imp.lib;mozjs.lib;ws2_32.lib;sqlite3.lib;websockets.lib;%(AdditionalDependencies) + libcocos2d.lib;libExtensions.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;libcurl_imp.lib;mozjs-23.0.lib;ws2_32.lib;sqlite3.lib;websockets.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) true Windows @@ -155,7 +155,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\scripting\javascript\spidermonkey-win32\lib\* xcopy /Y /Q "$(ProjectDir)..\..\..\external\libwebsockets\win32\lib\*.*" "$(OutDir)" - libcocos2d.lib;libExtensions.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;libcurl_imp.lib;mozjs.lib;ws2_32.lib;sqlite3.lib;websockets.lib;%(AdditionalDependencies) + libcocos2d.lib;libExtensions.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;libcurl_imp.lib;mozjs-23.0.lib;ws2_32.lib;sqlite3.lib;websockets.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) Windows MachineX86 From 465867417569ca06b7318200f49fbcf98a2d16d8 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Fri, 23 Aug 2013 03:40:19 +0000 Subject: [PATCH 081/126] [AUTO] : updating submodule reference to latest autogenerated bindings --- scripting/javascript/bindings/generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripting/javascript/bindings/generated b/scripting/javascript/bindings/generated index aad3156eaf..03087c4b0e 160000 --- a/scripting/javascript/bindings/generated +++ b/scripting/javascript/bindings/generated @@ -1 +1 @@ -Subproject commit aad3156eaf669d8ff6dac0972a67f94f29d75f7d +Subproject commit 03087c4b0ef466ccb17f944c4ee5f1fca571a221 From 3f23a4a66108bd3284002341530d591239669896 Mon Sep 17 00:00:00 2001 From: boyu0 Date: Fri, 23 Aug 2013 14:37:56 +0800 Subject: [PATCH 082/126] closed #2494: Fix bug when two line is incident, the Point::isSegmentIntersect() may return wrong result --- cocos2dx/cocoa/CCGeometry.cpp | 43 +++++++++++++++++++++++++++++++++++ cocos2dx/cocoa/CCGeometry.h | 14 ++++++++++++ 2 files changed, 57 insertions(+) diff --git a/cocos2dx/cocoa/CCGeometry.cpp b/cocos2dx/cocoa/CCGeometry.cpp index 6976945b4d..d3350dc639 100644 --- a/cocos2dx/cocoa/CCGeometry.cpp +++ b/cocos2dx/cocoa/CCGeometry.cpp @@ -116,6 +116,40 @@ Point Point::rotateByAngle(const Point& pivot, float angle) const return pivot + (*this - pivot).rotate(Point::forAngle(angle)); } +bool Point::isOneDemensionLineIntersect(float A, float B, float C, float D, float *S) +{ + float ABmin = MIN(A, B); + float ABmax = MAX(A, B); + float CDmin = MIN(C, D); + float CDmax = MAX(C, D); + + if (ABmax < CDmin || CDmax < ABmin) + { + // ABmin->ABmax->CDmin->CDmax or CDmin->CDmax->ABmin->ABmax + *S = (CDmin - A) / (B - A); + return false; + } + else + { + if (ABmin >= CDmin && ABmin <= CDmax) + { + // CDmin->ABmin->CDmax->ABmax or CDmin->ABmin->ABmax->CDmax + *S = ABmin==A ? 0 : 1; + } + else if (ABmax >= CDmin && ABmax <= CDmax) + { + // ABmin->CDmin->ABmax->CDmax + *S = ABmax==A ? 0 : 1; + } + else + { + // ABmin->CDmin->CDmax->ABmax + *S = (CDmin - A) / (B - A); + } + return true; + } +} + bool Point::isLineIntersect(const Point& A, const Point& B, const Point& C, const Point& D, float *S, float *T) @@ -142,6 +176,15 @@ bool Point::isLineIntersect(const Point& A, const Point& B, if (*S == 0 || *T == 0) { // Lines incident + if (C.x != D.x) + { + isOneDemensionLineIntersect(A.x, B.x, C.x, D.x, S); + } + else + { + isOneDemensionLineIntersect(A.x, B.x, C.x, D.x, S); + } + return true; } // Lines parallel and not incident diff --git a/cocos2dx/cocoa/CCGeometry.h b/cocos2dx/cocoa/CCGeometry.h index 7b5ca63430..ccfe3b5616 100644 --- a/cocos2dx/cocoa/CCGeometry.h +++ b/cocos2dx/cocoa/CCGeometry.h @@ -245,6 +245,20 @@ public: return Point(cosf(a), sinf(a)); } + /** A general line-line intersection test + @param A the startpoint for the first line L1 = (A - B) + @param B the endpoint for the first line L1 = (A - B) + @param C the startpoint for the second line L2 = (C - D) + @param D the endpoint for the second line L2 = (C - D) + @param S the range for a hitpoint in L1 (p = A + S*(B - A)) + @returns whether these two lines interects. + + Note that if two line is intersection, S in line in [0..1] + the hit point also is A + S * (B - A); + @since 3.0 + */ + static bool isOneDemensionLineIntersect(float A, float B, float C, float D, float *S); + /** A general line-line intersection test @param A the startpoint for the first line L1 = (A - B) @param B the endpoint for the first line L1 = (A - B) From 9a3a03d6ef2b3062046dae98da45fe01e7ddffe1 Mon Sep 17 00:00:00 2001 From: boyu0 Date: Fri, 23 Aug 2013 14:41:49 +0800 Subject: [PATCH 083/126] closed #2494: Fix some typo --- cocos2dx/cocoa/CCGeometry.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2dx/cocoa/CCGeometry.cpp b/cocos2dx/cocoa/CCGeometry.cpp index d3350dc639..59f0d750b4 100644 --- a/cocos2dx/cocoa/CCGeometry.cpp +++ b/cocos2dx/cocoa/CCGeometry.cpp @@ -176,13 +176,13 @@ bool Point::isLineIntersect(const Point& A, const Point& B, if (*S == 0 || *T == 0) { // Lines incident - if (C.x != D.x) + if (A.x != B.x) { isOneDemensionLineIntersect(A.x, B.x, C.x, D.x, S); } else { - isOneDemensionLineIntersect(A.x, B.x, C.x, D.x, S); + isOneDemensionLineIntersect(A.y, B.y, C.y, D.y, T); } return true; From 2a147ec34a44dc21832dc27b23d59c20b44c96ca Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 23 Aug 2013 15:55:25 +0800 Subject: [PATCH 084/126] Adding a new search path 'res' to TestJavascript since some resources are defined as hard code in ControlColourPicker::init(). bool ControlColourPicker::init() { if (Control::init()) { setTouchEnabled(true); // Cache the sprites SpriteFrameCache::getInstance()->addSpriteFramesWithFile("extensions/CCControlColourPickerSpriteSheet.plist"); // Hard code here // Create the sprite batch node SpriteBatchNode *spriteSheet = SpriteBatchNode::create("extensions/CCControlColourPickerSpriteSheet.png"); // Hard code here addChild(spriteSheet); --- samples/Javascript/TestJavascript/Classes/AppDelegate.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp b/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp index de6a48a276..69d9cb6b60 100644 --- a/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp +++ b/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp @@ -55,6 +55,8 @@ bool AppDelegate::applicationDidFinishLaunching() sc->start(); + FileUtils::getInstance()->addSearchPath("res"); + auto pEngine = ScriptingCore::getInstance(); ScriptEngineManager::getInstance()->setScriptEngine(pEngine); #ifdef JS_OBFUSCATED From 699c7d1077ad36044ef93c5241146c5515b49007 Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 23 Aug 2013 15:56:38 +0800 Subject: [PATCH 085/126] Updating bindings-generator, it supports CCString. Some APIs, for example ControlButton::setTitleForState are using String as argument. --- tools/bindings-generator | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/bindings-generator b/tools/bindings-generator index 73d3d60825..ac2d52da39 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit 73d3d608251d377a473413d549931807b0fa2232 +Subproject commit ac2d52da397e8bd1c0d10c613a6ca41f3a25babe From 8345d4849dd4cd0058d94a6ffefcac866c3cb16a Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Fri, 23 Aug 2013 08:04:38 +0000 Subject: [PATCH 086/126] [AUTO] : updating submodule reference to latest autogenerated bindings --- scripting/javascript/bindings/generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripting/javascript/bindings/generated b/scripting/javascript/bindings/generated index 03087c4b0e..5b4a4c5b94 160000 --- a/scripting/javascript/bindings/generated +++ b/scripting/javascript/bindings/generated @@ -1 +1 @@ -Subproject commit 03087c4b0ef466ccb17f944c4ee5f1fca571a221 +Subproject commit 5b4a4c5b94ba4920a70900d47246612adcdc0ac5 From e557b6b7c285dc3798c1d3a9413f9bd1dc971749 Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Fri, 23 Aug 2013 16:12:59 +0800 Subject: [PATCH 087/126] issue #2433:Add lua deprecated fiel and modify some test samples --- .../project.pbxproj.REMOVED.git-id | 2 +- samples/Lua/HelloLua/Resources/hello.lua | 6 +- .../AccelerometerTest/AccelerometerTest.lua | 3 +- .../ActionManagerTest/ActionManagerTest.lua | 27 +- .../ActionsEaseTest/ActionsEaseTest.lua | 250 +----------------- .../ActionsProgressTest.lua | 6 - .../luaScript/ActionsTest/ActionsTest.lua | 106 +------- .../Resources/luaScript/BugsTest/BugsTest.lua | 44 +-- .../ClickAndMoveTest/ClickAndMoveTest.lua | 3 +- .../CocosDenshionTest/CocosDenshionTest.lua | 3 +- .../luaScript/LayerTest/LayerTest.lua | 10 +- .../Resources/luaScript/MenuTest/MenuTest.lua | 18 +- .../luaScript/OpenGLTest/OpenGLTest.lua | 3 +- .../luaScript/ParticleTest/ParticleTest.lua | 12 +- .../luaScript/TileMapTest/TileMapTest.lua | 8 +- .../TestLua/Resources/luaScript/mainMenu.lua | 3 +- scripting/lua/cocos2dx_support/CCLuaStack.cpp | 3 + .../cocos2dx_support/LuaBasicConversions.cpp | 6 +- .../lua_cocos2dx_auto.cpp.REMOVED.git-id | 2 +- .../generated/lua_cocos2dx_auto.hpp | 3 - .../lua_cocos2dx_auto_api.js.REMOVED.git-id | 2 +- ...cocos2dx_extension_auto.cpp.REMOVED.git-id | 2 +- ...lua_cocos2dx_deprecated.cpp.REMOVED.git-id | 1 + .../lua_cocos2dx_deprecated.h | 15 ++ .../cocos2dx_support/lua_cocos2dx_manual.cpp | 53 ++++ scripting/lua/script/Cocos2d.lua | 36 ++- scripting/lua/script/Deprecated.lua | 240 +++++++++++++---- tools/bindings-generator | 2 +- tools/tolua/cocos2dx.ini | 2 +- 29 files changed, 354 insertions(+), 517 deletions(-) create mode 100644 scripting/lua/cocos2dx_support/lua_cocos2dx_deprecated.cpp.REMOVED.git-id create mode 100644 scripting/lua/cocos2dx_support/lua_cocos2dx_deprecated.h diff --git a/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id b/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id index 6122e079d2..d70baf84d4 100644 --- a/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -1967da55fdcb71f9dd3dda53661eb4a1938803cf \ No newline at end of file +9420774ce7a3c38be6597cebe5a2888835d9c410 \ No newline at end of file diff --git a/samples/Lua/HelloLua/Resources/hello.lua b/samples/Lua/HelloLua/Resources/hello.lua index b6dd2e41d0..607b7d7508 100644 --- a/samples/Lua/HelloLua/Resources/hello.lua +++ b/samples/Lua/HelloLua/Resources/hello.lua @@ -54,8 +54,7 @@ local function main() -- moving dog at every frame local function tick() if spriteDog.isPaused then return end - local position = spriteDog:getPosition() - local x, y = position.x,position.y + local x, y = spriteDog:getPosition() if x > origin.x + visibleSize.width then x = origin.x else @@ -116,8 +115,7 @@ local function main() local function onTouchMoved(x, y) cclog("onTouchMoved: %0.2f, %0.2f", x, y) if touchBeginPoint then - local position = layerFarm:getPosition() - local cx, cy = position.x,position.y + local cx, cy = layerFarm:getPosition() layerFarm:setPosition(cx + x - touchBeginPoint.x, cy + y - touchBeginPoint.y) touchBeginPoint = {x = x, y = y} diff --git a/samples/Lua/TestLua/Resources/luaScript/AccelerometerTest/AccelerometerTest.lua b/samples/Lua/TestLua/Resources/luaScript/AccelerometerTest/AccelerometerTest.lua index dbdb62a470..88c7b0eee6 100644 --- a/samples/Lua/TestLua/Resources/luaScript/AccelerometerTest/AccelerometerTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/AccelerometerTest/AccelerometerTest.lua @@ -25,8 +25,7 @@ local function AccelerometerMainLayer() end local szBall = pBall:getContentSize() - local ptNow = pBall:getPosition() - local ptNowX,ptNowY = ptNow.x, ptNow.y + local ptNowX,ptNowY = pBall:getPosition() local ptTmp = pDir:convertToUI(cc.p(ptNowX,ptNowY)) ptTmp.x = ptTmp.x + x * 9.81 diff --git a/samples/Lua/TestLua/Resources/luaScript/ActionManagerTest/ActionManagerTest.lua b/samples/Lua/TestLua/Resources/luaScript/ActionManagerTest/ActionManagerTest.lua index bd1efd53d6..5d3941c3bf 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ActionManagerTest/ActionManagerTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ActionManagerTest/ActionManagerTest.lua @@ -17,25 +17,13 @@ local function CrashTest() --Sum of all action's duration is 1.5 second. child:runAction(cc.RotateBy:create(1.5, 90)) - --[[ - local arr = CCArray:create() - arr:addObject(CCDelayTime:create(1.4)) - arr:addObject(CCFadeOut:create(1.1)) - ]]-- child:runAction(cc.Sequence:create(cc.DelayTime:create(1.4),cc.FadeOut:create(1.1))) - --[[ - arr = CCArray:create() - arr:addObject(CCDelayTime:create(1.4)) - ]]-- local function removeThis() ret:getParent():removeChild(ret, true) Helper.nextAction() end - --[[ - local callfunc = CCCallFunc:create(removeThis) - arr:addObject(callfunc) - ]]-- + --After 1.5 second, self will be removed. ret:runAction( cc.Sequence:create(cc.DelayTime:create(1.4),cc.CallFunc:create(removeThis))) return ret @@ -52,18 +40,10 @@ local function LogicTest() local grossini = cc.Sprite:create(s_pPathGrossini) ret:addChild(grossini, 0, 2) grossini:setPosition(200,200) ---[[ - local arr = CCArray:create() - arr:addObject(CCMoveBy:create(1, CCPoint(150,0))) -]]-- local function bugMe(node) node:stopAllActions() --After this stop next action not working, if remove this stop everything is working node:runAction(cc.ScaleTo:create(2, 2)) end ---[[ - local callfunc = CCCallFunc:create(bugMe) - arr:addObject(callfunc) -]]-- grossini:runAction( cc.Sequence:create(cc.MoveBy:create(1, cc.p(150,0)) ,cc.CallFunc:create(bugMe))) return ret end @@ -133,11 +113,6 @@ local function RemoveTest() end local callfunc = cc.CallFunc:create(stopAction) - --[[ - local arr = CCArray:create() - arr:addObject(pMove) - arr:addObject(callfunc) - ]]-- local pSequence = cc.Sequence:create(pMove,callfunc) pSequence:setTag(kTagSequence) diff --git a/samples/Lua/TestLua/Resources/luaScript/ActionsEaseTest/ActionsEaseTest.lua b/samples/Lua/TestLua/Resources/luaScript/ActionsEaseTest/ActionsEaseTest.lua index 6d5487df7b..ae0da8b3bb 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ActionsEaseTest/ActionsEaseTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ActionsEaseTest/ActionsEaseTest.lua @@ -72,29 +72,8 @@ local function SpriteEase() local move_ease_out_back = move_ease_out:reverse() local delay = createSimpleDelayTime() ---[[ - local arr1 = CCArray:create() - arr1:addObject(move) - arr1:addObject(delay) - arr1:addObject(move_back) - arr1:addObject(createSimpleDelayTime()) - ]]-- local seq1 = cc.Sequence:create(move, delay, move_back, createSimpleDelayTime()) ---[[ - local arr2 = CCArray:create() - arr2:addObject(move_ease_in) - arr2:addObject(createSimpleDelayTime()) - arr2:addObject(move_ease_in_back) - arr2:addObject(createSimpleDelayTime()) - ]]-- local seq2 = cc.Sequence:create(move_ease_in,createSimpleDelayTime(),move_ease_in_back,createSimpleDelayTime()) ---[[ - local arr3 = CCArray:create() - arr3:addObject(move_ease_out) - arr3:addObject(createSimpleDelayTime()) - arr3:addObject(move_ease_out_back) - arr3:addObject(createSimpleDelayTime()) - ]]-- local seq3 = cc.Sequence:create(move_ease_out,createSimpleDelayTime(),move_ease_out_back,createSimpleDelayTime()) local a2 = grossini:runAction(cc.RepeatForever:create(seq1)) @@ -128,30 +107,8 @@ local function SpriteEaseInOut() local move_ease_inout_back3 = move_ease_inout3:reverse() local delay = createSimpleDelayTime() ---[[ - local arr1 = CCArray:create() - arr1:addObject(move_ease_inout1) - arr1:addObject(delay) - arr1:addObject(move_ease_inout_back1) - arr1:addObject(createSimpleDelayTime()) - ]]-- local seq1 = cc.Sequence:create(move_ease_inout1,delay,move_ease_inout_back1,createSimpleDelayTime()) - ---[[ - local arr2 = CCArray:create() - arr2:addObject(move_ease_inout2) - arr2:addObject(createSimpleDelayTime()) - arr2:addObject(move_ease_inout_back2) - arr2:addObject(createSimpleDelayTime()) - ]]-- local seq2 = cc.Sequence:create(move_ease_inout2,createSimpleDelayTime(),move_ease_inout_back2,createSimpleDelayTime()) ---[[ - local arr3 = CCArray:create() - arr3:addObject(move_ease_inout3) - arr3:addObject(createSimpleDelayTime()) - arr3:addObject(move_ease_inout_back3) - arr3:addObject(createSimpleDelayTime()) -]]-- local seq3 = cc.Sequence:create(move_ease_inout3, createSimpleDelayTime(), move_ease_inout_back3, createSimpleDelayTime() ) tamara:runAction(cc.RepeatForever:create(seq1)) @@ -178,37 +135,9 @@ local function SpriteEaseExponential() local move_ease_out_back = move_ease_out:reverse() local delay = createSimpleDelayTime() - ---[[ - local arr1 = CCArray:create() - arr1:addObject(move) - arr1:addObject(delay) - arr1:addObject(move_back) - - arr1:addObject(createSimpleDelayTime()) -]]-- - local seq1 = cc.Sequence:create(move, delay, move_back, createSimpleDelayTime() ) ---[[ - local arr2 = CCArray:create() - arr2:addObject(move_ease_in) - - arr2:addObject(createSimpleDelayTime()) - arr2:addObject(move_ease_in_back) - - arr2:addObject(createSimpleDelayTime()) - ]]-- - local seq2 = cc.Sequence:create(move_ease_in, createSimpleDelayTime(), move_ease_in_back, createSimpleDelayTime() ) - ---[[ - local arr3 = CCArray:create() - arr3:addObject(move_ease_out) - - arr3:addObject(createSimpleDelayTime()) - arr3:addObject(move_ease_out_back) - - arr3:addObject(createSimpleDelayTime()) - ]]-- - local seq3 = cc.Sequence:create(move_ease_out, createSimpleDelayTime(), move_ease_out_back, createSimpleDelayTime() ) + local seq1 = cc.Sequence:create(move, delay, move_back, createSimpleDelayTime()) + local seq2 = cc.Sequence:create(move_ease_in, createSimpleDelayTime(), move_ease_in_back, createSimpleDelayTime()) + local seq3 = cc.Sequence:create(move_ease_out, createSimpleDelayTime(), move_ease_out_back, createSimpleDelayTime()) grossini:runAction(cc.RepeatForever:create(seq1)) tamara:runAction(cc.RepeatForever:create(seq2)) @@ -231,25 +160,7 @@ local function SpriteEaseExponentialInOut() local move_ease_back = move_ease:reverse() local delay = createSimpleDelayTime() ---[[ - local arr1 = CCArray:create() - arr1:addObject(move) - arr1:addObject(delay) - arr1:addObject(move_back) - - arr1:addObject(createSimpleDelayTime()) -]]-- local seq1 = cc.Sequence:create(move, delay, move_back, createSimpleDelayTime()) - ---[[ - local arr2 = CCArray:create() - arr2:addObject(move_ease) - - arr2:addObject(createSimpleDelayTime()) - arr2:addObject(move_ease_back) - - arr2:addObject(createSimpleDelayTime()) - ]]-- local seq2 = cc.Sequence:create(move_ease, createSimpleDelayTime(), move_ease_back, createSimpleDelayTime() ) positionForTwo() @@ -277,30 +188,9 @@ local function SpriteEaseSine() local move_ease_out_back = move_ease_out:reverse() local delay = createSimpleDelayTime() ---[[ - local arr1 = CCArray:create() - arr1:addObject(move) - arr1:addObject(delay) - arr1:addObject(move_back) - arr1:addObject(createSimpleDelayTime()) - ]]-- local seq1 = cc.Sequence:create(move, delay, move_back, createSimpleDelayTime() ) ---[[ - local arr2 = CCArray:create() - arr2:addObject(move_ease_in) - arr2:addObject(createSimpleDelayTime()) - arr2:addObject(move_ease_in_back) - arr2:addObject(createSimpleDelayTime()) - ]]-- - local seq2 = cc.Sequence:create(move_ease_in, createSimpleDelayTime(), move_ease_in_back, createSimpleDelayTime() ) ---[[ - local arr3 = CCArray:create() - arr3:addObject(move_ease_out) - arr3:addObject(createSimpleDelayTime()) - arr3:addObject(move_ease_out_back) - arr3:addObject(createSimpleDelayTime()) - ]]-- - local seq3 = cc.Sequence:create(move_ease_out, createSimpleDelayTime(), move_ease_out_back,createSimpleDelayTime() ) + local seq2 = cc.Sequence:create(move_ease_in, createSimpleDelayTime(), move_ease_in_back, createSimpleDelayTime()) + local seq3 = cc.Sequence:create(move_ease_out, createSimpleDelayTime(), move_ease_out_back,createSimpleDelayTime()) grossini:runAction(cc.RepeatForever:create(seq1)) tamara:runAction(cc.RepeatForever:create(seq2)) @@ -323,21 +213,7 @@ local function SpriteEaseSineInOut() local move_ease_back = move_ease:reverse() local delay = createSimpleDelayTime() ---[[ - local arr1 = CCArray:create() - arr1:addObject(move) - arr1:addObject(delay) - arr1:addObject(move_back) - arr1:addObject(createSimpleDelayTime()) - ]]-- - local seq1 = cc.Sequence:create(move, delay, move_back, createSimpleDelayTime() ) ---[[ - local arr2 = CCArray:create() - arr2:addObject(move_ease) - arr2:addObject(createSimpleDelayTime()) - arr2:addObject(move_ease_back) - arr2:addObject(createSimpleDelayTime()) - ]]-- + local seq1 = cc.Sequence:create(move, delay, move_back, createSimpleDelayTime()) local seq2 = cc.Sequence:create(move_ease, createSimpleDelayTime(), move_ease_back, createSimpleDelayTime()) positionForTwo() @@ -365,29 +241,8 @@ local function SpriteEaseElastic() local move_ease_out_back = move_ease_out:reverse() local delay = createSimpleDelayTime() ---[[ - local arr1 = CCArray:create() - arr1:addObject(move) - arr1:addObject(delay) - arr1:addObject(move_back) - arr1:addObject(createSimpleDelayTime()) - ]]-- local seq1 = cc.Sequence:create(move, delay, move_back, createSimpleDelayTime() ) ---[[ - local arr2 = CCArray:create() - arr2:addObject(move_ease_in) - arr2:addObject(createSimpleDelayTime()) - arr2:addObject(move_ease_in_back) - arr2:addObject(createSimpleDelayTime()) - ]]-- local seq2 = cc.Sequence:create(move_ease_in, createSimpleDelayTime(), move_ease_in_back, createSimpleDelayTime()) ---[[ - local arr3 = CCArray:create() - arr3:addObject(move_ease_out) - arr3:addObject(createSimpleDelayTime()) - arr3:addObject(move_ease_out_back) - arr3:addObject(createSimpleDelayTime()) - ]]-- local seq3 = cc.Sequence:create(move_ease_out, createSimpleDelayTime(), move_ease_out_back, createSimpleDelayTime()) grossini:runAction(cc.RepeatForever:create(seq1)) @@ -416,29 +271,8 @@ local function SpriteEaseElasticInOut() local move_ease_inout_back3 = move_ease_inout3:reverse() local delay = createSimpleDelayTime() ---[[ - local arr1 = CCArray:create() - arr1:addObject(move_ease_inout1) - arr1:addObject(delay) - arr1:addObject(move_ease_inout_back1) - arr1:addObject(createSimpleDelayTime()) - ]]-- local seq1 = cc.Sequence:create(move_ease_inout1, delay, move_ease_inout_back1, createSimpleDelayTime()) ---[[ - local arr2 = CCArray:create() - arr2:addObject(move_ease_inout2) - arr2:addObject(createSimpleDelayTime()) - arr2:addObject(move_ease_inout_back2) - arr2:addObject(createSimpleDelayTime()) - ]]-- local seq2 = cc.Sequence:create(move_ease_inout2, createSimpleDelayTime(), move_ease_inout_back2, createSimpleDelayTime()) ---[[ - local arr3 = CCArray:create() - arr3:addObject(move_ease_inout3) - arr3:addObject(createSimpleDelayTime()) - arr3:addObject(move_ease_inout_back3) - arr3:addObject(createSimpleDelayTime()) - ]]-- local seq3 = cc.Sequence:create(move_ease_inout3, createSimpleDelayTime(), move_ease_inout_back3, createSimpleDelayTime()) tamara:runAction(cc.RepeatForever:create(seq1)) @@ -465,29 +299,8 @@ local function SpriteEaseBounce() local move_ease_out_back = move_ease_out:reverse() local delay = createSimpleDelayTime() ---[[ - local arr1 = CCArray:create() - arr1:addObject(move) - arr1:addObject(delay) - arr1:addObject(move_back) - arr1:addObject(createSimpleDelayTime()) - ]]-- local seq1 = cc.Sequence:create(move, delay, move_back, createSimpleDelayTime() ) ---[[ - local arr2 = CCArray:create() - arr2:addObject(move_ease_in) - arr2:addObject(createSimpleDelayTime()) - arr2:addObject(move_ease_in_back) - arr2:addObject(createSimpleDelayTime()) - ]]-- - local seq2 = cc.Sequence:create(move_ease_in, createSimpleDelayTime(), move_ease_in_back, createSimpleDelayTime() ) ---[[ - local arr3 = CCArray:create() - arr3:addObject(move_ease_out) - arr3:addObject(createSimpleDelayTime()) - arr3:addObject(move_ease_out_back) - arr3:addObject(createSimpleDelayTime()) - ]]-- + local seq2 = cc.Sequence:create(move_ease_in, createSimpleDelayTime(), move_ease_in_back, createSimpleDelayTime()) local seq3 = cc.Sequence:create(move_ease_out, createSimpleDelayTime(), move_ease_out_back, createSimpleDelayTime()) grossini:runAction(cc.RepeatForever:create(seq1)) @@ -511,21 +324,7 @@ local function SpriteEaseBounceInOut() local move_ease_back = move_ease:reverse() local delay = createSimpleDelayTime() ---[[ - local arr1 = CCArray:create() - arr1:addObject(move) - arr1:addObject(delay) - arr1:addObject(move_back) - arr1:addObject(createSimpleDelayTime()) - ]]-- local seq1 = cc.Sequence:create(move, delay, move_back, createSimpleDelayTime()) ---[[ - local arr2 = CCArray:create() - arr2:addObject(move_ease) - arr2:addObject(createSimpleDelayTime()) - arr2:addObject(move_ease_back) - arr2:addObject(createSimpleDelayTime()) - ]]-- local seq2 = cc.Sequence:create(move_ease, createSimpleDelayTime(), move_ease_back, createSimpleDelayTime()) positionForTwo() @@ -553,29 +352,8 @@ local function SpriteEaseBack() local move_ease_out_back = move_ease_out:reverse() local delay = createSimpleDelayTime() ---[[ - local arr1 = CCArray:create() - arr1:addObject(move) - arr1:addObject(delay) - arr1:addObject(move_back) - arr1:addObject(createSimpleDelayTime()) - ]]-- local seq1 = cc.Sequence:create(move, delay, move_back, createSimpleDelayTime()) ---[[ - local arr2 = CCArray:create() - arr2:addObject(move_ease_in) - arr2:addObject(createSimpleDelayTime()) - arr2:addObject(move_ease_in_back) - arr2:addObject(createSimpleDelayTime()) - ]]-- local seq2 = cc.Sequence:create(move_ease_in, createSimpleDelayTime(), move_ease_in_back, createSimpleDelayTime()) ---[[ - local arr3 = CCArray:create() - arr3:addObject(move_ease_out) - arr3:addObject(createSimpleDelayTime()) - arr3:addObject(move_ease_out_back) - arr3:addObject(createSimpleDelayTime()) - ]]-- local seq3 = cc.Sequence:create(move_ease_out, createSimpleDelayTime(), move_ease_out_back, createSimpleDelayTime()) grossini:runAction(cc.RepeatForever:create(seq1)) @@ -599,21 +377,7 @@ local function SpriteEaseBackInOut() local move_ease_back = move_ease:reverse() local delay = createSimpleDelayTime() ---[[ - local arr1 = CCArray:create() - arr1:addObject(move) - arr1:addObject(delay) - arr1:addObject(move_back) - arr1:addObject(createSimpleDelayTime()) - ]]-- local seq1 = cc.Sequence:create(move, delay, move_back, createSimpleDelayTime()) ---[[ - local arr2 = CCArray:create() - arr2:addObject(move_ease) - arr2:addObject(createSimpleDelayTime()) - arr2:addObject(move_ease_back) - arr2:addObject(createSimpleDelayTime()) - ]]-- local seq2 = cc.Sequence:create(move_ease,createSimpleDelayTime(), move_ease_back, createSimpleDelayTime()) positionForTwo() diff --git a/samples/Lua/TestLua/Resources/luaScript/ActionsProgressTest/ActionsProgressTest.lua b/samples/Lua/TestLua/Resources/luaScript/ActionsProgressTest/ActionsProgressTest.lua index ec1db2e6d1..8d53dcd301 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ActionsProgressTest/ActionsProgressTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ActionsProgressTest/ActionsProgressTest.lua @@ -184,12 +184,6 @@ local function SpriteProgressBarTintAndFade() Helper.initWithLayer(layer) local to = cc.ProgressTo:create(6, 100) - --[[ - local array = CCArray:create() - array:addObject(CCTintTo:create(1, 255, 0, 0)) - array:addObject(CCTintTo:create(1, 0, 255, 0)) - array:addObject(CCTintTo:create(1, 0, 0, 255)) - ]]-- local tint = cc.Sequence:create(cc.TintTo:create(1, 255, 0, 0), cc.TintTo:create(1, 0, 255, 0), cc.TintTo:create(1, 0, 0, 255)) local fade = cc.Sequence:create(cc.FadeTo:create(1.0, 0),cc.FadeTo:create(1.0, 255)) local left = cc.ProgressTimer:create(cc.Sprite:create(s_pPathSister1)) diff --git a/samples/Lua/TestLua/Resources/luaScript/ActionsTest/ActionsTest.lua b/samples/Lua/TestLua/Resources/luaScript/ActionsTest/ActionsTest.lua index f866def795..594c43b12a 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ActionsTest/ActionsTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ActionsTest/ActionsTest.lua @@ -289,14 +289,6 @@ local function ActionCardinalSpline() initWithLayer(layer) centerSprites(2) ---[[ - local array = cc.pArray:create(20) - array:addControlPoint(cc.p(0, 0)) - array:addControlPoint(cc.p(size.width / 2 - 30, 0)) - array:addControlPoint(cc.p(size.width / 2 - 30, size.height - 80)) - array:addControlPoint(cc.p(0, size.height - 80)) - array:addControlPoint(cc.p(0, 0)) -]]-- local array = { cc.p(0, 0), cc.p(size.width / 2 - 30, 0), @@ -353,16 +345,6 @@ local function ActionCatmullRom() centerSprites(2) tamara:setPosition(cc.p(50, 50)) ---[[ - local array = cc.pArray:create(20) - array:addControlPoint(cc.p(0, 0)) - array:addControlPoint(cc.p(80, 80)) - array:addControlPoint(cc.p(size.width - 80, 80)) - array:addControlPoint(cc.p(size.width - 80, size.height - 80)) - array:addControlPoint(cc.p(80, size.height - 80)) - array:addControlPoint(cc.p(80, 80)) - array:addControlPoint(cc.p(size.width / 2, size.height / 2)) - ]]-- local array = { cc.p(0, 0), cc.p(80, 80), @@ -377,14 +359,7 @@ local function ActionCatmullRom() local reverse = action:reverse() local seq = cc.Sequence:create(action, reverse) tamara:runAction(seq) ---[[ - local array2 = cc.pArray:create(20) - array2:addControlPoint(cc.p(size.width / 2, 30)) - array2:addControlPoint(cc.p(size.width -80, 30)) - array2:addControlPoint(cc.p(size.width - 80, size.height - 80)) - array2:addControlPoint(cc.p(size.width / 2, size.height - 80)) - array2:addControlPoint(cc.p(size.width / 2, 30)) - ]]-- + local array2 = { cc.p(size.width / 2, 30), cc.p(size.width -80, 30), @@ -640,16 +615,6 @@ local function ActionSequence2() alignSpritesLeft(1) grossini:setVisible(false) - --[[ - local array = cc.Array:create() - array:addObject(cc.Place:create(cc.p(200,200))) - array:addObject(cc.Show:create()) - array:addObject(cc.MoveBy:create(1, cc.p(100,0))) - array:addObject(cc.CallFunc:create(ActionSequenceCallback1)) - array:addObject(cc.CallFunc:create(ActionSequenceCallback2)) - array:addObject(cc.CallFunc:create(ActionSequenceCallback3)) - ]]-- - local action = cc.Sequence:create(cc.Place:create(cc.p(200,200)),cc.Show:create(),cc.MoveBy:create(1, cc.p(100,0)), cc.CallFunc:create(ActionSequenceCallback1),cc.CallFunc:create(ActionSequenceCallback2),cc.CallFunc:create(ActionSequenceCallback3)) grossini:runAction(action) @@ -707,12 +672,6 @@ local function ActionDelaytime() alignSpritesLeft(1) local move = cc.MoveBy:create(1, cc.p(150,0)) - --[[ - local array = cc.Array:create() - array:addObject(move) - array:addObject(cc.DelayTime:create(2)) - array:addObject(move) - ]]-- local action = cc.Sequence:create(move, cc.DelayTime:create(2), move) grossini:runAction(action) @@ -854,19 +813,7 @@ local function ActionCallFunc() local action = cc.Sequence:create( cc.MoveBy:create(2, cc.p(200,0)), cc.CallFunc:create(CallFucnCallback1) ) ---[[ - local array = cc.Array:create() - array:addObject(cc.ScaleBy:create(2, 2)) - array:addObject(cc.FadeOut:create(2)) - array:addObject(cc.CallFunc:create(CallFucnCallback2)) - ]]-- local action2 = cc.Sequence:create(cc.ScaleBy:create(2, 2),cc.FadeOut:create(2),cc.CallFunc:create(CallFucnCallback2)) ---[[ - local array2 = cc.Array:create() - array2:addObject(cc.RotateBy:create(3 , 360)) - array2:addObject(cc.FadeOut:create(2)) - array2:addObject(cc.CallFunc:create(CallFucnCallback3)) - ]]-- local action3 = cc.Sequence:create(cc.RotateBy:create(3 , 360),cc.FadeOut:create(2),cc.CallFunc:create(CallFucnCallback3)) grossini:runAction(action) @@ -905,12 +852,6 @@ local function ActionReverseSequence() local move1 = cc.MoveBy:create(1, cc.p(250,0)) local move2 = cc.MoveBy:create(1, cc.p(0,50)) - --[[ - local array = cc.Array:create() - array:addObject(move1) - array:addObject(move2) - array:addObject(move1:reverse()) - ]]-- local seq = cc.Sequence:create(move1, move2, move1:reverse()) local action = cc.Sequence:create(seq, seq:reverse()) @@ -935,14 +876,6 @@ local function ActionReverseSequence2() local move2 = cc.MoveBy:create(1, cc.p(0,50)) local tog1 = cc.ToggleVisibility:create() local tog2 = cc.ToggleVisibility:create() - --[[ - local array = cc.Array:createWithCapacity(10) - array:addObject(move1) - array:addObject(tog1) - array:addObject(move2) - array:addObject(tog2) - array:addObject(move1:reverse()) - ]]-- local seq = cc.Sequence:create(move1, tog1, move2, tog2, move1:reverse()) local action = cc.Repeat:create(cc.Sequence:create(seq, seq:reverse()), 3) @@ -953,12 +886,7 @@ local function ActionReverseSequence2() local move_tamara = cc.MoveBy:create(1, cc.p(100,0)) local move_tamara2 = cc.MoveBy:create(1, cc.p(50,0)) local hide = cc.Hide:create() - --[[ - local array2 = cc.Array:createWithCapacity(10) - array2:addObject(move_tamara) - array2:addObject(hide) - array2:addObject(move_tamara2) - ]]-- + local seq_tamara = cc.Sequence:create(move_tamara, hide, move_tamara2) local seq_back = seq_tamara:reverse() tamara:runAction(cc.Sequence:create(seq_tamara, seq_back)) @@ -1056,13 +984,6 @@ local function ActionTargeted() local t1 = cc.TargetedAction:create(kathia, jump2) local t2 = cc.TargetedAction:create(kathia, rot2) ---[[ - local array = cc.Array:createWithCapacity(10) - array:addObject(jump1) - array:addObject(t1) - array:addObject(rot1) - array:addObject(t2) - ]]-- local seq = cc.Sequence:create(jump1, t1, rot1, t2) local always = cc.RepeatForever:create(seq) @@ -1214,17 +1135,6 @@ local function ActionIssue1305_2() local act6 = cc.CallFunc:create(Issue1305_2_log3) local act7 = cc.MoveBy:create(2, cc.p(-100, 0)) local act8 = cc.CallFunc:create(Issue1305_2_log4) ---[[ - local array = cc.Array:create() - array:addObject(act1) - array:addObject(act2) - array:addObject(act3) - array:addObject(act4) - array:addObject(act5) - array:addObject(act6) - array:addObject(act7) - array:addObject(act8) - ]]-- local actF = cc.Sequence:create(act1, act2, act3, act4, act5, act6, act7, act8) cc.Director:getInstance():getActionManager():addAction(actF ,spr, false) @@ -1306,18 +1216,6 @@ local function ActionIssue1327() local act7 = cc.CallFunc:create(logSprRotation) local act8 = cc.RotateBy:create(0.25, 45) local act9 = cc.CallFunc:create(logSprRotation) ---[[ - local array = cc.Array:create() - array:addObject(act1) - array:addObject(act2) - array:addObject(act3) - array:addObject(act4) - array:addObject(act5) - array:addObject(act6) - array:addObject(act7) - array:addObject(act8) - array:addObject(act9) - ]]-- spr:runAction(cc.Sequence:create(act1, act2, act3, act4, act5, act6, act7,act8, act9)) Helper.titleLabel:setString("Issue 1327") diff --git a/samples/Lua/TestLua/Resources/luaScript/BugsTest/BugsTest.lua b/samples/Lua/TestLua/Resources/luaScript/BugsTest/BugsTest.lua index 90325ab93d..e935a44a44 100644 --- a/samples/Lua/TestLua/Resources/luaScript/BugsTest/BugsTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/BugsTest/BugsTest.lua @@ -69,17 +69,12 @@ local function BugTest422() pMenuItem1:registerScriptTapHandler(menuCallback) local pMenuItem2 = cc.MenuItemFont:create("Two") pMenuItem2:registerScriptTapHandler(menuCallback) - --[[ - local arr = cc.Array:create() - arr:addObject(pMenuItem1) - arr:addObject(pMenuItem2) - ]]-- local pMenu = cc.Menu:create(pMenuItem1, pMenuItem2) pMenu:alignItemsVertically() local fX = math.random() * 50 local fY = math.random() * 50 - local menuPos = pMenu:getPosition() - pMenu:setPosition(cc.p(menuPos.x + fX,menuPos.y + fY)) + local menuPosX ,menuPosY = pMenu:getPosition() + pMenu:setPosition(cc.p(menuPosX + fX,menuPosY + fY)) pResetLayer:addChild(pMenu,0,nLocalTag) end @@ -117,8 +112,7 @@ local function BugTest458() pCorner:setPosition(cc.p(-(nWidth / 2 + pCorner:getContentSize().width / 2), -(nHeight / 2 + pCorner:getContentSize().height / 2))); pSprite:addChild(pCorner); - local posCorner = pCorner:getPosition() - local nX,nY = posCorner.x,posCorner.y + local nX,nY = pCorner:getPosition() local pCorner2 = cc.Sprite:create("Images/bugs/corner.png"); pCorner2:setPosition(cc.p(-nX, nY)); pCorner2:setFlipX(true); @@ -178,11 +172,6 @@ local function BugTest458() local pLayerColor2 = cc.LayerColor:create(cc.c4b(255,0,0,255), 100, 100); local pMenuItemSprite2 = cc.MenuItemSprite:create(pLayerColor1, pLayerColor2); pMenuItemSprite2:registerScriptTapHandler(menuCallback) ---[[ - local arr = cc.Array:create() - arr:addObject(pMenuItemSprite) - arr:addObject(pMenuItemSprite2) - ]]-- local pMenu = cc.Menu:create(pMenuItemSprite, pMenuItemSprite2) pMenu:alignItemsVerticallyWithPadding(100); pMenu:setPosition(cc.p(Winsize.width / 2, Winsize.height / 2)); @@ -380,12 +369,6 @@ local function BugTest1159() sprite_a:ignoreAnchorPointForPosition(false) sprite_a:setPosition(cc.p(0.0, Winsize.height/2)) pLayer:addChild(sprite_a) - ---[[ - local arr = cc.Array:create() - arr:addObject(cc.MoveTo:create(1.0, cc.p(1024.0, 384.0))) - arr:addObject(cc.MoveTo:create(1.0, cc.p(0.0, 384.0))) - ]]-- local seq = cc.Sequence:create(cc.MoveTo:create(1.0, cc.p(1024.0, 384.0)), cc.MoveTo:create(1.0, cc.p(0.0, 384.0))) sprite_a:runAction(cc.RepeatForever:create(seq)) @@ -430,13 +413,13 @@ local function BugTest1174() local pLayer = cc.Layer:create() local function check_for_error(p1,p2,p3,p4,s,t) - local p4_p3 = cc.p.__sub(p4,p3) - local p4_p3_t = cc.p.__mul(p4_p3,t) - local hitp1 = cc.p.__add(p3,p4_p3_t) + local p4_p3 = cc.pSub(p4,p3) + local p4_p3_t = cc.pMul(p4_p3,t) + local hitp1 = cc.pAdd(p3,p4_p3_t) - local p2_p1 = cc.p.__sub(p2,p1) - local p2_p1_s = cc.p.__mul(p2_p1,s) - local hitp2 = cc.p.__add(p1,p2_p1_s) + local p2_p1 = cc.pSub(p2,p1) + local p2_p1_s = cc.pMul(p2_p1,s) + local hitp2 = cc.pAdd(p1,p2_p1_s) if math.abs(hitp1.x - hitp2.x ) > 0.1 or math.abs(hitp1.y - hitp2.y) > 0.1 then local strErr = "ERROR: ("..hitp1.x..","..hitp1.y..") != ("..hitp2.x..","..hitp2.y..")" @@ -491,7 +474,7 @@ local function BugTest1174() C = cc.p(cx,cy) D = cc.p(dx,dy) - bRet,s,t = cc.p:isLineIntersect( A, D, B, C, s, t) + bRet,s,t = cc.pIsLineIntersect( A, D, B, C, s, t) if true == bRet then if 1 == check_for_error(A,D,B,C,s,t) then err = err + 1 @@ -513,7 +496,7 @@ local function BugTest1174() p4 = cc.p(186,416); s = 0.0; t = 0.0; - bRet,s,t = cc.p:isLineIntersect( p1, p2, p3, p4, s, t) + bRet,s,t = cc.pIsLineIntersect( p1, p2, p3, p4, s, t) if true == bRet then check_for_error(p1, p2, p3, p4, s, t) end @@ -558,7 +541,7 @@ local function BugTest1174() s = 0.0 t = 0.0 - bRet,s,t = cc.p:isLineIntersect(p1, p2, p3, p4, s, t) + bRet,s,t = cc.pIsLineIntersect(p1, p2, p3, p4, s, t) if true == bRet then if 1 == check_for_error(p1, p2, p3, p4, s,t ) then err = err + 1 @@ -635,8 +618,7 @@ local function BugsTestMainLayer() local function onTouchMoved(x, y) local nMoveY = y - ptBeginPos.y - local curPos = pItemMenu:getPosition() - local curPosx, curPosy = curPos.x,curPos.y + local curPosx, curPosy = pItemMenu:getPosition() local nextPosy = curPosy + nMoveY if nextPosy < 0 then pItemMenu:setPosition(0, 0) diff --git a/samples/Lua/TestLua/Resources/luaScript/ClickAndMoveTest/ClickAndMoveTest.lua b/samples/Lua/TestLua/Resources/luaScript/ClickAndMoveTest/ClickAndMoveTest.lua index 8bd2dd4250..781a8824e6 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ClickAndMoveTest/ClickAndMoveTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ClickAndMoveTest/ClickAndMoveTest.lua @@ -21,8 +21,7 @@ local function initWithLayer() local s = layer:getChildByTag(kTagSprite) s:stopAllActions() s:runAction(cc.MoveTo:create(1, cc.p(x, y))) - local pos = s:getPosition() - local posX, posY = pos.x,pos.y + local posX, posY = s:getPosition() local o = x - posX local a = y - posY local at = math.atan(o / a) / math.pi * 180.0 diff --git a/samples/Lua/TestLua/Resources/luaScript/CocosDenshionTest/CocosDenshionTest.lua b/samples/Lua/TestLua/Resources/luaScript/CocosDenshionTest/CocosDenshionTest.lua index ef25bb978b..62aef54479 100644 --- a/samples/Lua/TestLua/Resources/luaScript/CocosDenshionTest/CocosDenshionTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/CocosDenshionTest/CocosDenshionTest.lua @@ -138,8 +138,7 @@ local function CocosDenshionTest() elseif eventType == "moved" then local touchLocation = cc.p(x, y) local nMoveY = touchLocation.y - m_tBeginPos.y - local curPos = m_pItmeMenu:getPosition() - local curPosX, curPosY = curPos.x,curPos.y + local curPosX, curPosY = m_pItmeMenu:getPosition() local curPos = cc.p(curPosX, curPosY) local nextPos = cc.p(curPos.x, curPos.y + nMoveY) diff --git a/samples/Lua/TestLua/Resources/luaScript/LayerTest/LayerTest.lua b/samples/Lua/TestLua/Resources/luaScript/LayerTest/LayerTest.lua index 04e54d2842..86b67ca4c8 100644 --- a/samples/Lua/TestLua/Resources/luaScript/LayerTest/LayerTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/LayerTest/LayerTest.lua @@ -40,9 +40,9 @@ local function setEnableRecursiveCascading(node, enable) return end - if node.__CCRGBAProtocol__ ~= nil then - node.__CCRGBAProtocol__:setCascadeColorEnabled(enable) - node.__CCRGBAProtocol__:setCascadeOpacityEnabled(enable) + if node.setCascadeColorEnabled ~= nil and node.setCascadeOpacityEnabled ~= nil then + node:setCascadeColorEnabled(enable) + node:setCascadeOpacityEnabled(enable) end local obj = nil @@ -56,9 +56,7 @@ local function setEnableRecursiveCascading(node, enable) local i = 0 local len = table.getn(children) for i = 0, len-1, 1 do - print("come in") - local child = tolua.cast(children[i + 1], "Node") - setEnableRecursiveCascading(child, enable) + setEnableRecursiveCascading(children[i + 1], enable) end end diff --git a/samples/Lua/TestLua/Resources/luaScript/MenuTest/MenuTest.lua b/samples/Lua/TestLua/Resources/luaScript/MenuTest/MenuTest.lua index cb2dc86af3..0e8d723b25 100644 --- a/samples/Lua/TestLua/Resources/luaScript/MenuTest/MenuTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/MenuTest/MenuTest.lua @@ -164,8 +164,7 @@ local function MenuLayerMainMenu() break end child = tolua.cast(pObject, "Node") - local dstPoint = child:getPosition() - local dstPointX, dstPointY = dstPoint.x,dstPoint.y + local dstPointX, dstPointY = child:getPosition() local offset = s.width/2 + 50 if i % 2 == 0 then offset = 0-offset @@ -217,14 +216,12 @@ local function MenuLayer2() if i==0 then -- TIP: if no padding, padding = 5 menu:alignItemsHorizontally() - local menuPos = menu:getPosition() - local x, y = menuPos.x,menuPos.y + local x, y = menu:getPosition() menu:setPosition( cc.pAdd(cc.p(x, y), cc.p(0,30)) ) else -- TIP: but padding is configurable menu:alignItemsHorizontallyWithPadding(40) - local menuPos = menu:getPosition() - local x, y = menuPos.x,menuPos.y + local x, y = menu:getPosition() menu:setPosition( cc.pSub(cc.p(x, y), cc.p(0,30)) ) end end @@ -238,14 +235,12 @@ local function MenuLayer2() if i==0 then -- TIP: if no padding, padding = 5 menu:alignItemsVertically() - local menuPos = menu:getPosition() - local x, y = menuPos.x,menuPos.y + local x, y = menu:getPosition() menu:setPosition( cc.pAdd(cc.p(x, y), cc.p(100,0)) ) else -- TIP: but padding is configurable menu:alignItemsVerticallyWithPadding(40) - local menuPos = menu:getPosition() - local x, y = menuPos.x,menuPos.y + local x, y = menu:getPosition() menu:setPosition( cc.pSub(cc.p(x, y), cc.p(100,0)) ) end end @@ -302,8 +297,7 @@ local function MenuLayer2() menu:setTag( kTagMenu ) ret:addChild(menu, 0, 100+i) - local menuPos = menu:getPosition() - local x, y = menuPos.x,menuPos.y + local x, y = menu:getPosition() m_centeredMenu = cc.p(x, y) end diff --git a/samples/Lua/TestLua/Resources/luaScript/OpenGLTest/OpenGLTest.lua b/samples/Lua/TestLua/Resources/luaScript/OpenGLTest/OpenGLTest.lua index a840ccd203..91ac6844e4 100644 --- a/samples/Lua/TestLua/Resources/luaScript/OpenGLTest/OpenGLTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/OpenGLTest/OpenGLTest.lua @@ -148,8 +148,7 @@ local function OpenGLTestMainLayer() local len = table.getn(children) for i= 0 ,len - 1 do local child = tolua.cast(children[i + 1], "Sprite") - local oldPos = child:getPosition() - local oldPosX,oldPosY = oldPos.x, oldPos.y + local oldPosX,oldPosY = child:getPosition() child:setPosition(oldPosX,math.sin(accum * 2 + i / 2.0) * 20) local scaleY = math.sin(accum * 2 + i / 2.0 + 0.707) child:setScaleY(scaleY) diff --git a/samples/Lua/TestLua/Resources/luaScript/ParticleTest/ParticleTest.lua b/samples/Lua/TestLua/Resources/luaScript/ParticleTest/ParticleTest.lua index ad3f22d36b..8b4dca5692 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ParticleTest/ParticleTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ParticleTest/ParticleTest.lua @@ -487,8 +487,7 @@ local function DemoFire() background:addChild(emitter, 10) emitter:setTexture(cc.TextureCache:getInstance():addImage(s_fire)) - local pos = emitter:getPosition() - local pos_x, pos_y = pos.x, pos.y + local pos_x, pos_y = emitter:getPosition() emitter:setPosition(pos_x, 100) titleLabel:setString("ParticleFire") @@ -505,8 +504,7 @@ local function DemoSmoke() -- emitter:retain() background:addChild(emitter, 10) emitter:setTexture(cc.TextureCache:getInstance():addImage(s_fire)) - local pos = emitter:getPosition() - local pos_x, pos_y = pos.x, pos.y + local pos_x, pos_y = emitter:getPosition() emitter:setPosition(pos_x, 100) setEmitterPosition() @@ -544,8 +542,7 @@ local function DemoSnow() emitter = cc.ParticleSnow:create() -- emitter:retain() background:addChild(emitter, 10) - local pos = emitter:getPosition() - local pos_x, pos_y = pos.x, pos.y + local pos_x, pos_y = emitter:getPosition() emitter:setPosition(pos_x, pos_y - 110) emitter:setLife(3) emitter:setLifeVar(1) @@ -586,8 +583,7 @@ local function DemoRain() emitter = cc.ParticleRain:create() -- emitter:retain() background:addChild(emitter, 10) - local pos = emitter:getPosition() - local pos_x, pos_y = pos.x, pos.y + local pos_x, pos_y = emitter:getPosition() emitter:setPosition(pos_x, pos_y - 100) emitter:setLife(4) diff --git a/samples/Lua/TestLua/Resources/luaScript/TileMapTest/TileMapTest.lua b/samples/Lua/TestLua/Resources/luaScript/TileMapTest/TileMapTest.lua index b80891af25..96e6073d9e 100644 --- a/samples/Lua/TestLua/Resources/luaScript/TileMapTest/TileMapTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/TileMapTest/TileMapTest.lua @@ -816,7 +816,7 @@ local function TMXIsoZorder() m_tamara:runAction( cc.RepeatForever:create(seq) ) local function repositionSprite(dt) - local p = m_tamara:getPosition() + local p = cc.p(m_tamara:getPosition()) p = CC_POINT_POINTS_TO_PIXELS(p) local map = ret:getChildByTag(kTagTileMap) @@ -874,7 +874,7 @@ local function TMXOrthoZorder() m_tamara:runAction( cc.RepeatForever:create(seq)) local function repositionSprite(dt) - local p = m_tamara:getPosition() + local p = cc.p(m_tamara:getPosition()) p = CC_POINT_POINTS_TO_PIXELS(p) local map = ret:getChildByTag(kTagTileMap) @@ -935,7 +935,7 @@ local function TMXIsoVertexZ() -- tile height is 64x32 -- map size: 30x30 - local p = m_tamara:getPosition() + local p = cc.p(m_tamara:getPosition()) p = CC_POINT_POINTS_TO_PIXELS(p) local newZ = -(p.y+32) /16 m_tamara:setVertexZ( newZ ) @@ -991,7 +991,7 @@ local function TMXOrthoVertexZ() local function repositionSprite(dt) -- tile height is 101x81 -- map size: 12x12 - local p = m_tamara:getPosition() + local p = cc.p(m_tamara:getPosition()) p = CC_POINT_POINTS_TO_PIXELS(p) m_tamara:setVertexZ( -( (p.y+81) /81) ) end diff --git a/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua b/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua index 1e2bb48e4f..2ca0f087f2 100644 --- a/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua +++ b/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua @@ -162,8 +162,7 @@ function CreateTestMenu() local function onTouchMoved(x, y) local nMoveY = y - BeginPos.y - local curPos = MainMenu:getPosition() - local curPosx, curPosy = curPos.x,curPos.y + local curPosx, curPosy = MainMenu:getPosition() local nextPosy = curPosy + nMoveY local winSize = cc.Director:getInstance():getWinSize() if nextPosy < 0 then diff --git a/scripting/lua/cocos2dx_support/CCLuaStack.cpp b/scripting/lua/cocos2dx_support/CCLuaStack.cpp index 143534d437..085f63f895 100644 --- a/scripting/lua/cocos2dx_support/CCLuaStack.cpp +++ b/scripting/lua/cocos2dx_support/CCLuaStack.cpp @@ -51,6 +51,7 @@ extern "C" { #include "lua_cocos2dx_manual.hpp" #include "LuaBasicConversions.h" #include "lua_cocos2dx_extension_manual.h" +#include "lua_cocos2dx_deprecated.h" namespace { int lua_print(lua_State * luastate) @@ -130,10 +131,12 @@ bool LuaStack::init(void) g_luaType.clear(); register_all_cocos2dx(_state); register_all_cocos2dx_extension(_state); + register_all_cocos2dx_deprecated(_state); register_cocos2dx_extension_CCBProxy(_state); tolua_opengl_open(_state); register_all_cocos2dx_manual(_state); register_all_cocos2dx_extension_manual(_state); + register_all_cocos2dx_manual_deprecated(_state); #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) LuaObjcBridge::luaopen_luaoc(_state); #endif diff --git a/scripting/lua/cocos2dx_support/LuaBasicConversions.cpp b/scripting/lua/cocos2dx_support/LuaBasicConversions.cpp index 27b8888883..9b389e25a7 100644 --- a/scripting/lua/cocos2dx_support/LuaBasicConversions.cpp +++ b/scripting/lua/cocos2dx_support/LuaBasicConversions.cpp @@ -1115,11 +1115,12 @@ void fontdefinition_to_luaval(lua_State* L,const FontDefinition& inValue) void array_to_luaval(lua_State* L,Array* inValue) { + lua_newtable(L); + if (nullptr == L || nullptr == inValue) return; Object* obj = nullptr; - lua_newtable(L); std::string className = ""; String* strVal = nullptr; @@ -1204,11 +1205,12 @@ void array_to_luaval(lua_State* L,Array* inValue) void dictionary_to_luaval(lua_State* L, Dictionary* dict) { + lua_newtable(L); + if (nullptr == L || nullptr == dict) return; DictElement* element = nullptr; - lua_newtable(L); std::string className = ""; String* strVal = nullptr; diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id index 50f2ae2029..a079474a29 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id @@ -1 +1 @@ -e4cde349657e805611bb37bf5123dac55dad4381 \ No newline at end of file +451f7b8e8003474fb17be07923476ea2f12a9122 \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.hpp b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.hpp index 8033110aff..5dcc6b742c 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.hpp +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.hpp @@ -2065,9 +2065,6 @@ int register_all_cocos2dx(lua_State* tolua_S); - - - diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id index 5f8959c762..ecb3af7f4c 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id @@ -1 +1 @@ -f36d9af5f8cb5dd623c2963b6c433e90bbad9570 \ No newline at end of file +7ec8c685dde8f273f39cb13c8e009d9bca6e0e53 \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id index 7717b7c83b..55cb9b86aa 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id @@ -1 +1 @@ -99f6cd0f27234a5dc217c264746002c73b30c08e \ No newline at end of file +2c817ab849fe61f97c010cf5e9b6528bca2a0396 \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/lua_cocos2dx_deprecated.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/lua_cocos2dx_deprecated.cpp.REMOVED.git-id new file mode 100644 index 0000000000..b3b4027b66 --- /dev/null +++ b/scripting/lua/cocos2dx_support/lua_cocos2dx_deprecated.cpp.REMOVED.git-id @@ -0,0 +1 @@ +6bb676eae227e4e547cbeaea273b5289354d5a89 \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/lua_cocos2dx_deprecated.h b/scripting/lua/cocos2dx_support/lua_cocos2dx_deprecated.h new file mode 100644 index 0000000000..62bea3bf27 --- /dev/null +++ b/scripting/lua/cocos2dx_support/lua_cocos2dx_deprecated.h @@ -0,0 +1,15 @@ +#ifndef COCOS2DX_SCRIPT_LUA_COCOS2DX_SUPPORT_LUA_COCOS2DX_DEPRECATED_H +#define COCOS2DX_SCRIPT_LUA_COCOS2DX_SUPPORT_LUA_COCOS2DX_DEPRECATED_H + +#ifdef __cplusplus +extern "C" { +#endif +#include "tolua++.h" +#ifdef __cplusplus +} +#endif + +TOLUA_API int register_all_cocos2dx_deprecated(lua_State* tolua_S); +TOLUA_API int register_all_cocos2dx_manual_deprecated(lua_State* tolua_S); + +#endif // #ifndef COCOS2DX_SCRIPT_LUA_COCOS2DX_SUPPORT_LUA_COCOS2DX_DEPRECATED_H diff --git a/scripting/lua/cocos2dx_support/lua_cocos2dx_manual.cpp b/scripting/lua/cocos2dx_support/lua_cocos2dx_manual.cpp index 5f8e226167..c3ee4d2e0c 100644 --- a/scripting/lua/cocos2dx_support/lua_cocos2dx_manual.cpp +++ b/scripting/lua/cocos2dx_support/lua_cocos2dx_manual.cpp @@ -1172,6 +1172,56 @@ tolua_lerror: #endif } +static int tolua_cocos2d_Node_getPosition(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + Node* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"Node",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(tolua_S,1,0)); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Node_getPosition'\n", NULL); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc >= 0 && argc <= 2) + { +#if COCOS2D_DEBUG >= 1 + if (!tolua_isnumber(tolua_S,2,1,&tolua_err) || !tolua_isnumber(tolua_S,3,1,&tolua_err) ) + goto tolua_lerror; +#endif + float x = (float) tolua_tonumber(tolua_S,2,0); + float y = (float) tolua_tonumber(tolua_S,3,0); + + self->getPosition(&x,&y); + + tolua_pushnumber(tolua_S,(lua_Number)x); + tolua_pushnumber(tolua_S,(lua_Number)y); + + return 2; + } + + CCLOG("'getPosition' function in Node has wrong number of arguments: %d, was expecting %d\n", argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'getPosition'.",&tolua_err); + return 0; +#endif +} + static int tolua_cocos2d_Spawn_create(lua_State* tolua_S) { if (NULL == tolua_S) @@ -2356,6 +2406,9 @@ static void extendNode(lua_State* tolua_S) lua_pushstring(tolua_S,"unscheduleUpdate"); lua_pushcfunction(tolua_S,tolua_cocos2d_Node_unscheduleUpdate); lua_rawset(tolua_S, -3); + lua_pushstring(tolua_S,"getPosition"); + lua_pushcfunction(tolua_S,tolua_cocos2d_Node_getPosition); + lua_rawset(tolua_S, -3); } } diff --git a/scripting/lua/script/Cocos2d.lua b/scripting/lua/script/Cocos2d.lua index cc6b948c82..12e853c043 100644 --- a/scripting/lua/script/Cocos2d.lua +++ b/scripting/lua/script/Cocos2d.lua @@ -29,7 +29,7 @@ function cc.pForAngle(a) end function cc.pGetLength(pt) - return math.sqrt( pt.x * pt.x + pt.y * pt.y ); + return math.sqrt( pt.x * pt.x + pt.y * pt.y ) end function cc.pNormalize(pt) @@ -68,6 +68,36 @@ function cc.pGetDistance(startP,endP) return cc.pGetLength(cc.pSub(startP,endP)) end +function cc.pIsLineIntersect(A, B, C, D, s, t) + if ((A.x == B.x) and (A.y == B.y)) or ((C.x == D.x) and (C.y == D.y))then + return false, s, t + end + + local BAx = B.x - A.x + local BAy = B.y - A.y + local DCx = D.x - C.x + local DCy = D.y - C.y + local ACx = A.x - C.x + local ACy = A.y - C.y + + local denom = DCy * BAx - DCx * BAy + s = DCx * ACy - DCy * ACx + t = BAx * ACy - BAy * ACx + + if (denom == 0) then + if (s == 0 or t == 0) then + return true, s , t + end + + return false, s, t + end + + s = s / denom + t = t / denom + + return true,s,t +end + --Size function cc.size( _width,_height ) return { width = _width, height = _height } @@ -97,7 +127,7 @@ function cc.rectGetMidX(rect) end function cc.rectGetMinX(rect) - return rect.x; + return rect.x end function cc.rectGetMaxY(rect) @@ -149,7 +179,7 @@ function cc.rectIntersection( rect1, rect2 ) intersection.width = math.min(rect1.x + rect1.width, rect2.x + rect2.width) - intersection.x intersection.height = math.min(rect1.y + rect1.height, rect2.y + rect2.height) - intersection.y - return intersection; + return intersection end --Color3B diff --git a/scripting/lua/script/Deprecated.lua b/scripting/lua/script/Deprecated.lua index cd0ccf6cde..1e41223323 100644 --- a/scripting/lua/script/Deprecated.lua +++ b/scripting/lua/script/Deprecated.lua @@ -1,8 +1,199 @@ +require "Cocos2d.lua" --tip local function deprecatedTip(old_name,new_name) print("\n********** \n"..old_name.." was deprecated please use ".. new_name .. " instead.\n**********") end +--CCDirector class will be Deprecated,begin +local function CCDirectorClassDeprecated( ) + deprecatedTip("CCDirector","cc.Director") + return cc.Director +end +_G["CCDirector"] = CCDirectorClassDeprecated() + + +--functions of CCDirector will be deprecated,begin +local CCDirectorDeprecated = { } +function CCDirectorDeprecated.sharedDirector() + deprecatedTip("CCDirector:sharedDirector","cc.Director:getInstance") + return cc.Director:getInstance() +end +rawset(CCDirector,"sharedDirector",CCDirectorDeprecated.sharedDirector) + +--functions of CCDirector will be deprecated,end +--CCDirector class will be Deprecated,end + + +--CCTextureCache class will be Deprecated,begin +local function CCTextureCacheClassDeprecated( ) + deprecatedTip("CCTextureCache ","cc.TextureCache") + return cc.TextureCache +end +_G["CCTextureCache"] = CCTextureCacheClassDeprecated() + +--functions of CCTextureCache will be deprecated begin +local CCTextureCacheDeprecated = { } +function CCTextureCacheDeprecated.sharedTextureCache() + deprecatedTip("CCTextureCache:sharedTextureCache","CCTextureCache:getInstance") + return cc.TextureCache:getInstance() +end +rawset(CCTextureCache,"sharedTextureCache",CCTextureCacheDeprecated.sharedTextureCache) + +function CCTextureCacheDeprecated.purgeSharedTextureCache() + deprecatedTip("CCTextureCache:purgeSharedTextureCache","CCTextureCache:destroyInstance") + return cc.TextureCache:destroyInstance() +end +rawset(CCTextureCache,"purgeSharedTextureCache",CCTextureCacheDeprecated.purgeSharedTextureCache) +--functions of CCTextureCache will be deprecated end +--CCTextureCache class will be Deprecated,end + +--CCSpriteFrame class will be Deprecated,begin +local function CCSpriteFrameClassDeprecated( ) + deprecatedTip("CCSpriteFrame ","cc.SpriteFrame") + return cc.SpriteFrame +end +_G["CCSpriteFrame"] = CCSpriteFrameClassDeprecated() + +--CCSpriteFrame class will be Deprecated,end + +--CCSprite class will be Deprecated,begin +local function CCSpriteClassDeprecated( ) + deprecatedTip("CCSprite ","cc.Sprite") + return cc.Sprite +end +_G["CCSprite"] = CCSpriteClassDeprecated() + +--CCSprite class will be Deprecated,end + +--CCAnimation class will be Deprecated,begin +local function CCAnimationClassDeprecated( ) + deprecatedTip("CCAnimation ","cc.Animation") + return cc.Animation +end +_G["CCAnimation"] = CCAnimationClassDeprecated() + +--CCAnimation class will be Deprecated,end + +--CCAnimate class will be Deprecated,begin +local function CCAnimateClassDeprecated( ) + deprecatedTip("CCAnimate ","cc.Animate") + return cc.Animate +end +_G["CCAnimate"] = CCAnimateClassDeprecated() + +--CCAnimate class will be Deprecated,end + +--CCRepeatForever class will be Deprecated,begin +local function CCRepeatForeverClassDeprecated( ) + deprecatedTip("CCRepeatForever ","cc.RepeatForever") + return cc.RepeatForever +end +_G["CCRepeatForever"] = CCRepeatForeverClassDeprecated() + +--CCRepeatForever class will be Deprecated,end + +--CCLayer class will be Deprecated,begin +local function CCLayerClassDeprecated( ) + deprecatedTip("CCLayer ","cc.Layer") + return cc.Layer +end +_G["CCLayer"] = CCLayerClassDeprecated() +--CCLayer class will be Deprecated,end + +--CCScene class will be Deprecated,begin +local function CCSceneClassDeprecated( ) + deprecatedTip("CCScene ","cc.Scene") + return cc.Scene +end +_G["CCScene"] = CCSceneClassDeprecated() +--CCScene class will be Deprecated,end + +--CCFileUtils class will be Deprecated,begin +local function CCFileUtilsClassDeprecated( ) + deprecatedTip("CCFileUtils ","cc.FileUtils") + return cc.FileUtils +end +_G["CCFileUtils"] = CCFileUtilsClassDeprecated() + +--functions of CCFileUtils will be deprecated end +local CCFileUtilsDeprecated = { } +function CCFileUtilsDeprecated.sharedFileUtils() + deprecatedTip("CCFileUtils:sharedFileUtils","CCFileUtils:getInstance") + return cc.FileUtils:getInstance() +end +rawset(CCFileUtils,"sharedFileUtils",CCFileUtilsDeprecated.sharedFileUtils) + +function CCFileUtilsDeprecated.purgeFileUtils() + deprecatedTip("CCFileUtils:purgeFileUtils","CCFileUtils:destroyInstance") + return cc.FileUtils:destroyInstance() +end +rawset(CCFileUtils,"purgeFileUtils",CCFileUtilsDeprecated.purgeFileUtils) +--functions of CCFileUtils will be deprecated end +--CCFileUtils class will be Deprecated,end + +--SimpleAudioEngine will be deprecated begin +local function SimpleAudioEngineClassDeprecated( ) + deprecatedTip("SimpleAudioEngine ","cc.SimpleAudioEngine") + return cc.SimpleAudioEngine +end +_G["SimpleAudioEngine"] = SimpleAudioEngineClassDeprecated() + +--functions of SimpleAudioEngine will be deprecated begin + +local SimpleAudioEngineDeprecated = { } +function SimpleAudioEngineDeprecated.sharedEngine() + deprecatedTip("SimpleAudioEngine:sharedEngine","SimpleAudioEngine:getInstance") + return cc.SimpleAudioEngine:getInstance() +end +rawset(SimpleAudioEngine,"sharedEngine",SimpleAudioEngineDeprecated.sharedEngine) + +function SimpleAudioEngineDeprecated.playBackgroundMusic(self,...) + deprecatedTip("SimpleAudioEngine:playBackgroundMusic","SimpleAudioEngine:playMusic") + return self:playMusic(...) +end +rawset(SimpleAudioEngine,"playBackgroundMusic",SimpleAudioEngineDeprecated.playBackgroundMusic) + +--functions of SimpleAudioEngine will be deprecated end + +--SimpleAudioEngine class will be Deprecated,end + +--CCMenuItemImage will be deprecated begin +local function CCMenuItemImageClassDeprecated( ) + deprecatedTip("CCMenuItemImage ","cc.MenuItemImage") + return cc.MenuItemImage +end +_G["CCMenuItemImage"] = CCMenuItemImageClassDeprecated( ) + +--CCMenu will be deprecated end + +--CCMenu will be deprecated begin +local function CCMenuClassDeprecated( ) + deprecatedTip("CCMenu ","cc.Menu") + return cc.Menu +end +_G["CCMenu"] = cc.Menu + +--functions of SimpleAudioEngine will be deprecated begin + +local CCMenuDeprecated = { } +function CCMenuDeprecated.createWithItem(self,...) + deprecatedTip("CCMenuDeprecated:createWithItem","cc.Menu:create") + return self:create(...) +end +rawset(CCMenu,"createWithItem",CCMenuDeprecated.createWithItem) +--functions of SimpleAudioEngine will be deprecated end + +--CCMenu will be deprecated end + +--global functions wil be deprecated, begin +local function CCRectMake(x,y,width,height) + deprecatedTip("CCRectMake(x,y,width,height)","CCRect(x,y,width,height) in lua") + return CCRect(x,y,width,height) +end +rawset(_G,"CCRectMake",CCRectMake) +--global functions wil be deprecated, end + + --functions of _G will be deprecated begin local function ccpLineIntersect(a,b,c,d,s,t) deprecatedTip("ccpLineIntersect","CCPoint:isLineIntersect") @@ -29,12 +220,6 @@ local function CCSizeMake(width,height) end rawset(_G,"CCSizeMake",CCSizeMake) -local function CCRectMake(x,y,width,height) - deprecatedTip("CCRectMake(x,y,width,height)","CCRect(x,y,width,height)") - return CCRect(x,y,width,height) -end -rawset(_G,"CCRectMake",CCRectMake) - local function ccpNeg(pt) deprecatedTip("ccpNeg","CCPoint.__sub") return CCPoint.__sub(CCPoint:new_local(0,0),pt) @@ -408,22 +593,6 @@ rawset(CCEGLView,"sharedOpenGLView",CCEGLViewDeprecated.sharedOpenGLView) --functions of CCFileUtils will be deprecated end ---functions of CCFileUtils will be deprecated end -local CCFileUtilsDeprecated = { } -function CCFileUtilsDeprecated.sharedFileUtils() - deprecatedTip("CCFileUtils:sharedFileUtils","CCFileUtils:getInstance") - return CCFileUtils:getInstance() -end -rawset(CCFileUtils,"sharedFileUtils",CCFileUtilsDeprecated.sharedFileUtils) - -function CCFileUtilsDeprecated.purgeFileUtils() - deprecatedTip("CCFileUtils:purgeFileUtils","CCFileUtils:destroyInstance") - return CCFileUtils:destroyInstance() -end -rawset(CCFileUtils,"purgeFileUtils",CCFileUtilsDeprecated.purgeFileUtils) ---functions of CCFileUtils will be deprecated end - - --functions of CCApplication will be deprecated end local CCApplicationDeprecated = { } function CCApplicationDeprecated.sharedApplication() @@ -476,22 +645,6 @@ rawset(CCNotificationCenter,"purgeNotificationCenter",CCNotificationCenterDeprec --functions of CCNotificationCenter will be deprecated end ---functions of CCTextureCache will be deprecated begin -local CCTextureCacheDeprecated = { } -function CCTextureCacheDeprecated.sharedTextureCache() - deprecatedTip("CCTextureCache:sharedTextureCache","CCTextureCache:getInstance") - return CCTextureCache:getInstance() -end -rawset(CCTextureCache,"sharedTextureCache",CCTextureCacheDeprecated.sharedTextureCache) - -function CCTextureCacheDeprecated.purgeSharedTextureCache() - deprecatedTip("CCTextureCache:purgeSharedTextureCache","CCTextureCache:destroyInstance") - return CCTextureCache:destroyInstance() -end -rawset(CCTextureCache,"purgeSharedTextureCache",CCTextureCacheDeprecated.purgeSharedTextureCache) ---functions of CCTextureCache will be deprecated end - - --functions of CCGrid3DAction will be deprecated begin local CCGrid3DActionDeprecated = { } function CCGrid3DActionDeprecated.vertex(self,pt) @@ -697,17 +850,6 @@ end rawset(CCTMXLayer,"propertyNamed",CCTMXLayerDeprecated.propertyNamed) --functions of CCTMXLayer will be deprecated end - ---functions of SimpleAudioEngine will be deprecated begin -local SimpleAudioEngineDeprecated = { } -function SimpleAudioEngineDeprecated.sharedEngine() - deprecatedTip("SimpleAudioEngine:sharedEngine","SimpleAudioEngine:getInstance") - return SimpleAudioEngine:getInstance() -end -rawset(SimpleAudioEngine,"sharedEngine",SimpleAudioEngineDeprecated.sharedEngine) ---functions of SimpleAudioEngine will be deprecated end - - --functions of CCTMXTiledMap will be deprecated begin local CCTMXTiledMapDeprecated = { } function CCTMXTiledMapDeprecated.layerNamed(self,layerName) diff --git a/tools/bindings-generator b/tools/bindings-generator index eb2e212426..e82fb176bd 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit eb2e2124260b7bc1ebd27c0872aaf4e95ead93db +Subproject commit e82fb176bd9a9fa573e3282e6af5ba19a7131633 diff --git a/tools/tolua/cocos2dx.ini b/tools/tolua/cocos2dx.ini index abbf927ec7..6af12e07b9 100644 --- a/tools/tolua/cocos2dx.ini +++ b/tools/tolua/cocos2dx.ini @@ -35,7 +35,7 @@ classes = Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* # will apply to all class names. This is a convenience wildcard to be able to skip similar named # functions from all classes. -skip = Node::[setGLServerState description getUserObject .*UserData getGLServerState .*schedule], +skip = Node::[setGLServerState description getUserObject .*UserData getGLServerState .*schedule getPosition], Sprite::[getQuad displayFrame getBlendFunc ^setPosition$ setBlendFunc setSpriteBatchNode getSpriteBatchNode], SpriteBatchNode::[getBlendFunc setBlendFunc], MotionStreak::[getBlendFunc setBlendFunc draw update], From 364288cf667fff01726ee2c6df1e0b19d2a725cd Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 23 Aug 2013 13:14:57 -0700 Subject: [PATCH 088/126] Adds "Sort all Children" perf test Adds a new perf tests: "sortAllChildren" Signed-off-by: Ricardo Quesada --- cocos2dx/cocoa/CCArray.cpp | 8 +- .../PerformanceNodeChildrenTest.cpp | 74 ++++++++++++++++++- .../PerformanceNodeChildrenTest.h | 10 +++ 3 files changed, 82 insertions(+), 10 deletions(-) diff --git a/cocos2dx/cocoa/CCArray.cpp b/cocos2dx/cocoa/CCArray.cpp index 2fc12593b2..b525fdde6a 100644 --- a/cocos2dx/cocoa/CCArray.cpp +++ b/cocos2dx/cocoa/CCArray.cpp @@ -42,12 +42,6 @@ Array::Array() init(); } -Array::Array(unsigned int capacity) -: data(NULL) -{ - initWithCapacity(capacity); -} - Array* Array::create() { Array* array = new Array(); @@ -132,7 +126,7 @@ Array* Array::createWithContentsOfFile(const char* fileName) Array* ret = Array::createWithContentsOfFileThreadSafe(fileName); if (ret != nullptr) { - pRet->autorelease(); + ret->autorelease(); } return ret; } diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp index ed3a5e0021..178eddef27 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp @@ -41,6 +41,7 @@ static std::function createFunctions[] = CL(AddSpriteSheet), CL(RemoveSpriteSheet), CL(ReorderSpriteSheet), + CL(SortAllChildrenSpriteSheet), }; #define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0])) @@ -381,9 +382,15 @@ void CallFuncsSpriteSheetForEach::update(float dt) CC_PROFILER_START(this->profilerName()); +#if CC_USE_ARRAY_VECTOR + std::for_each(std::begin(*children), std::end(*children), [](const RCPtr& obj) { + static_cast( static_cast(obj) )->getPosition(); + }); +#else std::for_each(std::begin(*children), std::end(*children), [](Object* obj) { static_cast(obj)->getPosition(); }); +#endif CC_PROFILER_STOP(this->profilerName()); } @@ -544,7 +551,7 @@ void AddSpriteSheet::update(float dt) std::string AddSpriteSheet::title() { - return "D - Add to spritesheet"; + return "F - Add to spritesheet"; } std::string AddSpriteSheet::subtitle() @@ -600,7 +607,7 @@ void RemoveSpriteSheet::update(float dt) std::string RemoveSpriteSheet::title() { - return "E - Del from spritesheet"; + return "G - Del from spritesheet"; } std::string RemoveSpriteSheet::subtitle() @@ -666,7 +673,7 @@ void ReorderSpriteSheet::update(float dt) std::string ReorderSpriteSheet::title() { - return "F - Reorder from spritesheet"; + return "H - Reorder from spritesheet"; } std::string ReorderSpriteSheet::subtitle() @@ -679,6 +686,67 @@ const char* ReorderSpriteSheet::profilerName() return "reorder sprites"; } +//////////////////////////////////////////////////////// +// +// SortAllChildrenSpriteSheet +// +//////////////////////////////////////////////////////// +void SortAllChildrenSpriteSheet::update(float dt) +{ + //srandom(0); + + // 15 percent + int totalToAdd = currentQuantityOfNodes * 0.15f; + + if( totalToAdd > 0 ) + { + auto sprites = Array::createWithCapacity(totalToAdd); + + // Don't include the sprite's creation time as part of the profiling + for(int i=0; igetTexture(), Rect(0,0,32,32)); + sprites->addObject(sprite); + } + + // add them with random Z (very important!) + for( int i=0; i < totalToAdd;i++ ) + { + batchNode->addChild((Node*) (sprites->getObjectAtIndex(i)), CCRANDOM_MINUS1_1() * 50, kTagBase+i); + } + + batchNode->sortAllChildren(); + + // reorder them + for( int i=0;i < totalToAdd;i++) + { + auto node = (Node*) (batchNode->getChildren()->getObjectAtIndex(i)); + batchNode->reorderChild(node, CCRANDOM_MINUS1_1() * 50); + } + + CC_PROFILER_START( this->profilerName() ); + batchNode->sortAllChildren(); + CC_PROFILER_STOP( this->profilerName() ); + + batchNode->removeAllChildrenWithCleanup(true); + } +} + +std::string SortAllChildrenSpriteSheet::title() +{ + return "H - Sort All Children from spritesheet"; +} + +std::string SortAllChildrenSpriteSheet::subtitle() +{ + return "Calls sortOfChildren(). See console"; +} + +const char* SortAllChildrenSpriteSheet::profilerName() +{ + return "sort all children"; +} + void runNodeChildrenTest() { auto scene = createFunctions[g_curCase](); diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.h b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.h index e501677267..0d74ea4488 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.h +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.h @@ -148,6 +148,16 @@ public: virtual const char* profilerName(); }; +class SortAllChildrenSpriteSheet : public AddRemoveSpriteSheet +{ +public: + virtual void update(float dt); + + virtual std::string title(); + virtual std::string subtitle(); + virtual const char* profilerName(); +}; + void runNodeChildrenTest(); #endif // __PERFORMANCE_NODE_CHILDREN_TEST_H__ From bbf905378896d264e4076e257f9e3808fb77e865 Mon Sep 17 00:00:00 2001 From: "Lee, Jae-Hong" Date: Sun, 25 Aug 2013 02:22:50 +0900 Subject: [PATCH 089/126] [Tizen] Update project files. - Update file list. - change order of link files. --- cocos2dx/proj.tizen/.project | 1510 +++++++++++++++++++++- samples/Cpp/TestCpp/proj.tizen/.cproject | 2 +- 2 files changed, 1486 insertions(+), 26 deletions(-) diff --git a/cocos2dx/proj.tizen/.project b/cocos2dx/proj.tizen/.project index 340034f8a1..453a406efd 100644 --- a/cocos2dx/proj.tizen/.project +++ b/cocos2dx/proj.tizen/.project @@ -31,7 +31,7 @@ org.eclipse.cdt.make.core.buildLocation - ${workspace_loc:/cocos2dx/Debug-Tizen-Emulator} + ${workspace_loc:/cocos2dx/Debug-Tizen-Device} org.eclipse.cdt.make.core.cleanBuildTarget @@ -135,12 +135,12 @@ src/actions 2 - PARENT-1-PROJECT_LOC/actions + virtual:/virtual src/base_nodes 2 - PARENT-1-PROJECT_LOC/base_nodes + virtual:/virtual src/ccFPSImages.c @@ -160,7 +160,7 @@ src/cocoa 2 - PARENT-1-PROJECT_LOC/cocoa + virtual:/virtual src/cocos2d.cpp @@ -170,57 +170,57 @@ src/draw_nodes 2 - PARENT-1-PROJECT_LOC/draw_nodes + virtual:/virtual src/effects 2 - PARENT-1-PROJECT_LOC/effects + virtual:/virtual src/include 2 - PARENT-1-PROJECT_LOC/include + virtual:/virtual src/kazmath 2 - PARENT-1-PROJECT_LOC/kazmath + virtual:/virtual src/keyboard_dispatcher 2 - PARENT-1-PROJECT_LOC/keyboard_dispatcher + virtual:/virtual src/keypad_dispatcher 2 - PARENT-1-PROJECT_LOC/keypad_dispatcher + virtual:/virtual src/label_nodes 2 - PARENT-1-PROJECT_LOC/label_nodes + virtual:/virtual src/layers_scenes_transitions_nodes 2 - PARENT-1-PROJECT_LOC/layers_scenes_transitions_nodes + virtual:/virtual src/menu_nodes 2 - PARENT-1-PROJECT_LOC/menu_nodes + virtual:/virtual src/misc_nodes 2 - PARENT-1-PROJECT_LOC/misc_nodes + virtual:/virtual src/particle_nodes 2 - PARENT-1-PROJECT_LOC/particle_nodes + virtual:/virtual src/platform @@ -230,42 +230,747 @@ src/script_support 2 - PARENT-1-PROJECT_LOC/script_support + virtual:/virtual src/shaders 2 - PARENT-1-PROJECT_LOC/shaders + virtual:/virtual src/sprite_nodes 2 - PARENT-1-PROJECT_LOC/sprite_nodes + virtual:/virtual src/support 2 - PARENT-1-PROJECT_LOC/support + virtual:/virtual src/text_input_node 2 - PARENT-1-PROJECT_LOC/text_input_node + virtual:/virtual src/textures 2 - PARENT-1-PROJECT_LOC/textures + virtual:/virtual src/tilemap_parallax_nodes 2 - PARENT-1-PROJECT_LOC/tilemap_parallax_nodes + virtual:/virtual src/touch_dispatcher 2 - PARENT-1-PROJECT_LOC/touch_dispatcher + virtual:/virtual + + + src/actions/CCAction.cpp + 1 + PARENT-1-PROJECT_LOC/actions/CCAction.cpp + + + src/actions/CCAction.h + 1 + PARENT-1-PROJECT_LOC/actions/CCAction.h + + + src/actions/CCActionCamera.cpp + 1 + PARENT-1-PROJECT_LOC/actions/CCActionCamera.cpp + + + src/actions/CCActionCamera.h + 1 + PARENT-1-PROJECT_LOC/actions/CCActionCamera.h + + + src/actions/CCActionCatmullRom.cpp + 1 + PARENT-1-PROJECT_LOC/actions/CCActionCatmullRom.cpp + + + src/actions/CCActionCatmullRom.h + 1 + PARENT-1-PROJECT_LOC/actions/CCActionCatmullRom.h + + + src/actions/CCActionEase.cpp + 1 + PARENT-1-PROJECT_LOC/actions/CCActionEase.cpp + + + src/actions/CCActionEase.h + 1 + PARENT-1-PROJECT_LOC/actions/CCActionEase.h + + + src/actions/CCActionGrid.cpp + 1 + PARENT-1-PROJECT_LOC/actions/CCActionGrid.cpp + + + src/actions/CCActionGrid.h + 1 + PARENT-1-PROJECT_LOC/actions/CCActionGrid.h + + + src/actions/CCActionGrid3D.cpp + 1 + PARENT-1-PROJECT_LOC/actions/CCActionGrid3D.cpp + + + src/actions/CCActionGrid3D.h + 1 + PARENT-1-PROJECT_LOC/actions/CCActionGrid3D.h + + + src/actions/CCActionInstant.cpp + 1 + PARENT-1-PROJECT_LOC/actions/CCActionInstant.cpp + + + src/actions/CCActionInstant.h + 1 + PARENT-1-PROJECT_LOC/actions/CCActionInstant.h + + + src/actions/CCActionInterval.cpp + 1 + PARENT-1-PROJECT_LOC/actions/CCActionInterval.cpp + + + src/actions/CCActionInterval.h + 1 + PARENT-1-PROJECT_LOC/actions/CCActionInterval.h + + + src/actions/CCActionManager.cpp + 1 + PARENT-1-PROJECT_LOC/actions/CCActionManager.cpp + + + src/actions/CCActionManager.h + 1 + PARENT-1-PROJECT_LOC/actions/CCActionManager.h + + + src/actions/CCActionPageTurn3D.cpp + 1 + PARENT-1-PROJECT_LOC/actions/CCActionPageTurn3D.cpp + + + src/actions/CCActionPageTurn3D.h + 1 + PARENT-1-PROJECT_LOC/actions/CCActionPageTurn3D.h + + + src/actions/CCActionProgressTimer.cpp + 1 + PARENT-1-PROJECT_LOC/actions/CCActionProgressTimer.cpp + + + src/actions/CCActionProgressTimer.h + 1 + PARENT-1-PROJECT_LOC/actions/CCActionProgressTimer.h + + + src/actions/CCActionTiledGrid.cpp + 1 + PARENT-1-PROJECT_LOC/actions/CCActionTiledGrid.cpp + + + src/actions/CCActionTiledGrid.h + 1 + PARENT-1-PROJECT_LOC/actions/CCActionTiledGrid.h + + + src/actions/CCActionTween.cpp + 1 + PARENT-1-PROJECT_LOC/actions/CCActionTween.cpp + + + src/actions/CCActionTween.h + 1 + PARENT-1-PROJECT_LOC/actions/CCActionTween.h + + + src/base_nodes/CCAtlasNode.cpp + 1 + PARENT-1-PROJECT_LOC/base_nodes/CCAtlasNode.cpp + + + src/base_nodes/CCAtlasNode.h + 1 + PARENT-1-PROJECT_LOC/base_nodes/CCAtlasNode.h + + + src/base_nodes/CCGLBufferedNode.cpp + 1 + PARENT-1-PROJECT_LOC/base_nodes/CCGLBufferedNode.cpp + + + src/base_nodes/CCGLBufferedNode.h + 1 + PARENT-1-PROJECT_LOC/base_nodes/CCGLBufferedNode.h + + + src/base_nodes/CCNode.cpp + 1 + PARENT-1-PROJECT_LOC/base_nodes/CCNode.cpp + + + src/base_nodes/CCNode.h + 1 + PARENT-1-PROJECT_LOC/base_nodes/CCNode.h + + + src/cocoa/CCAffineTransform.cpp + 1 + PARENT-1-PROJECT_LOC/cocoa/CCAffineTransform.cpp + + + src/cocoa/CCAffineTransform.h + 1 + PARENT-1-PROJECT_LOC/cocoa/CCAffineTransform.h + + + src/cocoa/CCArray.cpp + 1 + PARENT-1-PROJECT_LOC/cocoa/CCArray.cpp + + + src/cocoa/CCArray.h + 1 + PARENT-1-PROJECT_LOC/cocoa/CCArray.h + + + src/cocoa/CCAutoreleasePool.cpp + 1 + PARENT-1-PROJECT_LOC/cocoa/CCAutoreleasePool.cpp + + + src/cocoa/CCAutoreleasePool.h + 1 + PARENT-1-PROJECT_LOC/cocoa/CCAutoreleasePool.h + + + src/cocoa/CCBool.h + 1 + PARENT-1-PROJECT_LOC/cocoa/CCBool.h + + + src/cocoa/CCData.cpp + 1 + PARENT-1-PROJECT_LOC/cocoa/CCData.cpp + + + src/cocoa/CCData.h + 1 + PARENT-1-PROJECT_LOC/cocoa/CCData.h + + + src/cocoa/CCDataVisitor.cpp + 1 + PARENT-1-PROJECT_LOC/cocoa/CCDataVisitor.cpp + + + src/cocoa/CCDataVisitor.h + 1 + PARENT-1-PROJECT_LOC/cocoa/CCDataVisitor.h + + + src/cocoa/CCDictionary.cpp + 1 + PARENT-1-PROJECT_LOC/cocoa/CCDictionary.cpp + + + src/cocoa/CCDictionary.h + 1 + PARENT-1-PROJECT_LOC/cocoa/CCDictionary.h + + + src/cocoa/CCDouble.h + 1 + PARENT-1-PROJECT_LOC/cocoa/CCDouble.h + + + src/cocoa/CCFloat.h + 1 + PARENT-1-PROJECT_LOC/cocoa/CCFloat.h + + + src/cocoa/CCGeometry.cpp + 1 + PARENT-1-PROJECT_LOC/cocoa/CCGeometry.cpp + + + src/cocoa/CCGeometry.h + 1 + PARENT-1-PROJECT_LOC/cocoa/CCGeometry.h + + + src/cocoa/CCInteger.h + 1 + PARENT-1-PROJECT_LOC/cocoa/CCInteger.h + + + src/cocoa/CCNS.cpp + 1 + PARENT-1-PROJECT_LOC/cocoa/CCNS.cpp + + + src/cocoa/CCNS.h + 1 + PARENT-1-PROJECT_LOC/cocoa/CCNS.h + + + src/cocoa/CCObject.cpp + 1 + PARENT-1-PROJECT_LOC/cocoa/CCObject.cpp + + + src/cocoa/CCObject.h + 1 + PARENT-1-PROJECT_LOC/cocoa/CCObject.h + + + src/cocoa/CCSet.cpp + 1 + PARENT-1-PROJECT_LOC/cocoa/CCSet.cpp + + + src/cocoa/CCSet.h + 1 + PARENT-1-PROJECT_LOC/cocoa/CCSet.h + + + src/cocoa/CCString.cpp + 1 + PARENT-1-PROJECT_LOC/cocoa/CCString.cpp + + + src/cocoa/CCString.h + 1 + PARENT-1-PROJECT_LOC/cocoa/CCString.h + + + src/draw_nodes/CCDrawNode.cpp + 1 + PARENT-1-PROJECT_LOC/draw_nodes/CCDrawNode.cpp + + + src/draw_nodes/CCDrawNode.h + 1 + PARENT-1-PROJECT_LOC/draw_nodes/CCDrawNode.h + + + src/draw_nodes/CCDrawingPrimitives.cpp + 1 + PARENT-1-PROJECT_LOC/draw_nodes/CCDrawingPrimitives.cpp + + + src/draw_nodes/CCDrawingPrimitives.h + 1 + PARENT-1-PROJECT_LOC/draw_nodes/CCDrawingPrimitives.h + + + src/effects/CCGrabber.cpp + 1 + PARENT-1-PROJECT_LOC/effects/CCGrabber.cpp + + + src/effects/CCGrabber.h + 1 + PARENT-1-PROJECT_LOC/effects/CCGrabber.h + + + src/effects/CCGrid.cpp + 1 + PARENT-1-PROJECT_LOC/effects/CCGrid.cpp + + + src/effects/CCGrid.h + 1 + PARENT-1-PROJECT_LOC/effects/CCGrid.h + + + src/include/CCDeprecated.h + 1 + PARENT-1-PROJECT_LOC/include/CCDeprecated.h + + + src/include/CCEventType.h + 1 + PARENT-1-PROJECT_LOC/include/CCEventType.h + + + src/include/CCProtocols.h + 1 + PARENT-1-PROJECT_LOC/include/CCProtocols.h + + + src/include/ccConfig.h + 1 + PARENT-1-PROJECT_LOC/include/ccConfig.h + + + src/include/ccMacros.h + 1 + PARENT-1-PROJECT_LOC/include/ccMacros.h + + + src/include/ccTypeInfo.h + 1 + PARENT-1-PROJECT_LOC/include/ccTypeInfo.h + + + src/include/ccTypes.h + 1 + PARENT-1-PROJECT_LOC/include/ccTypes.h + + + src/include/cocos2d.h + 1 + PARENT-1-PROJECT_LOC/include/cocos2d.h + + + src/kazmath/include + 2 + virtual:/virtual + + + src/kazmath/src + 2 + virtual:/virtual + + + src/keyboard_dispatcher/CCKeyboardDispatcher.cpp + 1 + PARENT-1-PROJECT_LOC/keyboard_dispatcher/CCKeyboardDispatcher.cpp + + + src/keyboard_dispatcher/CCKeyboardDispatcher.h + 1 + PARENT-1-PROJECT_LOC/keyboard_dispatcher/CCKeyboardDispatcher.h + + + src/keypad_dispatcher/CCKeypadDelegate.cpp + 1 + PARENT-1-PROJECT_LOC/keypad_dispatcher/CCKeypadDelegate.cpp + + + src/keypad_dispatcher/CCKeypadDelegate.h + 1 + PARENT-1-PROJECT_LOC/keypad_dispatcher/CCKeypadDelegate.h + + + src/keypad_dispatcher/CCKeypadDispatcher.cpp + 1 + PARENT-1-PROJECT_LOC/keypad_dispatcher/CCKeypadDispatcher.cpp + + + src/keypad_dispatcher/CCKeypadDispatcher.h + 1 + PARENT-1-PROJECT_LOC/keypad_dispatcher/CCKeypadDispatcher.h + + + src/label_nodes/CCFont.cpp + 1 + PARENT-1-PROJECT_LOC/label_nodes/CCFont.cpp + + + src/label_nodes/CCFont.h + 1 + PARENT-1-PROJECT_LOC/label_nodes/CCFont.h + + + src/label_nodes/CCFontAtlas.cpp + 1 + PARENT-1-PROJECT_LOC/label_nodes/CCFontAtlas.cpp + + + src/label_nodes/CCFontAtlas.h + 1 + PARENT-1-PROJECT_LOC/label_nodes/CCFontAtlas.h + + + src/label_nodes/CCFontAtlasCache.cpp + 1 + PARENT-1-PROJECT_LOC/label_nodes/CCFontAtlasCache.cpp + + + src/label_nodes/CCFontAtlasCache.h + 1 + PARENT-1-PROJECT_LOC/label_nodes/CCFontAtlasCache.h + + + src/label_nodes/CCFontAtlasFactory.cpp + 1 + PARENT-1-PROJECT_LOC/label_nodes/CCFontAtlasFactory.cpp + + + src/label_nodes/CCFontAtlasFactory.h + 1 + PARENT-1-PROJECT_LOC/label_nodes/CCFontAtlasFactory.h + + + src/label_nodes/CCFontCache.h + 1 + PARENT-1-PROJECT_LOC/label_nodes/CCFontCache.h + + + src/label_nodes/CCFontDefinition.cpp + 1 + PARENT-1-PROJECT_LOC/label_nodes/CCFontDefinition.cpp + + + src/label_nodes/CCFontDefinition.h + 1 + PARENT-1-PROJECT_LOC/label_nodes/CCFontDefinition.h + + + src/label_nodes/CCFontFNT.cpp + 1 + PARENT-1-PROJECT_LOC/label_nodes/CCFontFNT.cpp + + + src/label_nodes/CCFontFNT.h + 1 + PARENT-1-PROJECT_LOC/label_nodes/CCFontFNT.h + + + src/label_nodes/CCFontFreeType.cpp + 1 + PARENT-1-PROJECT_LOC/label_nodes/CCFontFreeType.cpp + + + src/label_nodes/CCFontFreeType.h + 1 + PARENT-1-PROJECT_LOC/label_nodes/CCFontFreeType.h + + + src/label_nodes/CCLabel.cpp + 1 + PARENT-1-PROJECT_LOC/label_nodes/CCLabel.cpp + + + src/label_nodes/CCLabel.h + 1 + PARENT-1-PROJECT_LOC/label_nodes/CCLabel.h + + + src/label_nodes/CCLabelAtlas.cpp + 1 + PARENT-1-PROJECT_LOC/label_nodes/CCLabelAtlas.cpp + + + src/label_nodes/CCLabelAtlas.h + 1 + PARENT-1-PROJECT_LOC/label_nodes/CCLabelAtlas.h + + + src/label_nodes/CCLabelBMFont.cpp + 1 + PARENT-1-PROJECT_LOC/label_nodes/CCLabelBMFont.cpp + + + src/label_nodes/CCLabelBMFont.h + 1 + PARENT-1-PROJECT_LOC/label_nodes/CCLabelBMFont.h + + + src/label_nodes/CCLabelTTF.cpp + 1 + PARENT-1-PROJECT_LOC/label_nodes/CCLabelTTF.cpp + + + src/label_nodes/CCLabelTTF.h + 1 + PARENT-1-PROJECT_LOC/label_nodes/CCLabelTTF.h + + + src/label_nodes/CCLabelTextFormatProtocol.h + 1 + PARENT-1-PROJECT_LOC/label_nodes/CCLabelTextFormatProtocol.h + + + src/label_nodes/CCLabelTextFormatter.cpp + 1 + PARENT-1-PROJECT_LOC/label_nodes/CCLabelTextFormatter.cpp + + + src/label_nodes/CCLabelTextFormatter.h + 1 + PARENT-1-PROJECT_LOC/label_nodes/CCLabelTextFormatter.h + + + src/label_nodes/CCTextImage.cpp + 1 + PARENT-1-PROJECT_LOC/label_nodes/CCTextImage.cpp + + + src/label_nodes/CCTextImage.h + 1 + PARENT-1-PROJECT_LOC/label_nodes/CCTextImage.h + + + src/layers_scenes_transitions_nodes/CCLayer.cpp + 1 + PARENT-1-PROJECT_LOC/layers_scenes_transitions_nodes/CCLayer.cpp + + + src/layers_scenes_transitions_nodes/CCLayer.h + 1 + PARENT-1-PROJECT_LOC/layers_scenes_transitions_nodes/CCLayer.h + + + src/layers_scenes_transitions_nodes/CCScene.cpp + 1 + PARENT-1-PROJECT_LOC/layers_scenes_transitions_nodes/CCScene.cpp + + + src/layers_scenes_transitions_nodes/CCScene.h + 1 + PARENT-1-PROJECT_LOC/layers_scenes_transitions_nodes/CCScene.h + + + src/layers_scenes_transitions_nodes/CCTransition.cpp + 1 + PARENT-1-PROJECT_LOC/layers_scenes_transitions_nodes/CCTransition.cpp + + + src/layers_scenes_transitions_nodes/CCTransition.h + 1 + PARENT-1-PROJECT_LOC/layers_scenes_transitions_nodes/CCTransition.h + + + src/layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp + 1 + PARENT-1-PROJECT_LOC/layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp + + + src/layers_scenes_transitions_nodes/CCTransitionPageTurn.h + 1 + PARENT-1-PROJECT_LOC/layers_scenes_transitions_nodes/CCTransitionPageTurn.h + + + src/layers_scenes_transitions_nodes/CCTransitionProgress.cpp + 1 + PARENT-1-PROJECT_LOC/layers_scenes_transitions_nodes/CCTransitionProgress.cpp + + + src/layers_scenes_transitions_nodes/CCTransitionProgress.h + 1 + PARENT-1-PROJECT_LOC/layers_scenes_transitions_nodes/CCTransitionProgress.h + + + src/menu_nodes/CCMenu.cpp + 1 + PARENT-1-PROJECT_LOC/menu_nodes/CCMenu.cpp + + + src/menu_nodes/CCMenu.h + 1 + PARENT-1-PROJECT_LOC/menu_nodes/CCMenu.h + + + src/menu_nodes/CCMenuItem.cpp + 1 + PARENT-1-PROJECT_LOC/menu_nodes/CCMenuItem.cpp + + + src/menu_nodes/CCMenuItem.h + 1 + PARENT-1-PROJECT_LOC/menu_nodes/CCMenuItem.h + + + src/misc_nodes/CCClippingNode.cpp + 1 + PARENT-1-PROJECT_LOC/misc_nodes/CCClippingNode.cpp + + + src/misc_nodes/CCClippingNode.h + 1 + PARENT-1-PROJECT_LOC/misc_nodes/CCClippingNode.h + + + src/misc_nodes/CCMotionStreak.cpp + 1 + PARENT-1-PROJECT_LOC/misc_nodes/CCMotionStreak.cpp + + + src/misc_nodes/CCMotionStreak.h + 1 + PARENT-1-PROJECT_LOC/misc_nodes/CCMotionStreak.h + + + src/misc_nodes/CCProgressTimer.cpp + 1 + PARENT-1-PROJECT_LOC/misc_nodes/CCProgressTimer.cpp + + + src/misc_nodes/CCProgressTimer.h + 1 + PARENT-1-PROJECT_LOC/misc_nodes/CCProgressTimer.h + + + src/misc_nodes/CCRenderTexture.cpp + 1 + PARENT-1-PROJECT_LOC/misc_nodes/CCRenderTexture.cpp + + + src/misc_nodes/CCRenderTexture.h + 1 + PARENT-1-PROJECT_LOC/misc_nodes/CCRenderTexture.h + + + src/particle_nodes/CCParticleBatchNode.cpp + 1 + PARENT-1-PROJECT_LOC/particle_nodes/CCParticleBatchNode.cpp + + + src/particle_nodes/CCParticleBatchNode.h + 1 + PARENT-1-PROJECT_LOC/particle_nodes/CCParticleBatchNode.h + + + src/particle_nodes/CCParticleExamples.cpp + 1 + PARENT-1-PROJECT_LOC/particle_nodes/CCParticleExamples.cpp + + + src/particle_nodes/CCParticleExamples.h + 1 + PARENT-1-PROJECT_LOC/particle_nodes/CCParticleExamples.h + + + src/particle_nodes/CCParticleSystem.cpp + 1 + PARENT-1-PROJECT_LOC/particle_nodes/CCParticleSystem.cpp + + + src/particle_nodes/CCParticleSystem.h + 1 + PARENT-1-PROJECT_LOC/particle_nodes/CCParticleSystem.h + + + src/particle_nodes/CCParticleSystemQuad.cpp + 1 + PARENT-1-PROJECT_LOC/particle_nodes/CCParticleSystemQuad.cpp + + + src/particle_nodes/CCParticleSystemQuad.h + 1 + PARENT-1-PROJECT_LOC/particle_nodes/CCParticleSystemQuad.h + + + src/particle_nodes/firePngData.h + 1 + PARENT-1-PROJECT_LOC/particle_nodes/firePngData.h src/platform/CCAccelerometerDelegate.h @@ -347,21 +1052,576 @@ 1 PARENT-1-PROJECT_LOC/platform/CCThread.h + + src/platform/atitc + 2 + virtual:/virtual + src/platform/etc 2 - PARENT-1-PROJECT_LOC/platform/third_party/common/etc + virtual:/virtual src/platform/s3tc 2 - PARENT-1-PROJECT_LOC/platform/third_party/common/s3tc + virtual:/virtual src/platform/tizen 2 virtual:/virtual + + src/script_support/CCScriptSupport.cpp + 1 + PARENT-1-PROJECT_LOC/script_support/CCScriptSupport.cpp + + + src/script_support/CCScriptSupport.h + 1 + PARENT-1-PROJECT_LOC/script_support/CCScriptSupport.h + + + src/shaders/CCGLProgram.cpp + 1 + PARENT-1-PROJECT_LOC/shaders/CCGLProgram.cpp + + + src/shaders/CCGLProgram.h + 1 + PARENT-1-PROJECT_LOC/shaders/CCGLProgram.h + + + src/shaders/CCShaderCache.cpp + 1 + PARENT-1-PROJECT_LOC/shaders/CCShaderCache.cpp + + + src/shaders/CCShaderCache.h + 1 + PARENT-1-PROJECT_LOC/shaders/CCShaderCache.h + + + src/shaders/ccGLStateCache.cpp + 1 + PARENT-1-PROJECT_LOC/shaders/ccGLStateCache.cpp + + + src/shaders/ccGLStateCache.h + 1 + PARENT-1-PROJECT_LOC/shaders/ccGLStateCache.h + + + src/shaders/ccShaderEx_SwitchMask_frag.h + 1 + PARENT-1-PROJECT_LOC/shaders/ccShaderEx_SwitchMask_frag.h + + + src/shaders/ccShader_PositionColorLengthTexture_frag.h + 1 + PARENT-1-PROJECT_LOC/shaders/ccShader_PositionColorLengthTexture_frag.h + + + src/shaders/ccShader_PositionColorLengthTexture_vert.h + 1 + PARENT-1-PROJECT_LOC/shaders/ccShader_PositionColorLengthTexture_vert.h + + + src/shaders/ccShader_PositionColor_frag.h + 1 + PARENT-1-PROJECT_LOC/shaders/ccShader_PositionColor_frag.h + + + src/shaders/ccShader_PositionColor_vert.h + 1 + PARENT-1-PROJECT_LOC/shaders/ccShader_PositionColor_vert.h + + + src/shaders/ccShader_PositionTextureA8Color_frag.h + 1 + PARENT-1-PROJECT_LOC/shaders/ccShader_PositionTextureA8Color_frag.h + + + src/shaders/ccShader_PositionTextureA8Color_vert.h + 1 + PARENT-1-PROJECT_LOC/shaders/ccShader_PositionTextureA8Color_vert.h + + + src/shaders/ccShader_PositionTextureColorAlphaTest_frag.h + 1 + PARENT-1-PROJECT_LOC/shaders/ccShader_PositionTextureColorAlphaTest_frag.h + + + src/shaders/ccShader_PositionTextureColor_frag.h + 1 + PARENT-1-PROJECT_LOC/shaders/ccShader_PositionTextureColor_frag.h + + + src/shaders/ccShader_PositionTextureColor_vert.h + 1 + PARENT-1-PROJECT_LOC/shaders/ccShader_PositionTextureColor_vert.h + + + src/shaders/ccShader_PositionTexture_frag.h + 1 + PARENT-1-PROJECT_LOC/shaders/ccShader_PositionTexture_frag.h + + + src/shaders/ccShader_PositionTexture_uColor_frag.h + 1 + PARENT-1-PROJECT_LOC/shaders/ccShader_PositionTexture_uColor_frag.h + + + src/shaders/ccShader_PositionTexture_uColor_vert.h + 1 + PARENT-1-PROJECT_LOC/shaders/ccShader_PositionTexture_uColor_vert.h + + + src/shaders/ccShader_PositionTexture_vert.h + 1 + PARENT-1-PROJECT_LOC/shaders/ccShader_PositionTexture_vert.h + + + src/shaders/ccShader_Position_uColor_frag.h + 1 + PARENT-1-PROJECT_LOC/shaders/ccShader_Position_uColor_frag.h + + + src/shaders/ccShader_Position_uColor_vert.h + 1 + PARENT-1-PROJECT_LOC/shaders/ccShader_Position_uColor_vert.h + + + src/shaders/ccShaders.cpp + 1 + PARENT-1-PROJECT_LOC/shaders/ccShaders.cpp + + + src/shaders/ccShaders.h + 1 + PARENT-1-PROJECT_LOC/shaders/ccShaders.h + + + src/sprite_nodes/CCAnimation.cpp + 1 + PARENT-1-PROJECT_LOC/sprite_nodes/CCAnimation.cpp + + + src/sprite_nodes/CCAnimation.h + 1 + PARENT-1-PROJECT_LOC/sprite_nodes/CCAnimation.h + + + src/sprite_nodes/CCAnimationCache.cpp + 1 + PARENT-1-PROJECT_LOC/sprite_nodes/CCAnimationCache.cpp + + + src/sprite_nodes/CCAnimationCache.h + 1 + PARENT-1-PROJECT_LOC/sprite_nodes/CCAnimationCache.h + + + src/sprite_nodes/CCSprite.cpp + 1 + PARENT-1-PROJECT_LOC/sprite_nodes/CCSprite.cpp + + + src/sprite_nodes/CCSprite.h + 1 + PARENT-1-PROJECT_LOC/sprite_nodes/CCSprite.h + + + src/sprite_nodes/CCSpriteBatchNode.cpp + 1 + PARENT-1-PROJECT_LOC/sprite_nodes/CCSpriteBatchNode.cpp + + + src/sprite_nodes/CCSpriteBatchNode.h + 1 + PARENT-1-PROJECT_LOC/sprite_nodes/CCSpriteBatchNode.h + + + src/sprite_nodes/CCSpriteFrame.cpp + 1 + PARENT-1-PROJECT_LOC/sprite_nodes/CCSpriteFrame.cpp + + + src/sprite_nodes/CCSpriteFrame.h + 1 + PARENT-1-PROJECT_LOC/sprite_nodes/CCSpriteFrame.h + + + src/sprite_nodes/CCSpriteFrameCache.cpp + 1 + PARENT-1-PROJECT_LOC/sprite_nodes/CCSpriteFrameCache.cpp + + + src/sprite_nodes/CCSpriteFrameCache.h + 1 + PARENT-1-PROJECT_LOC/sprite_nodes/CCSpriteFrameCache.h + + + src/support/CCNotificationCenter.cpp + 1 + PARENT-1-PROJECT_LOC/support/CCNotificationCenter.cpp + + + src/support/CCNotificationCenter.h + 1 + PARENT-1-PROJECT_LOC/support/CCNotificationCenter.h + + + src/support/CCProfiling.cpp + 1 + PARENT-1-PROJECT_LOC/support/CCProfiling.cpp + + + src/support/CCProfiling.h + 1 + PARENT-1-PROJECT_LOC/support/CCProfiling.h + + + src/support/CCVertex.cpp + 1 + PARENT-1-PROJECT_LOC/support/CCVertex.cpp + + + src/support/CCVertex.h + 1 + PARENT-1-PROJECT_LOC/support/CCVertex.h + + + src/support/TransformUtils.cpp + 1 + PARENT-1-PROJECT_LOC/support/TransformUtils.cpp + + + src/support/TransformUtils.h + 1 + PARENT-1-PROJECT_LOC/support/TransformUtils.h + + + src/support/base64.cpp + 1 + PARENT-1-PROJECT_LOC/support/base64.cpp + + + src/support/base64.h + 1 + PARENT-1-PROJECT_LOC/support/base64.h + + + src/support/ccUTF8.cpp + 1 + PARENT-1-PROJECT_LOC/support/ccUTF8.cpp + + + src/support/ccUTF8.h + 1 + PARENT-1-PROJECT_LOC/support/ccUTF8.h + + + src/support/ccUtils.cpp + 1 + PARENT-1-PROJECT_LOC/support/ccUtils.cpp + + + src/support/ccUtils.h + 1 + PARENT-1-PROJECT_LOC/support/ccUtils.h + + + src/support/component + 2 + virtual:/virtual + + + src/support/data_support + 2 + virtual:/virtual + + + src/support/image_support + 2 + virtual:/virtual + + + src/support/tinyxml2 + 2 + virtual:/virtual + + + src/support/user_default + 2 + virtual:/virtual + + + src/support/zip_support + 2 + virtual:/virtual + + + src/text_input_node/CCIMEDelegate.h + 1 + PARENT-1-PROJECT_LOC/text_input_node/CCIMEDelegate.h + + + src/text_input_node/CCIMEDispatcher.cpp + 1 + PARENT-1-PROJECT_LOC/text_input_node/CCIMEDispatcher.cpp + + + src/text_input_node/CCIMEDispatcher.h + 1 + PARENT-1-PROJECT_LOC/text_input_node/CCIMEDispatcher.h + + + src/text_input_node/CCTextFieldTTF.cpp + 1 + PARENT-1-PROJECT_LOC/text_input_node/CCTextFieldTTF.cpp + + + src/text_input_node/CCTextFieldTTF.h + 1 + PARENT-1-PROJECT_LOC/text_input_node/CCTextFieldTTF.h + + + src/textures/CCTexture2D.cpp + 1 + PARENT-1-PROJECT_LOC/textures/CCTexture2D.cpp + + + src/textures/CCTexture2D.h + 1 + PARENT-1-PROJECT_LOC/textures/CCTexture2D.h + + + src/textures/CCTextureAtlas.cpp + 1 + PARENT-1-PROJECT_LOC/textures/CCTextureAtlas.cpp + + + src/textures/CCTextureAtlas.h + 1 + PARENT-1-PROJECT_LOC/textures/CCTextureAtlas.h + + + src/textures/CCTextureCache.cpp + 1 + PARENT-1-PROJECT_LOC/textures/CCTextureCache.cpp + + + src/textures/CCTextureCache.h + 1 + PARENT-1-PROJECT_LOC/textures/CCTextureCache.h + + + src/tilemap_parallax_nodes/CCParallaxNode.cpp + 1 + PARENT-1-PROJECT_LOC/tilemap_parallax_nodes/CCParallaxNode.cpp + + + src/tilemap_parallax_nodes/CCParallaxNode.h + 1 + PARENT-1-PROJECT_LOC/tilemap_parallax_nodes/CCParallaxNode.h + + + src/tilemap_parallax_nodes/CCTMXLayer.cpp + 1 + PARENT-1-PROJECT_LOC/tilemap_parallax_nodes/CCTMXLayer.cpp + + + src/tilemap_parallax_nodes/CCTMXLayer.h + 1 + PARENT-1-PROJECT_LOC/tilemap_parallax_nodes/CCTMXLayer.h + + + src/tilemap_parallax_nodes/CCTMXObjectGroup.cpp + 1 + PARENT-1-PROJECT_LOC/tilemap_parallax_nodes/CCTMXObjectGroup.cpp + + + src/tilemap_parallax_nodes/CCTMXObjectGroup.h + 1 + PARENT-1-PROJECT_LOC/tilemap_parallax_nodes/CCTMXObjectGroup.h + + + src/tilemap_parallax_nodes/CCTMXTiledMap.cpp + 1 + PARENT-1-PROJECT_LOC/tilemap_parallax_nodes/CCTMXTiledMap.cpp + + + src/tilemap_parallax_nodes/CCTMXTiledMap.h + 1 + PARENT-1-PROJECT_LOC/tilemap_parallax_nodes/CCTMXTiledMap.h + + + src/tilemap_parallax_nodes/CCTMXXMLParser.cpp + 1 + PARENT-1-PROJECT_LOC/tilemap_parallax_nodes/CCTMXXMLParser.cpp + + + src/tilemap_parallax_nodes/CCTMXXMLParser.h + 1 + PARENT-1-PROJECT_LOC/tilemap_parallax_nodes/CCTMXXMLParser.h + + + src/tilemap_parallax_nodes/CCTileMapAtlas.cpp + 1 + PARENT-1-PROJECT_LOC/tilemap_parallax_nodes/CCTileMapAtlas.cpp + + + src/tilemap_parallax_nodes/CCTileMapAtlas.h + 1 + PARENT-1-PROJECT_LOC/tilemap_parallax_nodes/CCTileMapAtlas.h + + + src/touch_dispatcher/CCTouch.cpp + 1 + PARENT-1-PROJECT_LOC/touch_dispatcher/CCTouch.cpp + + + src/touch_dispatcher/CCTouch.h + 1 + PARENT-1-PROJECT_LOC/touch_dispatcher/CCTouch.h + + + src/touch_dispatcher/CCTouchDelegateProtocol.h + 1 + PARENT-1-PROJECT_LOC/touch_dispatcher/CCTouchDelegateProtocol.h + + + src/touch_dispatcher/CCTouchDispatcher.cpp + 1 + PARENT-1-PROJECT_LOC/touch_dispatcher/CCTouchDispatcher.cpp + + + src/touch_dispatcher/CCTouchDispatcher.h + 1 + PARENT-1-PROJECT_LOC/touch_dispatcher/CCTouchDispatcher.h + + + src/touch_dispatcher/CCTouchHandler.cpp + 1 + PARENT-1-PROJECT_LOC/touch_dispatcher/CCTouchHandler.cpp + + + src/touch_dispatcher/CCTouchHandler.h + 1 + PARENT-1-PROJECT_LOC/touch_dispatcher/CCTouchHandler.h + + + src/kazmath/include/kazmath + 2 + virtual:/virtual + + + src/kazmath/src/CMakeLists.txt + 1 + PARENT-1-PROJECT_LOC/kazmath/src/CMakeLists.txt + + + src/kazmath/src/ChangeLog + 1 + PARENT-1-PROJECT_LOC/kazmath/src/ChangeLog + + + src/kazmath/src/GL + 2 + virtual:/virtual + + + src/kazmath/src/aabb.c + 1 + PARENT-1-PROJECT_LOC/kazmath/src/aabb.c + + + src/kazmath/src/mat3.c + 1 + PARENT-1-PROJECT_LOC/kazmath/src/mat3.c + + + src/kazmath/src/mat4.c + 1 + PARENT-1-PROJECT_LOC/kazmath/src/mat4.c + + + src/kazmath/src/neon_matrix_impl.c + 1 + PARENT-1-PROJECT_LOC/kazmath/src/neon_matrix_impl.c + + + src/kazmath/src/plane.c + 1 + PARENT-1-PROJECT_LOC/kazmath/src/plane.c + + + src/kazmath/src/quaternion.c + 1 + PARENT-1-PROJECT_LOC/kazmath/src/quaternion.c + + + src/kazmath/src/ray2.c + 1 + PARENT-1-PROJECT_LOC/kazmath/src/ray2.c + + + src/kazmath/src/utility.c + 1 + PARENT-1-PROJECT_LOC/kazmath/src/utility.c + + + src/kazmath/src/vec2.c + 1 + PARENT-1-PROJECT_LOC/kazmath/src/vec2.c + + + src/kazmath/src/vec3.c + 1 + PARENT-1-PROJECT_LOC/kazmath/src/vec3.c + + + src/kazmath/src/vec4.c + 1 + PARENT-1-PROJECT_LOC/kazmath/src/vec4.c + + + src/platform/atitc/atitc.cpp + 1 + PARENT-1-PROJECT_LOC/platform/third_party/common/atitc/atitc.cpp + + + src/platform/atitc/atitc.h + 1 + PARENT-1-PROJECT_LOC/platform/third_party/common/atitc/atitc.h + + + src/platform/etc/etc1.cpp + 1 + PARENT-1-PROJECT_LOC/platform/third_party/common/etc/etc1.cpp + + + src/platform/etc/etc1.h + 1 + PARENT-1-PROJECT_LOC/platform/third_party/common/etc/etc1.h + + + src/platform/s3tc/s3tc.cpp + 1 + PARENT-1-PROJECT_LOC/platform/third_party/common/s3tc/s3tc.cpp + + + src/platform/s3tc/s3tc.h + 1 + PARENT-1-PROJECT_LOC/platform/third_party/common/s3tc/s3tc.h + + + src/platform/tizen/.CCCommon.cpp.swp + 1 + PARENT-1-PROJECT_LOC/platform/tizen/.CCCommon.cpp.swp + src/platform/tizen/CCAccelerometer.cpp 1 @@ -452,5 +1712,205 @@ 1 PARENT-1-PROJECT_LOC/platform/tizen/CCStdC.h + + src/support/component/CCComponent.cpp + 1 + PARENT-1-PROJECT_LOC/support/component/CCComponent.cpp + + + src/support/component/CCComponent.h + 1 + PARENT-1-PROJECT_LOC/support/component/CCComponent.h + + + src/support/component/CCComponentContainer.cpp + 1 + PARENT-1-PROJECT_LOC/support/component/CCComponentContainer.cpp + + + src/support/component/CCComponentContainer.h + 1 + PARENT-1-PROJECT_LOC/support/component/CCComponentContainer.h + + + src/support/data_support/ccCArray.cpp + 1 + PARENT-1-PROJECT_LOC/support/data_support/ccCArray.cpp + + + src/support/data_support/ccCArray.h + 1 + PARENT-1-PROJECT_LOC/support/data_support/ccCArray.h + + + src/support/data_support/uthash.h + 1 + PARENT-1-PROJECT_LOC/support/data_support/uthash.h + + + src/support/data_support/utlist.h + 1 + PARENT-1-PROJECT_LOC/support/data_support/utlist.h + + + src/support/image_support/TGAlib.cpp + 1 + PARENT-1-PROJECT_LOC/support/image_support/TGAlib.cpp + + + src/support/image_support/TGAlib.h + 1 + PARENT-1-PROJECT_LOC/support/image_support/TGAlib.h + + + src/support/tinyxml2/tinyxml2.cpp + 1 + PARENT-1-PROJECT_LOC/support/tinyxml2/tinyxml2.cpp + + + src/support/tinyxml2/tinyxml2.h + 1 + PARENT-1-PROJECT_LOC/support/tinyxml2/tinyxml2.h + + + src/support/user_default/Archive.zip + 1 + PARENT-1-PROJECT_LOC/support/user_default/Archive.zip + + + src/support/user_default/CCUserDefault.cpp + 1 + PARENT-1-PROJECT_LOC/support/user_default/CCUserDefault.cpp + + + src/support/user_default/CCUserDefault.h + 1 + PARENT-1-PROJECT_LOC/support/user_default/CCUserDefault.h + + + src/support/user_default/CCUserDefault.mm + 1 + PARENT-1-PROJECT_LOC/support/user_default/CCUserDefault.mm + + + src/support/user_default/CCUserDefaultAndroid.cpp + 1 + PARENT-1-PROJECT_LOC/support/user_default/CCUserDefaultAndroid.cpp + + + src/support/zip_support/ZipUtils.cpp + 1 + PARENT-1-PROJECT_LOC/support/zip_support/ZipUtils.cpp + + + src/support/zip_support/ZipUtils.h + 1 + PARENT-1-PROJECT_LOC/support/zip_support/ZipUtils.h + + + src/support/zip_support/ioapi.cpp + 1 + PARENT-1-PROJECT_LOC/support/zip_support/ioapi.cpp + + + src/support/zip_support/ioapi.h + 1 + PARENT-1-PROJECT_LOC/support/zip_support/ioapi.h + + + src/support/zip_support/unzip.cpp + 1 + PARENT-1-PROJECT_LOC/support/zip_support/unzip.cpp + + + src/support/zip_support/unzip.h + 1 + PARENT-1-PROJECT_LOC/support/zip_support/unzip.h + + + src/kazmath/include/kazmath/GL + 2 + virtual:/virtual + + + src/kazmath/include/kazmath/aabb.h + 1 + PARENT-1-PROJECT_LOC/kazmath/include/kazmath/aabb.h + + + src/kazmath/include/kazmath/kazmath.h + 1 + PARENT-1-PROJECT_LOC/kazmath/include/kazmath/kazmath.h + + + src/kazmath/include/kazmath/mat3.h + 1 + PARENT-1-PROJECT_LOC/kazmath/include/kazmath/mat3.h + + + src/kazmath/include/kazmath/mat4.h + 1 + PARENT-1-PROJECT_LOC/kazmath/include/kazmath/mat4.h + + + src/kazmath/include/kazmath/neon_matrix_impl.h + 1 + PARENT-1-PROJECT_LOC/kazmath/include/kazmath/neon_matrix_impl.h + + + src/kazmath/include/kazmath/plane.h + 1 + PARENT-1-PROJECT_LOC/kazmath/include/kazmath/plane.h + + + src/kazmath/include/kazmath/quaternion.h + 1 + PARENT-1-PROJECT_LOC/kazmath/include/kazmath/quaternion.h + + + src/kazmath/include/kazmath/ray2.h + 1 + PARENT-1-PROJECT_LOC/kazmath/include/kazmath/ray2.h + + + src/kazmath/include/kazmath/utility.h + 1 + PARENT-1-PROJECT_LOC/kazmath/include/kazmath/utility.h + + + src/kazmath/include/kazmath/vec2.h + 1 + PARENT-1-PROJECT_LOC/kazmath/include/kazmath/vec2.h + + + src/kazmath/include/kazmath/vec3.h + 1 + PARENT-1-PROJECT_LOC/kazmath/include/kazmath/vec3.h + + + src/kazmath/include/kazmath/vec4.h + 1 + PARENT-1-PROJECT_LOC/kazmath/include/kazmath/vec4.h + + + src/kazmath/src/GL/mat4stack.c + 1 + PARENT-1-PROJECT_LOC/kazmath/src/GL/mat4stack.c + + + src/kazmath/src/GL/matrix.c + 1 + PARENT-1-PROJECT_LOC/kazmath/src/GL/matrix.c + + + src/kazmath/include/kazmath/GL/mat4stack.h + 1 + PARENT-1-PROJECT_LOC/kazmath/include/kazmath/GL/mat4stack.h + + + src/kazmath/include/kazmath/GL/matrix.h + 1 + PARENT-1-PROJECT_LOC/kazmath/include/kazmath/GL/matrix.h + diff --git a/samples/Cpp/TestCpp/proj.tizen/.cproject b/samples/Cpp/TestCpp/proj.tizen/.cproject index 812a6153f7..9cb31d8072 100644 --- a/samples/Cpp/TestCpp/proj.tizen/.cproject +++ b/samples/Cpp/TestCpp/proj.tizen/.cproject @@ -653,8 +653,8 @@ - + From ea8eb601afd87f0e357b0faa0dab477f168812ec Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Sat, 24 Aug 2013 10:56:07 -0700 Subject: [PATCH 090/126] Uses std::sort() Uses std::sort() for inserting the nodes. This code is not final, but preliminary results show that std::sort() is 60% faster Signed-off-by: Ricardo Quesada --- cocos2dx/base_nodes/CCNode.cpp | 31 +++++ cocos2dx/cocoa/CCObject.cpp | 18 --- cocos2dx/cocoa/CCObject.h | 16 ++- cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp | 28 ++++ .../PerformanceNodeChildrenTest.cpp | 131 +++++++++++++----- .../PerformanceNodeChildrenTest.h | 10 ++ 6 files changed, 182 insertions(+), 52 deletions(-) diff --git a/cocos2dx/base_nodes/CCNode.cpp b/cocos2dx/base_nodes/CCNode.cpp index 86aa58849d..f9d80fa66d 100644 --- a/cocos2dx/base_nodes/CCNode.cpp +++ b/cocos2dx/base_nodes/CCNode.cpp @@ -709,8 +709,33 @@ void Node::reorderChild(Node *child, int zOrder) child->_setZOrder(zOrder); } +#if CC_USE_ARRAY_VECTOR +static bool objectComparisonLess(const RCPtr& pp1, const RCPtr& pp2) +{ + Object *p1 = static_cast(pp1); + Object *p2 = static_cast(pp2); + Node *n1 = static_cast(p1); + Node *n2 = static_cast(p2); + + return( n1->getZOrder() < n2->getZOrder() || + ( n1->getZOrder() == n2->getZOrder() && n1->getOrderOfArrival() < n2->getOrderOfArrival() ) + ); +} +#else +static bool objectComparisonLess(Object* p1, Object* p2) +{ + Node *n1 = static_cast(p1); + Node *n2 = static_cast(p2); + + return( n1->getZOrder() < n2->getZOrder() || + ( n1->getZOrder() == n2->getZOrder() && n1->getOrderOfArrival() < n2->getOrderOfArrival() ) + ); +} +#endif + void Node::sortAllChildren() { +#if 0 if (_reorderChildDirty) { int i,j,length = _children->count(); @@ -737,6 +762,12 @@ void Node::sortAllChildren() _reorderChildDirty = false; } +#else + if( _reorderChildDirty ) { + std::sort( std::begin(*_children), std::end(*_children), objectComparisonLess ); + _reorderChildDirty = false; + } +#endif } diff --git a/cocos2dx/cocoa/CCObject.cpp b/cocos2dx/cocoa/CCObject.cpp index d79fa8151f..13fa0e3236 100644 --- a/cocos2dx/cocoa/CCObject.cpp +++ b/cocos2dx/cocoa/CCObject.cpp @@ -64,24 +64,6 @@ Object::~Object() } } -void Object::release() -{ - CCASSERT(_reference > 0, "reference count should greater than 0"); - --_reference; - - if (_reference == 0) - { - delete this; - } -} - -void Object::retain() -{ - CCASSERT(_reference > 0, "reference count should greater than 0"); - - ++_reference; -} - Object* Object::autorelease() { PoolManager::sharedPoolManager()->addObject(this); diff --git a/cocos2dx/cocoa/CCObject.h b/cocos2dx/cocoa/CCObject.h index b1fe11b7c2..896d9cd484 100644 --- a/cocos2dx/cocoa/CCObject.h +++ b/cocos2dx/cocoa/CCObject.h @@ -26,6 +26,7 @@ THE SOFTWARE. #define __CCOBJECT_H__ #include "cocoa/CCDataVisitor.h" +#include "ccMacros.h" #ifdef EMSCRIPTEN #include @@ -93,7 +94,14 @@ public: * * @see retain, autorelease */ - void release(); + inline void release() + { + CCASSERT(_reference > 0, "reference count should greater than 0"); + --_reference; + + if (_reference == 0) + delete this; + } /** * Retains the ownership. @@ -102,7 +110,11 @@ public: * * @see release, autorelease */ - void retain(); + inline void retain() + { + CCASSERT(_reference > 0, "reference count should greater than 0"); + ++_reference; + } /** * Release the ownership sometime soon automatically. diff --git a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp index de63c8f81b..968f099d97 100644 --- a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp @@ -241,11 +241,36 @@ void SpriteBatchNode::removeAllChildrenWithCleanup(bool bCleanup) _textureAtlas->removeAllQuads(); } +#if CC_USE_ARRAY_VECTOR +static bool objectComparisonLess(const RCPtr& pp1, const RCPtr& pp2) +{ + Object *p1 = static_cast(pp1); + Object *p2 = static_cast(pp2); + Node *n1 = static_cast(p1); + Node *n2 = static_cast(p2); + + return( n1->getZOrder() < n2->getZOrder() || + ( n1->getZOrder() == n2->getZOrder() && n1->getOrderOfArrival() < n2->getOrderOfArrival() ) + ); +} +#else +static bool objectComparisonLess(Object* p1, Object* p2) +{ + Node *n1 = static_cast(p1); + Node *n2 = static_cast(p2); + + return( n1->getZOrder() < n2->getZOrder() || + ( n1->getZOrder() == n2->getZOrder() && n1->getOrderOfArrival() < n2->getOrderOfArrival() ) + ); +} +#endif + //override sortAllChildren void SpriteBatchNode::sortAllChildren() { if (_reorderChildDirty) { +#if 0 int i = 0,j = 0,length = _children->count(); // insertion sort @@ -267,6 +292,9 @@ void SpriteBatchNode::sortAllChildren() } _children->fastSetObject(tempI, j+1); } +#else + std::sort(std::begin(*_children), std::end(*_children), objectComparisonLess); +#endif //sorted now check all children if (_children->count() > 0) diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp index 178eddef27..61a7c2e084 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp @@ -39,6 +39,7 @@ static std::function createFunctions[] = CL(CallFuncsSpriteSheetCMacro), CL(AddSpriteSheet), + CL(GetSpriteSheet), CL(RemoveSpriteSheet), CL(ReorderSpriteSheet), CL(SortAllChildrenSpriteSheet), @@ -516,14 +517,13 @@ void AddSpriteSheet::update(float dt) if( totalToAdd > 0 ) { - auto sprites = Array::createWithCapacity(totalToAdd); + Sprite **sprites = new Sprite*[totalToAdd]; int *zs = new int[totalToAdd]; // Don't include the sprite creation time and random as part of the profiling for(int i=0; igetTexture(), Rect(0,0,32,32)); - sprites->addObject(sprite); + sprites[i] = Sprite::createWithTexture(batchNode->getTexture(), Rect(0,0,32,32)); zs[i] = CCRANDOM_MINUS1_1() * 50; } @@ -532,7 +532,7 @@ void AddSpriteSheet::update(float dt) for( int i=0; i < totalToAdd;i++ ) { - batchNode->addChild((Node*) (sprites->getObjectAtIndex(i)), zs[i], kTagBase+i); + batchNode->addChild( sprites[i], zs[i], kTagBase+i); } batchNode->sortAllChildren(); @@ -542,9 +542,10 @@ void AddSpriteSheet::update(float dt) // remove them for( int i=0;i < totalToAdd;i++) { - batchNode->removeChildByTag(kTagBase+i, true); + batchNode->removeChild( sprites[i], true); } + delete [] sprites; delete [] zs; } } @@ -564,6 +565,72 @@ const char* AddSpriteSheet::profilerName() return "add sprites"; } +//////////////////////////////////////////////////////// +// +// GetSpriteSheet +// +//////////////////////////////////////////////////////// +void GetSpriteSheet::update(float dt) +{ + // reset seed + //srandom(0); + + // 15 percent + int totalToAdd = currentQuantityOfNodes * 0.15f; + + if( totalToAdd > 0 ) + { + Sprite **sprites = new Sprite*[totalToAdd]; + int *zs = new int[totalToAdd]; + + // Don't include the sprite creation time and random as part of the profiling + for(int i=0; igetTexture(), Rect(0,0,32,32)); + zs[i] = CCRANDOM_MINUS1_1() * 50; + } + + for( int i=0; i < totalToAdd;i++ ) + { + batchNode->addChild( sprites[i], zs[i], kTagBase+i); + } + + batchNode->sortAllChildren(); + + CC_PROFILER_START( this->profilerName() ); + for( int i=0; i < totalToAdd;i++ ) + { + batchNode->getChildByTag(kTagBase+1); + } + CC_PROFILER_STOP(this->profilerName()); + + // remove them + for( int i=0;i < totalToAdd;i++) + { + batchNode->removeChild( sprites[i], true); + } + + delete [] sprites; + delete [] zs; + } +} + +std::string GetSpriteSheet::title() +{ + return "G - getChildByTag from spritesheet"; +} + +std::string GetSpriteSheet::subtitle() +{ + return "Get sprites using getChildByTag(). See console"; +} + +const char* GetSpriteSheet::profilerName() +{ + return "get sprites"; +} + + //////////////////////////////////////////////////////// // // RemoveSpriteSheet @@ -578,36 +645,35 @@ void RemoveSpriteSheet::update(float dt) if( totalToAdd > 0 ) { - auto sprites = Array::createWithCapacity(totalToAdd); + Sprite **sprites = new Sprite*[totalToAdd]; // Don't include the sprite creation time as part of the profiling for(int i=0;igetTexture(), Rect(0,0,32,32)); - sprites->addObject(sprite); + sprites[i] = Sprite::createWithTexture(batchNode->getTexture(), Rect(0,0,32,32)); } // add them with random Z (very important!) for( int i=0; i < totalToAdd;i++ ) { - batchNode->addChild((Node*) (sprites->getObjectAtIndex(i)), CCRANDOM_MINUS1_1() * 50, kTagBase+i); + batchNode->addChild( sprites[i], CCRANDOM_MINUS1_1() * 50, kTagBase+i); } // remove them CC_PROFILER_START( this->profilerName() ); - for( int i=0;i < totalToAdd;i++) { - batchNode->removeChildByTag(kTagBase+i, true); + batchNode->removeChild( sprites[i], true); } - CC_PROFILER_STOP( this->profilerName() ); + + delete [] sprites; } } std::string RemoveSpriteSheet::title() { - return "G - Del from spritesheet"; + return "H - Del from spritesheet"; } std::string RemoveSpriteSheet::subtitle() @@ -634,46 +700,43 @@ void ReorderSpriteSheet::update(float dt) if( totalToAdd > 0 ) { - auto sprites = Array::createWithCapacity(totalToAdd); + Sprite **sprites = new Sprite*[totalToAdd]; // Don't include the sprite creation time as part of the profiling for(int i=0; igetTexture(), Rect(0,0,32,32)); - sprites->addObject(sprite); + sprites[i] = Sprite::createWithTexture(batchNode->getTexture(), Rect(0,0,32,32)); } // add them with random Z (very important!) for( int i=0; i < totalToAdd;i++ ) { - batchNode->addChild((Node*) (sprites->getObjectAtIndex(i)), CCRANDOM_MINUS1_1() * 50, kTagBase+i); + batchNode->addChild( sprites[i], CCRANDOM_MINUS1_1() * 50, kTagBase+i); } batchNode->sortAllChildren(); // reorder them CC_PROFILER_START( this->profilerName() ); - for( int i=0;i < totalToAdd;i++) { - auto node = (Node*) (batchNode->getChildren()->getObjectAtIndex(i)); - batchNode->reorderChild(node, CCRANDOM_MINUS1_1() * 50); + batchNode->reorderChild(sprites[i], CCRANDOM_MINUS1_1() * 50); } - - batchNode->sortAllChildren(); CC_PROFILER_STOP( this->profilerName() ); // remove them for( int i=0;i < totalToAdd;i++) { - batchNode->removeChildByTag(kTagBase+i, true); + batchNode->removeChild( sprites[i], true); } + + delete [] sprites; } } std::string ReorderSpriteSheet::title() { - return "H - Reorder from spritesheet"; + return "I - Reorder from spritesheet"; } std::string ReorderSpriteSheet::subtitle() @@ -700,19 +763,18 @@ void SortAllChildrenSpriteSheet::update(float dt) if( totalToAdd > 0 ) { - auto sprites = Array::createWithCapacity(totalToAdd); + Sprite **sprites = new Sprite*[totalToAdd]; // Don't include the sprite's creation time as part of the profiling for(int i=0; igetTexture(), Rect(0,0,32,32)); - sprites->addObject(sprite); + sprites[i] = Sprite::createWithTexture(batchNode->getTexture(), Rect(0,0,32,32)); } // add them with random Z (very important!) for( int i=0; i < totalToAdd;i++ ) { - batchNode->addChild((Node*) (sprites->getObjectAtIndex(i)), CCRANDOM_MINUS1_1() * 50, kTagBase+i); + batchNode->addChild( sprites[i], CCRANDOM_MINUS1_1() * 50, kTagBase+i); } batchNode->sortAllChildren(); @@ -720,21 +782,26 @@ void SortAllChildrenSpriteSheet::update(float dt) // reorder them for( int i=0;i < totalToAdd;i++) { - auto node = (Node*) (batchNode->getChildren()->getObjectAtIndex(i)); - batchNode->reorderChild(node, CCRANDOM_MINUS1_1() * 50); + batchNode->reorderChild(sprites[i], CCRANDOM_MINUS1_1() * 50); } CC_PROFILER_START( this->profilerName() ); batchNode->sortAllChildren(); CC_PROFILER_STOP( this->profilerName() ); - batchNode->removeAllChildrenWithCleanup(true); + // remove them + for( int i=0;i < totalToAdd;i++) + { + batchNode->removeChild( sprites[i], true); + } + + delete [] sprites; } } std::string SortAllChildrenSpriteSheet::title() { - return "H - Sort All Children from spritesheet"; + return "J - Sort All Children from spritesheet"; } std::string SortAllChildrenSpriteSheet::subtitle() diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.h b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.h index 0d74ea4488..f1b20529bd 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.h +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.h @@ -128,6 +128,16 @@ public: virtual const char* profilerName(); }; +class GetSpriteSheet : public AddRemoveSpriteSheet +{ +public: + virtual void update(float dt); + + virtual std::string title(); + virtual std::string subtitle(); + virtual const char* profilerName(); +}; + class RemoveSpriteSheet : public AddRemoveSpriteSheet { public: From b6a90b81aaef39bd983d9a56e34ccbfb258f7e14 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Sun, 25 Aug 2013 10:50:29 -0700 Subject: [PATCH 091/126] Adds missing include --- cocos2dx/base_nodes/CCNode.cpp | 6 +++++- cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/cocos2dx/base_nodes/CCNode.cpp b/cocos2dx/base_nodes/CCNode.cpp index f9d80fa66d..1c0af95862 100644 --- a/cocos2dx/base_nodes/CCNode.cpp +++ b/cocos2dx/base_nodes/CCNode.cpp @@ -24,8 +24,12 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#include "cocoa/CCString.h" + #include "CCNode.h" + +#include + +#include "cocoa/CCString.h" #include "support/TransformUtils.h" #include "CCCamera.h" #include "effects/CCGrid.h" diff --git a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp index 968f099d97..f83b11bf49 100644 --- a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp @@ -24,7 +24,11 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ + #include "CCSpriteBatchNode.h" + +#include + #include "ccConfig.h" #include "CCSprite.h" #include "effects/CCGrid.h" From 1e452bf0bcb1042997fa6971a6003220583a6196 Mon Sep 17 00:00:00 2001 From: boyu0 Date: Mon, 26 Aug 2013 13:45:45 +0800 Subject: [PATCH 092/126] closed #2494: add isLineOverlap, isLineParallel, isSegmentOverlap method to Point. --- cocos2dx/cocoa/CCGeometry.cpp | 105 +++++++++++++++++++++------------- cocos2dx/cocoa/CCGeometry.h | 45 ++++++++++----- 2 files changed, 96 insertions(+), 54 deletions(-) diff --git a/cocos2dx/cocoa/CCGeometry.cpp b/cocos2dx/cocoa/CCGeometry.cpp index 59f0d750b4..e62247cbc4 100644 --- a/cocos2dx/cocoa/CCGeometry.cpp +++ b/cocos2dx/cocoa/CCGeometry.cpp @@ -116,7 +116,7 @@ Point Point::rotateByAngle(const Point& pivot, float angle) const return pivot + (*this - pivot).rotate(Point::forAngle(angle)); } -bool Point::isOneDemensionLineIntersect(float A, float B, float C, float D, float *S) +bool Point::isOneDemensionSegmentOverlap(float A, float B, float C, float D, float *S, float *E) { float ABmin = MIN(A, B); float ABmax = MAX(A, B); @@ -126,7 +126,6 @@ bool Point::isOneDemensionLineIntersect(float A, float B, float C, float D, floa if (ABmax < CDmin || CDmax < ABmin) { // ABmin->ABmax->CDmin->CDmax or CDmin->CDmax->ABmin->ABmax - *S = (CDmin - A) / (B - A); return false; } else @@ -134,17 +133,20 @@ bool Point::isOneDemensionLineIntersect(float A, float B, float C, float D, floa if (ABmin >= CDmin && ABmin <= CDmax) { // CDmin->ABmin->CDmax->ABmax or CDmin->ABmin->ABmax->CDmax - *S = ABmin==A ? 0 : 1; + if (S != nullptr) *S = ABmin; + if (E != nullptr) *E = CDmax < ABmax ? CDmax : ABmax; } else if (ABmax >= CDmin && ABmax <= CDmax) { // ABmin->CDmin->ABmax->CDmax - *S = ABmax==A ? 0 : 1; + if (S != nullptr) *S = CDmin; + if (E != nullptr) *E = ABmax; } else { // ABmin->CDmin->CDmax->ABmax - *S = (CDmin - A) / (B - A); + if (S != nullptr) *S = CDmin; + if (E != nullptr) *E = CDmax; } return true; } @@ -159,58 +161,83 @@ bool Point::isLineIntersect(const Point& A, const Point& B, { return false; } - const float BAx = B.x - A.x; - const float BAy = B.y - A.y; - const float DCx = D.x - C.x; - const float DCy = D.y - C.y; - const float ACx = A.x - C.x; - const float ACy = A.y - C.y; - const float denom = DCy*BAx - DCx*BAy; - - *S = DCx*ACy - DCy*ACx; - *T = BAx*ACy - BAy*ACx; + const float denom = crossProduct2Vector(A, B, C, D); if (denom == 0) { - if (*S == 0 || *T == 0) - { - // Lines incident - if (A.x != B.x) - { - isOneDemensionLineIntersect(A.x, B.x, C.x, D.x, S); - } - else - { - isOneDemensionLineIntersect(A.y, B.y, C.y, D.y, T); - } - - return true; - } - // Lines parallel and not incident + // Lines parallel or overlap return false; } - *S = *S / denom; - *T = *T / denom; - - // Point of intersection - // CGPoint P; - // P.x = A.x + *S * (B.x - A.x); - // P.y = A.y + *S * (B.y - A.y); + if (S != nullptr) *S = crossProduct2Vector(C, D, C, A) / denom; + if (T != nullptr) *T = crossProduct2Vector(A, B, C, A) / denom; return true; } +bool Point::isLineParallel(const Point& A, const Point& B, + const Point& C, const Point& D) +{ + // FAIL: Line undefined + if ( (A.x==B.x && A.y==B.y) || (C.x==D.x && C.y==D.y) ) + { + return false; + } + + if (crossProduct2Vector(A, B, C, D) == 0) + { + // line overlap + if (crossProduct2Vector(C, D, C, A) == 0 || crossProduct2Vector(A, B, C, A) == 0) + { + return false; + } + + return true; + } + + return false; +} + +bool Point::isLineOverlap(const Point& A, const Point& B, + const Point& C, const Point& D) +{ + // FAIL: Line undefined + if ( (A.x==B.x && A.y==B.y) || (C.x==D.x && C.y==D.y) ) + { + return false; + } + + if (crossProduct2Vector(A, B, C, D) == 0 && + (crossProduct2Vector(C, D, C, A) == 0 || crossProduct2Vector(A, B, C, A) == 0)) + { + return true; + } + + return false; +} + +bool Point::isSegmentOverlap(const Point& A, const Point& B, const Point& C, const Point& D, Point* S, Point* E) +{ + + if (isLineOverlap(A, B, C, D)) + { + return isOneDemensionSegmentOverlap(A.x, B.x, C.x, D.x, &S->x, &E->x) && + isOneDemensionSegmentOverlap(A.y, B.y, C.y, D.y, &S->y, &E->y); + } + + return false; +} + bool Point::isSegmentIntersect(const Point& A, const Point& B, const Point& C, const Point& D) { float S, T; if (isLineIntersect(A, B, C, D, &S, &T )&& - (S >= 0.0f && S <= 1.0f && T >= 0.0f && T <= 1.0f)) + (S >= 0.0f && S <= 1.0f && T >= 0.0f && T <= 1.0f)) { return true; - } + } return false; } diff --git a/cocos2dx/cocoa/CCGeometry.h b/cocos2dx/cocoa/CCGeometry.h index ccfe3b5616..eb66763412 100644 --- a/cocos2dx/cocoa/CCGeometry.h +++ b/cocos2dx/cocoa/CCGeometry.h @@ -245,20 +245,6 @@ public: return Point(cosf(a), sinf(a)); } - /** A general line-line intersection test - @param A the startpoint for the first line L1 = (A - B) - @param B the endpoint for the first line L1 = (A - B) - @param C the startpoint for the second line L2 = (C - D) - @param D the endpoint for the second line L2 = (C - D) - @param S the range for a hitpoint in L1 (p = A + S*(B - A)) - @returns whether these two lines interects. - - Note that if two line is intersection, S in line in [0..1] - the hit point also is A + S * (B - A); - @since 3.0 - */ - static bool isOneDemensionLineIntersect(float A, float B, float C, float D, float *S); - /** A general line-line intersection test @param A the startpoint for the first line L1 = (A - B) @param B the endpoint for the first line L1 = (A - B) @@ -276,7 +262,29 @@ public: */ static bool isLineIntersect(const Point& A, const Point& B, const Point& C, const Point& D, - float *S, float *T); + float *S = nullptr, float *T = nullptr); + + /* + returns true if Line A-B overlap with segment C-D + @since v3.0 + */ + static bool isLineOverlap(const Point& A, const Point& B, + const Point& C, const Point& D); + + /* + returns true if Line A-B parallel with segment C-D + @since v3.0 + */ + static bool isLineParallel(const Point& A, const Point& B, + const Point& C, const Point& D); + + /* + returns true if Segment A-B overlap with segment C-D + @since v3.0 + */ + static bool isSegmentOverlap(const Point& A, const Point& B, + const Point& C, const Point& D, + Point* S = nullptr, Point* E = nullptr); /* returns true if Segment A-B intersects with segment C-D @@ -291,6 +299,13 @@ public: static Point getIntersectPoint(const Point& A, const Point& B, const Point& C, const Point& D); static const Point ZERO; + +private: + // returns true if segment A-B intersects with segment C-D. S->E is the ovderlap part + static bool isOneDemensionSegmentOverlap(float A, float B, float C, float D, float *S, float * E); + + // cross procuct of 2 vector. A->B X C->D + static float crossProduct2Vector(const Point& A, const Point& B, const Point& C, const Point& D) { return (D.y - C.y) * (B.x - A.x) - (D.x - C.x) * (B.y - A.y); } }; class CC_DLL Size From c9ffc44bc4557c647061a7908933e4d3abfab57b Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 26 Aug 2013 16:52:20 +0800 Subject: [PATCH 093/126] [Android] Removing x86 from APP_ABI. Otherwise the time of compiling will be very long. --- samples/Cpp/SimpleGame/proj.android/jni/Application.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/Cpp/SimpleGame/proj.android/jni/Application.mk b/samples/Cpp/SimpleGame/proj.android/jni/Application.mk index a12ec4dd7b..133b505945 100644 --- a/samples/Cpp/SimpleGame/proj.android/jni/Application.mk +++ b/samples/Cpp/SimpleGame/proj.android/jni/Application.mk @@ -1,4 +1,4 @@ APP_STL := gnustl_static APP_CPPFLAGS := -frtti -DCOCOS2D_DEBUG=1 -std=c++11 -APP_ABI := armeabi x86 +APP_ABI := armeabi APP_OPTIM := debug From 11ea111affb6984722328c376dea90fb43c53c6a Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 26 Aug 2013 16:57:10 +0800 Subject: [PATCH 094/126] closed #2446: Add a tool to auto export releasing zip file --- tools/make-package/Makefile | 15 + tools/make-package/README.markdown | 21 ++ tools/make-package/git-archive-all | 464 +++++++++++++++++++++++++++++ 3 files changed, 500 insertions(+) create mode 100644 tools/make-package/Makefile create mode 100644 tools/make-package/README.markdown create mode 100755 tools/make-package/git-archive-all diff --git a/tools/make-package/Makefile b/tools/make-package/Makefile new file mode 100644 index 0000000000..2f5734d0b8 --- /dev/null +++ b/tools/make-package/Makefile @@ -0,0 +1,15 @@ +prefix=/usr/local +EXEC_FILES=git-archive-all + +all: + @echo "usage: make install" + @echo " make uninstall" + +install: + install -d -m 0755 $(prefix)/bin + install -m 0755 $(EXEC_FILES) $(prefix)/bin + +uninstall: + test -d $(prefix)/bin && \ + cd $(prefix)/bin && \ + rm -f ${EXEC_FILES} diff --git a/tools/make-package/README.markdown b/tools/make-package/README.markdown new file mode 100644 index 0000000000..36c5366923 --- /dev/null +++ b/tools/make-package/README.markdown @@ -0,0 +1,21 @@ +Creates archive from the current state using `git ls-files --cached --full-name --no-empty-directory`. Supports for any level of submodules tree. Files from submodules are extracted using the same command. + +*License:* MIT + +*Usage:* `git-archive-all [-v] [--prefix PREFIX] [--no-exclude] [--force-submodules] [--dry-run] OUTPUT_FILE` + +*Options:* + + **--version** Show program's version number and exit. + + **-h, --help** Show this help message and exit. + + **--prefix=PREFIX** Prepend PREFIX to each filename in the archive. OUTPUT_FILE name is used by default to avoid tarbomb. + + **--force-submodules** Force a `git submodule init && git submodule update` at each level before iterating submodules + + **-v, --verbose** Enable verbose mode. + + **--no-exclude** Don't read .gitattributes files for patterns containing export-ignore attributes. + + **--dry-run** Don't actually archive anything, just show what would be done. diff --git a/tools/make-package/git-archive-all b/tools/make-package/git-archive-all new file mode 100755 index 0000000000..a84a79ad37 --- /dev/null +++ b/tools/make-package/git-archive-all @@ -0,0 +1,464 @@ +#! /usr/bin/env python +# coding=utf-8 + +from __future__ import print_function +from __future__ import unicode_literals + +__version__ = "1.7" + +import sys +from os import path, extsep +from subprocess import Popen, PIPE, CalledProcessError + + +class GitArchiver(object): + """ + GitArchiver + + Scan a git repository and export all tracked files, and submodules. + Checks for .gitattributes files in each directory and uses 'export-ignore' + pattern entries for ignore files in the archive. + + Automatically detects output format extension: zip, tar, bz2, or gz. + """ + + def __init__(self, prefix='', verbose=False, exclude=True, force_sub=False, extra=None, main_repo_abspath=None): + """ + @type prefix: string + @param prefix: Prefix used to prepend all paths in the resulting archive. + + @type verbose: bool + @param verbose: Determines verbosity of the output (stdout). + + @type exclude: bool + @param exclude: Determines whether archiver should follow rules specified in .gitattributes files. + Defaults to True. + + @type force_sub: bool + @param force_sub: Determines whether submodules are initialized and updated before archiving. + Defaults to False + + @type extra: list + @param extra: List of extra paths to include in the resulting archive. + + @type main_repo_abspath: string + @param main_repo_abspath: Absolute path to the main repository (or one of subdirectories). + If None, current cwd is used. + If given path is path to a subdirectory (but not a submodule directory!) + it will be replaced with abspath to toplevel directory of the repository. + """ + if extra is None: + extra = [] + + if main_repo_abspath is None: + main_repo_abspath = path.abspath('') + elif not path.isabs(main_repo_abspath): + raise ValueError("You MUST pass absolute path to the main git repository.") + + # Raises an exception if there is no repo under main_repo_abspath. + try: + self.run_shell("[ -d .git ] || git rev-parse --git-dir > /dev/null 2>&1", main_repo_abspath) + except Exception as e: + raise ValueError("Not a git repository (or any of the parent directories).".format(path=main_repo_abspath)) + + # Detect toplevel directory of the repo. + main_repo_abspath = path.abspath(self.read_git_shell('git rev-parse --show-toplevel', main_repo_abspath).rstrip()) + + self.prefix = prefix + self.verbose = verbose + self.exclude = exclude + self.extra = extra + self.force_sub = force_sub + self.main_repo_abspath = main_repo_abspath + + def create(self, output_path, dry_run=False, output_format=None): + """ + Creates the archive, written to the given output_file_path + + Type of the archive is determined either by extension of output_file_path or by the format argument. + Supported formats are: gz, zip, bz2, tar, tgz + + @type output_path: string + @param output_path: Output file path. + + @type dry_run: bool + @param dry_run: Determines whether create should do nothing but print what it would archive. + + @type output_format: string + @param output_format: Determines format of the output archive. + If None, format is determined from extension of output_file_path. + """ + if output_format is None: + file_name, file_ext = path.splitext(output_path) + output_format = file_ext[len(extsep):].lower() + + if output_format == 'zip': + from zipfile import ZipFile, ZIP_DEFLATED + + if not dry_run: + archive = ZipFile(path.abspath(output_path), 'w') + add = lambda file_path, file_name: archive.write(file_path, path.join(self.prefix, file_name), ZIP_DEFLATED) + elif output_format in ['tar', 'bz2', 'gz', 'tgz']: + import tarfile + + if output_format == 'tar': + t_mode = 'w' + elif output_format == 'tgz': + t_mode = 'w:gz' + else: + t_mode = 'w:{f}'.format(f=output_format) + + if not dry_run: + archive = tarfile.open(path.abspath(output_path), t_mode) + add = lambda file_path, file_name: archive.add(file_path, path.join(self.prefix, file_name)) + else: + raise RuntimeError("Unknown format: {f}".format(f=output_format)) + + for file_path in self.extra: + if not dry_run: + if self.verbose: + print("Compressing {f} => {a}...".format(f=file_path, + a=path.join(self.prefix, file_path))) + add(file_path, file_path) + else: + print("{f} => {a}".format(f=file_path, + a=path.join(self.prefix, file_path))) + + for file_path in self.list_files(): + if not dry_run: + if self.verbose: + print("Compressing {f} => {a}...".format(f=path.join(self.main_repo_abspath, file_path), + a=path.join(self.prefix, file_path))) + add(path.join(self.main_repo_abspath, file_path), file_path) + else: + print("{f} => {a}".format(f=path.join(self.main_repo_abspath, file_path), + a=path.join(self.prefix, file_path))) + + if not dry_run: + archive.close() + + def get_path_components(self, repo_abspath, abspath): + """ + Splits given abspath into components until repo_abspath is reached. + + E.g. if repo_abspath is '/Documents/Hobby/ParaView/' and abspath is + '/Documents/Hobby/ParaView/Catalyst/Editions/Base/', function will return: + ['.', 'Catalyst', 'Editions', 'Base'] + + First element is always '.' (concrete symbol depends on OS). + + @type repo_abspath: string + @param repo_abspath: Absolute path to the git repository. + + @type abspath: string + @param abspath: Absolute path to within repo_abspath. + + @rtype: list + @return: List of path components. + """ + components = [] + + while not path.samefile(abspath, repo_abspath): + abspath, tail = path.split(abspath) + + if len(tail): + components.insert(0, tail) + + components.insert(0, path.relpath(repo_abspath, repo_abspath)) + return components + + def get_exclude_patterns(self, repo_abspath, repo_file_paths): + """ + Returns exclude patterns for a given repo. It looks for .gitattributes files in repo_file_paths. + + Resulting dictionary will contain exclude patterns per path (relative to the repo_abspath). + E.g. {('.', 'Catalyst', 'Editions', 'Base'), ['Foo*', '*Bar']} + + @type repo_abspath: string + @param repo_abspath: Absolute path to the git repository. + + @type repo_file_paths: list + @param repo_file_paths: List of paths relative to the repo_abspath that are under git control. + + @rtype: dict + @return: Dictionary representing exclude patterns. + Keys are tuples of strings. Values are lists of strings. + Returns None if self.exclude is not set. + """ + if not self.exclude: + return None + + def read_attributes(attributes_abspath): + patterns = [] + if path.isfile(attributes_abspath): + attributes = open(attributes_abspath, 'r').readlines() + patterns = [] + for line in attributes: + tokens = line.strip().split() + if "export-ignore" in tokens[1:]: + patterns.append(tokens[0]) + return patterns + + exclude_patterns = {(): []} + + # There may be no gitattributes. + try: + global_attributes_abspath = self.read_shell("git config --get core.attributesfile", repo_abspath).rstrip() + exclude_patterns[()] = read_attributes(global_attributes_abspath) + except: + # And valid to not have them. + pass + + for attributes_abspath in [path.join(repo_abspath, f) for f in repo_file_paths if f.endswith(".gitattributes")]: + # Each .gitattributes affects only files within its directory. + key = tuple(self.get_path_components(repo_abspath, path.dirname(attributes_abspath))) + exclude_patterns[key] = read_attributes(attributes_abspath) + + local_attributes_abspath = path.join(repo_abspath, ".git", "info", "attributes") + key = tuple(self.get_path_components(repo_abspath, repo_abspath)) + + if key in exclude_patterns: + exclude_patterns[key].extend(read_attributes(local_attributes_abspath)) + else: + exclude_patterns[key] = read_attributes(local_attributes_abspath) + + return exclude_patterns + + def is_file_excluded(self, repo_abspath, repo_file_path, exclude_patterns): + """ + Checks whether file at a given path is excluded. + + @type repo_abspath: string + @param repo_abspath: Absolute path to the git repository. + + @type repo_file_path: string + @param repo_file_path: Path to a file within repo_abspath. + + @type exclude_patterns: dict + @param exclude_patterns: Exclude patterns with format specified for get_exclude_patterns. + + @rtype: bool + @return: True if file should be excluded. Otherwise False. + """ + if exclude_patterns is None or not len(exclude_patterns): + return False + + from fnmatch import fnmatch + + file_name = path.basename(repo_file_path) + components = self.get_path_components(repo_abspath, path.join(repo_abspath, path.dirname(repo_file_path))) + + is_excluded = False + # We should check all patterns specified in intermediate directories to the given file. + # At the end we should also check for the global patterns (key '()' or empty tuple). + while not is_excluded: + key = tuple(components) + if key in exclude_patterns: + patterns = exclude_patterns[key] + for p in patterns: + if fnmatch(file_name, p) or fnmatch(repo_file_path, p): + if self.verbose: + print("Exclude pattern matched {pattern}: {path}".format(pattern=p, path=repo_file_path)) + is_excluded = True + + if not len(components): + break + + components.pop() + + return is_excluded + + def list_files(self, repo_path=''): + """ + An iterator method that yields a file path relative to main_repo_abspath + for each file that should be included in the archive. + Skips those that match the exclusion patterns found in + any discovered .gitattributes files along the way. + + Recurs into submodules as well. + + @type repo_path: string + @param repo_path: Path to the git submodule repository within the main git repository. + + @rtype: iterator + @return: Iterator to traverse files under git control relative to main_repo_abspath. + """ + repo_abspath = path.join(self.main_repo_abspath, repo_path) + repo_file_paths = self.read_git_shell("git ls-files --cached --full-name --no-empty-directory", repo_abspath).splitlines() + exclude_patterns = self.get_exclude_patterns(repo_abspath, repo_file_paths) + + for repo_file_path in repo_file_paths: + # Git puts path in quotes if file path has unicode characters. + repo_file_path = repo_file_path.strip('"') # file path relative to current repo + file_name = path.basename(repo_file_path) + + # Only list symlinks and files that don't start with git. + if (not path.islink(repo_file_path) and path.isdir(repo_file_path)): + continue + + main_repo_file_path = path.join(repo_path, repo_file_path) # file path relative to the main repo + + if self.is_file_excluded(repo_abspath, repo_file_path, exclude_patterns): + continue + + # Yield both repo_file_path and main_repo_file_path to preserve structure of the repo. + yield main_repo_file_path + + if self.force_sub: + self.run_shell("git submodule init", repo_abspath) + self.run_shell("git submodule update", repo_abspath) + + # List files of every submodule. + for submodule_path in self.read_shell("git submodule --quiet foreach 'pwd'", repo_abspath).splitlines(): + # In order to get output path we need to exclude repository path from submodule_path. + submodule_path = path.relpath(submodule_path, self.main_repo_abspath) + for file_path in self.list_files(submodule_path): + yield file_path + + @staticmethod + def run_shell(cmd, cwd=None): + """ + Runs shell command. + + @type cmd: string + @param cmd: Command to be executed. + + @type cwd: string + @param cwd: Working directory. + + @rtype: int + @return: Return code of the command. + + @raise CalledProcessError: Raises exception if return code of the command is non-zero. + """ + p = Popen(cmd, shell=True, cwd=cwd) + p.wait() + + if p.returncode: + raise CalledProcessError(returncode=p.returncode, cmd=cmd) + + return p.returncode + + @staticmethod + def read_shell(cmd, cwd=None, encoding='utf-8'): + """ + Runs shell command and reads output. + + @type cmd: string + @param cmd: Command to be executed. + + @type cwd: string + @param cwd: Working directory. + + @type encoding: string + @param encoding: Encoding used to decode bytes returned by Popen into string. + + @rtype: string + @return: Output of the command. + + @raise CalledProcessError: Raises exception if return code of the command is non-zero. + """ + p = Popen(cmd, shell=True, stdout=PIPE, cwd=cwd) + output, _ = p.communicate() + output = output.decode(encoding) + + if p.returncode: + raise CalledProcessError(returncode=p.returncode, cmd=cmd, output=output) + + return output + + @staticmethod + def read_git_shell(cmd, cwd=None): + """ + Runs git shell command, reads output and decodes it into unicode string + + @type cmd: string + @param cmd: Command to be executed. + + @type cwd: string + @param cwd: Working directory. + + @rtype: string + @return: Output of the command. + + @raise CalledProcessError: Raises exception if return code of the command is non-zero. + """ + p = Popen(cmd, shell=True, stdout=PIPE, cwd=cwd) + output, _ = p.communicate() + output = output.decode('unicode_escape').encode('raw_unicode_escape').decode('utf-8') + + if p.returncode: + raise CalledProcessError(returncode=p.returncode, cmd=cmd, output=output) + + return output + + +if __name__ == '__main__': + from optparse import OptionParser + + parser = OptionParser(usage="usage: %prog [-v] [--prefix PREFIX] [--no-exclude] [--force-submodules] [--dry-run] OUTPUT_FILE", + version="%prog {version}".format(version=__version__)) + + parser.add_option('--prefix', + type='string', + dest='prefix', + default='', + help="Prepend PREFIX to each filename in the archive. OUTPUT_FILE name is used by default to avoid tarbomb.") + + parser.add_option('-v', '--verbose', + action='store_true', + dest='verbose', + help='Enable verbose mode.') + + parser.add_option('--no-exclude', + action='store_false', + dest='exclude', + default=True, + help="Don't read .gitattributes files for patterns containing export-ignore attrib.") + + parser.add_option('--force-submodules', + action='store_true', + dest='force_sub', + help="Force a git submodule init && git submodule update at each level before iterating submodules.") + + parser.add_option('--extra', + action='append', + dest='extra', + default=[], + help="Any additional files to include in the archive.") + parser.add_option('--dry-run', + action='store_true', + dest='dry_run', + help="Don't actually archive anything, just show what would be done.") + + options, args = parser.parse_args() + + if len(args) != 1: + parser.error("You must specify exactly one output file") + + output_file_path = args[0] + + if path.isdir(output_file_path): + parser.error("You cannot use directory as output") + + # avoid tarbomb + if options.prefix: + options.prefix = path.join(options.prefix, '') + else: + import re + + output_name = path.basename(output_file_path) + output_name = re.sub('(\.zip|\.tar|\.tgz|\.gz|\.bz2|\.tar\.gz|\.tar\.bz2)$', '', output_name) or "Archive" + options.prefix = path.join(output_name, '') + + try: + archiver = GitArchiver(options.prefix, + options.verbose, + options.exclude, + options.force_sub, + options.extra) + archiver.create(output_file_path, options.dry_run) + except Exception as e: + parser.exit(2, "{exception}\n".format(exception=e)) + + sys.exit(0) From ec3fa59ae34b5fc64d1d38fe2f6138a43746dfff Mon Sep 17 00:00:00 2001 From: minggo Date: Mon, 26 Aug 2013 17:40:25 +0800 Subject: [PATCH 095/126] remove unneeded files --- .../org/cocos2dx/lib/Cocos2dxETCLoader.java | 109 ------------------ ...org_cocos2dx_lib_Cocos2dxAccelerometer.cpp | 13 --- cocos2dx/platform/android/jni/TouchesJni.cpp | 90 --------------- 3 files changed, 212 deletions(-) delete mode 100644 cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxETCLoader.java delete mode 100644 cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxAccelerometer.cpp delete mode 100644 cocos2dx/platform/android/jni/TouchesJni.cpp diff --git a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxETCLoader.java b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxETCLoader.java deleted file mode 100644 index fd4cd81954..0000000000 --- a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxETCLoader.java +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -Copyright (c) 2013 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - ****************************************************************************/ -package org.cocos2dx.lib; - -import java.io.FileInputStream; -import java.io.InputStream; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; - -import android.content.Context; -import android.content.res.AssetManager; -import android.opengl.ETC1Util; -import android.util.Log; - -public class Cocos2dxETCLoader { - private static final String ASSETS_PATH = "assets/"; - private static Context context; - - public static boolean loadTexture(String filePath) { - if (! ETC1Util.isETC1Supported()) { - return false; - } - - if (filePath.length() == 0) { - return false; - } - - // Create ETC1Texture - InputStream inputStream = null; - ETC1Util.ETC1Texture texture = null; - AssetManager assetManager = null; - try { - if (filePath.charAt(0) == '/') { - // absolute path - inputStream = new FileInputStream(filePath); - } else { - // remove prefix: "assets/" - if (filePath.startsWith(ASSETS_PATH)) { - filePath = filePath.substring(ASSETS_PATH.length()); - } - assetManager = context.getAssets(); - inputStream = assetManager.open(filePath); - } - - texture = ETC1Util.createTexture(inputStream); - inputStream.close(); - } catch (Exception e) { - Log.d("Cocos2dx", "Unable to create texture for " + filePath); - - texture = null; - } - - if (texture != null) { - boolean ret = true; - - try { - final int width = texture.getWidth(); - final int height = texture.getHeight(); - final int length = texture.getData().remaining(); - - final byte[] data = new byte[length]; - final ByteBuffer buf = ByteBuffer.wrap(data); - buf.order(ByteOrder.nativeOrder()); - buf.put(texture.getData()); - - nativeSetTextureInfo(width, - height, - data, - length); - } catch (Exception e) - { - Log.d("invoke native function error", e.toString()); - ret = false; - } - - return ret; - } else { - return false; - } - } - - public static void setContext(Context context) { - Cocos2dxETCLoader.context = context; - } - - private static native void nativeSetTextureInfo(final int width, final int height, final byte[] data, - final int dataLength); -} diff --git a/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxAccelerometer.cpp b/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxAccelerometer.cpp deleted file mode 100644 index b3ce029634..0000000000 --- a/cocos2dx/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxAccelerometer.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "cocoa/CCGeometry.h" -#include "platform/android/CCAccelerometer.h" -#include "../CCEGLView.h" -#include "JniHelper.h" -#include -#include "CCDirector.h" - -using namespace cocos2d; - -extern "C" { - JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxAccelerometer_onSensorChanged(JNIEnv* env, jobject thiz, jfloat x, jfloat y, jfloat z, jlong timeStamp) { - } -} diff --git a/cocos2dx/platform/android/jni/TouchesJni.cpp b/cocos2dx/platform/android/jni/TouchesJni.cpp deleted file mode 100644 index 0f8e16af77..0000000000 --- a/cocos2dx/platform/android/jni/TouchesJni.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -#include "cocoa/CCSet.h" -#include "CCDirector.h" -#include "keypad_dispatcher/CCKeypadDispatcher.h" -#include "touch_dispatcher/CCTouch.h" -#include "../CCEGLView.h" -#include "touch_dispatcher/CCTouchDispatcher.h" - -#include -#include - -using namespace cocos2d; - -extern "C" { - JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesBegin(JNIEnv * env, jobject thiz, jint id, jfloat x, jfloat y) { - cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesBegin(1, &id, &x, &y); - } - - JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesEnd(JNIEnv * env, jobject thiz, jint id, jfloat x, jfloat y) { - cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesEnd(1, &id, &x, &y); - } - - JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesMove(JNIEnv * env, jobject thiz, jintArray ids, jfloatArray xs, jfloatArray ys) { - int size = env->GetArrayLength(ids); - jint id[size]; - jfloat x[size]; - jfloat y[size]; - - env->GetIntArrayRegion(ids, 0, size, id); - env->GetFloatArrayRegion(xs, 0, size, x); - env->GetFloatArrayRegion(ys, 0, size, y); - - cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesMove(size, id, x, y); - } - - JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesCancel(JNIEnv * env, jobject thiz, jintArray ids, jfloatArray xs, jfloatArray ys) { - int size = env->GetArrayLength(ids); - jint id[size]; - jfloat x[size]; - jfloat y[size]; - - env->GetIntArrayRegion(ids, 0, size, id); - env->GetFloatArrayRegion(xs, 0, size, x); - env->GetFloatArrayRegion(ys, 0, size, y); - - cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesCancel(size, id, x, y); - } - - #define KEYCODE_BACK 0x04 - #define KEYCODE_MENU 0x52 - - JNIEXPORT jboolean JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeKeyDown(JNIEnv * env, jobject thiz, jint keyCode) { - Director* pDirector = Director::getInstance(); - switch (keyCode) { - case KEYCODE_BACK: - if (pDirector->getKeypadDispatcher()->dispatchKeypadMSG(kTypeBackClicked)) - return JNI_TRUE; - break; - case KEYCODE_MENU: - if (pDirector->getKeypadDispatcher()->dispatchKeypadMSG(kTypeMenuClicked)) - return JNI_TRUE; - break; - default: - return JNI_FALSE; - } - return JNI_FALSE; - } -} From 61d82924beafc6903098f2591b05587e94687160 Mon Sep 17 00:00:00 2001 From: minggo Date: Mon, 26 Aug 2013 18:01:42 +0800 Subject: [PATCH 096/126] update Android.mk to remove deleted cpp files --- cocos2dx/platform/android/Android.mk | 12 +++++------- tools/android_mk_generator/config.py | 4 ++++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/cocos2dx/platform/android/Android.mk b/cocos2dx/platform/android/Android.mk index 4beac84bd1..23dffef39b 100644 --- a/cocos2dx/platform/android/Android.mk +++ b/cocos2dx/platform/android/Android.mk @@ -7,21 +7,19 @@ LOCAL_MODULE := cocos2dxandroid_static LOCAL_MODULE_FILENAME := libcocos2dandroid LOCAL_SRC_FILES := \ -CCDevice.cpp \ -CCEGLView.cpp \ CCAccelerometer.cpp \ CCApplication.cpp \ CCCommon.cpp \ +CCDevice.cpp \ +CCEGLView.cpp \ CCFileUtilsAndroid.cpp \ CCImage.cpp \ nativeactivity.cpp \ +jni/DPIJni.cpp \ +jni/IMEJni.cpp \ jni/Java_org_cocos2dx_lib_Cocos2dxBitmap.cpp \ jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp \ -jni/Java_org_cocos2dx_lib_Cocos2dxAccelerometer.cpp \ -jni/JniHelper.cpp \ -jni/IMEJni.cpp \ -jni/TouchesJni.cpp \ -jni/DPIJni.cpp +jni/JniHelper.cpp LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) diff --git a/tools/android_mk_generator/config.py b/tools/android_mk_generator/config.py index 968f55438d..3684acc607 100644 --- a/tools/android_mk_generator/config.py +++ b/tools/android_mk_generator/config.py @@ -21,4 +21,8 @@ 'mkfile' : 'external/chipmunk/Android.mk', 'pathes' : ("external/chipmunk/",), }, +{ + 'mkfile' : 'cocos2dx/platform/android/Android.mk', + 'pathes' : ('cocos2dx/platform/android/',), +}, ] \ No newline at end of file From e567b6c54be024dd7814089e38c4f83d6c4fd780 Mon Sep 17 00:00:00 2001 From: minggo Date: Mon, 26 Aug 2013 18:02:51 +0800 Subject: [PATCH 097/126] fix warnings on ndk-r9 --- .../Cpp/AssetsManagerTest/proj.android/jni/Application.mk | 5 ++++- samples/Cpp/HelloCpp/proj.android/jni/Application.mk | 5 ++++- samples/Cpp/SimpleGame/proj.android/jni/Application.mk | 7 ++++--- samples/Cpp/TestCpp/proj.android/jni/Application.mk | 7 ++++--- .../CocosDragonJS/proj.android/jni/Application.mk | 5 ++++- .../CrystalCraze/proj.android/jni/Application.mk | 5 ++++- .../MoonWarriors/proj.android/jni/Application.mk | 4 +++- .../TestJavascript/proj.android/jni/Application.mk | 4 +++- .../WatermelonWithMe/proj.android/jni/Application.mk | 4 +++- samples/Lua/HelloLua/proj.android/jni/Application.mk | 6 +++++- samples/Lua/TestLua/proj.android/jni/Application.mk | 6 +++++- 11 files changed, 43 insertions(+), 15 deletions(-) diff --git a/samples/Cpp/AssetsManagerTest/proj.android/jni/Application.mk b/samples/Cpp/AssetsManagerTest/proj.android/jni/Application.mk index 7d9d576f0c..5273ceb9dd 100644 --- a/samples/Cpp/AssetsManagerTest/proj.android/jni/Application.mk +++ b/samples/Cpp/AssetsManagerTest/proj.android/jni/Application.mk @@ -1,3 +1,6 @@ APP_STL := gnustl_static APP_CPPFLAGS := -frtti -DCOCOS2D_JAVASCRIPT=1 -std=c++11 -APP_CPPFLAGS += -DCOCOS2D_DEBUG=1 -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 + +# add -Wno-literal-suffix to avoid warning: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix] +# in NDK_ROOT/arch-arm/usr/include/sys/cdefs_elf.h:35:28: when using ndk-r9 +APP_CPPFLAGS := -frtti -DCOCOS2D_DEBUG=1 -std=c++11 -Wno-literal-suffix diff --git a/samples/Cpp/HelloCpp/proj.android/jni/Application.mk b/samples/Cpp/HelloCpp/proj.android/jni/Application.mk index 988bf2fadc..0e9d025fba 100644 --- a/samples/Cpp/HelloCpp/proj.android/jni/Application.mk +++ b/samples/Cpp/HelloCpp/proj.android/jni/Application.mk @@ -1,2 +1,5 @@ APP_STL := gnustl_static -APP_CPPFLAGS := -frtti -DCOCOS2D_DEBUG=1 -std=c++11 + +# add -Wno-literal-suffix to avoid warning: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix] +# in NDK_ROOT/arch-arm/usr/include/sys/cdefs_elf.h:35:28: when using ndk-r9 +APP_CPPFLAGS := -frtti -DCOCOS2D_DEBUG=1 -std=c++11 -Wno-literal-suffix diff --git a/samples/Cpp/SimpleGame/proj.android/jni/Application.mk b/samples/Cpp/SimpleGame/proj.android/jni/Application.mk index 133b505945..0e9d025fba 100644 --- a/samples/Cpp/SimpleGame/proj.android/jni/Application.mk +++ b/samples/Cpp/SimpleGame/proj.android/jni/Application.mk @@ -1,4 +1,5 @@ APP_STL := gnustl_static -APP_CPPFLAGS := -frtti -DCOCOS2D_DEBUG=1 -std=c++11 -APP_ABI := armeabi -APP_OPTIM := debug + +# add -Wno-literal-suffix to avoid warning: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix] +# in NDK_ROOT/arch-arm/usr/include/sys/cdefs_elf.h:35:28: when using ndk-r9 +APP_CPPFLAGS := -frtti -DCOCOS2D_DEBUG=1 -std=c++11 -Wno-literal-suffix diff --git a/samples/Cpp/TestCpp/proj.android/jni/Application.mk b/samples/Cpp/TestCpp/proj.android/jni/Application.mk index 5c3833f465..9761d1692d 100644 --- a/samples/Cpp/TestCpp/proj.android/jni/Application.mk +++ b/samples/Cpp/TestCpp/proj.android/jni/Application.mk @@ -1,4 +1,5 @@ APP_STL := gnustl_static -APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -DCOCOS2D_DEBUG=1 -std=c++11 -APP_OPTIM := debug -APP_ABI := armeabi + +# add -Wno-literal-suffix to avoid warning: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix] +# in NDK_ROOT/arch-arm/usr/include/sys/cdefs_elf.h:35:28: when using ndk-r9 +APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -DCOCOS2D_DEBUG=1 -std=c++11 -Wno-literal-suffix diff --git a/samples/Javascript/CocosDragonJS/proj.android/jni/Application.mk b/samples/Javascript/CocosDragonJS/proj.android/jni/Application.mk index ee9712a9d8..24a7a8cbb3 100644 --- a/samples/Javascript/CocosDragonJS/proj.android/jni/Application.mk +++ b/samples/Javascript/CocosDragonJS/proj.android/jni/Application.mk @@ -1,4 +1,7 @@ APP_STL := gnustl_static APP_CPPFLAGS := -frtti -DCOCOS2D_JAVASCRIPT=1 -std=c++11 -APP_CPPFLAGS += -DCOCOS2D_DEBUG=1 -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 + +# add -Wno-literal-suffix to avoid warning: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix] +# in NDK_ROOT/arch-arm/usr/include/sys/cdefs_elf.h:35:28: when using ndk-r9 +APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -DCOCOS2D_DEBUG=1 -std=c++11 -Wno-literal-suffix diff --git a/samples/Javascript/CrystalCraze/proj.android/jni/Application.mk b/samples/Javascript/CrystalCraze/proj.android/jni/Application.mk index ee9712a9d8..24a7a8cbb3 100644 --- a/samples/Javascript/CrystalCraze/proj.android/jni/Application.mk +++ b/samples/Javascript/CrystalCraze/proj.android/jni/Application.mk @@ -1,4 +1,7 @@ APP_STL := gnustl_static APP_CPPFLAGS := -frtti -DCOCOS2D_JAVASCRIPT=1 -std=c++11 -APP_CPPFLAGS += -DCOCOS2D_DEBUG=1 -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 + +# add -Wno-literal-suffix to avoid warning: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix] +# in NDK_ROOT/arch-arm/usr/include/sys/cdefs_elf.h:35:28: when using ndk-r9 +APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -DCOCOS2D_DEBUG=1 -std=c++11 -Wno-literal-suffix diff --git a/samples/Javascript/MoonWarriors/proj.android/jni/Application.mk b/samples/Javascript/MoonWarriors/proj.android/jni/Application.mk index 4014245067..6608c6e10e 100644 --- a/samples/Javascript/MoonWarriors/proj.android/jni/Application.mk +++ b/samples/Javascript/MoonWarriors/proj.android/jni/Application.mk @@ -1,4 +1,6 @@ APP_STL := gnustl_static APP_CPPFLAGS := -frtti -DCOCOS2D_JAVASCRIPT= -std=c++11 -APP_CPPFLAGS += -DCOCOS2D_DEBUG=1 -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 +# add -Wno-literal-suffix to avoid warning: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix] +# in NDK_ROOT/arch-arm/usr/include/sys/cdefs_elf.h:35:28: when using ndk-r9 +APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -DCOCOS2D_DEBUG=1 -std=c++11 -Wno-literal-suffix diff --git a/samples/Javascript/TestJavascript/proj.android/jni/Application.mk b/samples/Javascript/TestJavascript/proj.android/jni/Application.mk index ee9712a9d8..dc8b56b0ac 100644 --- a/samples/Javascript/TestJavascript/proj.android/jni/Application.mk +++ b/samples/Javascript/TestJavascript/proj.android/jni/Application.mk @@ -1,4 +1,6 @@ APP_STL := gnustl_static APP_CPPFLAGS := -frtti -DCOCOS2D_JAVASCRIPT=1 -std=c++11 -APP_CPPFLAGS += -DCOCOS2D_DEBUG=1 -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 +# add -Wno-literal-suffix to avoid warning: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix] +# in NDK_ROOT/arch-arm/usr/include/sys/cdefs_elf.h:35:28: when using ndk-r9 +APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -DCOCOS2D_DEBUG=1 -std=c++11 -Wno-literal-suffix diff --git a/samples/Javascript/WatermelonWithMe/proj.android/jni/Application.mk b/samples/Javascript/WatermelonWithMe/proj.android/jni/Application.mk index ee9712a9d8..dc8b56b0ac 100644 --- a/samples/Javascript/WatermelonWithMe/proj.android/jni/Application.mk +++ b/samples/Javascript/WatermelonWithMe/proj.android/jni/Application.mk @@ -1,4 +1,6 @@ APP_STL := gnustl_static APP_CPPFLAGS := -frtti -DCOCOS2D_JAVASCRIPT=1 -std=c++11 -APP_CPPFLAGS += -DCOCOS2D_DEBUG=1 -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 +# add -Wno-literal-suffix to avoid warning: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix] +# in NDK_ROOT/arch-arm/usr/include/sys/cdefs_elf.h:35:28: when using ndk-r9 +APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -DCOCOS2D_DEBUG=1 -std=c++11 -Wno-literal-suffix diff --git a/samples/Lua/HelloLua/proj.android/jni/Application.mk b/samples/Lua/HelloLua/proj.android/jni/Application.mk index daad673c2b..a829fc0f48 100644 --- a/samples/Lua/HelloLua/proj.android/jni/Application.mk +++ b/samples/Lua/HelloLua/proj.android/jni/Application.mk @@ -1,4 +1,8 @@ APP_STL := gnustl_static -APP_CPPFLAGS := -frtti -DCOCOS2D_DEBUG=1 -std=c++11 + +# add -Wno-literal-suffix to avoid warning: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix] +# in NDK_ROOT/arch-arm/usr/include/sys/cdefs_elf.h:35:28: when using ndk-r9 +APP_CPPFLAGS := -frtti -DCOCOS2D_DEBUG=1 -std=c++11 -Wno-literal-suffix + APP_CPPFLAGS += -fexceptions diff --git a/samples/Lua/TestLua/proj.android/jni/Application.mk b/samples/Lua/TestLua/proj.android/jni/Application.mk index daad673c2b..a829fc0f48 100644 --- a/samples/Lua/TestLua/proj.android/jni/Application.mk +++ b/samples/Lua/TestLua/proj.android/jni/Application.mk @@ -1,4 +1,8 @@ APP_STL := gnustl_static -APP_CPPFLAGS := -frtti -DCOCOS2D_DEBUG=1 -std=c++11 + +# add -Wno-literal-suffix to avoid warning: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix] +# in NDK_ROOT/arch-arm/usr/include/sys/cdefs_elf.h:35:28: when using ndk-r9 +APP_CPPFLAGS := -frtti -DCOCOS2D_DEBUG=1 -std=c++11 -Wno-literal-suffix + APP_CPPFLAGS += -fexceptions From c7b0b6791f3513db79f9ac12e4777fde8fa4c0a7 Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Mon, 26 Aug 2013 18:09:15 +0800 Subject: [PATCH 098/126] issue #2433:Update typed function and add some manual binding --- .../lua/cocos2dx_support/LuaBasicConversions.cpp | 5 +++-- .../cocos2dx_support/LuaOpengl.cpp.REMOVED.git-id | 2 +- .../generated/lua_cocos2dx_auto.cpp.REMOVED.git-id | 2 +- .../lua_cocos2dx_auto_api.js.REMOVED.git-id | 2 +- .../lua_cocos2dx_extension_auto.cpp.REMOVED.git-id | 2 +- .../lua_cocos2dx_extension_manual.cpp | 2 +- .../lua/cocos2dx_support/lua_cocos2dx_manual.cpp | 14 +++++++------- tools/bindings-generator | 2 +- 8 files changed, 16 insertions(+), 15 deletions(-) diff --git a/scripting/lua/cocos2dx_support/LuaBasicConversions.cpp b/scripting/lua/cocos2dx_support/LuaBasicConversions.cpp index 9b389e25a7..73d2e811ea 100644 --- a/scripting/lua/cocos2dx_support/LuaBasicConversions.cpp +++ b/scripting/lua/cocos2dx_support/LuaBasicConversions.cpp @@ -1137,7 +1137,7 @@ void array_to_luaval(lua_State* L,Array* inValue) if (nullptr == obj) continue; - uint32_t typeId = cocos2d::getHashCodeByString(typeid(*obj).name()); + uint32_t typeId = typeid(*obj).hash_code(); auto iter = g_luaType.find(typeId); if (g_luaType.end() != iter) { @@ -1226,7 +1226,8 @@ void dictionary_to_luaval(lua_State* L, Dictionary* dict) if (NULL == element) continue; - uint32_t typeId = cocos2d::getHashCodeByString(typeid(element->getObject()).name()); + uint32_t typeId = typeid(element->getObject()).hash_code(); + auto iter = g_luaType.find(typeId); if (g_luaType.end() != iter) { diff --git a/scripting/lua/cocos2dx_support/LuaOpengl.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/LuaOpengl.cpp.REMOVED.git-id index 1a95695d30..59e1eb54ca 100644 --- a/scripting/lua/cocos2dx_support/LuaOpengl.cpp.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/LuaOpengl.cpp.REMOVED.git-id @@ -1 +1 @@ -13bc27135b11b87249075c37897972a41802f216 \ No newline at end of file +e2ec824824096631a51472eab29643b0f55ef6f3 \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id index a079474a29..ba456b9a2d 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id @@ -1 +1 @@ -451f7b8e8003474fb17be07923476ea2f12a9122 \ No newline at end of file +90eec5befefca388a591c3cf8dc10950588cec15 \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id index ecb3af7f4c..9fa10a1d50 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id @@ -1 +1 @@ -7ec8c685dde8f273f39cb13c8e009d9bca6e0e53 \ No newline at end of file +bc27ec5b64be9ac5530fd15fcc22cd8832504685 \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id index 55cb9b86aa..40c1f53607 100644 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id @@ -1 +1 @@ -2c817ab849fe61f97c010cf5e9b6528bca2a0396 \ No newline at end of file +0389c415199783d5bbcc1ee8882cc01220bc37f6 \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/lua_cocos2dx_extension_manual.cpp b/scripting/lua/cocos2dx_support/lua_cocos2dx_extension_manual.cpp index 7a4b325aaf..790e64a15e 100644 --- a/scripting/lua/cocos2dx_support/lua_cocos2dx_extension_manual.cpp +++ b/scripting/lua/cocos2dx_support/lua_cocos2dx_extension_manual.cpp @@ -690,7 +690,7 @@ int register_cocos2dx_extension_CCBProxy(lua_State* tolua_S) tolua_endmodule(tolua_S); tolua_endmodule(tolua_S); - uint32_t typeId = cocos2d::getHashCodeByString(typeid(CCBProxy).name()); + uint32_t typeId = typeid(CCBProxy).hash_code(); g_luaType[typeId] = "CCBProxy"; return 1; } diff --git a/scripting/lua/cocos2dx_support/lua_cocos2dx_manual.cpp b/scripting/lua/cocos2dx_support/lua_cocos2dx_manual.cpp index c3ee4d2e0c..275f08edf0 100644 --- a/scripting/lua/cocos2dx_support/lua_cocos2dx_manual.cpp +++ b/scripting/lua/cocos2dx_support/lua_cocos2dx_manual.cpp @@ -903,7 +903,7 @@ tolua_lerror: #endif } -static int tolua_cocos2d_Sequence_create(lua_State* tolua_S) +int tolua_cocos2d_Sequence_create(lua_State* tolua_S) { if (NULL == tolua_S) return 0; @@ -1279,7 +1279,7 @@ tolua_lerror: #endif } -static int tolua_cocos2d_CardinalSplineBy_create(lua_State* tolua_S) +int lua_cocos2d_CardinalSplineBy_create(lua_State* tolua_S) { if (NULL == tolua_S) return 0; @@ -1348,7 +1348,7 @@ tolua_lerror: #endif } -static int tolua_cocos2d_CatmullRomBy_create(lua_State* tolua_S) +int tolua_cocos2d_CatmullRomBy_create(lua_State* tolua_S) { if (NULL == tolua_S) return 0; @@ -1412,7 +1412,7 @@ tolua_lerror: #endif } -static int tolua_cocos2d_CatmullRomTo_create(lua_State* tolua_S) +int tolua_cocos2d_CatmullRomTo_create(lua_State* tolua_S) { if (NULL == tolua_S) return 0; @@ -1476,7 +1476,7 @@ tolua_lerror: #endif } -static int tolua_cocos2d_BezierBy_create(lua_State* tolua_S) +int tolua_cocos2d_BezierBy_create(lua_State* tolua_S) { if (NULL == tolua_S) return 0; @@ -1536,7 +1536,7 @@ tolua_lerror: #endif } -static int tolua_cocos2d_BezierTo_create(lua_State* tolua_S) +int tolua_cocos2d_BezierTo_create(lua_State* tolua_S) { if (NULL == tolua_S) return 0; @@ -2497,7 +2497,7 @@ static void extendCardinalSplineBy(lua_State* tolua_S) if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"create"); - lua_pushcfunction(tolua_S,tolua_cocos2d_CardinalSplineBy_create); + lua_pushcfunction(tolua_S,lua_cocos2d_CardinalSplineBy_create); lua_rawset(tolua_S,-3); } } diff --git a/tools/bindings-generator b/tools/bindings-generator index e82fb176bd..98ddf882f2 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit e82fb176bd9a9fa573e3282e6af5ba19a7131633 +Subproject commit 98ddf882f2898bc9043ea54d9ed7f32383f6be4d From 84fcb26e4449fba0fc002ec8cc65e6edc47e3680 Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Mon, 26 Aug 2013 18:30:03 +0800 Subject: [PATCH 099/126] issue #2433:compile error --- .../cocos2dx_support/lua_cocos2dx_deprecated.cpp.REMOVED.git-id | 2 +- scripting/lua/tolua/tolua_map.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripting/lua/cocos2dx_support/lua_cocos2dx_deprecated.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/lua_cocos2dx_deprecated.cpp.REMOVED.git-id index b3b4027b66..8209aca090 100644 --- a/scripting/lua/cocos2dx_support/lua_cocos2dx_deprecated.cpp.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/lua_cocos2dx_deprecated.cpp.REMOVED.git-id @@ -1 +1 @@ -6bb676eae227e4e547cbeaea273b5289354d5a89 \ No newline at end of file +8b050405631c049752c3abcbbdf1175624cc1d2a \ No newline at end of file diff --git a/scripting/lua/tolua/tolua_map.c b/scripting/lua/tolua/tolua_map.c index 3857c869d8..6b6c047e15 100644 --- a/scripting/lua/tolua/tolua_map.c +++ b/scripting/lua/tolua/tolua_map.c @@ -211,7 +211,7 @@ static int tolua_bnd_releaseownership (lua_State* L) /* Type casting */ -static int tolua_bnd_cast (lua_State* L) +int tolua_bnd_cast (lua_State* L) { /* // old code From 59e3785baf30c8a31dc29a0f81f125567c3f8651 Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Mon, 26 Aug 2013 18:45:50 +0800 Subject: [PATCH 100/126] issue #2433:Modify platform config --- scripting/lua/proj.android/Android.mk | 1 + scripting/lua/proj.emscripten/Makefile | 3 ++- scripting/lua/proj.linux/Makefile | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/scripting/lua/proj.android/Android.mk b/scripting/lua/proj.android/Android.mk index 0b6cb93bd9..7980093553 100644 --- a/scripting/lua/proj.android/Android.mk +++ b/scripting/lua/proj.android/Android.mk @@ -22,6 +22,7 @@ LOCAL_SRC_FILES := ../cocos2dx_support/CCLuaBridge.cpp \ ../cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp \ ../cocos2dx_support/lua_cocos2dx_manual.cpp \ ../cocos2dx_support/lua_cocos2dx_extension_manual.cpp \ + ../cocos2dx_support/lua_cocos2dx_deprecated.cpp \ ../tolua/tolua_event.c \ ../tolua/tolua_is.c \ ../tolua/tolua_map.c \ diff --git a/scripting/lua/proj.emscripten/Makefile b/scripting/lua/proj.emscripten/Makefile index 7e3af98d23..3a68b6b2ab 100644 --- a/scripting/lua/proj.emscripten/Makefile +++ b/scripting/lua/proj.emscripten/Makefile @@ -54,7 +54,8 @@ SOURCES = ../lua/lapi.o \ ../cocos2dx_support/generated/lua_cocos2dx_auto.cpp \ ../cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp \ ../cocos2dx_support/lua_cocos2dx_manual.cpp \ - ../cocos2dx_support/lua_cocos2dx_extension_manual.cpp + ../cocos2dx_support/lua_cocos2dx_extension_manual.cpp \ + ../cocos2dx_support/lua_cocos2dx_deprecated.cpp include ../../../cocos2dx/proj.emscripten/cocos2dx.mk diff --git a/scripting/lua/proj.linux/Makefile b/scripting/lua/proj.linux/Makefile index 29042d516f..7bf87661c1 100644 --- a/scripting/lua/proj.linux/Makefile +++ b/scripting/lua/proj.linux/Makefile @@ -54,7 +54,8 @@ SOURCES = ../lua/lapi.o \ ../cocos2dx_support/generated/lua_cocos2dx_auto.cpp \ ../cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp \ ../cocos2dx_support/lua_cocos2dx_manual.cpp \ - ../cocos2dx_support/lua_cocos2dx_extension_manual.cpp + ../cocos2dx_support/lua_cocos2dx_extension_manual.cpp \ + ../cocos2dx_support/lua_cocos2dx_deprecated.cpp include ../../../cocos2dx/proj.linux/cocos2dx.mk From f0620b0e857cf2c3cc5401cd06c562a50572965e Mon Sep 17 00:00:00 2001 From: psi Date: Mon, 26 Aug 2013 20:38:23 +0900 Subject: [PATCH 101/126] add overrode init method for LayerMultiplex --- cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp | 10 ++++++++++ cocos2dx/layers_scenes_transitions_nodes/CCLayer.h | 1 + 2 files changed, 11 insertions(+) diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp index d3d218819c..d0bbc5b07f 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp @@ -1073,6 +1073,16 @@ void LayerMultiplex::addLayer(Layer* layer) _layers->addObject(layer); } +bool LayerMultiplex::init() + if (Layer::init()) { + _layers = Array::create(); + _layers->retain(); + + _enabledLayer = 0; + return true; + } + return false; +} bool LayerMultiplex::initWithLayers(Layer *layer, va_list params) { if (Layer::init()) diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h index 24df564cba..32e8991b75 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h @@ -374,6 +374,7 @@ public: LayerMultiplex(); virtual ~LayerMultiplex(); + virtual bool init(); /** initializes a MultiplexLayer with one or more layers using a variable argument list. */ bool initWithLayers(Layer* layer, va_list params); From 1beea771b44e75c3118126a38cb854997a870e9e Mon Sep 17 00:00:00 2001 From: psi Date: Mon, 26 Aug 2013 20:42:41 +0900 Subject: [PATCH 102/126] type --- cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp index d0bbc5b07f..edf2a037d4 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp @@ -1074,7 +1074,9 @@ void LayerMultiplex::addLayer(Layer* layer) } bool LayerMultiplex::init() - if (Layer::init()) { +{ + if (Layer::init()) + { _layers = Array::create(); _layers->retain(); @@ -1083,6 +1085,7 @@ bool LayerMultiplex::init() } return false; } + bool LayerMultiplex::initWithLayers(Layer *layer, va_list params) { if (Layer::init()) From b3b3583583eb191d96aa22962c291744e767b486 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Mon, 26 Aug 2013 18:04:51 -0700 Subject: [PATCH 103/126] CCNode perf improvements AffineTransforms uses a const global variable for the `IDENTITY` `removeObject` only seeks the index once Signed-off-by: Ricardo Quesada --- cocos2dx/base_nodes/CCNode.cpp | 24 +++++++++++++++--------- cocos2dx/base_nodes/CCNode.h | 6 +++--- cocos2dx/cocoa/CCAffineTransform.cpp | 2 +- cocos2dx/cocoa/CCAffineTransform.h | 6 ++++-- 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/cocos2dx/base_nodes/CCNode.cpp b/cocos2dx/base_nodes/CCNode.cpp index 1c0af95862..69fabed44d 100644 --- a/cocos2dx/base_nodes/CCNode.cpp +++ b/cocos2dx/base_nodes/CCNode.cpp @@ -30,6 +30,7 @@ THE SOFTWARE. #include #include "cocoa/CCString.h" +#include "support/data_support/ccCArray.h" #include "support/TransformUtils.h" #include "CCCamera.h" #include "effects/CCGrid.h" @@ -39,6 +40,7 @@ THE SOFTWARE. #include "actions/CCActionManager.h" #include "script_support/CCScriptSupport.h" #include "shaders/CCGLProgram.h" + // externals #include "kazmath/GL/matrix.h" #include "support/component/CCComponent.h" @@ -67,9 +69,9 @@ Node::Node(void) , _anchorPointInPoints(Point::ZERO) , _anchorPoint(Point::ZERO) , _contentSize(Size::ZERO) -, _additionalTransform(AffineTransformMakeIdentity()) -, _transform(AffineTransformMakeIdentity()) -, _inverse(AffineTransformMakeIdentity()) +, _additionalTransform(AffineTransform::IDENTITY) +, _transform(AffineTransform::IDENTITY) +, _inverse(AffineTransform::IDENTITY) , _additionalTransformDirty(false) , _transformDirty(true) , _inverseDirty(true) @@ -611,10 +613,14 @@ void Node::removeChild(Node* child, bool cleanup /* = true */) return; } - if ( _children->containsObject(child) ) - { - this->detachChild(child,cleanup); - } +// if ( _children->containsObject(child) ) +// { +// this->detachChild(child,cleanup); +// } + + int index = _children->getIndexOfObject(child); + if( index != CC_INVALID_INDEX ) + this->detachChild( child, index, cleanup ); } void Node::removeChildByTag(int tag, bool cleanup/* = true */) @@ -672,7 +678,7 @@ void Node::removeAllChildrenWithCleanup(bool cleanup) } -void Node::detachChild(Node *child, bool doCleanup) +void Node::detachChild(Node *child, int childIndex, bool doCleanup) { // IMPORTANT: // -1st do onExit @@ -693,7 +699,7 @@ void Node::detachChild(Node *child, bool doCleanup) // set parent nil at the end child->setParent(NULL); - _children->removeObject(child); + _children->removeObjectAtIndex(childIndex); } diff --git a/cocos2dx/base_nodes/CCNode.h b/cocos2dx/base_nodes/CCNode.h index 2c892ff63a..bfd830d72e 100644 --- a/cocos2dx/base_nodes/CCNode.h +++ b/cocos2dx/base_nodes/CCNode.h @@ -1296,7 +1296,7 @@ public: virtual void removeAllComponents(); /// @} end of component functions -private: +protected: /// lazy allocs void childrenAlloc(void); @@ -1304,12 +1304,12 @@ private: void insertChild(Node* child, int z); /// Removes a child, call child->onExit(), do cleanup, remove it from children array. - void detachChild(Node *child, bool doCleanup); + void detachChild(Node *child, int index, bool doCleanup); /// Convert cocos2d coordinates to UI windows coordinate. Point convertToWindowSpace(const Point& nodePoint) const; -protected: + float _rotationX; ///< rotation angle on x-axis float _rotationY; ///< rotation angle on y-axis diff --git a/cocos2dx/cocoa/CCAffineTransform.cpp b/cocos2dx/cocoa/CCAffineTransform.cpp index cbfa3c1f2f..2e39f344cc 100644 --- a/cocos2dx/cocoa/CCAffineTransform.cpp +++ b/cocos2dx/cocoa/CCAffineTransform.cpp @@ -60,7 +60,7 @@ AffineTransform AffineTransformMakeIdentity() } extern const AffineTransform AffineTransformIdentity = AffineTransformMakeIdentity(); - +const AffineTransform AffineTransform::IDENTITY = AffineTransformMakeIdentity(); Rect RectApplyAffineTransform(const Rect& rect, const AffineTransform& anAffineTransform) { diff --git a/cocos2dx/cocoa/CCAffineTransform.h b/cocos2dx/cocoa/CCAffineTransform.h index d6200440b5..667b5d9b46 100644 --- a/cocos2dx/cocoa/CCAffineTransform.h +++ b/cocos2dx/cocoa/CCAffineTransform.h @@ -31,8 +31,10 @@ THE SOFTWARE. NS_CC_BEGIN struct AffineTransform { - float a, b, c, d; - float tx, ty; + float a, b, c, d; + float tx, ty; + + static const AffineTransform IDENTITY; }; CC_DLL AffineTransform __CCAffineTransformMake(float a, float b, float c, float d, float tx, float ty); From 62c578667b651b5a631da65bc1d68cfee5d3648f Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Mon, 26 Aug 2013 18:05:48 -0700 Subject: [PATCH 104/126] API compliant with cocos2d-x best practices Uses `int` instead of `unsigned int` as described in the cocos2d-x best practices Signed-off-by: Ricardo Quesada --- cocos2dx/cocoa/CCArray.cpp | 56 ++++++------ cocos2dx/cocoa/CCArray.h | 16 ++-- cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp | 18 ++-- cocos2dx/support/data_support/ccCArray.cpp | 96 +++++++++++---------- cocos2dx/support/data_support/ccCArray.h | 34 ++++---- 5 files changed, 107 insertions(+), 113 deletions(-) diff --git a/cocos2dx/cocoa/CCArray.cpp b/cocos2dx/cocoa/CCArray.cpp index b525fdde6a..8eaab7fa6d 100644 --- a/cocos2dx/cocoa/CCArray.cpp +++ b/cocos2dx/cocoa/CCArray.cpp @@ -46,7 +46,7 @@ Array* Array::create() { Array* array = new Array(); - if (array && array->init()) + if (array && array->initWithCapacity(7)) { array->autorelease(); } @@ -105,7 +105,7 @@ Array* Array::createWithArray(Array* otherArray) return otherArray->clone(); } -Array* Array::createWithCapacity(unsigned int capacity) +Array* Array::createWithCapacity(int capacity) { Array* array = new Array(); @@ -138,12 +138,12 @@ Array* Array::createWithContentsOfFileThreadSafe(const char* fileName) bool Array::init() { - return initWithCapacity(10); + return initWithCapacity(7); } bool Array::initWithObject(Object* object) { - bool ret = initWithCapacity(1); + bool ret = initWithCapacity(7); if (ret) { addObject(object); @@ -180,7 +180,7 @@ bool Array::initWithObjects(Object* object, ...) return ret; } -bool Array::initWithCapacity(unsigned int capacity) +bool Array::initWithCapacity(int capacity) { data.reserve(capacity); return true; @@ -234,7 +234,7 @@ bool Array::containsObject(Object* object) const bool Array::isEqualToArray(Array* otherArray) { - for (unsigned int i = 0; i< this->count(); i++) + for (int i = 0; i< this->count(); i++) { if (!this->getObjectAtIndex(i)->isEqual(otherArray->getObjectAtIndex(i))) { @@ -272,18 +272,10 @@ void Array::removeLastObject(bool releaseObj) void Array::removeObject(Object* object, bool releaseObj /* ignored */) { - auto it = data.begin(); - for (; it != data.end(); ++it) - { - if (it->get() == object) - { - data.erase(it); - break; - } - } + data.erase( std::remove( data.begin(), data.end(), object ) ); } -void Array::removeObjectAtIndex(unsigned int index, bool releaseObj /* ignored */) +void Array::removeObjectAtIndex(int index, bool releaseObj /* ignored */) { auto obj = data[index]; data.erase( data.begin() + index ); @@ -299,7 +291,7 @@ void Array::removeAllObjects() data.erase(std::begin(data), std::end(data)); } -void Array::fastRemoveObjectAtIndex(unsigned int index) +void Array::fastRemoveObjectAtIndex(int index) { removeObjectAtIndex(index); } @@ -319,12 +311,12 @@ void Array::exchangeObject(Object* object1, Object* object2) std::swap( data[idx1], data[idx2] ); } -void Array::exchangeObjectAtIndex(unsigned int index1, unsigned int index2) +void Array::exchangeObjectAtIndex(int index1, int index2) { std::swap( data[index1], data[index2] ); } -void Array::replaceObjectAtIndex(unsigned int index, Object* object, bool releaseObject /* ignored */) +void Array::replaceObjectAtIndex(int index, Object* object, bool releaseObject /* ignored */) { data[index] = object; } @@ -393,7 +385,7 @@ Array* Array::create() { Array* array = new Array(); - if (array && array->init()) + if (array && array->initWithCapacity(7)) { array->autorelease(); } @@ -452,7 +444,7 @@ Array* Array::createWithArray(Array* otherArray) return otherArray->clone(); } -Array* Array::createWithCapacity(unsigned int capacity) +Array* Array::createWithCapacity(int capacity) { Array* array = new Array(); @@ -487,14 +479,14 @@ bool Array::init() { CCASSERT(!data, "Array cannot be re-initialized"); - return initWithCapacity(1); + return initWithCapacity(7); } bool Array::initWithObject(Object* object) { CCASSERT(!data, "Array cannot be re-initialized"); - bool ret = initWithCapacity(1); + bool ret = initWithCapacity(7); if (ret) { addObject(object); @@ -533,7 +525,7 @@ bool Array::initWithObjects(Object* object, ...) return ret; } -bool Array::initWithCapacity(unsigned int capacity) +bool Array::initWithCapacity(int capacity) { CCASSERT(!data, "Array cannot be re-initialized"); @@ -586,7 +578,7 @@ bool Array::containsObject(Object* object) const bool Array::isEqualToArray(Array* otherArray) { - for (unsigned int i = 0; i< this->count(); i++) + for (int i = 0; i< this->count(); i++) { if (!this->getObjectAtIndex(i)->isEqual(otherArray->getObjectAtIndex(i))) { @@ -637,7 +629,7 @@ void Array::removeObject(Object* object, bool releaseObj/* = true*/) ccArrayRemoveObject(data, object, releaseObj); } -void Array::removeObjectAtIndex(unsigned int index, bool releaseObj) +void Array::removeObjectAtIndex(int index, bool releaseObj) { ccArrayRemoveObjectAtIndex(data, index, releaseObj); } @@ -652,7 +644,7 @@ void Array::removeAllObjects() ccArrayRemoveAllObjects(data); } -void Array::fastRemoveObjectAtIndex(unsigned int index) +void Array::fastRemoveObjectAtIndex(int index) { ccArrayFastRemoveObjectAtIndex(data, index); } @@ -664,13 +656,13 @@ void Array::fastRemoveObject(Object* object) void Array::exchangeObject(Object* object1, Object* object2) { - unsigned int index1 = ccArrayGetIndexOfObject(data, object1); + int index1 = ccArrayGetIndexOfObject(data, object1); if (index1 == UINT_MAX) { return; } - unsigned int index2 = ccArrayGetIndexOfObject(data, object2); + int index2 = ccArrayGetIndexOfObject(data, object2); if (index2 == UINT_MAX) { return; @@ -679,12 +671,12 @@ void Array::exchangeObject(Object* object1, Object* object2) ccArraySwapObjectsAtIndexes(data, index1, index2); } -void Array::exchangeObjectAtIndex(unsigned int index1, unsigned int index2) +void Array::exchangeObjectAtIndex(int index1, int index2) { ccArraySwapObjectsAtIndexes(data, index1, index2); } -void Array::replaceObjectAtIndex(unsigned int index, Object* object, bool releaseObject/* = true*/) +void Array::replaceObjectAtIndex(int index, Object* object, bool releaseObject/* = true*/) { ccArrayInsertObjectAtIndex(data, object, index); ccArrayRemoveObjectAtIndex(data, index+1); @@ -696,7 +688,7 @@ void Array::reverseObjects() { // floorf(), since in the case of an even number, the number of swaps stays the same int count = (int) floorf(data->num/2.f); - unsigned int maxIndex = data->num - 1; + int maxIndex = data->num - 1; for (int i = 0; i < count ; i++) { diff --git a/cocos2dx/cocoa/CCArray.h b/cocos2dx/cocoa/CCArray.h index 771a33c9ee..518f7f122d 100644 --- a/cocos2dx/cocoa/CCArray.h +++ b/cocos2dx/cocoa/CCArray.h @@ -241,7 +241,7 @@ public: /** Create an array with one object */ static Array* createWithObject(Object* object); /** Create an array with a default capacity */ - static Array* createWithCapacity(unsigned int capacity); + static Array* createWithCapacity(int capacity); /** Create an array with from an existing array */ static Array* createWithArray(Array* otherArray); /** @@ -266,14 +266,14 @@ public: /** Initializes an array with some objects */ bool initWithObjects(Object* object, ...) CC_REQUIRES_NULL_TERMINATION; /** Initializes an array with capacity */ - bool initWithCapacity(unsigned int capacity); + bool initWithCapacity(int capacity); /** Initializes an array with an existing array */ bool initWithArray(Array* otherArray); // Querying an Array /** Returns element count of the array */ - unsigned int count() const + int count() const { #if CC_USE_ARRAY_VECTOR return data.size(); @@ -282,7 +282,7 @@ public: #endif } /** Returns capacity of the array */ - unsigned int capacity() const + int capacity() const { #if CC_USE_ARRAY_VECTOR return data.capacity(); @@ -363,7 +363,7 @@ public: /** Remove a certain object */ void removeObject(Object* object, bool releaseObj = true); /** Remove an element with a certain index */ - void removeObjectAtIndex(unsigned int index, bool releaseObj = true); + void removeObjectAtIndex(int index, bool releaseObj = true); /** Remove all elements */ void removeObjectsInArray(Array* otherArray); /** Remove all objects */ @@ -371,17 +371,17 @@ public: /** Fast way to remove a certain object */ void fastRemoveObject(Object* object); /** Fast way to remove an element with a certain index */ - void fastRemoveObjectAtIndex(unsigned int index); + void fastRemoveObjectAtIndex(int index); // Rearranging Content /** Swap two elements */ void exchangeObject(Object* object1, Object* object2); /** Swap two elements with certain indexes */ - void exchangeObjectAtIndex(unsigned int index1, unsigned int index2); + void exchangeObjectAtIndex(int index1, int index2); /** Replace object at index with another object. */ - void replaceObjectAtIndex(unsigned int index, Object* object, bool releaseObject = true); + void replaceObjectAtIndex(int index, Object* object, bool releaseObject = true); /** Revers the array */ void reverseObjects(); diff --git a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp index f83b11bf49..32e6d06e01 100644 --- a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp @@ -654,17 +654,17 @@ void SpriteBatchNode::removeSpriteFromAtlas(Sprite *sprite) // Cleanup sprite. It might be reused (issue #569) sprite->setBatchNode(NULL); - unsigned int uIndex = _descendants->getIndexOfObject(sprite); - if (uIndex != UINT_MAX) + int index = _descendants->getIndexOfObject(sprite); + if (index != UINT_MAX) { - _descendants->removeObjectAtIndex(uIndex); + _descendants->removeObjectAtIndex(index); // update all sprites beyond this one - unsigned int count = _descendants->count(); + int count = _descendants->count(); - for(; uIndex < count; ++uIndex) + for(; index < count; ++index) { - Sprite* s = (Sprite*)(_descendants->getObjectAtIndex(uIndex)); + Sprite* s = static_cast(_descendants->getObjectAtIndex(index)); s->setAtlasIndex( s->getAtlasIndex() - 1 ); } } @@ -673,10 +673,10 @@ void SpriteBatchNode::removeSpriteFromAtlas(Sprite *sprite) Array *children = sprite->getChildren(); if (children && children->count() > 0) { - Object* pObject = NULL; - CCARRAY_FOREACH(children, pObject) + Object* object = NULL; + CCARRAY_FOREACH(children, object) { - Sprite* child = static_cast(pObject); + Sprite* child = static_cast(object); if (child) { removeSpriteFromAtlas(child); diff --git a/cocos2dx/support/data_support/ccCArray.cpp b/cocos2dx/support/data_support/ccCArray.cpp index 95719d711d..8caa2db075 100644 --- a/cocos2dx/support/data_support/ccCArray.cpp +++ b/cocos2dx/support/data_support/ccCArray.cpp @@ -28,11 +28,13 @@ THE SOFTWARE. NS_CC_BEGIN +const int CC_INVALID_INDEX = -1; + /** Allocates and initializes a new array with specified capacity */ -ccArray* ccArrayNew(unsigned int capacity) +ccArray* ccArrayNew(int capacity) { if (capacity == 0) - capacity = 1; + capacity = 7; ccArray *arr = (ccArray*)malloc( sizeof(ccArray) ); arr->num = 0; @@ -66,17 +68,21 @@ void ccArrayDoubleCapacity(ccArray *arr) arr->arr = newArr; } -void ccArrayEnsureExtraCapacity(ccArray *arr, unsigned int extra) +void ccArrayEnsureExtraCapacity(ccArray *arr, int extra) { while (arr->max < arr->num + extra) { +// CCLOG("cocos2d: ccCArray: resizing ccArray capacity from [%lu] to [%lu].", +// (long) arr->max, +// (long) arr->max*2); + ccArrayDoubleCapacity(arr); } } void ccArrayShrink(ccArray *arr) { - unsigned int newSize = 0; + int newSize = 0; //only resize when necessary if (arr->max > arr->num && !(arr->num==0 && arr->max==1)) @@ -98,13 +104,14 @@ void ccArrayShrink(ccArray *arr) } /** Returns index of first occurrence of object, CC_INVALID_INDEX if object not found. */ -unsigned int ccArrayGetIndexOfObject(ccArray *arr, Object* object) +int ccArrayGetIndexOfObject(ccArray *arr, Object* object) { - const unsigned int arrNum = arr->num; + const int arrNum = arr->num; Object** ptr = arr->arr; - for(unsigned int i = 0; i < arrNum; ++i, ++ptr) + for(int i = 0; i < arrNum; ++i, ++ptr) { - if( *ptr == object ) return i; + if( *ptr == object ) + return i; } return CC_INVALID_INDEX; @@ -136,7 +143,7 @@ void ccArrayAppendObjectWithResize(ccArray *arr, Object* object) enough capacity. */ void ccArrayAppendArray(ccArray *arr, ccArray *plusArr) { - for(unsigned int i = 0; i < plusArr->num; i++) + for(int i = 0; i < plusArr->num; i++) { ccArrayAppendObject(arr, plusArr->arr[i]); } @@ -150,14 +157,14 @@ void ccArrayAppendArrayWithResize(ccArray *arr, ccArray *plusArr) } /** Inserts an object at index */ -void ccArrayInsertObjectAtIndex(ccArray *arr, Object* object, unsigned int index) +void ccArrayInsertObjectAtIndex(ccArray *arr, Object* object, int index) { CCASSERT(index<=arr->num, "Invalid index. Out of bounds"); CCASSERT(object != NULL, "Invalid parameter!"); ccArrayEnsureExtraCapacity(arr, 1); - unsigned int remaining = arr->num - index; + int remaining = arr->num - index; if( remaining > 0) { memmove((void *)&arr->arr[index+1], (void *)&arr->arr[index], sizeof(Object*) * remaining ); @@ -169,10 +176,10 @@ void ccArrayInsertObjectAtIndex(ccArray *arr, Object* object, unsigned int index } /** Swaps two objects */ -void ccArraySwapObjectsAtIndexes(ccArray *arr, unsigned int index1, unsigned int index2) +void ccArraySwapObjectsAtIndexes(ccArray *arr, int index1, int index2) { - CCASSERT(index1 < arr->num, "(1) Invalid index. Out of bounds"); - CCASSERT(index2 < arr->num, "(2) Invalid index. Out of bounds"); + CCASSERT(index1>=0 && index1 < arr->num, "(1) Invalid index. Out of bounds"); + CCASSERT(index2>=0 && index2 < arr->num, "(2) Invalid index. Out of bounds"); Object* object1 = arr->arr[index1]; @@ -191,9 +198,9 @@ void ccArrayRemoveAllObjects(ccArray *arr) /** Removes object at specified index and pushes back all subsequent objects. Behavior undefined if index outside [0, num-1]. */ -void ccArrayRemoveObjectAtIndex(ccArray *arr, unsigned int index, bool bReleaseObj/* = true*/) +void ccArrayRemoveObjectAtIndex(ccArray *arr, int index, bool bReleaseObj/* = true*/) { - CCASSERT(arr && arr->num > 0 && index < arr->num, "Invalid index. Out of bounds"); + CCASSERT(arr && arr->num > 0 && index>=0 && index < arr->num, "Invalid index. Out of bounds"); if (bReleaseObj) { CC_SAFE_RELEASE(arr->arr[index]); @@ -201,7 +208,7 @@ void ccArrayRemoveObjectAtIndex(ccArray *arr, unsigned int index, bool bReleaseO arr->num--; - unsigned int remaining = arr->num - index; + int remaining = arr->num - index; if(remaining>0) { memmove((void *)&arr->arr[index], (void *)&arr->arr[index+1], remaining * sizeof(Object*)); @@ -211,16 +218,16 @@ void ccArrayRemoveObjectAtIndex(ccArray *arr, unsigned int index, bool bReleaseO /** Removes object at specified index and fills the gap with the last object, thereby avoiding the need to push back subsequent objects. Behavior undefined if index outside [0, num-1]. */ -void ccArrayFastRemoveObjectAtIndex(ccArray *arr, unsigned int index) +void ccArrayFastRemoveObjectAtIndex(ccArray *arr, int index) { CC_SAFE_RELEASE(arr->arr[index]); - unsigned int last = --arr->num; + int last = --arr->num; arr->arr[index] = arr->arr[last]; } void ccArrayFastRemoveObject(ccArray *arr, Object* object) { - unsigned int index = ccArrayGetIndexOfObject(arr, object); + int index = ccArrayGetIndexOfObject(arr, object); if (index != CC_INVALID_INDEX) { ccArrayFastRemoveObjectAtIndex(arr, index); @@ -231,7 +238,7 @@ void ccArrayFastRemoveObject(ccArray *arr, Object* object) found the function has no effect. */ void ccArrayRemoveObject(ccArray *arr, Object* object, bool bReleaseObj/* = true*/) { - unsigned int index = ccArrayGetIndexOfObject(arr, object); + int index = ccArrayGetIndexOfObject(arr, object); if (index != CC_INVALID_INDEX) { ccArrayRemoveObjectAtIndex(arr, index, bReleaseObj); @@ -242,7 +249,7 @@ void ccArrayRemoveObject(ccArray *arr, Object* object, bool bReleaseObj/* = true first matching instance in arr will be removed. */ void ccArrayRemoveArray(ccArray *arr, ccArray *minusArr) { - for(unsigned int i = 0; i < minusArr->num; i++) + for(int i = 0; i < minusArr->num; i++) { ccArrayRemoveObject(arr, minusArr->arr[i]); } @@ -252,8 +259,8 @@ void ccArrayRemoveArray(ccArray *arr, ccArray *minusArr) matching instances in arr will be removed. */ void ccArrayFullRemoveArray(ccArray *arr, ccArray *minusArr) { - unsigned int back = 0; - unsigned int i = 0; + int back = 0; + int i = 0; for( i = 0; i < arr->num; i++) { @@ -275,11 +282,11 @@ void ccArrayFullRemoveArray(ccArray *arr, ccArray *minusArr) // #pragma mark ccCArray for Values (c structures) /** Allocates and initializes a new C array with specified capacity */ -ccCArray* ccCArrayNew(unsigned int capacity) +ccCArray* ccCArrayNew(int capacity) { if (capacity == 0) { - capacity = 1; + capacity = 7; } ccCArray *arr = (ccCArray*)malloc( sizeof(ccCArray) ); @@ -310,19 +317,18 @@ void ccCArrayDoubleCapacity(ccCArray *arr) } /** Increases array capacity such that max >= num + extra. */ -void ccCArrayEnsureExtraCapacity(ccCArray *arr, unsigned int extra) +void ccCArrayEnsureExtraCapacity(ccCArray *arr, int extra) { ccArrayEnsureExtraCapacity((ccArray*)arr,extra); } /** Returns index of first occurrence of value, CC_INVALID_INDEX if value not found. */ -unsigned int ccCArrayGetIndexOfValue(ccCArray *arr, void* value) +int ccCArrayGetIndexOfValue(ccCArray *arr, void* value) { - unsigned int i; - - for( i = 0; i < arr->num; i++) + for( int i = 0; i < arr->num; i++) { - if( arr->arr[i] == value ) return i; + if( arr->arr[i] == value ) + return i; } return CC_INVALID_INDEX; } @@ -334,11 +340,11 @@ bool ccCArrayContainsValue(ccCArray *arr, void* value) } /** Inserts a value at a certain position. Behavior undefined if array doesn't have enough capacity */ -void ccCArrayInsertValueAtIndex( ccCArray *arr, void* value, unsigned int index) +void ccCArrayInsertValueAtIndex( ccCArray *arr, void* value, int index) { CCASSERT( index < arr->max, "ccCArrayInsertValueAtIndex: invalid index"); - unsigned int remaining = arr->num - index; + int remaining = arr->num - index; // make sure it has enough capacity if (arr->num + 1 == arr->max) { @@ -379,9 +385,7 @@ void ccCArrayAppendValueWithResize(ccCArray *arr, void* value) enough capacity. */ void ccCArrayAppendArray(ccCArray *arr, ccCArray *plusArr) { - unsigned int i; - - for( i = 0; i < plusArr->num; i++) + for( int i = 0; i < plusArr->num; i++) { ccCArrayAppendValue(arr, plusArr->arr[i]); } @@ -404,11 +408,9 @@ void ccCArrayRemoveAllValues(ccCArray *arr) Behavior undefined if index outside [0, num-1]. @since v0.99.4 */ -void ccCArrayRemoveValueAtIndex(ccCArray *arr, unsigned int index) +void ccCArrayRemoveValueAtIndex(ccCArray *arr, int index) { - unsigned int last; - - for( last = --arr->num; index < last; index++) + for( int last = --arr->num; index < last; index++) { arr->arr[index] = arr->arr[index + 1]; } @@ -419,9 +421,9 @@ void ccCArrayRemoveValueAtIndex(ccCArray *arr, unsigned int index) Behavior undefined if index outside [0, num-1]. @since v0.99.4 */ -void ccCArrayFastRemoveValueAtIndex(ccCArray *arr, unsigned int index) +void ccCArrayFastRemoveValueAtIndex(ccCArray *arr, int index) { - unsigned int last = --arr->num; + int last = --arr->num; arr->arr[index] = arr->arr[last]; } @@ -430,7 +432,7 @@ void ccCArrayFastRemoveValueAtIndex(ccCArray *arr, unsigned int index) */ void ccCArrayRemoveValue(ccCArray *arr, void* value) { - unsigned int index = ccCArrayGetIndexOfValue(arr, value); + int index = ccCArrayGetIndexOfValue(arr, value); if (index != CC_INVALID_INDEX) { ccCArrayRemoveValueAtIndex(arr, index); @@ -442,7 +444,7 @@ void ccCArrayRemoveValue(ccCArray *arr, void* value) */ void ccCArrayRemoveArray(ccCArray *arr, ccCArray *minusArr) { - for(unsigned int i = 0; i < minusArr->num; i++) + for(int i = 0; i < minusArr->num; i++) { ccCArrayRemoveValue(arr, minusArr->arr[i]); } @@ -453,9 +455,9 @@ void ccCArrayRemoveArray(ccCArray *arr, ccCArray *minusArr) */ void ccCArrayFullRemoveArray(ccCArray *arr, ccCArray *minusArr) { - unsigned int back = 0; + int back = 0; - for(unsigned int i = 0; i < arr->num; i++) + for(int i = 0; i < arr->num; i++) { if( ccCArrayContainsValue(minusArr, arr->arr[i]) ) { diff --git a/cocos2dx/support/data_support/ccCArray.h b/cocos2dx/support/data_support/ccCArray.h index a2bbe5a010..0a788769d4 100644 --- a/cocos2dx/support/data_support/ccCArray.h +++ b/cocos2dx/support/data_support/ccCArray.h @@ -51,20 +51,20 @@ THE SOFTWARE. NS_CC_BEGIN -#define CC_INVALID_INDEX 0xffffffff +extern const int CC_INVALID_INDEX; // Easy integration #define CCARRAYDATA_FOREACH(__array__, __object__) \ -__object__=__array__->arr[0]; for(unsigned int i=0, num=__array__->num; iarr[i]) \ +__object__=__array__->arr[0]; for(int i=0, num=__array__->num; iarr[i]) \ typedef struct _ccArray { - unsigned int num, max; + int num, max; Object** arr; } ccArray; /** Allocates and initializes a new array with specified capacity */ -ccArray* ccArrayNew(unsigned int capacity); +ccArray* ccArrayNew(int capacity); /** Frees array after removing all remaining objects. Silently ignores nil arr. */ void ccArrayFree(ccArray*& arr); @@ -73,13 +73,13 @@ void ccArrayFree(ccArray*& arr); void ccArrayDoubleCapacity(ccArray *arr); /** Increases array capacity such that max >= num + extra. */ -void ccArrayEnsureExtraCapacity(ccArray *arr, unsigned int extra); +void ccArrayEnsureExtraCapacity(ccArray *arr, int extra); /** shrinks the array so the memory footprint corresponds with the number of items */ void ccArrayShrink(ccArray *arr); /** Returns index of first occurrence of object, NSNotFound if object not found. */ -unsigned int ccArrayGetIndexOfObject(ccArray *arr, Object* object); +int ccArrayGetIndexOfObject(ccArray *arr, Object* object); /** Returns a Boolean value that indicates whether object is present in array. */ bool ccArrayContainsObject(ccArray *arr, Object* object); @@ -98,22 +98,22 @@ void ccArrayAppendArray(ccArray *arr, ccArray *plusArr); void ccArrayAppendArrayWithResize(ccArray *arr, ccArray *plusArr); /** Inserts an object at index */ -void ccArrayInsertObjectAtIndex(ccArray *arr, Object* object, unsigned int index); +void ccArrayInsertObjectAtIndex(ccArray *arr, Object* object, int index); /** Swaps two objects */ -void ccArraySwapObjectsAtIndexes(ccArray *arr, unsigned int index1, unsigned int index2); +void ccArraySwapObjectsAtIndexes(ccArray *arr, int index1, int index2); /** Removes all objects from arr */ void ccArrayRemoveAllObjects(ccArray *arr); /** Removes object at specified index and pushes back all subsequent objects. Behavior undefined if index outside [0, num-1]. */ -void ccArrayRemoveObjectAtIndex(ccArray *arr, unsigned int index, bool bReleaseObj = true); +void ccArrayRemoveObjectAtIndex(ccArray *arr, int index, bool bReleaseObj = true); /** Removes object at specified index and fills the gap with the last object, thereby avoiding the need to push back subsequent objects. Behavior undefined if index outside [0, num-1]. */ -void ccArrayFastRemoveObjectAtIndex(ccArray *arr, unsigned int index); +void ccArrayFastRemoveObjectAtIndex(ccArray *arr, int index); void ccArrayFastRemoveObject(ccArray *arr, Object* object); @@ -133,12 +133,12 @@ void ccArrayFullRemoveArray(ccArray *arr, ccArray *minusArr); // #pragma mark ccCArray for Values (c structures) typedef struct _ccCArray { - unsigned int num, max; + int num, max; void** arr; } ccCArray; /** Allocates and initializes a new C array with specified capacity */ -ccCArray* ccCArrayNew(unsigned int capacity); +ccCArray* ccCArrayNew(int capacity); /** Frees C array after removing all remaining values. Silently ignores nil arr. */ void ccCArrayFree(ccCArray *arr); @@ -147,16 +147,16 @@ void ccCArrayFree(ccCArray *arr); void ccCArrayDoubleCapacity(ccCArray *arr); /** Increases array capacity such that max >= num + extra. */ -void ccCArrayEnsureExtraCapacity(ccCArray *arr, unsigned int extra); +void ccCArrayEnsureExtraCapacity(ccCArray *arr, int extra); /** Returns index of first occurrence of value, NSNotFound if value not found. */ -unsigned int ccCArrayGetIndexOfValue(ccCArray *arr, void* value); +int ccCArrayGetIndexOfValue(ccCArray *arr, void* value); /** Returns a Boolean value that indicates whether value is present in the C array. */ bool ccCArrayContainsValue(ccCArray *arr, void* value); /** Inserts a value at a certain position. Behavior undefined if array doesn't have enough capacity */ -void ccCArrayInsertValueAtIndex( ccCArray *arr, void* value, unsigned int index); +void ccCArrayInsertValueAtIndex( ccCArray *arr, void* value, int index); /** Appends an value. Behavior undefined if array doesn't have enough capacity. */ void ccCArrayAppendValue(ccCArray *arr, void* value); @@ -178,14 +178,14 @@ void ccCArrayRemoveAllValues(ccCArray *arr); Behavior undefined if index outside [0, num-1]. @since v0.99.4 */ -void ccCArrayRemoveValueAtIndex(ccCArray *arr, unsigned int index); +void ccCArrayRemoveValueAtIndex(ccCArray *arr, int index); /** Removes value at specified index and fills the gap with the last value, thereby avoiding the need to push back subsequent values. Behavior undefined if index outside [0, num-1]. @since v0.99.4 */ -void ccCArrayFastRemoveValueAtIndex(ccCArray *arr, unsigned int index); +void ccCArrayFastRemoveValueAtIndex(ccCArray *arr, int index); /** Searches for the first occurrence of value and removes it. If value is not found the function has no effect. @since v0.99.4 From 0093263c1838e21c0693a40c07e54e63a25a63a1 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Mon, 26 Aug 2013 18:08:21 -0700 Subject: [PATCH 105/126] Little performance improvements Uses `AffineTransform::IDENTITY` Signed-off-by: Ricardo Quesada --- extensions/GUI/CCControlExtension/CCScale9Sprite.cpp | 4 ++-- .../Cpp/TestCpp/Classes/ClippingNodeTest/ClippingNodeTest.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp b/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp index a086e475b5..311f51748b 100644 --- a/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp +++ b/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp @@ -225,7 +225,7 @@ bool Scale9Sprite::updateWithBatchNode(SpriteBatchNode* batchnode, Rect rect, bo if (!rotated) { // log("!rotated"); - AffineTransform t = AffineTransformMakeIdentity(); + AffineTransform t = AffineTransform::IDENTITY; t = AffineTransformTranslate(t, rect.origin.x, rect.origin.y); centerbounds = RectApplyAffineTransform(centerbounds, t); @@ -288,7 +288,7 @@ bool Scale9Sprite::updateWithBatchNode(SpriteBatchNode* batchnode, Rect rect, bo // in the spritesheet // log("rotated"); - AffineTransform t = AffineTransformMakeIdentity(); + AffineTransform t = AffineTransform::IDENTITY; Rect rotatedcenterbounds = centerbounds; Rect rotatedrightbottombounds = rightbottombounds; diff --git a/samples/Cpp/TestCpp/Classes/ClippingNodeTest/ClippingNodeTest.cpp b/samples/Cpp/TestCpp/Classes/ClippingNodeTest/ClippingNodeTest.cpp index 777b855300..292af7cac7 100644 --- a/samples/Cpp/TestCpp/Classes/ClippingNodeTest/ClippingNodeTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ClippingNodeTest/ClippingNodeTest.cpp @@ -419,7 +419,7 @@ void HoleDemo::setup() _outerClipper = ClippingNode::create(); _outerClipper->retain(); - AffineTransform tranform = AffineTransformMakeIdentity(); + AffineTransform tranform = AffineTransform::IDENTITY; tranform = AffineTransformScale(tranform, target->getScale(), target->getScale()); _outerClipper->setContentSize( SizeApplyAffineTransform(target->getContentSize(), tranform)); From 48ef1f24c3898a588cd85ccf32fb5ccf5ad8b47a Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Mon, 26 Aug 2013 18:08:56 -0700 Subject: [PATCH 106/126] fixes possible crash when using `SpriteFrameCache` the returned dictionary was double-released. ouch. Signed-off-by: Ricardo Quesada --- cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp b/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp index ddf235c933..93e7b44e05 100644 --- a/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp @@ -209,8 +209,6 @@ void SpriteFrameCache::addSpriteFramesWithFile(const char *pszPlist, Texture2D * Dictionary *dict = Dictionary::createWithContentsOfFileThreadSafe(fullPath.c_str()); addSpriteFramesWithDictionary(dict, pobTexture); - - dict->release(); } void SpriteFrameCache::addSpriteFramesWithFile(const char* plist, const char* textureFileName) @@ -239,7 +237,7 @@ void SpriteFrameCache::addSpriteFramesWithFile(const char *pszPlist) string texturePath(""); - Dictionary* metadataDict = (Dictionary*)dict->objectForKey("metadata"); + Dictionary* metadataDict = static_cast( dict->objectForKey("metadata") ); if (metadataDict) { // try to read texture file name from meta data @@ -277,10 +275,7 @@ void SpriteFrameCache::addSpriteFramesWithFile(const char *pszPlist) { CCLOG("cocos2d: SpriteFrameCache: Couldn't load texture"); } - - dict->release(); } - } void SpriteFrameCache::addSpriteFrame(SpriteFrame *pobFrame, const char *pszFrameName) @@ -356,8 +351,6 @@ void SpriteFrameCache::removeSpriteFramesFromFile(const char* plist) { _loadedFileNames->erase(ret); } - - dict->release(); } void SpriteFrameCache::removeSpriteFramesFromDictionary(Dictionary* dictionary) From 514967dedc21829f6c81a47d085a1ce63a5267f4 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Tue, 27 Aug 2013 06:16:39 +0000 Subject: [PATCH 107/126] [AUTO] : updating submodule reference to latest autogenerated bindings --- scripting/javascript/bindings/generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripting/javascript/bindings/generated b/scripting/javascript/bindings/generated index 5b4a4c5b94..2210cee9be 160000 --- a/scripting/javascript/bindings/generated +++ b/scripting/javascript/bindings/generated @@ -1 +1 @@ -Subproject commit 5b4a4c5b94ba4920a70900d47246612adcdc0ac5 +Subproject commit 2210cee9be0c65daf3a1f02566e0f131728bce23 From 43a022526701f17274450896971b7c34feda069d Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 27 Aug 2013 14:45:19 +0800 Subject: [PATCH 108/126] issue #2732: Deleting tolua/userconf.ini --- tools/tolua/userconf.ini | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 tools/tolua/userconf.ini diff --git a/tools/tolua/userconf.ini b/tools/tolua/userconf.ini deleted file mode 100644 index 8282d99b56..0000000000 --- a/tools/tolua/userconf.ini +++ /dev/null @@ -1,7 +0,0 @@ -[DEFAULT] -androidndkdir=/Users/cocos2d/MyWork/android/android-ndk-r8e -clangllvmdir=/Users/cocos2d/bin/clang+llvm-3.3 -cocosdir=/Users/cocos2d/MyWork/cocos2d-x -cxxgeneratordir=/Users/cocos2d/MyWork/cocos2d-x/tools/bindings-generator -extra_flags= - From c2099f5d3e0a63fe9da1cd0a4c0127ca4cc633da Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 27 Aug 2013 14:50:53 +0800 Subject: [PATCH 109/126] issue #2732: Moving 'scripting/javascript/bindings/generated' to 'scripting/auto-generated'. --- .gitmodules | 2 +- scripting/{javascript/bindings/generated => auto-generated} | 0 tools/tojs/genbindings.sh | 4 ++-- tools/tolua/genbindings.sh | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) rename scripting/{javascript/bindings/generated => auto-generated} (100%) diff --git a/.gitmodules b/.gitmodules index b781dad207..300f48de0d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -2,7 +2,7 @@ path = tools/bindings-generator url = git://github.com/cocos2d/bindings-generator.git [submodule "scripting/javascript/bindings/generated"] - path = scripting/javascript/bindings/generated + path = scripting/auto-generated url = git://github.com/folecr/cocos2dx-autogen-bindings.git [submodule "samples/Javascript/Shared"] path = samples/Javascript/Shared diff --git a/scripting/javascript/bindings/generated b/scripting/auto-generated similarity index 100% rename from scripting/javascript/bindings/generated rename to scripting/auto-generated diff --git a/tools/tojs/genbindings.sh b/tools/tojs/genbindings.sh index 17c02f8606..8801c65d1f 100755 --- a/tools/tojs/genbindings.sh +++ b/tools/tojs/genbindings.sh @@ -80,7 +80,7 @@ echo --- # Generate bindings for cocos2dx echo "Generating bindings for cocos2dx..." set -x -LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx.ini -s cocos2d-x -t spidermonkey -o ${COCOS2DX_ROOT}/scripting/javascript/bindings/generated -n jsb_cocos2dx_auto +LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx.ini -s cocos2d-x -t spidermonkey -o ${COCOS2DX_ROOT}/scripting/auto-generated/js-bindings -n jsb_cocos2dx_auto echo "Generating bindings for cocos2dx_extension..." -LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx_extension.ini -s cocos2dx_extension -t spidermonkey -o ${COCOS2DX_ROOT}/scripting/javascript/bindings/generated -n jsb_cocos2dx_extension_auto +LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx_extension.ini -s cocos2dx_extension -t spidermonkey -o ${COCOS2DX_ROOT}/scripting/auto-generated/js-bindings -n jsb_cocos2dx_extension_auto diff --git a/tools/tolua/genbindings.sh b/tools/tolua/genbindings.sh index 2a0a3759a3..ba6033c7fc 100755 --- a/tools/tolua/genbindings.sh +++ b/tools/tolua/genbindings.sh @@ -80,7 +80,7 @@ echo --- # Generate bindings for cocos2dx echo "Generating bindings for cocos2dx..." set -x -LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx.ini -s cocos2d-x -t lua -o ${COCOS2DX_ROOT}/scripting/lua/cocos2dx_support/generated -n lua_cocos2dx_auto +LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx.ini -s cocos2d-x -t lua -o ${COCOS2DX_ROOT}/scripting/auto-generated/lua-bindings -n lua_cocos2dx_auto echo "Generating bindings for cocos2dx_extension..." -LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx_extension.ini -s cocos2dx_extension -t lua -o ${COCOS2DX_ROOT}/scripting/lua/cocos2dx_support/generated -n lua_cocos2dx_extension_auto +LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx_extension.ini -s cocos2dx_extension -t lua -o ${COCOS2DX_ROOT}/scripting/auto-generated/lua-bindings -n lua_cocos2dx_extension_auto From 7552a725778a35462e9fa30640aa8e95abc4c2be Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 27 Aug 2013 16:05:48 +0800 Subject: [PATCH 110/126] issue #2732: [iOS] Updating the reference of auto-generated binding glue codes. --- .../project.pbxproj.REMOVED.git-id | 2 +- .../HelloAnalytics-JS/Classes/AppDelegate.cpp | 4 +- .../HelloIAP-JS/Classes/AppDelegate.cpp | 4 +- .../AssetsManagerTest/Classes/AppDelegate.cpp | 2 +- .../CocosDragonJS/Classes/AppDelegate.cpp | 4 +- .../CrystalCraze/Classes/AppDelegate.cpp | 4 +- .../MoonWarriors/Classes/AppDelegate.cpp | 4 +- .../TestJavascript/Classes/AppDelegate.cpp | 4 +- .../WatermelonWithMe/Classes/AppDelegate.cpp | 4 +- .../project.pbxproj.REMOVED.git-id | 2 +- .../cocos2d_specifics.cpp.REMOVED.git-id | 2 +- .../multi-platform-js/Classes/AppDelegate.cpp | 4 +- tools/travis-scripts/generate-jsbindings.sh | 38 ++++++++++++------- 13 files changed, 44 insertions(+), 34 deletions(-) diff --git a/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id b/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id index 116f89b47f..89ce949321 100644 --- a/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -027d1d69c91552623e04c46fd002c5976c4bb40c \ No newline at end of file +9bf893fd31bf044ec732332fb109c050b711fdc8 \ No newline at end of file diff --git a/plugin/samples/HelloAnalytics-JS/Classes/AppDelegate.cpp b/plugin/samples/HelloAnalytics-JS/Classes/AppDelegate.cpp index 2e5330a1b8..f11764c513 100644 --- a/plugin/samples/HelloAnalytics-JS/Classes/AppDelegate.cpp +++ b/plugin/samples/HelloAnalytics-JS/Classes/AppDelegate.cpp @@ -3,8 +3,8 @@ #include "cocos2d.h" #include "SimpleAudioEngine.h" #include "ScriptingCore.h" -#include "generated/jsb_cocos2dx_auto.hpp" -#include "generated/jsb_cocos2dx_extension_auto.hpp" +#include "jsb_cocos2dx_auto.hpp" +#include "jsb_cocos2dx_extension_auto.hpp" #include "cocos2d_specifics.hpp" #include "js_bindings_chipmunk_registration.h" #include "js_bindings_system_registration.h" diff --git a/plugin/samples/HelloIAP-JS/Classes/AppDelegate.cpp b/plugin/samples/HelloIAP-JS/Classes/AppDelegate.cpp index f3005181cb..d2b993e889 100644 --- a/plugin/samples/HelloIAP-JS/Classes/AppDelegate.cpp +++ b/plugin/samples/HelloIAP-JS/Classes/AppDelegate.cpp @@ -3,8 +3,8 @@ #include "cocos2d.h" #include "SimpleAudioEngine.h" #include "ScriptingCore.h" -#include "generated/jsb_cocos2dx_auto.hpp" -#include "generated/jsb_cocos2dx_extension_auto.hpp" +#include "jsb_cocos2dx_auto.hpp" +#include "jsb_cocos2dx_extension_auto.hpp" #include "cocos2d_specifics.hpp" #include "js_bindings_chipmunk_registration.h" #include "js_bindings_system_registration.h" diff --git a/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.cpp b/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.cpp index 3e222e6bf6..6d34e0ef82 100644 --- a/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.cpp +++ b/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.cpp @@ -8,7 +8,7 @@ #include "cocos2d.h" #include "SimpleAudioEngine.h" #include "ScriptingCore.h" -#include "generated/jsb_cocos2dx_auto.hpp" +#include "jsb_cocos2dx_auto.hpp" #include "cocos2d_specifics.hpp" #if (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32) diff --git a/samples/Javascript/CocosDragonJS/Classes/AppDelegate.cpp b/samples/Javascript/CocosDragonJS/Classes/AppDelegate.cpp index 670d57a92b..da5a5d6dc7 100644 --- a/samples/Javascript/CocosDragonJS/Classes/AppDelegate.cpp +++ b/samples/Javascript/CocosDragonJS/Classes/AppDelegate.cpp @@ -6,8 +6,8 @@ #include "cocos2d.h" #include "SimpleAudioEngine.h" #include "ScriptingCore.h" -#include "generated/jsb_cocos2dx_auto.hpp" -#include "generated/jsb_cocos2dx_extension_auto.hpp" +#include "jsb_cocos2dx_auto.hpp" +#include "jsb_cocos2dx_extension_auto.hpp" #include "jsb_cocos2dx_extension_manual.h" #include "cocos2d_specifics.hpp" #include "js_bindings_ccbreader.h" diff --git a/samples/Javascript/CrystalCraze/Classes/AppDelegate.cpp b/samples/Javascript/CrystalCraze/Classes/AppDelegate.cpp index ec958730ba..246f022d4c 100644 --- a/samples/Javascript/CrystalCraze/Classes/AppDelegate.cpp +++ b/samples/Javascript/CrystalCraze/Classes/AppDelegate.cpp @@ -3,8 +3,8 @@ #include "cocos2d.h" #include "SimpleAudioEngine.h" #include "ScriptingCore.h" -#include "generated/jsb_cocos2dx_auto.hpp" -#include "generated/jsb_cocos2dx_extension_auto.hpp" +#include "jsb_cocos2dx_auto.hpp" +#include "jsb_cocos2dx_extension_auto.hpp" #include "jsb_cocos2dx_extension_manual.h" #include "cocos2d_specifics.hpp" #include "js_bindings_ccbreader.h" diff --git a/samples/Javascript/MoonWarriors/Classes/AppDelegate.cpp b/samples/Javascript/MoonWarriors/Classes/AppDelegate.cpp index 0932e12b27..93dc35d856 100644 --- a/samples/Javascript/MoonWarriors/Classes/AppDelegate.cpp +++ b/samples/Javascript/MoonWarriors/Classes/AppDelegate.cpp @@ -3,8 +3,8 @@ #include "cocos2d.h" #include "SimpleAudioEngine.h" #include "ScriptingCore.h" -#include "generated/jsb_cocos2dx_auto.hpp" -#include "generated/jsb_cocos2dx_extension_auto.hpp" +#include "jsb_cocos2dx_auto.hpp" +#include "jsb_cocos2dx_extension_auto.hpp" #include "jsb_cocos2dx_extension_manual.h" #include "cocos2d_specifics.hpp" #include "js_bindings_ccbreader.h" diff --git a/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp b/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp index 69d9cb6b60..4b7b6c87ff 100644 --- a/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp +++ b/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp @@ -3,8 +3,8 @@ #include "cocos2d.h" #include "SimpleAudioEngine.h" #include "ScriptingCore.h" -#include "generated/jsb_cocos2dx_auto.hpp" -#include "generated/jsb_cocos2dx_extension_auto.hpp" +#include "jsb_cocos2dx_auto.hpp" +#include "jsb_cocos2dx_extension_auto.hpp" #include "jsb_cocos2dx_extension_manual.h" #include "cocos2d_specifics.hpp" #include "js_bindings_chipmunk_registration.h" diff --git a/samples/Javascript/WatermelonWithMe/Classes/AppDelegate.cpp b/samples/Javascript/WatermelonWithMe/Classes/AppDelegate.cpp index 3364e34c12..c0878b49e0 100644 --- a/samples/Javascript/WatermelonWithMe/Classes/AppDelegate.cpp +++ b/samples/Javascript/WatermelonWithMe/Classes/AppDelegate.cpp @@ -3,8 +3,8 @@ #include "cocos2d.h" #include "SimpleAudioEngine.h" #include "ScriptingCore.h" -#include "generated/jsb_cocos2dx_auto.hpp" -#include "generated/jsb_cocos2dx_extension_auto.hpp" +#include "jsb_cocos2dx_auto.hpp" +#include "jsb_cocos2dx_extension_auto.hpp" #include "jsb_cocos2dx_extension_manual.h" #include "cocos2d_specifics.hpp" #include "js_bindings_chipmunk_registration.h" diff --git a/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id b/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id index e3b14635f1..1e5160fb00 100644 --- a/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -10b7b9eb9dd50e4480e377538b5a1fa7261b9029 \ No newline at end of file +01ccea588d07b1419922fb6fd66502422184c2bd \ No newline at end of file diff --git a/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id b/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id index dbf188c465..a1179d6b16 100644 --- a/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id +++ b/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id @@ -1 +1 @@ -d4944c285d6219a01aa06f326168ae67d08b9cb0 \ No newline at end of file +1a67569d3ade0153cccbfa71ca5ac5355d03fbd4 \ No newline at end of file diff --git a/template/multi-platform-js/Classes/AppDelegate.cpp b/template/multi-platform-js/Classes/AppDelegate.cpp index f086f7b889..ec78d9f5ae 100644 --- a/template/multi-platform-js/Classes/AppDelegate.cpp +++ b/template/multi-platform-js/Classes/AppDelegate.cpp @@ -3,8 +3,8 @@ #include "cocos2d.h" #include "SimpleAudioEngine.h" #include "ScriptingCore.h" -#include "generated/jsb_cocos2dx_auto.hpp" -#include "generated/jsb_cocos2dx_extension_auto.hpp" +#include "jsb_cocos2dx_auto.hpp" +#include "jsb_cocos2dx_extension_auto.hpp" #include "jsb_cocos2dx_extension_manual.h" #include "cocos2d_specifics.hpp" #include "js_bindings_chipmunk_registration.h" diff --git a/tools/travis-scripts/generate-jsbindings.sh b/tools/travis-scripts/generate-jsbindings.sh index ffc59702fe..2a1dd3b69a 100755 --- a/tools/travis-scripts/generate-jsbindings.sh +++ b/tools/travis-scripts/generate-jsbindings.sh @@ -1,6 +1,6 @@ #!/bin/bash -# Generate JS bindings for Cocos2D-X +# Generate JS and Lua bindings for Cocos2D-X # ... using Android NDK system headers # ... and automatically update submodule references # ... and push these changes to remote repos @@ -8,7 +8,7 @@ # Dependencies # # For bindings generator: -# (see ../../../tojs/genbindings.sh +# (see ../../../tojs/genbindings.sh and ../../../tolua/genbindings.sh # ... for the defaults used if the environment is not customized) # # * $PYTHON_BIN @@ -19,7 +19,8 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" COCOS2DX_ROOT="$DIR"/../.. TOJS_ROOT=$COCOS2DX_ROOT/tools/tojs -GENERATED_WORKTREE="$COCOS2DX_ROOT"/scripting/javascript/bindings/generated +TOLUA_ROOT=$COCOS2DX_ROOT/tools/tolua +GENERATED_WORKTREE="$COCOS2DX_ROOT"/scripting/auto-generated COMMITTAG="[AUTO]" # Exit on error @@ -42,10 +43,21 @@ else sudo apt-get --force-yes --yes install python-yaml python-cheetah fi -if [ "$GEN_JSB"x != "YES"x ]; then +generate_bindings_glue_codes() +{ + echo "Create auto-generated jsbinding glue codes." pushd "$TOJS_ROOT" ./genbindings.sh popd + + echo "Create auto-generated luabinding glue codes." + pushd "$TOLUA_ROOT" + ./genbindings.sh + popd +} + +if [ "$GEN_JSB"x != "YES"x ]; then + generate_bindings_glue_codes exit 0 fi @@ -55,11 +67,11 @@ git config user.email ${GH_EMAIL} git config user.name ${GH_USER} popd -# Update submodule of auto-gen JSBinding repo. +# Update submodule of auto-gen Binding repo. pushd "$GENERATED_WORKTREE" git checkout -B master -#Set git user for the submodule of 'scripting/javascript/bindings/generated' +echo "Set git user for the submodule of ${GENERATED_WORKTREE}" git config user.email ${GH_EMAIL} git config user.name ${GH_USER} #Set remotes @@ -67,16 +79,14 @@ git remote add upstream https://${GH_USER}:${GH_PASSWORD}@github.com/folecr/coco echo "Delete all directories and files except '.git' and 'README'." ls -a | grep -E -v ^\[.\]\{1,2\}$ | grep -E -v ^\.git$ | grep -E -v ^README$ | xargs -I{} rm -rf {} -echo "Show files in scripting/javascript/bindings/generated folder." +echo "Show files in ${GENERATED_WORKTREE} folder." ls -a popd # 1. Generate JS bindings -pushd "$TOJS_ROOT" -./genbindings.sh -popd +generate_bindings_glue_codes echo echo Bindings generated successfully @@ -98,7 +108,7 @@ echo Using "$ELAPSEDSECS" in the branch names for pseudo-uniqueness GENERATED_BRANCH=autogeneratedbindings_"$ELAPSEDSECS" -# 2. In JSBindings repo, Check if there are any files that are different from the index +# 2. In Bindings repo, Check if there are any files that are different from the index pushd "$GENERATED_WORKTREE" @@ -130,13 +140,13 @@ fi # Exit on error set -e -# 3. In JSBindings repo, Check out a branch named "autogeneratedbindings" and commit the auto generated bindings to it +# 3. In Bindings repo, Check out a branch named "autogeneratedbindings" and commit the auto generated bindings to it git checkout -b "$GENERATED_BRANCH" git add --verbose . git add --verbose -u . git commit --verbose -m "$COMMITTAG : autogenerated bindings" -# 4. In JSBindings repo, Push the commit with generated bindings to "master" of the auto generated bindings repository +# 4. In Bindings repo, Push the commit with generated bindings to "master" of the auto generated bindings repository git push -fq upstream "$GENERATED_BRANCH":${TRAVIS_BRANCH}_${ELAPSEDSECS} 2> /dev/null popd @@ -148,7 +158,7 @@ pushd "${DIR}" # 5. In Cocos2D-X repo, Checkout a branch named "updategeneratedsubmodule" Update the submodule reference to point to the commit with generated bindings cd "${COCOS2DX_ROOT}" -git add scripting/javascript/bindings/generated +git add ${GENERATED_WORKTREE} git checkout -b "$COCOS_BRANCH" git commit -m "$COMMITTAG : updating submodule reference to latest autogenerated bindings" #Set remotes From 7bc1a01f18052a19b0e7f421c9f5a4b5364d4e6e Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 27 Aug 2013 16:20:13 +0800 Subject: [PATCH 111/126] issue #2732: Removing "scripting/lua/cocos2dx_support/generated" folder. --- .../lua_cocos2dx_auto.cpp.REMOVED.git-id | 1 - .../generated/lua_cocos2dx_auto.hpp | 2072 -------------- .../lua_cocos2dx_auto_api.js.REMOVED.git-id | 1 - ...cocos2dx_extension_auto.cpp.REMOVED.git-id | 1 - .../generated/lua_cocos2dx_extension_auto.hpp | 406 --- .../lua_cocos2dx_extension_auto_api.js | 2394 ----------------- 6 files changed, 4875 deletions(-) delete mode 100644 scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id delete mode 100644 scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.hpp delete mode 100644 scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id delete mode 100644 scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id delete mode 100644 scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.hpp delete mode 100644 scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto_api.js diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id deleted file mode 100644 index ba456b9a2d..0000000000 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.cpp.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -90eec5befefca388a591c3cf8dc10950588cec15 \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.hpp b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.hpp deleted file mode 100644 index 5dcc6b742c..0000000000 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto.hpp +++ /dev/null @@ -1,2072 +0,0 @@ -#ifndef __cocos2dx_h__ -#define __cocos2dx_h__ - -#ifdef __cplusplus -extern "C" { -#endif -#include "tolua++.h" -#ifdef __cplusplus -} -#endif - -int register_all_cocos2dx(lua_State* tolua_S); - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -#endif // __cocos2dx_h__ diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id deleted file mode 100644 index 9fa10a1d50..0000000000 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_auto_api.js.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -bc27ec5b64be9ac5530fd15fcc22cd8832504685 \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id deleted file mode 100644 index 40c1f53607..0000000000 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -0389c415199783d5bbcc1ee8882cc01220bc37f6 \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.hpp b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.hpp deleted file mode 100644 index a91e44ecea..0000000000 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto.hpp +++ /dev/null @@ -1,406 +0,0 @@ -#ifndef __cocos2dx_extension_h__ -#define __cocos2dx_extension_h__ - -#ifdef __cplusplus -extern "C" { -#endif -#include "tolua++.h" -#ifdef __cplusplus -} -#endif - -int register_all_cocos2dx_extension(lua_State* tolua_S); - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -#endif // __cocos2dx_extension_h__ diff --git a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto_api.js b/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto_api.js deleted file mode 100644 index 5d80c436a6..0000000000 --- a/scripting/lua/cocos2dx_support/generated/lua_cocos2dx_extension_auto_api.js +++ /dev/null @@ -1,2394 +0,0 @@ -/** - * @module cocos2dx_extension - */ -var cc = cc || {}; - -/** - * @class Control - */ -cc.Control = { - -/** - * @method setEnabled - * @param {bool} - */ -setEnabled : function () {}, - -/** - * @method getState - * @return A value converted from C/C++ "cocos2d::extension::Control::State" - */ -getState : function () {}, - -/** - * @method isTouchInside - * @return A value converted from C/C++ "bool" - * @param {cocos2d::Touch*} - */ -isTouchInside : function () {}, - -/** - * @method sendActionsForControlEvents - * @param {cocos2d::extension::Control::EventType} - */ -sendActionsForControlEvents : function () {}, - -/** - * @method setSelected - * @param {bool} - */ -setSelected : function () {}, - -/** - * @method registerWithTouchDispatcher - */ -registerWithTouchDispatcher : function () {}, - -/** - * @method isEnabled - * @return A value converted from C/C++ "bool" - */ -isEnabled : function () {}, - -/** - * @method setOpacityModifyRGB - * @param {bool} - */ -setOpacityModifyRGB : function () {}, - -/** - * @method needsLayout - */ -needsLayout : function () {}, - -/** - * @method hasVisibleParents - * @return A value converted from C/C++ "bool" - */ -hasVisibleParents : function () {}, - -/** - * @method isSelected - * @return A value converted from C/C++ "bool" - */ -isSelected : function () {}, - -/** - * @method init - * @return A value converted from C/C++ "bool" - */ -init : function () {}, - -/** - * @method setHighlighted - * @param {bool} - */ -setHighlighted : function () {}, - -/** - * @method isOpacityModifyRGB - * @return A value converted from C/C++ "bool" - */ -isOpacityModifyRGB : function () {}, - -/** - * @method getTouchLocation - * @return A value converted from C/C++ "cocos2d::Point" - * @param {cocos2d::Touch*} - */ -getTouchLocation : function () {}, - -/** - * @method isHighlighted - * @return A value converted from C/C++ "bool" - */ -isHighlighted : function () {}, - -/** - * @method create - * @return A value converted from C/C++ "cocos2d::extension::Control*" - */ -create : function () {}, - -/** - * @method Control - * @constructor - */ -Control : function () {}, - -}; - -/** - * @class CCBReader - */ -cc._Reader = { - -/** - * @method addOwnerOutletName - * @param {std::string} - */ -addOwnerOutletName : function () {}, - -/** - * @method getOwnerCallbackNames - * @return A value converted from C/C++ "cocos2d::Array*" - */ -getOwnerCallbackNames : function () {}, - -/** - * @method addDocumentCallbackControlEvents - * @param {cocos2d::extension::Control::EventType} - */ -addDocumentCallbackControlEvents : function () {}, - -/** - * @method setCCBRootPath - * @param {const char*} - */ -setCCBRootPath : function () {}, - -/** - * @method addOwnerOutletNode - * @param {cocos2d::Node*} - */ -addOwnerOutletNode : function () {}, - -/** - * @method getOwnerCallbackNodes - * @return A value converted from C/C++ "cocos2d::Array*" - */ -getOwnerCallbackNodes : function () {}, - -/** - * @method readSoundKeyframesForSeq - * @return A value converted from C/C++ "bool" - * @param {cocos2d::extension::CCBSequence*} - */ -readSoundKeyframesForSeq : function () {}, - -/** - * @method getCCBRootPath - * @return A value converted from C/C++ "std::string" - */ -getCCBRootPath : function () {}, - -/** - * @method getOwnerCallbackControlEvents - * @return A value converted from C/C++ "cocos2d::Array*" - */ -getOwnerCallbackControlEvents : function () {}, - -/** - * @method getOwnerOutletNodes - * @return A value converted from C/C++ "cocos2d::Array*" - */ -getOwnerOutletNodes : function () {}, - -/** - * @method readUTF8 - * @return A value converted from C/C++ "std::string" - */ -readUTF8 : function () {}, - -/** - * @method addOwnerCallbackControlEvents - * @param {cocos2d::extension::Control::EventType} - */ -addOwnerCallbackControlEvents : function () {}, - -/** - * @method getOwnerOutletNames - * @return A value converted from C/C++ "cocos2d::Array*" - */ -getOwnerOutletNames : function () {}, - -/** - * @method setAnimationManager - * @param {cocos2d::extension::CCBAnimationManager*} - */ -setAnimationManager : function () {}, - -/** - * @method readCallbackKeyframesForSeq - * @return A value converted from C/C++ "bool" - * @param {cocos2d::extension::CCBSequence*} - */ -readCallbackKeyframesForSeq : function () {}, - -/** - * @method getAnimationManagersForNodes - * @return A value converted from C/C++ "cocos2d::Array*" - */ -getAnimationManagersForNodes : function () {}, - -/** - * @method getNodesWithAnimationManagers - * @return A value converted from C/C++ "cocos2d::Array*" - */ -getNodesWithAnimationManagers : function () {}, - -/** - * @method getAnimationManager - * @return A value converted from C/C++ "cocos2d::extension::CCBAnimationManager*" - */ -getAnimationManager : function () {}, - -/** - * @method setResolutionScale - * @param {float} - */ -setResolutionScale : function () {}, - -}; - -/** - * @class Scale9Sprite - */ -cc.Scale9Sprite = { - -/** - * @method resizableSpriteWithCapInsets - * @return A value converted from C/C++ "cocos2d::extension::Scale9Sprite*" - * @param {cocos2d::Rect} - */ -resizableSpriteWithCapInsets : function () {}, - -/** - * @method setOpacityModifyRGB - * @param {bool} - */ -setOpacityModifyRGB : function () {}, - -/** - * @method setContentSize - * @param {cocos2d::Size} - */ -setContentSize : function () {}, - -/** - * @method setInsetBottom - * @param {float} - */ -setInsetBottom : function () {}, - -/** - * @method isOpacityModifyRGB - * @return A value converted from C/C++ "bool" - */ -isOpacityModifyRGB : function () {}, - -/** - * @method setOpacity - * @param {unsigned char} - */ -setOpacity : function () {}, - -/** - * @method setInsetTop - * @param {float} - */ -setInsetTop : function () {}, - -/** - * @method updateDisplayedOpacity - * @param {unsigned char} - */ -updateDisplayedOpacity : function () {}, - -/** - * @method init - * @return A value converted from C/C++ "bool" - */ -init : function () {}, - -/** - * @method setPreferredSize - * @param {cocos2d::Size} - */ -setPreferredSize : function () {}, - -/** - * @method getOpacity - * @return A value converted from C/C++ "unsigned char" - */ -getOpacity : function () {}, - -/** - * @method setSpriteFrame - * @param {cocos2d::SpriteFrame*} - */ -setSpriteFrame : function () {}, - -/** - * @method getColor - * @return A value converted from C/C++ "cocos2d::Color3B" - */ -getColor : function () {}, - -/** - * @method getInsetBottom - * @return A value converted from C/C++ "float" - */ -getInsetBottom : function () {}, - -/** - * @method getCapInsets - * @return A value converted from C/C++ "cocos2d::Rect" - */ -getCapInsets : function () {}, - -/** - * @method updateWithBatchNode - * @return A value converted from C/C++ "bool" - * @param {cocos2d::SpriteBatchNode*} - * @param {cocos2d::Rect} - * @param {bool} - * @param {cocos2d::Rect} - */ -updateWithBatchNode : function () {}, - -/** - * @method getInsetRight - * @return A value converted from C/C++ "float" - */ -getInsetRight : function () {}, - -/** - * @method getOriginalSize - * @return A value converted from C/C++ "cocos2d::Size" - */ -getOriginalSize : function () {}, - -/** - * @method setColor - * @param {cocos2d::Color3B} - */ -setColor : function () {}, - -/** - * @method getInsetTop - * @return A value converted from C/C++ "float" - */ -getInsetTop : function () {}, - -/** - * @method setInsetLeft - * @param {float} - */ -setInsetLeft : function () {}, - -/** - * @method getPreferredSize - * @return A value converted from C/C++ "cocos2d::Size" - */ -getPreferredSize : function () {}, - -/** - * @method setCapInsets - * @param {cocos2d::Rect} - */ -setCapInsets : function () {}, - -/** - * @method getInsetLeft - * @return A value converted from C/C++ "float" - */ -getInsetLeft : function () {}, - -/** - * @method updateDisplayedColor - * @param {cocos2d::Color3B} - */ -updateDisplayedColor : function () {}, - -/** - * @method setInsetRight - * @param {float} - */ -setInsetRight : function () {}, - -/** - * @method Scale9Sprite - * @constructor - */ -Scale9Sprite : function () {}, - -}; - -/** - * @class ControlButton - */ -cc.ControlButton = { - -/** - * @method setTitleColorDispatchTable - * @param {cocos2d::Dictionary*} - */ -setTitleColorDispatchTable : function () {}, - -/** - * @method isPushed - * @return A value converted from C/C++ "bool" - */ -isPushed : function () {}, - -/** - * @method setSelected - * @param {bool} - */ -setSelected : function () {}, - -/** - * @method setTitleLabelForState - * @param {cocos2d::Node*} - * @param {cocos2d::extension::Control::State} - */ -setTitleLabelForState : function () {}, - -/** - * @method ccTouchBegan - * @return A value converted from C/C++ "bool" - * @param {cocos2d::Touch*} - * @param {cocos2d::Event*} - */ -ccTouchBegan : function () {}, - -/** - * @method setAdjustBackgroundImage - * @param {bool} - */ -setAdjustBackgroundImage : function () {}, - -/** - * @method ccTouchEnded - * @param {cocos2d::Touch*} - * @param {cocos2d::Event*} - */ -ccTouchEnded : function () {}, - -/** - * @method setHighlighted - * @param {bool} - */ -setHighlighted : function () {}, - -/** - * @method setZoomOnTouchDown - * @param {bool} - */ -setZoomOnTouchDown : function () {}, - -/** - * @method setBackgroundSpriteDispatchTable - * @param {cocos2d::Dictionary*} - */ -setBackgroundSpriteDispatchTable : function () {}, - -/** - * @method setTitleForState - * @param {cocos2d::String*} - * @param {cocos2d::extension::Control::State} - */ -setTitleForState : function () {}, - -/** - * @method getTitleDispatchTable - * @return A value converted from C/C++ "cocos2d::Dictionary*" - */ -getTitleDispatchTable : function () {}, - -/** - * @method setLabelAnchorPoint - * @param {cocos2d::Point} - */ -setLabelAnchorPoint : function () {}, - -/** - * @method getPreferredSize - * @return A value converted from C/C++ "cocos2d::Size" - */ -getPreferredSize : function () {}, - -/** - * @method getLabelAnchorPoint - * @return A value converted from C/C++ "cocos2d::Point" - */ -getLabelAnchorPoint : function () {}, - -/** - * @method initWithBackgroundSprite - * @return A value converted from C/C++ "bool" - * @param {cocos2d::extension::Scale9Sprite*} - */ -initWithBackgroundSprite : function () {}, - -/** - * @method getTitleTTFSizeForState - * @return A value converted from C/C++ "float" - * @param {cocos2d::extension::Control::State} - */ -getTitleTTFSizeForState : function () {}, - -/** - * @method setTitleDispatchTable - * @param {cocos2d::Dictionary*} - */ -setTitleDispatchTable : function () {}, - -/** - * @method setOpacity - * @param {unsigned char} - */ -setOpacity : function () {}, - -/** - * @method init - * @return A value converted from C/C++ "bool" - */ -init : function () {}, - -/** - * @method setTitleTTFForState - * @param {const char*} - * @param {cocos2d::extension::Control::State} - */ -setTitleTTFForState : function () {}, - -/** - * @method setTitleTTFSizeForState - * @param {float} - * @param {cocos2d::extension::Control::State} - */ -setTitleTTFSizeForState : function () {}, - -/** - * @method setTitleLabel - * @param {cocos2d::Node*} - */ -setTitleLabel : function () {}, - -/** - * @method ccTouchMoved - * @param {cocos2d::Touch*} - * @param {cocos2d::Event*} - */ -ccTouchMoved : function () {}, - -/** - * @method getOpacity - * @return A value converted from C/C++ "unsigned char" - */ -getOpacity : function () {}, - -/** - * @method getCurrentTitleColor - * @return A value converted from C/C++ "cocos2d::Color3B" - */ -getCurrentTitleColor : function () {}, - -/** - * @method getTitleColorDispatchTable - * @return A value converted from C/C++ "cocos2d::Dictionary*" - */ -getTitleColorDispatchTable : function () {}, - -/** - * @method setEnabled - * @param {bool} - */ -setEnabled : function () {}, - -/** - * @method setBackgroundSprite - * @param {cocos2d::extension::Scale9Sprite*} - */ -setBackgroundSprite : function () {}, - -/** - * @method getBackgroundSpriteForState - * @return A value converted from C/C++ "cocos2d::extension::Scale9Sprite*" - * @param {cocos2d::extension::Control::State} - */ -getBackgroundSpriteForState : function () {}, - -/** - * @method getColor - * @return A value converted from C/C++ "cocos2d::Color3B" - */ -getColor : function () {}, - -/** - * @method setMargins - * @param {int} - * @param {int} - */ -setMargins : function () {}, - -/** - * @method needsLayout - */ -needsLayout : function () {}, - -/** - * @method initWithTitleAndFontNameAndFontSize - * @return A value converted from C/C++ "bool" - * @param {std::string} - * @param {const char*} - * @param {float} - */ -initWithTitleAndFontNameAndFontSize : function () {}, - -/** - * @method getCurrentTitle - * @return A value converted from C/C++ "cocos2d::String*" - */ -getCurrentTitle : function () {}, - -/** - * @method getHorizontalOrigin - * @return A value converted from C/C++ "int" - */ -getHorizontalOrigin : function () {}, - -/** - * @method getTitleTTFForState - * @return A value converted from C/C++ "const char*" - * @param {cocos2d::extension::Control::State} - */ -getTitleTTFForState : function () {}, - -/** - * @method getBackgroundSprite - * @return A value converted from C/C++ "cocos2d::extension::Scale9Sprite*" - */ -getBackgroundSprite : function () {}, - -/** - * @method getTitleColorForState - * @return A value converted from C/C++ "cocos2d::Color3B" - * @param {cocos2d::extension::Control::State} - */ -getTitleColorForState : function () {}, - -/** - * @method setTitleColorForState - * @param {cocos2d::Color3B} - * @param {cocos2d::extension::Control::State} - */ -setTitleColorForState : function () {}, - -/** - * @method doesAdjustBackgroundImage - * @return A value converted from C/C++ "bool" - */ -doesAdjustBackgroundImage : function () {}, - -/** - * @method setBackgroundSpriteFrameForState - * @param {cocos2d::SpriteFrame*} - * @param {cocos2d::extension::Control::State} - */ -setBackgroundSpriteFrameForState : function () {}, - -/** - * @method setBackgroundSpriteForState - * @param {cocos2d::extension::Scale9Sprite*} - * @param {cocos2d::extension::Control::State} - */ -setBackgroundSpriteForState : function () {}, - -/** - * @method setColor - * @param {cocos2d::Color3B} - */ -setColor : function () {}, - -/** - * @method getTitleLabelDispatchTable - * @return A value converted from C/C++ "cocos2d::Dictionary*" - */ -getTitleLabelDispatchTable : function () {}, - -/** - * @method initWithLabelAndBackgroundSprite - * @return A value converted from C/C++ "bool" - * @param {cocos2d::Node*} - * @param {cocos2d::extension::Scale9Sprite*} - */ -initWithLabelAndBackgroundSprite : function () {}, - -/** - * @method setPreferredSize - * @param {cocos2d::Size} - */ -setPreferredSize : function () {}, - -/** - * @method setTitleLabelDispatchTable - * @param {cocos2d::Dictionary*} - */ -setTitleLabelDispatchTable : function () {}, - -/** - * @method getTitleLabel - * @return A value converted from C/C++ "cocos2d::Node*" - */ -getTitleLabel : function () {}, - -/** - * @method ccTouchCancelled - * @param {cocos2d::Touch*} - * @param {cocos2d::Event*} - */ -ccTouchCancelled : function () {}, - -/** - * @method getVerticalMargin - * @return A value converted from C/C++ "int" - */ -getVerticalMargin : function () {}, - -/** - * @method getBackgroundSpriteDispatchTable - * @return A value converted from C/C++ "cocos2d::Dictionary*" - */ -getBackgroundSpriteDispatchTable : function () {}, - -/** - * @method getTitleLabelForState - * @return A value converted from C/C++ "cocos2d::Node*" - * @param {cocos2d::extension::Control::State} - */ -getTitleLabelForState : function () {}, - -/** - * @method setTitleBMFontForState - * @param {const char*} - * @param {cocos2d::extension::Control::State} - */ -setTitleBMFontForState : function () {}, - -/** - * @method getTitleBMFontForState - * @return A value converted from C/C++ "const char*" - * @param {cocos2d::extension::Control::State} - */ -getTitleBMFontForState : function () {}, - -/** - * @method getZoomOnTouchDown - * @return A value converted from C/C++ "bool" - */ -getZoomOnTouchDown : function () {}, - -/** - * @method getTitleForState - * @return A value converted from C/C++ "cocos2d::String*" - * @param {cocos2d::extension::Control::State} - */ -getTitleForState : function () {}, - -/** - * @method ControlButton - * @constructor - */ -ControlButton : function () {}, - -}; - -/** - * @class ScrollView - */ -cc.ScrollView = { - -/** - * @method isClippingToBounds - * @return A value converted from C/C++ "bool" - */ -isClippingToBounds : function () {}, - -/** - * @method setContainer - * @param {cocos2d::Node*} - */ -setContainer : function () {}, - -/** - * @method setContentOffsetInDuration - * @param {cocos2d::Point} - * @param {float} - */ -setContentOffsetInDuration : function () {}, - -/** - * @method setZoomScaleInDuration - * @param {float} - * @param {float} - */ -setZoomScaleInDuration : function () {}, - -/** - * @method ccTouchBegan - * @return A value converted from C/C++ "bool" - * @param {cocos2d::Touch*} - * @param {cocos2d::Event*} - */ -ccTouchBegan : function () {}, - -/** - * @method getContainer - * @return A value converted from C/C++ "cocos2d::Node*" - */ -getContainer : function () {}, - -/** - * @method ccTouchEnded - * @param {cocos2d::Touch*} - * @param {cocos2d::Event*} - */ -ccTouchEnded : function () {}, - -/** - * @method getDirection - * @return A value converted from C/C++ "cocos2d::extension::ScrollView::Direction" - */ -getDirection : function () {}, - -/** - * @method getZoomScale - * @return A value converted from C/C++ "float" - */ -getZoomScale : function () {}, - -/** - * @method updateInset - */ -updateInset : function () {}, - -/** - * @method initWithViewSize - * @return A value converted from C/C++ "bool" - * @param {cocos2d::Size} - * @param {cocos2d::Node*} - */ -initWithViewSize : function () {}, - -/** - * @method pause - * @param {cocos2d::Object*} - */ -pause : function () {}, - -/** - * @method setDirection - * @param {cocos2d::extension::ScrollView::Direction} - */ -setDirection : function () {}, - -/** - * @method setBounceable - * @param {bool} - */ -setBounceable : function () {}, - -/** - * @method setContentOffset - * @param {cocos2d::Point} - * @param {bool} - */ -setContentOffset : function () {}, - -/** - * @method isDragging - * @return A value converted from C/C++ "bool" - */ -isDragging : function () {}, - -/** - * @method init - * @return A value converted from C/C++ "bool" - */ -init : function () {}, - -/** - * @method isBounceable - * @return A value converted from C/C++ "bool" - */ -isBounceable : function () {}, - -/** - * @method getContentSize - * @return A value converted from C/C++ "cocos2d::Size" - */ -getContentSize : function () {}, - -/** - * @method ccTouchMoved - * @param {cocos2d::Touch*} - * @param {cocos2d::Event*} - */ -ccTouchMoved : function () {}, - -/** - * @method setTouchEnabled - * @param {bool} - */ -setTouchEnabled : function () {}, - -/** - * @method getContentOffset - * @return A value converted from C/C++ "cocos2d::Point" - */ -getContentOffset : function () {}, - -/** - * @method resume - * @param {cocos2d::Object*} - */ -resume : function () {}, - -/** - * @method setClippingToBounds - * @param {bool} - */ -setClippingToBounds : function () {}, - -/** - * @method setViewSize - * @param {cocos2d::Size} - */ -setViewSize : function () {}, - -/** - * @method getViewSize - * @return A value converted from C/C++ "cocos2d::Size" - */ -getViewSize : function () {}, - -/** - * @method maxContainerOffset - * @return A value converted from C/C++ "cocos2d::Point" - */ -maxContainerOffset : function () {}, - -/** - * @method setContentSize - * @param {cocos2d::Size} - */ -setContentSize : function () {}, - -/** - * @method isTouchMoved - * @return A value converted from C/C++ "bool" - */ -isTouchMoved : function () {}, - -/** - * @method isNodeVisible - * @return A value converted from C/C++ "bool" - * @param {cocos2d::Node*} - */ -isNodeVisible : function () {}, - -/** - * @method ccTouchCancelled - * @param {cocos2d::Touch*} - * @param {cocos2d::Event*} - */ -ccTouchCancelled : function () {}, - -/** - * @method minContainerOffset - * @return A value converted from C/C++ "cocos2d::Point" - */ -minContainerOffset : function () {}, - -/** - * @method registerWithTouchDispatcher - */ -registerWithTouchDispatcher : function () {}, - -/** - * @method ScrollView - * @constructor - */ -ScrollView : function () {}, - -}; - -/** - * @class CCBAnimationManager - */ -cc.AnimationManager = { - -/** - * @method moveAnimationsFromNode - * @param {cocos2d::Node*} - * @param {cocos2d::Node*} - */ -moveAnimationsFromNode : function () {}, - -/** - * @method setAutoPlaySequenceId - * @param {int} - */ -setAutoPlaySequenceId : function () {}, - -/** - * @method getDocumentCallbackNames - * @return A value converted from C/C++ "cocos2d::Array*" - */ -getDocumentCallbackNames : function () {}, - -/** - * @method actionForSoundChannel - * @return A value converted from C/C++ "cocos2d::Object*" - * @param {cocos2d::extension::CCBSequenceProperty*} - */ -actionForSoundChannel : function () {}, - -/** - * @method setBaseValue - * @param {cocos2d::Object*} - * @param {cocos2d::Node*} - * @param {const char*} - */ -setBaseValue : function () {}, - -/** - * @method getDocumentOutletNodes - * @return A value converted from C/C++ "cocos2d::Array*" - */ -getDocumentOutletNodes : function () {}, - -/** - * @method addNode - * @param {cocos2d::Node*} - * @param {cocos2d::Dictionary*} - */ -addNode : function () {}, - -/** - * @method getLastCompletedSequenceName - * @return A value converted from C/C++ "std::string" - */ -getLastCompletedSequenceName : function () {}, - -/** - * @method setRootNode - * @param {cocos2d::Node*} - */ -setRootNode : function () {}, - -/** - * @method runAnimationsForSequenceNamedTweenDuration - * @param {const char*} - * @param {float} - */ -runAnimationsForSequenceNamedTweenDuration : function () {}, - -/** - * @method addDocumentOutletName - * @param {std::string} - */ -addDocumentOutletName : function () {}, - -/** - * @method getSequences - * @return A value converted from C/C++ "cocos2d::Array*" - */ -getSequences : function () {}, - -/** - * @method getRootContainerSize - * @return A value converted from C/C++ "cocos2d::Size" - */ -getRootContainerSize : function () {}, - -/** - * @method setDocumentControllerName - * @param {std::string} - */ -setDocumentControllerName : function () {}, - -/** - * @method getContainerSize - * @return A value converted from C/C++ "cocos2d::Size" - * @param {cocos2d::Node*} - */ -getContainerSize : function () {}, - -/** - * @method actionForCallbackChannel - * @return A value converted from C/C++ "cocos2d::Object*" - * @param {cocos2d::extension::CCBSequenceProperty*} - */ -actionForCallbackChannel : function () {}, - -/** - * @method getDocumentOutletNames - * @return A value converted from C/C++ "cocos2d::Array*" - */ -getDocumentOutletNames : function () {}, - -/** - * @method addDocumentCallbackControlEvents - * @param {cocos2d::extension::Control::EventType} - */ -addDocumentCallbackControlEvents : function () {}, - -/** - * @method init - * @return A value converted from C/C++ "bool" - */ -init : function () {}, - -/** - * @method getKeyframeCallbacks - * @return A value converted from C/C++ "cocos2d::Array*" - */ -getKeyframeCallbacks : function () {}, - -/** - * @method getDocumentCallbackControlEvents - * @return A value converted from C/C++ "cocos2d::Array*" - */ -getDocumentCallbackControlEvents : function () {}, - -/** - * @method setRootContainerSize - * @param {cocos2d::Size} - */ -setRootContainerSize : function () {}, - -/** - * @method runAnimationsForSequenceIdTweenDuration - * @param {int} - * @param {float} - */ -runAnimationsForSequenceIdTweenDuration : function () {}, - -/** - * @method getRunningSequenceName - * @return A value converted from C/C++ "const char*" - */ -getRunningSequenceName : function () {}, - -/** - * @method getAutoPlaySequenceId - * @return A value converted from C/C++ "int" - */ -getAutoPlaySequenceId : function () {}, - -/** - * @method addDocumentCallbackName - * @param {std::string} - */ -addDocumentCallbackName : function () {}, - -/** - * @method getRootNode - * @return A value converted from C/C++ "cocos2d::Node*" - */ -getRootNode : function () {}, - -/** - * @method addDocumentOutletNode - * @param {cocos2d::Node*} - */ -addDocumentOutletNode : function () {}, - -/** - * @method getSequenceDuration - * @return A value converted from C/C++ "float" - * @param {const char*} - */ -getSequenceDuration : function () {}, - -/** - * @method addDocumentCallbackNode - * @param {cocos2d::Node*} - */ -addDocumentCallbackNode : function () {}, - -/** - * @method runAnimationsForSequenceNamed - * @param {const char*} - */ -runAnimationsForSequenceNamed : function () {}, - -/** - * @method getSequenceId - * @return A value converted from C/C++ "int" - * @param {const char*} - */ -getSequenceId : function () {}, - -/** - * @method getDocumentCallbackNodes - * @return A value converted from C/C++ "cocos2d::Array*" - */ -getDocumentCallbackNodes : function () {}, - -/** - * @method setSequences - * @param {cocos2d::Array*} - */ -setSequences : function () {}, - -/** - * @method debug - */ -debug : function () {}, - -/** - * @method getDocumentControllerName - * @return A value converted from C/C++ "std::string" - */ -getDocumentControllerName : function () {}, - -/** - * @method CCBAnimationManager - * @constructor - */ -CCBAnimationManager : function () {}, - -}; - -/** - * @class ControlHuePicker - */ -cc.ControlHuePicker = { - -/** - * @method setEnabled - * @param {bool} - */ -setEnabled : function () {}, - -/** - * @method initWithTargetAndPos - * @return A value converted from C/C++ "bool" - * @param {cocos2d::Node*} - * @param {cocos2d::Point} - */ -initWithTargetAndPos : function () {}, - -/** - * @method setHue - * @param {float} - */ -setHue : function () {}, - -/** - * @method getStartPos - * @return A value converted from C/C++ "cocos2d::Point" - */ -getStartPos : function () {}, - -/** - * @method getHue - * @return A value converted from C/C++ "float" - */ -getHue : function () {}, - -/** - * @method ccTouchBegan - * @return A value converted from C/C++ "bool" - * @param {cocos2d::Touch*} - * @param {cocos2d::Event*} - */ -ccTouchBegan : function () {}, - -/** - * @method setBackground - * @param {cocos2d::Sprite*} - */ -setBackground : function () {}, - -/** - * @method setHuePercentage - * @param {float} - */ -setHuePercentage : function () {}, - -/** - * @method getBackground - * @return A value converted from C/C++ "cocos2d::Sprite*" - */ -getBackground : function () {}, - -/** - * @method ccTouchMoved - * @param {cocos2d::Touch*} - * @param {cocos2d::Event*} - */ -ccTouchMoved : function () {}, - -/** - * @method getSlider - * @return A value converted from C/C++ "cocos2d::Sprite*" - */ -getSlider : function () {}, - -/** - * @method getHuePercentage - * @return A value converted from C/C++ "float" - */ -getHuePercentage : function () {}, - -/** - * @method setSlider - * @param {cocos2d::Sprite*} - */ -setSlider : function () {}, - -/** - * @method create - * @return A value converted from C/C++ "cocos2d::extension::ControlHuePicker*" - * @param {cocos2d::Node*} - * @param {cocos2d::Point} - */ -create : function () {}, - -/** - * @method ControlHuePicker - * @constructor - */ -ControlHuePicker : function () {}, - -}; - -/** - * @class ControlSaturationBrightnessPicker - */ -cc.ControlSaturationBrightnessPicker = { - -/** - * @method getShadow - * @return A value converted from C/C++ "cocos2d::Sprite*" - */ -getShadow : function () {}, - -/** - * @method initWithTargetAndPos - * @return A value converted from C/C++ "bool" - * @param {cocos2d::Node*} - * @param {cocos2d::Point} - */ -initWithTargetAndPos : function () {}, - -/** - * @method getStartPos - * @return A value converted from C/C++ "cocos2d::Point" - */ -getStartPos : function () {}, - -/** - * @method getOverlay - * @return A value converted from C/C++ "cocos2d::Sprite*" - */ -getOverlay : function () {}, - -/** - * @method setEnabled - * @param {bool} - */ -setEnabled : function () {}, - -/** - * @method getSlider - * @return A value converted from C/C++ "cocos2d::Sprite*" - */ -getSlider : function () {}, - -/** - * @method getBackground - * @return A value converted from C/C++ "cocos2d::Sprite*" - */ -getBackground : function () {}, - -/** - * @method getSaturation - * @return A value converted from C/C++ "float" - */ -getSaturation : function () {}, - -/** - * @method getBrightness - * @return A value converted from C/C++ "float" - */ -getBrightness : function () {}, - -/** - * @method create - * @return A value converted from C/C++ "cocos2d::extension::ControlSaturationBrightnessPicker*" - * @param {cocos2d::Node*} - * @param {cocos2d::Point} - */ -create : function () {}, - -/** - * @method ControlSaturationBrightnessPicker - * @constructor - */ -ControlSaturationBrightnessPicker : function () {}, - -}; - -/** - * @class ControlColourPicker - */ -cc.ControlColourPicker = { - -/** - * @method setEnabled - * @param {bool} - */ -setEnabled : function () {}, - -/** - * @method getHuePicker - * @return A value converted from C/C++ "cocos2d::extension::ControlHuePicker*" - */ -getHuePicker : function () {}, - -/** - * @method setColor - * @param {cocos2d::Color3B} - */ -setColor : function () {}, - -/** - * @method hueSliderValueChanged - * @param {cocos2d::Object*} - * @param {cocos2d::extension::Control::EventType} - */ -hueSliderValueChanged : function () {}, - -/** - * @method getcolourPicker - * @return A value converted from C/C++ "cocos2d::extension::ControlSaturationBrightnessPicker*" - */ -getcolourPicker : function () {}, - -/** - * @method setBackground - * @param {cocos2d::Sprite*} - */ -setBackground : function () {}, - -/** - * @method init - * @return A value converted from C/C++ "bool" - */ -init : function () {}, - -/** - * @method setcolourPicker - * @param {cocos2d::extension::ControlSaturationBrightnessPicker*} - */ -setcolourPicker : function () {}, - -/** - * @method colourSliderValueChanged - * @param {cocos2d::Object*} - * @param {cocos2d::extension::Control::EventType} - */ -colourSliderValueChanged : function () {}, - -/** - * @method setHuePicker - * @param {cocos2d::extension::ControlHuePicker*} - */ -setHuePicker : function () {}, - -/** - * @method getBackground - * @return A value converted from C/C++ "cocos2d::Sprite*" - */ -getBackground : function () {}, - -/** - * @method create - * @return A value converted from C/C++ "cocos2d::extension::ControlColourPicker*" - */ -create : function () {}, - -/** - * @method ControlColourPicker - * @constructor - */ -ControlColourPicker : function () {}, - -}; - -/** - * @class ControlPotentiometer - */ -cc.ControlPotentiometer = { - -/** - * @method setPreviousLocation - * @param {cocos2d::Point} - */ -setPreviousLocation : function () {}, - -/** - * @method setProgressTimer - * @param {cocos2d::ProgressTimer*} - */ -setProgressTimer : function () {}, - -/** - * @method potentiometerMoved - * @param {cocos2d::Point} - */ -potentiometerMoved : function () {}, - -/** - * @method ccTouchEnded - * @param {cocos2d::Touch*} - * @param {cocos2d::Event*} - */ -ccTouchEnded : function () {}, - -/** - * @method getMinimumValue - * @return A value converted from C/C++ "float" - */ -getMinimumValue : function () {}, - -/** - * @method setThumbSprite - * @param {cocos2d::Sprite*} - */ -setThumbSprite : function () {}, - -/** - * @method ccTouchMoved - * @param {cocos2d::Touch*} - * @param {cocos2d::Event*} - */ -ccTouchMoved : function () {}, - -/** - * @method ccTouchBegan - * @return A value converted from C/C++ "bool" - * @param {cocos2d::Touch*} - * @param {cocos2d::Event*} - */ -ccTouchBegan : function () {}, - -/** - * @method setEnabled - * @param {bool} - */ -setEnabled : function () {}, - -/** - * @method setValue - * @param {float} - */ -setValue : function () {}, - -/** - * @method setMaximumValue - * @param {float} - */ -setMaximumValue : function () {}, - -/** - * @method setMinimumValue - * @param {float} - */ -setMinimumValue : function () {}, - -/** - * @method potentiometerEnded - * @param {cocos2d::Point} - */ -potentiometerEnded : function () {}, - -/** - * @method distanceBetweenPointAndPoint - * @return A value converted from C/C++ "float" - * @param {cocos2d::Point} - * @param {cocos2d::Point} - */ -distanceBetweenPointAndPoint : function () {}, - -/** - * @method getProgressTimer - * @return A value converted from C/C++ "cocos2d::ProgressTimer*" - */ -getProgressTimer : function () {}, - -/** - * @method getMaximumValue - * @return A value converted from C/C++ "float" - */ -getMaximumValue : function () {}, - -/** - * @method angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint - * @return A value converted from C/C++ "float" - * @param {cocos2d::Point} - * @param {cocos2d::Point} - * @param {cocos2d::Point} - * @param {cocos2d::Point} - */ -angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint : function () {}, - -/** - * @method isTouchInside - * @return A value converted from C/C++ "bool" - * @param {cocos2d::Touch*} - */ -isTouchInside : function () {}, - -/** - * @method getValue - * @return A value converted from C/C++ "float" - */ -getValue : function () {}, - -/** - * @method potentiometerBegan - * @param {cocos2d::Point} - */ -potentiometerBegan : function () {}, - -/** - * @method getThumbSprite - * @return A value converted from C/C++ "cocos2d::Sprite*" - */ -getThumbSprite : function () {}, - -/** - * @method initWithTrackSprite_ProgressTimer_ThumbSprite - * @return A value converted from C/C++ "bool" - * @param {cocos2d::Sprite*} - * @param {cocos2d::ProgressTimer*} - * @param {cocos2d::Sprite*} - */ -initWithTrackSprite_ProgressTimer_ThumbSprite : function () {}, - -/** - * @method getPreviousLocation - * @return A value converted from C/C++ "cocos2d::Point" - */ -getPreviousLocation : function () {}, - -/** - * @method create - * @return A value converted from C/C++ "cocos2d::extension::ControlPotentiometer*" - * @param {const char*} - * @param {const char*} - * @param {const char*} - */ -create : function () {}, - -/** - * @method ControlPotentiometer - * @constructor - */ -ControlPotentiometer : function () {}, - -}; - -/** - * @class ControlSlider - */ -cc.ControlSlider = { - -/** - * @method locationFromTouch - * @return A value converted from C/C++ "cocos2d::Point" - * @param {cocos2d::Touch*} - */ -locationFromTouch : function () {}, - -/** - * @method setProgressSprite - * @param {cocos2d::Sprite*} - */ -setProgressSprite : function () {}, - -/** - * @method getMaximumAllowedValue - * @return A value converted from C/C++ "float" - */ -getMaximumAllowedValue : function () {}, - -/** - * @method getMinimumAllowedValue - * @return A value converted from C/C++ "float" - */ -getMinimumAllowedValue : function () {}, - -/** - * @method getMinimumValue - * @return A value converted from C/C++ "float" - */ -getMinimumValue : function () {}, - -/** - * @method setThumbSprite - * @param {cocos2d::Sprite*} - */ -setThumbSprite : function () {}, - -/** - * @method setMinimumValue - * @param {float} - */ -setMinimumValue : function () {}, - -/** - * @method setMinimumAllowedValue - * @param {float} - */ -setMinimumAllowedValue : function () {}, - -/** - * @method setEnabled - * @param {bool} - */ -setEnabled : function () {}, - -/** - * @method setValue - * @param {float} - */ -setValue : function () {}, - -/** - * @method setMaximumValue - * @param {float} - */ -setMaximumValue : function () {}, - -/** - * @method needsLayout - */ -needsLayout : function () {}, - -/** - * @method getBackgroundSprite - * @return A value converted from C/C++ "cocos2d::Sprite*" - */ -getBackgroundSprite : function () {}, - -/** - * @method initWithSprites - * @return A value converted from C/C++ "bool" - * @param {cocos2d::Sprite*} - * @param {cocos2d::Sprite*} - * @param {cocos2d::Sprite*} - */ -initWithSprites : function () {}, - -/** - * @method getMaximumValue - * @return A value converted from C/C++ "float" - */ -getMaximumValue : function () {}, - -/** - * @method isTouchInside - * @return A value converted from C/C++ "bool" - * @param {cocos2d::Touch*} - */ -isTouchInside : function () {}, - -/** - * @method getValue - * @return A value converted from C/C++ "float" - */ -getValue : function () {}, - -/** - * @method getThumbSprite - * @return A value converted from C/C++ "cocos2d::Sprite*" - */ -getThumbSprite : function () {}, - -/** - * @method getProgressSprite - * @return A value converted from C/C++ "cocos2d::Sprite*" - */ -getProgressSprite : function () {}, - -/** - * @method setBackgroundSprite - * @param {cocos2d::Sprite*} - */ -setBackgroundSprite : function () {}, - -/** - * @method setMaximumAllowedValue - * @param {float} - */ -setMaximumAllowedValue : function () {}, - -/** - * @method ControlSlider - * @constructor - */ -ControlSlider : function () {}, - -}; - -/** - * @class ControlStepper - */ -cc.ControlStepper = { - -/** - * @method setMinusSprite - * @param {cocos2d::Sprite*} - */ -setMinusSprite : function () {}, - -/** - * @method ccTouchBegan - * @return A value converted from C/C++ "bool" - * @param {cocos2d::Touch*} - * @param {cocos2d::Event*} - */ -ccTouchBegan : function () {}, - -/** - * @method getMinusLabel - * @return A value converted from C/C++ "cocos2d::LabelTTF*" - */ -getMinusLabel : function () {}, - -/** - * @method setWraps - * @param {bool} - */ -setWraps : function () {}, - -/** - * @method ccTouchEnded - * @param {cocos2d::Touch*} - * @param {cocos2d::Event*} - */ -ccTouchEnded : function () {}, - -/** - * @method isContinuous - * @return A value converted from C/C++ "bool" - */ -isContinuous : function () {}, - -/** - * @method getMinusSprite - * @return A value converted from C/C++ "cocos2d::Sprite*" - */ -getMinusSprite : function () {}, - -/** - * @method updateLayoutUsingTouchLocation - * @param {cocos2d::Point} - */ -updateLayoutUsingTouchLocation : function () {}, - -/** - * @method setValueWithSendingEvent - * @param {double} - * @param {bool} - */ -setValueWithSendingEvent : function () {}, - -/** - * @method getPlusLabel - * @return A value converted from C/C++ "cocos2d::LabelTTF*" - */ -getPlusLabel : function () {}, - -/** - * @method stopAutorepeat - */ -stopAutorepeat : function () {}, - -/** - * @method ccTouchMoved - * @param {cocos2d::Touch*} - * @param {cocos2d::Event*} - */ -ccTouchMoved : function () {}, - -/** - * @method setMaximumValue - * @param {double} - */ -setMaximumValue : function () {}, - -/** - * @method setPlusSprite - * @param {cocos2d::Sprite*} - */ -setPlusSprite : function () {}, - -/** - * @method setMinusLabel - * @param {cocos2d::LabelTTF*} - */ -setMinusLabel : function () {}, - -/** - * @method setValue - * @param {double} - */ -setValue : function () {}, - -/** - * @method setStepValue - * @param {double} - */ -setStepValue : function () {}, - -/** - * @method getPlusSprite - * @return A value converted from C/C++ "cocos2d::Sprite*" - */ -getPlusSprite : function () {}, - -/** - * @method update - * @param {float} - */ -update : function () {}, - -/** - * @method setMinimumValue - * @param {double} - */ -setMinimumValue : function () {}, - -/** - * @method startAutorepeat - */ -startAutorepeat : function () {}, - -/** - * @method initWithMinusSpriteAndPlusSprite - * @return A value converted from C/C++ "bool" - * @param {cocos2d::Sprite*} - * @param {cocos2d::Sprite*} - */ -initWithMinusSpriteAndPlusSprite : function () {}, - -/** - * @method getValue - * @return A value converted from C/C++ "double" - */ -getValue : function () {}, - -/** - * @method setPlusLabel - * @param {cocos2d::LabelTTF*} - */ -setPlusLabel : function () {}, - -/** - * @method create - * @return A value converted from C/C++ "cocos2d::extension::ControlStepper*" - * @param {cocos2d::Sprite*} - * @param {cocos2d::Sprite*} - */ -create : function () {}, - -/** - * @method ControlStepper - * @constructor - */ -ControlStepper : function () {}, - -}; - -/** - * @class ControlSwitch - */ -cc.ControlSwitch = { - -/** - * @method setEnabled - * @param {bool} - */ -setEnabled : function () {}, - -/** - * @method ccTouchBegan - * @return A value converted from C/C++ "bool" - * @param {cocos2d::Touch*} - * @param {cocos2d::Event*} - */ -ccTouchBegan : function () {}, - -/** - * @method isOn - * @return A value converted from C/C++ "bool" - */ -isOn : function () {}, - -/** - * @method ccTouchCancelled - * @param {cocos2d::Touch*} - * @param {cocos2d::Event*} - */ -ccTouchCancelled : function () {}, - -/** - * @method ccTouchEnded - * @param {cocos2d::Touch*} - * @param {cocos2d::Event*} - */ -ccTouchEnded : function () {}, - -/** - * @method ccTouchMoved - * @param {cocos2d::Touch*} - * @param {cocos2d::Event*} - */ -ccTouchMoved : function () {}, - -/** - * @method hasMoved - * @return A value converted from C/C++ "bool" - */ -hasMoved : function () {}, - -/** - * @method locationFromTouch - * @return A value converted from C/C++ "cocos2d::Point" - * @param {cocos2d::Touch*} - */ -locationFromTouch : function () {}, - -/** - * @method ControlSwitch - * @constructor - */ -ControlSwitch : function () {}, - -}; - -/** - * @class TableViewCell - */ -cc.TableViewCell = { - -/** - * @method reset - */ -reset : function () {}, - -/** - * @method setIdx - * @param {unsigned int} - */ -setIdx : function () {}, - -/** - * @method setObjectID - * @param {unsigned int} - */ -setObjectID : function () {}, - -/** - * @method getObjectID - * @return A value converted from C/C++ "unsigned int" - */ -getObjectID : function () {}, - -/** - * @method getIdx - * @return A value converted from C/C++ "unsigned int" - */ -getIdx : function () {}, - -/** - * @method TableViewCell - * @constructor - */ -TableViewCell : function () {}, - -}; - -/** - * @class TableView - */ -cc.TableView = { - -/** - * @method updateCellAtIndex - * @param {unsigned int} - */ -updateCellAtIndex : function () {}, - -/** - * @method setVerticalFillOrder - * @param {cocos2d::extension::TableView::VerticalFillOrder} - */ -setVerticalFillOrder : function () {}, - -/** - * @method scrollViewDidZoom - * @param {cocos2d::extension::ScrollView*} - */ -scrollViewDidZoom : function () {}, - -/** - * @method ccTouchBegan - * @return A value converted from C/C++ "bool" - * @param {cocos2d::Touch*} - * @param {cocos2d::Event*} - */ -ccTouchBegan : function () {}, - -/** - * @method getVerticalFillOrder - * @return A value converted from C/C++ "cocos2d::extension::TableView::VerticalFillOrder" - */ -getVerticalFillOrder : function () {}, - -/** - * @method removeCellAtIndex - * @param {unsigned int} - */ -removeCellAtIndex : function () {}, - -/** - * @method initWithViewSize - * @return A value converted from C/C++ "bool" - * @param {cocos2d::Size} - * @param {cocos2d::Node*} - */ -initWithViewSize : function () {}, - -/** - * @method scrollViewDidScroll - * @param {cocos2d::extension::ScrollView*} - */ -scrollViewDidScroll : function () {}, - -/** - * @method reloadData - */ -reloadData : function () {}, - -/** - * @method ccTouchCancelled - * @param {cocos2d::Touch*} - * @param {cocos2d::Event*} - */ -ccTouchCancelled : function () {}, - -/** - * @method ccTouchEnded - * @param {cocos2d::Touch*} - * @param {cocos2d::Event*} - */ -ccTouchEnded : function () {}, - -/** - * @method ccTouchMoved - * @param {cocos2d::Touch*} - * @param {cocos2d::Event*} - */ -ccTouchMoved : function () {}, - -/** - * @method _updateContentSize - */ -_updateContentSize : function () {}, - -/** - * @method insertCellAtIndex - * @param {unsigned int} - */ -insertCellAtIndex : function () {}, - -/** - * @method cellAtIndex - * @return A value converted from C/C++ "cocos2d::extension::TableViewCell*" - * @param {unsigned int} - */ -cellAtIndex : function () {}, - -/** - * @method dequeueCell - * @return A value converted from C/C++ "cocos2d::extension::TableViewCell*" - */ -dequeueCell : function () {}, - -/** - * @method TableView - * @constructor - */ -TableView : function () {}, - -}; - -/** - * @class EditBox - */ -cc.EditBox = { - -/** - * @method setAnchorPoint - * @param {cocos2d::Point} - */ -setAnchorPoint : function () {}, - -/** - * @method getText - * @return A value converted from C/C++ "const char*" - */ -getText : function () {}, - -/** - * @method setPlaceholderFontName - * @param {const char*} - */ -setPlaceholderFontName : function () {}, - -/** - * @method getPlaceHolder - * @return A value converted from C/C++ "const char*" - */ -getPlaceHolder : function () {}, - -/** - * @method setFontName - * @param {const char*} - */ -setFontName : function () {}, - -/** - * @method setPlaceholderFontSize - * @param {int} - */ -setPlaceholderFontSize : function () {}, - -/** - * @method setInputMode - * @param {cocos2d::extension::EditBox::InputMode} - */ -setInputMode : function () {}, - -/** - * @method setPlaceholderFontColor - * @param {cocos2d::Color3B} - */ -setPlaceholderFontColor : function () {}, - -/** - * @method setFontColor - * @param {cocos2d::Color3B} - */ -setFontColor : function () {}, - -/** - * @method setPlaceholderFont - * @param {const char*} - * @param {int} - */ -setPlaceholderFont : function () {}, - -/** - * @method setFontSize - * @param {int} - */ -setFontSize : function () {}, - -/** - * @method initWithSizeAndBackgroundSprite - * @return A value converted from C/C++ "bool" - * @param {cocos2d::Size} - * @param {cocos2d::extension::Scale9Sprite*} - */ -initWithSizeAndBackgroundSprite : function () {}, - -/** - * @method setPlaceHolder - * @param {const char*} - */ -setPlaceHolder : function () {}, - -/** - * @method setPosition - * @param {cocos2d::Point} - */ -setPosition : function () {}, - -/** - * @method setReturnType - * @param {cocos2d::extension::EditBox::KeyboardReturnType} - */ -setReturnType : function () {}, - -/** - * @method setInputFlag - * @param {cocos2d::extension::EditBox::InputFlag} - */ -setInputFlag : function () {}, - -/** - * @method getMaxLength - * @return A value converted from C/C++ "int" - */ -getMaxLength : function () {}, - -/** - * @method setText - * @param {const char*} - */ -setText : function () {}, - -/** - * @method setMaxLength - * @param {int} - */ -setMaxLength : function () {}, - -/** - * @method setContentSize - * @param {cocos2d::Size} - */ -setContentSize : function () {}, - -/** - * @method setFont - * @param {const char*} - * @param {int} - */ -setFont : function () {}, - -/** - * @method setVisible - * @param {bool} - */ -setVisible : function () {}, - -/** - * @method create - * @return A value converted from C/C++ "cocos2d::extension::EditBox*" - * @param {cocos2d::Size} - * @param {cocos2d::extension::Scale9Sprite*} - * @param {cocos2d::extension::Scale9Sprite*} - * @param {cocos2d::extension::Scale9Sprite*} - */ -create : function () {}, - -/** - * @method EditBox - * @constructor - */ -EditBox : function () {}, - -}; From 220d4b7d8abf217031e5e12b524481494a156bfc Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 27 Aug 2013 16:21:06 +0800 Subject: [PATCH 112/126] issue #2732: Updating scripting/javascript/bindings/Android.mk and scripting/lua/proj.android/Android.mk. --- scripting/javascript/bindings/Android.mk | 9 +++++---- scripting/lua/proj.android/Android.mk | 16 ++++++++-------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/scripting/javascript/bindings/Android.mk b/scripting/javascript/bindings/Android.mk index c1f7e7e611..2aca99df10 100644 --- a/scripting/javascript/bindings/Android.mk +++ b/scripting/javascript/bindings/Android.mk @@ -23,8 +23,8 @@ LOCAL_SRC_FILES := ScriptingCore.cpp \ jsb_opengl_functions.cpp \ jsb_opengl_manual.cpp \ jsb_opengl_registration.cpp \ - generated/jsb_cocos2dx_auto.cpp \ - generated/jsb_cocos2dx_extension_auto.cpp \ + ../../auto-generated/js-bindings/jsb_cocos2dx_auto.cpp \ + ../../auto-generated/js-bindings/jsb_cocos2dx_extension_auto.cpp \ XMLHTTPRequest.cpp \ jsb_websocket.cpp @@ -33,10 +33,11 @@ LOCAL_CFLAGS := -DCOCOS2D_JAVASCRIPT LOCAL_EXPORT_CFLAGS := -DCOCOS2D_JAVASCRIPT LOCAL_C_INCLUDES := $(LOCAL_PATH) \ - $(LOCAL_PATH)/../../../CocosDenshion/include + $(LOCAL_PATH)/../../../CocosDenshion/include \ + $(LOCAL_PATH)/../../auto-generated/js-bindings LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) \ - $(LOCAL_PATH)/generated + $(LOCAL_PATH)/../../auto-generated/js-bindings LOCAL_WHOLE_STATIC_LIBRARIES := spidermonkey_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static diff --git a/scripting/lua/proj.android/Android.mk b/scripting/lua/proj.android/Android.mk index 7980093553..5a79262dfc 100644 --- a/scripting/lua/proj.android/Android.mk +++ b/scripting/lua/proj.android/Android.mk @@ -10,7 +10,6 @@ LOCAL_SRC_FILES := ../cocos2dx_support/CCLuaBridge.cpp \ ../cocos2dx_support/CCLuaStack.cpp \ ../cocos2dx_support/CCLuaValue.cpp \ ../cocos2dx_support/Cocos2dxLuaLoader.cpp \ - ../cocos2dx_support/LuaCocos2d.cpp \ ../cocos2dx_support/CCBProxy.cpp \ ../cocos2dx_support/Lua_extensions_CCB.cpp \ ../cocos2dx_support/Lua_web_socket.cpp \ @@ -18,8 +17,8 @@ LOCAL_SRC_FILES := ../cocos2dx_support/CCLuaBridge.cpp \ ../cocos2dx_support/LuaScrollView.cpp \ ../cocos2dx_support/LuaScriptHandlerMgr.cpp \ ../cocos2dx_support/LuaBasicConversions.cpp \ - ../cocos2dx_support/generated/lua_cocos2dx_auto.cpp \ - ../cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp \ + ../../auto-generated/lua-bindings/lua_cocos2dx_auto.cpp \ + ../../auto-generated/lua-bindings/lua_cocos2dx_extension_auto.cpp \ ../cocos2dx_support/lua_cocos2dx_manual.cpp \ ../cocos2dx_support/lua_cocos2dx_extension_manual.cpp \ ../cocos2dx_support/lua_cocos2dx_deprecated.cpp \ @@ -29,12 +28,13 @@ LOCAL_SRC_FILES := ../cocos2dx_support/CCLuaBridge.cpp \ ../tolua/tolua_push.c \ ../tolua/tolua_to.c \ ../cocos2dx_support/tolua_fix.c - + LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../luajit/include \ $(LOCAL_PATH)/../tolua \ - $(LOCAL_PATH)/../cocos2dx_support - - + $(LOCAL_PATH)/../cocos2dx_support \ + $(LOCAL_PATH)/../../auto-generated/lua-bindings + + LOCAL_C_INCLUDES := $(LOCAL_PATH)/ \ $(LOCAL_PATH)/../luajit/include \ $(LOCAL_PATH)/../tolua \ @@ -46,7 +46,7 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/ \ $(LOCAL_PATH)/../../../CocosDenshion/include \ $(LOCAL_PATH)/../../../extensions \ $(LOCAL_PATH)/../cocos2dx_support \ - $(LOCAL_PATH)/../cocos2dx_support/generated + $(LOCAL_PATH)/../../auto-generated/lua-bindings LOCAL_WHOLE_STATIC_LIBRARIES := luajit_static From e76e3160638ca59c0fb031a266386e31482141a8 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 27 Aug 2013 16:30:56 +0800 Subject: [PATCH 113/126] issue #2732: [Win32] Updating project configuration for libJSBinding.vcxproj and liblua.vcxproj. --- .../bindings/proj.win32/libJSBinding.vcxproj | 12 +++---- .../proj.win32/libJSBinding.vcxproj.filters | 36 +++++++++---------- scripting/lua/proj.win32/liblua.vcxproj | 12 ++++--- .../lua/proj.win32/liblua.vcxproj.filters | 16 ++++++--- 4 files changed, 44 insertions(+), 32 deletions(-) diff --git a/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj b/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj index e6fff0dc38..454ae6e290 100644 --- a/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj +++ b/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj @@ -11,10 +11,10 @@ + + - - @@ -34,10 +34,10 @@ + + - - @@ -63,8 +63,8 @@ - - + + diff --git a/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj.filters b/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj.filters index 28046317c8..77d3dd915b 100644 --- a/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj.filters +++ b/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj.filters @@ -50,12 +50,6 @@ manual - - generated - - - generated - manual @@ -77,6 +71,12 @@ manual + + generated + + + generated + @@ -130,12 +130,6 @@ manual - - generated - - - generated - manual @@ -160,14 +154,14 @@ manual + + generated + + + generated + - - generated - - - generated - js @@ -195,5 +189,11 @@ js + + generated + + + generated + \ No newline at end of file diff --git a/scripting/lua/proj.win32/liblua.vcxproj b/scripting/lua/proj.win32/liblua.vcxproj index fee462e804..dd2ce120c2 100644 --- a/scripting/lua/proj.win32/liblua.vcxproj +++ b/scripting/lua/proj.win32/liblua.vcxproj @@ -122,14 +122,14 @@ xcopy /Y /Q "$(ProjectDir)..\luajit\win32\*.*" "$(OutDir)" + + - - @@ -147,14 +147,14 @@ xcopy /Y /Q "$(ProjectDir)..\luajit\win32\*.*" "$(OutDir)" + + - - @@ -172,6 +172,10 @@ xcopy /Y /Q "$(ProjectDir)..\luajit\win32\*.*" "$(OutDir)" + + + + diff --git a/scripting/lua/proj.win32/liblua.vcxproj.filters b/scripting/lua/proj.win32/liblua.vcxproj.filters index 0c50a3c7f7..1005cce19a 100644 --- a/scripting/lua/proj.win32/liblua.vcxproj.filters +++ b/scripting/lua/proj.win32/liblua.vcxproj.filters @@ -81,10 +81,10 @@ cocos2dx_support - + cocos2dx_support\generated - + cocos2dx_support\generated @@ -155,11 +155,19 @@ cocos2dx_support - + cocos2dx_support\generated - + cocos2dx_support\generated + + + cocos2dx_support\generated + + + cocos2dx_support\generated + + \ No newline at end of file From a7f4e82799c0ec08119c41ff7fbe499ccf6116ae Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 27 Aug 2013 16:46:31 +0800 Subject: [PATCH 114/126] issue #2732: Adding 'scripting/auto-generated/js(lua)-bindings' to search path of include files. --- .../proj.win32/AssetsManagerTest.vcxproj | 4 ++-- .../CocosDragonJS/proj.win32/CocosDragonJS.vcxproj | 4 ++-- .../CrystalCraze/proj.win32/CrystalCraze.vcxproj | 4 ++-- .../MoonWarriors/proj.win32/MoonWarriors.vcxproj | 4 ++-- .../TestJavascript/proj.win32/TestJavascript.vcxproj | 4 ++-- .../proj.win32/WatermelonWithMe.vcxproj | 4 ++-- samples/Lua/HelloLua/proj.win32/HelloLua.vcxproj | 4 ++-- samples/Lua/TestLua/proj.win32/TestLua.win32.vcxproj | 4 ++-- .../bindings/proj.win32/libJSBinding.vcxproj | 4 ++-- scripting/lua/cocos2dx_support/CCLuaStack.cpp | 1 - scripting/lua/proj.win32/liblua.vcxproj | 8 ++++---- scripting/lua/proj.win32/liblua.vcxproj.filters | 12 ++++++------ .../proj.win32/HelloJavascript.vcxproj | 4 ++-- .../multi-platform-lua/proj.win32/HelloLua.vcxproj | 2 +- 14 files changed, 31 insertions(+), 32 deletions(-) diff --git a/samples/Cpp/AssetsManagerTest/proj.win32/AssetsManagerTest.vcxproj b/samples/Cpp/AssetsManagerTest/proj.win32/AssetsManagerTest.vcxproj index 93de6b0663..fd9e6fcd1a 100644 --- a/samples/Cpp/AssetsManagerTest/proj.win32/AssetsManagerTest.vcxproj +++ b/samples/Cpp/AssetsManagerTest/proj.win32/AssetsManagerTest.vcxproj @@ -77,7 +77,7 @@ Disabled - $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\pthread;$(ProjectDir)..\..\..\..\CocosDenshion\include;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\scripting\auto-generated\js-bindings;$(ProjectDir)..\..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\pthread;$(ProjectDir)..\..\..\..\CocosDenshion\include;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;DEBUG;_DEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_DEBUG=1;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false EnableFastChecks @@ -131,7 +131,7 @@ xcopy "$(ProjectDir)..\Resources" "$(OutDir)\AssetsManagerTestRes\" /e /Yres_p.c - $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\pthread;$(ProjectDir)..\..\..\..\CocosDenshion\include;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\scripting\auto-generated\js-bindings;$(ProjectDir)..\..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\pthread;$(ProjectDir)..\..\..\..\CocosDenshion\include;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;NDEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) diff --git a/samples/Javascript/CocosDragonJS/proj.win32/CocosDragonJS.vcxproj b/samples/Javascript/CocosDragonJS/proj.win32/CocosDragonJS.vcxproj index 76021134e8..b2884c859c 100644 --- a/samples/Javascript/CocosDragonJS/proj.win32/CocosDragonJS.vcxproj +++ b/samples/Javascript/CocosDragonJS/proj.win32/CocosDragonJS.vcxproj @@ -77,7 +77,7 @@ Disabled - $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\CocosDenshion\include;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\scripting\auto-generated\js-bindings;$(ProjectDir)..\..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\CocosDenshion\include;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;_DEBUG;DEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_DEBUG=1;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false EnableFastChecks @@ -131,7 +131,7 @@ xcopy "$(ProjectDir)..\..\Shared\games\CocosDragonJS\Published files Android" "$ testjs_p.c - $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\CocosDenshion\include;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\scripting\auto-generated\js-bindings;$(ProjectDir)..\..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\CocosDenshion\include;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;NDEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;CC_ENABLE_CHIPMUNK_INTEGRATION=1;COCOS2D_JAVASCRIPT=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) diff --git a/samples/Javascript/CrystalCraze/proj.win32/CrystalCraze.vcxproj b/samples/Javascript/CrystalCraze/proj.win32/CrystalCraze.vcxproj index ab6776d024..2acd1a14ef 100644 --- a/samples/Javascript/CrystalCraze/proj.win32/CrystalCraze.vcxproj +++ b/samples/Javascript/CrystalCraze/proj.win32/CrystalCraze.vcxproj @@ -77,7 +77,7 @@ Disabled - $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\CocosDenshion\include;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\scripting\auto-generated\js-bindings;$(ProjectDir)..\..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\CocosDenshion\include;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;_DEBUG;DEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_DEBUG=1;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false EnableFastChecks @@ -131,7 +131,7 @@ xcopy "$(ProjectDir)..\..\Shared\games\CrystalCraze\Published-Android" "$(OutDir testjs_p.c - $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\CocosDenshion\include;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\scripting\auto-generated\js-bindings;$(ProjectDir)..\..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\CocosDenshion\include;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;NDEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;CC_ENABLE_CHIPMUNK_INTEGRATION=1;COCOS2D_JAVASCRIPT=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) diff --git a/samples/Javascript/MoonWarriors/proj.win32/MoonWarriors.vcxproj b/samples/Javascript/MoonWarriors/proj.win32/MoonWarriors.vcxproj index 6824c22522..72876c46f7 100644 --- a/samples/Javascript/MoonWarriors/proj.win32/MoonWarriors.vcxproj +++ b/samples/Javascript/MoonWarriors/proj.win32/MoonWarriors.vcxproj @@ -77,7 +77,7 @@ Disabled - .;..\Classes;$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\CocosDenshion\include;%(AdditionalIncludeDirectories) + .;..\Classes;$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\scripting\auto-generated\js-bindings;$(ProjectDir)..\..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\CocosDenshion\include;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;_DEBUG;DEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_DEBUG=1;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false EnableFastChecks @@ -129,7 +129,7 @@ xcopy "$(ProjectDir)..\..\Shared\games\MoonWarriors" "$(OutDir)\MoonWarriorsRes\ testjs_p.c - .;..\Classes;$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\CocosDenshion\include;%(AdditionalIncludeDirectories) + .;..\Classes;$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\scripting\auto-generated\js-bindings;$(ProjectDir)..\..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\CocosDenshion\include;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;NDEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) diff --git a/samples/Javascript/TestJavascript/proj.win32/TestJavascript.vcxproj b/samples/Javascript/TestJavascript/proj.win32/TestJavascript.vcxproj index da3b2b9fe0..4a2575b30d 100644 --- a/samples/Javascript/TestJavascript/proj.win32/TestJavascript.vcxproj +++ b/samples/Javascript/TestJavascript/proj.win32/TestJavascript.vcxproj @@ -77,7 +77,7 @@ Disabled - $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\CocosDenshion\include;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\..\scripting\auto-generated\js-bindings;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\CocosDenshion\include;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;DEBUG;_DEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_DEBUG=1;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false EnableFastChecks @@ -132,7 +132,7 @@ xcopy "$(ProjectDir)..\..\Shared\tests" "$(OutDir)\TestJavascriptRes\" /e /Ytestjs_p.c - $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\CocosDenshion\include;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\..\scripting\auto-generated\js-bindings;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\CocosDenshion\include;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;NDEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) diff --git a/samples/Javascript/WatermelonWithMe/proj.win32/WatermelonWithMe.vcxproj b/samples/Javascript/WatermelonWithMe/proj.win32/WatermelonWithMe.vcxproj index 9601ebb7f1..7eb13d66cd 100644 --- a/samples/Javascript/WatermelonWithMe/proj.win32/WatermelonWithMe.vcxproj +++ b/samples/Javascript/WatermelonWithMe/proj.win32/WatermelonWithMe.vcxproj @@ -77,7 +77,7 @@ Disabled - $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\CocosDenshion\include;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\scripting\auto-generated\js-bindings;$(ProjectDir)..\..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\CocosDenshion\include;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;_DEBUG;DEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_DEBUG=1;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false EnableFastChecks @@ -131,7 +131,7 @@ xcopy "$(ProjectDir)..\..\Shared\games\WatermelonWithMe" "$(OutDir)\WatermelonWi testjs_p.c - $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\CocosDenshion\include;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\scripting\auto-generated\js-bindings;$(ProjectDir)..\..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\CocosDenshion\include;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;NDEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) diff --git a/samples/Lua/HelloLua/proj.win32/HelloLua.vcxproj b/samples/Lua/HelloLua/proj.win32/HelloLua.vcxproj index d00b43f5d4..7ab70c4ea1 100644 --- a/samples/Lua/HelloLua/proj.win32/HelloLua.vcxproj +++ b/samples/Lua/HelloLua/proj.win32/HelloLua.vcxproj @@ -77,7 +77,7 @@ Disabled - $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\lua\cocos2dx_support;$(ProjectDir)..\..\..\..\scripting\lua\lua;$(ProjectDir)..\..\..\..\scripting\lua\tolua;$(ProjectDir)..\..\..\..\scripting\lua\src;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\CocosDenshion\include;$(ProjectDir)..\..\..\..\extensions;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\auto-generated\lua-bindings;$(ProjectDir)..\..\..\..\scripting\lua\cocos2dx_support;$(ProjectDir)..\..\..\..\scripting\lua\lua;$(ProjectDir)..\..\..\..\scripting\lua\tolua;$(ProjectDir)..\..\..\..\scripting\lua\src;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\CocosDenshion\include;$(ProjectDir)..\..\..\..\extensions;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;_DEBUG;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false EnableFastChecks @@ -119,7 +119,7 @@ HelloLua_p.c - $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\lua\cocos2dx_support;$(ProjectDir)..\..\..\..\scripting\lua\lua;$(ProjectDir)..\..\..\..\scripting\lua\tolua;$(ProjectDir)..\..\..\..\scripting\lua\src;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\CocosDenshion\include;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\auto-generated\lua-bindings;$(ProjectDir)..\..\..\..\scripting\lua\cocos2dx_support;$(ProjectDir)..\..\..\..\scripting\lua\lua;$(ProjectDir)..\..\..\..\scripting\lua\tolua;$(ProjectDir)..\..\..\..\scripting\lua\src;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\CocosDenshion\include;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;NDEBUG;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) diff --git a/samples/Lua/TestLua/proj.win32/TestLua.win32.vcxproj b/samples/Lua/TestLua/proj.win32/TestLua.win32.vcxproj index 770db34824..b0c68e4a86 100644 --- a/samples/Lua/TestLua/proj.win32/TestLua.win32.vcxproj +++ b/samples/Lua/TestLua/proj.win32/TestLua.win32.vcxproj @@ -64,7 +64,7 @@ - $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\lua\cocos2dx_support;$(ProjectDir)..\..\..\..\scripting\lua\lua;$(ProjectDir)..\..\..\..\scripting\lua\tolua;$(ProjectDir)..\..\..\..\scripting\lua\src;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\external;$(ProjectDir)..\..\..\..\external\libwebsockets\win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\CocosDenshion\include;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\auto-generated\lua-bindings;$(ProjectDir)..\..\..\..\scripting\lua\cocos2dx_support;$(ProjectDir)..\..\..\..\scripting\lua\lua;$(ProjectDir)..\..\..\..\scripting\lua\tolua;$(ProjectDir)..\..\..\..\scripting\lua\src;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\external;$(ProjectDir)..\..\..\..\external\libwebsockets\win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\CocosDenshion\include;%(AdditionalIncludeDirectories) Level3 @@ -113,7 +113,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\libwebsockets\win32\lib\*.*" "$(O - $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\lua\cocos2dx_support;$(ProjectDir)..\..\..\..\scripting\lua\lua;$(ProjectDir)..\..\..\..\scripting\lua\tolua;$(ProjectDir)..\..\..\..\scripting\lua\src;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\external;$(ProjectDir)..\..\..\..\external\libwebsockets\win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\CocosDenshion\include;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\auto-generated\lua-bindings;$(ProjectDir)..\..\..\..\scripting\lua\cocos2dx_support;$(ProjectDir)..\..\..\..\scripting\lua\lua;$(ProjectDir)..\..\..\..\scripting\lua\tolua;$(ProjectDir)..\..\..\..\scripting\lua\src;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\external;$(ProjectDir)..\..\..\..\external\libwebsockets\win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\CocosDenshion\include;%(AdditionalIncludeDirectories) Level3 diff --git a/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj b/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj index 454ae6e290..c97fcde24f 100644 --- a/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj +++ b/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj @@ -126,7 +126,7 @@ Level3 Disabled WIN32;_WINDOWS;_DEBUG;_LIB;DEBUG;COCOS2D_DEBUG=1;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - $(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\pthread;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\CocosDenshion\include;$(ProjectDir)..;$(ProjectDir)..\..\spidermonkey-win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\external\libwebsockets\win32\include;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\extensions\LocalStorage;$(ProjectDir)..\..\..\..\extensions\network;%(AdditionalIncludeDirectories) + $(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\pthread;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\CocosDenshion\include;$(ProjectDir)..;$(ProjectDir)..\..\spidermonkey-win32\include;$(ProjectDir)..\..\..\auto-generated\js-bindings;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\external\libwebsockets\win32\include;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\extensions\LocalStorage;$(ProjectDir)..\..\..\..\extensions\network;%(AdditionalIncludeDirectories) 4068;4101;4800;4251;4244;%(DisableSpecificWarnings) true false @@ -149,7 +149,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\sqlite3\libraries\win32\*.*" "$(O true true WIN32;_WINDOWS;NDEBUG;_LIB;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - $(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\pthread;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\CocosDenshion\include;$(ProjectDir)..;$(ProjectDir)..\..\spidermonkey-win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\external\libwebsockets\win32\include;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\extensions\LocalStorage;$(ProjectDir)..\..\..\..\extensions\network;%(AdditionalIncludeDirectories) + $(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\pthread;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\CocosDenshion\include;$(ProjectDir)..;$(ProjectDir)..\..\spidermonkey-win32\include;$(ProjectDir)..\..\..\auto-generated\js-bindings;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\external\libwebsockets\win32\include;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\extensions\LocalStorage;$(ProjectDir)..\..\..\..\extensions\network;%(AdditionalIncludeDirectories) 4068;4101;4800;4251;4244;%(DisableSpecificWarnings) true diff --git a/scripting/lua/cocos2dx_support/CCLuaStack.cpp b/scripting/lua/cocos2dx_support/CCLuaStack.cpp index 085f63f895..edbcb8ff1d 100644 --- a/scripting/lua/cocos2dx_support/CCLuaStack.cpp +++ b/scripting/lua/cocos2dx_support/CCLuaStack.cpp @@ -32,7 +32,6 @@ extern "C" { #include "tolua_fix.h" } -#include "LuaCocos2d.h" #include "Cocos2dxLuaLoader.h" #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) diff --git a/scripting/lua/proj.win32/liblua.vcxproj b/scripting/lua/proj.win32/liblua.vcxproj index dd2ce120c2..55b9ef9815 100644 --- a/scripting/lua/proj.win32/liblua.vcxproj +++ b/scripting/lua/proj.win32/liblua.vcxproj @@ -62,7 +62,7 @@ Disabled - $(ProjectDir)..\..\..\cocos2dx;$(ProjectDir)..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32\pthread;$(ProjectDir)..\..\..\CocosDenshion\include;$(ProjectDir)..\..\..\extensions;$(ProjectDir)..\..\..\extensions\network;$(ProjectDir)..\..\..\external\libwebsockets\win32\include;$(ProjectDir)..\tolua;$(ProjectDir)..\luajit\include;$(ProjectDir)..\cocos2dx_support\generated;$(ProjectDir)..\cocos2dx_support;%(AdditionalIncludeDirectories) + $(ProjectDir)..\..\..\cocos2dx;$(ProjectDir)..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32\pthread;$(ProjectDir)..\..\..\CocosDenshion\include;$(ProjectDir)..\..\..\extensions;$(ProjectDir)..\..\..\extensions\network;$(ProjectDir)..\..\..\external\libwebsockets\win32\include;$(ProjectDir)..\tolua;$(ProjectDir)..\luajit\include;$(ProjectDir)..\..\auto-generated\lua-bindings;$(ProjectDir)..\cocos2dx_support;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;_DEBUG;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false EnableFastChecks @@ -94,7 +94,7 @@ xcopy /Y /Q "$(ProjectDir)..\luajit\win32\*.*" "$(OutDir)" MaxSpeed true - $(ProjectDir)..\..\..\cocos2dx;$(ProjectDir)..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32\pthread;$(ProjectDir)..\..\..\CocosDenshion\include;$(ProjectDir)..\..\..\extensions;$(ProjectDir)..\..\..\extensions\network;$(ProjectDir)..\..\..\external\libwebsockets\win32\include;$(ProjectDir)..\tolua;$(ProjectDir)..\luajit\include;%(AdditionalIncludeDirectories) + $(ProjectDir)..\..\..\cocos2dx;$(ProjectDir)..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32\pthread;$(ProjectDir)..\..\..\CocosDenshion\include;$(ProjectDir)..\..\..\extensions;$(ProjectDir)..\..\..\extensions\network;$(ProjectDir)..\..\..\external\libwebsockets\win32\include;$(ProjectDir)..\tolua;$(ProjectDir)..\luajit\include;$(ProjectDir)..\..\auto-generated\lua-bindings;$(ProjectDir)..\cocos2dx_support;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;LIBLUA_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreadedDLL true @@ -131,10 +131,10 @@ xcopy /Y /Q "$(ProjectDir)..\luajit\win32\*.*" "$(OutDir)" - + @@ -156,10 +156,10 @@ xcopy /Y /Q "$(ProjectDir)..\luajit\win32\*.*" "$(OutDir)" - + diff --git a/scripting/lua/proj.win32/liblua.vcxproj.filters b/scripting/lua/proj.win32/liblua.vcxproj.filters index 1005cce19a..7d9abe41e4 100644 --- a/scripting/lua/proj.win32/liblua.vcxproj.filters +++ b/scripting/lua/proj.win32/liblua.vcxproj.filters @@ -39,9 +39,6 @@ cocos2dx_support - - cocos2dx_support - cocos2dx_support @@ -87,6 +84,9 @@ cocos2dx_support\generated + + cocos2dx_support + @@ -101,9 +101,6 @@ cocos2dx_support - - cocos2dx_support - cocos2dx_support @@ -161,6 +158,9 @@ cocos2dx_support\generated + + cocos2dx_support + diff --git a/template/multi-platform-js/proj.win32/HelloJavascript.vcxproj b/template/multi-platform-js/proj.win32/HelloJavascript.vcxproj index 9a800ef063..783c66698e 100644 --- a/template/multi-platform-js/proj.win32/HelloJavascript.vcxproj +++ b/template/multi-platform-js/proj.win32/HelloJavascript.vcxproj @@ -77,7 +77,7 @@ Disabled - $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\extensions;$(ProjectDir)..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\cocos2dx;$(ProjectDir)..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\CocosDenshion\include;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\extensions;$(ProjectDir)..\..\..\scripting\auto-generated\js-bindings;$(ProjectDir)..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\cocos2dx;$(ProjectDir)..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\CocosDenshion\include;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;DEBUG;_DEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_DEBUG=1;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false EnableFastChecks @@ -131,7 +131,7 @@ xcopy "$(ProjectDir)..\Resources" "$(OutDir)\HelloJavascriptRes\" /e /Ygame_p.c - $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\extensions;$(ProjectDir)..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\cocos2dx;$(ProjectDir)..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\CocosDenshion\include;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\scripting\javascript\spidermonkey-win32\include;$(ProjectDir)..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\extensions;$(ProjectDir)..\..\..\scripting\auto-generated\js-bindings;$(ProjectDir)..\..\..\scripting\javascript\bindings;$(ProjectDir)..\..\..\cocos2dx;$(ProjectDir)..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\CocosDenshion\include;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;NDEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) diff --git a/template/multi-platform-lua/proj.win32/HelloLua.vcxproj b/template/multi-platform-lua/proj.win32/HelloLua.vcxproj index da44296fff..db2f03d387 100644 --- a/template/multi-platform-lua/proj.win32/HelloLua.vcxproj +++ b/template/multi-platform-lua/proj.win32/HelloLua.vcxproj @@ -64,7 +64,7 @@ - $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\scripting\lua\cocos2dx_support;$(ProjectDir)..\..\..\scripting\lua\lua;$(ProjectDir)..\..\..\scripting\lua\tolua;$(ProjectDir)..\..\..\scripting\lua\src;$(ProjectDir)..\..\..\cocos2dx;$(ProjectDir)..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\external;$(ProjectDir)..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\CocosDenshion\include;$(ProjectDir)..\..\..\scripting\lua\cocos2dx_support;$(ProjectDir)..\..\..\scripting\lua\tolua;$(ProjectDir)..\..\..\scripting\lua\lua;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\scripting\auto-generated\js-bindings;$(ProjectDir)..\..\..\scripting\lua\cocos2dx_support;$(ProjectDir)..\..\..\scripting\lua\lua;$(ProjectDir)..\..\..\scripting\lua\tolua;$(ProjectDir)..\..\..\scripting\lua\src;$(ProjectDir)..\..\..\cocos2dx;$(ProjectDir)..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\external;$(ProjectDir)..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\CocosDenshion\include;%(AdditionalIncludeDirectories) Level3 From 7523a6e685bb08a86ef61cd7b019a5b6c6da5158 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 27 Aug 2013 16:47:06 +0800 Subject: [PATCH 115/126] issue #2732: Removing unused files (LuaCocos2d.cpp/.h). --- .../cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id | 1 - scripting/lua/cocos2dx_support/LuaCocos2d.h | 14 -------------- 2 files changed, 15 deletions(-) delete mode 100644 scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id delete mode 100644 scripting/lua/cocos2dx_support/LuaCocos2d.h diff --git a/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id deleted file mode 100644 index 7703975b38..0000000000 --- a/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -b301dd3607b8b0142ecf3fc016dd7dad2aa86094 \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/LuaCocos2d.h b/scripting/lua/cocos2dx_support/LuaCocos2d.h deleted file mode 100644 index 5f45ab53ea..0000000000 --- a/scripting/lua/cocos2dx_support/LuaCocos2d.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef __LUACOCOS2D_H_ -#define __LUACOCOS2D_H_ - -#ifdef __cplusplus -extern "C" { -#endif -#include "tolua++.h" -#ifdef __cplusplus -} -#endif - -TOLUA_API int tolua_Cocos2d_open(lua_State* tolua_S); - -#endif // __LUACOCOS2D_H_ From eb2335952c6a99b32755eb228a608c992131d75e Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 27 Aug 2013 16:52:39 +0800 Subject: [PATCH 116/126] issue #2732: [iOS, Mac] Removing unused files (LuaCocos2d.cpp/.h). --- cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id b/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id index 89ce949321..9c0cf28357 100644 --- a/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -9bf893fd31bf044ec732332fb109c050b711fdc8 \ No newline at end of file +dcaf07070ad651b671d721564b6d1aa99ea03d0b \ No newline at end of file From 64ab842a74d765f3afcc6e9e294ea40feb39c04d Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 27 Aug 2013 16:53:41 +0800 Subject: [PATCH 117/126] issue #2732: [iOS]Adding 'scripting/auto-generated/js(lua)-bindings' to search path of include files. --- .../proj.ios/HelloJavascript.xcodeproj/project.pbxproj | 2 ++ .../proj.ios/HelloLua.xcodeproj/project.pbxproj | 2 ++ 2 files changed, 4 insertions(+) diff --git a/template/multi-platform-js/proj.ios/HelloJavascript.xcodeproj/project.pbxproj b/template/multi-platform-js/proj.ios/HelloJavascript.xcodeproj/project.pbxproj index 5f0ecf7c0d..5eca11ad36 100644 --- a/template/multi-platform-js/proj.ios/HelloJavascript.xcodeproj/project.pbxproj +++ b/template/multi-platform-js/proj.ios/HelloJavascript.xcodeproj/project.pbxproj @@ -683,6 +683,7 @@ "$(SRCROOT)/../../../cocos2dx/platform/ios", "$(SRCROOT)/../../../external/chipmunk/include/chipmunk", "$(SRCROOT)/../../../scripting/javascript/spidermonkey-ios/include", + "$(SRCROOT)/../../../scripting/auto-generated/js-bindings", "$(SRCROOT)/../../../scripting/javascript/bindings", "$(SRCROOT)/../../../extensions", ); @@ -732,6 +733,7 @@ "$(SRCROOT)/../../../cocos2dx/platform/ios", "$(SRCROOT)/../../../external/chipmunk/include/chipmunk", "$(SRCROOT)/../../../scripting/javascript/spidermonkey-ios/include", + "$(SRCROOT)/../../../scripting/auto-generated/js-bindings", "$(SRCROOT)/../../../scripting/javascript/bindings", "$(SRCROOT)/../../../extensions", ); diff --git a/template/multi-platform-lua/proj.ios/HelloLua.xcodeproj/project.pbxproj b/template/multi-platform-lua/proj.ios/HelloLua.xcodeproj/project.pbxproj index 80b06ce627..54e8902814 100644 --- a/template/multi-platform-lua/proj.ios/HelloLua.xcodeproj/project.pbxproj +++ b/template/multi-platform-lua/proj.ios/HelloLua.xcodeproj/project.pbxproj @@ -715,6 +715,7 @@ "\"$(SRCROOT)/../../../cocos2dx/kazmath/include\"", "\"$(SRCROOT)/../../../scripting/lua/tolua\"", "\"$(SRCROOT)/../../../scripting/lua/luajit/include\"", + "\"$(SRCROOT)/../../../scripting/auto-generated/lua-bindings\"", "\"$(SRCROOT)/../../../scripting/lua/cocos2dx_support\"", "\"$(SRCROOT)/../../../cocos2dx/platform/ios\"", "\"$(SRCROOT)/../../../cocos2dx/include\"", @@ -765,6 +766,7 @@ "\"$(SRCROOT)/../../../cocos2dx/kazmath/include\"", "\"$(SRCROOT)/../../../scripting/lua/tolua\"", "\"$(SRCROOT)/../../../scripting/lua/luajit/include\"", + "\"$(SRCROOT)/../../../scripting/auto-generated/lua-bindings\"", "\"$(SRCROOT)/../../../scripting/lua/cocos2dx_support\"", "\"$(SRCROOT)/../../../cocos2dx/platform/ios\"", "\"$(SRCROOT)/../../../cocos2dx/include\"", From 0e1770ca82ab46c5db30088e6c9d8452dfbd5b46 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 27 Aug 2013 16:57:10 +0800 Subject: [PATCH 118/126] issue #2732: [iOS] Adding 'Cocos2d.lua". --- .../proj.ios/HelloLua.xcodeproj/project.pbxproj | 4 ++++ .../proj.mac/HelloLua.xcodeproj/project.pbxproj | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/template/multi-platform-lua/proj.ios/HelloLua.xcodeproj/project.pbxproj b/template/multi-platform-lua/proj.ios/HelloLua.xcodeproj/project.pbxproj index 54e8902814..d0908f894c 100644 --- a/template/multi-platform-lua/proj.ios/HelloLua.xcodeproj/project.pbxproj +++ b/template/multi-platform-lua/proj.ios/HelloLua.xcodeproj/project.pbxproj @@ -34,6 +34,7 @@ 1AC3623816D47C5C000847F2 /* land.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AC3622C16D47C5C000847F2 /* land.png */; }; 1AC3623916D47C5C000847F2 /* menu1.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AC3622D16D47C5C000847F2 /* menu1.png */; }; 1AC3623A16D47C5C000847F2 /* menu2.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AC3622E16D47C5C000847F2 /* menu2.png */; }; + 1ADB273817CCA0C200634B5E /* Cocos2d.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1ADB273717CCA0C200634B5E /* Cocos2d.lua */; }; 1AF4C3F21786633E00122817 /* libchipmunk iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AF4C3DF1786631700122817 /* libchipmunk iOS.a */; }; 1AF4C3F31786633E00122817 /* libcocos2dx iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AF4C3DB1786631700122817 /* libcocos2dx iOS.a */; }; 1AF4C3F41786633E00122817 /* libcocos2dx-extensions iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AF4C3DD1786631700122817 /* libcocos2dx-extensions iOS.a */; }; @@ -218,6 +219,7 @@ 1AC3622C16D47C5C000847F2 /* land.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = land.png; path = ../Resources/land.png; sourceTree = ""; }; 1AC3622D16D47C5C000847F2 /* menu1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = menu1.png; path = ../Resources/menu1.png; sourceTree = ""; }; 1AC3622E16D47C5C000847F2 /* menu2.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = menu2.png; path = ../Resources/menu2.png; sourceTree = ""; }; + 1ADB273717CCA0C200634B5E /* Cocos2d.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = Cocos2d.lua; path = ../../../scripting/lua/script/Cocos2d.lua; sourceTree = ""; }; 1AF4C3B8178662A500122817 /* Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Prefix.pch; sourceTree = ""; }; 1AF4C3B91786631600122817 /* cocos2d_libs.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = cocos2d_libs.xcodeproj; path = ../../../cocos2d_libs.xcodeproj; sourceTree = ""; }; 1AF4C402178663F200122817 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; }; @@ -270,6 +272,7 @@ children = ( 1A0227A517A3AA3500B867AD /* AudioEngine.lua */, 1A0227A617A3AA3500B867AD /* CCBReaderLoad.lua */, + 1ADB273717CCA0C200634B5E /* Cocos2d.lua */, 1A0227A717A3AA3500B867AD /* Cocos2dConstants.lua */, 1A0227A817A3AA3500B867AD /* Deprecated.lua */, 1A0227A917A3AA3500B867AD /* DrawPrimitives.lua */, @@ -575,6 +578,7 @@ 1A0227B017A3AA3500B867AD /* DrawPrimitives.lua in Resources */, 1A0227B117A3AA3500B867AD /* Opengl.lua in Resources */, 1A0227B217A3AA3500B867AD /* OpenglConstants.lua in Resources */, + 1ADB273817CCA0C200634B5E /* Cocos2d.lua in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/template/multi-platform-lua/proj.mac/HelloLua.xcodeproj/project.pbxproj b/template/multi-platform-lua/proj.mac/HelloLua.xcodeproj/project.pbxproj index 5aab5d9d64..d38a6e4642 100644 --- a/template/multi-platform-lua/proj.mac/HelloLua.xcodeproj/project.pbxproj +++ b/template/multi-platform-lua/proj.mac/HelloLua.xcodeproj/project.pbxproj @@ -46,6 +46,7 @@ 15A02F7517A64DFB0035E92B /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 15A02F6F17A64DFB0035E92B /* main.m */; }; 15A02F7B17A64E2A0035E92B /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 15A02F7717A64E2A0035E92B /* InfoPlist.strings */; }; 15A02F7C17A64E2A0035E92B /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 15A02F7917A64E2A0035E92B /* MainMenu.xib */; }; + 1ADB273B17CCA0F500634B5E /* Cocos2d.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1ADB273A17CCA0F500634B5E /* Cocos2d.lua */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -224,6 +225,7 @@ 15A02F7A17A64E2A0035E92B /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = MainMenu.xib; sourceTree = ""; }; 15A02F7D17A64EF30035E92B /* Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Prefix.pch; sourceTree = ""; }; 15A02FAA17A65D810035E92B /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; }; + 1ADB273A17CCA0F500634B5E /* Cocos2d.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Cocos2d.lua; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -256,6 +258,7 @@ children = ( 1501825217A74F8000E674E5 /* AudioEngine.lua */, 1501825317A74F8000E674E5 /* CCBReaderLoad.lua */, + 1ADB273A17CCA0F500634B5E /* Cocos2d.lua */, 1501825417A74F8000E674E5 /* Cocos2dConstants.lua */, 1501825517A74F8000E674E5 /* Deprecated.lua */, 1501825617A74F8000E674E5 /* DrawPrimitives.lua */, @@ -561,6 +564,7 @@ 1501825D17A74F8000E674E5 /* DrawPrimitives.lua in Resources */, 1501825E17A74F8000E674E5 /* Opengl.lua in Resources */, 1501825F17A74F8000E674E5 /* OpenglConstants.lua in Resources */, + 1ADB273B17CCA0F500634B5E /* Cocos2d.lua in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; From 16a8e1d92e262a02d420c964ffbc6285a04f275d Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 27 Aug 2013 17:20:12 +0800 Subject: [PATCH 119/126] issue #2732: [Linux, Emscripten] Updating Makefile. --- scripting/lua/proj.emscripten/Makefile | 7 +++---- scripting/lua/proj.linux/Makefile | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/scripting/lua/proj.emscripten/Makefile b/scripting/lua/proj.emscripten/Makefile index 3a68b6b2ab..472a139433 100644 --- a/scripting/lua/proj.emscripten/Makefile +++ b/scripting/lua/proj.emscripten/Makefile @@ -1,6 +1,6 @@ TARGET = liblua.so -INCLUDES += -I.. -I../lua -I../tolua -I../cocos2dx_support -I../cocos2dx_support/generated \ +INCLUDES += -I.. -I../lua -I../tolua -I../cocos2dx_support -I../../auto-generated/lua-bindings \ -I../Classes -I../../../CocosDenshion/include -I../../../extensions SOURCES = ../lua/lapi.o \ @@ -44,15 +44,14 @@ SOURCES = ../lua/lapi.o \ ../cocos2dx_support/CCLuaStack.cpp \ ../cocos2dx_support/CCLuaValue.cpp \ ../cocos2dx_support/Cocos2dxLuaLoader.cpp \ - ../cocos2dx_support/LuaCocos2d.cpp \ ../cocos2dx_support/CCBProxy.cpp \ ../cocos2dx_support/Lua_extensions_CCB.cpp \ ../cocos2dx_support/LuaOpengl.cpp \ ../cocos2dx_support/LuaScrollView.cpp \ ../cocos2dx_support/LuaScriptHandlerMgr.cpp \ ../cocos2dx_support/LuaBasicConversions.cpp \ - ../cocos2dx_support/generated/lua_cocos2dx_auto.cpp \ - ../cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp \ + ../../auto-generated/lua-bindings/lua_cocos2dx_auto.cpp \ + ../../auto-generated/lua-bindings/lua_cocos2dx_extension_auto.cpp \ ../cocos2dx_support/lua_cocos2dx_manual.cpp \ ../cocos2dx_support/lua_cocos2dx_extension_manual.cpp \ ../cocos2dx_support/lua_cocos2dx_deprecated.cpp diff --git a/scripting/lua/proj.linux/Makefile b/scripting/lua/proj.linux/Makefile index 7bf87661c1..79cc15e845 100644 --- a/scripting/lua/proj.linux/Makefile +++ b/scripting/lua/proj.linux/Makefile @@ -1,6 +1,6 @@ TARGET = liblua.so -INCLUDES += -I.. -I../lua -I../tolua -I../cocos2dx_support -I../cocos2dx_support/generated \ +INCLUDES += -I.. -I../lua -I../tolua -I../cocos2dx_support -I../../auto-generated/lua-bindings \ -I../Classes -I../../../CocosDenshion/include -I../../../extensions -I../../../external/chipmunk/include/chipmunk SOURCES = ../lua/lapi.o \ @@ -44,15 +44,14 @@ SOURCES = ../lua/lapi.o \ ../cocos2dx_support/CCLuaStack.cpp \ ../cocos2dx_support/CCLuaValue.cpp \ ../cocos2dx_support/Cocos2dxLuaLoader.cpp \ - ../cocos2dx_support/LuaCocos2d.cpp \ ../cocos2dx_support/CCBProxy.cpp \ ../cocos2dx_support/Lua_extensions_CCB.cpp \ ../cocos2dx_support/LuaOpengl.cpp \ ../cocos2dx_support/LuaScrollView.cpp \ ../cocos2dx_support/LuaScriptHandlerMgr.cpp \ ../cocos2dx_support/LuaBasicConversions.cpp \ - ../cocos2dx_support/generated/lua_cocos2dx_auto.cpp \ - ../cocos2dx_support/generated/lua_cocos2dx_extension_auto.cpp \ + ../../auto-generated/lua-bindings/lua_cocos2dx_auto.cpp \ + ../../auto-generated/lua-bindings/lua_cocos2dx_extension_auto.cpp \ ../cocos2dx_support/lua_cocos2dx_manual.cpp \ ../cocos2dx_support/lua_cocos2dx_extension_manual.cpp \ ../cocos2dx_support/lua_cocos2dx_deprecated.cpp From 935222f27cefa1f8856052cd471c5fc810f50312 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 27 Aug 2013 17:20:40 +0800 Subject: [PATCH 120/126] issue #2732: Adding 'tools/tolua/userconf.ini' to ignore list. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index da34e166e5..3c208646e4 100644 --- a/.gitignore +++ b/.gitignore @@ -89,6 +89,7 @@ projects/ tools/tojs/user.cfg # ... userconf.ini generated if running from tools/tojs tools/tojs/userconf.ini +tools/tolua/userconf.ini # ... userconf.ini generated if running from tools/jenkins_scripts/mac/android/ tools/jenkins_scripts/mac/android/userconf.ini From 78d8576a3aac3402afa084057bb9b8f46c327fac Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 27 Aug 2013 21:40:29 +0800 Subject: [PATCH 121/126] closed #2732: [Linux emscripten] Updating Makefile. --- scripting/lua/proj.emscripten/Makefile | 10 +++++++--- scripting/lua/proj.linux/Makefile | 11 ++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/scripting/lua/proj.emscripten/Makefile b/scripting/lua/proj.emscripten/Makefile index 472a139433..b51ef3de8b 100644 --- a/scripting/lua/proj.emscripten/Makefile +++ b/scripting/lua/proj.emscripten/Makefile @@ -3,7 +3,7 @@ TARGET = liblua.so INCLUDES += -I.. -I../lua -I../tolua -I../cocos2dx_support -I../../auto-generated/lua-bindings \ -I../Classes -I../../../CocosDenshion/include -I../../../extensions -SOURCES = ../lua/lapi.o \ +SOURCES = ../lua/lapi.c \ ../lua/lauxlib.c \ ../lua/lbaselib.c \ ../lua/lcode.c \ @@ -39,6 +39,8 @@ SOURCES = ../lua/lapi.o \ ../tolua/tolua_push.c \ ../tolua/tolua_to.c \ ../cocos2dx_support/tolua_fix.c \ + ../../auto-generated/lua-bindings/lua_cocos2dx_auto.cpp \ + ../../auto-generated/lua-bindings/lua_cocos2dx_extension_auto.cpp \ ../cocos2dx_support/CCLuaBridge.cpp \ ../cocos2dx_support/CCLuaEngine.cpp \ ../cocos2dx_support/CCLuaStack.cpp \ @@ -50,8 +52,6 @@ SOURCES = ../lua/lapi.o \ ../cocos2dx_support/LuaScrollView.cpp \ ../cocos2dx_support/LuaScriptHandlerMgr.cpp \ ../cocos2dx_support/LuaBasicConversions.cpp \ - ../../auto-generated/lua-bindings/lua_cocos2dx_auto.cpp \ - ../../auto-generated/lua-bindings/lua_cocos2dx_extension_auto.cpp \ ../cocos2dx_support/lua_cocos2dx_manual.cpp \ ../cocos2dx_support/lua_cocos2dx_extension_manual.cpp \ ../cocos2dx_support/lua_cocos2dx_deprecated.cpp @@ -66,6 +66,10 @@ $(TARGET): $(OBJECTS) $(CORE_MAKEFILE_LIST) @mkdir -p $(@D) $(CXX) $(CXXFLAGS) $(OBJECTS) -shared -o $@ $(SHAREDLIBS) $(STATICLIBS) +$(OBJ_DIR)/%.o: ../../%.cpp $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ + $(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST) @mkdir -p $(@D) $(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ diff --git a/scripting/lua/proj.linux/Makefile b/scripting/lua/proj.linux/Makefile index 79cc15e845..4913da40bc 100644 --- a/scripting/lua/proj.linux/Makefile +++ b/scripting/lua/proj.linux/Makefile @@ -3,7 +3,7 @@ TARGET = liblua.so INCLUDES += -I.. -I../lua -I../tolua -I../cocos2dx_support -I../../auto-generated/lua-bindings \ -I../Classes -I../../../CocosDenshion/include -I../../../extensions -I../../../external/chipmunk/include/chipmunk -SOURCES = ../lua/lapi.o \ +SOURCES = ../lua/lapi.c \ ../lua/lauxlib.c \ ../lua/lbaselib.c \ ../lua/lcode.c \ @@ -39,6 +39,8 @@ SOURCES = ../lua/lapi.o \ ../tolua/tolua_push.c \ ../tolua/tolua_to.c \ ../cocos2dx_support/tolua_fix.c \ + ../../auto-generated/lua-bindings/lua_cocos2dx_auto.cpp \ + ../../auto-generated/lua-bindings/lua_cocos2dx_extension_auto.cpp \ ../cocos2dx_support/CCLuaBridge.cpp \ ../cocos2dx_support/CCLuaEngine.cpp \ ../cocos2dx_support/CCLuaStack.cpp \ @@ -50,12 +52,11 @@ SOURCES = ../lua/lapi.o \ ../cocos2dx_support/LuaScrollView.cpp \ ../cocos2dx_support/LuaScriptHandlerMgr.cpp \ ../cocos2dx_support/LuaBasicConversions.cpp \ - ../../auto-generated/lua-bindings/lua_cocos2dx_auto.cpp \ - ../../auto-generated/lua-bindings/lua_cocos2dx_extension_auto.cpp \ ../cocos2dx_support/lua_cocos2dx_manual.cpp \ ../cocos2dx_support/lua_cocos2dx_extension_manual.cpp \ ../cocos2dx_support/lua_cocos2dx_deprecated.cpp + include ../../../cocos2dx/proj.linux/cocos2dx.mk TARGET := $(LIB_DIR)/$(TARGET) @@ -67,6 +68,10 @@ $(TARGET): $(OBJECTS) $(CORE_MAKEFILE_LIST) @mkdir -p $(@D) $(LOG_LINK)$(CXX) $(CXXFLAGS) $(OBJECTS) -shared -o $@ $(SHAREDLIBS) $(STATICLIBS) +$(OBJ_DIR)/%.o: ../../%.cpp $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ + $(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST) @mkdir -p $(@D) $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ From 384bf0007050a1d5ffc490e22c6627622e77fcdc Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 27 Aug 2013 21:52:06 +0800 Subject: [PATCH 122/126] issue #2732: Updating travis script. Linux port needs to generate luabinding codes. --- tools/travis-scripts/before-install.sh | 2 ++ tools/travis-scripts/run-script.sh | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/tools/travis-scripts/before-install.sh b/tools/travis-scripts/before-install.sh index 07ff3e10a2..f3d350e93c 100755 --- a/tools/travis-scripts/before-install.sh +++ b/tools/travis-scripts/before-install.sh @@ -103,6 +103,7 @@ elif [ "$PLATFORM"x = "linux"x ]; then sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.7 90 --slave /usr/bin/g++ g++ /usr/bin/g++-4.7 g++ --version bash $COCOS2DX_ROOT/install-deps-linux.sh + install_android_ndk elif [ "$PLATFORM"x = "nacl"x ]; then install_nacl_sdk elif [ "$PLATFORM"x = "android"x ]; then @@ -110,6 +111,7 @@ elif [ "$PLATFORM"x = "android"x ]; then install_llvm elif [ "$PLATFORM"x = "emscripten"x ]; then sudo rm -rf /dev/shm && sudo ln -s /run/shm /dev/shm + install_android_ndk install_llvm_3_2 elif [ "$PLATFORM"x = "ios"x ]; then install_android_ndk diff --git a/tools/travis-scripts/run-script.sh b/tools/travis-scripts/run-script.sh index 87e3379de3..79c063dc0e 100755 --- a/tools/travis-scripts/run-script.sh +++ b/tools/travis-scripts/run-script.sh @@ -41,8 +41,8 @@ if [ "$GEN_JSB"x = "YES"x ]; then elif [ "$PLATFORM"x = "android"x ]; then export NDK_ROOT=$HOME/bin/android-ndk - # Generate jsbinding glue codes - echo "Generating jsbindings glue codes ..." + # Generate binding glue codes + echo "Generating bindings glue codes ..." cd $COCOS2DX_ROOT/tools/travis-scripts ./generate-jsbindings.sh @@ -83,9 +83,19 @@ elif [ "$PLATFORM"x = "nacl"x ]; then cd $COCOS2DX_ROOT make -j4 elif [ "$PLATFORM"x = "linux"x ]; then + # Generate binding glue codes + echo "Generating bindings glue codes ..." + cd $COCOS2DX_ROOT/tools/travis-scripts + ./generate-jsbindings.sh + cd $COCOS2DX_ROOT make -j4 elif [ "$PLATFORM"x = "emscripten"x ]; then + # Generate binding glue codes + echo "Generating bindings glue codes ..." + cd $COCOS2DX_ROOT/tools/travis-scripts + ./generate-jsbindings.sh + cd $COCOS2DX_ROOT export PYTHON=/usr/bin/python export LLVM=$HOME/bin/clang+llvm-3.2/bin From f3e0775cef16a6d232b240e50db103931be766d8 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 27 Aug 2013 22:04:08 +0800 Subject: [PATCH 123/126] issue #2732: [travis ci] install llvm for linux. --- tools/travis-scripts/before-install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/travis-scripts/before-install.sh b/tools/travis-scripts/before-install.sh index f3d350e93c..36898f2eee 100755 --- a/tools/travis-scripts/before-install.sh +++ b/tools/travis-scripts/before-install.sh @@ -104,6 +104,7 @@ elif [ "$PLATFORM"x = "linux"x ]; then g++ --version bash $COCOS2DX_ROOT/install-deps-linux.sh install_android_ndk + install_llvm elif [ "$PLATFORM"x = "nacl"x ]; then install_nacl_sdk elif [ "$PLATFORM"x = "android"x ]; then From fbfb4d1002a21c553da81c77a1c2900cf947bce2 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Tue, 27 Aug 2013 15:42:55 +0000 Subject: [PATCH 124/126] [AUTO] : updating submodule reference to latest autogenerated bindings --- scripting/auto-generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripting/auto-generated b/scripting/auto-generated index 5b4a4c5b94..d124fe684b 160000 --- a/scripting/auto-generated +++ b/scripting/auto-generated @@ -1 +1 @@ -Subproject commit 5b4a4c5b94ba4920a70900d47246612adcdc0ac5 +Subproject commit d124fe684b95f4434b3582dbb74b652f550abbd9 From 275d719edec10776c48e72109883da8ed8b1b75b Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Wed, 28 Aug 2013 02:16:33 +0000 Subject: [PATCH 125/126] [AUTO] : updating submodule reference to latest autogenerated bindings --- scripting/auto-generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripting/auto-generated b/scripting/auto-generated index d124fe684b..bd70d439fe 160000 --- a/scripting/auto-generated +++ b/scripting/auto-generated @@ -1 +1 @@ -Subproject commit d124fe684b95f4434b3582dbb74b652f550abbd9 +Subproject commit bd70d439fec3629bf0acab52e5c059031c2d1372 From 498d8d9e6d14cd490351a05988514ad3e20411b7 Mon Sep 17 00:00:00 2001 From: shinriyo Date: Wed, 28 Aug 2013 11:53:18 +0900 Subject: [PATCH 126/126] Python2.x 3.x runnable For Python2.x 3.x runnable, I used print() --- tools/project_creator/create_project.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/project_creator/create_project.py b/tools/project_creator/create_project.py index 728a068ecd..6ea0ff13f8 100755 --- a/tools/project_creator/create_project.py +++ b/tools/project_creator/create_project.py @@ -72,8 +72,8 @@ def checkParams(): context["src_package_name"] = "org.cocos2dx.hellojavascript" context["src_project_path"] = os.path.join(template_dir, "multi-platform-js") else: - print "Your language parameter doesn\'t exist." \ - "Check correct language option\'s parameter" + print ("Your language parameter doesn\'t exist." \ + "Check correct language option\'s parameter") sys.exit() platforms_list = PLATFORMS.get(context["language"], []) return context, platforms_list