diff --git a/AUTHORS b/AUTHORS index 1d70fcaeb5..59204c5e69 100644 --- a/AUTHORS +++ b/AUTHORS @@ -414,6 +414,7 @@ Developers: Added some guards to prevent Eclipse to compile twice the same class. Linux Eclipse projects updates Refactored emscripten-build.sh, it's no longer need to be edited to make emscripten work. + Use of a single emscripten HTML template file. elmiro Correction of passed buffer size to readlink and verification of result return by readlink. @@ -552,6 +553,12 @@ Retired Core Developers: michaelcontento [Android] use onWindowFocusChanged(bool) instead of onResume()/onPause() + + bmanGH + Use gl caching functions in TexturePVR::createGLTexture() + + metadao + make create_project.py more pythonic and fix some typoes Cocos2d-x can not grow so fast without the active community. diff --git a/cocos2dx/CCDirector.cpp b/cocos2dx/CCDirector.cpp index 2e2e9d1c27..5a916fe678 100644 --- a/cocos2dx/CCDirector.cpp +++ b/cocos2dx/CCDirector.cpp @@ -963,7 +963,7 @@ void Director::setScheduler(Scheduler* pScheduler) } } -Scheduler* Director::getScheduler() +Scheduler* Director::getScheduler() const { return _scheduler; } @@ -978,7 +978,7 @@ void Director::setActionManager(ActionManager* pActionManager) } } -ActionManager* Director::getActionManager() +ActionManager* Director::getActionManager() const { return _actionManager; } @@ -993,7 +993,7 @@ void Director::setTouchDispatcher(TouchDispatcher* pTouchDispatcher) } } -TouchDispatcher* Director::getTouchDispatcher() +TouchDispatcher* Director::getTouchDispatcher() const { return _touchDispatcher; } @@ -1005,7 +1005,7 @@ void Director::setKeyboardDispatcher(KeyboardDispatcher* pKeyboardDispatcher) _keyboardDispatcher = pKeyboardDispatcher; } -KeyboardDispatcher* Director::getKeyboardDispatcher() +KeyboardDispatcher* Director::getKeyboardDispatcher() const { return _keyboardDispatcher; } @@ -1017,7 +1017,7 @@ void Director::setKeypadDispatcher(KeypadDispatcher* pKeypadDispatcher) _keypadDispatcher = pKeypadDispatcher; } -KeypadDispatcher* Director::getKeypadDispatcher() +KeypadDispatcher* Director::getKeypadDispatcher() const { return _keypadDispatcher; } @@ -1031,7 +1031,7 @@ void Director::setAccelerometer(Accelerometer* pAccelerometer) } } -Accelerometer* Director::getAccelerometer() +Accelerometer* Director::getAccelerometer() const { return _accelerometer; } diff --git a/cocos2dx/CCDirector.h b/cocos2dx/CCDirector.h index a963de89f1..3def5eac2a 100644 --- a/cocos2dx/CCDirector.h +++ b/cocos2dx/CCDirector.h @@ -318,39 +318,70 @@ public: float getContentScaleFactor(void) const; public: - /** Scheduler associated with this director + /** Gets the Scheduler associated with this director @since v2.0 */ - CC_PROPERTY(Scheduler*, _scheduler, Scheduler); - - /** ActionManager associated with this director + Scheduler* getScheduler() const; + + /** Sets the Scheduler associated with this director @since v2.0 */ - CC_PROPERTY(ActionManager*, _actionManager, ActionManager); + void setScheduler(Scheduler* scheduler); - /** TouchDispatcher associated with this director + /** Gets the ActionManager associated with this director @since v2.0 */ - CC_PROPERTY(TouchDispatcher*, _touchDispatcher, TouchDispatcher); + ActionManager* getActionManager() const; + + /** Sets the ActionManager associated with this director + @since v2.0 + */ + void setActionManager(ActionManager* actionManager); + + /** Gets the TouchDispatcher associated with this director + @since v2.0 + */ + TouchDispatcher* getTouchDispatcher() const; + + /** Sets the TouchDispatcher associated with this director + @since v2.0 + */ + void setTouchDispatcher(TouchDispatcher* touchDispatcher); - /** KeyboardDispatcher associated with this director + /** Gets the KeyboardDispatcher associated with this director @note Supported on Mac and Linux only now. @since v3.0 */ - CC_PROPERTY(KeyboardDispatcher*, _keyboardDispatcher, KeyboardDispatcher); + KeyboardDispatcher* getKeyboardDispatcher() const; - /** KeypadDispatcher associated with this director + /** Sets the KeyboardDispatcher associated with this director + @note Supported on Mac and Linux only now. + @since v3.0 + */ + void setKeyboardDispatcher(KeyboardDispatcher* keyboardDispatcher); + + /** Gets the KeypadDispatcher associated with this director @since v2.0 */ - CC_PROPERTY(KeypadDispatcher*, _keypadDispatcher, KeypadDispatcher); + KeypadDispatcher* getKeypadDispatcher() const; - /** Accelerometer associated with this director + /** Sets the KeypadDispatcher associated with this director @since v2.0 */ - CC_PROPERTY(Accelerometer*, _accelerometer, Accelerometer); + void setKeypadDispatcher(KeypadDispatcher* keypadDispatcher); + + /** Gets Accelerometer associated with this director + @since v2.0 + */ + Accelerometer* getAccelerometer() const; + + /** Sets Accelerometer associated with this director + @since v2.0 + */ + void setAccelerometer(Accelerometer* acc); - /* delta time since last tick to main loop */ - CC_PROPERTY_READONLY(float, _deltaTime, DeltaTime); + /* Gets delta time since last tick to main loop */ + float getDeltaTime() const; protected: void purgeDirector(); @@ -367,6 +398,40 @@ protected: void calculateDeltaTime(); protected: + /** Scheduler associated with this director + @since v2.0 + */ + Scheduler* _scheduler; + + /** ActionManager associated with this director + @since v2.0 + */ + ActionManager* _actionManager; + + /** TouchDispatcher associated with this director + @since v2.0 + */ + TouchDispatcher* _touchDispatcher; + + /** KeyboardDispatcher associated with this director + @note Supported on Mac and Linux only now. + @since v3.0 + */ + KeyboardDispatcher* _keyboardDispatcher; + + /** KeypadDispatcher associated with this director + @since v2.0 + */ + KeypadDispatcher* _keypadDispatcher; + + /** Accelerometer associated with this director + @since v2.0 + */ + Accelerometer* _accelerometer; + + /* delta time since last tick to main loop */ + float _deltaTime; + /* The EGLView, where everything is rendered */ EGLView *_openGLView; diff --git a/cocos2dx/actions/CCAction.h b/cocos2dx/actions/CCAction.h index 027a5eccf9..ec38f59c83 100644 --- a/cocos2dx/actions/CCAction.h +++ b/cocos2dx/actions/CCAction.h @@ -172,10 +172,7 @@ public: void setInnerAction(ActionInterval *pAction); - inline ActionInterval* getInnerAction() const - { - return _innerAction; - } + inline ActionInterval* getInnerAction() const { return _innerAction; } // // Override diff --git a/cocos2dx/actions/CCActionInterval.h b/cocos2dx/actions/CCActionInterval.h index 3c9fc7303b..0b0d534a3c 100644 --- a/cocos2dx/actions/CCActionInterval.h +++ b/cocos2dx/actions/CCActionInterval.h @@ -92,7 +92,7 @@ class CC_DLL Sequence : public ActionInterval { public: /** helper constructor to create an array of sequenceable actions */ - static Sequence* create(FiniteTimeAction *pAction1, ...); + static Sequence* create(FiniteTimeAction *pAction1, ...) CC_REQUIRES_NULL_TERMINATION; /** helper constructor to create an array of sequenceable actions given an array */ static Sequence* create(Array *arrayOfActions); /** helper constructor to create an array of sequence-able actions */ @@ -221,7 +221,7 @@ class CC_DLL Spawn : public ActionInterval { public: /** helper constructor to create an array of spawned actions */ - static Spawn* create(FiniteTimeAction *pAction1, ...); + static Spawn* create(FiniteTimeAction *pAction1, ...) CC_REQUIRES_NULL_TERMINATION; /** helper constructor to create an array of spawned actions */ static Spawn* createWithVariableList(FiniteTimeAction *pAction1, va_list args); diff --git a/cocos2dx/base_nodes/CCAtlasNode.cpp b/cocos2dx/base_nodes/CCAtlasNode.cpp index 881274bb12..b82a2bb06c 100644 --- a/cocos2dx/base_nodes/CCAtlasNode.cpp +++ b/cocos2dx/base_nodes/CCAtlasNode.cpp @@ -233,24 +233,24 @@ void AtlasNode::setTexture(Texture2D *texture) this->updateOpacityModifyRGB(); } -Texture2D * AtlasNode::getTexture() +Texture2D * AtlasNode::getTexture() const { return _textureAtlas->getTexture(); } -void AtlasNode::setTextureAtlas(TextureAtlas* var) +void AtlasNode::setTextureAtlas(TextureAtlas* textureAtlas) { - CC_SAFE_RETAIN(var); + CC_SAFE_RETAIN(textureAtlas); CC_SAFE_RELEASE(_textureAtlas); - _textureAtlas = var; + _textureAtlas = textureAtlas; } -TextureAtlas * AtlasNode::getTextureAtlas() +TextureAtlas * AtlasNode::getTextureAtlas() const { return _textureAtlas; } -unsigned int AtlasNode::getQuadsToDraw() +unsigned int AtlasNode::getQuadsToDraw() const { return _quadsToDraw; } diff --git a/cocos2dx/base_nodes/CCAtlasNode.h b/cocos2dx/base_nodes/CCAtlasNode.h index fb5ec70fb4..efeb6583a4 100644 --- a/cocos2dx/base_nodes/CCAtlasNode.h +++ b/cocos2dx/base_nodes/CCAtlasNode.h @@ -68,15 +68,24 @@ public: */ virtual void updateAtlasValues(); + void setTextureAtlas(TextureAtlas* textureAtlas); + TextureAtlas* getTextureAtlas() const; + + void setQuadsToDraw(unsigned int quadsToDraw); + unsigned int getQuadsToDraw() const; + + // Overrides virtual void draw() override; - virtual Texture2D* getTexture() override; + virtual Texture2D* getTexture() const override; virtual void setTexture(Texture2D *texture) override; virtual bool isOpacityModifyRGB() const override; virtual void setOpacityModifyRGB(bool isOpacityModifyRGB) override; virtual const Color3B& getColor(void) const override; virtual void setColor(const Color3B& color) override; virtual void setOpacity(GLubyte opacity) override; + virtual void setBlendFunc(const BlendFunc& blendFunc) override; + virtual const BlendFunc& getBlendFunc() const override; private : void calculateMaxItems(); @@ -96,18 +105,16 @@ protected: unsigned int _itemWidth; //! height of each char unsigned int _itemHeight; - + Color3B _colorUnmodified; - - CC_PROPERTY(TextureAtlas*, _textureAtlas, TextureAtlas); - + + TextureAtlas* _textureAtlas; // protocol variables bool _isOpacityModifyRGB; - - CC_PROPERTY_PASS_BY_REF(BlendFunc, _blendFunc, BlendFunc); + BlendFunc _blendFunc; // quads to draw - CC_PROPERTY(unsigned int, _quadsToDraw, QuadsToDraw); + unsigned int _quadsToDraw; // color uniform GLint _uniformColor; // This varible is only used for LabelAtlas FPS display. So plz don't modify its value. diff --git a/cocos2dx/cocoa/CCArray.h b/cocos2dx/cocoa/CCArray.h index 88be1ede4d..28e34ccb07 100644 --- a/cocos2dx/cocoa/CCArray.h +++ b/cocos2dx/cocoa/CCArray.h @@ -117,7 +117,7 @@ public: /** Create an array */ static Array* create(); /** Create an array with some objects */ - static Array* create(Object* pObject, ...); + static Array* create(Object* pObject, ...) CC_REQUIRES_NULL_TERMINATION; /** Create an array with one object */ static Array* createWithObject(Object* pObject); /** Create an array with capacity */ @@ -142,7 +142,7 @@ public: /** Initializes an array with one object */ bool initWithObject(Object* pObject); /** Initializes an array with some objects */ - bool initWithObjects(Object* pObject, ...); + bool initWithObjects(Object* pObject, ...) CC_REQUIRES_NULL_TERMINATION; /** Initializes an array with capacity */ bool initWithCapacity(unsigned int capacity); /** Initializes an array with an existing array */ diff --git a/cocos2dx/cocoa/CCDictionary.h b/cocos2dx/cocoa/CCDictionary.h index b82136c257..c7edbad0ae 100644 --- a/cocos2dx/cocoa/CCDictionary.h +++ b/cocos2dx/cocoa/CCDictionary.h @@ -162,9 +162,9 @@ public: * * // Get the object for key * String* pStr1 = (String*)pDict->objectForKey("key1"); - * CCLog("{ key1: %s }", pStr1->getCString()); + * log("{ key1: %s }", pStr1->getCString()); * Integer* pInteger = (Integer*)pDict->objectForKey("key3"); - * CCLog("{ key3: %d }", pInteger->getValue()); + * log("{ key3: %d }", pInteger->getValue()); * @endcode * */ diff --git a/cocos2dx/cocos2d.cpp b/cocos2dx/cocos2d.cpp index d109164fe1..859af0a34a 100644 --- a/cocos2dx/cocos2d.cpp +++ b/cocos2dx/cocos2d.cpp @@ -30,7 +30,7 @@ NS_CC_BEGIN const char* cocos2dVersion() { - return "3.0-alpha0-pre"; + return "3.0-pre-alpha0"; } NS_CC_END diff --git a/cocos2dx/include/CCDeprecated.h b/cocos2dx/include/CCDeprecated.h index 1543c3abcb..708b97c862 100644 --- a/cocos2dx/include/CCDeprecated.h +++ b/cocos2dx/include/CCDeprecated.h @@ -907,6 +907,10 @@ CC_DEPRECATED_ATTRIBUTE typedef void* CCZone; #define kCCFlipedAll kFlipedAll #define kCCFlippedMask kFlippedMask + +/** use log() instead */ +CC_DEPRECATED_ATTRIBUTE void CC_DLL CCLog(const char * pszFormat, ...) CC_FORMAT_PRINTF(1, 2); + // end of data_structures group /// @} diff --git a/cocos2dx/include/CCProtocols.h b/cocos2dx/include/CCProtocols.h index f2c10d4db7..01f361f078 100644 --- a/cocos2dx/include/CCProtocols.h +++ b/cocos2dx/include/CCProtocols.h @@ -50,21 +50,21 @@ public: * * @return The Color3B contains R,G,B bytes. */ - virtual const Color3B& getColor(void) const = 0; + virtual const Color3B& getColor() const = 0; /** * Returns the displayed color. * * @return The Color3B contains R,G,B bytes. */ - virtual const Color3B& getDisplayedColor(void) const = 0; + virtual const Color3B& getDisplayedColor() const = 0; /** * Returns the displayed opacity. * * @return The opacity of sprite, from 0 ~ 255 */ - virtual GLubyte getDisplayedOpacity(void) const = 0; + virtual GLubyte getDisplayedOpacity() const = 0; /** * Returns the opacity. * @@ -73,7 +73,7 @@ public: * * @return The opacity of sprite, from 0 ~ 255 */ - virtual GLubyte getOpacity(void) const = 0; + virtual GLubyte getOpacity() const = 0; /** * Changes the opacity. @@ -100,12 +100,12 @@ public: * * @return Returns opacity modify flag. */ - virtual bool isOpacityModifyRGB(void) const = 0; + virtual bool isOpacityModifyRGB() const = 0; /** * whether or not color should be propagated to its children. */ - virtual bool isCascadeColorEnabled(void) const = 0; + virtual bool isCascadeColorEnabled() const = 0; virtual void setCascadeColorEnabled(bool cascadeColorEnabled) = 0; /** @@ -116,7 +116,7 @@ public: /** * whether or not opacity should be propagated to its children. */ - virtual bool isCascadeOpacityEnabled(void) const = 0; + virtual bool isCascadeOpacityEnabled() const = 0; virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled) = 0; /** @@ -147,7 +147,7 @@ public: * * @return A BlendFunc structure with source and destination factor which specified pixel arithmetic. */ - virtual const BlendFunc &getBlendFunc(void) const = 0; + virtual const BlendFunc &getBlendFunc() const = 0; }; /** @@ -167,7 +167,7 @@ public: * * @return The texture that is currenlty being used. */ - virtual Texture2D* getTexture(void) = 0; + virtual Texture2D* getTexture() const = 0; /** * Sets a new texuture. It will be retained. @@ -195,7 +195,7 @@ public: * * @return The string that is currently being used in this label */ - virtual const char* getString(void) const = 0; + virtual const char* getString() const = 0; }; /** @@ -207,7 +207,7 @@ public: /** * Will be called by Director when the projection is updated, and "custom" projection is used */ - virtual void updateProjection(void) = 0; + virtual void updateProjection() = 0; }; NS_CC_END diff --git a/cocos2dx/include/ccMacros.h b/cocos2dx/include/ccMacros.h index 7b6aa94ea0..d1cb92c33b 100644 --- a/cocos2dx/include/ccMacros.h +++ b/cocos2dx/include/ccMacros.h @@ -40,7 +40,7 @@ extern bool CC_DLL cc_assert_script_compatible(const char *msg); #define CCASSERT(cond, msg) do { \ if (!(cond)) { \ if (!cc_assert_script_compatible(msg) && strlen(msg)) \ - cocos2d::CCLog("Assert failed: %s", msg); \ + cocos2d::log("Assert failed: %s", msg); \ CC_ASSERT(cond); \ } \ } while (0) @@ -238,7 +238,7 @@ It should work same as apples CFSwapInt32LittleToHost(..) do { \ GLenum __error = glGetError(); \ if(__error) { \ - CCLog("OpenGL error 0x%04X in %s %s %d\n", __error, __FILE__, __FUNCTION__, __LINE__); \ + cocos2d::log("OpenGL error 0x%04X in %s %s %d\n", __error, __FILE__, __FUNCTION__, __LINE__); \ } \ } while (false) #endif diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h index cc1ced690a..aa544079bd 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h @@ -241,9 +241,6 @@ public: */ void changeWidthAndHeight(GLfloat w ,GLfloat h); - /** BlendFunction. Conforms to BlendProtocol protocol */ - CC_PROPERTY_PASS_BY_REF(BlendFunc, _blendFunc, BlendFunc) - // // Overrides // @@ -251,10 +248,14 @@ public: virtual void setColor(const Color3B &color) override; virtual void setOpacity(GLubyte opacity) override; virtual void setContentSize(const Size & var) override; + /** BlendFunction. Conforms to BlendProtocol protocol */ + virtual const BlendFunc& getBlendFunc() const override; + virtual void setBlendFunc(const BlendFunc& blendFunc) override; protected: virtual void updateColor(); + BlendFunc _blendFunc; Vertex2F _squareVertices[4]; Color4F _squareColors[4]; }; diff --git a/cocos2dx/menu_nodes/CCMenu.h b/cocos2dx/menu_nodes/CCMenu.h index e31fe81094..2199495ad6 100644 --- a/cocos2dx/menu_nodes/CCMenu.h +++ b/cocos2dx/menu_nodes/CCMenu.h @@ -60,7 +60,7 @@ public: static Menu* create(); /** creates a Menu with MenuItem objects */ - static Menu* create(MenuItem* item, ...); + static Menu* create(MenuItem* item, ...) CC_REQUIRES_NULL_TERMINATION; /** creates a Menu with a Array of MenuItem objects */ static Menu* createWithArray(Array* pArrayOfItems); @@ -98,12 +98,12 @@ public: void alignItemsHorizontallyWithPadding(float padding); /** align items in rows of columns */ - void alignItemsInColumns(int columns, ...); + void alignItemsInColumns(int columns, ...) CC_REQUIRES_NULL_TERMINATION; void alignItemsInColumns(int columns, va_list args); void alignItemsInColumnsWithArray(Array* rows); /** align items in columns of rows */ - void alignItemsInRows(int rows, ...); + void alignItemsInRows(int rows, ...) CC_REQUIRES_NULL_TERMINATION; void alignItemsInRows(int rows, va_list args); void alignItemsInRowsWithArray(Array* columns); diff --git a/cocos2dx/menu_nodes/CCMenuItem.cpp b/cocos2dx/menu_nodes/CCMenuItem.cpp index 1d53aebd1e..2bfbf933c5 100644 --- a/cocos2dx/menu_nodes/CCMenuItem.cpp +++ b/cocos2dx/menu_nodes/CCMenuItem.cpp @@ -161,18 +161,6 @@ void MenuItem::setCallback(const ccMenuCallback& callback) //CCMenuItemLabel // -const Color3B& MenuItemLabel::getDisabledColor() const -{ - return _disabledColor; -} -void MenuItemLabel::setDisabledColor(const Color3B& var) -{ - _disabledColor = var; -} -Node *MenuItemLabel::getLabel() -{ - return _label; -} void MenuItemLabel::setLabel(Node* var) { if (var) @@ -473,11 +461,6 @@ const char* MenuItemFont::getFontNameObj() const //CCMenuItemSprite // -Node * MenuItemSprite::getNormalImage() -{ - return _normalImage; -} - void MenuItemSprite::setNormalImage(Node* pImage) { if (pImage != _normalImage) @@ -499,11 +482,6 @@ void MenuItemSprite::setNormalImage(Node* pImage) } } -Node * MenuItemSprite::getSelectedImage() -{ - return _selectedImage; -} - void MenuItemSprite::setSelectedImage(Node* pImage) { if (pImage != _normalImage) @@ -524,11 +502,6 @@ void MenuItemSprite::setSelectedImage(Node* pImage) } } -Node * MenuItemSprite::getDisabledImage() -{ - return _disabledImage; -} - void MenuItemSprite::setDisabledImage(Node* pImage) { if (pImage != _normalImage) @@ -818,18 +791,6 @@ void MenuItemImage::setDisabledSpriteFrame(SpriteFrame * frame) // MenuItemToggle // -void MenuItemToggle::setSubItems(Array* var) -{ - CC_SAFE_RETAIN(var); - CC_SAFE_RELEASE(_subItems); - _subItems = var; -} - -Array* MenuItemToggle::getSubItems() -{ - return _subItems; -} - // XXX: deprecated MenuItemToggle * MenuItemToggle::createWithTarget(Object* target, SEL_MenuHandler selector, Array* menuItems) { @@ -959,6 +920,7 @@ MenuItemToggle::~MenuItemToggle() { CC_SAFE_RELEASE(_subItems); } + void MenuItemToggle::setSelectedIndex(unsigned int index) { if( index != _selectedIndex && _subItems->count() > 0 ) @@ -977,20 +939,19 @@ void MenuItemToggle::setSelectedIndex(unsigned int index) item->setPosition( Point( s.width/2, s.height/2 ) ); } } -unsigned int MenuItemToggle::getSelectedIndex() -{ - return _selectedIndex; -} + void MenuItemToggle::selected() { MenuItem::selected(); - ((MenuItem*)(_subItems->objectAtIndex(_selectedIndex)))->selected(); + static_cast(_subItems->objectAtIndex(_selectedIndex))->selected(); } + void MenuItemToggle::unselected() { MenuItem::unselected(); - ((MenuItem*)(_subItems->objectAtIndex(_selectedIndex)))->unselected(); + static_cast(_subItems->objectAtIndex(_selectedIndex))->unselected(); } + void MenuItemToggle::activate() { // update index @@ -1021,7 +982,7 @@ void MenuItemToggle::setEnabled(bool enabled) MenuItem* MenuItemToggle::getSelectedItem() { - return (MenuItem*)_subItems->objectAtIndex(_selectedIndex); + return static_cast(_subItems->objectAtIndex(_selectedIndex)); } NS_CC_END diff --git a/cocos2dx/menu_nodes/CCMenuItem.h b/cocos2dx/menu_nodes/CCMenuItem.h index 37cddc1523..592d3f9ebb 100644 --- a/cocos2dx/menu_nodes/CCMenuItem.h +++ b/cocos2dx/menu_nodes/CCMenuItem.h @@ -142,6 +142,18 @@ public: /** sets a new string to the inner label */ void setString(const char * label); + /** Gets the color that will be used to disable the item */ + inline const Color3B& getDisabledColor() const { return _disabledColor; }; + + /** Sets the color that will be used to disable the item */ + inline void setDisabledColor(const Color3B& color) { _disabledColor = color; }; + + /** Gets the label that is rendered. */ + inline Node* getLabel() const { return _label; }; + + /** Sets the label that is rendered. */ + void setLabel(Node* node); + // Overrides virtual void activate() override; virtual void selected() override; @@ -153,9 +165,9 @@ protected: float _originalScale; /** the color that will be used to disable the item */ - CC_PROPERTY_PASS_BY_REF(Color3B, _disabledColor, DisabledColor); + Color3B _disabledColor; /** Label that is rendered. It can be any Node that implements the LabelProtocol */ - CC_PROPERTY(Node*, _label, Label); + Node* _label; }; @@ -277,6 +289,24 @@ public: /** initializes a menu item with a normal, selected and disabled image with a callable object */ bool initWithNormalSprite(Node* normalSprite, Node* selectedSprite, Node* disabledSprite, const ccMenuCallback& callback); + /** Gets the image used when the item is not selected */ + inline Node* getNormalImage() const { return _normalImage; }; + + /** Sets the image used when the item is not selected */ + void setNormalImage(Node* image); + + /** Gets the image used when the item is selected */ + inline Node* getSelectedImage() const { return _selectedImage; }; + + /** Sets the image used when the item is selected */ + void setSelectedImage(Node* image); + + /** Gets the image used when the item is disabled */ + inline Node* getDisabledImage() const { return _disabledImage; }; + + /** Sets the image used when the item is disabled */ + void setDisabledImage(Node* image); + /** @since v0.99.5 */ @@ -288,11 +318,11 @@ protected: virtual void updateImagesVisibility(); /** the image used when the item is not selected */ - CC_PROPERTY(Node*, _normalImage, NormalImage); + Node* _normalImage; /** the image used when the item is selected */ - CC_PROPERTY(Node*, _selectedImage, SelectedImage); + Node* _selectedImage; /** the image used when the item is disabled */ - CC_PROPERTY(Node*, _disabledImage, DisabledImage); + Node* _disabledImage; }; @@ -351,7 +381,7 @@ public: /** creates a menu item from a Array with a callable object */ static MenuItemToggle * createWithCallback(const ccMenuCallback& callback, Array* menuItems); /** creates a menu item from a list of items with a callable object */ - static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, MenuItem* item, ...); + static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, MenuItem* item, ...) CC_REQUIRES_NULL_TERMINATION; /** creates a menu item with no target/selector and no items */ static MenuItemToggle* create(); /** creates a menu item with a item */ @@ -359,7 +389,7 @@ public: /** creates a menu item from a Array with a target selector */ CC_DEPRECATED_ATTRIBUTE static MenuItemToggle * createWithTarget(Object* target, SEL_MenuHandler selector, Array* menuItems); /** creates a menu item from a list of items with a target/selector */ - CC_DEPRECATED_ATTRIBUTE static MenuItemToggle* createWithTarget(Object* target, SEL_MenuHandler selector, MenuItem* item, ...); + CC_DEPRECATED_ATTRIBUTE static MenuItemToggle* createWithTarget(Object* target, SEL_MenuHandler selector, MenuItem* item, ...)CC_REQUIRES_NULL_TERMINATION; MenuItemToggle() : _selectedIndex(0) @@ -382,6 +412,26 @@ public: /** @deprecated Use getSelectedItem() instead */ CC_DEPRECATED_ATTRIBUTE MenuItem* selectedItem() { return getSelectedItem(); } + /** Gets the index of the selected item */ + inline unsigned int getSelectedIndex() const { return _selectedIndex; }; + + /** Sets the index of the selected item */ + void setSelectedIndex(unsigned int index); + + /** Gets the array that contains the subitems. + You can add/remove items in runtime, and you can replace the array with a new one. + @since v0.7.2 + */ + + inline Array* getSubItems() const { return _subItems; }; + + /** Sets the array that contains the subitems. */ + inline void setSubItems(Array* items) { + CC_SAFE_RETAIN(items); + CC_SAFE_RELEASE(_subItems); + _subItems = items; + } + // Overrides virtual void activate() override; virtual void selected() override; @@ -390,11 +440,11 @@ public: protected: /** returns the selected item */ - CC_PROPERTY(unsigned int, _selectedIndex, SelectedIndex); - /** MutableArray that contains the subitems. You can add/remove items in runtime, and you can replace the array with a new one. + unsigned int _selectedIndex; + /** Array that contains the subitems. You can add/remove items in runtime, and you can replace the array with a new one. @since v0.7.2 */ - CC_PROPERTY(Array*, _subItems, SubItems); + Array* _subItems; }; diff --git a/cocos2dx/misc_nodes/CCMotionStreak.cpp b/cocos2dx/misc_nodes/CCMotionStreak.cpp index 1f6b64c1d2..40159988f1 100644 --- a/cocos2dx/misc_nodes/CCMotionStreak.cpp +++ b/cocos2dx/misc_nodes/CCMotionStreak.cpp @@ -153,7 +153,7 @@ void MotionStreak::tintWithColor(const Color3B& colors) } } -Texture2D* MotionStreak::getTexture(void) +Texture2D* MotionStreak::getTexture(void) const { return _texture; } diff --git a/cocos2dx/misc_nodes/CCMotionStreak.h b/cocos2dx/misc_nodes/CCMotionStreak.h index a7b623e84f..85b4a08e37 100644 --- a/cocos2dx/misc_nodes/CCMotionStreak.h +++ b/cocos2dx/misc_nodes/CCMotionStreak.h @@ -82,7 +82,7 @@ public: virtual void setPosition(const Point& position) override; virtual void draw() override; virtual void update(float delta) override; - virtual Texture2D* getTexture() override; + virtual Texture2D* getTexture() const override; virtual void setTexture(Texture2D *texture) override; virtual void setBlendFunc(const BlendFunc &blendFunc) override; virtual const BlendFunc& getBlendFunc() const override; diff --git a/cocos2dx/misc_nodes/CCRenderTexture.cpp b/cocos2dx/misc_nodes/CCRenderTexture.cpp index f7f5c44a11..edeab9643e 100644 --- a/cocos2dx/misc_nodes/CCRenderTexture.cpp +++ b/cocos2dx/misc_nodes/CCRenderTexture.cpp @@ -140,68 +140,6 @@ void RenderTexture::listenToForeground(cocos2d::Object *obj) #endif } -Sprite * RenderTexture::getSprite() -{ - return _sprite; -} - -void RenderTexture::setSprite(Sprite* var) -{ - CC_SAFE_RELEASE(_sprite); - _sprite = var; - CC_SAFE_RETAIN(_sprite); -} - -unsigned int RenderTexture::getClearFlags() const -{ - return _clearFlags; -} - -void RenderTexture::setClearFlags(unsigned int uClearFlags) -{ - _clearFlags = uClearFlags; -} - -const Color4F& RenderTexture::getClearColor() const -{ - return _clearColor; -} - -void RenderTexture::setClearColor(const Color4F &clearColor) -{ - _clearColor = clearColor; -} - -float RenderTexture::getClearDepth() const -{ - return _clearDepth; -} - -void RenderTexture::setClearDepth(float fClearDepth) -{ - _clearDepth = fClearDepth; -} - -int RenderTexture::getClearStencil() const -{ - return _clearStencil; -} - -void RenderTexture::setClearStencil(float fClearStencil) -{ - _clearStencil = fClearStencil; -} - -bool RenderTexture::isAutoDraw() const -{ - return _autoDraw; -} - -void RenderTexture::setAutoDraw(bool bAutoDraw) -{ - _autoDraw = bAutoDraw; -} - RenderTexture * RenderTexture::create(int w, int h, Texture2DPixelFormat eFormat) { RenderTexture *pRet = new RenderTexture(); diff --git a/cocos2dx/misc_nodes/CCRenderTexture.h b/cocos2dx/misc_nodes/CCRenderTexture.h index 048396576e..4fe49434e5 100644 --- a/cocos2dx/misc_nodes/CCRenderTexture.h +++ b/cocos2dx/misc_nodes/CCRenderTexture.h @@ -127,27 +127,37 @@ public: void listenToForeground(Object *obj); /** Valid flags: GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT, GL_STENCIL_BUFFER_BIT. They can be OR'ed. Valid when "autoDraw is YES. */ - unsigned int getClearFlags() const; - void setClearFlags(unsigned int uClearFlags); + inline unsigned int getClearFlags() const { return _clearFlags; }; + inline void setClearFlags(unsigned int clearFlags) { _clearFlags = clearFlags; }; /** Clear color value. Valid only when "autoDraw" is true. */ - const Color4F& getClearColor() const; - void setClearColor(const Color4F &clearColor); + inline const Color4F& getClearColor() const { return _clearColor; }; + inline void setClearColor(const Color4F &clearColor) { _clearColor = clearColor; }; /** Value for clearDepth. Valid only when autoDraw is true. */ - float getClearDepth() const; - void setClearDepth(float fClearDepth); + inline float getClearDepth() const { return _clearDepth; }; + inline void setClearDepth(float clearDepth) { _clearDepth = clearDepth; }; /** Value for clear Stencil. Valid only when autoDraw is true */ - int getClearStencil() const; - void setClearStencil(float fClearStencil); + inline int getClearStencil() const { return _clearStencil; }; + inline void setClearStencil(float clearStencil) { _clearStencil = clearStencil; }; /** When enabled, it will render its children into the texture automatically. Disabled by default for compatiblity reasons. Will be enabled in the future. */ - bool isAutoDraw() const; - void setAutoDraw(bool bAutoDraw); + inline bool isAutoDraw() const { return _autoDraw; }; + inline void setAutoDraw(bool isAutoDraw) { _autoDraw = isAutoDraw; }; + /** Gets the Sprite being used. */ + inline Sprite* getSprite() const { return _sprite; }; + + /** Sets the Sprite being used. */ + inline void setSprite(Sprite* sprite) { + CC_SAFE_RETAIN(sprite); + CC_SAFE_RELEASE(_sprite); + _sprite = sprite; + }; + // Overrides virtual void visit() override; virtual void draw() override; @@ -176,7 +186,7 @@ protected: The blending function can be changed in runtime by calling: - [[renderTexture sprite] setBlendFunc:(BlendFunc){GL_ONE, GL_ONE_MINUS_SRC_ALPHA}]; */ - CC_PROPERTY(Sprite*, _sprite, Sprite) + Sprite* _sprite; }; // end of textures group diff --git a/cocos2dx/particle_nodes/CCParticleBatchNode.cpp b/cocos2dx/particle_nodes/CCParticleBatchNode.cpp index 0b9a68c57a..15890dec8c 100644 --- a/cocos2dx/particle_nodes/CCParticleBatchNode.cpp +++ b/cocos2dx/particle_nodes/CCParticleBatchNode.cpp @@ -503,7 +503,7 @@ void ParticleBatchNode::setTexture(Texture2D* texture) } } -Texture2D* ParticleBatchNode::getTexture(void) +Texture2D* ParticleBatchNode::getTexture(void) const { return _textureAtlas->getTexture(); } diff --git a/cocos2dx/particle_nodes/CCParticleBatchNode.h b/cocos2dx/particle_nodes/CCParticleBatchNode.h index 55d4c6caad..f0eff12919 100644 --- a/cocos2dx/particle_nodes/CCParticleBatchNode.h +++ b/cocos2dx/particle_nodes/CCParticleBatchNode.h @@ -91,6 +91,12 @@ public: /** disables a particle by inserting a 0'd quad into the texture atlas */ void disableParticle(unsigned int particleIndex); + /** Gets the texture atlas used for drawing the quads */ + inline TextureAtlas* getTextureAtlas() const { return _textureAtlas; }; + + /** Sets the texture atlas used for drawing the quads */ + inline void setTextureAtlas(TextureAtlas* atlas) { _textureAtlas = atlas; }; + // Overrides void visit(); virtual void addChild(Node * child) override; @@ -99,7 +105,7 @@ public: virtual void removeChild(Node* child, bool cleanup) override; virtual void reorderChild(Node * child, int zOrder) override; virtual void draw(void) override; - virtual Texture2D* getTexture(void) override; + virtual Texture2D* getTexture(void) const override; virtual void setTexture(Texture2D *texture) override; virtual void setBlendFunc(const BlendFunc &blendFunc) override; virtual const BlendFunc& getBlendFunc(void) const override; @@ -112,7 +118,7 @@ private: unsigned int addChildHelper(ParticleSystem* child, int z, int aTag); void updateBlendFunc(void); /** the texture atlas used for drawing the quads */ - CC_SYNTHESIZE(TextureAtlas*, _textureAtlas, TextureAtlas); + TextureAtlas* _textureAtlas; private: /** the blend function used for drawing the quads */ diff --git a/cocos2dx/particle_nodes/CCParticleSystem.cpp b/cocos2dx/particle_nodes/CCParticleSystem.cpp index 6624acaab9..836a6c6977 100644 --- a/cocos2dx/particle_nodes/CCParticleSystem.cpp +++ b/cocos2dx/particle_nodes/CCParticleSystem.cpp @@ -821,7 +821,7 @@ void ParticleSystem::updateBlendFunc() } } -Texture2D * ParticleSystem::getTexture() +Texture2D * ParticleSystem::getTexture() const { return _texture; } @@ -1029,211 +1029,7 @@ bool ParticleSystem::isActive() const return _isActive; } -unsigned int ParticleSystem::getParticleCount() const -{ - return _particleCount; -} - -float ParticleSystem::getDuration() -{ - return _duration; -} - -void ParticleSystem::setDuration(float var) -{ - _duration = var; -} - -const Point& ParticleSystem::getSourcePosition() const -{ - return _sourcePosition; -} - -void ParticleSystem::setSourcePosition(const Point& var) -{ - _sourcePosition = var; -} - -const Point& ParticleSystem::getPosVar() const -{ - return _posVar; -} - -void ParticleSystem::setPosVar(const Point& var) -{ - _posVar = var; -} - -float ParticleSystem::getLife() -{ - return _life; -} - -void ParticleSystem::setLife(float var) -{ - _life = var; -} - -float ParticleSystem::getLifeVar() -{ - return _lifeVar; -} - -void ParticleSystem::setLifeVar(float var) -{ - _lifeVar = var; -} - -float ParticleSystem::getAngle() -{ - return _angle; -} - -void ParticleSystem::setAngle(float var) -{ - _angle = var; -} - -float ParticleSystem::getAngleVar() -{ - return _angleVar; -} - -void ParticleSystem::setAngleVar(float var) -{ - _angleVar = var; -} - -float ParticleSystem::getStartSize() -{ - return _startSize; -} - -void ParticleSystem::setStartSize(float var) -{ - _startSize = var; -} - -float ParticleSystem::getStartSizeVar() -{ - return _startSizeVar; -} - -void ParticleSystem::setStartSizeVar(float var) -{ - _startSizeVar = var; -} - -float ParticleSystem::getEndSize() -{ - return _endSize; -} - -void ParticleSystem::setEndSize(float var) -{ - _endSize = var; -} - -float ParticleSystem::getEndSizeVar() -{ - return _endSizeVar; -} - -void ParticleSystem::setEndSizeVar(float var) -{ - _endSizeVar = var; -} - -const Color4F& ParticleSystem::getStartColor() const -{ - return _startColor; -} - -void ParticleSystem::setStartColor(const Color4F& var) -{ - _startColor = var; -} - -const Color4F& ParticleSystem::getStartColorVar() const -{ - return _startColorVar; -} - -void ParticleSystem::setStartColorVar(const Color4F& var) -{ - _startColorVar = var; -} - -const Color4F& ParticleSystem::getEndColor() const -{ - return _endColor; -} - -void ParticleSystem::setEndColor(const Color4F& var) -{ - _endColor = var; -} - -const Color4F& ParticleSystem::getEndColorVar() const -{ - return _endColorVar; -} - -void ParticleSystem::setEndColorVar(const Color4F& var) -{ - _endColorVar = var; -} - -float ParticleSystem::getStartSpin() -{ - return _startSpin; -} - -void ParticleSystem::setStartSpin(float var) -{ - _startSpin = var; -} - -float ParticleSystem::getStartSpinVar() -{ - return _startSpinVar; -} - -void ParticleSystem::setStartSpinVar(float var) -{ - _startSpinVar = var; -} - -float ParticleSystem::getEndSpin() -{ - return _endSpin; -} - -void ParticleSystem::setEndSpin(float var) -{ - _endSpin = var; -} -float ParticleSystem::getEndSpinVar() -{ - return _endSpinVar; -} - -void ParticleSystem::setEndSpinVar(float var) -{ - _endSpinVar = var; -} - -float ParticleSystem::getEmissionRate() -{ - return _emissionRate; -} - -void ParticleSystem::setEmissionRate(float var) -{ - _emissionRate = var; -} - -unsigned int ParticleSystem::getTotalParticles() +unsigned int ParticleSystem::getTotalParticles() const { return _totalParticles; } @@ -1257,26 +1053,6 @@ void ParticleSystem::setBlendFunc(const BlendFunc &blendFunc) } } -bool ParticleSystem::getOpacityModifyRGB() -{ - return _opacityModifyRGB; -} - -void ParticleSystem::setOpacityModifyRGB(bool bOpacityModifyRGB) -{ - _opacityModifyRGB = bOpacityModifyRGB; -} - -tPositionType ParticleSystem::getPositionType() -{ - return _positionType; -} - -void ParticleSystem::setPositionType(tPositionType var) -{ - _positionType = var; -} - bool ParticleSystem::isAutoRemoveOnFinish() const { return _isAutoRemoveOnFinish; @@ -1287,20 +1063,10 @@ void ParticleSystem::setAutoRemoveOnFinish(bool var) _isAutoRemoveOnFinish = var; } -int ParticleSystem::getEmitterMode() -{ - return _emitterMode; -} - -void ParticleSystem::setEmitterMode(int var) -{ - _emitterMode = var; -} - // ParticleSystem - methods for batchNode rendering -ParticleBatchNode* ParticleSystem::getBatchNode(void) +ParticleBatchNode* ParticleSystem::getBatchNode(void) const { return _batchNode; } diff --git a/cocos2dx/particle_nodes/CCParticleSystem.h b/cocos2dx/particle_nodes/CCParticleSystem.h index 4d66b22a78..be34da3f6e 100644 --- a/cocos2dx/particle_nodes/CCParticleSystem.h +++ b/cocos2dx/particle_nodes/CCParticleSystem.h @@ -262,9 +262,124 @@ public: virtual bool isBlendAdditive() const; virtual void setBlendAdditive(bool value); + virtual ParticleBatchNode* getBatchNode() const; + virtual void setBatchNode(ParticleBatchNode* batchNode); + + // index of system in batch node array + inline int getAtlasIndex() const { return _atlasIndex; }; + inline void setAtlasIndex(int index) { _atlasIndex = index; }; + + /** Quantity of particles that are being simulated at the moment */ + inline unsigned int getParticleCount() const { return _particleCount; }; + + /** How many seconds the emitter will run. -1 means 'forever' */ + inline float getDuration() const { return _duration; }; + inline void setDuration(float duration) { _duration = duration; }; + + /** sourcePosition of the emitter */ + inline const Point& getSourcePosition() const { return _sourcePosition; }; + inline void setSourcePosition(const Point& pos) { _sourcePosition = pos; }; + + /** Position variance of the emitter */ + inline const Point& getPosVar() const { return _posVar; }; + inline void setPosVar(const Point& pos) { _posVar = pos; }; + + /** life, and life variation of each particle */ + inline float getLife() const { return _life; }; + inline void setLife(float life) { _life = life; }; + + /** life variance of each particle */ + inline float getLifeVar() const { return _lifeVar; }; + inline void setLifeVar(float lifeVar) { _lifeVar = lifeVar; }; + + /** angle and angle variation of each particle */ + inline float getAngle() const { return _angle; }; + inline void setAngle(float angle) { _angle = angle; }; + + /** angle variance of each particle */ + inline float getAngleVar() const { return _angleVar; }; + inline void setAngleVar(float angleVar) { _angleVar = angleVar; }; + + /** Switch between different kind of emitter modes: + - kParticleModeGravity: uses gravity, speed, radial and tangential acceleration + - kParticleModeRadius: uses radius movement + rotation + */ + inline int getEmitterMode() const { return _emitterMode; }; + inline void setEmitterMode(int mode) { _emitterMode = mode; }; + + /** start size in pixels of each particle */ + inline float getStartSize() const { return _startSize; }; + inline void setStartSize(float startSize) { _startSize = startSize; }; + + /** size variance in pixels of each particle */ + inline float getStartSizeVar() const { return _startSizeVar; }; + inline void setStartSizeVar(float sizeVar) { _startSizeVar = sizeVar; }; + + /** end size in pixels of each particle */ + inline float getEndSize() const { return _endSize; }; + inline void setEndSize(float endSize) { _endSize = endSize; }; + + /** end size variance in pixels of each particle */ + inline float getEndSizeVar() const { return _endSizeVar; }; + inline void setEndSizeVar(float sizeVar) { _endSizeVar = sizeVar; }; + + /** start color of each particle */ + inline const Color4F& getStartColor() const { return _startColor; }; + inline void setStartColor(const Color4F& color) { _startColor = color; }; + + /** start color variance of each particle */ + inline const Color4F& getStartColorVar() const { return _startColorVar; }; + inline void setStartColorVar(const Color4F& color) { _startColorVar = color; }; + + /** end color and end color variation of each particle */ + inline const Color4F& getEndColor() const { return _endColor; }; + inline void setEndColor(const Color4F& color) { _endColor = color; }; + + /** end color variance of each particle */ + inline const Color4F& getEndColorVar() const { return _endColorVar; }; + inline void setEndColorVar(const Color4F& color) { _endColorVar = color; }; + + //* initial angle of each particle + inline float getStartSpin() const { return _startSpin; }; + inline void setStartSpin(float spin) { _startSpin = spin; }; + + //* initial angle of each particle + inline float getStartSpinVar() const { return _startSpinVar; }; + inline void setStartSpinVar(float pinVar) { _startSpinVar = pinVar; }; + + //* initial angle of each particle + inline float getEndSpin() const { return _endSpin; }; + inline void setEndSpin(float endSpin) { _endSpin = endSpin; }; + + //* initial angle of each particle + inline float getEndSpinVar() const { return _endSpinVar; }; + inline void setEndSpinVar(float endSpinVar) { _endSpinVar = endSpinVar; }; + + /** emission rate of the particles */ + inline float getEmissionRate() const { return _emissionRate; }; + inline void setEmissionRate(float rate) { _emissionRate = rate; }; + + /** maximum particles of the system */ + virtual unsigned int getTotalParticles() const; + virtual void setTotalParticles(unsigned int totalParticles); + + /** does the alpha value modify color */ + inline void setOpacityModifyRGB(bool opacityModifyRGB) { _opacityModifyRGB = opacityModifyRGB; }; + inline bool isOpacityModifyRGB() const { return _opacityModifyRGB; }; + CC_DEPRECATED_ATTRIBUTE inline bool getOpacityModifyRGB() const { return isOpacityModifyRGB(); } + + /** particles movement type: Free or Grouped + @since v0.8 + */ + inline tPositionType getPositionType() const { return _positionType; }; + inline void setPositionType(tPositionType type) { _positionType = type; }; + // Overrides virtual void update(float dt) override; - + virtual Texture2D* getTexture() const override; + virtual void setTexture(Texture2D *texture) override; + virtual void setBlendFunc(const BlendFunc &blendFunc) override; + virtual const BlendFunc &getBlendFunc() const override; protected: virtual void updateBlendFunc(); @@ -342,10 +457,10 @@ protected: //SEL updateParticleSel; /** weak reference to the SpriteBatchNode that renders the Sprite */ - CC_PROPERTY(ParticleBatchNode*, _batchNode, BatchNode); + ParticleBatchNode* _batchNode; // index of system in batch node array - CC_SYNTHESIZE(int, _atlasIndex, AtlasIndex); + int _atlasIndex; //true if scaled or rotated bool _transformSystemDirty; @@ -356,67 +471,67 @@ protected: bool _isActive; /** Quantity of particles that are being simulated at the moment */ - CC_PROPERTY_READONLY(unsigned int, _particleCount, ParticleCount) + unsigned int _particleCount; /** How many seconds the emitter will run. -1 means 'forever' */ - CC_PROPERTY(float, _duration, Duration) + float _duration; /** sourcePosition of the emitter */ - CC_PROPERTY_PASS_BY_REF(Point, _sourcePosition, SourcePosition) + Point _sourcePosition; /** Position variance of the emitter */ - CC_PROPERTY_PASS_BY_REF(Point, _posVar, PosVar) + Point _posVar; /** life, and life variation of each particle */ - CC_PROPERTY(float, _life, Life) + float _life; /** life variance of each particle */ - CC_PROPERTY(float, _lifeVar, LifeVar) + float _lifeVar; /** angle and angle variation of each particle */ - CC_PROPERTY(float, _angle, Angle) + float _angle; /** angle variance of each particle */ - CC_PROPERTY(float, _angleVar, AngleVar) + float _angleVar; /** Switch between different kind of emitter modes: - kParticleModeGravity: uses gravity, speed, radial and tangential acceleration - kParticleModeRadius: uses radius movement + rotation */ - CC_PROPERTY(int, _emitterMode, EmitterMode) + int _emitterMode; /** start size in pixels of each particle */ - CC_PROPERTY(float, _startSize, StartSize) + float _startSize; /** size variance in pixels of each particle */ - CC_PROPERTY(float, _startSizeVar, StartSizeVar) + float _startSizeVar; /** end size in pixels of each particle */ - CC_PROPERTY(float, _endSize, EndSize) + float _endSize; /** end size variance in pixels of each particle */ - CC_PROPERTY(float, _endSizeVar, EndSizeVar) + float _endSizeVar; /** start color of each particle */ - CC_PROPERTY_PASS_BY_REF(Color4F, _startColor, StartColor) + Color4F _startColor; /** start color variance of each particle */ - CC_PROPERTY_PASS_BY_REF(Color4F, _startColorVar, StartColorVar) + Color4F _startColorVar; /** end color and end color variation of each particle */ - CC_PROPERTY_PASS_BY_REF(Color4F, _endColor, EndColor) + Color4F _endColor; /** end color variance of each particle */ - CC_PROPERTY_PASS_BY_REF(Color4F, _endColorVar, EndColorVar) + Color4F _endColorVar; //* initial angle of each particle - CC_PROPERTY(float, _startSpin, StartSpin) + float _startSpin; //* initial angle of each particle - CC_PROPERTY(float, _startSpinVar, StartSpinVar) + float _startSpinVar; //* initial angle of each particle - CC_PROPERTY(float, _endSpin, EndSpin) + float _endSpin; //* initial angle of each particle - CC_PROPERTY(float, _endSpinVar, EndSpinVar) + float _endSpinVar; /** emission rate of the particles */ - CC_PROPERTY(float, _emissionRate, EmissionRate) + float _emissionRate; /** maximum particles of the system */ - CC_PROPERTY(unsigned int, _totalParticles, TotalParticles) + unsigned int _totalParticles; /** conforms to CocosNodeTexture protocol */ - CC_PROPERTY(Texture2D*, _texture, Texture) + Texture2D* _texture; /** conforms to CocosNodeTexture protocol */ - CC_PROPERTY_PASS_BY_REF(BlendFunc, _blendFunc, BlendFunc) + BlendFunc _blendFunc; /** does the alpha value modify color */ - CC_PROPERTY(bool, _opacityModifyRGB, OpacityModifyRGB) + bool _opacityModifyRGB; /** particles movement type: Free or Grouped @since v0.8 */ - CC_PROPERTY(tPositionType, _positionType, PositionType) + tPositionType _positionType; }; // end of particle_nodes group diff --git a/cocos2dx/particle_nodes/CCParticleSystemQuad.h b/cocos2dx/particle_nodes/CCParticleSystemQuad.h index 6c6bfad9cc..528e1d429d 100644 --- a/cocos2dx/particle_nodes/CCParticleSystemQuad.h +++ b/cocos2dx/particle_nodes/CCParticleSystemQuad.h @@ -52,16 +52,6 @@ Special features and Limitations: */ class CC_DLL ParticleSystemQuad : public ParticleSystem { -protected: - V3F_C4B_T2F_Quad *_quads; // quads to be rendered - GLushort *_indices; // indices - -#if CC_TEXTURE_ATLAS_USE_VAO - GLuint _VAOname; -#endif - - GLuint _buffersVBO[2]; //0: vertex 1: indices - public: /** creates a Particle Emitter */ @@ -113,6 +103,16 @@ private: void setupVBO(); #endif bool allocMemory(); + +protected: + V3F_C4B_T2F_Quad *_quads; // quads to be rendered + GLushort *_indices; // indices + +#if CC_TEXTURE_ATLAS_USE_VAO + GLuint _VAOname; +#endif + + GLuint _buffersVBO[2]; //0: vertex 1: indices }; // end of particle_nodes group diff --git a/cocos2dx/platform/CCCommon.h b/cocos2dx/platform/CCCommon.h index 015b9b6e9a..ff98158a14 100644 --- a/cocos2dx/platform/CCCommon.h +++ b/cocos2dx/platform/CCCommon.h @@ -40,7 +40,7 @@ static const int kMaxLogLen = 16*1024; /** @brief Output Debug message. */ -void CC_DLL CCLog(const char * pszFormat, ...) CC_FORMAT_PRINTF(1, 2); +void CC_DLL log(const char * pszFormat, ...) CC_FORMAT_PRINTF(1, 2); /** * lua can not deal with ... diff --git a/cocos2dx/platform/CCImage.h b/cocos2dx/platform/CCImage.h index 01aa23b46f..dd2895a511 100644 --- a/cocos2dx/platform/CCImage.h +++ b/cocos2dx/platform/CCImage.h @@ -48,7 +48,7 @@ public: friend class TextureCache; Image(); - ~Image(); + virtual ~Image(); typedef enum { @@ -145,25 +145,25 @@ public: #endif - unsigned char * getData() { return _data; } - int getDataLen() { return _width * _height; } - - - bool hasAlpha() { return _hasAlpha; } - bool isPremultipliedAlpha() { return _preMulti; } - - /** - @brief Save Image data to the specified file, with specified format. - @param pszFilePath the file's absolute path, including file suffix. - @param bIsToRGB whether the image is saved as RGB format. - */ + @brief Save Image data to the specified file, with specified format. + @param pszFilePath the file's absolute path, including file suffix. + @param bIsToRGB whether the image is saved as RGB format. + */ bool saveToFile(const char *pszFilePath, bool bIsToRGB = true); + + // Getters + inline unsigned char * getData() { return _data; } + inline int getDataLen() { return _width * _height; } - CC_SYNTHESIZE_READONLY(unsigned short, _width, Width); - CC_SYNTHESIZE_READONLY(unsigned short, _height, Height); - CC_SYNTHESIZE_READONLY(int, _bitsPerComponent, BitsPerComponent); + inline bool hasAlpha() { return _hasAlpha; } + inline bool isPremultipliedAlpha() { return _preMulti; } + inline unsigned short getWidth() { return _width; }; + inline unsigned short getHeight() { return _height; }; + inline int getBitsPerComponent() { return _bitsPerComponent; }; + // + protected: bool _initWithJpgData(void *pData, int nDatalen); bool _initWithPngData(void *pData, int nDatalen); @@ -173,6 +173,10 @@ protected: bool _saveImageToPNG(const char *pszFilePath, bool bIsToRGB = true); bool _saveImageToJPG(const char *pszFilePath); + unsigned short _width; + unsigned short _height; + int _bitsPerComponent; + unsigned char *_data; bool _hasAlpha; bool _preMulti; diff --git a/cocos2dx/platform/CCImageCommon_cpp.h b/cocos2dx/platform/CCImageCommon_cpp.h index 321c6570ca..b68ff02c40 100644 --- a/cocos2dx/platform/CCImageCommon_cpp.h +++ b/cocos2dx/platform/CCImageCommon_cpp.h @@ -306,7 +306,7 @@ bool Image::_initWithJpgData(void * data, int nSize) /* If we get here, the JPEG code has signaled an error. * We need to clean up the JPEG object, close the input file, and return. */ - CCLog("%d", bRet); + log("%d", bRet); jpeg_destroy_decompress(&cinfo); break; } diff --git a/cocos2dx/platform/CCPlatformMacros.h b/cocos2dx/platform/CCPlatformMacros.h index d08122bda2..814ba46940 100644 --- a/cocos2dx/platform/CCPlatformMacros.h +++ b/cocos2dx/platform/CCPlatformMacros.h @@ -205,7 +205,7 @@ public: virtual void set##funName(varType var) \ #define CC_BREAK_IF(cond) if(cond) break #define __CCLOGWITHFUNCTION(s, ...) \ - CCLog("%s : %s",__FUNCTION__, String::createWithFormat(s, ##__VA_ARGS__)->getCString()) + log("%s : %s",__FUNCTION__, String::createWithFormat(s, ##__VA_ARGS__)->getCString()) // cocos2d debug #if !defined(COCOS2D_DEBUG) || COCOS2D_DEBUG == 0 @@ -215,15 +215,15 @@ public: virtual void set##funName(varType var) \ #define CCLOGWARN(...) do {} while (0) #elif COCOS2D_DEBUG == 1 -#define CCLOG(format, ...) cocos2d::CCLog(format, ##__VA_ARGS__) -#define CCLOGERROR(format,...) cocos2d::CCLog(format, ##__VA_ARGS__) +#define CCLOG(format, ...) cocos2d::log(format, ##__VA_ARGS__) +#define CCLOGERROR(format,...) cocos2d::log(format, ##__VA_ARGS__) #define CCLOGINFO(format,...) do {} while (0) #define CCLOGWARN(...) __CCLOGWITHFUNCTION(__VA_ARGS__) #elif COCOS2D_DEBUG > 1 -#define CCLOG(format, ...) cocos2d::CCLog(format, ##__VA_ARGS__) -#define CCLOGERROR(format,...) cocos2d::CCLog(format, ##__VA_ARGS__) -#define CCLOGINFO(format,...) cocos2d::CCLog(format, ##__VA_ARGS__) +#define CCLOG(format, ...) cocos2d::log(format, ##__VA_ARGS__) +#define CCLOGERROR(format,...) cocos2d::log(format, ##__VA_ARGS__) +#define CCLOGINFO(format,...) cocos2d::log(format, ##__VA_ARGS__) #define CCLOGWARN(...) __CCLOGWITHFUNCTION(__VA_ARGS__) #endif // COCOS2D_DEBUG @@ -231,7 +231,7 @@ public: virtual void set##funName(varType var) \ #if !defined(COCOS2D_DEBUG) || COCOS2D_DEBUG == 0 || CC_LUA_ENGINE_DEBUG == 0 #define LUALOG(...) #else -#define LUALOG(format, ...) cocos2d::CCLog(format, ##__VA_ARGS__) +#define LUALOG(format, ...) cocos2d::log(format, ##__VA_ARGS__) #endif // Lua engine debug #if defined(__GNUC__) && ((__GNUC__ >= 5) || ((__GNUG__ == 4) && (__GNUC_MINOR__ >= 4))) \ @@ -285,4 +285,17 @@ private: \ #define CC_UNUSED #endif +// +// CC_REQUIRES_NULL_TERMINATION +// +#if !defined(CC_REQUIRES_NULL_TERMINATION) + #if defined(__APPLE_CC__) && (__APPLE_CC__ >= 5549) + #define CC_REQUIRES_NULL_TERMINATION __attribute__((sentinel(0,1))) + #elif defined(__GNUC__) + #define CC_REQUIRES_NULL_TERMINATION __attribute__((sentinel)) + #else + #define CC_REQUIRES_NULL_TERMINATION + #endif +#endif + #endif // __CC_PLATFORM_MACROS_H__ diff --git a/cocos2dx/platform/CCSAXParser.cpp b/cocos2dx/platform/CCSAXParser.cpp index e8ff678f04..7a857452e0 100644 --- a/cocos2dx/platform/CCSAXParser.cpp +++ b/cocos2dx/platform/CCSAXParser.cpp @@ -53,14 +53,14 @@ private: bool XmlSaxHander::VisitEnter( const tinyxml2::XMLElement& element, const tinyxml2::XMLAttribute* firstAttribute ) { - //CCLog(" VisitEnter %s",element.Value()); + //log(" VisitEnter %s",element.Value()); std::vector attsVector; for( const tinyxml2::XMLAttribute* attrib = firstAttribute; attrib; attrib = attrib->Next() ) { - //CCLog("%s", attrib->Name()); + //log("%s", attrib->Name()); attsVector.push_back(attrib->Name()); - //CCLog("%s",attrib->Value()); + //log("%s",attrib->Value()); attsVector.push_back(attrib->Value()); } @@ -73,7 +73,7 @@ bool XmlSaxHander::VisitEnter( const tinyxml2::XMLElement& element, const tinyxm } bool XmlSaxHander::VisitExit( const tinyxml2::XMLElement& element ) { - //CCLog("VisitExit %s",element.Value()); + //log("VisitExit %s",element.Value()); SAXParser::endElement(_ccsaxParserImp, (const CC_XML_CHAR *)element.Value()); return true; @@ -81,7 +81,7 @@ bool XmlSaxHander::VisitExit( const tinyxml2::XMLElement& element ) bool XmlSaxHander::Visit( const tinyxml2::XMLText& text ) { - //CCLog("Visit %s",text.Value()); + //log("Visit %s",text.Value()); SAXParser::textHandler(_ccsaxParserImp, (const CC_XML_CHAR *)text.Value(), strlen(text.Value())); return true; } diff --git a/cocos2dx/platform/android/CCCommon.cpp b/cocos2dx/platform/android/CCCommon.cpp index 16b48899be..e00c05dbec 100644 --- a/cocos2dx/platform/android/CCCommon.cpp +++ b/cocos2dx/platform/android/CCCommon.cpp @@ -32,6 +32,7 @@ NS_CC_BEGIN #define MAX_LEN (cocos2d::kMaxLogLen + 1) +// XXX deprecated void CCLog(const char * pszFormat, ...) { char buf[MAX_LEN]; @@ -44,6 +45,18 @@ void CCLog(const char * pszFormat, ...) __android_log_print(ANDROID_LOG_DEBUG, "cocos2d-x debug info", buf); } +void log(const char * pszFormat, ...) +{ + char buf[MAX_LEN]; + + va_list args; + va_start(args, pszFormat); + vsnprintf(buf, MAX_LEN, pszFormat, args); + va_end(args); + + __android_log_print(ANDROID_LOG_DEBUG, "cocos2d-x debug info", buf); +} + void MessageBox(const char * pszMsg, const char * pszTitle) { showDialogJNI(pszMsg, pszTitle); diff --git a/cocos2dx/platform/emscripten/CCCommon.cpp b/cocos2dx/platform/emscripten/CCCommon.cpp index cf0618745b..31976935e5 100644 --- a/cocos2dx/platform/emscripten/CCCommon.cpp +++ b/cocos2dx/platform/emscripten/CCCommon.cpp @@ -28,6 +28,7 @@ NS_CC_BEGIN #define MAX_LEN (cocos2d::kMaxLogLen + 1) +// XXX deprecated void CCLog(const char * pszFormat, ...) { char buf[MAX_LEN]; @@ -40,10 +41,22 @@ void CCLog(const char * pszFormat, ...) fprintf(stderr, "cocos2d-x debug info %s\n", buf); } +void log(const char * pszFormat, ...) +{ + char buf[MAX_LEN]; + + va_list args; + va_start(args, pszFormat); + vsnprintf(buf, MAX_LEN, pszFormat, args); + va_end(args); + + fprintf(stderr, "cocos2d-x debug info %s\n", buf); +} + void MessageBox(const char * pszMsg, const char * pszTitle) { // MessageBoxA(NULL, pszMsg, pszTitle, MB_OK); - CCLog(pszMsg); + log(pszMsg); } void LuaLog(const char * pszFormat) diff --git a/cocos2dx/platform/ios/CCCommon.mm b/cocos2dx/platform/ios/CCCommon.mm index f78eb0742c..dcf3a66a33 100644 --- a/cocos2dx/platform/ios/CCCommon.mm +++ b/cocos2dx/platform/ios/CCCommon.mm @@ -31,6 +31,7 @@ NS_CC_BEGIN +// XXX deprecated void CCLog(const char * pszFormat, ...) { printf("Cocos2d: "); @@ -43,7 +44,19 @@ void CCLog(const char * pszFormat, ...) printf("\n"); } -// ios no MessageBox, use CCLog instead +void log(const char * pszFormat, ...) +{ + printf("Cocos2d: "); + char szBuf[kMaxLogLen+1] = {0}; + va_list ap; + va_start(ap, pszFormat); + vsnprintf(szBuf, kMaxLogLen, pszFormat, ap); + va_end(ap); + printf("%s", szBuf); + printf("\n"); +} + +// ios no MessageBox, use log instead void MessageBox(const char * pszMsg, const char * pszTitle) { NSString * title = (pszTitle) ? [NSString stringWithUTF8String : pszTitle] : nil; diff --git a/cocos2dx/platform/linux/CCCommon.cpp b/cocos2dx/platform/linux/CCCommon.cpp index d46c8cd794..880d626540 100644 --- a/cocos2dx/platform/linux/CCCommon.cpp +++ b/cocos2dx/platform/linux/CCCommon.cpp @@ -28,6 +28,7 @@ NS_CC_BEGIN #define MAX_LEN (cocos2d::kMaxLogLen + 1) +// XXX deprecated void CCLog(const char * pszFormat, ...) { char szBuf[MAX_LEN]; @@ -48,9 +49,29 @@ void CCLog(const char * pszFormat, ...) fprintf(stderr, "cocos2d-x debug info [%s]\n", szBuf); } +void log(const char * pszFormat, ...) +{ + char szBuf[MAX_LEN]; + + va_list ap; + va_start(ap, pszFormat); + vsnprintf(szBuf, MAX_LEN, pszFormat, ap); + va_end(ap); + + // Strip any trailing newlines from log message. + size_t len = strlen(szBuf); + while (len && szBuf[len-1] == '\n') + { + szBuf[len-1] = '\0'; + len--; + } + + fprintf(stderr, "cocos2d-x debug info [%s]\n", szBuf); +} + void MessageBox(const char * pszMsg, const char * pszTitle) { - CCLog("%s: %s", pszTitle, pszMsg); + log("%s: %s", pszTitle, pszMsg); } void LuaLog(const char * pszFormat) diff --git a/cocos2dx/platform/linux/CCEGLView.cpp b/cocos2dx/platform/linux/CCEGLView.cpp index d36c0e95fc..247af6e62c 100644 --- a/cocos2dx/platform/linux/CCEGLView.cpp +++ b/cocos2dx/platform/linux/CCEGLView.cpp @@ -325,20 +325,20 @@ bool EGLView::initGL() if (GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader) { - CCLog("Ready for GLSL"); + log("Ready for GLSL"); } else { - CCLog("Not totally ready :("); + log("Not totally ready :("); } if (glewIsSupported("GL_VERSION_2_0")) { - CCLog("Ready for OpenGL 2.0"); + log("Ready for OpenGL 2.0"); } else { - CCLog("OpenGL 2.0 not supported"); + log("OpenGL 2.0 not supported"); } // Enable point size by default on linux. diff --git a/cocos2dx/platform/mac/CCCommon.mm b/cocos2dx/platform/mac/CCCommon.mm index e9d8904724..b2b4781460 100644 --- a/cocos2dx/platform/mac/CCCommon.mm +++ b/cocos2dx/platform/mac/CCCommon.mm @@ -32,6 +32,7 @@ NS_CC_BEGIN +// XXX deprecated void CCLog(const char * pszFormat, ...) { printf("Cocos2d: "); @@ -46,12 +47,27 @@ void CCLog(const char * pszFormat, ...) fflush(stdout); } +void log(const char * pszFormat, ...) +{ + printf("Cocos2d: "); + char szBuf[kMaxLogLen]; + + va_list ap; + va_start(ap, pszFormat); + vsnprintf(szBuf, kMaxLogLen, pszFormat, ap); + va_end(ap); + printf("%s", szBuf); + printf("\n"); + fflush(stdout); +} + + void LuaLog(const char * pszFormat) { puts(pszFormat); } -// ios no MessageBox, use CCLog instead +// ios no MessageBox, use log instead void MessageBox(const char * pszMsg, const char * pszTitle) { NSString * title = (pszTitle) ? [NSString stringWithUTF8String : pszTitle] : nil; diff --git a/cocos2dx/platform/nacl/CCCommon.cpp b/cocos2dx/platform/nacl/CCCommon.cpp index 01601ab744..898ea70d70 100644 --- a/cocos2dx/platform/nacl/CCCommon.cpp +++ b/cocos2dx/platform/nacl/CCCommon.cpp @@ -29,6 +29,7 @@ NS_CC_BEGIN #define MAX_LEN (cocos2d::kMaxLogLen + 1) +// XXX deprecated void CCLog(const char * pszFormat, ...) { char szBuf[MAX_LEN]; @@ -49,14 +50,34 @@ void CCLog(const char * pszFormat, ...) fprintf(stderr, "cocos2d-x debug info [%s]\n", szBuf); } +void log(const char * pszFormat, ...) +{ + char szBuf[MAX_LEN]; + + va_list ap; + va_start(ap, pszFormat); + vsnprintf( szBuf, MAX_LEN, pszFormat, ap); + va_end(ap); + + // Strip any trailing newlines from log message. + size_t len = strlen(szBuf); + while (len && szBuf[len-1] == '\n') + { + szBuf[len-1] = '\0'; + len--; + } + + fprintf(stderr, "cocos2d-x debug info [%s]\n", szBuf); +} + void MessageBox(const char * pszMsg, const char * pszTitle) { - CCLog("%s: %s", pszTitle, pszMsg); + log("%s: %s", pszTitle, pszMsg); } void LuaLog(const char * pszFormat) { - CCLog("%s", pszFormat); + log("%s", pszFormat); } NS_CC_END diff --git a/cocos2dx/platform/nacl/CCInstance.cpp b/cocos2dx/platform/nacl/CCInstance.cpp index 0a71c85d44..ea23189d5f 100644 --- a/cocos2dx/platform/nacl/CCInstance.cpp +++ b/cocos2dx/platform/nacl/CCInstance.cpp @@ -74,7 +74,7 @@ void CocosPepperInstance::DidChangeView(const pp::View& view) bool CocosPepperInstance::Init(uint32_t argc, const char* argn[], const char* argv[]) { - CCLog("CocosPepperInstance::Init: %x %p", pp_instance(), + log("CocosPepperInstance::Init: %x %p", pp_instance(), pp::Module::Get()->get_browser_interface()); nacl_io_init_ppapi(pp_instance(), pp::Module::Get()->get_browser_interface()); diff --git a/cocos2dx/platform/tizen/CCCommon.cpp b/cocos2dx/platform/tizen/CCCommon.cpp index 22c8364a9c..26f764de6e 100644 --- a/cocos2dx/platform/tizen/CCCommon.cpp +++ b/cocos2dx/platform/tizen/CCCommon.cpp @@ -31,6 +31,7 @@ NS_CC_BEGIN #define MAX_LEN (cocos2d::kMaxLogLen + 1) +// XXX deprecated void CCLog(const char * pszFormat, ...) { char szBuf[MAX_LEN]; @@ -51,9 +52,29 @@ void CCLog(const char * pszFormat, ...) AppLog("cocos2d-x debug info [%s]\n", szBuf); } +void log(const char * pszFormat, ...) +{ + char szBuf[MAX_LEN]; + + va_list ap; + va_start(ap, pszFormat); + vsnprintf(szBuf, MAX_LEN, pszFormat, ap); + va_end(ap); + + // Strip any trailing newlines from log message. + size_t len = strlen(szBuf); + while (len && szBuf[len-1] == '\n') + { + szBuf[len-1] = '\0'; + len--; + } + + AppLog("cocos2d-x debug info [%s]\n", szBuf); +} + void MessageBox(const char * pszMsg, const char * pszTitle) { - CCLog("%s: %s", pszTitle, pszMsg); + log("%s: %s", pszTitle, pszMsg); } void LuaLog(const char * pszFormat) diff --git a/cocos2dx/platform/win32/CCCommon.cpp b/cocos2dx/platform/win32/CCCommon.cpp index 178f6f1983..2a66aaf49e 100644 --- a/cocos2dx/platform/win32/CCCommon.cpp +++ b/cocos2dx/platform/win32/CCCommon.cpp @@ -28,6 +28,7 @@ NS_CC_BEGIN #define MAX_LEN (cocos2d::kMaxLogLen + 1) +// XXX deprecated void CCLog(const char * pszFormat, ...) { char szBuf[MAX_LEN]; @@ -46,6 +47,24 @@ void CCLog(const char * pszFormat, ...) printf("%s\n", szBuf); } +void log(const char * pszFormat, ...) +{ + char szBuf[MAX_LEN]; + + va_list ap; + va_start(ap, pszFormat); + vsnprintf_s(szBuf, MAX_LEN, MAX_LEN, pszFormat, ap); + va_end(ap); + + WCHAR wszBuf[MAX_LEN] = {0}; + MultiByteToWideChar(CP_UTF8, 0, szBuf, -1, wszBuf, sizeof(wszBuf)); + OutputDebugStringW(wszBuf); + OutputDebugStringA("\n"); + + WideCharToMultiByte(CP_ACP, 0, wszBuf, sizeof(wszBuf), szBuf, sizeof(szBuf), NULL, FALSE); + printf("%s\n", szBuf); +} + void MessageBox(const char * pszMsg, const char * pszTitle) { MessageBoxA(NULL, pszMsg, pszTitle, MB_OK); diff --git a/cocos2dx/platform/win32/CCEGLView.cpp b/cocos2dx/platform/win32/CCEGLView.cpp index fc669dd284..21cca48145 100644 --- a/cocos2dx/platform/win32/CCEGLView.cpp +++ b/cocos2dx/platform/win32/CCEGLView.cpp @@ -105,10 +105,10 @@ static bool glew_dynamic_binding() // If the current opengl driver doesn't have framebuffers methods, check if an extension exists if (glGenFramebuffers == NULL) { - CCLog("OpenGL: glGenFramebuffers is NULL, try to detect an extension"); + log("OpenGL: glGenFramebuffers is NULL, try to detect an extension"); if (strstr(gl_extensions, "ARB_framebuffer_object")) { - CCLog("OpenGL: ARB_framebuffer_object is supported"); + log("OpenGL: ARB_framebuffer_object is supported"); glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC) wglGetProcAddress("glIsRenderbuffer"); glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC) wglGetProcAddress("glBindRenderbuffer"); @@ -131,7 +131,7 @@ static bool glew_dynamic_binding() else if (strstr(gl_extensions, "EXT_framebuffer_object")) { - CCLog("OpenGL: EXT_framebuffer_object is supported"); + log("OpenGL: EXT_framebuffer_object is supported"); glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC) wglGetProcAddress("glIsRenderbufferEXT"); glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC) wglGetProcAddress("glBindRenderbufferEXT"); glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC) wglGetProcAddress("glDeleteRenderbuffersEXT"); @@ -152,8 +152,8 @@ static bool glew_dynamic_binding() } else { - CCLog("OpenGL: No framebuffers extension is supported"); - CCLog("OpenGL: Any call to Fbo will crash!"); + log("OpenGL: No framebuffers extension is supported"); + log("OpenGL: Any call to Fbo will crash!"); return false; } } @@ -228,20 +228,20 @@ bool EGLView::initGL() if (GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader) { - CCLog("Ready for GLSL"); + log("Ready for GLSL"); } else { - CCLog("Not totally ready :("); + log("Not totally ready :("); } if (glewIsSupported("GL_VERSION_2_0")) { - CCLog("Ready for OpenGL 2.0"); + log("Ready for OpenGL 2.0"); } else { - CCLog("OpenGL 2.0 not supported"); + log("OpenGL 2.0 not supported"); } if(glew_dynamic_binding() == false) diff --git a/cocos2dx/platform/win32/CCImage.cpp b/cocos2dx/platform/win32/CCImage.cpp index 6543df7045..f53f375c0d 100644 --- a/cocos2dx/platform/win32/CCImage.cpp +++ b/cocos2dx/platform/win32/CCImage.cpp @@ -383,7 +383,7 @@ bool Image::initWithString( if (! dc.setFont(pFontName, nSize)) { - CCLog("Can't found font(%s), use system default", pFontName); + log("Can't found font(%s), use system default", pFontName); } // draw text diff --git a/cocos2dx/proj.emscripten/cocos2dx.mk b/cocos2dx/proj.emscripten/cocos2dx.mk index 348d635dfd..b6893beeea 100644 --- a/cocos2dx/proj.emscripten/cocos2dx.mk +++ b/cocos2dx/proj.emscripten/cocos2dx.mk @@ -97,9 +97,12 @@ STATICLIBS = \ SHAREDLIBS += -L$(LIB_DIR) -Wl,-rpath,$(RPATH_REL)/$(LIB_DIR) LIBS = -lrt -lz +HTMLTPL_DIR = $(COCOS_ROOT)/tools/emscripten-template +HTMLTPL_FILE = index.html + clean: rm -rf $(OBJ_DIR) - rm -f $(TARGET).js $(TARGET).data $(TARGET).data.js $(BIN_DIR)/index.html core + rm -rf $(TARGET).js $(TARGET).data $(TARGET).data.js $(BIN_DIR) core .PHONY: all clean @@ -108,7 +111,7 @@ clean: ifdef EXECUTABLE TARGET := $(BIN_DIR)/$(EXECUTABLE) -all: $(TARGET).js $(TARGET).data $(BIN_DIR)/index.html +all: $(TARGET).js $(TARGET).data $(BIN_DIR)/$(HTMLTPL_FILE) run: $(TARGET) cd $(dir $^) && ./$(notdir $^) diff --git a/cocos2dx/sprite_nodes/CCAnimation.cpp b/cocos2dx/sprite_nodes/CCAnimation.cpp index e4a536d5ba..89cbbe8671 100644 --- a/cocos2dx/sprite_nodes/CCAnimation.cpp +++ b/cocos2dx/sprite_nodes/CCAnimation.cpp @@ -88,7 +88,7 @@ Animation* Animation::createWithSpriteFrames(Array *frames, float delay/* = 0.0f return pAnimation; } -Animation* Animation::create(Array* arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops) +Animation* Animation::create(Array* arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops /* = 1 */) { Animation *pAnimation = new Animation(); pAnimation->initWithAnimationFrames(arrayOfAnimationFrameNames, delayPerUnit, loops); diff --git a/cocos2dx/sprite_nodes/CCAnimation.h b/cocos2dx/sprite_nodes/CCAnimation.h index 7648677a5a..c4840f8f06 100644 --- a/cocos2dx/sprite_nodes/CCAnimation.h +++ b/cocos2dx/sprite_nodes/CCAnimation.h @@ -61,18 +61,46 @@ public: /** initializes the animation frame with a spriteframe, number of delay units and a notification user info */ bool initWithSpriteFrame(SpriteFrame* spriteFrame, float delayUnits, Dictionary* userInfo); + SpriteFrame* getSpriteFrame() const { return _spriteFrame; }; + + void setSpriteFrame(SpriteFrame* frame) + { + CC_SAFE_RETAIN(frame); + CC_SAFE_RELEASE(_spriteFrame); + _spriteFrame = frame; + } + + /** Gets the units of time the frame takes */ + float getDelayUnits() const { return _delayUnits; }; + + /** Sets the units of time the frame takes */ + void setDelayUnits(float delayUnits) { _delayUnits = delayUnits; }; + + /** @brief Gets user infomation + A AnimationFrameDisplayedNotification notification will be broadcast when the frame is displayed with this dictionary as UserInfo. If UserInfo is nil, then no notification will be broadcast. + */ + Dictionary* getUserInfo() const { return _userInfo; }; + + /** Sets user infomation */ + void setUserInfo(Dictionary* userInfo) + { + CC_SAFE_RETAIN(userInfo); + CC_SAFE_RELEASE(_userInfo); + _userInfo = userInfo; + } + // Overrides virtual AnimationFrame *clone() const override; protected: /** SpriteFrameName to be used */ - CC_SYNTHESIZE_RETAIN(SpriteFrame*, _spriteFrame, SpriteFrame) + SpriteFrame* _spriteFrame; /** how many units of time the frame takes */ - CC_SYNTHESIZE(float, _delayUnits, DelayUnits) + float _delayUnits; /** A AnimationFrameDisplayedNotification notification will be broadcast when the frame is displayed with this dictionary as UserInfo. If UserInfo is nil, then no notification will be broadcast. */ - CC_SYNTHESIZE_RETAIN(Dictionary*, _userInfo, UserInfo) + Dictionary* _userInfo; }; @@ -103,10 +131,7 @@ public: /* Creates an animation with an array of AnimationFrame, the delay per units in seconds and and how many times it should be executed. @since v2.0 */ - static Animation* create(Array *arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops); - static Animation* create(Array *arrayOfAnimationFrameNames, float delayPerUnit) { - return Animation::create(arrayOfAnimationFrameNames, delayPerUnit, 1); - } + static Animation* create(Array *arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops = 1); Animation(); virtual ~Animation(void); @@ -140,27 +165,63 @@ public: */ void addSpriteFrameWithTexture(Texture2D* pobTexture, const Rect& rect); + /** Gets the total Delay units of the Animation. */ + float getTotalDelayUnits() const { return _totalDelayUnits; }; + + /** Sets the delay in seconds of the "delay unit" */ + void setDelayPerUnit(float delayPerUnit) { _delayPerUnit = delayPerUnit; }; + + /** Gets the delay in seconds of the "delay unit" */ + float getDelayPerUnit() const { return _delayPerUnit; }; + + + /** Gets the duration in seconds of the whole animation. It is the result of totalDelayUnits * delayPerUnit */ + float getDuration() const; + + /** Gets the array of AnimationFrames */ + Array* getFrames() const { return _frames; }; + + /** Sets the array of AnimationFrames */ + void setFrames(Array* frames) + { + CC_SAFE_RETAIN(frames); + CC_SAFE_RELEASE(_frames); + _frames = frames; + } + + /** Checks whether to restore the original frame when animation finishes. */ + bool getRestoreOriginalFrame() const { return _restoreOriginalFrame; }; + + /** Sets whether to restore the original frame when animation finishes */ + void setRestoreOriginalFrame(bool restoreOriginalFrame) { _restoreOriginalFrame = restoreOriginalFrame; }; + + /** Gets the times the animation is going to loop. 0 means animation is not animated. 1, animation is executed one time, ... */ + unsigned int getLoops() const { return _loops; }; + + /** Sets the times the animation is going to loop. 0 means animation is not animated. 1, animation is executed one time, ... */ + void setLoops(unsigned int loops) { _loops = loops; }; + // overrides virtual Animation *clone() const override; protected: /** total Delay units of the Animation. */ - CC_SYNTHESIZE_READONLY(float, _totalDelayUnits, TotalDelayUnits) + float _totalDelayUnits; /** Delay in seconds of the "delay unit" */ - CC_SYNTHESIZE(float, _delayPerUnit, DelayPerUnit) + float _delayPerUnit; /** duration in seconds of the whole animation. It is the result of totalDelayUnits * delayPerUnit */ - CC_PROPERTY_READONLY(float, _duration, Duration) + float _duration; /** array of AnimationFrames */ - CC_SYNTHESIZE_RETAIN(Array*, _frames, Frames) + Array* _frames; /** whether or not it shall restore the original frame when the animation finishes */ - CC_SYNTHESIZE(bool, _restoreOriginalFrame, RestoreOriginalFrame) + bool _restoreOriginalFrame; /** how many times the animation is going to loop. 0 means animation is not animated. 1, animation is executed one time, ... */ - CC_SYNTHESIZE(unsigned int, _loops, Loops) + unsigned int _loops; }; // end of sprite_nodes group diff --git a/cocos2dx/sprite_nodes/CCSprite.cpp b/cocos2dx/sprite_nodes/CCSprite.cpp index 5c303fabde..df593fcfa1 100644 --- a/cocos2dx/sprite_nodes/CCSprite.cpp +++ b/cocos2dx/sprite_nodes/CCSprite.cpp @@ -1119,7 +1119,7 @@ void Sprite::setTexture(Texture2D *texture) } } -Texture2D* Sprite::getTexture(void) +Texture2D* Sprite::getTexture(void) const { return _texture; } diff --git a/cocos2dx/sprite_nodes/CCSprite.h b/cocos2dx/sprite_nodes/CCSprite.h index 403e9b052a..313abd4b2e 100644 --- a/cocos2dx/sprite_nodes/CCSprite.h +++ b/cocos2dx/sprite_nodes/CCSprite.h @@ -449,9 +449,9 @@ public: /// @{ /// @name Functions inherited from TextureProtocol virtual void setTexture(Texture2D *texture) override; - virtual Texture2D* getTexture(void) override; + virtual Texture2D* getTexture() const override; inline void setBlendFunc(const BlendFunc &blendFunc) override { _blendFunc = blendFunc; } - inline const BlendFunc& getBlendFunc(void) const override { return _blendFunc; } + inline const BlendFunc& getBlendFunc() const override { return _blendFunc; } /// @} /// @{ diff --git a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp index 8d199939b4..e3c9744a1e 100644 --- a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp @@ -684,7 +684,7 @@ const BlendFunc& SpriteBatchNode::getBlendFunc(void) const return _blendFunc; } -Texture2D* SpriteBatchNode::getTexture(void) +Texture2D* SpriteBatchNode::getTexture(void) const { return _textureAtlas->getTexture(); } diff --git a/cocos2dx/sprite_nodes/CCSpriteBatchNode.h b/cocos2dx/sprite_nodes/CCSpriteBatchNode.h index ac1ce475bc..4651fb3607 100644 --- a/cocos2dx/sprite_nodes/CCSpriteBatchNode.h +++ b/cocos2dx/sprite_nodes/CCSpriteBatchNode.h @@ -67,19 +67,13 @@ public: /** creates a SpriteBatchNode with a texture2d and capacity of children. The capacity will be increased in 33% in runtime if it run out of space. */ - static SpriteBatchNode* createWithTexture(Texture2D* tex, int capacity); - static SpriteBatchNode* createWithTexture(Texture2D* tex) { - return SpriteBatchNode::createWithTexture(tex, kDefaultSpriteBatchCapacity); - } + static SpriteBatchNode* createWithTexture(Texture2D* tex, int capacity = kDefaultSpriteBatchCapacity); /** creates a SpriteBatchNode with a file image (.png, .jpeg, .pvr, etc) and capacity of children. The capacity will be increased in 33% in runtime if it run out of space. The file will be loaded using the TextureMgr. */ - static SpriteBatchNode* create(const char* fileImage, int capacity); - static SpriteBatchNode* create(const char* fileImage) { - return SpriteBatchNode::create(fileImage, kDefaultSpriteBatchCapacity); - } + static SpriteBatchNode* create(const char* fileImage, int capacity = kDefaultSpriteBatchCapacity); SpriteBatchNode(); virtual ~SpriteBatchNode(); @@ -133,7 +127,7 @@ public: // Overrides // // TextureProtocol - virtual Texture2D* getTexture(void) override; + virtual Texture2D* getTexture(void) const override; virtual void setTexture(Texture2D *texture) override; virtual void setBlendFunc(const BlendFunc &blendFunc) override; virtual const BlendFunc& getBlendFunc(void) const override; @@ -174,7 +168,7 @@ protected: TextureAtlas *_textureAtlas; BlendFunc _blendFunc; - // all descendants: children, gran children, etc... + // all descendants: children, grand children, etc... Array* _descendants; }; diff --git a/cocos2dx/support/CCNotificationCenter.cpp b/cocos2dx/support/CCNotificationCenter.cpp index 0be4b78070..c4aca29a6f 100644 --- a/cocos2dx/support/CCNotificationCenter.cpp +++ b/cocos2dx/support/CCNotificationCenter.cpp @@ -247,17 +247,13 @@ NotificationObserver::NotificationObserver(Object *target, _selector = selector; _object = obj; - _name = new char[strlen(name)+1]; - memset(_name,0,strlen(name)+1); - - string orig (name); - orig.copy(_name,strlen(name),0); + _name = name; _handler = 0; } NotificationObserver::~NotificationObserver() { - CC_SAFE_DELETE_ARRAY(_name); + } void NotificationObserver::performSelector(Object *obj) @@ -282,17 +278,17 @@ SEL_CallFuncO NotificationObserver::getSelector() const return _selector; } -char *NotificationObserver::getName() const +const char* NotificationObserver::getName() const { - return _name; + return _name.c_str(); } -Object *NotificationObserver::getObject() const +Object* NotificationObserver::getObject() const { return _object; } -int NotificationObserver::getHandler() +int NotificationObserver::getHandler() const { return _handler; } diff --git a/cocos2dx/support/CCNotificationCenter.h b/cocos2dx/support/CCNotificationCenter.h index 6563422e4f..b12a2b3d16 100644 --- a/cocos2dx/support/CCNotificationCenter.h +++ b/cocos2dx/support/CCNotificationCenter.h @@ -139,12 +139,21 @@ public: /** Invokes the callback function of this observer */ void performSelector(Object *obj); + + // Getters / Setters + Object* getTarget() const; + SEL_CallFuncO getSelector() const; + const char* getName() const; + Object* getObject() const; + int getHandler() const; + void setHandler(int handler); + private: - CC_PROPERTY_READONLY(Object *, _target, Target); - CC_PROPERTY_READONLY(SEL_CallFuncO, _selector, Selector); - CC_PROPERTY_READONLY(char *, _name, Name); - CC_PROPERTY_READONLY(Object *, _object, Object); - CC_PROPERTY(int, _handler,Handler); + Object* _target; + SEL_CallFuncO _selector; + std::string _name; + Object* _object; + int _handler; }; NS_CC_END diff --git a/cocos2dx/support/CCProfiling.cpp b/cocos2dx/support/CCProfiling.cpp index 8dbd637bb4..3b50ff30a0 100644 --- a/cocos2dx/support/CCProfiling.cpp +++ b/cocos2dx/support/CCProfiling.cpp @@ -91,7 +91,7 @@ void Profiler::displayTimers() CCDICT_FOREACH(_activeTimers, pElement) { ProfilingTimer* timer = static_cast(pElement->getObject()); - CCLog("%s", timer->description()); + log("%s", timer->description()); } } diff --git a/cocos2dx/text_input_node/CCTextFieldTTF.h b/cocos2dx/text_input_node/CCTextFieldTTF.h index 7acd779387..fc7893d620 100644 --- a/cocos2dx/text_input_node/CCTextFieldTTF.h +++ b/cocos2dx/text_input_node/CCTextFieldTTF.h @@ -125,8 +125,10 @@ public: // properties ////////////////////////////////////////////////////////////////////////// - CC_SYNTHESIZE(TextFieldDelegate *, _delegate, Delegate); - CC_SYNTHESIZE_READONLY(int, _charCount, CharCount); + inline TextFieldDelegate* getDelegate() const { return _delegate; }; + inline void setDelegate(TextFieldDelegate* delegate) { _delegate = delegate; }; + + inline int getCharCount() const { return _charCount; }; virtual const Color3B& getColorSpaceHolder(); virtual void setColorSpaceHolder(const Color3B& color); @@ -135,6 +137,9 @@ public: virtual void setString(const char *text); virtual const char* getString(void) const; protected: + TextFieldDelegate * _delegate; + int _charCount; + std::string * _inputText; // place holder text property diff --git a/cocos2dx/textures/CCTexture2D.cpp b/cocos2dx/textures/CCTexture2D.cpp index 33086e6b8b..2ed6ad2813 100644 --- a/cocos2dx/textures/CCTexture2D.cpp +++ b/cocos2dx/textures/CCTexture2D.cpp @@ -111,7 +111,6 @@ GLuint Texture2D::getName() const Size Texture2D::getContentSize() const { - Size ret; ret.width = _contentSize.width / CC_CONTENT_SCALE_FACTOR(); ret.height = _contentSize.height / CC_CONTENT_SCALE_FACTOR(); @@ -124,7 +123,7 @@ const Size& Texture2D::getContentSizeInPixels() return _contentSize; } -GLfloat Texture2D::getMaxS() +GLfloat Texture2D::getMaxS() const { return _maxS; } @@ -134,7 +133,7 @@ void Texture2D::setMaxS(GLfloat maxS) _maxS = maxS; } -GLfloat Texture2D::getMaxT() +GLfloat Texture2D::getMaxT() const { return _maxT; } @@ -144,7 +143,7 @@ void Texture2D::setMaxT(GLfloat maxT) _maxT = maxT; } -GLProgram* Texture2D::getShaderProgram(void) +GLProgram* Texture2D::getShaderProgram() const { return _shaderProgram; } diff --git a/cocos2dx/textures/CCTexture2D.h b/cocos2dx/textures/CCTexture2D.h index d9194d1d1f..85e90b0776 100644 --- a/cocos2dx/textures/CCTexture2D.h +++ b/cocos2dx/textures/CCTexture2D.h @@ -238,28 +238,60 @@ public: bool hasPremultipliedAlpha() const; bool hasMipmaps() const; + /** Gets the pixel format of the texture */ + Texture2DPixelFormat getPixelFormat() const; + + /** Gets the width of the texture in pixels */ + unsigned int getPixelsWide() const; + + /** Gets the height of the texture in pixels */ + unsigned int getPixelsHigh() const; + + /** Gets the texture name */ + GLuint getName() const; + + /** Gets max S */ + GLfloat getMaxS() const; + /** Sets max S */ + void setMaxS(GLfloat maxS); + + /** Gets max T */ + GLfloat getMaxT() const; + /** Sets max T */ + void setMaxT(GLfloat maxT); + + Size getContentSize() const; + + void setShaderProgram(GLProgram* program); + GLProgram* getShaderProgram() const; + private: bool initPremultipliedATextureWithImage(Image * image, unsigned int pixelsWide, unsigned int pixelsHigh); // By default PVR images are treated as if they don't have the alpha channel premultiplied bool _PVRHaveAlphaPremultiplied; +protected: /** pixel format of the texture */ - CC_PROPERTY_READONLY(Texture2DPixelFormat, _pixelFormat, PixelFormat) + Texture2DPixelFormat _pixelFormat; + /** width in pixels */ - CC_PROPERTY_READONLY(unsigned int, _pixelsWide, PixelsWide) + unsigned int _pixelsWide; + /** height in pixels */ - CC_PROPERTY_READONLY(unsigned int, _pixelsHigh, PixelsHigh) + unsigned int _pixelsHigh; /** texture name */ - CC_PROPERTY_READONLY(GLuint, _name, Name) + GLuint _name; /** texture max S */ - CC_PROPERTY(GLfloat, _maxS, MaxS) + GLfloat _maxS; + /** texture max T */ - CC_PROPERTY(GLfloat, _maxT, MaxT) + GLfloat _maxT; + /** content size */ - CC_PROPERTY_READONLY(Size, _contentSize, ContentSize) + Size _contentSize; /** whether or not the texture has their Alpha premultiplied */ bool _hasPremultipliedAlpha; @@ -267,7 +299,7 @@ private: bool _hasMipmaps; /** shader program used by drawAtPoint and drawInRect */ - CC_PROPERTY(GLProgram*, _shaderProgram, ShaderProgram); + GLProgram* _shaderProgram; }; // end of textures group diff --git a/cocos2dx/textures/CCTextureAtlas.cpp b/cocos2dx/textures/CCTextureAtlas.cpp index 222609e8e5..417604370b 100644 --- a/cocos2dx/textures/CCTextureAtlas.cpp +++ b/cocos2dx/textures/CCTextureAtlas.cpp @@ -81,7 +81,7 @@ int TextureAtlas::getCapacity() const return _capacity; } -Texture2D* TextureAtlas::getTexture() +Texture2D* TextureAtlas::getTexture() const { return _texture; } @@ -100,22 +100,22 @@ V3F_C4B_T2F_Quad* TextureAtlas::getQuads() return _quads; } -void TextureAtlas::setQuads(V3F_C4B_T2F_Quad *var) +void TextureAtlas::setQuads(V3F_C4B_T2F_Quad* quads) { - _quads = var; + _quads = quads; } // TextureAtlas - alloc & init TextureAtlas * TextureAtlas::create(const char* file, int capacity) { - TextureAtlas * pTextureAtlas = new TextureAtlas(); - if(pTextureAtlas && pTextureAtlas->initWithFile(file, capacity)) + TextureAtlas * textureAtlas = new TextureAtlas(); + if(textureAtlas && textureAtlas->initWithFile(file, capacity)) { - pTextureAtlas->autorelease(); - return pTextureAtlas; + textureAtlas->autorelease(); + return textureAtlas; } - CC_SAFE_DELETE(pTextureAtlas); + CC_SAFE_DELETE(textureAtlas); return NULL; } diff --git a/cocos2dx/textures/CCTextureAtlas.h b/cocos2dx/textures/CCTextureAtlas.h index 21164a1c87..ae5e13ab16 100644 --- a/cocos2dx/textures/CCTextureAtlas.h +++ b/cocos2dx/textures/CCTextureAtlas.h @@ -187,6 +187,24 @@ public: const char* description() const; + /** Gets the quantity of quads that are going to be drawn */ + int getTotalQuads() const; + + /** Gets the quantity of quads that can be stored with the current texture atlas size */ + int getCapacity() const; + + /** Gets the texture of the texture atlas */ + Texture2D* getTexture() const; + + /** Sets the texture for the texture atlas */ + void setTexture(Texture2D* texture); + + /** Gets the quads that are going to be rendered */ + V3F_C4B_T2F_Quad* getQuads(); + + /** Sets the quads that are going to be rendered */ + void setQuads(V3F_C4B_T2F_Quad* quads); + private: void setupIndices(); void mapBuffers(); @@ -203,16 +221,14 @@ protected: #endif GLuint _buffersVBO[2]; //0: vertex 1: indices bool _dirty; //indicates whether or not the array buffer of the VBO needs to be updated - - /** quantity of quads that are going to be drawn */ - CC_PROPERTY_READONLY(int, _totalQuads, TotalQuads) + int _totalQuads; /** quantity of quads that can be stored with the current texture atlas size */ - CC_PROPERTY_READONLY(int, _capacity, Capacity) + int _capacity; /** Texture of the texture atlas */ - CC_PROPERTY(Texture2D *, _texture, Texture) + Texture2D* _texture; /** Quads that are going to be rendered */ - CC_PROPERTY(V3F_C4B_T2F_Quad *, _quads, Quads) + V3F_C4B_T2F_Quad* _quads; }; // end of textures group diff --git a/cocos2dx/textures/CCTexturePVR.cpp b/cocos2dx/textures/CCTexturePVR.cpp index 467847ae5b..00aa5c0ef8 100644 --- a/cocos2dx/textures/CCTexturePVR.cpp +++ b/cocos2dx/textures/CCTexturePVR.cpp @@ -547,7 +547,7 @@ bool TexturePVR::createGLTexture() glPixelStorei(GL_UNPACK_ALIGNMENT,1); glGenTextures(1, &_name); - glBindTexture(GL_TEXTURE_2D, _name); + ccGLBindTexture2D(_name); // Default: Anti alias. if (_numberOfMipmaps == 1) diff --git a/cocos2dx/tilemap_parallax_nodes/CCParallaxNode.cpp b/cocos2dx/tilemap_parallax_nodes/CCParallaxNode.cpp index 5d447f04dc..f8b4bb8575 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCParallaxNode.cpp +++ b/cocos2dx/tilemap_parallax_nodes/CCParallaxNode.cpp @@ -30,18 +30,15 @@ NS_CC_BEGIN class PointObject : Object { - CC_SYNTHESIZE(Point, _ratio, Ratio) - CC_SYNTHESIZE(Point, _offset, Offset) - CC_SYNTHESIZE(Node *,_child, Child) // weak ref - public: - static PointObject * pointWithPoint(Point ratio, Point offset) + static PointObject * create(Point ratio, Point offset) { PointObject *pRet = new PointObject(); pRet->initWithPoint(ratio, offset); pRet->autorelease(); return pRet; } + bool initWithPoint(Point ratio, Point offset) { _ratio = ratio; @@ -49,6 +46,20 @@ public: _child = NULL; return true; } + + inline const Point& getRatio() const { return _ratio; }; + inline void setRatio(const Point& ratio) { _ratio = ratio; }; + + inline const Point& getOffset() const { return _offset; }; + inline void setOffset(const Point& offset) { _offset = offset; }; + + inline Node* getChild() const { return _child; }; + inline void setChild(Node* child) { _child = child; }; + +private: + Point _ratio; + Point _offset; + Node *_child; // weak ref }; ParallaxNode::ParallaxNode() @@ -56,6 +67,7 @@ ParallaxNode::ParallaxNode() _parallaxArray = ccArrayNew(5); _lastPosition = Point(-100,-100); } + ParallaxNode::~ParallaxNode() { if( _parallaxArray ) @@ -83,7 +95,7 @@ void ParallaxNode::addChild(Node * child, int zOrder, int tag) void ParallaxNode::addChild(Node *child, int z, const Point& ratio, const Point& offset) { CCASSERT( child != NULL, "Argument must be non-nil"); - PointObject *obj = PointObject::pointWithPoint(ratio, offset); + PointObject *obj = PointObject::create(ratio, offset); obj->setChild(child); ccArrayAppendObjectWithResize(_parallaxArray, (Object*)obj); diff --git a/cocos2dx/tilemap_parallax_nodes/CCParallaxNode.h b/cocos2dx/tilemap_parallax_nodes/CCParallaxNode.h index 00ed30e664..7a752d4b2d 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCParallaxNode.h +++ b/cocos2dx/tilemap_parallax_nodes/CCParallaxNode.h @@ -56,6 +56,9 @@ public: ParallaxNode(); virtual ~ParallaxNode(); + // prevents compiler warning: "Included function hides overloaded virtual functions" + using Node::addChild; + void addChild(Node * child, int z, const Point& parallaxRatio, const Point& positionOffset); /** Sets an array of layers for the Parallax node */ diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXLayer.cpp b/cocos2dx/tilemap_parallax_nodes/CCTMXLayer.cpp index 79d8a771f9..b2f6a03f5c 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXLayer.cpp +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXLayer.cpp @@ -123,18 +123,6 @@ TMXLayer::~TMXLayer() CC_SAFE_DELETE_ARRAY(_tiles); } -TMXTilesetInfo * TMXLayer::getTileSet() -{ - return _tileSet; -} - -void TMXLayer::setTileSet(TMXTilesetInfo* var) -{ - CC_SAFE_RETAIN(var); - CC_SAFE_RELEASE(_tileSet); - _tileSet = var; -} - void TMXLayer::releaseMap() { if (_tiles) @@ -718,17 +706,5 @@ int TMXLayer::getVertexZForPos(const Point& pos) return ret; } -Dictionary * TMXLayer::getProperties() -{ - return _properties; -} - -void TMXLayer::setProperties(Dictionary* var) -{ - CC_SAFE_RETAIN(var); - CC_SAFE_RELEASE(_properties); - _properties = var; -} - NS_CC_END diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXLayer.h b/cocos2dx/tilemap_parallax_nodes/CCTMXLayer.h index 041b1406f4..be459ac8a7 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXLayer.h +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXLayer.h @@ -139,6 +139,37 @@ public: inline const char* getLayerName(){ return _layerName.c_str(); } inline void setLayerName(const char *layerName){ _layerName = layerName; } + /** size of the layer in tiles */ + inline const Size& getLayerSize() const { return _layerSize; }; + inline void setLayerSize(const Size& size) { _layerSize = size; }; + + /** size of the map's tile (could be different from the tile's size) */ + inline const Size& getMapTileSize() const { return _mapTileSize; }; + inline void setMapTileSize(const Size& size) { _mapTileSize = size; }; + + /** pointer to the map of tiles */ + inline unsigned int* getTiles() const { return _tiles; }; + inline void setTiles(unsigned int* tiles) { _tiles = tiles; }; + + /** Tileset information for the layer */ + inline TMXTilesetInfo* getTileSet() const { return _tileSet; }; + inline void setTileSet(TMXTilesetInfo* info) { + CC_SAFE_RETAIN(info); + CC_SAFE_RELEASE(_tileSet); + _tileSet = info; + }; + + /** Layer orientation, which is the same as the map orientation */ + inline unsigned int getLayerOrientation() const { return _layerOrientation; }; + inline void setLayerOrientation(unsigned int orientation) { _layerOrientation = orientation; }; + + /** properties from the layer. They can be added using Tiled */ + inline Dictionary* getProperties() const { return _properties; }; + inline void setProperties(Dictionary* properties) { + CC_SAFE_RETAIN(properties); + CC_SAFE_RELEASE(_properties); + _properties = properties; + }; // // Override // @@ -192,19 +223,18 @@ protected: // used for retina display float _contentScaleFactor; -private: /** size of the layer in tiles */ - CC_SYNTHESIZE_PASS_BY_REF(Size, _layerSize, LayerSize); + Size _layerSize; /** size of the map's tile (could be different from the tile's size) */ - CC_SYNTHESIZE_PASS_BY_REF(Size, _mapTileSize, MapTileSize); + Size _mapTileSize; /** pointer to the map of tiles */ - CC_SYNTHESIZE(unsigned int*, _tiles, Tiles); + unsigned int* _tiles; /** Tileset information for the layer */ - CC_PROPERTY(TMXTilesetInfo*, _tileSet, TileSet); + TMXTilesetInfo* _tileSet; /** Layer orientation, which is the same as the map orientation */ - CC_SYNTHESIZE(unsigned int, _layerOrientation, LayerOrientation); + unsigned int _layerOrientation; /** properties from the layer. They can be added using Tiled */ - CC_PROPERTY(Dictionary*, _properties, Properties); + Dictionary* _properties; }; // end of tilemap_parallax_nodes group diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXObjectGroup.cpp b/cocos2dx/tilemap_parallax_nodes/CCTMXObjectGroup.cpp index b8d4e41d8f..aecfa72320 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXObjectGroup.cpp +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXObjectGroup.cpp @@ -39,13 +39,15 @@ TMXObjectGroup::TMXObjectGroup() _objects->retain(); _properties = new Dictionary(); } + TMXObjectGroup::~TMXObjectGroup() { CCLOGINFO( "cocos2d: deallocing: %p", this); CC_SAFE_RELEASE(_objects); CC_SAFE_RELEASE(_properties); } -Dictionary* TMXObjectGroup::objectNamed(const char *objectName) + +Dictionary* TMXObjectGroup::getObjectNamed(const char *objectName) const { if (_objects && _objects->count() > 0) { @@ -53,7 +55,7 @@ Dictionary* TMXObjectGroup::objectNamed(const char *objectName) CCARRAY_FOREACH(_objects, pObj) { Dictionary* pDict = static_cast(pObj); - String *name = (String*)pDict->objectForKey("name"); + String *name = static_cast(pDict->objectForKey("name")); if (name && name->_string == objectName) { return pDict; @@ -63,30 +65,10 @@ Dictionary* TMXObjectGroup::objectNamed(const char *objectName) // object not found return NULL; } -String* TMXObjectGroup::propertyNamed(const char* propertyName) -{ - return (String*)_properties->objectForKey(propertyName); -} -Dictionary* TMXObjectGroup::getProperties() -{ - return _properties; -} -void TMXObjectGroup::setProperties(Dictionary * properties) -{ - CC_SAFE_RETAIN(properties); - CC_SAFE_RELEASE(_properties); - _properties = properties; -} -Array* TMXObjectGroup::getObjects() -{ - return _objects; -} -void TMXObjectGroup::setObjects(Array* objects) -{ - CC_SAFE_RETAIN(objects); - CC_SAFE_RELEASE(_objects); - _objects = objects; +String* TMXObjectGroup::getPropertyNamed(const char* propertyName) const +{ + return static_cast(_properties->objectForKey(propertyName)); } NS_CC_END diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXObjectGroup.h b/cocos2dx/tilemap_parallax_nodes/CCTMXObjectGroup.h index f89e4e0c9c..b758c177aa 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXObjectGroup.h +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXObjectGroup.h @@ -44,12 +44,6 @@ NS_CC_BEGIN */ class CC_DLL TMXObjectGroup : public Object { - /** offset position of child objects */ - CC_SYNTHESIZE_PASS_BY_REF(Point, _positionOffset, PositionOffset); - /** list of properties stored in a dictionary */ - CC_PROPERTY(Dictionary*, _properties, Properties); - /** array of the objects */ - CC_PROPERTY(Array*, _objects, Objects); public: TMXObjectGroup(); virtual ~TMXObjectGroup(); @@ -58,15 +52,52 @@ public: inline void setGroupName(const char *groupName){ _groupName = groupName; } /** return the value for the specific property name */ - String *propertyNamed(const char* propertyName); + String* getPropertyNamed(const char* propertyName) const; + + CC_DEPRECATED_ATTRIBUTE String *propertyNamed(const char* propertyName) const { return getPropertyNamed(propertyName); }; /** return the dictionary for the specific object name. It will return the 1st object found on the array for the given name. */ - Dictionary* objectNamed(const char *objectName); -protected: + Dictionary* getObjectNamed(const char *objectName) const; + + CC_DEPRECATED_ATTRIBUTE Dictionary* objectNamed(const char *objectName) const { return getObjectNamed(objectName); }; + + /** Gets the offset position of child objects */ + inline const Point& getPositionOffset() const { return _positionOffset; }; + + /** Sets the offset position of child objects */ + inline void setPositionOffset(const Point& offset) { _positionOffset = offset; }; + + /** Gets the list of properties stored in a dictionary */ + inline Dictionary* getProperties() const { return _properties; }; + + /** Sets the list of properties */ + inline void setProperties(Dictionary* properties) { + CC_SAFE_RETAIN(properties); + CC_SAFE_RELEASE(_properties); + _properties = properties; + }; + + /** Gets the array of the objects */ + inline Array* getObjects() const { return _objects; }; + + /** Sets the array of the objects */ + inline void setObjects(Array* objects) { + CC_SAFE_RETAIN(objects); + CC_SAFE_RELEASE(_objects); + _objects = objects; + }; + +protected: /** name of the group */ std::string _groupName; + /** offset position of child objects */ + Point _positionOffset; + /** list of properties stored in a dictionary */ + Dictionary* _properties; + /** array of the objects */ + Array* _objects; }; // end of tilemap_parallax_nodes group diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXTiledMap.cpp b/cocos2dx/tilemap_parallax_nodes/CCTMXTiledMap.cpp index ad5103ebcc..a856f577a4 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXTiledMap.cpp +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXTiledMap.cpp @@ -62,7 +62,7 @@ bool TMXTiledMap::initWithTMXFile(const char *tmxFile) setContentSize(Size::ZERO); - TMXMapInfo *mapInfo = TMXMapInfo::formatWithTMXFile(tmxFile); + TMXMapInfo *mapInfo = TMXMapInfo::create(tmxFile); if (! mapInfo) { @@ -78,7 +78,7 @@ bool TMXTiledMap::initWithXML(const char* tmxString, const char* resourcePath) { setContentSize(Size::ZERO); - TMXMapInfo *mapInfo = TMXMapInfo::formatWithXML(tmxString, resourcePath); + TMXMapInfo *mapInfo = TMXMapInfo::createWithXML(tmxString, resourcePath); CCASSERT( mapInfo->getTilesets()->count() != 0, "TMXTiledMap: Map not found. Please check the filename."); buildWithMapInfo(mapInfo); @@ -101,30 +101,6 @@ TMXTiledMap::~TMXTiledMap() CC_SAFE_RELEASE(_tileProperties); } -Array* TMXTiledMap::getObjectGroups() -{ - return _objectGroups; -} - -void TMXTiledMap::setObjectGroups(Array* var) -{ - CC_SAFE_RETAIN(var); - CC_SAFE_RELEASE(_objectGroups); - _objectGroups = var; -} - -Dictionary * TMXTiledMap::getProperties() -{ - return _properties; -} - -void TMXTiledMap::setProperties(Dictionary* var) -{ - CC_SAFE_RETAIN(var); - CC_SAFE_RELEASE(_properties); - _properties = var; -} - // private TMXLayer * TMXTiledMap::parseLayer(TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo) { @@ -230,7 +206,7 @@ void TMXTiledMap::buildWithMapInfo(TMXMapInfo* mapInfo) } // public -TMXLayer * TMXTiledMap::layerNamed(const char *layerName) +TMXLayer * TMXTiledMap::getLayer(const char *layerName) const { CCASSERT(layerName != NULL && strlen(layerName) > 0, "Invalid layer name!"); Object* pObj = NULL; @@ -250,7 +226,7 @@ TMXLayer * TMXTiledMap::layerNamed(const char *layerName) return NULL; } -TMXObjectGroup * TMXTiledMap::objectGroupNamed(const char *groupName) +TMXObjectGroup * TMXTiledMap::getObjectGroup(const char *groupName) const { CCASSERT(groupName != NULL && strlen(groupName) > 0, "Invalid group name!"); @@ -273,14 +249,14 @@ TMXObjectGroup * TMXTiledMap::objectGroupNamed(const char *groupName) return NULL; } -String* TMXTiledMap::propertyNamed(const char *propertyName) +String* TMXTiledMap::getProperty(const char *propertyName) const { - return (String*)_properties->objectForKey(propertyName); + return static_cast(_properties->objectForKey(propertyName)); } -Dictionary* TMXTiledMap::propertiesForGID(int GID) +Dictionary* TMXTiledMap::getPropertiesForGID(int GID) const { - return (Dictionary*)_tileProperties->objectForKey(GID); + return static_cast(_tileProperties->objectForKey(GID)); } diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXTiledMap.h b/cocos2dx/tilemap_parallax_nodes/CCTMXTiledMap.h index 03ed002909..cb3ef5841a 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXTiledMap.h +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXTiledMap.h @@ -88,36 +88,26 @@ Each layer is created using an TMXLayer (subclass of SpriteBatchNode). If you ha unless the layer visibility is off. In that case, the layer won't be created at all. You can obtain the layers (TMXLayer objects) at runtime by: - map->getChildByTag(tag_number); // 0=1st layer, 1=2nd layer, 2=3rd layer, etc... -- map->layerNamed(name_of_the_layer); +- map->getLayer(name_of_the_layer); Each object group is created using a TMXObjectGroup which is a subclass of MutableArray. You can obtain the object groups at runtime by: -- map->objectGroupNamed(name_of_the_object_group); +- map->getObjectGroup(name_of_the_object_group); Each object is a TMXObject. Each property is stored as a key-value pair in an MutableDictionary. You can obtain the properties at runtime by: -map->propertyNamed(name_of_the_property); -layer->propertyNamed(name_of_the_property); -objectGroup->propertyNamed(name_of_the_property); -object->propertyNamed(name_of_the_property); +map->getProperty(name_of_the_property); +layer->getProperty(name_of_the_property); +objectGroup->getProperty(name_of_the_property); +object->getProperty(name_of_the_property); @since v0.8.1 */ class CC_DLL TMXTiledMap : public Node { - /** the map's size property measured in tiles */ - CC_SYNTHESIZE_PASS_BY_REF(Size, _mapSize, MapSize); - /** the tiles's size property measured in pixels */ - CC_SYNTHESIZE_PASS_BY_REF(Size, _tileSize, TileSize); - /** map orientation */ - CC_SYNTHESIZE(int, _mapOrientation, MapOrientation); - /** object groups */ - CC_PROPERTY(Array*, _objectGroups, ObjectGroups); - /** properties */ - CC_PROPERTY(Dictionary*, _properties, Properties); public: TMXTiledMap(); virtual ~TMXTiledMap(); @@ -135,22 +125,65 @@ public: bool initWithXML(const char* tmxString, const char* resourcePath); /** return the TMXLayer for the specific layer */ - TMXLayer* layerNamed(const char *layerName); + TMXLayer* getLayer(const char *layerName) const; + CC_DEPRECATED_ATTRIBUTE TMXLayer* layerNamed(const char *layerName) const { return getLayer(layerName); }; /** return the TMXObjectGroup for the specific group */ - TMXObjectGroup* objectGroupNamed(const char *groupName); + TMXObjectGroup* getObjectGroup(const char *groupName) const; + CC_DEPRECATED_ATTRIBUTE TMXObjectGroup* objectGroupNamed(const char *groupName) const { return getObjectGroup(groupName); }; /** return the value for the specific property name */ - String *propertyNamed(const char *propertyName); + String *getProperty(const char *propertyName) const; + CC_DEPRECATED_ATTRIBUTE String *propertyNamed(const char *propertyName) const { return getProperty(propertyName); }; /** return properties dictionary for tile GID */ - Dictionary* propertiesForGID(int GID); + Dictionary* getPropertiesForGID(int GID) const; + CC_DEPRECATED_ATTRIBUTE Dictionary* propertiesForGID(int GID) const { return getPropertiesForGID(GID); }; + /** the map's size property measured in tiles */ + inline const Size& getMapSize() const { return _mapSize; }; + inline void setMapSize(const Size& mapSize) { _mapSize = mapSize; }; + + /** the tiles's size property measured in pixels */ + inline const Size& getTileSize() const { return _tileSize; }; + inline void setTileSize(const Size& tileSize) { _tileSize = tileSize; }; + + /** map orientation */ + inline int getMapOrientation() const { return _mapOrientation; }; + inline void setMapOrientation(int mapOrientation) { _mapOrientation = mapOrientation; }; + + /** object groups */ + inline Array* getObjectGroups() const { return _objectGroups; }; + inline void setObjectGroups(Array* groups) { + CC_SAFE_RETAIN(groups); + CC_SAFE_RELEASE(_objectGroups); + _objectGroups = groups; + }; + + /** properties */ + inline Dictionary* getProperties() const { return _properties; }; + inline void setProperties(Dictionary* properties) { + CC_SAFE_RETAIN(properties); + CC_SAFE_RELEASE(_properties); + _properties = properties; + }; + private: TMXLayer * parseLayer(TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo); TMXTilesetInfo * tilesetForLayer(TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo); void buildWithMapInfo(TMXMapInfo* mapInfo); protected: + /** the map's size property measured in tiles */ + Size _mapSize; + /** the tiles's size property measured in pixels */ + Size _tileSize; + /** map orientation */ + int _mapOrientation; + /** object groups */ + Array* _objectGroups; + /** properties */ + Dictionary* _properties; + //! tile properties Dictionary* _tileProperties; diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp b/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp index b95475e675..d466289a2a 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp @@ -35,24 +35,9 @@ THE SOFTWARE. #include "support/base64.h" using namespace std; -/* -#if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE) - #include "expat.h" -#else - #include - #include - #include -#endif -*/ NS_CC_BEGIN -/* -void tmx_startElement(void *ctx, const xmlChar *name, const xmlChar **atts); -void tmx_endElement(void *ctx, const xmlChar *name); -void tmx_characters(void *ctx, const xmlChar *ch, int len); -*/ - static const char* valueForKey(const char *key, std::map* dict) { if (dict) @@ -84,6 +69,7 @@ TMXLayerInfo::~TMXLayerInfo() _tiles = NULL; } } + Dictionary * TMXLayerInfo::getProperties() { return _properties; @@ -104,10 +90,12 @@ TMXTilesetInfo::TMXTilesetInfo() ,_imageSize(Size::ZERO) { } + TMXTilesetInfo::~TMXTilesetInfo() { CCLOGINFO("cocos2d: deallocing: %p", this); } + Rect TMXTilesetInfo::rectForGID(unsigned int gid) { Rect rect; @@ -123,7 +111,7 @@ Rect TMXTilesetInfo::rectForGID(unsigned int gid) // implementation TMXMapInfo -TMXMapInfo * TMXMapInfo::formatWithTMXFile(const char *tmxFile) +TMXMapInfo * TMXMapInfo::create(const char *tmxFile) { TMXMapInfo *pRet = new TMXMapInfo(); if(pRet->initWithTMXFile(tmxFile)) @@ -135,7 +123,7 @@ TMXMapInfo * TMXMapInfo::formatWithTMXFile(const char *tmxFile) return NULL; } -TMXMapInfo * TMXMapInfo::formatWithXML(const char* tmxString, const char* resourcePath) +TMXMapInfo * TMXMapInfo::createWithXML(const char* tmxString, const char* resourcePath) { TMXMapInfo *pRet = new TMXMapInfo(); if(pRet->initWithXML(tmxString, resourcePath)) @@ -214,66 +202,6 @@ TMXMapInfo::~TMXMapInfo() CC_SAFE_RELEASE(_objectGroups); } -Array* TMXMapInfo::getLayers() -{ - return _layers; -} - -void TMXMapInfo::setLayers(Array* var) -{ - CC_SAFE_RETAIN(var); - CC_SAFE_RELEASE(_layers); - _layers = var; -} - -Array* TMXMapInfo::getTilesets() -{ - return _tilesets; -} - -void TMXMapInfo::setTilesets(Array* var) -{ - CC_SAFE_RETAIN(var); - CC_SAFE_RELEASE(_tilesets); - _tilesets = var; -} - -Array* TMXMapInfo::getObjectGroups() -{ - return _objectGroups; -} - -void TMXMapInfo::setObjectGroups(Array* var) -{ - CC_SAFE_RETAIN(var); - CC_SAFE_RELEASE(_objectGroups); - _objectGroups = var; -} - -Dictionary * TMXMapInfo::getProperties() -{ - return _properties; -} - -void TMXMapInfo::setProperties(Dictionary* var) -{ - CC_SAFE_RETAIN(var); - CC_SAFE_RELEASE(_properties); - _properties = var; -} - -Dictionary* TMXMapInfo::getTileProperties() -{ - return _tileProperties; -} - -void TMXMapInfo::setTileProperties(Dictionary* tileProperties) -{ - CC_SAFE_RETAIN(tileProperties); - CC_SAFE_RELEASE(_tileProperties); - _tileProperties = tileProperties; -} - bool TMXMapInfo::parseXMLString(const char *xmlString) { int len = strlen(xmlString); @@ -768,7 +696,7 @@ void TMXMapInfo::textHandler(void *ctx, const char *ch, int len) TMXMapInfo *pTMXMapInfo = this; std::string pText((char*)ch,0,len); - if (pTMXMapInfo->getStoringCharacters()) + if (pTMXMapInfo->isStoringCharacters()) { std::string currentString = pTMXMapInfo->getCurrentString(); currentString += pText; diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.h b/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.h index f95cbb31fa..4e183e04d5 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.h +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.h @@ -151,35 +151,19 @@ This information is obtained from the TMX file. class CC_DLL TMXMapInfo : public Object, public SAXDelegator { public: - /// map orientation - CC_SYNTHESIZE(int, _orientation, Orientation); - /// map width & height - CC_SYNTHESIZE_PASS_BY_REF(Size, _mapSize, MapSize); - /// tiles width & height - CC_SYNTHESIZE_PASS_BY_REF(Size, _tileSize, TileSize); - /// Layers - CC_PROPERTY(Array*, _layers, Layers); - /// tilesets - CC_PROPERTY(Array*, _tilesets, Tilesets); - /// ObjectGroups - CC_PROPERTY(Array*, _objectGroups, ObjectGroups); - /// parent element - CC_SYNTHESIZE(int, _parentElement, ParentElement); - /// parent GID - CC_SYNTHESIZE(unsigned int, _parentGID, ParentGID); - /// layer attribs - CC_SYNTHESIZE(int, _layerAttribs, LayerAttribs); - /// is storing characters? - CC_SYNTHESIZE(bool, _storingCharacters, StoringCharacters); - /// properties - CC_PROPERTY(Dictionary*, _properties, Properties); -public: + /** creates a TMX Format with a tmx file */ + static TMXMapInfo * create(const char *tmxFile); + /** creates a TMX Format with an XML string and a TMX resource path */ + static TMXMapInfo * createWithXML(const char* tmxString, const char* resourcePath); + + /** creates a TMX Format with a tmx file */ + CC_DEPRECATED_ATTRIBUTE static TMXMapInfo * formatWithTMXFile(const char *tmxFile) { return TMXMapInfo::create(tmxFile); }; + /** creates a TMX Format with an XML string and a TMX resource path */ + CC_DEPRECATED_ATTRIBUTE static TMXMapInfo * formatWithXML(const char* tmxString, const char* resourcePath) { return TMXMapInfo::createWithXML(tmxString, resourcePath); }; + TMXMapInfo(); virtual ~TMXMapInfo(); - /** creates a TMX Format with a tmx file */ - static TMXMapInfo * formatWithTMXFile(const char *tmxFile); - /** creates a TMX Format with an XML string and a TMX resource path */ - static TMXMapInfo * formatWithXML(const char* tmxString, const char* resourcePath); + /** initializes a TMX format with a tmx file */ bool initWithTMXFile(const char *tmxFile); /** initializes a TMX format with an XML string and a TMX resource path */ @@ -189,9 +173,74 @@ public: /* initializes parsing of an XML string, either a tmx (Map) string or tsx (Tileset) string */ bool parseXMLString(const char *xmlString); - Dictionary* getTileProperties(); - void setTileProperties(Dictionary* tileProperties); + Dictionary* getTileProperties() { return _tileProperties; }; + void setTileProperties(Dictionary* tileProperties) { + CC_SAFE_RETAIN(tileProperties); + CC_SAFE_RELEASE(_tileProperties); + _tileProperties = tileProperties; + }; + /// map orientation + inline int getOrientation() const { return _orientation; }; + inline void setOrientation(int orientation) { _orientation = orientation; }; + + /// map width & height + inline const Size& getMapSize() const { return _mapSize; }; + inline void setMapSize(const Size& mapSize) { _mapSize = mapSize; }; + + /// tiles width & height + inline const Size& getTileSize() const { return _tileSize; }; + inline void setTileSize(const Size& tileSize) { _tileSize = tileSize; }; + + /// Layers + inline Array* getLayers() const { return _layers; }; + inline void setLayers(Array* layers) { + CC_SAFE_RETAIN(layers); + CC_SAFE_RELEASE(_layers); + _layers = layers; + }; + + /// tilesets + inline Array* getTilesets() const { return _tilesets; }; + inline void setTilesets(Array* tilesets) { + CC_SAFE_RETAIN(tilesets); + CC_SAFE_RELEASE(_tilesets); + _tilesets = tilesets; + }; + + /// ObjectGroups + inline Array* getObjectGroups() const { return _objectGroups; }; + inline void setObjectGroups(Array* groups) { + CC_SAFE_RETAIN(groups); + CC_SAFE_RELEASE(_objectGroups); + _objectGroups = groups; + }; + + /// parent element + inline int getParentElement() const { return _parentElement; }; + inline void setParentElement(int element) { _parentElement = element; }; + + /// parent GID + inline unsigned int getParentGID() const { return _parentGID; }; + inline void setParentGID(unsigned int gid) { _parentGID = gid; }; + + /// layer attribs + inline int getLayerAttribs() const { return _layerAttribs; }; + inline void setLayerAttribs(int layerAttribs) { _layerAttribs = layerAttribs; }; + + /// is storing characters? + inline bool isStoringCharacters() const { return _storingCharacters; }; + CC_DEPRECATED_ATTRIBUTE inline bool getStoringCharacters() const { return isStoringCharacters(); }; + inline void setStoringCharacters(bool storingCharacters) { _storingCharacters = storingCharacters; }; + + /// properties + inline Dictionary* getProperties() const { return _properties; }; + inline void setProperties(Dictionary* properties) { + CC_SAFE_RETAIN(properties); + CC_SAFE_RELEASE(_properties); + _properties = properties; + }; + // implement pure virtual methods of SAXDelegator void startElement(void *ctx, const char *name, const char **atts); void endElement(void *ctx, const char *name); @@ -204,6 +253,30 @@ public: private: void internalInit(const char* tmxFileName, const char* resourcePath); protected: + + /// map orientation + int _orientation; + /// map width & height + Size _mapSize; + /// tiles width & height + Size _tileSize; + /// Layers + Array* _layers; + /// tilesets + Array* _tilesets; + /// ObjectGroups + Array* _objectGroups; + /// parent element + int _parentElement; + /// parent GID + unsigned int _parentGID; + /// layer attribs + int _layerAttribs; + /// is storing characters? + bool _storingCharacters; + /// properties + Dictionary* _properties; + //! tmx filename std::string _TMXFileName; // tmx resource path diff --git a/cocos2dx/tilemap_parallax_nodes/CCTileMapAtlas.cpp b/cocos2dx/tilemap_parallax_nodes/CCTileMapAtlas.cpp index e548b801aa..483e607f85 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTileMapAtlas.cpp +++ b/cocos2dx/tilemap_parallax_nodes/CCTileMapAtlas.cpp @@ -264,14 +264,5 @@ void TileMapAtlas::updateAtlasValues() } } -void TileMapAtlas::setTGAInfo(struct sImageTGA* var) -{ - _TGAInfo = var; -} - -struct sImageTGA * TileMapAtlas::getTGAInfo() -{ - return _TGAInfo; -} NS_CC_END diff --git a/cocos2dx/tilemap_parallax_nodes/CCTileMapAtlas.h b/cocos2dx/tilemap_parallax_nodes/CCTileMapAtlas.h index 085f229967..00d0e6ea18 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTileMapAtlas.h +++ b/cocos2dx/tilemap_parallax_nodes/CCTileMapAtlas.h @@ -80,6 +80,9 @@ public: void setTile(const Color3B& tile, const Point& position); /** dealloc the map from memory */ void releaseMap(); + + inline struct sImageTGA* getTGAInfo() const { return _TGAInfo; }; + inline void setTGAInfo(struct sImageTGA* TGAInfo) { _TGAInfo = TGAInfo; }; private: void loadTGAfile(const char *file); void calculateItemsToRender(); @@ -91,10 +94,8 @@ protected: Dictionary* _posToAtlasIndex; //! numbers of tiles to render int _itemsToRender; - -private: /** TileMap info */ - CC_PROPERTY(struct sImageTGA*, _TGAInfo, TGAInfo); + struct sImageTGA* _TGAInfo; }; // end of tilemap_parallax_nodes group diff --git a/extensions/CCArmature/external_tool/CCTexture2DMutable.cpp b/extensions/CCArmature/external_tool/CCTexture2DMutable.cpp index 235deea201..a352930c88 100644 --- a/extensions/CCArmature/external_tool/CCTexture2DMutable.cpp +++ b/extensions/CCArmature/external_tool/CCTexture2DMutable.cpp @@ -157,7 +157,7 @@ Color4B Texture2DMutable::pixelAt(const Point& pt) c.b = 255; } - //CCLog("color : %i, %i, %i, %i", c.r, c.g, c.b, c.a); + //log("color : %i, %i, %i, %i", c.r, c.g, c.b, c.a); return c; } diff --git a/extensions/CCArmature/utils/CCSpriteFrameCacheHelper.cpp b/extensions/CCArmature/utils/CCSpriteFrameCacheHelper.cpp index db7b206f38..36fc52cb9a 100644 --- a/extensions/CCArmature/utils/CCSpriteFrameCacheHelper.cpp +++ b/extensions/CCArmature/utils/CCSpriteFrameCacheHelper.cpp @@ -92,7 +92,7 @@ void SpriteFrameCacheHelper::addSpriteFrameFromDict(Dictionary *dictionary, Text _display2ImageMap[spriteFrameName] = imagePath; - //CCLog("spriteFrameName : %s, imagePath : %s", spriteFrameName.c_str(), _imagePath); + //log("spriteFrameName : %s, imagePath : %s", spriteFrameName.c_str(), _imagePath); SpriteFrame *spriteFrame = (SpriteFrame *)SpriteFrameCache::getInstance()->getSpriteFrameByName(spriteFrameName.c_str()); if (spriteFrame) diff --git a/extensions/CCBReader/CCBAnimationManager.cpp b/extensions/CCBReader/CCBAnimationManager.cpp index a38dad5a7b..135ef99368 100644 --- a/extensions/CCBReader/CCBAnimationManager.cpp +++ b/extensions/CCBReader/CCBAnimationManager.cpp @@ -382,7 +382,7 @@ ActionInterval* CCBAnimationManager::getAction(CCBKeyframe *pKeyframe0, CCBKeyfr } else { - CCLog("CCBReader: Failed to create animation for property: %s", pPropName); + log("CCBReader: Failed to create animation for property: %s", pPropName); } return NULL; @@ -482,7 +482,7 @@ void CCBAnimationManager::setAnimatedProperty(const char *pPropName, Node *pNode } else { - CCLog("unsupported property name is %s", pPropName); + log("unsupported property name is %s", pPropName); CCASSERT(false, "unsupported property now"); } } @@ -573,7 +573,7 @@ ActionInterval* CCBAnimationManager::getEaseAction(ActionInterval *pAction, int } else { - CCLog("CCBReader: Unkown easing type %d", nEasingType); + log("CCBReader: Unkown easing type %d", nEasingType); return pAction; } } diff --git a/extensions/CCBReader/CCBReader.cpp b/extensions/CCBReader/CCBReader.cpp index 6893dd04e8..17e6111b5c 100644 --- a/extensions/CCBReader/CCBReader.cpp +++ b/extensions/CCBReader/CCBReader.cpp @@ -396,7 +396,7 @@ bool CCBReader::readHeader() /* Read version. */ int version = this->readInt(false); if(version != kCCBVersion) { - CCLog("WARNING! Incompatible ccbi file version (file: %d reader: %d)", version, kCCBVersion); + log("WARNING! Incompatible ccbi file version (file: %d reader: %d)", version, kCCBVersion); return false; } @@ -563,7 +563,7 @@ Node * CCBReader::readNodeGraph(Node * pParent) { if (! ccNodeLoader) { - CCLog("no corresponding node loader for %s", className.c_str()); + log("no corresponding node loader for %s", className.c_str()); return NULL; } diff --git a/extensions/CCBReader/CCNodeLoader.cpp b/extensions/CCBReader/CCNodeLoader.cpp index 5728b55484..a574b25c39 100644 --- a/extensions/CCBReader/CCNodeLoader.cpp +++ b/extensions/CCBReader/CCNodeLoader.cpp @@ -437,7 +437,7 @@ Size NodeLoader::parsePropTypeSize(Node * pNode, Node * pParent, CCBReader * pCC } default: { - CCLog("Unknown CCB type."); + log("Unknown CCB type."); } break; } diff --git a/extensions/CCBReader/CCNodeLoader.h b/extensions/CCBReader/CCNodeLoader.h index f9ba4f874a..be45ea67d2 100644 --- a/extensions/CCBReader/CCNodeLoader.h +++ b/extensions/CCBReader/CCNodeLoader.h @@ -20,8 +20,8 @@ NS_CC_EXT_BEGIN #define PROPERTY_IGNOREANCHORPOINTFORPOSITION "ignoreAnchorPointForPosition" #define PROPERTY_VISIBLE "visible" -#define ASSERT_FAIL_UNEXPECTED_PROPERTY(PROPERTY) CCLog("Unexpected property: '%s'!\n", PROPERTY); assert(false) -#define ASSERT_FAIL_UNEXPECTED_PROPERTYTYPE(PROPERTYTYPE) CCLog("Unexpected property type: '%d'!\n", PROPERTYTYPE); assert(false) +#define ASSERT_FAIL_UNEXPECTED_PROPERTY(PROPERTY) cocos2d::log("Unexpected property: '%s'!\n", PROPERTY); assert(false) +#define ASSERT_FAIL_UNEXPECTED_PROPERTYTYPE(PROPERTYTYPE) cocos2d::log("Unexpected property type: '%d'!\n", PROPERTYTYPE); assert(false) #define CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(T) virtual T * createNode(cocos2d::Node * pParent, cocos2d::extension::CCBReader * pCCBReader) { \ return T::create(); \ diff --git a/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp b/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp index 6945341f14..8e588b5706 100644 --- a/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp +++ b/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp @@ -160,7 +160,7 @@ bool Scale9Sprite::updateWithBatchNode(SpriteBatchNode* batchnode, Rect rect, bo // If there is no specified center region if ( _capInsetsInternal.equals(Rect::ZERO) ) { - // CCLog("... cap insets not specified : using default cap insets ..."); + // log("... cap insets not specified : using default cap insets ..."); _capInsetsInternal = Rect(w/3, h/3, w/3, h/3); } @@ -223,7 +223,7 @@ bool Scale9Sprite::updateWithBatchNode(SpriteBatchNode* batchnode, Rect rect, bo Rect rightbottombounds = Rect(x, y, right_w, bottom_h); if (!rotated) { - // CCLog("!rotated"); + // log("!rotated"); AffineTransform t = AffineTransformMakeIdentity(); t = AffineTransformTranslate(t, rect.origin.x, rect.origin.y); @@ -286,7 +286,7 @@ bool Scale9Sprite::updateWithBatchNode(SpriteBatchNode* batchnode, Rect rect, bo // set up transformation of coordinates // to handle the case where the sprite is stored rotated // in the spritesheet - // CCLog("rotated"); + // log("rotated"); AffineTransform t = AffineTransformMakeIdentity(); @@ -611,7 +611,7 @@ Scale9Sprite* Scale9Sprite::createWithSpriteFrameName(const char* spriteFrameNam } CC_SAFE_DELETE(pReturn); - CCLog("Could not allocate Scale9Sprite()"); + log("Could not allocate Scale9Sprite()"); return NULL; } diff --git a/extensions/GUI/CCScrollView/CCTableView.cpp b/extensions/GUI/CCScrollView/CCTableView.cpp index 0637f99810..4ee615b252 100644 --- a/extensions/GUI/CCScrollView/CCTableView.cpp +++ b/extensions/GUI/CCScrollView/CCTableView.cpp @@ -494,18 +494,18 @@ void TableView::scrollViewDidScroll(ScrollView* view) CCARRAY_FOREACH(_cellsUsed, pObj) { TableViewCell* pCell = static_cast(pObj); - CCLog("cells Used index %d, value = %d", i, pCell->getIdx()); + log("cells Used index %d, value = %d", i, pCell->getIdx()); i++; } - CCLog("---------------------------------------"); + log("---------------------------------------"); i = 0; CCARRAY_FOREACH(_cellsFreed, pObj) { TableViewCell* pCell = static_cast(pObj); - CCLog("cells freed index %d, value = %d", i, pCell->getIdx()); + log("cells freed index %d, value = %d", i, pCell->getIdx()); i++; } - CCLog("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); + log("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); #endif if (_cellsUsed->count() > 0) diff --git a/extensions/network/HttpClient.cpp b/extensions/network/HttpClient.cpp index 9dde68a888..0026fd39cf 100644 --- a/extensions/network/HttpClient.cpp +++ b/extensions/network/HttpClient.cpp @@ -477,7 +477,7 @@ void HttpClient::send(HttpRequest* request) // Poll and notify main thread if responses exists in queue void HttpClient::dispatchResponseCallbacks(float delta) { - // CCLog("CCHttpClient::dispatchResponseCallbacks is running"); + // log("CCHttpClient::dispatchResponseCallbacks is running"); HttpResponse* response = NULL; diff --git a/extensions/network/SocketIO.cpp b/extensions/network/SocketIO.cpp index 6e4a387f56..80a1320269 100644 --- a/extensions/network/SocketIO.cpp +++ b/extensions/network/SocketIO.cpp @@ -114,7 +114,7 @@ SIOClientImpl::~SIOClientImpl() { } void SIOClientImpl::handshake() { - CCLog("SIOClientImpl::handshake() called"); + log("SIOClientImpl::handshake() called"); std::stringstream pre; pre << "http://" << _uri << "/socket.io/1"; @@ -126,7 +126,7 @@ void SIOClientImpl::handshake() { request->setResponseCallback(this, httpresponse_selector(SIOClientImpl::handshakeResponse)); request->setTag("handshake"); - CCLog("SIOClientImpl::handshake() waiting"); + log("SIOClientImpl::handshake() waiting"); HttpClient::getInstance()->send(request); @@ -137,22 +137,22 @@ void SIOClientImpl::handshake() { void SIOClientImpl::handshakeResponse(HttpClient *sender, HttpResponse *response) { - CCLog("SIOClientImpl::handshakeResponse() called"); + log("SIOClientImpl::handshakeResponse() called"); if (0 != strlen(response->getHttpRequest()->getTag())) { - CCLog("%s completed", response->getHttpRequest()->getTag()); + log("%s completed", response->getHttpRequest()->getTag()); } int statusCode = response->getResponseCode(); char statusString[64] = {}; sprintf(statusString, "HTTP Status Code: %d, tag = %s", statusCode, response->getHttpRequest()->getTag()); - CCLog("response code: %d", statusCode); + log("response code: %d", statusCode); if (!response->isSucceed()) { - CCLog("SIOClientImpl::handshake() failed"); - CCLog("error buffer: %s", response->getErrorBuffer()); + log("SIOClientImpl::handshake() failed"); + log("error buffer: %s", response->getErrorBuffer()); DictElement* el = NULL; @@ -167,7 +167,7 @@ void SIOClientImpl::handshakeResponse(HttpClient *sender, HttpResponse *response return; } - CCLog("SIOClientImpl::handshake() succeeded"); + log("SIOClientImpl::handshake() succeeded"); std::vector *buffer = response->getResponseData(); std::stringstream s; @@ -177,7 +177,7 @@ void SIOClientImpl::handshakeResponse(HttpClient *sender, HttpResponse *response s << (*buffer)[i]; } - CCLog("SIOClientImpl::handshake() dump data: %s", s.str().c_str()); + log("SIOClientImpl::handshake() dump data: %s", s.str().c_str()); std::string res = s.str(); std::string sid; @@ -212,7 +212,7 @@ void SIOClientImpl::handshakeResponse(HttpClient *sender, HttpResponse *response void SIOClientImpl::openSocket() { - CCLog("SIOClientImpl::openSocket() called"); + log("SIOClientImpl::openSocket() called"); std::stringstream s; s << _uri << "/socket.io/1/websocket/" << _sid; @@ -228,7 +228,7 @@ void SIOClientImpl::openSocket() { bool SIOClientImpl::init() { - CCLog("SIOClientImpl::init() successful"); + log("SIOClientImpl::init() successful"); return true; } @@ -247,7 +247,7 @@ void SIOClientImpl::disconnect() { _ws->send(s); - CCLog("Disconnect sent"); + log("Disconnect sent"); _ws->close(); @@ -303,7 +303,7 @@ void SIOClientImpl::disconnectFromEndpoint(const std::string& endpoint) { if(_clients->count() == 0 || endpoint == "/") { - CCLog("SIOClientImpl::disconnectFromEndpoint out of endpoints, checking for disconnect"); + log("SIOClientImpl::disconnectFromEndpoint out of endpoints, checking for disconnect"); if(_connected) this->disconnect(); @@ -325,7 +325,7 @@ void SIOClientImpl::heartbeat(float dt) { _ws->send(s); - CCLog("Heartbeat sent"); + log("Heartbeat sent"); } @@ -339,7 +339,7 @@ void SIOClientImpl::send(std::string endpoint, std::string s) { std::string msg = pre.str(); - CCLog("sending message: %s", msg.c_str()); + log("sending message: %s", msg.c_str()); _ws->send(msg); @@ -355,7 +355,7 @@ void SIOClientImpl::emit(std::string endpoint, std::string eventname, std::strin std::string msg = pre.str(); - CCLog("emitting event with data: %s", msg.c_str()); + log("emitting event with data: %s", msg.c_str()); _ws->send(msg); @@ -379,13 +379,13 @@ void SIOClientImpl::onOpen(cocos2d::extension::WebSocket* ws) { Director::getInstance()->getScheduler()->scheduleSelector(schedule_selector(SIOClientImpl::heartbeat), this, (_heartbeat * .9), false); - CCLog("SIOClientImpl::onOpen socket connected!"); + log("SIOClientImpl::onOpen socket connected!"); } void SIOClientImpl::onMessage(cocos2d::extension::WebSocket* ws, const cocos2d::extension::WebSocket::Data& data) { - CCLog("SIOClientImpl::onMessage received: %s", data.bytes); + log("SIOClientImpl::onMessage received: %s", data.bytes); int control = atoi(&data.bytes[0]); @@ -422,31 +422,31 @@ void SIOClientImpl::onMessage(cocos2d::extension::WebSocket* ws, const cocos2d:: s_data = payload; SIOClient *c = NULL; c = getClient(endpoint); - if(c == NULL) CCLog("SIOClientImpl::onMessage client lookup returned NULL"); + if(c == NULL) log("SIOClientImpl::onMessage client lookup returned NULL"); switch(control) { case 0: - CCLog("Received Disconnect Signal for Endpoint: %s\n", endpoint.c_str()); + log("Received Disconnect Signal for Endpoint: %s\n", endpoint.c_str()); if(c) c->receivedDisconnect(); disconnectFromEndpoint(endpoint); break; case 1: - CCLog("Connected to endpoint: %s \n",endpoint.c_str()); + log("Connected to endpoint: %s \n",endpoint.c_str()); if(c) c->onConnect(); break; case 2: - CCLog("Heartbeat received\n"); + log("Heartbeat received\n"); break; case 3: - CCLog("Message received: %s \n", s_data.c_str()); + log("Message received: %s \n", s_data.c_str()); if(c) c->getDelegate()->onMessage(c, s_data); break; case 4: - CCLog("JSON Message Received: %s \n", s_data.c_str()); + log("JSON Message Received: %s \n", s_data.c_str()); if(c) c->getDelegate()->onMessage(c, s_data); break; case 5: - CCLog("Event Received with data: %s \n", s_data.c_str()); + log("Event Received with data: %s \n", s_data.c_str()); if(c) { eventname = ""; @@ -463,14 +463,14 @@ void SIOClientImpl::onMessage(cocos2d::extension::WebSocket* ws, const cocos2d:: break; case 6: - CCLog("Message Ack\n"); + log("Message Ack\n"); break; case 7: - CCLog("Error\n"); + log("Error\n"); if(c) c->getDelegate()->onError(c, s_data); break; case 8: - CCLog("Noop\n"); + log("Noop\n"); break; } @@ -590,7 +590,7 @@ void SIOClient::on(const std::string& eventName, SIOEvent e) { void SIOClient::fireEvent(const std::string& eventName, const std::string& data) { - CCLog("SIOClient::fireEvent called with event name: %s and data: %s", eventName.c_str(), data.c_str()); + log("SIOClient::fireEvent called with event name: %s and data: %s", eventName.c_str(), data.c_str()); if(_eventRegistry[eventName]) { @@ -601,7 +601,7 @@ void SIOClient::fireEvent(const std::string& eventName, const std::string& data) return; } - CCLog("SIOClient::fireEvent no event with name %s found", eventName.c_str()); + log("SIOClient::fireEvent no event with name %s found", eventName.c_str()); } diff --git a/plugin/samples/HelloPlugins/Classes/TestAds/TestAdsScene.cpp b/plugin/samples/HelloPlugins/Classes/TestAds/TestAdsScene.cpp index 0ebfaa5840..45a6459071 100644 --- a/plugin/samples/HelloPlugins/Classes/TestAds/TestAdsScene.cpp +++ b/plugin/samples/HelloPlugins/Classes/TestAds/TestAdsScene.cpp @@ -216,31 +216,31 @@ void TestAds::caseChanged(Object* pSender) default: break; } - CCLog("case selected change to : %s", strLog.c_str()); + log("case selected change to : %s", strLog.c_str()); } void TestAds::typeChanged(Object* pSender) { int selectIndex = _typeItem->getSelectedIndex(); _type = (ProtocolAds::AdsType) selectIndex; - CCLog("type selected change to : %d", _type); + log("type selected change to : %d", _type); } void TestAds::posChanged(Object* pSender) { int selectIndex = _posItem->getSelectedIndex(); _pos = (ProtocolAds::AdsPos) selectIndex; - CCLog("pos selected change to : %d", _pos); + log("pos selected change to : %d", _pos); } void MyAdsListener::onAdsResult(AdsResultCode code, const char* msg) { - CCLog("OnAdsResult, code : %d, msg : %s", code, msg); + log("OnAdsResult, code : %d, msg : %s", code, msg); } void MyAdsListener::onPlayerGetPoints(cocos2d::plugin::ProtocolAds* pAdsPlugin, int points) { - CCLog("Player get points : %d", points); + log("Player get points : %d", points); // @warning should add code to give game-money to player here diff --git a/plugin/samples/HelloPlugins/Classes/TestAnalytics/TestAnalyticsScene.cpp b/plugin/samples/HelloPlugins/Classes/TestAnalytics/TestAnalyticsScene.cpp index a5e20d1584..a0f110307b 100644 --- a/plugin/samples/HelloPlugins/Classes/TestAnalytics/TestAnalyticsScene.cpp +++ b/plugin/samples/HelloPlugins/Classes/TestAnalytics/TestAnalyticsScene.cpp @@ -153,7 +153,7 @@ void TestAnalytics::eventMenuCallback(Object* pSender) case TAG_LOG_ONLINE_CONFIG: { PluginParam param("abc"); - CCLog("Online config = %s", _pluginAnalytics->callStringFuncWithParam("getConfigParams", ¶m, NULL).c_str()); + log("Online config = %s", _pluginAnalytics->callStringFuncWithParam("getConfigParams", ¶m, NULL).c_str()); } break; case TAG_LOG_EVENT_ID_DURATION: @@ -259,7 +259,7 @@ void TestAnalytics::loadPlugins() _pluginAnalytics->setSessionContinueMillis(10000); const char* sdkVer = _pluginAnalytics->getSDKVersion().c_str(); - CCLog("SDK version : %s", sdkVer); + log("SDK version : %s", sdkVer); _pluginAnalytics->callFuncWithParam("updateOnlineConfig", NULL); diff --git a/plugin/samples/HelloPlugins/Classes/TestIAPOnline/MyIAPOLManager.cpp b/plugin/samples/HelloPlugins/Classes/TestIAPOnline/MyIAPOLManager.cpp index 7dc0460263..83da784f39 100644 --- a/plugin/samples/HelloPlugins/Classes/TestIAPOnline/MyIAPOLManager.cpp +++ b/plugin/samples/HelloPlugins/Classes/TestIAPOnline/MyIAPOLManager.cpp @@ -170,6 +170,6 @@ void MyIAPOnlineResult::onPayResult(PayResultCode ret, const char* msg, TProduct MessageBox(goodInfo , msg); if (ret == kPaySuccess) { - CCLog("Pay success locally, should check the real result by game server!"); + log("Pay success locally, should check the real result by game server!"); } } diff --git a/plugin/samples/HelloPlugins/Classes/TestUser/MyUserManager.cpp b/plugin/samples/HelloPlugins/Classes/TestUser/MyUserManager.cpp index 3c63bd8091..456b525969 100644 --- a/plugin/samples/HelloPlugins/Classes/TestUser/MyUserManager.cpp +++ b/plugin/samples/HelloPlugins/Classes/TestUser/MyUserManager.cpp @@ -215,8 +215,8 @@ void MyUserActionResult::onActionResult(ProtocolUser* pPlugin, UserActionResultC // get session ID std::string sessionID = pPlugin->getSessionID(); - CCLog("User Session ID of plugin %s is : %s", pPlugin->getPluginName(), sessionID.c_str()); + log("User Session ID of plugin %s is : %s", pPlugin->getPluginName(), sessionID.c_str()); std::string strStatus = pPlugin->isLogined() ? "online" : "offline"; - CCLog("User status of plugin %s is : %s", pPlugin->getPluginName(), strStatus.c_str()); + log("User status of plugin %s is : %s", pPlugin->getPluginName(), strStatus.c_str()); } diff --git a/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.cpp b/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.cpp index cb0b05d5ac..95c96b8473 100644 --- a/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.cpp +++ b/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.cpp @@ -32,14 +32,14 @@ AppDelegate::~AppDelegate() bool AppDelegate::applicationDidFinishLaunching() { // initialize director - Director *pDirector = Director::getInstance(); - pDirector->setOpenGLView(EGLView::getInstance()); + Director *director = Director::getInstance(); + director->setOpenGLView(EGLView::getInstance()); // turn on display FPS - //pDirector->setDisplayStats(true); + //director->setDisplayStats(true); // set FPS. the default value is 1.0/60 if you don't call this - pDirector->setAnimationInterval(1.0 / 60); + director->setAnimationInterval(1.0 / 60); ScriptingCore* sc = ScriptingCore::getInstance(); sc->addRegisterCallback(register_all_cocos2dx); @@ -52,7 +52,7 @@ bool AppDelegate::applicationDidFinishLaunching() scene->addChild(updateLayer); updateLayer->release(); - pDirector->runWithScene(scene); + director->runWithScene(scene); return true; } diff --git a/samples/Cpp/HelloCpp/Classes/AppDelegate.cpp b/samples/Cpp/HelloCpp/Classes/AppDelegate.cpp index 239242149a..b22c7e8a6e 100644 --- a/samples/Cpp/HelloCpp/Classes/AppDelegate.cpp +++ b/samples/Cpp/HelloCpp/Classes/AppDelegate.cpp @@ -19,17 +19,17 @@ AppDelegate::~AppDelegate() bool AppDelegate::applicationDidFinishLaunching() { // initialize director - Director* pDirector = Director::getInstance(); - EGLView* pEGLView = EGLView::getInstance(); + Director* director = Director::getInstance(); + EGLView* glView = EGLView::getInstance(); - pDirector->setOpenGLView(pEGLView); + director->setOpenGLView(glView); - Size size = pDirector->getWinSize(); + Size size = director->getWinSize(); // Set the design resolution - pEGLView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, kResolutionNoBorder); + glView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, kResolutionNoBorder); - Size frameSize = pEGLView->getFrameSize(); + Size frameSize = glView->getFrameSize(); vector searchPath; @@ -43,37 +43,37 @@ bool AppDelegate::applicationDidFinishLaunching() { { searchPath.push_back(largeResource.directory); - pDirector->setContentScaleFactor(MIN(largeResource.size.height/designResolutionSize.height, largeResource.size.width/designResolutionSize.width)); + director->setContentScaleFactor(MIN(largeResource.size.height/designResolutionSize.height, largeResource.size.width/designResolutionSize.width)); } // if the frame's height is larger than the height of small resource size, select medium resource. else if (frameSize.height > smallResource.size.height) { searchPath.push_back(mediumResource.directory); - pDirector->setContentScaleFactor(MIN(mediumResource.size.height/designResolutionSize.height, mediumResource.size.width/designResolutionSize.width)); + director->setContentScaleFactor(MIN(mediumResource.size.height/designResolutionSize.height, mediumResource.size.width/designResolutionSize.width)); } // if the frame's height is smaller than the height of medium resource size, select small resource. else { searchPath.push_back(smallResource.directory); - pDirector->setContentScaleFactor(MIN(smallResource.size.height/designResolutionSize.height, smallResource.size.width/designResolutionSize.width)); + director->setContentScaleFactor(MIN(smallResource.size.height/designResolutionSize.height, smallResource.size.width/designResolutionSize.width)); } // set searching path FileUtils::getInstance()->setSearchPaths(searchPath); // turn on display FPS - pDirector->setDisplayStats(true); + director->setDisplayStats(true); // set FPS. the default value is 1.0/60 if you don't call this - pDirector->setAnimationInterval(1.0 / 60); + director->setAnimationInterval(1.0 / 60); // create a scene. it's an autorelease object - Scene *pScene = HelloWorld::scene(); + Scene *scene = HelloWorld::scene(); // run - pDirector->runWithScene(pScene); + director->runWithScene(scene); return true; } diff --git a/samples/Cpp/HelloCpp/Classes/HelloWorldScene.cpp b/samples/Cpp/HelloCpp/Classes/HelloWorldScene.cpp index 902216f48b..b00c3184c1 100644 --- a/samples/Cpp/HelloCpp/Classes/HelloWorldScene.cpp +++ b/samples/Cpp/HelloCpp/Classes/HelloWorldScene.cpp @@ -36,18 +36,18 @@ bool HelloWorld::init() // you may modify it. // add a "close" icon to exit the progress. it's an autorelease object - MenuItemImage *pCloseItem = MenuItemImage::create( + MenuItemImage *closeItem = MenuItemImage::create( "CloseNormal.png", "CloseSelected.png", CC_CALLBACK_1(HelloWorld::menuCloseCallback,this)); - pCloseItem->setPosition(Point(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 , - origin.y + pCloseItem->getContentSize().height/2)); + closeItem->setPosition(Point(origin.x + visibleSize.width - closeItem->getContentSize().width/2 , + origin.y + closeItem->getContentSize().height/2)); // create menu, it's an autorelease object - Menu* pMenu = Menu::create(pCloseItem, NULL); - pMenu->setPosition(Point::ZERO); - this->addChild(pMenu, 1); + Menu* menu = Menu::create(closeItem, NULL); + menu->setPosition(Point::ZERO); + this->addChild(menu, 1); ///////////////////////////// // 3. add your codes below... @@ -55,23 +55,23 @@ bool HelloWorld::init() // add a label shows "Hello World" // create and initialize a label - LabelTTF* pLabel = LabelTTF::create("Hello World", "Arial", TITLE_FONT_SIZE); + LabelTTF* label = LabelTTF::create("Hello World", "Arial", TITLE_FONT_SIZE); // position the label on the center of the screen - pLabel->setPosition(Point(origin.x + visibleSize.width/2, - origin.y + visibleSize.height - pLabel->getContentSize().height)); + label->setPosition(Point(origin.x + visibleSize.width/2, + origin.y + visibleSize.height - label->getContentSize().height)); // add the label as a child to this layer - this->addChild(pLabel, 1); + this->addChild(label, 1); // add "HelloWorld" splash screen" - Sprite* pSprite = Sprite::create("HelloWorld.png"); + Sprite* sprite = Sprite::create("HelloWorld.png"); // position the sprite on the center of the screen - pSprite->setPosition(Point(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y)); + sprite->setPosition(Point(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y)); // add the sprite as a child to this layer - this->addChild(pSprite, 0); + this->addChild(sprite, 0); return true; } diff --git a/samples/Cpp/HelloCpp/proj.emscripten/Makefile b/samples/Cpp/HelloCpp/proj.emscripten/Makefile index 9e47a17ce9..56bb3d7df1 100644 --- a/samples/Cpp/HelloCpp/proj.emscripten/Makefile +++ b/samples/Cpp/HelloCpp/proj.emscripten/Makefile @@ -26,9 +26,9 @@ $(TARGET).js: $(OBJECTS) $(STATICLIBS) $(COCOS_LIBS) $(CORE_MAKEFILE_LIST) ifeq ($(shell uname -s),Darwin) -ARIEL_TTF := /Library/Fonts/Arial.ttf +ARIAL_TTF := /Library/Fonts/Arial.ttf else -ARIEL_TTF := $(COCOS_ROOT)/samples/Cpp/TestCpp/Resources/fonts/arial.ttf +ARIAL_TTF := $(COCOS_ROOT)/samples/Cpp/TestCpp/Resources/fonts/arial.ttf endif $(TARGET).data: @@ -39,15 +39,16 @@ $(TARGET).data: (cd $(RESOURCE_PATH) && cp -a $(RESOURCES) $(RESTMP)) (cd $(FONT_PATH) && cp -a * $(RESTMP)/fonts) # NOTE: we copy the system arial.ttf so that there is always a fallback. - cp $(ARIEL_TTF) $(RESTMP)/fonts/arial.ttf + cp $(ARIAL_TTF) $(RESTMP)/fonts/arial.ttf (cd $(RESTMP); python $(PACKAGER) $(EXECUTABLE).data $(patsubst %,--preload %,$(RESOURCES)) --preload fonts --pre-run > $(EXECUTABLE).data.js) mv $(RESTMP)/$(EXECUTABLE).data $@ mv $(RESTMP)/$(EXECUTABLE).data.js $@.js rm -rf $(RESTMP) -$(BIN_DIR)/index.html: index.html +$(BIN_DIR)/$(HTMLTPL_FILE): $(HTMLTPL_DIR)/$(HTMLTPL_FILE) @mkdir -p $(@D) - cp index.html $(@D) + @cp -Rf $(HTMLTPL_DIR)/* $(BIN_DIR) + @sed -i -e "s/JS_APPLICATION/$(EXECUTABLE)/g" $(BIN_DIR)/$(HTMLTPL_FILE) $(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST) @mkdir -p $(@D) diff --git a/samples/Cpp/HelloCpp/proj.emscripten/index.html b/samples/Cpp/HelloCpp/proj.emscripten/index.html deleted file mode 100644 index b8befe726a..0000000000 --- a/samples/Cpp/HelloCpp/proj.emscripten/index.html +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - Emscripten-Generated Code - - - -
-
Downloading...
-
- -
-
- -
-
-
- Resize canvas - Lock/hide mouse pointer -     - -
- -
- -
- - - - - diff --git a/samples/Cpp/SimpleGame/Classes/AppDelegate.cpp b/samples/Cpp/SimpleGame/Classes/AppDelegate.cpp index 5a682be8c9..961f517e43 100644 --- a/samples/Cpp/SimpleGame/Classes/AppDelegate.cpp +++ b/samples/Cpp/SimpleGame/Classes/AppDelegate.cpp @@ -14,9 +14,9 @@ AppDelegate::~AppDelegate() bool AppDelegate::applicationDidFinishLaunching() { // initialize director - Director *pDirector = Director::getInstance(); + Director *director = Director::getInstance(); - pDirector->setOpenGLView(EGLView::getInstance()); + director->setOpenGLView(EGLView::getInstance()); Size screenSize = EGLView::getInstance()->getFrameSize(); Size designSize = Size(480, 320); @@ -26,12 +26,12 @@ bool AppDelegate::applicationDidFinishLaunching() { { searchPaths.push_back("hd"); searchPaths.push_back("sd"); - pDirector->setContentScaleFactor(640.0f/designSize.height); + director->setContentScaleFactor(640.0f/designSize.height); } else { searchPaths.push_back("sd"); - pDirector->setContentScaleFactor(320.0f/designSize.height); + director->setContentScaleFactor(320.0f/designSize.height); } FileUtils::getInstance()->setSearchPaths(searchPaths); @@ -39,16 +39,16 @@ bool AppDelegate::applicationDidFinishLaunching() { EGLView::getInstance()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionNoBorder); // turn on display FPS - pDirector->setDisplayStats(true); + director->setDisplayStats(true); // set FPS. the default value is 1.0/60 if you don't call this - pDirector->setAnimationInterval(1.0 / 60); + director->setAnimationInterval(1.0 / 60); // create a scene. it's an autorelease object - Scene *pScene = HelloWorld::scene(); + Scene *scene = HelloWorld::scene(); // run - pDirector->runWithScene(pScene); + director->runWithScene(scene); return true; } diff --git a/samples/Cpp/SimpleGame/Classes/HelloWorldScene.cpp b/samples/Cpp/SimpleGame/Classes/HelloWorldScene.cpp index 88eed08a64..2f2ed57017 100644 --- a/samples/Cpp/SimpleGame/Classes/HelloWorldScene.cpp +++ b/samples/Cpp/SimpleGame/Classes/HelloWorldScene.cpp @@ -69,26 +69,26 @@ 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 *pCloseItem = MenuItemImage::create( + MenuItemImage *closeItem = MenuItemImage::create( "CloseNormal.png", "CloseSelected.png", CC_CALLBACK_1(HelloWorld::menuCloseCallback,this)); - CC_BREAK_IF(! pCloseItem); + CC_BREAK_IF(! closeItem); // Place the menu item bottom-right conner. Size visibleSize = Director::getInstance()->getVisibleSize(); Point origin = Director::getInstance()->getVisibleOrigin(); - pCloseItem->setPosition(Point(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2, - origin.y + pCloseItem->getContentSize().height/2)); + 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* pMenu = Menu::create(pCloseItem, NULL); - pMenu->setPosition(Point::ZERO); - CC_BREAK_IF(! pMenu); + Menu* menu = Menu::create(closeItem, NULL); + menu->setPosition(Point::ZERO); + CC_BREAK_IF(! menu); // Add the menu to HelloWorld layer as a child layer. - this->addChild(pMenu, 1); + this->addChild(menu, 1); ///////////////////////////// // 2. add your codes below... @@ -193,7 +193,7 @@ void HelloWorld::ccTouchesEnded(Set* touches, Event* event) Touch* touch = (Touch*)( touches->anyObject() ); Point location = touch->getLocation(); - CCLog("++++++++after x:%f, y:%f", location.x, location.y); + log("++++++++after x:%f, y:%f", location.x, location.y); // Set up initial location of projectile Size winSize = Director::getInstance()->getVisibleSize(); diff --git a/samples/Cpp/SimpleGame/proj.emscripten/Makefile b/samples/Cpp/SimpleGame/proj.emscripten/Makefile index 39559056f2..cc538b4d65 100644 --- a/samples/Cpp/SimpleGame/proj.emscripten/Makefile +++ b/samples/Cpp/SimpleGame/proj.emscripten/Makefile @@ -57,9 +57,10 @@ $(TARGET).data: mv $(RESTMP)/$(EXECUTABLE).data.js $@.js rm -rf $(RESTMP) -$(BIN_DIR)/index.html: index.html +$(BIN_DIR)/$(HTMLTPL_FILE): $(HTMLTPL_DIR)/$(HTMLTPL_FILE) @mkdir -p $(@D) - cp index.html $(@D) + @cp -Rf $(HTMLTPL_DIR)/* $(BIN_DIR) + @sed -i -e "s/JS_APPLICATION/$(EXECUTABLE)/g" $(BIN_DIR)/$(HTMLTPL_FILE) $(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST) @mkdir -p $(@D) diff --git a/samples/Cpp/SimpleGame/proj.emscripten/index.html b/samples/Cpp/SimpleGame/proj.emscripten/index.html deleted file mode 100644 index a78af31af6..0000000000 --- a/samples/Cpp/SimpleGame/proj.emscripten/index.html +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - SimpleGame - - - -
-
Downloading...
-
- -
-
- -
-
-
- Resize canvas - Lock/hide mouse pointer -     - -
- -
- -
- - - - - diff --git a/samples/Cpp/TestCpp/Classes/AccelerometerTest/AccelerometerTest.cpp b/samples/Cpp/TestCpp/Classes/AccelerometerTest/AccelerometerTest.cpp index 21f8fe15d8..4ffb54a8f8 100644 --- a/samples/Cpp/TestCpp/Classes/AccelerometerTest/AccelerometerTest.cpp +++ b/samples/Cpp/TestCpp/Classes/AccelerometerTest/AccelerometerTest.cpp @@ -85,9 +85,9 @@ void AccelerometerTest::didAccelerate(Acceleration* pAccelerationValue) //------------------------------------------------------------------ void AccelerometerTestScene::runThisTest() { - Layer* pLayer = new AccelerometerTest(); - addChild(pLayer); - pLayer->release(); + Layer* layer = new AccelerometerTest(); + addChild(layer); + layer->release(); Director::getInstance()->replaceScene(this); } diff --git a/samples/Cpp/TestCpp/Classes/ActionManagerTest/ActionManagerTest.cpp b/samples/Cpp/TestCpp/Classes/ActionManagerTest/ActionManagerTest.cpp index 04af0b6e62..9260a12bb9 100644 --- a/samples/Cpp/TestCpp/Classes/ActionManagerTest/ActionManagerTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ActionManagerTest/ActionManagerTest.cpp @@ -36,10 +36,10 @@ Layer* nextActionManagerAction() sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - Layer* pLayer = createActionManagerLayer(sceneIdx); - pLayer->autorelease(); + Layer* layer = createActionManagerLayer(sceneIdx); + layer->autorelease(); - return pLayer; + return layer; } Layer* backActionManagerAction() @@ -49,18 +49,18 @@ Layer* backActionManagerAction() if( sceneIdx < 0 ) sceneIdx += total; - Layer* pLayer = createActionManagerLayer(sceneIdx); - pLayer->autorelease(); + Layer* layer = createActionManagerLayer(sceneIdx); + layer->autorelease(); - return pLayer; + return layer; } Layer* restartActionManagerAction() { - Layer* pLayer = createActionManagerLayer(sceneIdx); - pLayer->autorelease(); + Layer* layer = createActionManagerLayer(sceneIdx); + layer->autorelease(); - return pLayer; + return layer; } //------------------------------------------------------------------ @@ -117,7 +117,7 @@ void CrashTest::onEnter() { ActionManagerTest::onEnter(); - Sprite* child = Sprite::create(s_pPathGrossini); + Sprite* 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_pPathGrossini); + Sprite* grossini = Sprite::create(s_pathGrossini); addChild(grossini, 0, 2); grossini->setPosition(VisibleRect::center()); @@ -203,14 +203,14 @@ void PauseTest::onEnter() // // Also, this test MUST be done, after [super onEnter] // - Sprite* grossini = Sprite::create(s_pPathGrossini); + Sprite* grossini = Sprite::create(s_pathGrossini); addChild(grossini, 0, kTagGrossini); grossini->setPosition(VisibleRect::center() ); Action* action = MoveBy::create(1, Point(150,0)); - Director* pDirector = Director::getInstance(); - pDirector->getActionManager()->addAction(action, grossini, true); + Director* director = Director::getInstance(); + director->getActionManager()->addAction(action, grossini, true); schedule( schedule_selector(PauseTest::unpause), 3); } @@ -219,8 +219,8 @@ void PauseTest::unpause(float dt) { unschedule( schedule_selector(PauseTest::unpause) ); Node* node = getChildByTag( kTagGrossini ); - Director* pDirector = Director::getInstance(); - pDirector->getActionManager()->resumeTarget(node); + Director* director = Director::getInstance(); + director->getActionManager()->resumeTarget(node); } std::string PauseTest::title() @@ -246,7 +246,7 @@ void RemoveTest::onEnter() ActionInterval* pSequence = Sequence::create(pMove, pCallback, NULL); pSequence->setTag(kTagSequence); - Sprite* pChild = Sprite::create(s_pPathGrossini); + Sprite* pChild = Sprite::create(s_pathGrossini); pChild->setPosition( VisibleRect::center() ); addChild(pChild, 1, kTagGrossini); @@ -255,8 +255,8 @@ void RemoveTest::onEnter() void RemoveTest::stopAction() { - Node* pSprite = getChildByTag(kTagGrossini); - pSprite->stopActionByTag(kTagSequence); + Node* sprite = getChildByTag(kTagGrossini); + sprite->stopActionByTag(kTagSequence); } std::string RemoveTest::title() @@ -282,14 +282,14 @@ void ResumeTest::onEnter() addChild(l); l->setPosition( Point(VisibleRect::center().x, VisibleRect::top().y - 75)); - Sprite* pGrossini = Sprite::create(s_pPathGrossini); + Sprite* pGrossini = Sprite::create(s_pathGrossini); addChild(pGrossini, 0, kTagGrossini); pGrossini->setPosition(VisibleRect::center()); pGrossini->runAction(ScaleBy::create(2, 2)); - Director* pDirector = Director::getInstance(); - pDirector->getActionManager()->pauseTarget(pGrossini); + Director* director = Director::getInstance(); + director->getActionManager()->pauseTarget(pGrossini); pGrossini->runAction(RotateBy::create(2, 360)); this->schedule(schedule_selector(ResumeTest::resumeGrossini), 3.0f); @@ -300,8 +300,8 @@ void ResumeTest::resumeGrossini(float time) this->unschedule(schedule_selector(ResumeTest::resumeGrossini)); Node* pGrossini = getChildByTag(kTagGrossini); - Director* pDirector = Director::getInstance(); - pDirector->getActionManager()->resumeTarget(pGrossini); + Director* director = Director::getInstance(); + director->getActionManager()->resumeTarget(pGrossini); } //------------------------------------------------------------------ @@ -311,8 +311,8 @@ void ResumeTest::resumeGrossini(float time) //------------------------------------------------------------------ void ActionManagerTestScene::runThisTest() { - Layer* pLayer = nextActionManagerAction(); - addChild(pLayer); + Layer* 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 690bfafffa..da9e8fa250 100644 --- a/samples/Cpp/TestCpp/Classes/ActionsEaseTest/ActionsEaseTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ActionsEaseTest/ActionsEaseTest.cpp @@ -552,10 +552,10 @@ Layer* nextEaseAction() sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - Layer* pLayer = createEaseLayer(sceneIdx); - pLayer->autorelease(); + Layer* layer = createEaseLayer(sceneIdx); + layer->autorelease(); - return pLayer; + return layer; } Layer* backEaseAction() @@ -565,18 +565,18 @@ Layer* backEaseAction() if( sceneIdx < 0 ) sceneIdx += total; - Layer* pLayer = createEaseLayer(sceneIdx); - pLayer->autorelease(); + Layer* layer = createEaseLayer(sceneIdx); + layer->autorelease(); - return pLayer; + return layer; } Layer* restartEaseAction() { - Layer* pLayer = createEaseLayer(sceneIdx); - pLayer->autorelease(); + Layer* layer = createEaseLayer(sceneIdx); + layer->autorelease(); - return pLayer; + return layer; } @@ -609,9 +609,9 @@ void EaseSpriteDemo::onEnter() BaseTest::onEnter(); // Or you can create an sprite using a filename. PNG and BMP files are supported. Probably TIFF too - _grossini = Sprite::create(s_pPathGrossini); _grossini->retain(); - _tamara = Sprite::create(s_pPathSister1); _tamara->retain(); - _kathia = Sprite::create(s_pPathSister2); _kathia->retain(); + _grossini = Sprite::create(s_pathGrossini); _grossini->retain(); + _tamara = Sprite::create(s_pathSister1); _tamara->retain(); + _kathia = Sprite::create(s_pathSister2); _kathia->retain(); addChild( _grossini, 3); addChild( _kathia, 2); @@ -649,8 +649,8 @@ void EaseSpriteDemo::backCallback(Object* pSender) void ActionsEaseTestScene::runThisTest() { - Layer* pLayer = nextEaseAction(); - addChild(pLayer); + Layer* 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 05184a4a38..8585e62243 100644 --- a/samples/Cpp/TestCpp/Classes/ActionsProgressTest/ActionsProgressTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ActionsProgressTest/ActionsProgressTest.cpp @@ -30,10 +30,10 @@ Layer* nextAction() sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - Layer* pLayer = createLayer(sceneIdx); - pLayer->autorelease(); + Layer* layer = createLayer(sceneIdx); + layer->autorelease(); - return pLayer; + return layer; } Layer* backAction() @@ -43,18 +43,18 @@ Layer* backAction() if( sceneIdx < 0 ) sceneIdx += total; - Layer* pLayer = createLayer(sceneIdx); - pLayer->autorelease(); + Layer* layer = createLayer(sceneIdx); + layer->autorelease(); - return pLayer; + return layer; } Layer* restartAction() { - Layer* pLayer = createLayer(sceneIdx); - pLayer->autorelease(); + Layer* layer = createLayer(sceneIdx); + layer->autorelease(); - return pLayer; + return layer; } @@ -135,13 +135,13 @@ void SpriteProgressToRadial::onEnter() ProgressTo *to1 = ProgressTo::create(2, 100); ProgressTo *to2 = ProgressTo::create(2, 100); - ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pPathSister1)); + ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathSister1)); left->setType( kProgressTimerTypeRadial ); addChild(left); left->setPosition(Point(100, s.height/2)); left->runAction( RepeatForever::create(to1)); - ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pPathBlock)); + ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathBlock)); right->setType(kProgressTimerTypeRadial); // Makes the ridial CCW right->setReverseProgress(true); @@ -170,7 +170,7 @@ void SpriteProgressToHorizontal::onEnter() ProgressTo *to1 = ProgressTo::create(2, 100); ProgressTo *to2 = ProgressTo::create(2, 100); - ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pPathSister1)); + ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathSister1)); left->setType(kProgressTimerTypeBar); // 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_pPathSister2)); + ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathSister2)); right->setType(kProgressTimerTypeBar); // Setup for a bar starting from the left since the midpoint is 1 for the x right->setMidpoint(Point(1, 0)); @@ -210,7 +210,7 @@ void SpriteProgressToVertical::onEnter() ProgressTo *to1 = ProgressTo::create(2, 100); ProgressTo *to2 = ProgressTo::create(2, 100); - ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pPathSister1)); + ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathSister1)); left->setType(kProgressTimerTypeBar); // 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_pPathSister2)); + ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathSister2)); right->setType(kProgressTimerTypeBar); // Setup for a bar starting from the bottom since the midpoint is 0 for the y right->setMidpoint(Point(0, 1)); @@ -253,7 +253,7 @@ void SpriteProgressToRadialMidpointChanged::onEnter() /** * Our image on the left should be a radial progress indicator, clockwise */ - ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pPathBlock)); + ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathBlock)); left->setType(kProgressTimerTypeRadial); 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_pPathBlock)); + ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathBlock)); right->setType(kProgressTimerTypeRadial); right->setMidpoint(Point(0.75f, 0.25f)); @@ -294,7 +294,7 @@ void SpriteProgressBarVarious::onEnter() ProgressTo *to = ProgressTo::create(2, 100); - ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pPathSister1)); + ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathSister1)); left->setType(kProgressTimerTypeBar); // 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_pPathSister2)); + ProgressTimer *middle = ProgressTimer::create(Sprite::create(s_pathSister2)); middle->setType(kProgressTimerTypeBar); // 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_pPathSister2)); + ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathSister2)); right->setType(kProgressTimerTypeBar); // Setup for a bar starting from the bottom since the midpoint is 0 for the y right->setMidpoint(Point(0.5f, 0.5f)); @@ -351,7 +351,7 @@ void SpriteProgressBarTintAndFade::onEnter() FadeTo::create(1.0f, 255), NULL); - ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pPathSister1)); + ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathSister1)); left->setType(kProgressTimerTypeBar); // 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_pPathSister2)); + ProgressTimer *middle = ProgressTimer::create(Sprite::create(s_pathSister2)); middle->setType(kProgressTimerTypeBar); // 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_pPathSister2)); + ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathSister2)); right->setType(kProgressTimerTypeBar); // 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 3e2cf0e2d0..8a956cd992 100644 --- a/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.cpp @@ -61,11 +61,11 @@ static Layer* nextAction() sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - Layer* pLayer = (createFunctions[sceneIdx])(); - pLayer->init(); - pLayer->autorelease(); + Layer* layer = (createFunctions[sceneIdx])(); + layer->init(); + layer->autorelease(); - return pLayer; + return layer; } static Layer* backAction() @@ -75,20 +75,20 @@ static Layer* backAction() if( sceneIdx < 0 ) sceneIdx += total; - Layer* pLayer = (createFunctions[sceneIdx])(); - pLayer->init(); - pLayer->autorelease(); + Layer* layer = (createFunctions[sceneIdx])(); + layer->init(); + layer->autorelease(); - return pLayer; + return layer; } static Layer* restartAction() { - Layer* pLayer = (createFunctions[sceneIdx])(); - pLayer->init(); - pLayer->autorelease(); + Layer* layer = (createFunctions[sceneIdx])(); + layer->init(); + layer->autorelease(); - return pLayer; + return layer; } void ActionsTestScene::runThisTest() @@ -115,13 +115,13 @@ void ActionsDemo::onEnter() BaseTest::onEnter(); // Or you can create an sprite using a filename. only PNG is supported now. Probably TIFF too - _grossini = Sprite::create(s_pPathGrossini); + _grossini = Sprite::create(s_pathGrossini); _grossini->retain(); - _tamara = Sprite::create(s_pPathSister1); + _tamara = Sprite::create(s_pathSister1); _tamara->retain(); - _kathia = Sprite::create(s_pPathSister2); + _kathia = Sprite::create(s_pathSister2); _kathia->retain(); addChild(_grossini, 1); @@ -1254,8 +1254,8 @@ void ActionOrbit::onEnter() auto move = MoveBy::create(3, Point(100,-100)); auto move_back = move->reverse(); - auto seq = Sequence::create(move, move_back, NULL); - auto rfe = RepeatForever::create(seq); + auto seq = Sequence::create(move, move_back, NULL); + auto rfe = RepeatForever::create(seq); _kathia->runAction(rfe); _tamara->runAction(rfe->clone() ); _grossini->runAction( rfe->clone() ); @@ -1279,10 +1279,10 @@ void ActionFollow::onEnter() auto s = Director::getInstance()->getWinSize(); _grossini->setPosition(Point(-200, s.height / 2)); - auto move = MoveBy::create(2, Point(s.width * 3, 0)); + auto move = MoveBy::create(2, Point(s.width * 3, 0)); auto move_back = move->reverse(); - auto seq = Sequence::create(move, move_back, NULL); - auto rep = RepeatForever::create(seq); + auto seq = Sequence::create(move, move_back, NULL); + auto rep = RepeatForever::create(seq); _grossini->runAction(rep); @@ -1313,7 +1313,7 @@ void ActionTargeted::onEnter() auto jump1 = JumpBy::create(2,Point::ZERO,100,3); auto jump2 = jump1->clone(); - auto rot1 = RotateBy::create(1, 360); + auto rot1 = RotateBy::create(1, 360); auto rot2 = rot1->clone(); auto t1 = TargetedAction::create(_kathia, jump2); @@ -1510,7 +1510,6 @@ void ActionCatmullRomStacked::onEnter() _tamara->runAction(seq); - _tamara->runAction( RepeatForever::create( Sequence::create( @@ -1547,7 +1546,6 @@ void ActionCatmullRomStacked::onEnter() MoveBy::create(0.05f, Point(-10,0)), NULL))); - array->retain(); _array1 = array; array2->retain(); @@ -1704,7 +1702,7 @@ void Issue1305::onEnter() void Issue1305::log(Node* pSender) { - CCLog("This message SHALL ONLY appear when the sprite is added to the scene, NOT BEFORE"); + cocos2d::log("This message SHALL ONLY appear when the sprite is added to the scene, NOT BEFORE"); } void Issue1305::onExit() @@ -1775,22 +1773,22 @@ void Issue1305_2::onEnter() void Issue1305_2::printLog1() { - CCLog("1st block"); + log("1st block"); } void Issue1305_2::printLog2() { - CCLog("2nd block"); + log("2nd block"); } void Issue1305_2::printLog3() { - CCLog("3rd block"); + log("3rd block"); } void Issue1305_2::printLog4() { - CCLog("4th block"); + log("4th block"); } std::string Issue1305_2::title() @@ -1889,14 +1887,14 @@ std::string Issue1327::subtitle() void Issue1327::logSprRotation(Sprite* pSender) { - CCLog("%f", pSender->getRotation()); + log("%f", pSender->getRotation()); } //Issue1398 void Issue1398::incrementInteger() { _testInteger++; - CCLog("incremented to %d", _testInteger); + log("incremented to %d", _testInteger); } void Issue1398::onEnter() @@ -1905,7 +1903,7 @@ void Issue1398::onEnter() this->centerSprites(0); _testInteger = 0; - CCLog("testInt = %d", _testInteger); + log("testInt = %d", _testInteger); this->runAction( Sequence::create( @@ -1923,7 +1921,7 @@ void Issue1398::onEnter() void Issue1398::incrementIntegerCallback(void* data) { this->incrementInteger(); - CCLog("%s", (char*)data); + log("%s", (char*)data); } std::string Issue1398::subtitle() @@ -2153,7 +2151,7 @@ string PauseResumeActions::subtitle() void PauseResumeActions::pause(float dt) { - CCLog("Pausing"); + log("Pausing"); Director *director = Director::getInstance(); CC_SAFE_RELEASE(_pausedTargets); @@ -2163,7 +2161,7 @@ void PauseResumeActions::pause(float dt) void PauseResumeActions::resume(float dt) { - CCLog("Resuming"); + log("Resuming"); Director *director = Director::getInstance(); director->getActionManager()->resumeTargets(_pausedTargets); } diff --git a/samples/Cpp/TestCpp/Classes/AppDelegate.cpp b/samples/Cpp/TestCpp/Classes/AppDelegate.cpp index 06d35122e1..32536a540e 100644 --- a/samples/Cpp/TestCpp/Classes/AppDelegate.cpp +++ b/samples/Cpp/TestCpp/Classes/AppDelegate.cpp @@ -27,8 +27,11 @@ bool AppDelegate::applicationDidFinishLaunching() Configuration::getInstance()->loadConfigFile("configs/config-example.plist"); // initialize director - Director *pDirector = Director::getInstance(); - pDirector->setOpenGLView(EGLView::getInstance()); + Director *director = Director::getInstance(); + director->setOpenGLView(EGLView::getInstance()); + + director->setDisplayStats(true); + director->setAnimationInterval(1.0 / 60); Size screenSize = EGLView::getInstance()->getFrameSize(); @@ -42,17 +45,17 @@ bool AppDelegate::applicationDidFinishLaunching() std::vector searchPaths; searchPaths.push_back("hd"); pFileUtils->setSearchPaths(searchPaths); - pDirector->setContentScaleFactor(resourceSize.height/designSize.height); + director->setContentScaleFactor(resourceSize.height/designSize.height); } EGLView::getInstance()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionNoBorder); - Scene * pScene = Scene::create(); - Layer * pLayer = new TestController(); - pLayer->autorelease(); + auto scene = Scene::create(); + auto layer = new TestController(); + layer->autorelease(); - pScene->addChild(pLayer); - pDirector->runWithScene(pScene); + scene->addChild(layer); + director->runWithScene(scene); return true; } diff --git a/samples/Cpp/TestCpp/Classes/BaseTest.cpp b/samples/Cpp/TestCpp/Classes/BaseTest.cpp index c4f268027d..de2ef9a17e 100644 --- a/samples/Cpp/TestCpp/Classes/BaseTest.cpp +++ b/samples/Cpp/TestCpp/Classes/BaseTest.cpp @@ -34,9 +34,9 @@ void BaseTest::onEnter() // add menu // CC_CALLBACK_1 == std::bind( function_ptr, instance, std::placeholders::_1, ...) - MenuItemImage *item1 = MenuItemImage::create(s_pPathB1, s_pPathB2, CC_CALLBACK_1(BaseTest::backCallback, this) ); - MenuItemImage *item2 = MenuItemImage::create(s_pPathR1, s_pPathR2, CC_CALLBACK_1(BaseTest::restartCallback, this) ); - MenuItemImage *item3 = MenuItemImage::create(s_pPathF1, s_pPathF2, CC_CALLBACK_1(BaseTest::nextCallback, this) ); + 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) ); Menu *menu = Menu::create(item1, item2, item3, NULL); @@ -66,15 +66,15 @@ std::string BaseTest::subtitle() void BaseTest::restartCallback(Object* pSender) { - CCLog("override restart!"); + log("override restart!"); } void BaseTest::nextCallback(Object* pSender) { - CCLog("override next!"); + log("override next!"); } void BaseTest::backCallback(Object* pSender) { - CCLog("override back!"); + log("override back!"); } diff --git a/samples/Cpp/TestCpp/Classes/Box2DTest/Box2dTest.cpp b/samples/Cpp/TestCpp/Classes/Box2DTest/Box2dTest.cpp index 5c1b417cca..36913874db 100644 --- a/samples/Cpp/TestCpp/Classes/Box2DTest/Box2dTest.cpp +++ b/samples/Cpp/TestCpp/Classes/Box2DTest/Box2dTest.cpp @@ -44,13 +44,13 @@ Box2DTestLayer::Box2DTestLayer() scheduleUpdate(); #else - LabelTTF *pLabel = LabelTTF::create("Should define CC_ENABLE_BOX2D_INTEGRATION=1\n to run this test case", + LabelTTF *label = LabelTTF::create("Should define CC_ENABLE_BOX2D_INTEGRATION=1\n to run this test case", "Arial", 18); Size size = Director::getInstance()->getWinSize(); - pLabel->setPosition(Point(size.width/2, size.height/2)); + label->setPosition(Point(size.width/2, size.height/2)); - addChild(pLabel); + addChild(label); #endif } @@ -248,9 +248,9 @@ void Box2DTestLayer::accelerometer(UIAccelerometer* accelerometer, Acceleration* void Box2DTestScene::runThisTest() { - Layer* pLayer = new Box2DTestLayer(); - addChild(pLayer); - pLayer->release(); + Layer* layer = new Box2DTestLayer(); + addChild(layer); + layer->release(); Director::getInstance()->replaceScene(this); } diff --git a/samples/Cpp/TestCpp/Classes/Box2DTestBed/Box2dView.cpp b/samples/Cpp/TestCpp/Classes/Box2DTestBed/Box2dView.cpp index dec9f47510..b07b92d335 100644 --- a/samples/Cpp/TestCpp/Classes/Box2DTestBed/Box2dView.cpp +++ b/samples/Cpp/TestCpp/Classes/Box2DTestBed/Box2dView.cpp @@ -37,18 +37,18 @@ MenuLayer::~MenuLayer(void) MenuLayer* MenuLayer::menuWithEntryID(int entryId) { - MenuLayer* pLayer = new MenuLayer(); - pLayer->initWithEntryID(entryId); - pLayer->autorelease(); + MenuLayer* layer = new MenuLayer(); + layer->initWithEntryID(entryId); + layer->autorelease(); - return pLayer; + return layer; } bool MenuLayer::initWithEntryID(int entryId) { - Director* pDirector = Director::getInstance(); - Point visibleOrigin = pDirector->getVisibleOrigin(); - Size visibleSize = pDirector->getVisibleSize(); + Director* director = Director::getInstance(); + Point visibleOrigin = director->getVisibleOrigin(); + Size visibleSize = director->getVisibleSize(); m_entryID = entryId; @@ -121,8 +121,8 @@ void MenuLayer::backCallback(Object* sender) void MenuLayer::registerWithTouchDispatcher() { - Director* pDirector = Director::getInstance(); - pDirector->getTouchDispatcher()->addTargetedDelegate(this, 0, true); + Director* director = Director::getInstance(); + director->getTouchDispatcher()->addTargetedDelegate(this, 0, true); } bool MenuLayer::ccTouchBegan(Touch* touch, Event* event) @@ -210,8 +210,8 @@ Box2DView::~Box2DView() void Box2DView::registerWithTouchDispatcher() { // higher priority than dragging - Director* pDirector = Director::getInstance(); - pDirector->getTouchDispatcher()->addTargetedDelegate(this, -10, true); + Director* director = Director::getInstance(); + director->getTouchDispatcher()->addTargetedDelegate(this, -10, true); } bool Box2DView::ccTouchBegan(Touch* touch, Event* event) diff --git a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-1159.cpp b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-1159.cpp index 131b7f9eec..2798076821 100644 --- a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-1159.cpp +++ b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-1159.cpp @@ -11,11 +11,11 @@ Scene* Bug1159Layer::scene() { - Scene *pScene = Scene::create(); + Scene *scene = Scene::create(); Bug1159Layer* layer = Bug1159Layer::create(); - pScene->addChild(layer); + scene->addChild(layer); - return pScene; + return scene; } bool Bug1159Layer::init() diff --git a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-1174.cpp b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-1174.cpp index 676d94afb7..6e1221a26b 100644 --- a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-1174.cpp +++ b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-1174.cpp @@ -23,7 +23,7 @@ int check_for_error( Point p1, Point p2, Point p3, Point p4, float s, float t ) // 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) ) { - CCLog("ERROR: (%f,%f) != (%f,%f)", hitPoint1.x, hitPoint1.y, hitPoint2.x, hitPoint2.y); + log("ERROR: (%f,%f) != (%f,%f)", hitPoint1.x, hitPoint1.y, hitPoint2.x, hitPoint2.y); return 1; } @@ -46,7 +46,7 @@ bool Bug1174Layer::init() // // Test 1. // - CCLog("Test1 - Start"); + log("Test1 - Start"); for( int i=0; i < 10000; i++) { // A | b @@ -84,12 +84,12 @@ bool Bug1174Layer::init() ok++; } } - CCLog("Test1 - End. OK=%i, Err=%i", ok, err); + log("Test1 - End. OK=%i, Err=%i", ok, err); // // Test 2. // - CCLog("Test2 - Start"); + log("Test2 - Start"); p1 = Point(220,480); p2 = Point(304,325); @@ -100,13 +100,13 @@ bool Bug1174Layer::init() if( Point::isLineIntersect(p1, p2, p3, p4, &s, &t) ) check_for_error(p1, p2, p3, p4, s,t ); - CCLog("Test2 - End"); + log("Test2 - End"); // // Test 3 // - CCLog("Test3 - Start"); + log("Test3 - Start"); ok=0; err=0; @@ -153,7 +153,7 @@ bool Bug1174Layer::init() } } - CCLog("Test3 - End. OK=%i, err=%i", ok, err); + log("Test3 - End. OK=%i, err=%i", ok, err); return true; } diff --git a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-422.cpp b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-422.cpp index f0ea06c351..1cdf836a89 100644 --- a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-422.cpp +++ b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-422.cpp @@ -27,12 +27,12 @@ void Bug422Layer::reset() // and then a new node will be allocated occupying the memory. // => CRASH BOOM BANG Node *node = getChildByTag(localtag-1); - CCLog("Menu: %p", node); + log("Menu: %p", node); removeChild(node, false); // [self removeChildByTag:localtag-1 cleanup:NO]; MenuItem *item1 = MenuItemFont::create("One", CC_CALLBACK_1(Bug422Layer::menuCallback, this) ); - CCLog("MenuItemFont: %p", item1); + log("MenuItemFont: %p", item1); MenuItem *item2 = MenuItemFont::create("Two", CC_CALLBACK_1(Bug422Layer::menuCallback, this) ); Menu *menu = Menu::create(item1, item2, NULL); menu->alignItemsVertically(); @@ -52,9 +52,9 @@ void Bug422Layer::check(Node* t) CCARRAY_FOREACH(array, pChild) { CC_BREAK_IF(! pChild); - Node* pNode = static_cast(pChild); - CCLog("%p, rc: %d", pNode, pNode->retainCount()); - check(pNode); + Node* 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 2d936b69ec..060ca63515 100644 --- a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-458/Bug-458.cpp +++ b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-458/Bug-458.cpp @@ -42,5 +42,5 @@ bool Bug458Layer::init() void Bug458Layer::selectAnswer(Object* sender) { - CCLog("Selected"); + log("Selected"); } diff --git a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-458/QuestionContainerSprite.cpp b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-458/QuestionContainerSprite.cpp index 544bf44b88..69fc37ebbd 100644 --- a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-458/QuestionContainerSprite.cpp +++ b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-458/QuestionContainerSprite.cpp @@ -30,7 +30,7 @@ bool QuestionContainerSprite::init() label->setColor(Color3B::BLUE); else { - CCLog("Color changed"); + log("Color changed"); label->setColor(Color3B::RED); } a++; diff --git a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-624.cpp b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-624.cpp index c901bebeac..977dc14fd1 100644 --- a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-624.cpp +++ b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-624.cpp @@ -39,7 +39,7 @@ void Bug624Layer::switchLayer(float dt) void Bug624Layer::didAccelerate(Acceleration* acceleration) { - CCLog("Layer1 accel"); + log("Layer1 accel"); } //////////////////////////////////////////////////////// @@ -76,5 +76,5 @@ void Bug624Layer2::switchLayer(float dt) void Bug624Layer2::didAccelerate(Acceleration* acceleration) { - CCLog("Layer2 accel"); + log("Layer2 accel"); } diff --git a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-914.cpp b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-914.cpp index ddc0276acf..73f43f0d3e 100644 --- a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-914.cpp +++ b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-914.cpp @@ -12,15 +12,15 @@ Scene* Bug914Layer::scene() { // 'scene' is an autorelease object. - Scene *pScene = Scene::create(); + Scene *scene = Scene::create(); // 'layer' is an autorelease object. Bug914Layer* layer = Bug914Layer::create(); // add layer as a child to scene - pScene->addChild(layer); + scene->addChild(layer); // return the scene - return pScene; + return scene; } // on "init" you need to initialize your instance @@ -65,7 +65,7 @@ bool Bug914Layer::init() void Bug914Layer::ccTouchesMoved(Set *touches, Event * event) { - CCLog("Number of touches: %d", touches->count()); + log("Number of touches: %d", touches->count()); } void Bug914Layer::ccTouchesBegan(Set *touches, Event * event) diff --git a/samples/Cpp/TestCpp/Classes/BugsTest/BugsTest.cpp b/samples/Cpp/TestCpp/Classes/BugsTest/BugsTest.cpp index 6e9828cda5..392c8f8a74 100644 --- a/samples/Cpp/TestCpp/Classes/BugsTest/BugsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/BugsTest/BugsTest.cpp @@ -11,12 +11,12 @@ #define TEST_BUG(__bug__) \ { \ - Scene* pScene = Scene::create(); \ - Bug##__bug__##Layer* pLayer = new Bug##__bug__##Layer(); \ - pLayer->init(); \ - pScene->addChild(pLayer); \ - Director::getInstance()->replaceScene(pScene); \ - pLayer->autorelease(); \ + Scene* scene = Scene::create(); \ + Bug##__bug__##Layer* layer = new Bug##__bug__##Layer(); \ + layer->init(); \ + scene->addChild(layer); \ + Director::getInstance()->replaceScene(scene); \ + layer->autorelease(); \ } enum @@ -117,17 +117,17 @@ void BugsTestBaseLayer::onEnter() MenuItemFont::setFontSize(24); MenuItemFont* pMainItem = MenuItemFont::create("Back", CC_CALLBACK_1(BugsTestBaseLayer::backCallback, this)); pMainItem->setPosition(Point(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25)); - Menu* pMenu = Menu::create(pMainItem, NULL); - pMenu->setPosition( Point::ZERO ); - addChild(pMenu); + Menu* menu = Menu::create(pMainItem, NULL); + menu->setPosition( Point::ZERO ); + addChild(menu); } void BugsTestBaseLayer::backCallback(Object* pSender) { // Director::getInstance()->enableRetinaDisplay(false); - BugsTestScene* pScene = new BugsTestScene(); - pScene->runThisTest(); - pScene->autorelease(); + BugsTestScene* scene = new BugsTestScene(); + scene->runThisTest(); + scene->autorelease(); } //////////////////////////////////////////////////////// @@ -137,9 +137,9 @@ void BugsTestBaseLayer::backCallback(Object* pSender) //////////////////////////////////////////////////////// void BugsTestScene::runThisTest() { - Layer* pLayer = new BugsTestMainLayer(); - addChild(pLayer); - pLayer->release(); + Layer* layer = new BugsTestMainLayer(); + addChild(layer); + layer->release(); Director::getInstance()->replaceScene(this); } diff --git a/samples/Cpp/TestCpp/Classes/ChipmunkTest/ChipmunkTest.cpp b/samples/Cpp/TestCpp/Classes/ChipmunkTest/ChipmunkTest.cpp index 57971a47e5..7c17ad36b2 100644 --- a/samples/Cpp/TestCpp/Classes/ChipmunkTest/ChipmunkTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ChipmunkTest/ChipmunkTest.cpp @@ -58,13 +58,13 @@ ChipmunkTestLayer::ChipmunkTestLayer() scheduleUpdate(); #else - LabelTTF *pLabel = LabelTTF::create("Should define CC_ENABLE_CHIPMUNK_INTEGRATION=1\n to run this test case", + LabelTTF *label = LabelTTF::create("Should define CC_ENABLE_CHIPMUNK_INTEGRATION=1\n to run this test case", "Arial", 18); Size size = Director::getInstance()->getWinSize(); - pLabel->setPosition(Point(size.width/2, size.height/2)); + label->setPosition(Point(size.width/2, size.height/2)); - addChild(pLabel); + addChild(label); #endif @@ -242,9 +242,9 @@ void ChipmunkTestLayer::didAccelerate(Acceleration* pAccelerationValue) void ChipmunkAccelTouchTestScene::runThisTest() { - Layer* pLayer = new ChipmunkTestLayer(); - addChild(pLayer); - pLayer->release(); + Layer* layer = new ChipmunkTestLayer(); + addChild(layer); + layer->release(); Director::getInstance()->replaceScene(this); } diff --git a/samples/Cpp/TestCpp/Classes/ClickAndMoveTest/ClickAndMoveTest.cpp b/samples/Cpp/TestCpp/Classes/ClickAndMoveTest/ClickAndMoveTest.cpp index 3edd8a2e0b..c5121c670b 100644 --- a/samples/Cpp/TestCpp/Classes/ClickAndMoveTest/ClickAndMoveTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ClickAndMoveTest/ClickAndMoveTest.cpp @@ -8,10 +8,10 @@ enum void ClickAndMoveTestScene::runThisTest() { - Layer* pLayer = new MainLayer(); - pLayer->autorelease(); + Layer* layer = new MainLayer(); + layer->autorelease(); - addChild(pLayer); + addChild(layer); Director::getInstance()->replaceScene(this); } @@ -19,7 +19,7 @@ MainLayer::MainLayer() { setTouchEnabled(true); - Sprite* sprite = Sprite::create(s_pPathGrossini); + Sprite* sprite = Sprite::create(s_pathGrossini); Layer* layer = LayerColor::create(Color4B(255,255,0,255)); addChild(layer, -1); diff --git a/samples/Cpp/TestCpp/Classes/ClippingNodeTest/ClippingNodeTest.cpp b/samples/Cpp/TestCpp/Classes/ClippingNodeTest/ClippingNodeTest.cpp index 3726e6530e..211a153627 100644 --- a/samples/Cpp/TestCpp/Classes/ClippingNodeTest/ClippingNodeTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ClippingNodeTest/ClippingNodeTest.cpp @@ -56,11 +56,11 @@ static Layer* nextAction() sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - Layer* pLayer = (createFunctions[sceneIdx])(); - pLayer->init(); - pLayer->autorelease(); + Layer* layer = (createFunctions[sceneIdx])(); + layer->init(); + layer->autorelease(); - return pLayer; + return layer; } static Layer* backAction() @@ -70,20 +70,20 @@ static Layer* backAction() if( sceneIdx < 0 ) sceneIdx += total; - Layer* pLayer = (createFunctions[sceneIdx])(); - pLayer->init(); - pLayer->autorelease(); + Layer* layer = (createFunctions[sceneIdx])(); + layer->init(); + layer->autorelease(); - return pLayer; + return layer; } static Layer* restartAction() { - Layer* pLayer = (createFunctions[sceneIdx])(); - pLayer->init(); - pLayer->autorelease(); + Layer* layer = (createFunctions[sceneIdx])(); + layer->init(); + layer->autorelease(); - return pLayer; + return layer; } //#pragma mark Demo examples start here @@ -208,7 +208,7 @@ DrawNode* BasicTest::shape() Sprite* BasicTest::grossini() { - Sprite *grossini = Sprite::create(s_pPathGrossini); + Sprite *grossini = Sprite::create(s_pathGrossini); grossini->setScale( 1.5 ); return grossini; } @@ -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_pPathGrossini); + Node *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_pPathBlock); + Sprite *target = Sprite::create(s_pathBlock); target->setAnchorPoint(Point::ZERO); target->setScale(3); @@ -598,7 +598,7 @@ void RawStencilBufferTest::setup() if (_stencilBits < 3) { CCLOGWARN("Stencil must be enabled for the current GLView."); } - _sprite = Sprite::create(s_pPathGrossini); + _sprite = Sprite::create(s_pathGrossini); _sprite->retain(); _sprite->setAnchorPoint( Point(0.5, 0) ); _sprite->setScale( 2.5f ); @@ -844,7 +844,7 @@ void RawStencilBufferTest6::setupStencilForDrawingOnPlane(GLint plane) void ClippingNodeTestScene::runThisTest() { - Layer* pLayer = nextAction(); - addChild(pLayer); + Layer* 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 bba950da1b..368560f9ab 100644 --- a/samples/Cpp/TestCpp/Classes/CocosDenshionTest/CocosDenshionTest.cpp +++ b/samples/Cpp/TestCpp/Classes/CocosDenshionTest/CocosDenshionTest.cpp @@ -414,9 +414,9 @@ void CocosDenshionTest::updateVolumes(float) void CocosDenshionTestScene::runThisTest() { - Layer* pLayer = new CocosDenshionTest(); - addChild(pLayer); - pLayer->autorelease(); + Layer* layer = new CocosDenshionTest(); + addChild(layer); + layer->autorelease(); Director::getInstance()->replaceScene(this); } diff --git a/samples/Cpp/TestCpp/Classes/ConfigurationTest/ConfigurationTest.cpp b/samples/Cpp/TestCpp/Classes/ConfigurationTest/ConfigurationTest.cpp index edd84d9579..2767ee1539 100644 --- a/samples/Cpp/TestCpp/Classes/ConfigurationTest/ConfigurationTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ConfigurationTest/ConfigurationTest.cpp @@ -25,11 +25,11 @@ static Layer* nextAction() sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - Layer* pLayer = (createFunctions[sceneIdx])(); - pLayer->init(); - pLayer->autorelease(); + Layer* layer = (createFunctions[sceneIdx])(); + layer->init(); + layer->autorelease(); - return pLayer; + return layer; } static Layer* backAction() @@ -39,20 +39,20 @@ static Layer* backAction() if( sceneIdx < 0 ) sceneIdx += total; - Layer* pLayer = (createFunctions[sceneIdx])(); - pLayer->init(); - pLayer->autorelease(); + Layer* layer = (createFunctions[sceneIdx])(); + layer->init(); + layer->autorelease(); - return pLayer; + return layer; } static Layer* restartAction() { - Layer* pLayer = (createFunctions[sceneIdx])(); - pLayer->init(); - pLayer->autorelease(); + Layer* layer = (createFunctions[sceneIdx])(); + layer->init(); + layer->autorelease(); - return pLayer; + return layer; } void ConfigurationTestScene::runThisTest() diff --git a/samples/Cpp/TestCpp/Classes/CurlTest/CurlTest.cpp b/samples/Cpp/TestCpp/Classes/CurlTest/CurlTest.cpp index ea6c4b09da..985f5061f4 100644 --- a/samples/Cpp/TestCpp/Classes/CurlTest/CurlTest.cpp +++ b/samples/Cpp/TestCpp/Classes/CurlTest/CurlTest.cpp @@ -58,9 +58,9 @@ CurlTest::~CurlTest() void CurlTestScene::runThisTest() { - Layer* pLayer = new CurlTest(); - addChild(pLayer); + Layer* layer = new CurlTest(); + addChild(layer); Director::getInstance()->replaceScene(this); - pLayer->release(); + layer->release(); } diff --git a/samples/Cpp/TestCpp/Classes/CurrentLanguageTest/CurrentLanguageTest.cpp b/samples/Cpp/TestCpp/Classes/CurrentLanguageTest/CurrentLanguageTest.cpp index a32c37a0ba..4fca603e08 100644 --- a/samples/Cpp/TestCpp/Classes/CurrentLanguageTest/CurrentLanguageTest.cpp +++ b/samples/Cpp/TestCpp/Classes/CurrentLanguageTest/CurrentLanguageTest.cpp @@ -61,9 +61,9 @@ CurrentLanguageTest::CurrentLanguageTest() void CurrentLanguageTestScene::runThisTest() { - Layer* pLayer = new CurrentLanguageTest(); - addChild(pLayer); + Layer* layer = new CurrentLanguageTest(); + addChild(layer); Director::getInstance()->replaceScene(this); - pLayer->release(); + layer->release(); } diff --git a/samples/Cpp/TestCpp/Classes/DataVisitorTest/DataVisitorTest.cpp b/samples/Cpp/TestCpp/Classes/DataVisitorTest/DataVisitorTest.cpp index a913156c0f..12eeed1ce7 100644 --- a/samples/Cpp/TestCpp/Classes/DataVisitorTest/DataVisitorTest.cpp +++ b/samples/Cpp/TestCpp/Classes/DataVisitorTest/DataVisitorTest.cpp @@ -55,10 +55,10 @@ void PrettyPrinterDemo::onEnter() PrettyPrinter vistor; // print dictionary - Dictionary* pDict = Dictionary::createWithContentsOfFile("animations/animations.plist"); - pDict->acceptVisitor(vistor); - CCLog("%s", vistor.getResult().c_str()); - CCLog("-------------------------------"); + Dictionary* dict = Dictionary::createWithContentsOfFile("animations/animations.plist"); + dict->acceptVisitor(vistor); + log("%s", vistor.getResult().c_str()); + log("-------------------------------"); Set myset; for (int i = 0; i < 30; ++i) { @@ -66,14 +66,14 @@ void PrettyPrinterDemo::onEnter() } vistor.clear(); myset.acceptVisitor(vistor); - CCLog("%s", vistor.getResult().c_str()); - CCLog("-------------------------------"); + log("%s", vistor.getResult().c_str()); + log("-------------------------------"); vistor.clear(); addSprite(); - pDict = TextureCache::getInstance()->snapshotTextures(); - pDict->acceptVisitor(vistor); - CCLog("%s", vistor.getResult().c_str()); + dict = TextureCache::getInstance()->snapshotTextures(); + dict->acceptVisitor(vistor); + log("%s", vistor.getResult().c_str()); } void DataVisitorTestScene::runThisTest() diff --git a/samples/Cpp/TestCpp/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp b/samples/Cpp/TestCpp/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp index 4dfe2f0fb6..db3b1f9d91 100644 --- a/samples/Cpp/TestCpp/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp +++ b/samples/Cpp/TestCpp/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp @@ -30,10 +30,10 @@ static Layer* nextAction() sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - Layer* pLayer = (createFunctions[sceneIdx])(); - pLayer->autorelease(); + Layer* layer = (createFunctions[sceneIdx])(); + layer->autorelease(); - return pLayer; + return layer; } static Layer* backAction() @@ -43,18 +43,18 @@ static Layer* backAction() if( sceneIdx < 0 ) sceneIdx += total; - Layer* pLayer = (createFunctions[sceneIdx])(); - pLayer->autorelease(); + Layer* layer = (createFunctions[sceneIdx])(); + layer->autorelease(); - return pLayer; + return layer; } static Layer* restartAction() { - Layer* pLayer = (createFunctions[sceneIdx])(); - pLayer->autorelease(); + Layer* layer = (createFunctions[sceneIdx])(); + layer->autorelease(); - return pLayer; + return layer; } // BaseLayer @@ -300,8 +300,8 @@ string DrawNodeTest::subtitle() void DrawPrimitivesTestScene::runThisTest() { - Layer* pLayer = nextAction(); - addChild(pLayer); + Layer* 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 ae70564183..99f8b79691 100644 --- a/samples/Cpp/TestCpp/Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp +++ b/samples/Cpp/TestCpp/Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp @@ -303,10 +303,10 @@ Layer* nextEffectAdvanceAction() sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - Layer* pLayer = createEffectAdvanceLayer(sceneIdx); - pLayer->autorelease(); + Layer* layer = createEffectAdvanceLayer(sceneIdx); + layer->autorelease(); - return pLayer; + return layer; } Layer* backEffectAdvanceAction() @@ -316,18 +316,18 @@ Layer* backEffectAdvanceAction() if( sceneIdx < 0 ) sceneIdx += total; - Layer* pLayer = createEffectAdvanceLayer(sceneIdx); - pLayer->autorelease(); + Layer* layer = createEffectAdvanceLayer(sceneIdx); + layer->autorelease(); - return pLayer; + return layer; } Layer* restartEffectAdvanceAction() { - Layer* pLayer = createEffectAdvanceLayer(sceneIdx); - pLayer->autorelease(); + Layer* layer = createEffectAdvanceLayer(sceneIdx); + layer->autorelease(); - return pLayer; + return layer; } @@ -396,8 +396,8 @@ void EffectAdvanceTextLayer::backCallback(Object* pSender) void EffectAdvanceScene::runThisTest() { - Layer* pLayer = nextEffectAdvanceAction(); + Layer* layer = nextEffectAdvanceAction(); - addChild(pLayer); + 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 df0c09863c..b26620e1a8 100644 --- a/samples/Cpp/TestCpp/Classes/EffectsTest/EffectsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/EffectsTest/EffectsTest.cpp @@ -352,14 +352,14 @@ TextLayer::TextLayer(void) // bg->setAnchorPoint( Point::ZERO ); bg->setPosition(VisibleRect::center()); - Sprite* grossini = Sprite::create(s_pPathSister2); + Sprite* 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(); grossini->runAction( RepeatForever::create(Sequence::create(sc, sc_back, NULL) ) ); - Sprite* tamara = Sprite::create(s_pPathSister1); + Sprite* 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); @@ -388,10 +388,10 @@ TextLayer::~TextLayer(void) TextLayer* TextLayer::create() { - TextLayer* pLayer = new TextLayer(); - pLayer->autorelease(); + TextLayer* layer = new TextLayer(); + layer->autorelease(); - return pLayer; + return layer; } void TextLayer::onEnter() diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ArmatureTest/ArmatureScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ArmatureTest/ArmatureScene.cpp index 915edf88f2..6d722b6ce8 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ArmatureTest/ArmatureScene.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ArmatureTest/ArmatureScene.cpp @@ -13,38 +13,38 @@ static int s_nActionIdx = -1; Layer *CreateLayer(int index) { - Layer *pLayer = NULL; + Layer *layer = NULL; switch(index) { case TEST_DRAGON_BONES_2_0: - pLayer = new TestDragonBones20(); break; + layer = new TestDragonBones20(); break; case TEST_COCOSTUDIO_WITH_SKELETON: - pLayer = new TestCSWithSkeleton(); break; + layer = new TestCSWithSkeleton(); break; case TEST_COCOSTUDIO_WITHOUT_SKELETON: - pLayer = new TestCSWithoutSkeleton(); break; + layer = new TestCSWithoutSkeleton(); break; case TEST_PERFORMANCE: - pLayer = new TestPerformance(); break; + layer = new TestPerformance(); break; case TEST_CHANGE_ZORDER: - pLayer = new TestChangeZorder(); break; + layer = new TestChangeZorder(); break; case TEST_ANIMATION_EVENT: - pLayer = new TestAnimationEvent(); break; + layer = new TestAnimationEvent(); break; case TEST_PARTICLE_DISPLAY: - pLayer = new TestParticleDisplay(); break; + layer = new TestParticleDisplay(); break; case TEST_USE_DIFFERENT_PICTURE: - pLayer = new TestUseMutiplePicture(); break; + layer = new TestUseMutiplePicture(); break; case TEST_BOX2D_DETECTOR: - pLayer = new TestBox2DDetector(); break; + layer = new TestBox2DDetector(); break; case TEST_BOUDINGBOX: - pLayer = new TestBoundingBox(); break; + layer = new TestBoundingBox(); break; case TEST_ANCHORPOINT: - pLayer = new TestAnchorPoint(); break; + layer = new TestAnchorPoint(); break; case TEST_ARMATURE_NESTING: - pLayer = new TestArmatureNesting(); break; + layer = new TestArmatureNesting(); break; default: break; } - return pLayer; + return layer; } @@ -53,10 +53,10 @@ Layer* NextTest() ++s_nActionIdx; s_nActionIdx = s_nActionIdx % TEST_LAYER_COUNT; - Layer* pLayer = CreateLayer(s_nActionIdx); - pLayer->autorelease(); + Layer* layer = CreateLayer(s_nActionIdx); + layer->autorelease(); - return pLayer; + return layer; } Layer* BackTest() @@ -65,18 +65,18 @@ Layer* BackTest() if( s_nActionIdx < 0 ) s_nActionIdx += TEST_LAYER_COUNT; - Layer* pLayer = CreateLayer(s_nActionIdx); - pLayer->autorelease(); + Layer* layer = CreateLayer(s_nActionIdx); + layer->autorelease(); - return pLayer; + return layer; } Layer* RestartTest() { - Layer* pLayer = CreateLayer(s_nActionIdx); - pLayer->autorelease(); + Layer* layer = CreateLayer(s_nActionIdx); + layer->autorelease(); - return pLayer; + return layer; } @@ -141,9 +141,9 @@ void ArmatureTestLayer::onEnter() } // add menu - MenuItemImage *item1 = MenuItemImage::create(s_pPathB1, s_pPathB2, CC_CALLBACK_1(ArmatureTestLayer::backCallback,this)); - MenuItemImage *item2 = MenuItemImage::create(s_pPathR1, s_pPathR2, CC_CALLBACK_1(ArmatureTestLayer::restartCallback, this)); - MenuItemImage *item3 = MenuItemImage::create(s_pPathF1, s_pPathF2, CC_CALLBACK_1(ArmatureTestLayer::nextCallback, this)); + MenuItemImage *item1 = MenuItemImage::create(s_pathB1, s_pathB2, CC_CALLBACK_1(ArmatureTestLayer::backCallback,this)); + MenuItemImage *item2 = MenuItemImage::create(s_pathR1, s_pathR2, CC_CALLBACK_1(ArmatureTestLayer::restartCallback, this)); + MenuItemImage *item3 = MenuItemImage::create(s_pathF1, s_pathF2, CC_CALLBACK_1(ArmatureTestLayer::nextCallback, this)); Menu *menu = Menu::create(item1, item2, item3, NULL); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.h index 288a397bfa..b92d1192fb 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.h @@ -17,7 +17,7 @@ public: virtual cocos2d::SEL_MenuHandler onResolveCCBMenuItemSelector(Object * pTarget, const char * pSelectorName); virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBControlSelector(cocos2d::Object * pTarget, const char * pSelectorName); - virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * pNode); + virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * node); void onControlButtonIdleClicked(cocos2d::Object * pSender, cocos2d::extension::ControlEvent pControlEvent); void onControlButtonWaveClicked(cocos2d::Object * pSender, cocos2d::extension::ControlEvent pControlEvent); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.h index c07d1842ad..a8d9c06c86 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.h @@ -17,7 +17,7 @@ public: virtual cocos2d::SEL_MenuHandler onResolveCCBMenuItemSelector(cocos2d::Object * pTarget, const char * pSelectorName); virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBControlSelector(cocos2d::Object * pTarget, const char * pSelectorName); - virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * pNode); + virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * node); void onControlButtonClicked(cocos2d::Object * pSender, cocos2d::extension::ControlEvent pControlEvent); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp index 7ac1ecc6fb..1458d1b5d2 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp @@ -24,13 +24,13 @@ HelloCocosBuilderLayer::~HelloCocosBuilderLayer() CC_SAFE_RELEASE(mTestTitleLabelTTF); } -void HelloCocosBuilderLayer::openTest(const char * pCCBFileName, const char * pNodeName, NodeLoader * pNodeLoader) { +void HelloCocosBuilderLayer::openTest(const char * pCCBFileName, const char * nodeName, NodeLoader * nodeLoader) { /* Create an autorelease NodeLoaderLibrary. */ NodeLoaderLibrary * ccNodeLoaderLibrary = NodeLoaderLibrary::newDefaultNodeLoaderLibrary(); ccNodeLoaderLibrary->registerNodeLoader("TestHeaderLayer", TestHeaderLayerLoader::loader()); - if(pNodeName != NULL && pNodeLoader != NULL) { - ccNodeLoaderLibrary->registerNodeLoader(pNodeName, pNodeLoader); + if(nodeName != NULL && nodeLoader != NULL) { + ccNodeLoaderLibrary->registerNodeLoader(nodeName, nodeLoader); } /* Create an autorelease CCBReader. */ @@ -61,7 +61,7 @@ void HelloCocosBuilderLayer::openTest(const char * pCCBFileName, const char * pN } -void HelloCocosBuilderLayer::onNodeLoaded(cocos2d::Node * pNode, cocos2d::extension::NodeLoader * pNodeLoader) { +void HelloCocosBuilderLayer::onNodeLoaded(cocos2d::Node * node, cocos2d::extension::NodeLoader * nodeLoader) { RotateBy * ccRotateBy = RotateBy::create(20.0f, 360); RepeatForever * ccRepeatForever = RepeatForever::create(ccRotateBy); this->mBurstSprite->runAction(ccRepeatForever); @@ -99,25 +99,25 @@ bool HelloCocosBuilderLayer::onAssignCCBCustomProperty(Object* pTarget, const ch if (0 == strcmp(pMemberVariableName, "mCustomPropertyInt")) { this->mCustomPropertyInt = pCCBValue->getIntValue(); - CCLog("mCustomPropertyInt = %d", mCustomPropertyInt); + log("mCustomPropertyInt = %d", mCustomPropertyInt); bRet = true; } else if ( 0 == strcmp(pMemberVariableName, "mCustomPropertyFloat")) { this->mCustomPropertyFloat = pCCBValue->getFloatValue(); - CCLog("mCustomPropertyFloat = %f", mCustomPropertyFloat); + log("mCustomPropertyFloat = %f", mCustomPropertyFloat); bRet = true; } else if ( 0 == strcmp(pMemberVariableName, "mCustomPropertyBoolean")) { this->mCustomPropertyBoolean = pCCBValue->getBoolValue(); - CCLog("mCustomPropertyBoolean = %d", mCustomPropertyBoolean); + log("mCustomPropertyBoolean = %d", mCustomPropertyBoolean); bRet = true; } else if ( 0 == strcmp(pMemberVariableName, "mCustomPropertyString")) { this->mCustomPropertyString = pCCBValue->getStringValue(); - CCLog("mCustomPropertyString = %s", mCustomPropertyString.c_str()); + log("mCustomPropertyString = %s", mCustomPropertyString.c_str()); bRet = true; } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h index f4ff30fd57..267a9adad8 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h @@ -26,13 +26,13 @@ class HelloCocosBuilderLayer HelloCocosBuilderLayer(); virtual ~HelloCocosBuilderLayer(); - void openTest(const char * pCCBFileName, const char * pNodeName = NULL, cocos2d::extension::NodeLoader * pNodeLoader = NULL); + void openTest(const char * pCCBFileName, const char * nodeName = NULL, cocos2d::extension::NodeLoader * nodeLoader = NULL); virtual cocos2d::SEL_MenuHandler onResolveCCBMenuItemSelector(cocos2d::Object * pTarget, const char * pSelectorName); virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBControlSelector(cocos2d::Object * pTarget, const char * pSelectorName); - virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * pNode); + virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * node); virtual bool onAssignCCBCustomProperty(Object* pTarget, const char* pMemberVariableName, cocos2d::extension::CCBValue* pCCBValue); - virtual void onNodeLoaded(cocos2d::Node * pNode, cocos2d::extension::NodeLoader * pNodeLoader); + virtual void onNodeLoaded(cocos2d::Node * node, cocos2d::extension::NodeLoader * nodeLoader); void onMenuTestClicked(cocos2d::Object * pSender, cocos2d::extension::ControlEvent pControlEvent); void onSpriteTestClicked(cocos2d::Object * pSender, cocos2d::extension::ControlEvent pControlEvent); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.h index faa092ba3a..95f3994f59 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.h @@ -17,7 +17,7 @@ class MenuTestLayer virtual cocos2d::SEL_MenuHandler onResolveCCBMenuItemSelector(cocos2d::Object * pTarget, const char * pSelectorName); virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBControlSelector(cocos2d::Object * pTarget, const char * pSelectorName); - virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * pNode); + virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * node); void onMenuItemAClicked(cocos2d::Object * pSender); void onMenuItemBClicked(cocos2d::Object * pSender); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.cpp index e2669e5517..7de128ab96 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.cpp @@ -14,7 +14,7 @@ SEL_CCControlHandler TestHeaderLayer::onResolveCCBControlSelector(Object * pTarg return NULL; } -void TestHeaderLayer::onNodeLoaded(cocos2d::Node * pNode, cocos2d::extension::NodeLoader * pNodeLoader) +void TestHeaderLayer::onNodeLoaded(cocos2d::Node * node, cocos2d::extension::NodeLoader * nodeLoader) { CCLOG("TestHeaderLayer::onNodeLoaded"); } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.h index f6a1e00412..40a020bc6e 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.h @@ -14,7 +14,7 @@ class TestHeaderLayer virtual cocos2d::SEL_MenuHandler onResolveCCBMenuItemSelector(cocos2d::Object * pTarget, const char * pSelectorName); virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBControlSelector(cocos2d::Object * pTarget, const char * pSelectorName); - virtual void onNodeLoaded(cocos2d::Node * pNode, cocos2d::extension::NodeLoader * pNodeLoader); + virtual void onNodeLoaded(cocos2d::Node * node, cocos2d::extension::NodeLoader * nodeLoader); void onBackClicked(cocos2d::Object * pSender); }; diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.h index 8a1cabfd1e..d9b045fb16 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.h @@ -18,7 +18,7 @@ class TimelineCallbackTestLayer virtual cocos2d::SEL_MenuHandler onResolveCCBMenuItemSelector(cocos2d::Object * pTarget, const char * pSelectorName); virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBControlSelector(cocos2d::Object * pTarget, const char * pSelectorName); virtual cocos2d::SEL_CallFuncN onResolveCCBCallFuncSelector(Object * pTarget, const char* pSelectorName); - virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * pNode); + virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * node); void onCallback1(Node* sender); void onCallback2(Node* sender); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/ComponentsTestScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/ComponentsTestScene.cpp index 8d32262357..1c9c71bd81 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/ComponentsTestScene.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/ComponentsTestScene.cpp @@ -81,9 +81,9 @@ cocos2d::Node* ComponentsTestLayer::createGameScene() MenuItemFont *itemBack = MenuItemFont::create("Back", [](Object* sender){ - ExtensionsTestScene *pScene = new ExtensionsTestScene(); - pScene->runThisTest(); - pScene->release(); + ExtensionsTestScene *scene = new ExtensionsTestScene(); + scene->runThisTest(); + scene->release(); }); itemBack->setColor(Color3B(0, 0, 0)); @@ -99,6 +99,6 @@ cocos2d::Node* ComponentsTestLayer::createGameScene() void runComponentsTestLayerTest() { - Scene *pScene = ComponentsTestLayer::scene(); - Director::getInstance()->replaceScene(pScene); + Scene *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 8b3ba010ff..2c62142516 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/EnemyController.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/EnemyController.cpp @@ -35,17 +35,18 @@ void EnemyController::onEnter() // Determine speed of the target - int minDuration = (int)2.0; - int maxDuration = (int)4.0; + int minDuration = 2; + int maxDuration = 4; int rangeDuration = maxDuration - minDuration; // srand( TimGetTicks() ); int actualDuration = ( rand() % rangeDuration ) + minDuration; // Create the actions - FiniteTimeAction* actionMove = MoveTo::create( (float)actualDuration, + FiniteTimeAction* actionMove = MoveTo::create( actualDuration, Point(0 - getOwner()->getContentSize().width/2, actualY) ); - FiniteTimeAction* actionMoveDone = CallFuncN::create(getOwner()->getParent()->getComponent("SceneController"), - callfuncN_selector(SceneController::spriteMoveFinished)); + FiniteTimeAction* actionMoveDone = CallFuncN::create( + CC_CALLBACK_1(SceneController::spriteMoveFinished, static_cast( getOwner()->getParent()->getComponent("SceneController") ))); + _owner->runAction( Sequence::create(actionMove, actionMoveDone, NULL) ); } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/GameOverScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/GameOverScene.cpp index f450ae3a19..9d5f482bc1 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/GameOverScene.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/GameOverScene.cpp @@ -73,9 +73,9 @@ bool GameOverLayer::init() MenuItemFont *itemBack = MenuItemFont::create("Back", [](Object* sender){ - ExtensionsTestScene *pScene = new ExtensionsTestScene(); - pScene->runThisTest(); - pScene->release(); + ExtensionsTestScene *scene = new ExtensionsTestScene(); + scene->runThisTest(); + scene->release(); }); itemBack->setColor(Color3B(0, 0, 0)); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/ProjectileController.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/ProjectileController.cpp index 3a3995f430..61fe94b312 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/ProjectileController.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/ProjectileController.cpp @@ -93,6 +93,10 @@ ProjectileController* ProjectileController::create(void) return pRet; } +void freeFunction( Node *ignore ) +{ + log("hello"); +} void ProjectileController::move(float flocationX, float flocationY) { @@ -121,19 +125,25 @@ void ProjectileController::move(float flocationX, float flocationY) float velocity = 480/1; // 480pixels/1sec float realMoveDuration = length/velocity; - // Move projectile to actual endpoint - _owner->runAction( Sequence::create( - MoveTo::create(realMoveDuration, realDest), - CallFuncN::create(getOwner()->getParent()->getComponent("SceneController"), - callfuncN_selector(SceneController::spriteMoveFinished)), - NULL) ); + auto callfunc = CallFuncN::create( + CC_CALLBACK_1( + SceneController::spriteMoveFinished, + static_cast( getOwner()->getParent()->getComponent("SceneController") + ) ) ); + // Move projectile to actual endpoint + _owner->runAction( + Sequence::create( + MoveTo::create(realMoveDuration, realDest), + callfunc, + NULL) + ); } void ProjectileController::die() { Component *com = _owner->getParent()->getComponent("SceneController"); - cocos2d::Array *_projectiles = ((SceneController*)com)->getProjectiles(); + cocos2d::Array *_projectiles = static_cast(com)->getProjectiles(); _projectiles->removeObject(_owner); _owner->removeFromParentAndCleanup(true); } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlScene.cpp index 0a7f74a57e..d69c754be6 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlScene.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlScene.cpp @@ -84,9 +84,9 @@ bool ControlScene::init() void ControlScene::toExtensionsMainLayer(Object* sender) { - ExtensionsTestScene* pScene = new ExtensionsTestScene(); - pScene->runThisTest(); - pScene->release(); + ExtensionsTestScene* scene = new ExtensionsTestScene(); + scene->runThisTest(); + scene->release(); } void ControlScene::previousCallback(Object* sender) diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlScene.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlScene.h index 5bda817846..0d90639cfa 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlScene.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlScene.h @@ -37,19 +37,19 @@ USING_NS_CC_EXT; public: \ static Scene* sceneWithTitle(const char * title) \ { \ - Scene* pScene = Scene::create(); \ + Scene* scene = Scene::create(); \ controlScene* controlLayer = new controlScene(); \ if (controlLayer && controlLayer->init()) \ { \ controlLayer->autorelease(); \ controlLayer->getSceneTitleLabel()->setString(title); \ - pScene->addChild(controlLayer); \ + scene->addChild(controlLayer); \ } \ else \ { \ CC_SAFE_DELETE(controlLayer); \ } \ - return pScene; \ + return scene; \ } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/EditBoxTest/EditBoxTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/EditBoxTest/EditBoxTest.cpp index cf5d47da6a..51168f33bd 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/EditBoxTest/EditBoxTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/EditBoxTest/EditBoxTest.cpp @@ -87,29 +87,29 @@ EditBoxTest::~EditBoxTest() void EditBoxTest::toExtensionsMainLayer(cocos2d::Object *sender) { - ExtensionsTestScene *pScene = new ExtensionsTestScene(); - pScene->runThisTest(); - pScene->release(); + ExtensionsTestScene *scene = new ExtensionsTestScene(); + scene->runThisTest(); + scene->release(); } void EditBoxTest::editBoxEditingDidBegin(cocos2d::extension::EditBox* editBox) { - CCLog("editBox %p DidBegin !", editBox); + log("editBox %p DidBegin !", editBox); } void EditBoxTest::editBoxEditingDidEnd(cocos2d::extension::EditBox* editBox) { - CCLog("editBox %p DidEnd !", editBox); + log("editBox %p DidEnd !", editBox); } void EditBoxTest::editBoxTextChanged(cocos2d::extension::EditBox* editBox, const std::string& text) { - CCLog("editBox %p TextChanged, text: %s ", editBox, text.c_str()); + log("editBox %p TextChanged, text: %s ", editBox, text.c_str()); } void EditBoxTest::editBoxReturn(EditBox* editBox) { - CCLog("editBox %p was returned !",editBox); + log("editBox %p was returned !",editBox); if (_editName == editBox) { @@ -127,10 +127,10 @@ void EditBoxTest::editBoxReturn(EditBox* editBox) void runEditBoxTest() { - Scene *pScene = Scene::create(); - EditBoxTest *pLayer = new EditBoxTest(); - pScene->addChild(pLayer); + Scene *scene = Scene::create(); + EditBoxTest *layer = new EditBoxTest(); + scene->addChild(layer); - Director::getInstance()->replaceScene(pScene); - pLayer->release(); + Director::getInstance()->replaceScene(scene); + layer->release(); } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ExtensionsTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ExtensionsTest.cpp index 31e8aa31ee..ba96f3d391 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ExtensionsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ExtensionsTest.cpp @@ -34,25 +34,25 @@ static struct { { "NotificationCenterTest", [](Object* sender) { runNotificationCenterTest(); } }, { "Scale9SpriteTest", [](Object* sender) { - S9SpriteTestScene* pScene = new S9SpriteTestScene(); - if (pScene) + S9SpriteTestScene* scene = new S9SpriteTestScene(); + if (scene) { - pScene->runThisTest(); - pScene->release(); + scene->runThisTest(); + scene->release(); } } }, { "CCControlButtonTest", [](Object *sender){ ControlSceneManager* pManager = ControlSceneManager::sharedControlSceneManager(); - Scene* pScene = pManager->currentControlScene(); - Director::getInstance()->replaceScene(pScene); + Scene* scene = pManager->currentControlScene(); + Director::getInstance()->replaceScene(scene); }}, { "CocosBuilderTest", [](Object *sender) { - TestScene* pScene = new CocosBuilderTestScene(); - if (pScene) + TestScene* scene = new CocosBuilderTestScene(); + if (scene) { - pScene->runThisTest(); - pScene->release(); + scene->runThisTest(); + scene->release(); } }}, #if (CC_TARGET_PLATFORM != CC_PLATFORM_EMSCRIPTEN) && (CC_TARGET_PLATFORM != CC_PLATFORM_NACL) @@ -73,9 +73,9 @@ static struct { }, { "CommponentTest", [](Object *sender) { runComponentsTestLayerTest(); } }, - { "ArmatureTest", [](Object *sender) { ArmatureTestScene *pScene = new ArmatureTestScene(); - pScene->runThisTest(); - pScene->release(); + { "ArmatureTest", [](Object *sender) { ArmatureTestScene *scene = new ArmatureTestScene(); + scene->runThisTest(); + scene->release(); } }, }; @@ -153,9 +153,9 @@ void ExtensionsMainLayer::ccTouchesMoved(Set *pTouches, Event *pEvent) void ExtensionsTestScene::runThisTest() { - Layer* pLayer = new ExtensionsMainLayer(); - addChild(pLayer); - pLayer->release(); + Layer* layer = new ExtensionsMainLayer(); + addChild(layer); + layer->release(); Director::getInstance()->replaceScene(this); } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp index ad1e1b1b77..771948a5d3 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp @@ -255,19 +255,19 @@ void HttpClientTest::onHttpRequestCompleted(HttpClient *sender, HttpResponse *re // You can get original request type from: response->request->reqType if (0 != strlen(response->getHttpRequest()->getTag())) { - CCLog("%s completed", response->getHttpRequest()->getTag()); + log("%s completed", response->getHttpRequest()->getTag()); } int statusCode = response->getResponseCode(); char statusString[64] = {}; sprintf(statusString, "HTTP Status Code: %d, tag = %s", statusCode, response->getHttpRequest()->getTag()); _labelStatusCode->setString(statusString); - CCLog("response code: %d", statusCode); + log("response code: %d", statusCode); if (!response->isSucceed()) { - CCLog("response failed"); - CCLog("error buffer: %s", response->getErrorBuffer()); + log("response failed"); + log("error buffer: %s", response->getErrorBuffer()); return; } @@ -283,17 +283,17 @@ void HttpClientTest::onHttpRequestCompleted(HttpClient *sender, HttpResponse *re void HttpClientTest::toExtensionsMainLayer(cocos2d::Object *sender) { - ExtensionsTestScene *pScene = new ExtensionsTestScene(); - pScene->runThisTest(); - pScene->release(); + ExtensionsTestScene *scene = new ExtensionsTestScene(); + scene->runThisTest(); + scene->release(); } void runHttpClientTest() { - Scene *pScene = Scene::create(); - HttpClientTest *pLayer = new HttpClientTest(); - pScene->addChild(pLayer); + Scene *scene = Scene::create(); + HttpClientTest *layer = new HttpClientTest(); + scene->addChild(layer); - Director::getInstance()->replaceScene(pScene); - pLayer->release(); + Director::getInstance()->replaceScene(scene); + layer->release(); } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/SocketIOTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/SocketIOTest.cpp index 784c94ead7..cb118e8595 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/SocketIOTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/SocketIOTest.cpp @@ -103,7 +103,7 @@ SocketIOTestLayer::~SocketIOTestLayer(void) //test event callback handlers, these will be registered with socket.io void SocketIOTestLayer::testevent(SIOClient *client, const std::string& data) { - CCLog("SocketIOTestLayer::testevent called with data: %s", data.c_str()); + log("SocketIOTestLayer::testevent called with data: %s", data.c_str()); std::stringstream s; s << client->getTag() << " received event testevent with data: " << data.c_str(); @@ -114,7 +114,7 @@ void SocketIOTestLayer::testevent(SIOClient *client, const std::string& data) { void SocketIOTestLayer::echotest(SIOClient *client, const std::string& data) { - CCLog("SocketIOTestLayer::echotest called with data: %s", data.c_str()); + log("SocketIOTestLayer::echotest called with data: %s", data.c_str()); std::stringstream s; s << client->getTag() << " received event echotest with data: " << data.c_str(); @@ -125,9 +125,9 @@ void SocketIOTestLayer::echotest(SIOClient *client, const std::string& data) { void SocketIOTestLayer::toExtensionsMainLayer(cocos2d::Object *sender) { - ExtensionsTestScene *pScene = new ExtensionsTestScene(); - pScene->runThisTest(); - pScene->release(); + ExtensionsTestScene *scene = new ExtensionsTestScene(); + scene->runThisTest(); + scene->release(); if(_sioEndpoint) _sioEndpoint->disconnect(); if(_sioClient) _sioClient->disconnect(); @@ -208,7 +208,7 @@ void SocketIOTestLayer::onMenuTestEndpointDisconnectClicked(cocos2d::Object *sen void SocketIOTestLayer::onConnect(cocos2d::extension::SIOClient* client) { - CCLog("SocketIOTestLayer::onConnect called"); + log("SocketIOTestLayer::onConnect called"); std::stringstream s; s << client->getTag() << " connected!"; @@ -218,7 +218,7 @@ void SocketIOTestLayer::onConnect(cocos2d::extension::SIOClient* client) void SocketIOTestLayer::onMessage(cocos2d::extension::SIOClient* client, const std::string& data) { - CCLog("SocketIOTestLayer::onMessage received: %s", data.c_str()); + log("SocketIOTestLayer::onMessage received: %s", data.c_str()); std::stringstream s; s << client->getTag() << " received message with content: " << data.c_str(); @@ -228,7 +228,7 @@ void SocketIOTestLayer::onMessage(cocos2d::extension::SIOClient* client, const s void SocketIOTestLayer::onClose(cocos2d::extension::SIOClient* client) { - CCLog("SocketIOTestLayer::onClose called"); + log("SocketIOTestLayer::onClose called"); std::stringstream s; s << client->getTag() << " closed!"; @@ -248,7 +248,7 @@ void SocketIOTestLayer::onClose(cocos2d::extension::SIOClient* client) void SocketIOTestLayer::onError(cocos2d::extension::SIOClient* client, const std::string& data) { - CCLog("SocketIOTestLayer::onError received: %s", data.c_str()); + log("SocketIOTestLayer::onError received: %s", data.c_str()); std::stringstream s; s << client->getTag() << " received error with content: " << data.c_str(); @@ -259,10 +259,10 @@ void SocketIOTestLayer::onError(cocos2d::extension::SIOClient* client, const std void runSocketIOTest() { - Scene *pScene = Scene::create(); - SocketIOTestLayer *pLayer = new SocketIOTestLayer(); - pScene->addChild(pLayer); + Scene *scene = Scene::create(); + SocketIOTestLayer *layer = new SocketIOTestLayer(); + scene->addChild(layer); - Director::getInstance()->replaceScene(pScene); - pLayer->release(); + Director::getInstance()->replaceScene(scene); + layer->release(); } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/WebSocketTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/WebSocketTest.cpp index 0d3b4e770a..d25c594d67 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/WebSocketTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/WebSocketTest.cpp @@ -109,7 +109,7 @@ WebSocketTestLayer::~WebSocketTestLayer() // Delegate methods void WebSocketTestLayer::onOpen(cocos2d::extension::WebSocket* ws) { - CCLog("Websocket (%p) opened", ws); + log("Websocket (%p) opened", ws); if (ws == _wsiSendText) { _sendTextStatus->setString("Send Text WS was opened."); @@ -132,7 +132,7 @@ void WebSocketTestLayer::onMessage(cocos2d::extension::WebSocket* ws, const coco char times[100] = {0}; sprintf(times, "%d", _sendTextTimes); std::string textStr = std::string("response text msg: ")+data.bytes+", "+times; - CCLog("%s", textStr.c_str()); + log("%s", textStr.c_str()); _sendTextStatus->setString(textStr.c_str()); } @@ -156,14 +156,14 @@ void WebSocketTestLayer::onMessage(cocos2d::extension::WebSocket* ws, const coco } binaryStr += std::string(", ")+times; - CCLog("%s", binaryStr.c_str()); + log("%s", binaryStr.c_str()); _sendBinaryStatus->setString(binaryStr.c_str()); } } void WebSocketTestLayer::onClose(cocos2d::extension::WebSocket* ws) { - CCLog("websocket instance (%p) closed.", ws); + log("websocket instance (%p) closed.", ws); if (ws == _wsiSendText) { _wsiSendText = NULL; @@ -182,7 +182,7 @@ void WebSocketTestLayer::onClose(cocos2d::extension::WebSocket* ws) void WebSocketTestLayer::onError(cocos2d::extension::WebSocket* ws, const cocos2d::extension::WebSocket::ErrorCode& error) { - CCLog("Error was fired, error code: %d", error); + log("Error was fired, error code: %d", error); if (ws == _wsiError) { char buf[100] = {0}; @@ -193,9 +193,9 @@ void WebSocketTestLayer::onError(cocos2d::extension::WebSocket* ws, const cocos2 void WebSocketTestLayer::toExtensionsMainLayer(cocos2d::Object *sender) { - ExtensionsTestScene *pScene = new ExtensionsTestScene(); - pScene->runThisTest(); - pScene->release(); + ExtensionsTestScene *scene = new ExtensionsTestScene(); + scene->runThisTest(); + scene->release(); } // Menu Callbacks @@ -209,7 +209,7 @@ void WebSocketTestLayer::onMenuSendTextClicked(cocos2d::Object *sender) else { std::string warningStr = "send text websocket instance wasn't ready..."; - CCLog("%s", warningStr.c_str()); + log("%s", warningStr.c_str()); _sendTextStatus->setString(warningStr.c_str()); } } @@ -225,17 +225,17 @@ void WebSocketTestLayer::onMenuSendBinaryClicked(cocos2d::Object *sender) else { std::string warningStr = "send binary websocket instance wasn't ready..."; - CCLog("%s", warningStr.c_str()); + log("%s", warningStr.c_str()); _sendBinaryStatus->setString(warningStr.c_str()); } } void runWebSocketTest() { - Scene *pScene = Scene::create(); - WebSocketTestLayer *pLayer = new WebSocketTestLayer(); - pScene->addChild(pLayer); + Scene *scene = Scene::create(); + WebSocketTestLayer *layer = new WebSocketTestLayer(); + scene->addChild(layer); - Director::getInstance()->replaceScene(pScene); - pLayer->release(); + Director::getInstance()->replaceScene(scene); + layer->release(); } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.cpp index c13cb291a1..fbeea9af12 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.cpp @@ -140,9 +140,9 @@ void NotificationCenterTest::toExtensionsMainLayer(cocos2d::Object* sender) int CC_UNUSED numObserversRemoved = NotificationCenter::getInstance()->removeAllObservers(this); CCASSERT(numObserversRemoved >= 3, "All observers were not removed!"); - ExtensionsTestScene* pScene = new ExtensionsTestScene(); - pScene->runThisTest(); - pScene->release(); + ExtensionsTestScene* scene = new ExtensionsTestScene(); + scene->runThisTest(); + scene->release(); } void NotificationCenterTest::toggleSwitch(Object *sender) @@ -167,9 +167,9 @@ void NotificationCenterTest::doNothing(cocos2d::Object *sender) void runNotificationCenterTest() { - Scene* pScene = Scene::create(); - NotificationCenterTest* pLayer = new NotificationCenterTest(); - pScene->addChild(pLayer); - Director::getInstance()->replaceScene(pScene); - pLayer->release(); + Scene* scene = Scene::create(); + NotificationCenterTest* layer = new NotificationCenterTest(); + scene->addChild(layer); + Director::getInstance()->replaceScene(scene); + layer->release(); } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp index 95b018a041..d01a167d96 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp @@ -57,11 +57,11 @@ static Layer* nextAction() sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - Layer* pLayer = (createFunctions[sceneIdx])(); - pLayer->init(); - pLayer->autorelease(); + Layer* layer = (createFunctions[sceneIdx])(); + layer->init(); + layer->autorelease(); - return pLayer; + return layer; } static Layer* backAction() @@ -71,20 +71,20 @@ static Layer* backAction() if( sceneIdx < 0 ) sceneIdx += total; - Layer* pLayer = (createFunctions[sceneIdx])(); - pLayer->init(); - pLayer->autorelease(); + Layer* layer = (createFunctions[sceneIdx])(); + layer->init(); + layer->autorelease(); - return pLayer; + return layer; } static Layer* restartAction() { - Layer* pLayer = (createFunctions[sceneIdx])(); - pLayer->init(); - pLayer->autorelease(); + Layer* layer = (createFunctions[sceneIdx])(); + layer->init(); + layer->autorelease(); - return pLayer; + return layer; } void S9SpriteTestScene::runThisTest() @@ -142,24 +142,24 @@ void S9BatchNodeBasic::onEnter() float x = winSize.width / 2; float y = 0 + (winSize.height / 2); - CCLog("S9BatchNodeBasic ..."); + log("S9BatchNodeBasic ..."); auto batchNode = SpriteBatchNode::create("Images/blocks9.png"); - CCLog("batchNode created with : Images/blocks9.png"); + log("batchNode created with : Images/blocks9.png"); auto blocks = Scale9Sprite::create(); - CCLog("... created"); + log("... created"); blocks->updateWithBatchNode(batchNode, Rect(0, 0, 96, 96), false, Rect(0, 0, 96, 96)); - CCLog("... updateWithBatchNode"); + log("... updateWithBatchNode"); blocks->setPosition(Point(x, y)); - CCLog("... setPosition"); + log("... setPosition"); this->addChild(blocks); - CCLog("this->addChild"); + log("this->addChild"); - CCLog("... S9BatchNodeBasic done."); + log("... S9BatchNodeBasic done."); } std::string S9BatchNodeBasic::title() @@ -182,18 +182,18 @@ void S9FrameNameSpriteSheet::onEnter() float x = winSize.width / 2; float y = 0 + (winSize.height / 2); - CCLog("S9FrameNameSpriteSheet ..."); + log("S9FrameNameSpriteSheet ..."); auto blocks = Scale9Sprite::createWithSpriteFrameName("blocks9.png"); - CCLog("... created"); + log("... created"); blocks->setPosition(Point(x, y)); - CCLog("... setPosition"); + log("... setPosition"); this->addChild(blocks); - CCLog("this->addChild"); + log("this->addChild"); - CCLog("... S9FrameNameSpriteSheet done."); + log("... S9FrameNameSpriteSheet done."); } std::string S9FrameNameSpriteSheet::title() @@ -216,18 +216,18 @@ void S9FrameNameSpriteSheetRotated::onEnter() float x = winSize.width / 2; float y = 0 + (winSize.height / 2); - CCLog("S9FrameNameSpriteSheetRotated ..."); + log("S9FrameNameSpriteSheetRotated ..."); auto blocks = Scale9Sprite::createWithSpriteFrameName("blocks9r.png"); - CCLog("... created"); + log("... created"); blocks->setPosition(Point(x, y)); - CCLog("... setPosition"); + log("... setPosition"); this->addChild(blocks); - CCLog("this->addChild"); + log("this->addChild"); - CCLog("... S9FrameNameSpriteSheetRotated done."); + log("... S9FrameNameSpriteSheetRotated done."); } std::string S9FrameNameSpriteSheetRotated::title() @@ -251,27 +251,27 @@ void S9BatchNodeScaledNoInsets::onEnter() float x = winSize.width / 2; float y = 0 + (winSize.height / 2); - CCLog("S9BatchNodeScaledNoInsets ..."); + log("S9BatchNodeScaledNoInsets ..."); // scaled without insets auto batchNode_scaled = SpriteBatchNode::create("Images/blocks9.png"); - CCLog("batchNode_scaled created with : Images/blocks9.png"); + log("batchNode_scaled created with : Images/blocks9.png"); auto blocks_scaled = Scale9Sprite::create(); - CCLog("... created"); + log("... created"); blocks_scaled->updateWithBatchNode(batchNode_scaled, Rect(0, 0, 96, 96), false, Rect(0, 0, 96, 96)); - CCLog("... updateWithBatchNode"); + log("... updateWithBatchNode"); blocks_scaled->setPosition(Point(x, y)); - CCLog("... setPosition"); + log("... setPosition"); blocks_scaled->setContentSize(Size(96 * 4, 96*2)); - CCLog("... setContentSize"); + log("... setContentSize"); this->addChild(blocks_scaled); - CCLog("this->addChild"); + log("this->addChild"); - CCLog("... S9BtchNodeScaledNoInsets done."); + log("... S9BtchNodeScaledNoInsets done."); } std::string S9BatchNodeScaledNoInsets::title() @@ -295,21 +295,21 @@ void S9FrameNameSpriteSheetScaledNoInsets::onEnter() float x = winSize.width / 2; float y = 0 + (winSize.height / 2); - CCLog("S9FrameNameSpriteSheetScaledNoInsets ..."); + log("S9FrameNameSpriteSheetScaledNoInsets ..."); auto blocks_scaled = Scale9Sprite::createWithSpriteFrameName("blocks9.png"); - CCLog("... created"); + log("... created"); blocks_scaled->setPosition(Point(x, y)); - CCLog("... setPosition"); + log("... setPosition"); blocks_scaled->setContentSize(Size(96 * 4, 96*2)); - CCLog("... setContentSize"); + log("... setContentSize"); this->addChild(blocks_scaled); - CCLog("this->addChild"); + log("this->addChild"); - CCLog("... S9FrameNameSpriteSheetScaledNoInsets done."); + log("... S9FrameNameSpriteSheetScaledNoInsets done."); } std::string S9FrameNameSpriteSheetScaledNoInsets::title() @@ -334,21 +334,21 @@ void S9FrameNameSpriteSheetRotatedScaledNoInsets::onEnter() float x = winSize.width / 2; float y = 0 + (winSize.height / 2); - CCLog("S9FrameNameSpriteSheetRotatedScaledNoInsets ..."); + log("S9FrameNameSpriteSheetRotatedScaledNoInsets ..."); auto blocks_scaled = Scale9Sprite::createWithSpriteFrameName("blocks9r.png"); - CCLog("... created"); + log("... created"); blocks_scaled->setPosition(Point(x, y)); - CCLog("... setPosition"); + log("... setPosition"); blocks_scaled->setContentSize(Size(96 * 4, 96*2)); - CCLog("... setContentSize"); + log("... setContentSize"); this->addChild(blocks_scaled); - CCLog("this->addChild"); + log("this->addChild"); - CCLog("... S9FrameNameSpriteSheetRotatedScaledNoInsets done."); + log("... S9FrameNameSpriteSheetRotatedScaledNoInsets done."); } std::string S9FrameNameSpriteSheetRotatedScaledNoInsets::title() @@ -373,27 +373,27 @@ void S9BatchNodeScaleWithCapInsets::onEnter() float x = winSize.width / 2; float y = 0 + (winSize.height / 2); - CCLog("S9BatchNodeScaleWithCapInsets ..."); + log("S9BatchNodeScaleWithCapInsets ..."); auto batchNode_scaled_with_insets = SpriteBatchNode::create("Images/blocks9.png"); - CCLog("batchNode_scaled_with_insets created with : Images/blocks9.png"); + log("batchNode_scaled_with_insets created with : Images/blocks9.png"); auto blocks_scaled_with_insets = Scale9Sprite::create(); - CCLog("... created"); + log("... created"); blocks_scaled_with_insets->updateWithBatchNode(batchNode_scaled_with_insets, Rect(0, 0, 96, 96), false, Rect(32, 32, 32, 32)); - CCLog("... updateWithBatchNode"); + log("... updateWithBatchNode"); blocks_scaled_with_insets->setContentSize(Size(96 * 4.5, 96 * 2.5)); - CCLog("... setContentSize"); + log("... setContentSize"); blocks_scaled_with_insets->setPosition(Point(x, y)); - CCLog("... setPosition"); + log("... setPosition"); this->addChild(blocks_scaled_with_insets); - CCLog("this->addChild"); + log("this->addChild"); - CCLog("... S9BatchNodeScaleWithCapInsets done."); + log("... S9BatchNodeScaleWithCapInsets done."); } std::string S9BatchNodeScaleWithCapInsets::title() @@ -417,18 +417,18 @@ void S9FrameNameSpriteSheetInsets::onEnter() float x = winSize.width / 2; float y = 0 + (winSize.height / 2); - CCLog("S9FrameNameSpriteSheetInsets ..."); + log("S9FrameNameSpriteSheetInsets ..."); auto blocks_with_insets = Scale9Sprite::createWithSpriteFrameName("blocks9.png", Rect(32, 32, 32, 32)); - CCLog("... created"); + log("... created"); blocks_with_insets->setPosition(Point(x, y)); - CCLog("... setPosition"); + log("... setPosition"); this->addChild(blocks_with_insets); - CCLog("this->addChild"); + log("this->addChild"); - CCLog("... S9FrameNameSpriteSheetInsets done."); + log("... S9FrameNameSpriteSheetInsets done."); } std::string S9FrameNameSpriteSheetInsets::title() @@ -451,21 +451,21 @@ void S9FrameNameSpriteSheetInsetsScaled::onEnter() float x = winSize.width / 2; float y = 0 + (winSize.height / 2); - CCLog("S9FrameNameSpriteSheetInsetsScaled ..."); + log("S9FrameNameSpriteSheetInsetsScaled ..."); auto blocks_scaled_with_insets = Scale9Sprite::createWithSpriteFrameName("blocks9.png", Rect(32, 32, 32, 32)); - CCLog("... created"); + log("... created"); blocks_scaled_with_insets->setContentSize(Size(96 * 4.5, 96 * 2.5)); - CCLog("... setContentSize"); + log("... setContentSize"); blocks_scaled_with_insets->setPosition(Point(x, y)); - CCLog("... setPosition"); + log("... setPosition"); this->addChild(blocks_scaled_with_insets); - CCLog("this->addChild"); + log("this->addChild"); - CCLog("... S9FrameNameSpriteSheetInsetsScaled done."); + log("... S9FrameNameSpriteSheetInsetsScaled done."); } std::string S9FrameNameSpriteSheetInsetsScaled::title() @@ -488,18 +488,18 @@ void S9FrameNameSpriteSheetRotatedInsets::onEnter() float x = winSize.width / 2; float y = 0 + (winSize.height / 2); - CCLog("S9FrameNameSpriteSheetRotatedInsets ..."); + log("S9FrameNameSpriteSheetRotatedInsets ..."); auto blocks_with_insets = Scale9Sprite::createWithSpriteFrameName("blocks9r.png", Rect(32, 32, 32, 32)); - CCLog("... created"); + log("... created"); blocks_with_insets->setPosition(Point(x, y)); - CCLog("... setPosition"); + log("... setPosition"); this->addChild(blocks_with_insets); - CCLog("this->addChild"); + log("this->addChild"); - CCLog("... S9FrameNameSpriteSheetRotatedInsets done."); + log("... S9FrameNameSpriteSheetRotatedInsets done."); } std::string S9FrameNameSpriteSheetRotatedInsets::title() @@ -525,35 +525,35 @@ void S9_TexturePacker::onEnter() float x = winSize.width / 4; float y = 0 + (winSize.height / 2); - CCLog("S9_TexturePacker ..."); + log("S9_TexturePacker ..."); auto s = Scale9Sprite::createWithSpriteFrameName("button_normal.png"); - CCLog("... created"); + log("... created"); s->setPosition(Point(x, y)); - CCLog("... setPosition"); + log("... setPosition"); s->setContentSize(Size(14 * 16, 10 * 16)); - CCLog("... setContentSize"); + log("... setContentSize"); this->addChild(s); - CCLog("this->addChild"); + log("this->addChild"); x = winSize.width * 3/4; auto s2 = Scale9Sprite::createWithSpriteFrameName("button_actived.png"); - CCLog("... created"); + log("... created"); s2->setPosition(Point(x, y)); - CCLog("... setPosition"); + log("... setPosition"); s2->setContentSize(Size(14 * 16, 10 * 16)); - CCLog("... setContentSize"); + log("... setContentSize"); this->addChild(s2); - CCLog("this->addChild"); + log("this->addChild"); - CCLog("... S9_TexturePacker done."); + log("... S9_TexturePacker done."); } std::string S9_TexturePacker::title() @@ -577,21 +577,21 @@ void S9FrameNameSpriteSheetRotatedInsetsScaled::onEnter() float x = winSize.width / 2; float y = 0 + (winSize.height / 2); - CCLog("S9FrameNameSpriteSheetRotatedInsetsScaled ..."); + log("S9FrameNameSpriteSheetRotatedInsetsScaled ..."); auto blocks_scaled_with_insets = Scale9Sprite::createWithSpriteFrameName("blocks9.png", Rect(32, 32, 32, 32)); - CCLog("... created"); + log("... created"); blocks_scaled_with_insets->setContentSize(Size(96 * 4.5, 96 * 2.5)); - CCLog("... setContentSize"); + log("... setContentSize"); blocks_scaled_with_insets->setPosition(Point(x, y)); - CCLog("... setPosition"); + log("... setPosition"); this->addChild(blocks_scaled_with_insets); - CCLog("this->addChild"); + log("this->addChild"); - CCLog("... S9FrameNameSpriteSheetRotatedInsetsScaled done."); + log("... S9FrameNameSpriteSheetRotatedInsetsScaled done."); } std::string S9FrameNameSpriteSheetRotatedInsetsScaled::title() @@ -615,22 +615,22 @@ void S9FrameNameSpriteSheetRotatedSetCapInsetLater::onEnter() float x = winSize.width / 2; float y = 0 + (winSize.height / 2); - CCLog("Scale9FrameNameSpriteSheetRotatedSetCapInsetLater ..."); + log("Scale9FrameNameSpriteSheetRotatedSetCapInsetLater ..."); auto blocks_scaled_with_insets = Scale9Sprite::createWithSpriteFrameName("blocks9r.png"); - CCLog("... created"); + log("... created"); blocks_scaled_with_insets->setInsetLeft(32); blocks_scaled_with_insets->setInsetRight(32); blocks_scaled_with_insets->setPreferredSize(Size(32*5.5f, 32*4)); blocks_scaled_with_insets->setPosition(Point(x, y)); - CCLog("... setPosition"); + log("... setPosition"); this->addChild(blocks_scaled_with_insets); - CCLog("this->addChild"); + log("this->addChild"); - CCLog("... Scale9FrameNameSpriteSheetRotatedSetCapInsetLater done."); + log("... Scale9FrameNameSpriteSheetRotatedSetCapInsetLater done."); } std::string S9FrameNameSpriteSheetRotatedSetCapInsetLater::title() @@ -658,13 +658,13 @@ void S9CascadeOpacityAndColor::onEnter() rgba->setCascadeOpacityEnabled(true); this->addChild(rgba); - CCLog("S9CascadeOpacityAndColor ..."); + log("S9CascadeOpacityAndColor ..."); auto blocks_scaled_with_insets = Scale9Sprite::createWithSpriteFrameName("blocks9r.png"); - CCLog("... created"); + log("... created"); blocks_scaled_with_insets->setPosition(Point(x, y)); - CCLog("... setPosition"); + log("... setPosition"); rgba->addChild(blocks_scaled_with_insets); Sequence* actions = Sequence::create(FadeIn::create(1), @@ -674,9 +674,9 @@ void S9CascadeOpacityAndColor::onEnter() NULL); RepeatForever* repeat = RepeatForever::create(actions); rgba->runAction(repeat); - CCLog("this->addChild"); + log("this->addChild"); - CCLog("... S9CascadeOpacityAndColor done."); + log("... S9CascadeOpacityAndColor done."); } std::string S9CascadeOpacityAndColor::title() diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/TableViewTest/TableViewTestScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/TableViewTest/TableViewTestScene.cpp index 71f8285c13..14d9f8ca1f 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/TableViewTest/TableViewTestScene.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/TableViewTest/TableViewTestScene.cpp @@ -7,10 +7,10 @@ USING_NS_CC_EXT; void runTableViewTest() { - Scene *pScene = Scene::create(); - TableViewTestLayer *pLayer = TableViewTestLayer::create(); - pScene->addChild(pLayer); - Director::getInstance()->replaceScene(pScene); + Scene *scene = Scene::create(); + TableViewTestLayer *layer = TableViewTestLayer::create(); + scene->addChild(layer); + Director::getInstance()->replaceScene(scene); } // on "init" you need to initialize your instance @@ -50,9 +50,9 @@ bool TableViewTestLayer::init() void TableViewTestLayer::toExtensionsMainLayer(cocos2d::Object *sender) { - ExtensionsTestScene *pScene = new ExtensionsTestScene(); - pScene->runThisTest(); - pScene->release(); + ExtensionsTestScene *scene = new ExtensionsTestScene(); + scene->runThisTest(); + scene->release(); } void TableViewTestLayer::tableCellTouched(TableView* table, TableViewCell* cell) diff --git a/samples/Cpp/TestCpp/Classes/FileUtilsTest/FileUtilsTest.cpp b/samples/Cpp/TestCpp/Classes/FileUtilsTest/FileUtilsTest.cpp index 9a5e582fa9..f8dc9a46b9 100644 --- a/samples/Cpp/TestCpp/Classes/FileUtilsTest/FileUtilsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/FileUtilsTest/FileUtilsTest.cpp @@ -23,11 +23,11 @@ static Layer* nextAction() sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - Layer* pLayer = (createFunctions[sceneIdx])(); - pLayer->init(); - pLayer->autorelease(); + Layer* layer = (createFunctions[sceneIdx])(); + layer->init(); + layer->autorelease(); - return pLayer; + return layer; } static Layer* backAction() @@ -37,26 +37,26 @@ static Layer* backAction() if( sceneIdx < 0 ) sceneIdx += total; - Layer* pLayer = (createFunctions[sceneIdx])(); - pLayer->init(); - pLayer->autorelease(); + Layer* layer = (createFunctions[sceneIdx])(); + layer->init(); + layer->autorelease(); - return pLayer; + return layer; } static Layer* restartAction() { - Layer* pLayer = (createFunctions[sceneIdx])(); - pLayer->init(); - pLayer->autorelease(); + Layer* layer = (createFunctions[sceneIdx])(); + layer->init(); + layer->autorelease(); - return pLayer; + return layer; } void FileUtilsTestScene::runThisTest() { - Layer* pLayer = nextAction(); - addChild(pLayer); + Layer* layer = nextAction(); + addChild(layer); Director::getInstance()->replaceScene(this); } @@ -70,32 +70,32 @@ void FileUtilsDemo::onEnter() void FileUtilsDemo::backCallback(Object* pSender) { - Scene* pScene = new FileUtilsTestScene(); - Layer* pLayer = backAction(); + Scene* scene = new FileUtilsTestScene(); + Layer* layer = backAction(); - pScene->addChild(pLayer); - Director::getInstance()->replaceScene(pScene); - pScene->release(); + scene->addChild(layer); + Director::getInstance()->replaceScene(scene); + scene->release(); } void FileUtilsDemo::nextCallback(Object* pSender) { - Scene* pScene = new FileUtilsTestScene(); - Layer* pLayer = nextAction(); + Scene* scene = new FileUtilsTestScene(); + Layer* layer = nextAction(); - pScene->addChild(pLayer); - Director::getInstance()->replaceScene(pScene); - pScene->release(); + scene->addChild(layer); + Director::getInstance()->replaceScene(scene); + scene->release(); } void FileUtilsDemo::restartCallback(Object* pSender) { - Scene* pScene = new FileUtilsTestScene(); - Layer* pLayer = restartAction(); + Scene* scene = new FileUtilsTestScene(); + Layer* layer = restartAction(); - pScene->addChild(pLayer); - Director::getInstance()->replaceScene(pScene); - pScene->release(); + scene->addChild(layer); + Director::getInstance()->replaceScene(scene); + scene->release(); } string FileUtilsDemo::title() @@ -138,7 +138,7 @@ void TestResolutionDirectories::onEnter() for( int i=1; i<7; i++) { String *filename = String::createWithFormat("test%d.txt", i); ret = sharedFileUtils->fullPathForFilename(filename->getCString()); - CCLog("%s -> %s", filename->getCString(), ret.c_str()); + log("%s -> %s", filename->getCString(), ret.c_str()); } } @@ -184,7 +184,7 @@ void TestSearchPath::onEnter() CCASSERT(ret == 0, "fwrite function returned nonzero value"); fclose(fp); if (ret == 0) - CCLog("Writing file to writable path succeed."); + log("Writing file to writable path succeed."); } searchPaths.insert(searchPaths.begin(), writablePath); @@ -201,12 +201,12 @@ void TestSearchPath::onEnter() for( int i=1; i<3; i++) { String *filename = String::createWithFormat("file%d.txt", i); ret = sharedFileUtils->fullPathForFilename(filename->getCString()); - CCLog("%s -> %s", filename->getCString(), ret.c_str()); + log("%s -> %s", filename->getCString(), ret.c_str()); } // Gets external.txt from writable path string fullPath = sharedFileUtils->fullPathForFilename("external.txt"); - CCLog("external file path = %s", fullPath.c_str()); + log("external file path = %s", fullPath.c_str()); if (fullPath.length() > 0) { fp = fopen(fullPath.c_str(), "rb"); @@ -215,7 +215,7 @@ void TestSearchPath::onEnter() char szReadBuf[100] = {0}; int read = fread(szReadBuf, 1, strlen(szBuf), fp); if (read > 0) - CCLog("The content of file from writable path: %s", szReadBuf); + log("The content of file from writable path: %s", szReadBuf); fclose(fp); } } @@ -363,9 +363,9 @@ void TextWritePlist::onEnter() std::string writablePath = FileUtils::getInstance()->getWritablePath(); std::string fullPath = writablePath + "text.plist"; if(root->writeToFile(fullPath.c_str())) - CCLog("see the plist file at %s", fullPath.c_str()); + log("see the plist file at %s", fullPath.c_str()); else - CCLog("write plist file failed"); + log("write plist file failed"); LabelTTF *label = LabelTTF::create(fullPath.c_str(), "Thonburi", 6); this->addChild(label); diff --git a/samples/Cpp/TestCpp/Classes/FontTest/FontTest.cpp b/samples/Cpp/TestCpp/Classes/FontTest/FontTest.cpp index 55afd673e7..04c5f2288d 100644 --- a/samples/Cpp/TestCpp/Classes/FontTest/FontTest.cpp +++ b/samples/Cpp/TestCpp/Classes/FontTest/FontTest.cpp @@ -166,8 +166,8 @@ void FontTest::restartCallback(Object* pSender) ///--------------------------------------- void FontTestScene::runThisTest() { - Layer* pLayer = FontTest::create(); - addChild(pLayer); + Layer* 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 fdae8df703..ed1955ad3f 100644 --- a/samples/Cpp/TestCpp/Classes/IntervalTest/IntervalTest.cpp +++ b/samples/Cpp/TestCpp/Classes/IntervalTest/IntervalTest.cpp @@ -49,7 +49,7 @@ IntervalLayer::IntervalLayer() addChild(_label4); // Sprite - Sprite* sprite = Sprite::create(s_pPathGrossini); + Sprite* 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); @@ -123,9 +123,9 @@ void IntervalLayer::step4(float dt) void IntervalTestScene::runThisTest() { - Layer* pLayer = new IntervalLayer(); - addChild(pLayer); - pLayer->release(); + Layer* layer = new IntervalLayer(); + addChild(layer); + layer->release(); Director::getInstance()->replaceScene(this); } diff --git a/samples/Cpp/TestCpp/Classes/KeyboardTest/KeyboardTest.cpp b/samples/Cpp/TestCpp/Classes/KeyboardTest/KeyboardTest.cpp index 7d56d4f503..eeb5b3b3e1 100644 --- a/samples/Cpp/TestCpp/Classes/KeyboardTest/KeyboardTest.cpp +++ b/samples/Cpp/TestCpp/Classes/KeyboardTest/KeyboardTest.cpp @@ -26,21 +26,21 @@ KeyboardTest::~KeyboardTest() void KeyboardTest::keyPressed(int keyCode) { - CCLog("Key with keycode %d pressed", keyCode); + log("Key with keycode %d pressed", keyCode); } void KeyboardTest::keyReleased(int keyCode) { - CCLog("Key with keycode %d released", keyCode); + log("Key with keycode %d released", keyCode); } void KeyboardTestScene::runThisTest() { - Layer* pLayer = new KeyboardTest(); - addChild(pLayer); + Layer* layer = new KeyboardTest(); + addChild(layer); Director::getInstance()->replaceScene(this); - pLayer->release(); + layer->release(); } #endif diff --git a/samples/Cpp/TestCpp/Classes/KeypadTest/KeypadTest.cpp b/samples/Cpp/TestCpp/Classes/KeypadTest/KeypadTest.cpp index 7b22cecdfe..7076e59e9d 100644 --- a/samples/Cpp/TestCpp/Classes/KeypadTest/KeypadTest.cpp +++ b/samples/Cpp/TestCpp/Classes/KeypadTest/KeypadTest.cpp @@ -34,9 +34,9 @@ void KeypadTest::keyMenuClicked() void KeypadTestScene::runThisTest() { - Layer* pLayer = new KeypadTest(); - addChild(pLayer); + Layer* layer = new KeypadTest(); + addChild(layer); Director::getInstance()->replaceScene(this); - pLayer->release(); + layer->release(); } diff --git a/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.cpp b/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.cpp index dc6eb71df0..bd8a693b4d 100644 --- a/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.cpp +++ b/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.cpp @@ -40,56 +40,51 @@ Layer* restartAtlasAction(); static int sceneIdx = -1; -#define MAX_LAYER 28 - -Layer* createAtlasLayer(int nIndex) +static std::function createFunctions[] = { - switch(nIndex) - { - case 0: return new LabelAtlasTest(); - case 1: return new LabelAtlasColorTest(); - case 2: return new Atlas3(); - case 3: return new Atlas4(); - case 4: return new Atlas5(); - case 5: return new Atlas6(); - case 6: return new AtlasBitmapColor(); - case 7: return new AtlasFastBitmap(); - case 8: return new BitmapFontMultiLine(); - case 9: return new LabelsEmpty(); - case 10: return new LabelBMFontHD(); - case 11: return new LabelAtlasHD(); - case 12: return new LabelGlyphDesigner(); + CL(LabelAtlasTest), + CL(LabelAtlasColorTest), + CL(Atlas3), + CL(Atlas4), + CL(Atlas5), + CL(Atlas6), + CL(AtlasBitmapColor), + CL(AtlasFastBitmap), + CL(BitmapFontMultiLine), + CL(LabelsEmpty), + CL(LabelBMFontHD), + CL(LabelAtlasHD), + CL(LabelGlyphDesigner), + CL(LabelTTFTest), + CL(LabelTTFMultiline), + CL(LabelTTFChinese), + CL(LabelBMFontChinese), + CL(BitmapFontMultiLineAlignment), + CL(LabelTTFA8Test), + CL(BMFontOneAtlas), + CL(BMFontUnicode), + CL(BMFontInit), + CL(TTFFontInit), + CL(Issue1343), + CL(LabelTTFAlignment), + CL(LabelBMFontBounds), + CL(TTFFontShadowAndStroke), - // Not a label test. Should be moved to Atlas test - case 13: return new Atlas1(); - case 14: return new LabelTTFTest(); - case 15: return new LabelTTFMultiline(); - case 16: return new LabelTTFChinese(); - case 17: return new LabelBMFontChinese(); - case 18: return new BitmapFontMultiLineAlignment(); - case 19: return new LabelTTFA8Test(); - case 20: return new BMFontOneAtlas(); - case 21: return new BMFontUnicode(); - case 22: return new BMFontInit(); - case 23: return new TTFFontInit(); - case 24: return new Issue1343(); - case 25: return new LabelTTFAlignment(); - case 26: return new LabelBMFontBounds(); - case 27: return new TTFFontShadowAndStroke(); - } + // should be moved to another test + CL(Atlas1), +}; - return NULL; -} +#define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0])) Layer* nextAtlasAction() { sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - Layer* pLayer = createAtlasLayer(sceneIdx); - pLayer->autorelease(); + Layer* layer = (createFunctions[sceneIdx])(); + layer->autorelease(); - return pLayer; + return layer; } Layer* backAtlasAction() @@ -99,18 +94,18 @@ Layer* backAtlasAction() if( sceneIdx < 0 ) sceneIdx += total; - Layer* pLayer = createAtlasLayer(sceneIdx); - pLayer->autorelease(); + Layer* layer = (createFunctions[sceneIdx])(); + layer->autorelease(); - return pLayer; + return layer; } Layer* restartAtlasAction() { - Layer* pLayer = createAtlasLayer(sceneIdx); - pLayer->autorelease(); + Layer* layer = (createFunctions[sceneIdx])(); + layer->autorelease(); - return pLayer; + return layer; } @@ -801,9 +796,9 @@ LabelsEmpty::LabelsEmpty() void LabelsEmpty::updateStrings(float dt) { - LabelBMFont* label1 = (LabelBMFont*) getChildByTag(kTagBitmapAtlas1); - LabelTTF* label2 = (LabelTTF*) getChildByTag(kTagBitmapAtlas2); - LabelAtlas* label3 = (LabelAtlas*) getChildByTag(kTagBitmapAtlas3); + auto label1 = static_cast( getChildByTag(kTagBitmapAtlas1) ); + auto label2 = static_cast( getChildByTag(kTagBitmapAtlas2) ); + auto label3 = static_cast( getChildByTag(kTagBitmapAtlas3) ); if( ! setEmpty ) { @@ -843,7 +838,7 @@ LabelBMFontHD::LabelBMFontHD() Size s = Director::getInstance()->getWinSize(); // LabelBMFont - LabelBMFont *label1 = LabelBMFont::create("TESTING RETINA DISPLAY", "fonts/konqa32.fnt"); + auto label1 = LabelBMFont::create("TESTING RETINA DISPLAY", "fonts/konqa32.fnt"); addChild(label1); label1->setPosition(Point(s.width/2, s.height/2)); } @@ -868,7 +863,7 @@ LabelAtlasHD::LabelAtlasHD() Size s = Director::getInstance()->getWinSize(); // LabelBMFont - LabelAtlas *label1 = LabelAtlas::create("TESTING RETINA DISPLAY", "fonts/larabie-16.plist"); + auto label1 = LabelAtlas::create("TESTING RETINA DISPLAY", "fonts/larabie-16.plist"); label1->setAnchorPoint(Point(0.5f, 0.5f)); addChild(label1); @@ -894,11 +889,11 @@ LabelGlyphDesigner::LabelGlyphDesigner() { Size 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 - LabelBMFont *label1 = LabelBMFont::create("Testing Glyph Designer", "fonts/futura-48.fnt"); + auto label1 = LabelBMFont::create("Testing Glyph Designer", "fonts/futura-48.fnt"); addChild(label1); label1->setPosition(Point(s.width/2, s.height/2)); } @@ -916,8 +911,8 @@ std::string LabelGlyphDesigner::subtitle() void AtlasTestScene::runThisTest() { sceneIdx = -1; - Layer* pLayer = nextAtlasAction(); - addChild(pLayer); + Layer* layer = nextAtlasAction(); + addChild(layer); Director::getInstance()->replaceScene(this); } @@ -932,7 +927,7 @@ LabelTTFTest::LabelTTFTest() Size blockSize = Size(200, 160); Size s = Director::getInstance()->getWinSize(); - LayerColor *colorLayer = LayerColor::create(Color4B(100, 100, 100, 255), blockSize.width, blockSize.height); + auto colorLayer = LayerColor::create(Color4B(100, 100, 100, 255), blockSize.width, blockSize.height); colorLayer->setAnchorPoint(Point(0,0)); colorLayer->setPosition(Point((s.width - blockSize.width) / 2, (s.height - blockSize.height) / 2)); @@ -1095,10 +1090,10 @@ string LabelTTFMultiline::subtitle() LabelTTFChinese::LabelTTFChinese() { - Size size = Director::getInstance()->getWinSize(); - LabelTTF *pLable = LabelTTF::create("中国", "Marker Felt", 30); - pLable->setPosition(Point(size.width / 2, size.height /2)); - this->addChild(pLable); + auto size = Director::getInstance()->getWinSize(); + auto label = LabelTTF::create("中国", "Marker Felt", 30); + label->setPosition(Point(size.width / 2, size.height /2)); + this->addChild(label); } string LabelTTFChinese::title() @@ -1108,10 +1103,10 @@ string LabelTTFChinese::title() LabelBMFontChinese::LabelBMFontChinese() { - Size size = Director::getInstance()->getWinSize(); - LabelBMFont* pLable = LabelBMFont::create("中国", "fonts/bitmapFontChinese.fnt"); - pLable->setPosition(Point(size.width / 2, size.height /2)); - this->addChild(pLable); + auto size = Director::getInstance()->getWinSize(); + auto label = LabelBMFont::create("中国", "fonts/bitmapFontChinese.fnt"); + label->setPosition(Point(size.width / 2, size.height /2)); + this->addChild(label); } string LabelBMFontChinese::title() @@ -1155,10 +1150,10 @@ BitmapFontMultiLineAlignment::BitmapFontMultiLineAlignment() this->_arrowsShouldRetain->retain(); MenuItemFont::setFontSize(20); - MenuItemFont *longSentences = MenuItemFont::create("Long Flowing Sentences", CC_CALLBACK_1(BitmapFontMultiLineAlignment::stringChanged, this)); - MenuItemFont *lineBreaks = MenuItemFont::create("Short Sentences With Intentional Line Breaks", CC_CALLBACK_1(BitmapFontMultiLineAlignment::stringChanged, this)); - MenuItemFont *mixed = MenuItemFont::create("Long Sentences Mixed With Intentional Line Breaks", CC_CALLBACK_1(BitmapFontMultiLineAlignment::stringChanged, this)); - Menu *stringMenu = Menu::create(longSentences, lineBreaks, mixed, NULL); + auto longSentences = MenuItemFont::create("Long Flowing Sentences", CC_CALLBACK_1(BitmapFontMultiLineAlignment::stringChanged, this)); + auto lineBreaks = MenuItemFont::create("Short Sentences With Intentional Line Breaks", CC_CALLBACK_1(BitmapFontMultiLineAlignment::stringChanged, this)); + auto mixed = MenuItemFont::create("Long Sentences Mixed With Intentional Line Breaks", CC_CALLBACK_1(BitmapFontMultiLineAlignment::stringChanged, this)); + auto stringMenu = Menu::create(longSentences, lineBreaks, mixed, NULL); stringMenu->alignItemsVertically(); longSentences->setColor(Color3B::RED); @@ -1169,10 +1164,10 @@ BitmapFontMultiLineAlignment::BitmapFontMultiLineAlignment() MenuItemFont::setFontSize(30); - MenuItemFont *left = MenuItemFont::create("Left", CC_CALLBACK_1(BitmapFontMultiLineAlignment::alignmentChanged, this)); - MenuItemFont *center = MenuItemFont::create("Center", CC_CALLBACK_1(BitmapFontMultiLineAlignment::alignmentChanged, this)); - MenuItemFont *right = MenuItemFont::create("Right", CC_CALLBACK_1(BitmapFontMultiLineAlignment::alignmentChanged, this)); - Menu *alignmentMenu = Menu::create(left, center, right, NULL); + auto left = MenuItemFont::create("Left", CC_CALLBACK_1(BitmapFontMultiLineAlignment::alignmentChanged, this)); + auto center = MenuItemFont::create("Center", CC_CALLBACK_1(BitmapFontMultiLineAlignment::alignmentChanged, this)); + auto right = MenuItemFont::create("Right", CC_CALLBACK_1(BitmapFontMultiLineAlignment::alignmentChanged, this)); + auto alignmentMenu = Menu::create(left, center, right, NULL); alignmentMenu->alignItemsHorizontallyWithPadding(alignmentItemPadding); center->setColor(Color3B::RED); @@ -1247,7 +1242,7 @@ void BitmapFontMultiLineAlignment::stringChanged(cocos2d::Object *sender) void BitmapFontMultiLineAlignment::alignmentChanged(cocos2d::Object *sender) { - MenuItemFont *item = (MenuItemFont*)sender; + MenuItemFont *item = static_cast(sender); item->setColor(Color3B::RED); this->_lastAlignmentItem->setColor(Color3B::WHITE); this->_lastAlignmentItem = item; @@ -1331,10 +1326,10 @@ LabelTTFA8Test::LabelTTFA8Test() label1->setColor(Color3B::RED); label1->setPosition(Point(s.width/2, s.height/2)); - FadeOut *fadeOut = FadeOut::create(2); - FadeIn *fadeIn = FadeIn::create(2); - Sequence *seq = Sequence::create(fadeOut, fadeIn, NULL); - RepeatForever *forever = RepeatForever::create(seq); + auto fadeOut = FadeOut::create(2); + auto fadeIn = FadeIn::create(2); + auto seq = Sequence::create(fadeOut, fadeIn, NULL); + auto forever = RepeatForever::create(seq); label1->runAction(forever); } @@ -1353,11 +1348,11 @@ BMFontOneAtlas::BMFontOneAtlas() { Size s = Director::getInstance()->getWinSize(); - LabelBMFont *label1 = LabelBMFont::create("This is Helvetica", "fonts/helvetica-32.fnt", kLabelAutomaticWidth, kTextAlignmentLeft, Point::ZERO); + auto label1 = LabelBMFont::create("This is Helvetica", "fonts/helvetica-32.fnt", kLabelAutomaticWidth, kTextAlignmentLeft, Point::ZERO); addChild(label1); label1->setPosition(Point(s.width/2, s.height/3*2)); - LabelBMFont *label2 = LabelBMFont::create("And this is Geneva", "fonts/geneva-32.fnt", kLabelAutomaticWidth, kTextAlignmentLeft, Point(0, 128)); + auto label2 = LabelBMFont::create("And this is Geneva", "fonts/geneva-32.fnt", kLabelAutomaticWidth, kTextAlignmentLeft, Point(0, 128)); addChild(label2); label2->setPosition(Point(s.width/2, s.height/3*1)); } @@ -1377,27 +1372,26 @@ BMFontUnicode::BMFontUnicode() { Dictionary *strings = Dictionary::createWithContentsOfFile("fonts/strings.xml"); - const char *chinese = ((String*)strings->objectForKey("chinese1"))->_string.c_str(); - const char *japanese = ((String*)strings->objectForKey("japanese"))->_string.c_str(); - const char *russian = ((String*)strings->objectForKey("russian"))->_string.c_str(); - const char *spanish = ((String*)strings->objectForKey("spanish"))->_string.c_str(); - + 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(); - LabelBMFont *label1 = LabelBMFont::create(spanish, "fonts/arial-unicode-26.fnt", 200, kTextAlignmentLeft); + auto label1 = LabelBMFont::create(spanish, "fonts/arial-unicode-26.fnt", 200, kTextAlignmentLeft); addChild(label1); label1->setPosition(Point(s.width/2, s.height/5*4)); - LabelBMFont *label2 = LabelBMFont::create(chinese, "fonts/arial-unicode-26.fnt"); + auto label2 = LabelBMFont::create(chinese, "fonts/arial-unicode-26.fnt"); addChild(label2); label2->setPosition(Point(s.width/2, s.height/5*3)); - LabelBMFont *label3 = LabelBMFont::create(russian, "fonts/arial-26-en-ru.fnt"); + auto label3 = LabelBMFont::create(russian, "fonts/arial-26-en-ru.fnt"); addChild(label3); label3->setPosition(Point(s.width/2, s.height/5*2)); - LabelBMFont *label4 = LabelBMFont::create(japanese, "fonts/arial-unicode-26.fnt"); + auto label4 = LabelBMFont::create(japanese, "fonts/arial-unicode-26.fnt"); addChild(label4); label4->setPosition(Point(s.width/2, s.height/5*1)); } @@ -1418,10 +1412,8 @@ BMFontInit::BMFontInit() { Size s = Director::getInstance()->getWinSize(); - LabelBMFont* bmFont = new LabelBMFont(); - bmFont->init(); - bmFont->autorelease(); - //CCLabelBMFont* bmFont = [LabelBMFont create:@"Foo" fntFile:@"arial-unicode-26.fnt"]; + LabelBMFont* bmFont = LabelBMFont::create(); + bmFont->setFntFile("fonts/helvetica-32.fnt"); bmFont->setString("It is working!"); this->addChild(bmFont); @@ -1430,12 +1422,12 @@ BMFontInit::BMFontInit() std::string BMFontInit::title() { - return "CCLabelBMFont init"; + return "LabelBMFont create()"; } std::string BMFontInit::subtitle() { - return "Test for support of init method without parameters."; + return "Testing LabelBMFont::create() wihtout params"; } // TTFFontInit @@ -1444,9 +1436,8 @@ TTFFontInit::TTFFontInit() { Size s = Director::getInstance()->getWinSize(); - LabelTTF* font = new LabelTTF(); - font->init(); - font->autorelease(); + LabelTTF* font = LabelTTF::create(); + font->setFontName("Marker Felt"); font->setFontSize(48); font->setString("It is working!"); @@ -1456,12 +1447,12 @@ TTFFontInit::TTFFontInit() std::string TTFFontInit::title() { - return "CCLabelTTF init"; + return "LabelTTF create()"; } std::string TTFFontInit::subtitle() { - return "Test for support of init method without parameters."; + return "Testing LabelTTF::create() wihtout params"; } TTFFontShadowAndStroke::TTFFontShadowAndStroke() @@ -1496,8 +1487,7 @@ TTFFontShadowAndStroke::TTFFontShadowAndStroke() this->addChild(fontShadow); fontShadow->setPosition(Point(s.width/2,s.height/4*2.5)); - - + // create the stroke only label FontDefinition strokeTextDef; strokeTextDef._fontSize = 20; @@ -1541,9 +1531,6 @@ TTFFontShadowAndStroke::TTFFontShadowAndStroke() // add label to the scene this->addChild(fontStrokeAndShadow); fontStrokeAndShadow->setPosition(Point(s.width/2,s.height/4*1.1)); - - - } std::string TTFFontShadowAndStroke::title() @@ -1563,14 +1550,14 @@ Issue1343::Issue1343() { Size s = Director::getInstance()->getWinSize(); - LabelBMFont* bmFont = new LabelBMFont(); - bmFont->init(); + LabelBMFont* bmFont = LabelBMFont::create(); + bmFont->setFntFile("fonts/font-issue1343.fnt"); bmFont->setString("ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz.,'"); - this->addChild(bmFont); - bmFont->release(); - bmFont->setScale(0.3f); + this->addChild(bmFont); + + bmFont->setScale(0.3f); bmFont->setPosition(Point(s.width/2,s.height/4*2)); } diff --git a/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.cpp b/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.cpp index 0739205325..1cf2d902a6 100644 --- a/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.cpp +++ b/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.cpp @@ -33,10 +33,10 @@ static Layer* nextAction() sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - Layer* pLayer = (createFunctions[sceneIdx])(); - pLayer->autorelease(); + Layer* layer = (createFunctions[sceneIdx])(); + layer->autorelease(); - return pLayer; + return layer; } static Layer* backAction() @@ -46,18 +46,18 @@ static Layer* backAction() if( sceneIdx < 0 ) sceneIdx += total; - Layer* pLayer = (createFunctions[sceneIdx])(); - pLayer->autorelease(); + Layer* layer = (createFunctions[sceneIdx])(); + layer->autorelease(); - return pLayer; + return layer; } static Layer* restartAction() { - Layer* pLayer = (createFunctions[sceneIdx])(); - pLayer->autorelease(); + Layer* layer = (createFunctions[sceneIdx])(); + layer->autorelease(); - return pLayer; + return layer; } //------------------------------------------------------------------ @@ -540,8 +540,8 @@ LayerTestBlend::LayerTestBlend() Size s = Director::getInstance()->getWinSize(); LayerColor* layer1 = LayerColor::create( Color4B(255, 255, 255, 80) ); - Sprite* sister1 = Sprite::create(s_pPathSister1); - Sprite* sister2 = Sprite::create(s_pPathSister2); + Sprite* sister1 = Sprite::create(s_pathSister1); + Sprite* sister2 = Sprite::create(s_pathSister2); addChild(sister1); addChild(sister2); @@ -607,7 +607,7 @@ LayerGradientTest::LayerGradientTest() void LayerGradientTest::toggleItem(Object *sender) { - LayerGradient *gradient = (LayerGradient*)getChildByTag(kTagLayer); + LayerGradient *gradient = static_cast( getChildByTag(kTagLayer) ); gradient->setCompressedInterpolation(! gradient->isCompressedInterpolation()); } @@ -615,13 +615,13 @@ void LayerGradientTest::ccTouchesMoved(Set * touches, Event *event) { Size s = Director::getInstance()->getWinSize(); - Touch* touch = (Touch*) touches->anyObject(); + Touch* touch = static_cast( touches->anyObject() ); Point start = touch->getLocation(); Point diff = Point(s.width/2,s.height/2) - start; diff = diff.normalize(); - LayerGradient *gradient = (LayerGradient*) getChildByTag(1); + LayerGradient *gradient = static_cast( getChildByTag(1) ); gradient->setVector(diff); } @@ -716,9 +716,9 @@ void LayerIgnoreAnchorPointPos::onEnter() void LayerIgnoreAnchorPointPos::onToggle(Object* pObject) { - Node* pLayer = this->getChildByTag(kLayerIgnoreAnchorPoint); - bool ignore = pLayer->isIgnoreAnchorPointForPosition(); - pLayer->ignoreAnchorPointForPosition(! ignore); + Node* layer = this->getChildByTag(kLayerIgnoreAnchorPoint); + bool ignore = layer->isIgnoreAnchorPointForPosition(); + layer->ignoreAnchorPointForPosition(! ignore); } std::string LayerIgnoreAnchorPointPos::title() @@ -764,9 +764,9 @@ void LayerIgnoreAnchorPointRot::onEnter() void LayerIgnoreAnchorPointRot::onToggle(Object* pObject) { - Node* pLayer = this->getChildByTag(kLayerIgnoreAnchorPoint); - bool ignore = pLayer->isIgnoreAnchorPointForPosition(); - pLayer->ignoreAnchorPointForPosition(! ignore); + Node* layer = this->getChildByTag(kLayerIgnoreAnchorPoint); + bool ignore = layer->isIgnoreAnchorPointForPosition(); + layer->ignoreAnchorPointForPosition(! ignore); } std::string LayerIgnoreAnchorPointRot::title() @@ -815,9 +815,9 @@ void LayerIgnoreAnchorPointScale::onEnter() void LayerIgnoreAnchorPointScale::onToggle(Object* pObject) { - Node* pLayer = this->getChildByTag(kLayerIgnoreAnchorPoint); - bool ignore = pLayer->isIgnoreAnchorPointForPosition(); - pLayer->ignoreAnchorPointForPosition(! ignore); + Node* layer = this->getChildByTag(kLayerIgnoreAnchorPoint); + bool ignore = layer->isIgnoreAnchorPointForPosition(); + layer->ignoreAnchorPointForPosition(! ignore); } std::string LayerIgnoreAnchorPointScale::title() @@ -833,8 +833,8 @@ std::string LayerIgnoreAnchorPointScale::subtitle() void LayerTestScene::runThisTest() { sceneIdx = -1; - Layer* pLayer = nextAction(); - addChild(pLayer); + Layer* layer = nextAction(); + addChild(layer); Director::getInstance()->replaceScene(this); } diff --git a/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.cpp b/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.cpp index b4cd240457..835349b3b2 100644 --- a/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.cpp +++ b/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.cpp @@ -148,19 +148,19 @@ void MenuLayerMainMenu::menuCallbackConfig(Object* sender) void MenuLayerMainMenu::allowTouches(float dt) { - Director* pDirector = Director::getInstance(); - pDirector->getTouchDispatcher()->setPriority(kMenuHandlerPriority+1, this); + Director* director = Director::getInstance(); + director->getTouchDispatcher()->setPriority(kMenuHandlerPriority+1, this); unscheduleAllSelectors(); - CCLog("TOUCHES ALLOWED AGAIN"); + log("TOUCHES ALLOWED AGAIN"); } void MenuLayerMainMenu::menuCallbackDisabled(Object* sender) { // hijack all touch events for 5 seconds - Director* pDirector = Director::getInstance(); - pDirector->getTouchDispatcher()->setPriority(kMenuHandlerPriority-1, this); + Director* director = Director::getInstance(); + director->getTouchDispatcher()->setPriority(kMenuHandlerPriority-1, this); schedule(schedule_selector(MenuLayerMainMenu::allowTouches), 5.0f); - CCLog("TOUCHES DISABLED FOR 5 SECONDS"); + log("TOUCHES DISABLED FOR 5 SECONDS"); } void MenuLayerMainMenu::menuCallback2(Object* sender) @@ -324,7 +324,7 @@ MenuLayer3::MenuLayer3() MenuItemSprite* item3 = MenuItemSprite::create(spriteNormal, spriteSelected, spriteDisabled, [](Object *sender) { - CCLog("sprite clicked!"); + log("sprite clicked!"); }); _disabledItem = item3; item3->retain(); _disabledItem->setEnabled( false ); @@ -512,7 +512,7 @@ MenuLayerPriorityTest::~MenuLayerPriorityTest() void MenuLayerPriorityTest::menuCallback(Object* pSender) { static_cast(_parent)->switchTo(0); -// [[Director sharedDirector] popScene]; +// [[Director sharedDirector] poscene]; } // BugsTest @@ -536,7 +536,7 @@ void BugsTest::issue1410MenuCallback(Object *sender) menu->setTouchEnabled(false); menu->setTouchEnabled(true); - CCLog("NO CRASHES"); + log("NO CRASHES"); } void BugsTest::issue1410v2MenuCallback(cocos2d::Object *pSender) @@ -545,7 +545,7 @@ void BugsTest::issue1410v2MenuCallback(cocos2d::Object *pSender) menu->setTouchEnabled(true); menu->setTouchEnabled(false); - CCLog("NO CRASHES. AND MENU SHOULD STOP WORKING"); + log("NO CRASHES. AND MENU SHOULD STOP WORKING"); } void BugsTest::backMenuCallback(cocos2d::Object *pSender) @@ -607,24 +607,24 @@ void RemoveMenuItemWhenMove::ccTouchMoved(Touch *pTouch, Event *pEvent) void MenuTestScene::runThisTest() { - Layer* pLayer1 = new MenuLayerMainMenu(); - Layer* pLayer2 = new MenuLayer2(); - Layer* pLayer3 = new MenuLayer3(); - Layer* pLayer4 = new MenuLayer4(); - Layer* pLayer5 = new MenuLayerPriorityTest(); - Layer* pLayer6 = new BugsTest(); - Layer* pLayer7 = new RemoveMenuItemWhenMove(); + 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(); - LayerMultiplex* layer = LayerMultiplex::create(pLayer1, pLayer2, pLayer3, pLayer4, pLayer5, pLayer6, pLayer7, NULL); + LayerMultiplex* layer = LayerMultiplex::create(layer1, layer2, layer3, layer4, layer5, layer6, layer7, NULL); addChild(layer, 0); - pLayer1->release(); - pLayer2->release(); - pLayer3->release(); - pLayer4->release(); - pLayer5->release(); - pLayer6->release(); - pLayer7->release(); + layer1->release(); + layer2->release(); + layer3->release(); + layer4->release(); + layer5->release(); + layer6->release(); + layer7->release(); Director::getInstance()->replaceScene(this); } diff --git a/samples/Cpp/TestCpp/Classes/MotionStreakTest/MotionStreakTest.cpp b/samples/Cpp/TestCpp/Classes/MotionStreakTest/MotionStreakTest.cpp index c7aa3965e2..b8a2019e55 100644 --- a/samples/Cpp/TestCpp/Classes/MotionStreakTest/MotionStreakTest.cpp +++ b/samples/Cpp/TestCpp/Classes/MotionStreakTest/MotionStreakTest.cpp @@ -11,6 +11,48 @@ Layer* nextMotionAction(); Layer* backMotionAction(); Layer* restartMotionAction(); +static int sceneIdx = -1; + +static std::function createFunctions[] = +{ + CL(MotionStreakTest1), + CL(MotionStreakTest2), + CL(Issue1358), +}; + +#define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0])) + +Layer* nextMotionAction() +{ + sceneIdx++; + sceneIdx = sceneIdx % MAX_LAYER; + + Layer* layer = (createFunctions[sceneIdx])(); + layer->autorelease(); + + return layer; +} + +Layer* backMotionAction() +{ + sceneIdx--; + int total = MAX_LAYER; + if( sceneIdx < 0 ) + sceneIdx += total; + + Layer* layer = (createFunctions[sceneIdx])(); + layer->autorelease(); + + return layer; +} + +Layer* restartMotionAction() +{ + Layer* layer = (createFunctions[sceneIdx])(); + layer->autorelease(); + + return layer; +} //------------------------------------------------------------------ // // MotionStreakTest1 @@ -24,12 +66,12 @@ void MotionStreakTest1::onEnter() Size s = Director::getInstance()->getWinSize(); // the root object just rotates around - _root = Sprite::create(s_pPathR1); + _root = Sprite::create(s_pathR1); addChild(_root, 1); _root->setPosition(Point(s.width/2, s.height/2)); // the target object is offset from root, and the streak is moved to follow it - _target = Sprite::create(s_pPathR1); + _target = Sprite::create(s_pathR1); _root->addChild(_target); _target->setPosition(Point(s.width/4, 0)); @@ -151,62 +193,6 @@ std::string Issue1358::subtitle() // //------------------------------------------------------------------ -// enum -// { -// IDC_NEXT = 100, -// IDC_BACK, -// IDC_RESTART -// }; - -static int sceneIdx = -1; - -#define MAX_LAYER 3 - -Layer* createMotionLayer(int nIndex) -{ - switch(nIndex) - { - case 0: return new MotionStreakTest1(); - case 1: return new MotionStreakTest2(); - case 2: return new Issue1358(); - } - - return NULL; -} - -Layer* nextMotionAction() -{ - sceneIdx++; - sceneIdx = sceneIdx % MAX_LAYER; - - Layer* pLayer = createMotionLayer(sceneIdx); - pLayer->autorelease(); - - return pLayer; -} - -Layer* backMotionAction() -{ - sceneIdx--; - int total = MAX_LAYER; - if( sceneIdx < 0 ) - sceneIdx += total; - - Layer* pLayer = createMotionLayer(sceneIdx); - pLayer->autorelease(); - - return pLayer; -} - -Layer* restartMotionAction() -{ - Layer* pLayer = createMotionLayer(sceneIdx); - pLayer->autorelease(); - - return pLayer; -} - - MotionStreakTest::MotionStreakTest(void) { } @@ -275,8 +261,8 @@ void MotionStreakTest::backCallback(Object* pSender) void MotionStreakTestScene::runThisTest() { - Layer* pLayer = nextMotionAction(); - addChild(pLayer); + Layer* 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 84a0ed9caf..c58e0944f2 100644 --- a/samples/Cpp/TestCpp/Classes/MutiTouchTest/MutiTouchTest.cpp +++ b/samples/Cpp/TestCpp/Classes/MutiTouchTest/MutiTouchTest.cpp @@ -117,9 +117,9 @@ void MutiTouchTestLayer::ccTouchesCancelled(Set *pTouches, Event *pEvent) void MutiTouchTestScene::runThisTest() { - MutiTouchTestLayer* pLayer = MutiTouchTestLayer::create(); + MutiTouchTestLayer* layer = MutiTouchTestLayer::create(); - addChild(pLayer, 0); + addChild(layer, 0); Director::getInstance()->replaceScene(this); } diff --git a/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.cpp b/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.cpp index 04fd99bf30..c16bee5a37 100644 --- a/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.cpp +++ b/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.cpp @@ -52,10 +52,10 @@ Layer* nextCocosNodeAction() sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - Layer* pLayer = createCocosNodeLayer(sceneIdx); - pLayer->autorelease(); + Layer* layer = createCocosNodeLayer(sceneIdx); + layer->autorelease(); - return pLayer; + return layer; } Layer* backCocosNodeAction() @@ -65,18 +65,18 @@ Layer* backCocosNodeAction() if( sceneIdx < 0 ) sceneIdx += total; - Layer* pLayer = createCocosNodeLayer(sceneIdx); - pLayer->autorelease(); + Layer* layer = createCocosNodeLayer(sceneIdx); + layer->autorelease(); - return pLayer; + return layer; } Layer* restartCocosNodeAction() { - Layer* pLayer = createCocosNodeLayer(sceneIdx); - pLayer->autorelease(); + Layer* layer = createCocosNodeLayer(sceneIdx); + layer->autorelease(); - return pLayer; + return layer; } @@ -140,10 +140,10 @@ void Test2::onEnter() Size s = Director::getInstance()->getWinSize(); - Sprite *sp1 = Sprite::create(s_pPathSister1); - Sprite *sp2 = Sprite::create(s_pPathSister2); - Sprite *sp3 = Sprite::create(s_pPathSister1); - Sprite *sp4 = Sprite::create(s_pPathSister2); + Sprite *sp1 = Sprite::create(s_pathSister1); + Sprite *sp2 = Sprite::create(s_pathSister2); + Sprite *sp3 = Sprite::create(s_pathSister1); + Sprite *sp4 = Sprite::create(s_pathSister2); sp1->setPosition(Point(100, s.height /2 )); sp2->setPosition(Point(380, s.height /2 )); @@ -189,8 +189,8 @@ std::string Test2::title() Test4::Test4() { - Sprite *sp1 = Sprite::create(s_pPathSister1); - Sprite *sp2 = Sprite::create(s_pPathSister2); + Sprite *sp1 = Sprite::create(s_pathSister1); + Sprite *sp2 = Sprite::create(s_pathSister2); sp1->setPosition( Point(100,160) ); sp2->setPosition( Point(380,160) ); @@ -228,8 +228,8 @@ std::string Test4::title() //------------------------------------------------------------------ Test5::Test5() { - Sprite* sp1 = Sprite::create(s_pPathSister1); - Sprite* sp2 = Sprite::create(s_pPathSister2); + Sprite* sp1 = Sprite::create(s_pathSister1); + Sprite* sp2 = Sprite::create(s_pathSister2); sp1->setPosition(Point(100,160)); sp2->setPosition(Point(380,160)); @@ -280,11 +280,11 @@ std::string Test5::title() //------------------------------------------------------------------ Test6::Test6() { - Sprite* sp1 = Sprite::create(s_pPathSister1); - Sprite* sp11 = Sprite::create(s_pPathSister1); + Sprite* sp1 = Sprite::create(s_pathSister1); + Sprite* sp11 = Sprite::create(s_pathSister1); - Sprite* sp2 = Sprite::create(s_pPathSister2); - Sprite* sp21 = Sprite::create(s_pPathSister2); + Sprite* sp2 = Sprite::create(s_pathSister2); + Sprite* sp21 = Sprite::create(s_pathSister2); sp1->setPosition(Point(100,160)); sp2->setPosition(Point(380,160)); @@ -343,7 +343,7 @@ StressTest1::StressTest1() { Size s = Director::getInstance()->getWinSize(); - Sprite *sp1 = Sprite::create(s_pPathSister1); + Sprite *sp1 = Sprite::create(s_pathSister1); addChild(sp1, 0, kTagSprite1); sp1->setPosition( Point(s.width/2, s.height/2) ); @@ -398,7 +398,7 @@ StressTest2::StressTest2() Layer* sublayer = Layer::create(); - Sprite *sp1 = Sprite::create(s_pPathSister1); + Sprite *sp1 = Sprite::create(s_pathSister1); sp1->setPosition( Point(80, s.height/2) ); ActionInterval* move = MoveBy::create(3, Point(350,0)); @@ -536,7 +536,7 @@ CameraOrbitTest::CameraOrbitTest() // LEFT s = p->getContentSize(); - sprite = Sprite::create(s_pPathGrossini); + sprite = Sprite::create(s_pathGrossini); sprite->setScale(0.5f); p->addChild(sprite, 0); sprite->setPosition( Point(s.width/4*1, s.height/2) ); @@ -544,7 +544,7 @@ CameraOrbitTest::CameraOrbitTest() sprite->runAction( RepeatForever::create( orbit ) ); // CENTER - sprite = Sprite::create(s_pPathGrossini); + sprite = Sprite::create(s_pathGrossini); sprite->setScale( 1.0f ); p->addChild(sprite, 0); sprite->setPosition( Point(s.width/4*2, s.height/2) ); @@ -553,7 +553,7 @@ CameraOrbitTest::CameraOrbitTest() // RIGHT - sprite = Sprite::create(s_pPathGrossini); + sprite = Sprite::create(s_pathGrossini); sprite->setScale( 2.0f ); p->addChild(sprite, 0); sprite->setPosition( Point(s.width/4*3, s.height/2) ); @@ -601,7 +601,7 @@ CameraZoomTest::CameraZoomTest() Camera *cam; // LEFT - sprite = Sprite::create(s_pPathGrossini); + sprite = Sprite::create(s_pathGrossini); addChild( sprite, 0); sprite->setPosition( Point(s.width/4*1, s.height/2) ); cam = sprite->getCamera(); @@ -609,12 +609,12 @@ CameraZoomTest::CameraZoomTest() cam->setCenterXYZ(0, 0, 0); // CENTER - sprite = Sprite::create(s_pPathGrossini); + sprite = Sprite::create(s_pathGrossini); addChild( sprite, 0, 40); sprite->setPosition(Point(s.width/4*2, s.height/2)); // RIGHT - sprite = Sprite::create(s_pPathGrossini); + sprite = Sprite::create(s_pathGrossini); addChild( sprite, 0, 20); sprite->setPosition(Point(s.width/4*3, s.height/2)); @@ -841,8 +841,8 @@ std::string NodeNonOpaqueTest::subtitle() void CocosNodeTestScene::runThisTest() { - Layer* pLayer = nextCocosNodeAction(); - addChild(pLayer); + Layer* 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 05b1681f54..0ede68f9cf 100644 --- a/samples/Cpp/TestCpp/Classes/ParallaxTest/ParallaxTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ParallaxTest/ParallaxTest.cpp @@ -173,10 +173,10 @@ Layer* nextParallaxAction() sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - Layer* pLayer = createParallaxTestLayer(sceneIdx); - pLayer->autorelease(); + Layer* layer = createParallaxTestLayer(sceneIdx); + layer->autorelease(); - return pLayer; + return layer; } Layer* backParallaxAction() @@ -186,18 +186,18 @@ Layer* backParallaxAction() if( sceneIdx < 0 ) sceneIdx += total; - Layer* pLayer = createParallaxTestLayer(sceneIdx); - pLayer->autorelease(); + Layer* layer = createParallaxTestLayer(sceneIdx); + layer->autorelease(); - return pLayer; + return layer; } Layer* restartParallaxAction() { - Layer* pLayer = createParallaxTestLayer(sceneIdx); - pLayer->autorelease(); + Layer* layer = createParallaxTestLayer(sceneIdx); + layer->autorelease(); - return pLayer; + return layer; } @@ -246,8 +246,8 @@ void ParallaxDemo::backCallback(Object* pSender) void ParallaxTestScene::runThisTest() { - Layer* pLayer = nextParallaxAction(); + Layer* layer = nextParallaxAction(); - addChild(pLayer); + 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 a6450c220f..4236714244 100644 --- a/samples/Cpp/TestCpp/Classes/ParticleTest/ParticleTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ParticleTest/ParticleTest.cpp @@ -1033,10 +1033,10 @@ Layer* nextParticleAction() sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - Layer* pLayer = createParticleLayer(sceneIdx); - pLayer->autorelease(); + Layer* layer = createParticleLayer(sceneIdx); + layer->autorelease(); - return pLayer; + return layer; } Layer* backParticleAction() @@ -1046,18 +1046,18 @@ Layer* backParticleAction() if( sceneIdx < 0 ) sceneIdx += total; - Layer* pLayer = createParticleLayer(sceneIdx); - pLayer->autorelease(); + Layer* layer = createParticleLayer(sceneIdx); + layer->autorelease(); - return pLayer; + return layer; } Layer* restartParticleAction() { - Layer* pLayer = createParticleLayer(sceneIdx); - pLayer->autorelease(); + Layer* layer = createParticleLayer(sceneIdx); + layer->autorelease(); - return pLayer; + return layer; } ParticleDemo::~ParticleDemo(void) @@ -1240,7 +1240,7 @@ void ParticleBatchHybrid::switchRender(float dt) Node *newParent = (usingBatch ? _parent2 : _parent1 ); newParent->addChild(_emitter); - CCLog("Particle: Using new parent: %s", usingBatch ? "CCNode" : "CCParticleBatchNode"); + log("Particle: Using new parent: %s", usingBatch ? "CCNode" : "CCParticleBatchNode"); } std::string ParticleBatchHybrid::title() @@ -1867,7 +1867,7 @@ void PremultipliedAlphaTest::onEnter() BlendFunc tBlendFunc = { GL_ONE, GL_ONE_MINUS_SRC_ALPHA }; _emitter->setBlendFunc(tBlendFunc); - CCASSERT(_emitter->getOpacityModifyRGB(), "Particle texture does not have premultiplied alpha, test is useless"); + CCASSERT(_emitter->isOpacityModifyRGB(), "Particle texture does not have premultiplied alpha, test is useless"); // Toggle next line to see old behavior // this->emitter.opacityModifyRGB = NO; diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp index 384c08c84c..c19375df07 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp @@ -31,34 +31,34 @@ NodeChildrenMenuLayer::NodeChildrenMenuLayer(bool bControlMenuVisible, int nMaxC void NodeChildrenMenuLayer::showCurrentTest() { int nNodes = ((NodeChildrenMainScene*)getParent())->getQuantityOfNodes(); - NodeChildrenMainScene* pScene = NULL; + NodeChildrenMainScene* scene = NULL; switch (_curCase) { // case 0: -// pScene = new IterateSpriteSheetFastEnum(); +// scene = new IterateSpriteSheetFastEnum(); // break; case 0: - pScene = new IterateSpriteSheetCArray(); + scene = new IterateSpriteSheetCArray(); break; case 1: - pScene = new AddSpriteSheet(); + scene = new AddSpriteSheet(); break; case 2: - pScene = new RemoveSpriteSheet(); + scene = new RemoveSpriteSheet(); break; case 3: - pScene = new ReorderSpriteSheet(); + scene = new ReorderSpriteSheet(); break; } s_nCurCase = _curCase; - if (pScene) + if (scene) { - pScene->initWithQuantityOfNodes(nNodes); + scene->initWithQuantityOfNodes(nNodes); - Director::getInstance()->replaceScene(pScene); - pScene->release(); + Director::getInstance()->replaceScene(scene); + scene->release(); } } @@ -121,9 +121,9 @@ void NodeChildrenMainScene::initWithQuantityOfNodes(unsigned int nNodes) infoLabel->setPosition(Point(s.width/2, s.height/2-15)); addChild(infoLabel, 1, kTagInfoLayer); - NodeChildrenMenuLayer* pMenu = new NodeChildrenMenuLayer(true, TEST_COUNT, s_nCurCase); - addChild(pMenu); - pMenu->release(); + NodeChildrenMenuLayer* menuLayer = new NodeChildrenMenuLayer(true, TEST_COUNT, s_nCurCase); + addChild(menuLayer); + menuLayer->release(); updateQuantityLabel(); updateQuantityOfNodes(); @@ -220,8 +220,8 @@ void IterateSpriteSheetFastEnum::update(float dt) CCARRAY_FOREACH(pChildren, pObject) { - Sprite* pSprite = static_cast(pObject); - pSprite->setVisible(false); + Sprite* sprite = static_cast(pObject); + sprite->setVisible(false); } CC_PROFILER_STOP_INSTANCE(this, this->profilerName()); @@ -257,8 +257,8 @@ void IterateSpriteSheetCArray::update(float dt) CCARRAY_FOREACH(pChildren, pObject) { - Sprite* pSprite = static_cast(pObject); - pSprite->setVisible(false); + Sprite* sprite = static_cast(pObject); + sprite->setVisible(false); } CC_PROFILER_STOP(this->profilerName()); @@ -349,13 +349,13 @@ void AddSpriteSheet::update(float dt) if( totalToAdd > 0 ) { Array* sprites = Array::createWithCapacity(totalToAdd); - int *zs = new int[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(pSprite); + Sprite* sprite = Sprite::createWithTexture(batchNode->getTexture(), Rect(0,0,32,32)); + sprites->addObject(sprite); zs[i] = CCRANDOM_MINUS1_1() * 50; } @@ -415,8 +415,8 @@ void RemoveSpriteSheet::update(float dt) // Don't include the sprite creation time as part of the profiling for(int i=0;igetTexture(), Rect(0,0,32,32)); - sprites->addObject(pSprite); + Sprite* sprite = Sprite::createWithTexture(batchNode->getTexture(), Rect(0,0,32,32)); + sprites->addObject(sprite); } // add them with random Z (very important!) @@ -469,10 +469,10 @@ void ReorderSpriteSheet::update(float dt) Array* 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)); - sprites->addObject(pSprite); + Sprite* sprite = Sprite::createWithTexture(batchNode->getTexture(), Rect(0,0,32,32)); + sprites->addObject(sprite); } // add them with random Z (very important!) @@ -488,8 +488,8 @@ void ReorderSpriteSheet::update(float dt) for( int i=0;i < totalToAdd;i++) { - Node* pNode = (Node*) (batchNode->getChildren()->objectAtIndex(i)); - batchNode->reorderChild(pNode, CCRANDOM_MINUS1_1() * 50); + Node* node = (Node*) (batchNode->getChildren()->objectAtIndex(i)); + batchNode->reorderChild(node, CCRANDOM_MINUS1_1() * 50); } batchNode->sortAllChildren(); @@ -520,9 +520,9 @@ const char* ReorderSpriteSheet::profilerName() void runNodeChildrenTest() { - IterateSpriteSheet* pScene = new IterateSpriteSheetCArray(); - pScene->initWithQuantityOfNodes(kNodesIncrease); + IterateSpriteSheet* scene = new IterateSpriteSheetCArray(); + scene->initWithQuantityOfNodes(kNodesIncrease); - Director::getInstance()->replaceScene(pScene); - pScene->release(); + Director::getInstance()->replaceScene(scene); + scene->release(); } diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceParticleTest.cpp b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceParticleTest.cpp index a7ee8874c2..a70b5c1d08 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceParticleTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceParticleTest.cpp @@ -31,9 +31,9 @@ ParticleMenuLayer::ParticleMenuLayer(bool bControlMenuVisible, int nMaxCases, in void ParticleMenuLayer::showCurrentTest() { - ParticleMainScene* pScene = (ParticleMainScene*)getParent(); - int subTest = pScene->getSubTestNum(); - int parNum = pScene->getParticlesNum(); + ParticleMainScene* scene = (ParticleMainScene*)getParent(); + int subTest = scene->getSubTestNum(); + int parNum = scene->getParticlesNum(); ParticleMainScene* pNewScene = NULL; @@ -114,9 +114,9 @@ void ParticleMainScene::initWithSubTest(int asubtest, int particles) labelAtlas->setPosition(Point(s.width-66,50)); // Next Prev Test - ParticleMenuLayer* pMenu = new ParticleMenuLayer(true, TEST_COUNT, s_nParCurIdx); - addChild(pMenu, 1, kTagMenuLayer); - pMenu->release(); + ParticleMenuLayer* menuLayer = new ParticleMenuLayer(true, TEST_COUNT, s_nParCurIdx); + addChild(menuLayer, 1, kTagMenuLayer); + menuLayer->release(); // Sub Tests MenuItemFont::setFontSize(40); @@ -259,8 +259,8 @@ void ParticleMainScene::testNCallback(Object* pSender) { subtestNumber = ((Node*)pSender)->getTag(); - ParticleMenuLayer* pMenu = (ParticleMenuLayer*)getChildByTag(kTagMenuLayer); - pMenu->restartCallback(pSender); + ParticleMenuLayer* menu = (ParticleMenuLayer*)getChildByTag(kTagMenuLayer); + menu->restartCallback(pSender); } void ParticleMainScene::updateQuantityLabel() @@ -559,9 +559,9 @@ void ParticlePerformTest4::doTest() void runParticleTest() { - ParticleMainScene* pScene = new ParticlePerformTest1; - pScene->initWithSubTest(1, kNodesIncrease); + ParticleMainScene* scene = new ParticlePerformTest1; + scene->initWithSubTest(1, kNodesIncrease); - Director::getInstance()->replaceScene(pScene); - pScene->release(); + Director::getInstance()->replaceScene(scene); + scene->release(); } diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceSpriteTest.cpp b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceSpriteTest.cpp index a6c769daa5..1777c1aa72 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceSpriteTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceSpriteTest.cpp @@ -229,7 +229,7 @@ void SubTest::removeByTag(int tag) //////////////////////////////////////////////////////// void SpriteMenuLayer::showCurrentTest() { - SpriteMainScene* pScene = NULL; + SpriteMainScene* scene = NULL; SpriteMainScene* pPreScene = (SpriteMainScene*) getParent(); int nSubTest = pPreScene->getSubTestNum(); int nNodes = pPreScene->getNodesNum(); @@ -237,34 +237,34 @@ void SpriteMenuLayer::showCurrentTest() switch (_curCase) { case 0: - pScene = new SpritePerformTest1; + scene = new SpritePerformTest1; break; case 1: - pScene = new SpritePerformTest2; + scene = new SpritePerformTest2; break; case 2: - pScene = new SpritePerformTest3; + scene = new SpritePerformTest3; break; case 3: - pScene = new SpritePerformTest4; + scene = new SpritePerformTest4; break; case 4: - pScene = new SpritePerformTest5; + scene = new SpritePerformTest5; break; case 5: - pScene = new SpritePerformTest6; + scene = new SpritePerformTest6; break; case 6: - pScene = new SpritePerformTest7; + scene = new SpritePerformTest7; break; } s_nSpriteCurCase = _curCase; - if (pScene) + if (scene) { - pScene->initWithSubTest(nSubTest, nNodes); - Director::getInstance()->replaceScene(pScene); - pScene->release(); + scene->initWithSubTest(nSubTest, nNodes); + Director::getInstance()->replaceScene(scene); + scene->release(); } } @@ -303,20 +303,20 @@ void SpriteMainScene::initWithSubTest(int asubtest, int nNodes) addChild(infoLabel, 1, kTagInfoLayer); // add menu - SpriteMenuLayer* pMenu = new SpriteMenuLayer(true, TEST_COUNT, s_nSpriteCurCase); - addChild(pMenu, 1, kTagMenuLayer); - pMenu->release(); + SpriteMenuLayer* menuLayer = new SpriteMenuLayer(true, TEST_COUNT, s_nSpriteCurCase); + addChild(menuLayer, 1, kTagMenuLayer); + menuLayer->release(); // Sub Tests MenuItemFont::setFontSize(32); - Menu* pSubMenu = Menu::create(); + Menu* 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)); itemFont->setTag(i); - pSubMenu->addChild(itemFont, 10); + subMenu->addChild(itemFont, 10); if( i<= 3) itemFont->setColor(Color3B(200,20,20)); @@ -326,9 +326,9 @@ void SpriteMainScene::initWithSubTest(int asubtest, int nNodes) itemFont->setColor(Color3B(0,20,200)); } - pSubMenu->alignItemsHorizontally(); - pSubMenu->setPosition(Point(s.width/2, 80)); - addChild(pSubMenu, 2); + subMenu->alignItemsHorizontally(); + subMenu->setPosition(Point(s.width/2, 80)); + addChild(subMenu, 2); // add title label LabelTTF *label = LabelTTF::create(title().c_str(), "Arial", 40); @@ -357,8 +357,8 @@ SpriteMainScene::~SpriteMainScene() void SpriteMainScene::testNCallback(Object* pSender) { subtestNumber = ((MenuItemFont*) pSender)->getTag(); - SpriteMenuLayer* pMenu = (SpriteMenuLayer*)getChildByTag(kTagMenuLayer); - pMenu->restartCallback(pSender); + SpriteMenuLayer* menu = (SpriteMenuLayer*)getChildByTag(kTagMenuLayer); + menu->restartCallback(pSender); } void SpriteMainScene::updateNodes() @@ -408,77 +408,77 @@ void SpriteMainScene::onDecrease(Object* pSender) // For test functions // //////////////////////////////////////////////////////// -void performanceActions(Sprite* pSprite) +void performanceActions(Sprite* sprite) { Size size = Director::getInstance()->getWinSize(); - pSprite->setPosition(Point((rand() % (int)size.width), (rand() % (int)size.height))); + 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)); - pSprite->runAction(permanentRotation); + 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)); - pSprite->runAction(permanentScaleLoop); + sprite->runAction(permanentScaleLoop); } -void performanceActions20(Sprite* pSprite) +void performanceActions20(Sprite* sprite) { Size size = Director::getInstance()->getWinSize(); if( CCRANDOM_0_1() < 0.2f ) - pSprite->setPosition(Point((rand() % (int)size.width), (rand() % (int)size.height))); + sprite->setPosition(Point((rand() % (int)size.width), (rand() % (int)size.height))); else - pSprite->setPosition(Point( -1000, -1000)); + 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)); - pSprite->runAction(permanentRotation); + 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())); - pSprite->runAction(permanentScaleLoop); + sprite->runAction(permanentScaleLoop); } -void performanceRotationScale(Sprite* pSprite) +void performanceRotationScale(Sprite* sprite) { Size size = Director::getInstance()->getWinSize(); - pSprite->setPosition(Point((rand() % (int)size.width), (rand() % (int)size.height))); - pSprite->setRotation(CCRANDOM_0_1() * 360); - pSprite->setScale(CCRANDOM_0_1() * 2); + sprite->setPosition(Point((rand() % (int)size.width), (rand() % (int)size.height))); + sprite->setRotation(CCRANDOM_0_1() * 360); + sprite->setScale(CCRANDOM_0_1() * 2); } -void performancePosition(Sprite* pSprite) +void performancePosition(Sprite* sprite) { Size size = Director::getInstance()->getWinSize(); - pSprite->setPosition(Point((rand() % (int)size.width), (rand() % (int)size.height))); + sprite->setPosition(Point((rand() % (int)size.width), (rand() % (int)size.height))); } -void performanceout20(Sprite* pSprite) +void performanceout20(Sprite* sprite) { Size size = Director::getInstance()->getWinSize(); if( CCRANDOM_0_1() < 0.2f ) - pSprite->setPosition(Point((rand() % (int)size.width), (rand() % (int)size.height))); + sprite->setPosition(Point((rand() % (int)size.width), (rand() % (int)size.height))); else - pSprite->setPosition(Point( -1000, -1000)); + sprite->setPosition(Point( -1000, -1000)); } -void performanceOut100(Sprite* pSprite) +void performanceOut100(Sprite* sprite) { - pSprite->setPosition(Point( -1000, -1000)); + sprite->setPosition(Point( -1000, -1000)); } -void performanceScale(Sprite* pSprite) +void performanceScale(Sprite* sprite) { Size size = Director::getInstance()->getWinSize(); - pSprite->setPosition(Point((rand() % (int)size.width), (rand() % (int)size.height))); - pSprite->setScale(CCRANDOM_0_1() * 100 / 50); + sprite->setPosition(Point((rand() % (int)size.width), (rand() % (int)size.height))); + sprite->setScale(CCRANDOM_0_1() * 100 / 50); } //////////////////////////////////////////////////////// @@ -609,8 +609,8 @@ void SpritePerformTest7::doTest(Sprite* sprite) void runSpriteTest() { - SpriteMainScene* pScene = new SpritePerformTest1; - pScene->initWithSubTest(1, 50); - Director::getInstance()->replaceScene(pScene); - pScene->release(); + SpriteMainScene* 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 50f71542dc..4f852ad552 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceTest.cpp @@ -37,18 +37,18 @@ void PerformanceMainLayer::onEnter() Size s = Director::getInstance()->getWinSize(); - Menu* pMenu = Menu::create(); - pMenu->setPosition( Point::ZERO ); + Menu* 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); pItem->setPosition(Point(s.width / 2, s.height - (i + 1) * LINE_SPACE)); - pMenu->addChild(pItem, kItemTagBasic + i); + menu->addChild(pItem, kItemTagBasic + i); } - addChild(pMenu); + addChild(menu); } //////////////////////////////////////////////////////// @@ -72,31 +72,31 @@ void PerformBasicLayer::onEnter() MenuItemFont::setFontSize(24); MenuItemFont* pMainItem = MenuItemFont::create("Back", CC_CALLBACK_1(PerformBasicLayer::toMainLayer, this)); pMainItem->setPosition(Point(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25)); - Menu* pMenu = Menu::create(pMainItem, NULL); - pMenu->setPosition( Point::ZERO ); + Menu* menu = Menu::create(pMainItem, NULL); + menu->setPosition( Point::ZERO ); if (_controlMenuVisible) { - MenuItemImage *item1 = MenuItemImage::create(s_pPathB1, s_pPathB2, CC_CALLBACK_1(PerformBasicLayer::backCallback, this)); - MenuItemImage *item2 = MenuItemImage::create(s_pPathR1, s_pPathR2, CC_CALLBACK_1(PerformBasicLayer::restartCallback, this)); - MenuItemImage *item3 = MenuItemImage::create(s_pPathF1, s_pPathF2, CC_CALLBACK_1(PerformBasicLayer::nextCallback, this)); + 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)); 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)); - pMenu->addChild(item1, kItemTagBasic); - pMenu->addChild(item2, kItemTagBasic); - pMenu->addChild(item3, kItemTagBasic); + menu->addChild(item1, kItemTagBasic); + menu->addChild(item2, kItemTagBasic); + menu->addChild(item3, kItemTagBasic); } - addChild(pMenu); + addChild(menu); } void PerformBasicLayer::toMainLayer(Object* pSender) { - PerformanceTestScene* pScene = new PerformanceTestScene(); - pScene->runThisTest(); + PerformanceTestScene* scene = new PerformanceTestScene(); + scene->runThisTest(); - pScene->release(); + scene->release(); } void PerformBasicLayer::restartCallback(Object* pSender) @@ -129,9 +129,9 @@ void PerformBasicLayer::backCallback(Object* pSender) void PerformanceTestScene::runThisTest() { - Layer* pLayer = new PerformanceMainLayer(); - addChild(pLayer); - pLayer->release(); + Layer* layer = new PerformanceMainLayer(); + addChild(layer); + layer->release(); Director::getInstance()->replaceScene(this); } diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceTextureTest.cpp b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceTextureTest.cpp index 7abd8101ca..3abf1fb776 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceTextureTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceTextureTest.cpp @@ -25,19 +25,19 @@ float calculateDeltaTime( struct timeval *lastUpdate ) //////////////////////////////////////////////////////// void TextureMenuLayer::showCurrentTest() { - Scene* pScene = NULL; + Scene* scene = NULL; switch (_curCase) { case 0: - pScene = TextureTest::scene(); + scene = TextureTest::scene(); break; } s_nTexCurCase = _curCase; - if (pScene) + if (scene) { - Director::getInstance()->replaceScene(pScene); + Director::getInstance()->replaceScene(scene); } } @@ -86,44 +86,44 @@ void TextureTest::performTestsPNG(const char* filename) Texture2D *texture; TextureCache *cache = TextureCache::getInstance(); - CCLog("RGBA 8888"); + log("RGBA 8888"); Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA8888); gettimeofday(&now, NULL); texture = cache->addImage(filename); if( texture ) - CCLog(" ms:%f", calculateDeltaTime(&now) ); + log(" ms:%f", calculateDeltaTime(&now) ); else - CCLog(" ERROR"); + log(" ERROR"); cache->removeTexture(texture); - CCLog("RGBA 4444"); + log("RGBA 4444"); Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA4444); gettimeofday(&now, NULL); texture = cache->addImage(filename); if( texture ) - CCLog(" ms:%f", calculateDeltaTime(&now) ); + log(" ms:%f", calculateDeltaTime(&now) ); else - CCLog(" ERROR"); + log(" ERROR"); cache->removeTexture(texture); - CCLog("RGBA 5551"); + log("RGBA 5551"); Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGB5A1); gettimeofday(&now, NULL); texture = cache->addImage(filename); if( texture ) - CCLog(" ms:%f", calculateDeltaTime(&now) ); + log(" ms:%f", calculateDeltaTime(&now) ); else - CCLog(" ERROR"); + log(" ERROR"); cache->removeTexture(texture); - CCLog("RGB 565"); + log("RGB 565"); Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGB565); gettimeofday(&now, NULL); texture = cache->addImage(filename); if( texture ) - CCLog(" ms:%f", calculateDeltaTime(&now) ); + log(" ms:%f", calculateDeltaTime(&now) ); else - CCLog(" ERROR"); + log(" ERROR"); cache->removeTexture(texture); } @@ -133,60 +133,60 @@ void TextureTest::performTests() // struct timeval now; // TextureCache *cache = TextureCache::getInstance(); - CCLog("--------"); + log("--------"); - CCLog("--- PNG 128x128 ---"); + log("--- PNG 128x128 ---"); performTestsPNG("Images/test_image.png"); -// CCLog("--- PVR 128x128 ---"); -// CCLog("RGBA 8888"); +// log("--- PVR 128x128 ---"); +// log("RGBA 8888"); // gettimeofday(&now, NULL); // texture = cache->addImage("Images/test_image_rgba8888.pvr"); // if( texture ) -// CCLog(" ms:%f", calculateDeltaTime(&now) ); +// log(" ms:%f", calculateDeltaTime(&now) ); // else -// CCLog("ERROR"); +// log("ERROR"); // cache->removeTexture(texture); // -// CCLog("BGRA 8888"); +// log("BGRA 8888"); // gettimeofday(&now, NULL); // texture = cache->addImage("Images/test_image_bgra8888.pvr"); // if( texture ) -// CCLog(" ms:%f", calculateDeltaTime(&now) ); +// log(" ms:%f", calculateDeltaTime(&now) ); // else -// CCLog("ERROR"); +// log("ERROR"); // cache->removeTexture(texture); // -// CCLog("RGBA 4444"); +// log("RGBA 4444"); // gettimeofday(&now, NULL); // texture = cache->addImage("Images/test_image_rgba4444.pvr"); // if( texture ) -// CCLog(" ms:%f", calculateDeltaTime(&now) ); +// log(" ms:%f", calculateDeltaTime(&now) ); // else -// CCLog("ERROR"); +// log("ERROR"); // cache->removeTexture(texture); // -// CCLog("RGB 565"); +// log("RGB 565"); // gettimeofday(&now, NULL); // texture = cache->addImage("Images/test_image_rgb565.pvr"); // if( texture ) -// CCLog(" ms:%f", calculateDeltaTime(&now) ); +// log(" ms:%f", calculateDeltaTime(&now) ); // else -// CCLog("ERROR"); +// log("ERROR"); // cache->removeTexture(texture); - CCLog("--- PNG 512x512 ---"); + log("--- PNG 512x512 ---"); performTestsPNG("Images/texture512x512.png"); -// CCLog("--- PVR 512x512 ---"); -// CCLog("RGBA 4444"); +// log("--- PVR 512x512 ---"); +// log("RGBA 4444"); // gettimeofday(&now, NULL); // texture = cache->addImage("Images/texture512x512_rgba4444.pvr"); // if( texture ) -// CCLog(" ms:%f", calculateDeltaTime(&now) ); +// log(" ms:%f", calculateDeltaTime(&now) ); // else -// CCLog("ERROR"); +// log("ERROR"); // cache->removeTexture(texture); // @@ -195,38 +195,38 @@ void TextureTest::performTests() // Empty image // - CCLog("EMPTY IMAGE"); - CCLog("--- PNG 1024x1024 ---"); + log("EMPTY IMAGE"); + log("--- PNG 1024x1024 ---"); performTestsPNG("Images/texture1024x1024.png"); -// CCLog("--- PVR 1024x1024 ---"); -// CCLog("RGBA 4444"); +// log("--- PVR 1024x1024 ---"); +// log("RGBA 4444"); // gettimeofday(&now, NULL); // texture = cache->addImage("Images/texture1024x1024_rgba4444.pvr"); // if( texture ) -// CCLog(" ms:%f", calculateDeltaTime(&now) ); +// log(" ms:%f", calculateDeltaTime(&now) ); // else -// CCLog("ERROR"); +// log("ERROR"); // cache->removeTexture(texture); // -// CCLog("--- PVR.GZ 1024x1024 ---"); -// CCLog("RGBA 4444"); +// log("--- PVR.GZ 1024x1024 ---"); +// log("RGBA 4444"); // gettimeofday(&now, NULL); // texture = cache->addImage("Images/texture1024x1024_rgba4444.pvr.gz"); // if( texture ) -// CCLog(" ms:%f", calculateDeltaTime(&now) ); +// log(" ms:%f", calculateDeltaTime(&now) ); // else -// CCLog("ERROR"); +// log("ERROR"); // cache->removeTexture(texture); // -// CCLog("--- PVR.CCZ 1024x1024 ---"); -// CCLog("RGBA 4444"); +// log("--- PVR.CCZ 1024x1024 ---"); +// log("RGBA 4444"); // gettimeofday(&now, NULL); // texture = cache->addImage("Images/texture1024x1024_rgba4444.pvr.ccz"); // if( texture ) -// CCLog(" ms:%f", calculateDeltaTime(&now) ); +// log(" ms:%f", calculateDeltaTime(&now) ); // else -// CCLog("ERROR"); +// log("ERROR"); // cache->removeTexture(texture); // @@ -235,38 +235,38 @@ void TextureTest::performTests() // SpriteSheet images // - CCLog("SPRITESHEET IMAGE"); - CCLog("--- PNG 1024x1024 ---"); + log("SPRITESHEET IMAGE"); + log("--- PNG 1024x1024 ---"); performTestsPNG("Images/PlanetCute-1024x1024.png"); -// CCLog("--- PVR 1024x1024 ---"); -// CCLog("RGBA 4444"); +// log("--- PVR 1024x1024 ---"); +// log("RGBA 4444"); // gettimeofday(&now, NULL); // texture = cache->addImage("Images/PlanetCute-1024x1024-rgba4444.pvr"); // if( texture ) -// CCLog(" ms:%f", calculateDeltaTime(&now) ); +// log(" ms:%f", calculateDeltaTime(&now) ); // else -// CCLog("ERROR"); +// log("ERROR"); // cache->removeTexture(texture); // -// CCLog("--- PVR.GZ 1024x1024 ---"); -// CCLog("RGBA 4444"); +// log("--- PVR.GZ 1024x1024 ---"); +// log("RGBA 4444"); // gettimeofday(&now, NULL); // texture = cache->addImage("Images/PlanetCute-1024x1024-rgba4444.pvr.gz"); // if( texture ) -// CCLog(" ms:%f", calculateDeltaTime(&now) ); +// log(" ms:%f", calculateDeltaTime(&now) ); // else -// CCLog("ERROR"); +// log("ERROR"); // cache->removeTexture(texture); // -// CCLog("--- PVR.CCZ 1024x1024 ---"); -// CCLog("RGBA 4444"); +// log("--- PVR.CCZ 1024x1024 ---"); +// log("RGBA 4444"); // gettimeofday(&now, NULL); // texture = cache->addImage("Images/PlanetCute-1024x1024-rgba4444.pvr.ccz"); // if( texture ) -// CCLog(" ms:%f", calculateDeltaTime(&now) ); +// log(" ms:%f", calculateDeltaTime(&now) ); // else -// CCLog("ERROR"); +// log("ERROR"); // cache->removeTexture(texture); @@ -276,39 +276,39 @@ void TextureTest::performTests() // Landscape Image // - CCLog("LANDSCAPE IMAGE"); + log("LANDSCAPE IMAGE"); - CCLog("--- PNG 1024x1024 ---"); + log("--- PNG 1024x1024 ---"); performTestsPNG("Images/landscape-1024x1024.png"); -// CCLog("--- PVR 1024x1024 ---"); -// CCLog("RGBA 8888"); +// log("--- PVR 1024x1024 ---"); +// log("RGBA 8888"); // gettimeofday(&now, NULL); // texture = cache->addImage("Images/landscape-1024x1024-rgba8888.pvr"); // if( texture ) -// CCLog(" ms:%f", calculateDeltaTime(&now) ); +// log(" ms:%f", calculateDeltaTime(&now) ); // else -// CCLog("ERROR"); +// log("ERROR"); // cache->removeTexture(texture); // -// CCLog("--- PVR.GZ 1024x1024 ---"); -// CCLog("RGBA 8888"); +// log("--- PVR.GZ 1024x1024 ---"); +// log("RGBA 8888"); // gettimeofday(&now, NULL); // texture = cache->addImage("Images/landscape-1024x1024-rgba8888.pvr.gz"); // if( texture ) -// CCLog(" ms:%f", calculateDeltaTime(&now) ); +// log(" ms:%f", calculateDeltaTime(&now) ); // else -// CCLog("ERROR"); +// log("ERROR"); // cache->removeTexture(texture); // -// CCLog("--- PVR.CCZ 1024x1024 ---"); -// CCLog("RGBA 8888"); +// log("--- PVR.CCZ 1024x1024 ---"); +// log("RGBA 8888"); // gettimeofday(&now, NULL); // texture = cache->addImage("Images/landscape-1024x1024-rgba8888.pvr.ccz"); // if( texture ) -// CCLog(" ms:%f", calculateDeltaTime(&now) ); +// log(" ms:%f", calculateDeltaTime(&now) ); // else -// CCLog("ERROR"); +// log("ERROR"); // cache->removeTexture(texture); @@ -318,17 +318,17 @@ void TextureTest::performTests() // // most platform don't support texture with width/height is 2048 -// CCLog("--- PNG 2048x2048 ---"); +// log("--- PNG 2048x2048 ---"); // performTestsPNG("Images/texture2048x2048.png"); -// CCLog("--- PVR 2048x2048 ---"); -// CCLog("RGBA 4444"); +// log("--- PVR 2048x2048 ---"); +// log("RGBA 4444"); // gettimeofday(&now, NULL); // texture = cache->addImage("Images/texture2048x2048_rgba4444.pvr"); // if( texture ) -// CCLog(" ms:%f", calculateDeltaTime(&now) ); +// log(" ms:%f", calculateDeltaTime(&now) ); // else -// CCLog("ERROR"); +// log("ERROR"); // cache->removeTexture(texture); } @@ -344,17 +344,17 @@ std::string TextureTest::subtitle() Scene* TextureTest::scene() { - Scene *pScene = Scene::create(); + Scene *scene = Scene::create(); TextureTest *layer = new TextureTest(false, TEST_COUNT, s_nTexCurCase); - pScene->addChild(layer); + scene->addChild(layer); layer->release(); - return pScene; + return scene; } void runTextureTest() { s_nTexCurCase = 0; - Scene* pScene = TextureTest::scene(); - Director::getInstance()->replaceScene(pScene); + Scene* 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 aa0656a987..e4166b0ae5 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceTouchesTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceTouchesTest.cpp @@ -14,25 +14,25 @@ static int s_nTouchCurCase = 0; //////////////////////////////////////////////////////// void TouchesMainScene::showCurrentTest() { - Layer* pLayer = NULL; + Layer* layer = NULL; switch (_curCase) { case 0: - pLayer = new TouchesPerformTest1(true, TEST_COUNT, _curCase); + layer = new TouchesPerformTest1(true, TEST_COUNT, _curCase); break; case 1: - pLayer = new TouchesPerformTest2(true, TEST_COUNT, _curCase); + layer = new TouchesPerformTest2(true, TEST_COUNT, _curCase); break; } s_nTouchCurCase = _curCase; - if (pLayer) + if (layer) { - Scene* pScene = Scene::create(); - pScene->addChild(pLayer); - pLayer->release(); + Scene* scene = Scene::create(); + scene->addChild(layer); + layer->release(); - Director::getInstance()->replaceScene(pScene); + Director::getInstance()->replaceScene(scene); } } @@ -99,8 +99,8 @@ std::string TouchesPerformTest1::title() void TouchesPerformTest1::registerWithTouchDispatcher() { - Director* pDirector = Director::getInstance(); - pDirector->getTouchDispatcher()->addTargetedDelegate(this, 0, true); + Director* director = Director::getInstance(); + director->getTouchDispatcher()->addTargetedDelegate(this, 0, true); } bool TouchesPerformTest1::ccTouchBegan(Touch* touch, Event* event) @@ -142,8 +142,8 @@ std::string TouchesPerformTest2::title() void TouchesPerformTest2::registerWithTouchDispatcher() { - Director* pDirector = Director::getInstance(); - pDirector->getTouchDispatcher()->addStandardDelegate(this, 0); + Director* director = Director::getInstance(); + director->getTouchDispatcher()->addStandardDelegate(this, 0); } void TouchesPerformTest2::ccTouchesBegan(Set* touches, Event* event) @@ -168,11 +168,11 @@ void TouchesPerformTest2::ccTouchesCancelled(Set* touches, Event* event) void runTouchesTest() { s_nTouchCurCase = 0; - Scene* pScene = Scene::create(); - Layer* pLayer = new TouchesPerformTest1(true, TEST_COUNT, s_nTouchCurCase); + Scene* scene = Scene::create(); + Layer* layer = new TouchesPerformTest1(true, TEST_COUNT, s_nTouchCurCase); - pScene->addChild(pLayer); - pLayer->release(); + scene->addChild(layer); + layer->release(); - Director::getInstance()->replaceScene(pScene); + Director::getInstance()->replaceScene(scene); } diff --git a/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp b/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp index 294035f4e2..0c9743b3b6 100644 --- a/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp +++ b/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp @@ -23,10 +23,10 @@ static Layer* nextTestCase() sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - Layer* pLayer = (createFunctions[sceneIdx])(); - pLayer->autorelease(); + Layer* layer = (createFunctions[sceneIdx])(); + layer->autorelease(); - return pLayer; + return layer; } static Layer* backTestCase() @@ -36,18 +36,18 @@ static Layer* backTestCase() if( sceneIdx < 0 ) sceneIdx += total; - Layer* pLayer = (createFunctions[sceneIdx])(); - pLayer->autorelease(); + Layer* layer = (createFunctions[sceneIdx])(); + layer->autorelease(); - return pLayer; + return layer; } static Layer* restartTestCase() { - Layer* pLayer = (createFunctions[sceneIdx])(); - pLayer->autorelease(); + Layer* layer = (createFunctions[sceneIdx])(); + layer->autorelease(); - return pLayer; + return layer; } void RenderTextureTest::onEnter() @@ -284,8 +284,8 @@ std::string RenderTextureIssue937::subtitle() void RenderTextureScene::runThisTest() { - Layer* pLayer = nextTestCase(); - addChild(pLayer); + Layer* layer = nextTestCase(); + addChild(layer); Director::getInstance()->replaceScene(this); } diff --git a/samples/Cpp/TestCpp/Classes/RotateWorldTest/RotateWorldTest.cpp b/samples/Cpp/TestCpp/Classes/RotateWorldTest/RotateWorldTest.cpp index b86fb0a359..8cbed145ec 100644 --- a/samples/Cpp/TestCpp/Classes/RotateWorldTest/RotateWorldTest.cpp +++ b/samples/Cpp/TestCpp/Classes/RotateWorldTest/RotateWorldTest.cpp @@ -41,9 +41,9 @@ void SpriteLayer::onEnter() x = size.width; y = size.height; - Sprite* sprite = Sprite::create(s_pPathGrossini); - Sprite* spriteSister1 = Sprite::create(s_pPathSister1); - Sprite* spriteSister2 = Sprite::create(s_pPathSister2); + Sprite* sprite = Sprite::create(s_pathGrossini); + Sprite* spriteSister1 = Sprite::create(s_pathSister1); + Sprite* spriteSister2 = Sprite::create(s_pathSister2); sprite->setScale(1.5f); spriteSister1->setScale(1.5f); @@ -126,9 +126,9 @@ void RotateWorldMainLayer::onEnter() void RotateWorldTestScene::runThisTest() { - Layer* pLayer = RotateWorldMainLayer::create(); + Layer* layer = RotateWorldMainLayer::create(); - addChild(pLayer); + addChild(layer); runAction( RotateBy::create(4, -360) ); Director::getInstance()->replaceScene(this); diff --git a/samples/Cpp/TestCpp/Classes/SceneTest/SceneTest.cpp b/samples/Cpp/TestCpp/Classes/SceneTest/SceneTest.cpp index 0cbaa3351e..018f9ec325 100644 --- a/samples/Cpp/TestCpp/Classes/SceneTest/SceneTest.cpp +++ b/samples/Cpp/TestCpp/Classes/SceneTest/SceneTest.cpp @@ -28,7 +28,7 @@ SceneTestLayer1::SceneTestLayer1() addChild( menu ); Size s = Director::getInstance()->getWinSize(); - Sprite* sprite = Sprite::create(s_pPathGrossini); + Sprite* sprite = Sprite::create(s_pathGrossini); addChild(sprite); sprite->setPosition( Point(s.width-40, s.height/2) ); ActionInterval* rotate = RotateBy::create(2, 360); @@ -63,29 +63,29 @@ SceneTestLayer1::~SceneTestLayer1() void SceneTestLayer1::onPushScene(Object* pSender) { Scene* scene = new SceneTestScene(); - Layer* pLayer = new SceneTestLayer2(); - scene->addChild( pLayer, 0 ); + Layer* layer = new SceneTestLayer2(); + scene->addChild( layer, 0 ); Director::getInstance()->pushScene( scene ); scene->release(); - pLayer->release(); + layer->release(); } void SceneTestLayer1::onPushSceneTran(Object* pSender) { Scene* scene = new SceneTestScene(); - Layer* pLayer = new SceneTestLayer2(); - scene->addChild( pLayer, 0 ); + Layer* layer = new SceneTestLayer2(); + scene->addChild( layer, 0 ); Director::getInstance()->pushScene( TransitionSlideInT::create(1, scene) ); scene->release(); - pLayer->release(); + layer->release(); } void SceneTestLayer1::onQuit(Object* pSender) { //getCocosApp()->exit(); - //CCDirector::getInstance()->popScene(); + //CCDirector::getInstance()->poscene(); //// HA HA... no more terminate on sdk v3.0 //// http://developer.apple.com/iphone/library/qa/qa2008/qa1561.html @@ -113,7 +113,7 @@ SceneTestLayer2::SceneTestLayer2() addChild( menu ); Size s = Director::getInstance()->getWinSize(); - Sprite* sprite = Sprite::create(s_pPathGrossini); + Sprite* sprite = Sprite::create(s_pathGrossini); addChild(sprite); sprite->setPosition( Point(s.width-40, s.height/2) ); ActionInterval* rotate = RotateBy::create(2, 360); @@ -137,21 +137,21 @@ void SceneTestLayer2::onGoBack(Object* pSender) void SceneTestLayer2::onReplaceScene(Object* pSender) { - Scene* pScene = new SceneTestScene(); - Layer* pLayer = SceneTestLayer3::create(); - pScene->addChild( pLayer, 0 ); - Director::getInstance()->replaceScene( pScene ); - pScene->release(); + Scene* scene = new SceneTestScene(); + Layer* layer = SceneTestLayer3::create(); + scene->addChild( layer, 0 ); + Director::getInstance()->replaceScene( scene ); + scene->release(); } void SceneTestLayer2::onReplaceSceneTran(Object* pSender) { - Scene* pScene = new SceneTestScene(); - Layer* pLayer = SceneTestLayer3::create(); - pScene->addChild( pLayer, 0 ); - Director::getInstance()->replaceScene( TransitionFlipX::create(2, pScene) ); - pScene->release(); + Scene* scene = new SceneTestScene(); + Layer* layer = SceneTestLayer3::create(); + scene->addChild( layer, 0 ); + Director::getInstance()->replaceScene( TransitionFlipX::create(2, scene) ); + scene->release(); } //------------------------------------------------------------------ @@ -172,7 +172,7 @@ bool SceneTestLayer3::init() Size s = Director::getInstance()->getWinSize(); MenuItemFont *item0 = MenuItemFont::create("Touch to pushScene (self)", CC_CALLBACK_1(SceneTestLayer3::item0Clicked, this)); - MenuItemFont *item1 = MenuItemFont::create("Touch to popScene", CC_CALLBACK_1(SceneTestLayer3::item1Clicked, 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)); @@ -182,7 +182,7 @@ bool SceneTestLayer3::init() this->schedule(schedule_selector(SceneTestLayer3::testDealloc)); - Sprite* sprite = Sprite::create(s_pPathGrossini); + Sprite* sprite = Sprite::create(s_pathGrossini); addChild(sprite); sprite->setPosition( Point(s.width/2, 40) ); ActionInterval* rotate = RotateBy::create(2, 360); @@ -195,7 +195,7 @@ bool SceneTestLayer3::init() void SceneTestLayer3::testDealloc(float dt) { - CCLog("Layer3:testDealloc"); + log("Layer3:testDealloc"); } void SceneTestLayer3::item0Clicked(Object* pSender) @@ -222,9 +222,9 @@ void SceneTestLayer3::item3Clicked(Object* pSender) void SceneTestScene::runThisTest() { - Layer* pLayer = new SceneTestLayer1(); - addChild(pLayer); - pLayer->release(); + Layer* layer = new SceneTestLayer1(); + addChild(layer); + layer->release(); Director::getInstance()->replaceScene(this); } diff --git a/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.cpp b/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.cpp index 21294e2b3c..b4d8cc5de6 100644 --- a/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.cpp +++ b/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.cpp @@ -54,11 +54,11 @@ Layer* nextSchedulerTest() sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - Layer* pLayer = (createFunctions[sceneIdx])(); - pLayer->init(); - pLayer->autorelease(); + Layer* layer = (createFunctions[sceneIdx])(); + layer->init(); + layer->autorelease(); - return pLayer; + return layer; } Layer* backSchedulerTest() @@ -68,20 +68,20 @@ Layer* backSchedulerTest() if( sceneIdx < 0 ) sceneIdx += total; - Layer* pLayer = (createFunctions[sceneIdx])(); - pLayer->init(); - pLayer->autorelease(); + Layer* layer = (createFunctions[sceneIdx])(); + layer->init(); + layer->autorelease(); - return pLayer; + return layer; } Layer* restartSchedulerTest() { - Layer* pLayer = (createFunctions[sceneIdx])(); - pLayer->init(); - pLayer->autorelease(); + Layer* layer = (createFunctions[sceneIdx])(); + layer->init(); + layer->autorelease(); - return pLayer; + return layer; } //------------------------------------------------------------------ @@ -96,32 +96,32 @@ void SchedulerTestLayer::onEnter() void SchedulerTestLayer::backCallback(Object* pSender) { - Scene* pScene = new SchedulerTestScene(); - Layer* pLayer = backSchedulerTest(); + Scene* scene = new SchedulerTestScene(); + Layer* layer = backSchedulerTest(); - pScene->addChild(pLayer); - Director::getInstance()->replaceScene(pScene); - pScene->release(); + scene->addChild(layer); + Director::getInstance()->replaceScene(scene); + scene->release(); } void SchedulerTestLayer::nextCallback(Object* pSender) { - Scene* pScene = new SchedulerTestScene(); - Layer* pLayer = nextSchedulerTest(); + Scene* scene = new SchedulerTestScene(); + Layer* layer = nextSchedulerTest(); - pScene->addChild(pLayer); - Director::getInstance()->replaceScene(pScene); - pScene->release(); + scene->addChild(layer); + Director::getInstance()->replaceScene(scene); + scene->release(); } void SchedulerTestLayer::restartCallback(Object* pSender) { - Scene* pScene = new SchedulerTestScene(); - Layer* pLayer = restartSchedulerTest(); + Scene* scene = new SchedulerTestScene(); + Layer* layer = restartSchedulerTest(); - pScene->addChild(pLayer); - Director::getInstance()->replaceScene(pScene); - pScene->release(); + scene->addChild(layer); + Director::getInstance()->replaceScene(scene); + scene->release(); } std::string SchedulerTestLayer::title() @@ -261,19 +261,19 @@ void SchedulerPauseResumeAll::onExit() void SchedulerPauseResumeAll::tick1(float dt) { - CCLog("tick1"); + log("tick1"); } void SchedulerPauseResumeAll::tick2(float dt) { - CCLog("tick2"); + log("tick2"); } void SchedulerPauseResumeAll::pause(float dt) { - CCLog("Pausing"); - Director* pDirector = Director::getInstance(); - _pausedTargets = pDirector->getScheduler()->pauseAllTargets(); + log("Pausing"); + Director* director = Director::getInstance(); + _pausedTargets = director->getScheduler()->pauseAllTargets(); CC_SAFE_RETAIN(_pausedTargets); unsigned int c = _pausedTargets->count(); @@ -281,15 +281,15 @@ void SchedulerPauseResumeAll::pause(float dt) if (c > 2) { // should have only 2 items: ActionManager, self - CCLog("Error: pausedTargets should have only 2 items, and not %u", (unsigned int)c); + log("Error: pausedTargets should have only 2 items, and not %u", (unsigned int)c); } } void SchedulerPauseResumeAll::resume(float dt) { - CCLog("Resuming"); - Director* pDirector = Director::getInstance(); - pDirector->getScheduler()->resumeTargets(_pausedTargets); + log("Resuming"); + Director* director = Director::getInstance(); + director->getScheduler()->resumeTargets(_pausedTargets); CC_SAFE_RELEASE_NULL(_pausedTargets); } @@ -347,27 +347,27 @@ void SchedulerPauseResumeAllUser::onExit() void SchedulerPauseResumeAllUser::tick1(float dt) { - CCLog("tick1"); + log("tick1"); } void SchedulerPauseResumeAllUser::tick2(float dt) { - CCLog("tick2"); + log("tick2"); } void SchedulerPauseResumeAllUser::pause(float dt) { - CCLog("Pausing"); - Director* pDirector = Director::getInstance(); - _pausedTargets = pDirector->getScheduler()->pauseAllTargetsWithMinPriority(kPriorityNonSystemMin); + log("Pausing"); + Director* director = Director::getInstance(); + _pausedTargets = director->getScheduler()->pauseAllTargetsWithMinPriority(kPriorityNonSystemMin); CC_SAFE_RETAIN(_pausedTargets); } void SchedulerPauseResumeAllUser::resume(float dt) { - CCLog("Resuming"); - Director* pDirector = Director::getInstance(); - pDirector->getScheduler()->resumeTargets(_pausedTargets); + log("Resuming"); + Director* director = Director::getInstance(); + director->getScheduler()->resumeTargets(_pausedTargets); CC_SAFE_RELEASE_NULL(_pausedTargets); } @@ -635,7 +635,7 @@ TestNode::~TestNode() void TestNode::update(float dt) { CC_UNUSED_PARAM(dt); - CCLog("%s", _pstring->getCString()); + log("%s", _pstring->getCString()); } //------------------------------------------------------------------ @@ -695,17 +695,17 @@ void SchedulerUpdate::onEnter() void SchedulerUpdate::removeUpdates(float dt) { Array* children = getChildren(); - Node* pNode; + Node* node; Object* pObject; CCARRAY_FOREACH(children, pObject) { - pNode = static_cast(pObject); + node = static_cast(pObject); - if (! pNode) + if (! node) { break; } - pNode->unscheduleAllSelectors(); + node->unscheduleAllSelectors(); } } @@ -856,7 +856,7 @@ std::string SchedulerDelayAndRepeat::subtitle() void SchedulerDelayAndRepeat::update(float dt) { - CCLog("update called:%f", dt); + log("update called:%f", dt); } // SchedulerTimeScale @@ -1095,7 +1095,7 @@ class TestNode2 : public Node { public: ~TestNode2() { - cocos2d::CCLog("Delete TestNode (should not crash)"); + cocos2d::log("Delete TestNode (should not crash)"); this->unscheduleAllSelectors(); } @@ -1154,8 +1154,8 @@ std::string SchedulerIssue2268::subtitle() //------------------------------------------------------------------ void SchedulerTestScene::runThisTest() { - Layer* pLayer = nextSchedulerTest(); - addChild(pLayer); + Layer* 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 19f2f23d8e..f5cd6d9ad0 100644 --- a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.cpp @@ -29,10 +29,10 @@ static Layer* nextAction(void) sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - Layer* pLayer = createShaderLayer(sceneIdx); - pLayer->autorelease(); + Layer* layer = createShaderLayer(sceneIdx); + layer->autorelease(); - return pLayer; + return layer; } static Layer* backAction(void) @@ -42,18 +42,18 @@ static Layer* backAction(void) if( sceneIdx < 0 ) sceneIdx += total; - Layer* pLayer = createShaderLayer(sceneIdx); - pLayer->autorelease(); + Layer* layer = createShaderLayer(sceneIdx); + layer->autorelease(); - return pLayer; + return layer; } static Layer* restartAction(void) { - Layer* pLayer = createShaderLayer(sceneIdx); - pLayer->autorelease(); + Layer* layer = createShaderLayer(sceneIdx); + layer->autorelease(); - return pLayer; + return layer; } diff --git a/samples/Cpp/TestCpp/Classes/SpineTest/SpineTest.cpp b/samples/Cpp/TestCpp/Classes/SpineTest/SpineTest.cpp index b8c2dd0070..b404303a8e 100644 --- a/samples/Cpp/TestCpp/Classes/SpineTest/SpineTest.cpp +++ b/samples/Cpp/TestCpp/Classes/SpineTest/SpineTest.cpp @@ -39,8 +39,8 @@ using namespace std; //------------------------------------------------------------------ void SpineTestScene::runThisTest() { - Layer* pLayer = SpineTestLayer::create(); - addChild(pLayer); + Layer* 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 009404a927..ddf3d1f722 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 @@ -3f19315a4e995c1dd1b5eb35f7dd8e5a15632952 \ No newline at end of file +715f77e7fdc777c303783dad8b6ce3e1b19526d7 \ 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 b0f55e7d04..cda39d5f81 100644 --- a/samples/Cpp/TestCpp/Classes/TextInputTest/TextInputTest.cpp +++ b/samples/Cpp/TestCpp/Classes/TextInputTest/TextInputTest.cpp @@ -58,11 +58,11 @@ Layer* backTextInputTest() return restartTextInputTest(); } -static Rect getRect(Node * pNode) +static Rect getRect(Node * node) { Rect rc; - rc.origin = pNode->getPosition(); - rc.size = pNode->getContentSize(); + rc.origin = node->getPosition(); + rc.size = node->getContentSize(); rc.origin.x -= rc.size.width / 2; rc.origin.y -= rc.size.height / 2; return rc; @@ -103,10 +103,10 @@ void TextInputTest::backCallback(Object* pSender) s->release(); } -void TextInputTest::addKeyboardNotificationLayer(KeyboardNotificationLayer * pLayer) +void TextInputTest::addKeyboardNotificationLayer(KeyboardNotificationLayer * layer) { - _notificationLayer = pLayer; - addChild(pLayer); + _notificationLayer = layer; + addChild(layer); } std::string TextInputTest::title() @@ -131,8 +131,8 @@ KeyboardNotificationLayer::KeyboardNotificationLayer() void KeyboardNotificationLayer::registerWithTouchDispatcher() { - Director* pDirector = Director::getInstance(); - pDirector->getTouchDispatcher()->addTargetedDelegate(this, 0, false); + Director* director = Director::getInstance(); + director->getTouchDispatcher()->addTargetedDelegate(this, 0, false); } void KeyboardNotificationLayer::keyboardWillShow(IMEKeyboardNotificationInfo& info) @@ -298,7 +298,7 @@ void TextFieldTTFActionTest::onEnter() Sequence::create( FadeOut::create(0.25), FadeIn::create(0.25), - 0 + NULL )); _textFieldAction->retain(); _action = false; @@ -390,9 +390,9 @@ bool TextFieldTTFActionTest::onTextFieldInsertText(TextFieldTTF * pSender, const MoveTo::create(duration, endPos), ScaleTo::create(duration, 1), FadeOut::create(duration), - 0), + NULL), CallFuncN::create(CC_CALLBACK_1(TextFieldTTFActionTest::callbackRemoveNodeWhenDidAction, this)), - 0); + NULL); label->runAction(seq); return false; } @@ -424,9 +424,9 @@ bool TextFieldTTFActionTest::onTextFieldDeleteBackward(TextFieldTTF * pSender, c RotateBy::create(rotateDuration, (rand()%2) ? 360 : -360), repeatTime), FadeOut::create(duration), - 0), + NULL), CallFuncN::create(CC_CALLBACK_1(TextFieldTTFActionTest::callbackRemoveNodeWhenDidAction, this)), - 0); + NULL); label->runAction(seq); return false; } @@ -436,9 +436,9 @@ bool TextFieldTTFActionTest::onDraw(TextFieldTTF * pSender) return false; } -void TextFieldTTFActionTest::callbackRemoveNodeWhenDidAction(Node * pNode) +void TextFieldTTFActionTest::callbackRemoveNodeWhenDidAction(Node * node) { - this->removeChild(pNode, true); + this->removeChild(node, true); } ////////////////////////////////////////////////////////////////////////// @@ -447,8 +447,8 @@ void TextFieldTTFActionTest::callbackRemoveNodeWhenDidAction(Node * pNode) void TextInputTestScene::runThisTest() { - Layer* pLayer = nextTextInputTest(); - addChild(pLayer); + Layer* layer = nextTextInputTest(); + addChild(layer); Director::getInstance()->replaceScene(this); } diff --git a/samples/Cpp/TestCpp/Classes/TextInputTest/TextInputTest.h b/samples/Cpp/TestCpp/Classes/TextInputTest/TextInputTest.h index e4add35b1a..ed4ed39a35 100644 --- a/samples/Cpp/TestCpp/Classes/TextInputTest/TextInputTest.h +++ b/samples/Cpp/TestCpp/Classes/TextInputTest/TextInputTest.h @@ -20,7 +20,7 @@ public: void backCallback(Object* pSender); std::string title(); - void addKeyboardNotificationLayer(KeyboardNotificationLayer * pLayer); + void addKeyboardNotificationLayer(KeyboardNotificationLayer * layer); virtual void onEnter(); }; @@ -76,7 +76,7 @@ class TextFieldTTFActionTest : public KeyboardNotificationLayer, public TextFiel int _charLimit; // the textfield max char limit public: - void callbackRemoveNodeWhenDidAction(Node * pNode); + void callbackRemoveNodeWhenDidAction(Node * node); // KeyboardNotificationLayer virtual std::string subtitle(); diff --git a/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp b/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp index 65e3dbda91..918c66eb44 100644 --- a/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp +++ b/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp @@ -69,14 +69,14 @@ static unsigned int TEST_CASE_COUNT = sizeof(createFunctions) / sizeof(createFun static int sceneIdx=-1; Layer* createTextureTest(int index) { - Layer* pLayer = (createFunctions[index])();; + Layer* layer = (createFunctions[index])();; - if (pLayer) + if (layer) { - pLayer->autorelease(); + layer->autorelease(); } - return pLayer; + return layer; } Layer* nextTextureTest(); @@ -438,7 +438,7 @@ void TexturePVRTest::onEnter() } else { - CCLog("This test is not supported."); + log("This test is not supported."); } TextureCache::getInstance()->dumpCachedTextureInfo(); @@ -470,7 +470,7 @@ void TexturePVR4BPP::onEnter() } else { - CCLog("This test is not supported in cocos2d-mac"); + log("This test is not supported in cocos2d-mac"); } TextureCache::getInstance()->dumpCachedTextureInfo(); } @@ -523,7 +523,7 @@ void TexturePVRBGRA8888::onEnter() } else { - CCLog("BGRA8888 images are not supported"); + log("BGRA8888 images are not supported"); } TextureCache::getInstance()->dumpCachedTextureInfo(); } @@ -825,7 +825,7 @@ void TexturePVR4BPPv3::onEnter() } else { - CCLog("This test is not supported"); + log("This test is not supported"); } TextureCache::getInstance()->dumpCachedTextureInfo(); @@ -860,7 +860,7 @@ void TexturePVRII4BPPv3::onEnter() } else { - CCLog("This test is not supported"); + log("This test is not supported"); } TextureCache::getInstance()->dumpCachedTextureInfo(); @@ -918,7 +918,7 @@ void TexturePVRBGRA8888v3::onEnter() } else { - CCLog("BGRA images are not supported"); + log("BGRA images are not supported"); } TextureCache::getInstance()->dumpCachedTextureInfo(); @@ -1514,7 +1514,7 @@ void TextureAsync::imageLoaded(Object* pObj) _imageOffset++; - CCLog("Image loaded: %p", tex); + log("Image loaded: %p", tex); } std::string TextureAsync::title() @@ -1612,33 +1612,33 @@ void TextureSizeTest::onEnter() TextureDemo::onEnter(); Sprite *sprite = NULL; - CCLog("Loading 512x512 image..."); + log("Loading 512x512 image..."); sprite = Sprite::create("Images/texture512x512.png"); if( sprite ) - CCLog("OK"); + log("OK"); else - CCLog("Error"); + log("Error"); - CCLog("Loading 1024x1024 image..."); + log("Loading 1024x1024 image..."); sprite = Sprite::create("Images/texture1024x1024.png"); if( sprite ) - CCLog("OK"); + log("OK"); else - CCLog("Error"); + log("Error"); // @todo -// CCLog("Loading 2048x2048 image..."); +// log("Loading 2048x2048 image..."); // sprite = Sprite::create("Images/texture2048x2048.png"); // if( sprite ) -// CCLog("OK"); +// log("OK"); // else -// CCLog("Error"); +// log("Error"); // -// CCLog("Loading 4096x4096 image..."); +// log("Loading 4096x4096 image..."); // sprite = Sprite::create("Images/texture4096x4096.png"); // if( sprite ) -// CCLog("OK"); +// log("OK"); // else -// CCLog("Error"); +// log("Error"); } std::string TextureSizeTest::title() @@ -1793,8 +1793,8 @@ std::string TextureDrawInRect::subtitle() //------------------------------------------------------------------ void TextureTestScene::runThisTest() { - Layer* pLayer = nextTextureTest(); - addChild(pLayer); + Layer* layer = nextTextureTest(); + addChild(layer); Director::getInstance()->replaceScene(this); } diff --git a/samples/Cpp/TestCpp/Classes/TextureCacheTest/TextureCacheTest.cpp b/samples/Cpp/TestCpp/Classes/TextureCacheTest/TextureCacheTest.cpp index f8f95acb47..c011000b78 100644 --- a/samples/Cpp/TestCpp/Classes/TextureCacheTest/TextureCacheTest.cpp +++ b/samples/Cpp/TestCpp/Classes/TextureCacheTest/TextureCacheTest.cpp @@ -129,9 +129,9 @@ void TextureCacheTest::addSprite() void TextureCacheTestScene::runThisTest() { - Layer* pLayer = new TextureCacheTest(); - addChild(pLayer); + Layer* layer = new TextureCacheTest(); + addChild(layer); Director::getInstance()->replaceScene(this); - pLayer->release(); + layer->release(); } diff --git a/samples/Cpp/TestCpp/Classes/TileMapTest/TileMapTest.cpp b/samples/Cpp/TestCpp/Classes/TileMapTest/TileMapTest.cpp index ef26adb35b..876478a58a 100644 --- a/samples/Cpp/TestCpp/Classes/TileMapTest/TileMapTest.cpp +++ b/samples/Cpp/TestCpp/Classes/TileMapTest/TileMapTest.cpp @@ -261,7 +261,7 @@ TMXOrthoTest4::TMXOrthoTest4() map->setAnchorPoint(Point(0, 0)); - TMXLayer* layer = map->layerNamed("Layer 0"); + auto layer = map->getLayer("Layer 0"); Size s = layer->getLayerSize(); Sprite* sprite; @@ -282,8 +282,8 @@ void TMXOrthoTest4::removeSprite(float dt) { unschedule(schedule_selector(TMXOrthoTest4::removeSprite)); - TMXTiledMap *map = (TMXTiledMap*)getChildByTag(kTagTileMap); - TMXLayer* layer = map->layerNamed("Layer 0"); + auto map = static_cast( getChildByTag(kTagTileMap) ); + auto layer = map->getLayer("Layer 0"); Size s = layer->getLayerSize(); Sprite* sprite = layer->getTileAt( Point(s.width-1,0) ); @@ -318,7 +318,7 @@ TMXReadWriteTest::TMXReadWriteTest() CCLOG("ContentSize: %f, %f", s.width,s.height); - TMXLayer* layer = map->layerNamed("Layer 0"); + TMXLayer* layer = map->getLayer("Layer 0"); layer->getTexture()->setAntiAliasTexParameters(); map->setScale( 1 ); @@ -585,13 +585,13 @@ TMXTilesetTest::TMXTilesetTest() CCLOG("ContentSize: %f, %f", s.width,s.height); TMXLayer* layer; - layer = map->layerNamed("Layer 0"); + layer = map->getLayer("Layer 0"); layer->getTexture()->setAntiAliasTexParameters(); - layer = map->layerNamed("Layer 1"); + layer = map->getLayer("Layer 1"); layer->getTexture()->setAntiAliasTexParameters(); - layer = map->layerNamed("Layer 2"); + layer = map->getLayer("Layer 2"); layer->getTexture()->setAntiAliasTexParameters(); } @@ -614,7 +614,7 @@ TMXOrthoObjectsTest::TMXOrthoObjectsTest() CCLOG("ContentSize: %f, %f", s.width,s.height); ////----CCLOG("----> Iterating over all the group objets"); - TMXObjectGroup* group = map->objectGroupNamed("Object Group 1"); + auto group = map->getObjectGroup("Object Group 1"); Array* objects = group->getObjects(); Dictionary* dict = NULL; @@ -636,8 +636,8 @@ TMXOrthoObjectsTest::TMXOrthoObjectsTest() void TMXOrthoObjectsTest::draw() { - TMXTiledMap* map = (TMXTiledMap*) getChildByTag(kTagTileMap); - TMXObjectGroup* group = map->objectGroupNamed("Object Group 1"); + auto map = static_cast( getChildByTag(kTagTileMap) ); + auto group = map->getObjectGroup("Object Group 1"); Array* objects = group->getObjects(); Dictionary* dict = NULL; @@ -693,7 +693,7 @@ TMXIsoObjectsTest::TMXIsoObjectsTest() Size CC_UNUSED s = map->getContentSize(); CCLOG("ContentSize: %f, %f", s.width,s.height); - TMXObjectGroup* group = map->objectGroupNamed("Object Group 1"); + TMXObjectGroup* group = map->getObjectGroup("Object Group 1"); //UxMutableArray* objects = group->objects(); Array* objects = group->getObjects(); @@ -714,7 +714,7 @@ TMXIsoObjectsTest::TMXIsoObjectsTest() void TMXIsoObjectsTest::draw() { TMXTiledMap *map = (TMXTiledMap*) getChildByTag(kTagTileMap); - TMXObjectGroup *group = map->objectGroupNamed("Object Group 1"); + TMXObjectGroup *group = map->getObjectGroup("Object Group 1"); Array* objects = group->getObjects(); Dictionary* dict; @@ -771,7 +771,7 @@ TMXResizeTest::TMXResizeTest() CCLOG("ContentSize: %f, %f", s.width,s.height); TMXLayer* layer; - layer = map->layerNamed("Layer 0"); + layer = map->getLayer("Layer 0"); Size ls = layer->getLayerSize(); for (unsigned int y = 0; y < ls.height; y++) @@ -808,7 +808,7 @@ TMXIsoZorder::TMXIsoZorder() CCLOG("ContentSize: %f, %f", s.width,s.height); map->setPosition(Point(-s.width/2,0)); - _tamara = Sprite::create(s_pPathSister1); + _tamara = Sprite::create(s_pathSister1); map->addChild(_tamara, map->getChildren()->count() ); _tamara->retain(); int mapWidth = map->getMapSize().width * map->getTileSize().width; @@ -876,7 +876,7 @@ TMXOrthoZorder::TMXOrthoZorder() Size CC_UNUSED s = map->getContentSize(); CCLOG("ContentSize: %f, %f", s.width,s.height); - _tamara = Sprite::create(s_pPathSister1); + _tamara = Sprite::create(s_pathSister1); map->addChild(_tamara, map->getChildren()->count()); _tamara->retain(); _tamara->setAnchorPoint(Point(0.5f,0)); @@ -940,7 +940,7 @@ TMXIsoVertexZ::TMXIsoVertexZ() // 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->layerNamed("Trees"); + TMXLayer* layer = map->getLayer("Trees"); _tamara = layer->getTileAt( Point(29,29) ); _tamara->retain(); @@ -1009,7 +1009,7 @@ 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->layerNamed("trees"); + TMXLayer* layer = map->getLayer("trees"); _tamara = layer->getTileAt(Point(0,11)); CCLOG("%p vertexZ: %f", _tamara, _tamara->getVertexZ()); _tamara->retain(); @@ -1126,7 +1126,7 @@ TMXTilePropertyTest::TMXTilePropertyTest() addChild(map ,0 ,kTagTileMap); for(int i=1;i<=20;i++){ - CCLog("GID:%i, Properties:%p", i, map->propertiesForGID(i)); + log("GID:%i, Properties:%p", i, map->getPropertiesForGID(i)); } } @@ -1152,7 +1152,7 @@ TMXOrthoFlipTest::TMXOrthoFlipTest() addChild(map, 0, kTagTileMap); Size CC_UNUSED s = map->getContentSize(); - CCLog("ContentSize: %f, %f", s.width,s.height); + log("ContentSize: %f, %f", s.width,s.height); Object* pObj = NULL; CCARRAY_FOREACH(map->getChildren(), pObj) @@ -1182,7 +1182,7 @@ TMXOrthoFlipRunTimeTest::TMXOrthoFlipRunTimeTest() addChild(map, 0, kTagTileMap); Size s = map->getContentSize(); - CCLog("ContentSize: %f, %f", s.width,s.height); + log("ContentSize: %f, %f", s.width,s.height); Object* pObj = NULL; CCARRAY_FOREACH(map->getChildren(), pObj) @@ -1210,7 +1210,7 @@ std::string TMXOrthoFlipRunTimeTest::subtitle() void TMXOrthoFlipRunTimeTest::flipIt(float dt) { TMXTiledMap *map = (TMXTiledMap*) getChildByTag(kTagTileMap); - TMXLayer *layer = map->layerNamed("Layer 0"); + TMXLayer *layer = map->getLayer("Layer 0"); //blue diamond Point tileCoord = Point(1,10); @@ -1261,7 +1261,7 @@ TMXOrthoFromXMLTest::TMXOrthoFromXMLTest() addChild(map, 0, kTagTileMap); Size s = map->getContentSize(); - CCLog("ContentSize: %f, %f", s.width,s.height); + log("ContentSize: %f, %f", s.width,s.height); Object* pObj = NULL; CCARRAY_FOREACH(map->getChildren(), pObj) @@ -1293,17 +1293,17 @@ TMXBug987::TMXBug987() CCLOG("ContentSize: %f, %f", s1.width,s1.height); Array* childs = map->getChildren(); - TMXLayer* pNode; + TMXLayer* node; Object* pObject = NULL; CCARRAY_FOREACH(childs, pObject) { - pNode = static_cast(pObject); - CC_BREAK_IF(!pNode); - pNode->getTexture()->setAntiAliasTexParameters(); + node = static_cast(pObject); + CC_BREAK_IF(!node); + node->getTexture()->setAntiAliasTexParameters(); } map->setAnchorPoint(Point(0, 0)); - TMXLayer *layer = map->layerNamed("Tile Layer 1"); + TMXLayer *layer = map->getLayer("Tile Layer 1"); layer->setTileGID(3, Point(2,2)); } @@ -1357,7 +1357,7 @@ static int sceneIdx = -1; #define MAX_LAYER 28 -Layer* createTileMapLayer(int nIndex) +Layer* createTileMalayer(int nIndex) { switch(nIndex) { @@ -1399,10 +1399,10 @@ Layer* nextTileMapAction() sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - Layer* pLayer = createTileMapLayer(sceneIdx); - pLayer->autorelease(); + Layer* layer = createTileMalayer(sceneIdx); + layer->autorelease(); - return pLayer; + return layer; } Layer* backTileMapAction() @@ -1412,18 +1412,18 @@ Layer* backTileMapAction() if( sceneIdx < 0 ) sceneIdx += total; - Layer* pLayer = createTileMapLayer(sceneIdx); - pLayer->autorelease(); + Layer* layer = createTileMalayer(sceneIdx); + layer->autorelease(); - return pLayer; + return layer; } Layer* restartTileMapAction() { - Layer* pLayer = createTileMapLayer(sceneIdx); - pLayer->autorelease(); + Layer* layer = createTileMalayer(sceneIdx); + layer->autorelease(); - return pLayer; + return layer; } @@ -1489,8 +1489,8 @@ void TileDemo::ccTouchesMoved(Set *pTouches, Event *pEvent) void TileMapTestScene::runThisTest() { - Layer* pLayer = nextTileMapAction(); - addChild(pLayer); + Layer* layer = nextTileMapAction(); + addChild(layer); // fix bug #486, #419. // "test" is the default value in Director::setGLDefaultValues() @@ -1516,7 +1516,7 @@ TMXGIDObjectsTest::TMXGIDObjectsTest() void TMXGIDObjectsTest::draw() { TMXTiledMap *map = (TMXTiledMap*)getChildByTag(kTagTileMap); - TMXObjectGroup *group = map->objectGroupNamed("Object Layer 1"); + TMXObjectGroup *group = map->getObjectGroup("Object Layer 1"); Array *array = group->getObjects(); Dictionary* dict; diff --git a/samples/Cpp/TestCpp/Classes/TouchesTest/Paddle.cpp b/samples/Cpp/TestCpp/Classes/TouchesTest/Paddle.cpp index ebcd7a4a6c..db6d109805 100644 --- a/samples/Cpp/TestCpp/Classes/TouchesTest/Paddle.cpp +++ b/samples/Cpp/TestCpp/Classes/TouchesTest/Paddle.cpp @@ -35,15 +35,15 @@ bool Paddle::initWithTexture(Texture2D* aTexture) void Paddle::onEnter() { - Director* pDirector = Director::getInstance(); - pDirector->getTouchDispatcher()->addTargetedDelegate(this, 0, true); + Director* director = Director::getInstance(); + director->getTouchDispatcher()->addTargetedDelegate(this, 0, true); Sprite::onEnter(); } void Paddle::onExit() { - Director* pDirector = Director::getInstance(); - pDirector->getTouchDispatcher()->removeDelegate(this); + Director* director = Director::getInstance(); + director->getTouchDispatcher()->removeDelegate(this); Sprite::onExit(); } diff --git a/samples/Cpp/TestCpp/Classes/TransitionsTest/TransitionsTest.cpp b/samples/Cpp/TestCpp/Classes/TransitionsTest/TransitionsTest.cpp index 9b0c15288c..9c192f0ba8 100644 --- a/samples/Cpp/TestCpp/Classes/TransitionsTest/TransitionsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/TransitionsTest/TransitionsTest.cpp @@ -267,9 +267,9 @@ TransitionScene* createTransition(int nIndex, float t, Scene* s) void TransitionsTestScene::runThisTest() { - Layer * pLayer = new TestLayer1(); - addChild(pLayer); - pLayer->release(); + Layer * layer = new TestLayer1(); + addChild(layer); + layer->release(); Director::getInstance()->replaceScene(this); } @@ -297,9 +297,9 @@ TestLayer1::TestLayer1(void) addChild( label); // menu - MenuItemImage *item1 = MenuItemImage::create(s_pPathB1, s_pPathB2, CC_CALLBACK_1(TestLayer1::backCallback, this) ); - MenuItemImage *item2 = MenuItemImage::create(s_pPathR1, s_pPathR2, CC_CALLBACK_1(TestLayer1::restartCallback, this) ); - MenuItemImage *item3 = MenuItemImage::create(s_pPathF1, s_pPathF2, CC_CALLBACK_1(TestLayer1::nextCallback, this) ); + 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) ); Menu *menu = Menu::create(item1, item2, item3, NULL); @@ -322,15 +322,15 @@ void TestLayer1::restartCallback(Object* pSender) { Scene* s = new TransitionsTestScene(); - Layer* pLayer = new TestLayer2(); - s->addChild(pLayer); + Layer* layer = new TestLayer2(); + s->addChild(layer); - Scene* pScene = createTransition(s_nSceneIdx, TRANSITION_DURATION, s); + Scene* scene = createTransition(s_nSceneIdx, TRANSITION_DURATION, s); s->release(); - pLayer->release(); - if (pScene) + layer->release(); + if (scene) { - Director::getInstance()->replaceScene(pScene); + Director::getInstance()->replaceScene(scene); } } @@ -341,15 +341,15 @@ void TestLayer1::nextCallback(Object* pSender) Scene* s = new TransitionsTestScene(); - Layer* pLayer = new TestLayer2(); - s->addChild(pLayer); + Layer* layer = new TestLayer2(); + s->addChild(layer); - Scene* pScene = createTransition(s_nSceneIdx, TRANSITION_DURATION, s); + Scene* scene = createTransition(s_nSceneIdx, TRANSITION_DURATION, s); s->release(); - pLayer->release(); - if (pScene) + layer->release(); + if (scene) { - Director::getInstance()->replaceScene(pScene); + Director::getInstance()->replaceScene(scene); } } @@ -362,15 +362,15 @@ void TestLayer1::backCallback(Object* pSender) Scene* s = new TransitionsTestScene(); - Layer* pLayer = new TestLayer2(); - s->addChild(pLayer); + Layer* layer = new TestLayer2(); + s->addChild(layer); - Scene* pScene = createTransition(s_nSceneIdx, TRANSITION_DURATION, s); + Scene* scene = createTransition(s_nSceneIdx, TRANSITION_DURATION, s); s->release(); - pLayer->release(); - if (pScene) + layer->release(); + if (scene) { - Director::getInstance()->replaceScene(pScene); + Director::getInstance()->replaceScene(scene); } } @@ -382,25 +382,25 @@ void TestLayer1::step(float dt) void TestLayer1::onEnter() { Layer::onEnter(); - CCLog("Scene 1 onEnter"); + log("Scene 1 onEnter"); } void TestLayer1::onEnterTransitionDidFinish() { Layer::onEnterTransitionDidFinish(); - CCLog("Scene 1: onEnterTransitionDidFinish"); + log("Scene 1: onEnterTransitionDidFinish"); } void TestLayer1::onExitTransitionDidStart() { Layer::onExitTransitionDidStart(); - CCLog("Scene 1: onExitTransitionDidStart"); + log("Scene 1: onExitTransitionDidStart"); } void TestLayer1::onExit() { Layer::onExit(); - CCLog("Scene 1 onExit"); + log("Scene 1 onExit"); } TestLayer2::TestLayer2() @@ -426,9 +426,9 @@ TestLayer2::TestLayer2() addChild( label); // menu - MenuItemImage *item1 = MenuItemImage::create(s_pPathB1, s_pPathB2, CC_CALLBACK_1(TestLayer2::backCallback, this) ); - MenuItemImage *item2 = MenuItemImage::create(s_pPathR1, s_pPathR2, CC_CALLBACK_1(TestLayer2::restartCallback, this) ); - MenuItemImage *item3 = MenuItemImage::create(s_pPathF1, s_pPathF2, CC_CALLBACK_1(TestLayer2::nextCallback, this) ); + 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) ); Menu *menu = Menu::create(item1, item2, item3, NULL); @@ -451,15 +451,15 @@ void TestLayer2::restartCallback(Object* pSender) { Scene* s = new TransitionsTestScene(); - Layer* pLayer = new TestLayer1(); - s->addChild(pLayer); + Layer* layer = new TestLayer1(); + s->addChild(layer); - Scene* pScene = createTransition(s_nSceneIdx, TRANSITION_DURATION, s); + Scene* scene = createTransition(s_nSceneIdx, TRANSITION_DURATION, s); s->release(); - pLayer->release(); - if (pScene) + layer->release(); + if (scene) { - Director::getInstance()->replaceScene(pScene); + Director::getInstance()->replaceScene(scene); } } @@ -470,15 +470,15 @@ void TestLayer2::nextCallback(Object* pSender) Scene* s = new TransitionsTestScene(); - Layer* pLayer = new TestLayer1(); - s->addChild(pLayer); + Layer* layer = new TestLayer1(); + s->addChild(layer); - Scene* pScene = createTransition(s_nSceneIdx, TRANSITION_DURATION, s); + Scene* scene = createTransition(s_nSceneIdx, TRANSITION_DURATION, s); s->release(); - pLayer->release(); - if (pScene) + layer->release(); + if (scene) { - Director::getInstance()->replaceScene(pScene); + Director::getInstance()->replaceScene(scene); } } @@ -491,15 +491,15 @@ void TestLayer2::backCallback(Object* pSender) Scene* s = new TransitionsTestScene(); - Layer* pLayer = new TestLayer1(); - s->addChild(pLayer); + Layer* layer = new TestLayer1(); + s->addChild(layer); - Scene* pScene = createTransition(s_nSceneIdx, TRANSITION_DURATION, s); + Scene* scene = createTransition(s_nSceneIdx, TRANSITION_DURATION, s); s->release(); - pLayer->release(); - if (pScene) + layer->release(); + if (scene) { - Director::getInstance()->replaceScene(pScene); + Director::getInstance()->replaceScene(scene); } } @@ -511,23 +511,23 @@ void TestLayer2::step(float dt) void TestLayer2::onEnter() { Layer::onEnter(); - CCLog("Scene 2 onEnter"); + log("Scene 2 onEnter"); } void TestLayer2::onEnterTransitionDidFinish() { Layer::onEnterTransitionDidFinish(); - CCLog("Scene 2: onEnterTransitionDidFinish"); + log("Scene 2: onEnterTransitionDidFinish"); } void TestLayer2::onExitTransitionDidStart() { Layer::onExitTransitionDidStart(); - CCLog("Scene 2: onExitTransitionDidStart"); + log("Scene 2: onExitTransitionDidStart"); } void TestLayer2::onExit() { Layer::onExit(); - CCLog("Scene 2 onExit"); + log("Scene 2 onExit"); } diff --git a/samples/Cpp/TestCpp/Classes/UserDefaultTest/UserDefaultTest.cpp b/samples/Cpp/TestCpp/Classes/UserDefaultTest/UserDefaultTest.cpp index dd8b386131..e7e656efd1 100644 --- a/samples/Cpp/TestCpp/Classes/UserDefaultTest/UserDefaultTest.cpp +++ b/samples/Cpp/TestCpp/Classes/UserDefaultTest/UserDefaultTest.cpp @@ -97,9 +97,9 @@ UserDefaultTest::~UserDefaultTest() void UserDefaultTestScene::runThisTest() { - Layer* pLayer = new UserDefaultTest(); - addChild(pLayer); + Layer* layer = new UserDefaultTest(); + addChild(layer); Director::getInstance()->replaceScene(this); - pLayer->release(); + layer->release(); } diff --git a/samples/Cpp/TestCpp/Classes/VisibleRect.cpp b/samples/Cpp/TestCpp/Classes/VisibleRect.cpp index fa9742e68d..f958697668 100644 --- a/samples/Cpp/TestCpp/Classes/VisibleRect.cpp +++ b/samples/Cpp/TestCpp/Classes/VisibleRect.cpp @@ -6,9 +6,9 @@ void VisibleRect::lazyInit() { if (s_visibleRect.size.width == 0.0f && s_visibleRect.size.height == 0.0f) { - EGLView* pEGLView = EGLView::getInstance(); - s_visibleRect.origin = pEGLView->getVisibleOrigin(); - s_visibleRect.size = pEGLView->getVisibleSize(); + EGLView* 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 b655fd544f..ef3b133d5e 100644 --- a/samples/Cpp/TestCpp/Classes/ZwoptexTest/ZwoptexTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ZwoptexTest/ZwoptexTest.cpp @@ -24,10 +24,10 @@ Layer* nextZwoptexTest() sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - Layer* pLayer = createZwoptexLayer(sceneIdx); - pLayer->autorelease(); + Layer* layer = createZwoptexLayer(sceneIdx); + layer->autorelease(); - return pLayer; + return layer; } Layer* backZwoptexTest() @@ -37,18 +37,18 @@ Layer* backZwoptexTest() if( sceneIdx < 0 ) sceneIdx += total; - Layer* pLayer = createZwoptexLayer(sceneIdx); - pLayer->autorelease(); + Layer* layer = createZwoptexLayer(sceneIdx); + layer->autorelease(); - return pLayer; + return layer; } Layer* restartZwoptexTest() { - Layer* pLayer = createZwoptexLayer(sceneIdx); - pLayer->autorelease(); + Layer* layer = createZwoptexLayer(sceneIdx); + layer->autorelease(); - return pLayer; + return layer; } //------------------------------------------------------------------ @@ -210,8 +210,8 @@ std::string ZwoptexGenericTest::subtitle() void ZwoptexTestScene::runThisTest() { - Layer* pLayer = nextZwoptexTest(); - addChild(pLayer); + Layer* 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 7265bd9ce1..522bb1c052 100644 --- a/samples/Cpp/TestCpp/Classes/controller.cpp +++ b/samples/Cpp/TestCpp/Classes/controller.cpp @@ -94,11 +94,11 @@ TestController::TestController() : _beginPos(Point::ZERO) { // add close menu - MenuItemImage *pCloseItem = MenuItemImage::create(s_pPathClose, s_pPathClose, CC_CALLBACK_1(TestController::closeCallback, this) ); - Menu* pMenu =Menu::create(pCloseItem, NULL); + MenuItemImage *closeItem = MenuItemImage::create(s_pathClose, s_pathClose, CC_CALLBACK_1(TestController::closeCallback, this) ); + Menu* menu =Menu::create(closeItem, NULL); - pMenu->setPosition( Point::ZERO ); - pCloseItem->setPosition(Point( VisibleRect::right().x - 30, VisibleRect::top().y - 30)); + menu->setPosition( Point::ZERO ); + closeItem->setPosition(Point( VisibleRect::right().x - 30, VisibleRect::top().y - 30)); // add menu items for tests _itemMenu = Menu::create(); @@ -109,10 +109,10 @@ TestController::TestController() // #else LabelTTF* label = LabelTTF::create( g_aTestNames[i].test_name, "Arial", 24); // #endif - MenuItemLabel* pMenuItem = MenuItemLabel::create(label, CC_CALLBACK_1(TestController::menuCallback, this)); + MenuItemLabel* menuItem = MenuItemLabel::create(label, CC_CALLBACK_1(TestController::menuCallback, this)); - _itemMenu->addChild(pMenuItem, i + 10000); - pMenuItem->setPosition( Point( VisibleRect::center().x, (VisibleRect::top().y - (i + 1) * LINE_SPACE) )); + _itemMenu->addChild(menuItem, i + 10000); + menuItem->setPosition( Point( VisibleRect::center().x, (VisibleRect::top().y - (i + 1) * LINE_SPACE) )); } _itemMenu->setContentSize(Size(VisibleRect::getVisibleRect().size.width, (g_testCount + 1) * (LINE_SPACE))); @@ -121,7 +121,7 @@ TestController::TestController() setTouchEnabled(true); - addChild(pMenu, 1); + addChild(menu, 1); } @@ -135,16 +135,16 @@ void TestController::menuCallback(Object * pSender) Director::getInstance()->purgeCachedData(); // get the userdata, it's the index of the menu item clicked - MenuItem* pMenuItem = (MenuItem *)(pSender); - int idx = pMenuItem->getZOrder() - 10000; + MenuItem* menuItem = (MenuItem *)(pSender); + int idx = menuItem->getZOrder() - 10000; // create the test scene and run it - TestScene* pScene = g_aTestNames[idx].callback(); + TestScene* scene = g_aTestNames[idx].callback(); - if (pScene) + if (scene) { - pScene->runThisTest(); - pScene->release(); + scene->runThisTest(); + scene->release(); } } diff --git a/samples/Cpp/TestCpp/Classes/testBasic.cpp b/samples/Cpp/TestCpp/Classes/testBasic.cpp index 844ab7c604..adabca863e 100644 --- a/samples/Cpp/TestCpp/Classes/testBasic.cpp +++ b/samples/Cpp/TestCpp/Classes/testBasic.cpp @@ -17,7 +17,7 @@ void TestScene::onEnter() //#else LabelTTF* label = LabelTTF::create("MainMenu", "Arial", 20); //#endif - MenuItemLabel* pMenuItem = MenuItemLabel::create(label, [](Object *sender) { + MenuItemLabel* 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,22 +35,22 @@ void TestScene::onEnter() outside the scope. So I choose the (2) solution. Commented by James Chen. */ -// Scene *pScene = Scene::create(); - Scene *pScene = new Scene(); - if (pScene && pScene->init()) +// Scene *scene = Scene::create(); + Scene *scene = new Scene(); + if (scene && scene->init()) { - Layer* pLayer = new TestController(); - pScene->addChild(pLayer); - pLayer->release(); - Director::getInstance()->replaceScene(pScene); - pScene->release(); + Layer* layer = new TestController(); + scene->addChild(layer); + layer->release(); + Director::getInstance()->replaceScene(scene); + scene->release(); } }); - Menu* pMenu =Menu::create(pMenuItem, NULL); + Menu* menu =Menu::create(menuItem, NULL); - pMenu->setPosition( Point::ZERO ); - pMenuItem->setPosition( Point( VisibleRect::right().x - 50, VisibleRect::bottom().y + 25) ); + menu->setPosition( Point::ZERO ); + menuItem->setPosition( Point( VisibleRect::right().x - 50, VisibleRect::bottom().y + 25) ); - addChild(pMenu, 1); + addChild(menu, 1); } diff --git a/samples/Cpp/TestCpp/Classes/testResource.h b/samples/Cpp/TestCpp/Classes/testResource.h index 72b72c286e..98984a7547 100644 --- a/samples/Cpp/TestCpp/Classes/testResource.h +++ b/samples/Cpp/TestCpp/Classes/testResource.h @@ -1,16 +1,16 @@ #ifndef _TEST_RESOURCE_H_ #define _TEST_RESOURCE_H_ -static const char s_pPathGrossini[] = "Images/grossini.png"; -static const char s_pPathSister1[] = "Images/grossinis_sister1.png"; -static const char s_pPathSister2[] = "Images/grossinis_sister2.png"; -static const char s_pPathB1[] = "Images/b1.png"; -static const char s_pPathB2[] = "Images/b2.png"; -static const char s_pPathR1[] = "Images/r1.png"; -static const char s_pPathR2[] = "Images/r2.png"; -static const char s_pPathF1[] = "Images/f1.png"; -static const char s_pPathF2[] = "Images/f2.png"; -static const char s_pPathBlock[] = "Images/blocks.png"; +static const char s_pathGrossini[] = "Images/grossini.png"; +static const char s_pathSister1[] = "Images/grossinis_sister1.png"; +static const char s_pathSister2[] = "Images/grossinis_sister2.png"; +static const char s_pathB1[] = "Images/b1.png"; +static const char s_pathB2[] = "Images/b2.png"; +static const char s_pathR1[] = "Images/r1.png"; +static const char s_pathR2[] = "Images/r2.png"; +static const char s_pathF1[] = "Images/f1.png"; +static const char s_pathF2[] = "Images/f2.png"; +static const char s_pathBlock[] = "Images/blocks.png"; static const char s_back[] = "Images/background.png"; static const char s_back1[] = "Images/background1.png"; static const char s_back2[] = "Images/background2.png"; @@ -28,7 +28,7 @@ static const char s_HighNormal[] = "Images/btn-highscores-normal.png"; static const char s_HighSelect[] = "Images/btn-highscores-selected.png"; static const char s_Ball[] = "Images/ball.png"; static const char s_Paddle[] = "Images/paddle.png"; -static const char s_pPathClose[] = "Images/close.png"; +static const char s_pathClose[] = "Images/close.png"; static const char s_MenuItem[] = "Images/menuitemsprite.png"; static const char s_SendScore[] = "Images/SendScoreButton.png"; static const char s_PressSendScore[] = "Images/SendScoreButtonPressed.png"; diff --git a/samples/Cpp/TestCpp/proj.emscripten/Makefile b/samples/Cpp/TestCpp/proj.emscripten/Makefile index 6f069f65bd..7673cd7ee5 100644 --- a/samples/Cpp/TestCpp/proj.emscripten/Makefile +++ b/samples/Cpp/TestCpp/proj.emscripten/Makefile @@ -143,9 +143,10 @@ $(TARGET).data: $(CORE_MAKEFILE_LIST) $(patsubst %,$(RESOURCE_PATH)/%,$(RESOURCE cp -av $(RESOURCE_PATH)/* $(shell dirname $@) rm -rf $(RESTMP) -$(BIN_DIR)/index.html: index.html $(CORE_MAKEFILE_LIST) +$(BIN_DIR)/$(HTMLTPL_FILE): $(HTMLTPL_DIR)/$(HTMLTPL_FILE) $(CORE_MAKEFILE_LIST) @mkdir -p $(@D) - cp index.html $(@D) + @cp -Rf $(HTMLTPL_DIR)/* $(BIN_DIR) + @sed -i -e "s/JS_APPLICATION/$(EXECUTABLE)/g" $(BIN_DIR)/$(HTMLTPL_FILE) ####### Compile $(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST) diff --git a/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp b/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp index fd8d397c8e..66d43c205c 100644 --- a/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp +++ b/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp @@ -23,7 +23,7 @@ AppDelegate::AppDelegate() AppDelegate::~AppDelegate() { - ScriptEngineManager::purgeSharedManager(); + ScriptEngineManager::destroyInstance(); } bool AppDelegate::applicationDidFinishLaunching() diff --git a/samples/Lua/TestLua/Resources/luaScript/DrawPrimitivesTest/DrawPrimitivesTest.lua b/samples/Lua/TestLua/Resources/luaScript/DrawPrimitivesTest/DrawPrimitivesTest.lua index 27c62fbb50..ee8cc649b9 100644 --- a/samples/Lua/TestLua/Resources/luaScript/DrawPrimitivesTest/DrawPrimitivesTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/DrawPrimitivesTest/DrawPrimitivesTest.lua @@ -1,139 +1,182 @@ +require "DrawPrimitives" -local SceneIdx = -1 -local MAX_LAYER = 2 +local function drawPrimitivesMainLayer() + local kItemTagBasic = 1000 + local testCount = 1 + local maxCases = testCount + local curCase = 0 + local size = CCDirector:getInstance():getWinSize() + local curLayer = nil -local background = nil - -local labelAtlas = nil -local baseLayer_entry = nil - -local s = CCDirector:sharedDirector():getWinSize() - -local function getBaseLayer() - local layer = CCLayer:create() - - 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")) - item1:registerScriptTapHandler(backCallback) - item2:registerScriptTapHandler(restartCallback) - item3:registerScriptTapHandler(nextCallback) - - labelAtlas = CCLabelAtlas:create("0000", "fps_images.png", 12, 32, string.byte('.')) - layer:addChild(labelAtlas, 100) - labelAtlas:setPosition(ccp(s.width - 66, 50)) - - layer:setTouchEnabled(false) - - Helper.initWithLayer(layer) - - return layer -end - -local function drawPrimitivesTest() - local layer = getBaseLayer() + local function orderCallbackMenu() + local function backCallback() + curCase = curCase - 1 + if curCase < 0 then + curCase = curCase + maxCases + end + showCurrentTest() + end - ccDrawLine( ccp(0, s.height), ccp(s.width, 0) ); - glLineWidth( 5.0); - ccDrawColor4B(255,0,0,255); - ccDrawLine(ccp(0, 0), ccp(s.width, s.height) ); + local function restartCallback() + showCurrentTest() + end --- ccPointSize(64); --- ccDrawColor4B(0,0,255,128); --- ccDrawPoint( VisibleRect::center() ); --- --- CHECK_GL_ERROR_DEBUG(); --- --- // draw 4 small points --- CCPoint points[] = { ccp(60,60), ccp(70,70), ccp(60,70), ccp(70,60) }; --- ccPointSize(4); --- ccDrawColor4B(0,255,255,255); --- ccDrawPoints( points, 4); --- --- CHECK_GL_ERROR_DEBUG(); --- --- // draw a green circle with 10 segments --- glLineWidth(16); --- ccDrawColor4B(0, 255, 0, 255); --- ccDrawCircle( VisibleRect::center(), 100, 0, 10, false); --- --- CHECK_GL_ERROR_DEBUG(); --- --- // draw a green circle with 50 segments with line to center --- glLineWidth(2); --- ccDrawColor4B(0, 255, 255, 255); --- ccDrawCircle( VisibleRect::center(), 50, CC_DEGREES_TO_RADIANS(90), 50, true); --- --- CHECK_GL_ERROR_DEBUG(); --- --- // open yellow poly --- ccDrawColor4B(255, 255, 0, 255); --- glLineWidth(10); --- CCPoint vertices[] = { ccp(0,0), ccp(50,50), ccp(100,50), ccp(100,100), ccp(50,100) }; --- ccDrawPoly( vertices, 5, false); --- --- CHECK_GL_ERROR_DEBUG(); --- --- // filled poly --- glLineWidth(1); --- CCPoint filledVertices[] = { ccp(0,120), ccp(50,120), ccp(50,170), ccp(25,200), ccp(0,170) }; --- ccDrawSolidPoly(filledVertices, 5, Color4F(0.5f, 0.5f, 1, 1 ) ); --- --- --- // closed purble poly --- ccDrawColor4B(255, 0, 255, 255); --- glLineWidth(2); --- CCPoint vertices2[] = { ccp(30,130), ccp(30,230), ccp(50,200) }; --- ccDrawPoly( vertices2, 3, true); --- --- CHECK_GL_ERROR_DEBUG(); --- --- // draw quad bezier path --- ccDrawQuadBezier(VisibleRect::leftTop(), VisibleRect::center(), VisibleRect::rightTop(), 50); --- --- CHECK_GL_ERROR_DEBUG(); --- --- // draw cubic bezier path --- ccDrawCubicBezier(VisibleRect::center(), ccp(VisibleRect::center().x+30,VisibleRect::center().y+50), ccp(VisibleRect::center().x+60,VisibleRect::center().y-50),VisibleRect::right(),100); --- --- CHECK_GL_ERROR_DEBUG(); --- --- //draw a solid polygon --- CCPoint vertices3[] = {ccp(60,160), ccp(70,190), ccp(100,190), ccp(90,160)}; --- ccDrawSolidPoly( vertices3, 4, Color4F(1,1,0,1) ); --- --- // restore original values --- glLineWidth(1); --- ccDrawColor4B(255,255,255,255); --- ccPointSize(1); --- --- CHECK_GL_ERROR_DEBUG(); - return layer -end + local function nextCallback() + curCase = curCase + 1 + curCase = curCase % maxCases + showCurrentTest() + end ---------------------------------- --- DrawPrimitives Test ---------------------------------- -function CreateDrawPrimitivesTestLayer() - if SceneIdx == 0 then return drawPrimitivesTest() - end + local ordercallbackmenu = CCMenu:create() + local size = CCDirector:getInstance():getWinSize() + local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2) + item1:registerScriptTapHandler(backCallback) + ordercallbackmenu:addChild(item1,kItemTagBasic) + local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2) + item2:registerScriptTapHandler(restartCallback) + ordercallbackmenu:addChild(item2,kItemTagBasic) + local item3 = CCMenuItemImage: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)) + + ordercallbackmenu:setPosition(ccp(0, 0)) + + return ordercallbackmenu + end + + local function GetTitle() + if 0 == curCase then + return "Draw primitives" + elseif 1 == curCase then + return "Test DrawNode" + end + end + + local function GetSubTitle() + if 0 == curCase then + return "Drawing Primitives by call gl funtions" + elseif 1 == curCase then + return "Testing DrawNode - batched draws. Concave polygons are BROKEN" + end + end + + local function InitTitle(layer) + --Title + local lableTitle = CCLabelTTF:create(GetTitle(), "Arial", 40) + layer:addChild(lableTitle, 15) + lableTitle:setPosition(CCPoint(size.width / 2, size.height - 32)) + lableTitle:setColor(Color3B(255, 255, 40)) + --SubTitle + local subLabelTitle = CCLabelTTF:create(GetSubTitle(), "Thonburi", 16) + layer:addChild(subLabelTitle, 15) + subLabelTitle:setPosition(CCPoint(size.width / 2, size.height - 80)) + end + + local function createDrawPrimitivesEffect() + local layer = CCLayer:create() + + InitTitle(layer) + + local glNode = gl.glNodeCreate() + glNode:setContentSize(CCSize(size.width, size.height)) + glNode:setAnchorPoint(CCPoint(0.5, 0.5)) + + local function primitivesDraw() + ccDrawLine(VisibleRect:leftBottom(), VisibleRect:rightTop() ) + + gl.lineWidth( 5.0 ) + ccDrawColor4B(255,0,0,255) + ccDrawLine( VisibleRect:leftTop(), VisibleRect:rightBottom() ) + + ccPointSize(64) + ccDrawColor4B(0, 0, 255, 128) + ccDrawPoint(VisibleRect:center()) + + local points = {CCPoint(60,60), CCPoint(70,70), CCPoint(60,70), CCPoint(70,60) } + ccPointSize(4) + ccDrawColor4B(0,255,255,255) + ccDrawPoints(points,4) + + gl.lineWidth(16) + ccDrawColor4B(0, 255, 0, 255) + ccDrawCircle( VisibleRect:center(), 100, 0, 10, false) + + gl.lineWidth(2) + ccDrawColor4B(0, 255, 255, 255) + ccDrawCircle( VisibleRect:center(), 50, math.pi / 2, 50, true) + + gl.lineWidth(2) + ccDrawColor4B(255, 0, 255, 255) + ccDrawSolidCircle( VisibleRect:center() + CCPoint(140,0), 40, math.rad(90), 50, 1.0, 1.0) + + + ccDrawColor4B(255, 255, 0, 255) + gl.lineWidth(10) + local yellowPoints = { CCPoint(0,0), CCPoint(50,50), CCPoint(100,50), CCPoint(100,100), CCPoint(50,100)} + ccDrawPoly( yellowPoints, 5, false) + + gl.lineWidth(1) + local filledVertices = { CCPoint(0,120), CCPoint(50,120), CCPoint(50,170), CCPoint(25,200), CCPoint(0,170) } + local colorFilled = { 0.5, 0.5, 1, 1 } + ccDrawSolidPoly(filledVertices, 5, colorFilled) + + ccDrawColor4B(255, 0, 255, 255) + gl.lineWidth(2) + local closePoints= { CCPoint(30,130), CCPoint(30,230), CCPoint(50,200) } + ccDrawPoly( closePoints, 3, true) + + ccDrawQuadBezier(VisibleRect:leftTop(), VisibleRect:center(), VisibleRect:rightTop(), 50) + + ccDrawCubicBezier(VisibleRect:center(), CCPoint(VisibleRect:center().x + 30, VisibleRect:center().y + 50), CCPoint(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)} + local colorsolid= { 1, 1, 0, 1 } + ccDrawSolidPoly( solidvertices, 4, colorsolid ) + + gl.lineWidth(1) + ccDrawColor4B(255,255,255,255) + ccPointSize(1) + end + + glNode:registerScriptDrawHandler(primitivesDraw) + layer:addChild(glNode,-10) + glNode:setPosition( size.width / 2, size.height / 2) + + return layer + end + + local function createLayerByCurCase(curCase) + if 0 == curCase then + return createDrawPrimitivesEffect() + end + end + + function showCurrentTest() + local curScene = CCScene: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) + end + end + end + + curLayer = createLayerByCurCase(curCase) + curLayer:addChild(orderCallbackMenu(),15) + return curLayer end function DrawPrimitivesTest() - cclog("DrawPrimitivesTest") - local scene = CCScene:create() - - Helper.createFunctionTable = { - drawPrimitivesTest - } - - scene:addChild(drawPrimitivesTest()) - scene:addChild(CreateBackMenuItem()) - - return scene + local scene = CCScene:create() + scene:addChild(drawPrimitivesMainLayer()) + scene:addChild(CreateBackMenuItem()) + return scene end - diff --git a/samples/Lua/TestLua/Resources/luaScript/PerformanceTest/PerformanceTest.lua b/samples/Lua/TestLua/Resources/luaScript/PerformanceTest/PerformanceTest.lua index 45e96b7c4f..7de350d954 100644 --- a/samples/Lua/TestLua/Resources/luaScript/PerformanceTest/PerformanceTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/PerformanceTest/PerformanceTest.lua @@ -1403,7 +1403,7 @@ local function runTextureTest() -- gettimeofday(&now, NULL) pTexture = pCache:addImage(strFileName) if nil ~= pTexture then - --CCLog(" ms:%f", calculateDeltaTime(&now) ) + --log(" ms:%f", calculateDeltaTime(&now) ) print("add sucess") else print(" ERROR") diff --git a/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua b/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua index 630be53cf5..105b3ce7ac 100644 --- a/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua +++ b/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua @@ -58,7 +58,7 @@ local _allTests = { { isSupported = true, name = "CocosDenshionTest" , create_func = CocosDenshionTestMain }, { isSupported = false, name = "CurlTest" , create_func= CurlTestMain }, { isSupported = true, name = "CurrentLanguageTest" , create_func= CurrentLanguageTestMain }, - { isSupported = false, name = "DrawPrimitivesTest" , create_func= DrawPrimitivesTest }, + { isSupported = true, name = "DrawPrimitivesTest" , create_func= DrawPrimitivesTest }, { isSupported = true, name = "EffectsTest" , create_func = EffectsTest }, { isSupported = true, name = "EffectAdvancedTest" , create_func = EffectAdvancedTestMain }, { isSupported = true, name = "ExtensionsTest" , create_func= ExtensionsTestMain }, diff --git a/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id b/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id index a7de9f9e04..a736c579cc 100644 --- a/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -32e637c6b271e1eea27e207c13116f43c310c0d4 \ No newline at end of file +d83a378b9954c34cb506cdee439ef636f9679f4f \ No newline at end of file diff --git a/scripting/javascript/bindings/ScriptingCore.cpp b/scripting/javascript/bindings/ScriptingCore.cpp index c307a84105..fd6b1fa55e 100644 --- a/scripting/javascript/bindings/ScriptingCore.cpp +++ b/scripting/javascript/bindings/ScriptingCore.cpp @@ -519,7 +519,7 @@ JSBool ScriptingCore::runScript(const char *path, JSObject* global, JSContext* c JSAutoCompartment ac(cx, global); evaluatedOK = JS_ExecuteScript(cx, global, script, &rval); if (JS_FALSE == evaluatedOK) { - CCLog("(evaluatedOK == JS_FALSE)"); + cocos2d::log("(evaluatedOK == JS_FALSE)"); JS_ReportPendingException(cx); } } diff --git a/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id b/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id index bd54a13aca..c3d23499cb 100644 --- a/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id +++ b/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id @@ -1 +1 @@ -b42669456f0d5c967937f769b5b38c5b1182032d \ No newline at end of file +044ec2b4004e74ab49c48a703b1ffd743da7eaa3 \ No newline at end of file diff --git a/scripting/javascript/bindings/generated b/scripting/javascript/bindings/generated index 3b53da0b06..1f1832e138 160000 --- a/scripting/javascript/bindings/generated +++ b/scripting/javascript/bindings/generated @@ -1 +1 @@ -Subproject commit 3b53da0b068d924f9752668c6e1602f8a1bedce5 +Subproject commit 1f1832e138a639b764e23efb9b9752dc667d8d43 diff --git a/scripting/javascript/bindings/js_bindings_config.h b/scripting/javascript/bindings/js_bindings_config.h index 653aac9669..3950f9a79f 100644 --- a/scripting/javascript/bindings/js_bindings_config.h +++ b/scripting/javascript/bindings/js_bindings_config.h @@ -44,8 +44,8 @@ #else #define JSB_PRECONDITION( condition, ...) do { \ if( ! (condition) ) { \ - cocos2d::CCLog("jsb: ERROR: File %s: Line: %d, Function: %s", __FILE__, __LINE__, __FUNCTION__ ); \ - cocos2d::CCLog(__VA_ARGS__); \ + cocos2d::log("jsb: ERROR: File %s: Line: %d, Function: %s", __FILE__, __LINE__, __FUNCTION__ ); \ + cocos2d::log(__VA_ARGS__); \ JSContext* globalContext = ScriptingCore::getInstance()->getGlobalContext(); \ if( ! JS_IsExceptionPending( globalContext ) ) { \ JS_ReportError( globalContext, __VA_ARGS__ ); \ @@ -55,8 +55,8 @@ } while(0) #define JSB_PRECONDITION2( condition, context, ret_value, ...) do { \ if( ! (condition) ) { \ - cocos2d::CCLog("jsb: ERROR: File %s: Line: %d, Function: %s", __FILE__, __LINE__, __FUNCTION__ ); \ - cocos2d::CCLog(__VA_ARGS__); \ + cocos2d::log("jsb: ERROR: File %s: Line: %d, Function: %s", __FILE__, __LINE__, __FUNCTION__ ); \ + cocos2d::log(__VA_ARGS__); \ if( ! JS_IsExceptionPending( context ) ) { \ JS_ReportError( context, __VA_ARGS__ ); \ } \ diff --git a/scripting/lua/cocos2dx_support/Cocos2dxLuaLoader.cpp b/scripting/lua/cocos2dx_support/Cocos2dxLuaLoader.cpp index f27ee759ed..a3ae0474d8 100644 --- a/scripting/lua/cocos2dx_support/Cocos2dxLuaLoader.cpp +++ b/scripting/lua/cocos2dx_support/Cocos2dxLuaLoader.cpp @@ -60,7 +60,7 @@ extern "C" } else { - CCLog("can not get file data of %s", filename.c_str()); + log("can not get file data of %s", filename.c_str()); } return 1; diff --git a/scripting/lua/cocos2dx_support/LuaOpengl.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/LuaOpengl.cpp.REMOVED.git-id index 601ee05858..b46045d3c2 100644 --- a/scripting/lua/cocos2dx_support/LuaOpengl.cpp.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/LuaOpengl.cpp.REMOVED.git-id @@ -1 +1 @@ -1e099e4c734f57f72adc2c665a8ab9e941b10417 \ No newline at end of file +d515328a92ac0cf64fb7b1ee9d1b0b200d36c473 \ No newline at end of file diff --git a/scripting/lua/script/Deprecated.lua b/scripting/lua/script/Deprecated.lua index 7097950c8b..84d79488dd 100644 --- a/scripting/lua/script/Deprecated.lua +++ b/scripting/lua/script/Deprecated.lua @@ -16,26 +16,26 @@ rawset(_G,"ccpLineIntersect",ccpLineIntersect) local function CCPointMake(x,y) - deprecatedTip("CCPointMake","CCPoint:__call") - return CCPoint:__call(x,y) + deprecatedTip("CCPointMake(x,y)","CCPoint(x,y)") + return CCPoint(x,y) end rawset(_G,"CCPointMake",CCPointMake) local function ccp(x,y) - deprecatedTip("ccp","CCPoint:__call") - return CCPoint:__call(x,y) + deprecatedTip("ccp(x,y)","CCPoint(x,y)") + return CCPoint(x,y) end rawset(_G,"ccp",ccp) local function CCSizeMake(width,height) - deprecatedTip("CCSizeMake","CCSize:__call") - return CCSize:__call(width,height) + deprecatedTip("CCSizeMake(width,height)","CCSize(width,height)") + return CCSize(width,height) end rawset(_G,"CCSizeMake",CCSizeMake) local function CCRectMake(x,y,width,height) - deprecatedTip("CCRectMake","CCRect:__call") - return CCRect:__call(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) @@ -162,8 +162,8 @@ rawset(_G,"ccpClamp",ccpClamp) local function ccpFromSize(sz) - deprecatedTip("ccpFromSize","CCPoint:__call") - return CCPoint:__call(sz) + deprecatedTip("ccpFromSize(sz)","CCPoint(sz)") + return CCPoint(sz) end rawset(_G,"ccpFromSize",ccpFromSize) @@ -180,8 +180,8 @@ end rawset(_G,"ccpFuzzyEqual",ccpFuzzyEqual) local function ccpCompMult(pt1,pt2) - deprecatedTip("ccpCompMult","CCPoint:__call") - return CCPoint:__call(pt1.x * pt2.x , pt1.y * pt2.y) + deprecatedTip("ccpCompMult","CCPoint") + return CCPoint(pt1.x * pt2.x , pt1.y * pt2.y) end rawset(_G,"ccpCompMult",ccpCompMult) @@ -450,9 +450,3 @@ local function sharedEngine() return SimpleAudioEngine:getInstance() end rawset(SimpleAudioEngine,"sharedEngine",sharedEngine) - - - - - - diff --git a/scripting/lua/script/DrawPrimitives.lua b/scripting/lua/script/DrawPrimitives.lua new file mode 100644 index 0000000000..5ee3b9ec46 --- /dev/null +++ b/scripting/lua/script/DrawPrimitives.lua @@ -0,0 +1,383 @@ +local dp_initialized = false +local dp_shader = nil +local dp_colorLocation = -1 +local dp_color = { 1.0, 1.0, 1.0, 1.0 } +local dp_pointSizeLocation = -1 +local dp_pointSize = 1.0 + +local kShader_Position_uColor = "ShaderPosition_uColor" + +local targetPlatform = CCApplication:getInstance():getTargetPlatform() + +local function lazy_init() + if not dp_initialized then + dp_shader = CCShaderCache:getInstance():getProgram(kShader_Position_uColor) + --dp_shader:retain() + if nil ~= dp_shader then + dp_colorLocation = gl.getUniformLocation( dp_shader:getProgram(), "u_color") + dp_pointSizeLocation = gl.getUniformLocation( dp_shader:getProgram(), "u_pointSize") + dp_Initialized = true + end + end + + if nil == dp_shader then + print("Error:dp_shader is nil!") + return false + end + + return true +end + +local function setDrawProperty() + gl.glEnableVertexAttribs( CCConstants.VERTEX_ATTRIB_FLAG_POSITION ) + dp_shader:use() + dp_shader:setUniformsForBuiltins() + dp_shader:setUniformLocationWith4fv(dp_colorLocation, dp_color, 1) +end + +function ccDrawInit() + lazy_init() +end + +function ccDrawFree() + dp_initialized = false +end + +function ccDrawColor4f(r,g,b,a) + dp_color[1] = r + dp_color[2] = g + dp_color[3] = b + dp_color[4] = a +end + +function ccPointSize(pointSize) + dp_pointSize = pointSize * CCDirector:sharedDirector():getContentScaleFactor() +end + +function ccDrawColor4B(r,g,b,a) + dp_color[1] = r / 255.0 + dp_color[2] = g / 255.0 + dp_color[3] = b / 255.0 + dp_color[4] = a / 255.0 +end + +function ccDrawPoint(point) + if not lazy_init() then + return + end + + local vertexBuffer = { } + + local function initBuffer() + vertexBuffer.buffer_id = gl.createBuffer() + gl.bindBuffer(gl.ARRAY_BUFFER,vertexBuffer.buffer_id) + local vertices = { point.x,point.y} + gl.bufferData(gl.ARRAY_BUFFER,2,vertices,gl.STATIC_DRAW) + gl.bindBuffer(gl.ARRAY_BUFFER, 0) + end + + initBuffer() + + setDrawProperty() + + dp_shader:setUniformLocationWith1f(dp_pointSizeLocation, dp_pointSize) + + gl.bindBuffer(gl.ARRAY_BUFFER,vertexBuffer.buffer_id) + gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) + gl.drawArrays(gl.POINTS,0,1) + gl.bindBuffer(gl.ARRAY_BUFFER,0) +end + +function ccDrawPoints(points,numOfPoint) + if not lazy_init() then + return + end + + local vertexBuffer = {} + local i = 1 + + local function initBuffer() + vertexBuffer.buffer_id = gl.createBuffer() + gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer.buffer_id) + local vertices = {} + for i = 1, numOfPoint do + vertices[2 * i - 1] = points[i].x + vertices[2 * i] = points[i].y + end + gl.bufferData(gl.ARRAY_BUFFER, numOfPoint * 2, vertices, gl.STATIC_DRAW) + gl.bindBuffer(gl.ARRAY_BUFFER, 0) + end + + initBuffer() + + setDrawProperty() + + dp_shader:setUniformLocationWith1f(dp_pointSizeLocation, dp_pointSize) + + gl.bindBuffer(gl.ARRAY_BUFFER,vertexBuffer.buffer_id) + gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) + gl.drawArrays(gl.POINTS,0,numOfPoint) + gl.bindBuffer(gl.ARRAY_BUFFER,0) +end + +function ccDrawLine(origin,destination) + if not lazy_init() then + return + end + + local vertexBuffer = {} + + local function initBuffer() + vertexBuffer.buffer_id = gl.createBuffer() + gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer.buffer_id) + local vertices = { origin.x, origin.y, destination.x, destination.y} + gl.bufferData(gl.ARRAY_BUFFER,4,vertices,gl.STATIC_DRAW) + gl.bindBuffer(gl.ARRAY_BUFFER, 0) + end + + initBuffer() + + setDrawProperty() + + gl.bindBuffer(gl.ARRAY_BUFFER,vertexBuffer.buffer_id) + gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) + gl.drawArrays(gl.LINES ,0,2) + gl.bindBuffer(gl.ARRAY_BUFFER,0) +end + +function ccDrawPoly(points,numOfPoints,closePolygon) + if not lazy_init() then + return + end + + local vertexBuffer = {} + local i = 1 + + local function initBuffer() + vertexBuffer.buffer_id = gl.createBuffer() + gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer.buffer_id) + local vertices = {} + for i = 1, numOfPoints do + vertices[2 * i - 1] = points[i].x + vertices[2 * i] = points[i].y + end + gl.bufferData(gl.ARRAY_BUFFER, numOfPoints * 2, vertices, gl.STATIC_DRAW) + gl.bindBuffer(gl.ARRAY_BUFFER, 0) + end + + initBuffer() + + setDrawProperty() + + gl.bindBuffer(gl.ARRAY_BUFFER,vertexBuffer.buffer_id) + gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) + if closePolygon then + gl.drawArrays(gl.LINE_LOOP , 0, numOfPoints) + else + gl.drawArrays(gl.LINE_STRIP, 0, numOfPoints) + end + gl.bindBuffer(gl.ARRAY_BUFFER,0) +end + +function ccDrawSolidPoly(points,numOfPoints,color) + if not lazy_init() then + return + end + + local vertexBuffer = {} + local i = 1 + + local function initBuffer() + vertexBuffer.buffer_id = gl.createBuffer() + gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer.buffer_id) + local vertices = {} + for i = 1, numOfPoints do + vertices[2 * i - 1] = points[i].x + vertices[2 * i] = points[i].y + + end + gl.bufferData(gl.ARRAY_BUFFER, numOfPoints * 2, vertices, gl.STATIC_DRAW) + gl.bindBuffer(gl.ARRAY_BUFFER, 0) + end + + initBuffer() + + gl.glEnableVertexAttribs( CCConstants.VERTEX_ATTRIB_FLAG_POSITION ) + dp_shader:use() + dp_shader:setUniformsForBuiltins() + dp_shader:setUniformLocationWith4fv(dp_colorLocation, color, 1) + + gl.bindBuffer(gl.ARRAY_BUFFER,vertexBuffer.buffer_id) + gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) + gl.drawArrays(gl.TRIANGLE_FAN , 0, numOfPoints) + gl.bindBuffer(gl.ARRAY_BUFFER,0) +end + +function ccDrawRect(origin,destination) + ccDrawLine(CCPoint:__call(origin.x, origin.y), CCPoint:__call(destination.x, origin.y)) + ccDrawLine(CCPoint:__call(destination.x, origin.y), CCPoint:__call(destination.x, destination.y)) + ccDrawLine(CCPoint:__call(destination.x, destination.y), CCPoint:__call(origin.x, destination.y)) + ccDrawLine(CCPoint:__call(origin.x, destination.y), CCPoint:__call(origin.x, origin.y)) +end + +function ccDrawSolidRect( origin,destination,color ) + local vertices = { origin, CCPoint:__call(destination.x, origin.y) , destination, CCPoint:__call(origin.x, destination.y) } + ccDrawSolidPoly(vertices,4,color) +end + +function ccDrawCircleScale( center, radius, angle, segments,drawLineToCenter,scaleX,scaleY) + if not lazy_init() then + return + end + + local additionalSegment = 1 + if drawLineToCenter then + additionalSegment = additionalSegment + 1 + end + + local vertexBuffer = { } + + local function initBuffer() + local coef = 2.0 * math.pi / segments + local i = 1 + local vertices = {} + vertexBuffer.buffer_id = gl.createBuffer() + gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer.buffer_id) + for i = 1, segments + 1 do + local rads = (i - 1) * coef + local j = radius * math.cos(rads + angle) * scaleX + center.x + local k = radius * math.sin(rads + angle) * scaleY + center.y + vertices[i * 2 - 1] = j + vertices[i * 2] = k + end + vertices[(segments + 2) * 2 - 1] = center.x + vertices[(segments + 2) * 2] = center.y + + gl.bufferData(gl.ARRAY_BUFFER, (segments + 2) * 2, vertices, gl.STATIC_DRAW) + gl.bindBuffer(gl.ARRAY_BUFFER, 0) + end + + initBuffer() + + setDrawProperty() + + gl.bindBuffer(gl.ARRAY_BUFFER,vertexBuffer.buffer_id) + gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) + gl.drawArrays(gl.LINE_STRIP , 0, segments + additionalSegment) + gl.bindBuffer(gl.ARRAY_BUFFER,0) +end + +function ccDrawCircle(center, radius, angle, segments, drawLineToCenter) + ccDrawCircleScale(center, radius, angle, segments, drawLineToCenter, 1.0, 1.0) +end + +function ccDrawSolidCircle(center, radius, angle, segments,scaleX,scaleY) + if not lazy_init() then + return + end + + local vertexBuffer = { } + + local function initBuffer() + local coef = 2.0 * math.pi / segments + local i = 1 + local vertices = {} + vertexBuffer.buffer_id = gl.createBuffer() + gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer.buffer_id) + for i = 1, segments + 1 do + local rads = (i - 1) * coef + local j = radius * math.cos(rads + angle) * scaleX + center.x + local k = radius * math.sin(rads + angle) * scaleY + center.y + vertices[i * 2 - 1] = j + vertices[i * 2] = k + end + vertices[(segments + 2) * 2 - 1] = center.x + vertices[(segments + 2) * 2] = center.y + + gl.bufferData(gl.ARRAY_BUFFER, (segments + 2) * 2, vertices, gl.STATIC_DRAW) + gl.bindBuffer(gl.ARRAY_BUFFER, 0) + end + + initBuffer() + + setDrawProperty() + + gl.bindBuffer(gl.ARRAY_BUFFER,vertexBuffer.buffer_id) + gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) + gl.drawArrays(gl.TRIANGLE_FAN , 0, segments + 1) + gl.bindBuffer(gl.ARRAY_BUFFER,0) +end + +function ccDrawQuadBezier(origin, control, destination, segments) + if not lazy_init() then + return + end + + local vertexBuffer = { } + + local function initBuffer() + local vertices = { } + local i = 1 + local t = 0.0 + + for i = 1, segments do + vertices[2 * i - 1] = math.pow(1 - t,2) * origin.x + 2.0 * (1 - t) * t * control.x + t * t * destination.x + vertices[2 * i] = math.pow(1 - t,2) * origin.y + 2.0 * (1 - t) * t * control.y + t * t * destination.y + t = t + 1.0 / segments + end + + vertices[2 * (segments + 1) - 1] = destination.x + vertices[2 * (segments + 1)] = destination.y + + vertexBuffer.buffer_id = gl.createBuffer() + gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer.buffer_id) + gl.bufferData(gl.ARRAY_BUFFER, (segments + 1) * 2, vertices, gl.STATIC_DRAW) + gl.bindBuffer(gl.ARRAY_BUFFER, 0) + end + + initBuffer() + + setDrawProperty() + + gl.bindBuffer(gl.ARRAY_BUFFER,vertexBuffer.buffer_id) + gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) + gl.drawArrays(gl.LINE_STRIP , 0, segments + 1) + gl.bindBuffer(gl.ARRAY_BUFFER,0) +end + +function ccDrawCubicBezier(origin, control1, control2, destination, segments) + if not lazy_init then + return + end + + local vertexBuffer = { } + + local function initBuffer() + local vertices = { } + local t = 0 + local i = 1 + + for i = 1, segments do + vertices[2 * i - 1] = math.pow(1 - t,3) * origin.x + 3.0 * math.pow(1 - t, 2) * t * control1.x + 3.0 * (1 - t) * t * t * control2.x + t * t * t * destination.x + vertices[2 * i] = math.pow(1 - t,3) * origin.y + 3.0 * math.pow(1 - t, 2) * t * control1.y + 3.0 * (1 - t) * t * t * control2.y + t * t * t * destination.y + t = t + 1.0 / segments + end + + vertices[2 * (segments + 1) - 1] = destination.x + vertices[2 * (segments + 1)] = destination.y + + vertexBuffer.buffer_id = gl.createBuffer() + gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer.buffer_id) + gl.bufferData(gl.ARRAY_BUFFER, (segments + 1) * 2, vertices, gl.STATIC_DRAW) + gl.bindBuffer(gl.ARRAY_BUFFER, 0) + end + + initBuffer() + + setDrawProperty() + + gl.bindBuffer(gl.ARRAY_BUFFER,vertexBuffer.buffer_id) + gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) + gl.drawArrays(gl.LINE_STRIP , 0, segments + 1) + gl.bindBuffer(gl.ARRAY_BUFFER,0) +end diff --git a/samples/Cpp/TestCpp/proj.emscripten/index.html b/tools/emscripten-template/index.html similarity index 95% rename from samples/Cpp/TestCpp/proj.emscripten/index.html rename to tools/emscripten-template/index.html index d1c4c339e0..c8ddb500e0 100644 --- a/samples/Cpp/TestCpp/proj.emscripten/index.html +++ b/tools/emscripten-template/index.html @@ -3,7 +3,7 @@ - TestCpp + JS_APPLICATION