diff --git a/AUTHORS b/AUTHORS index b31fa3b766..7dd5a123d2 100644 --- a/AUTHORS +++ b/AUTHORS @@ -677,6 +677,7 @@ Developers: seobyeongky Updates spine runtime. + Fixed a potential bug in Data's copy constructor. luocker Fix a bug that string itself is also modified in `String::componentsSeparatedByString`. diff --git a/CHANGELOG b/CHANGELOG index 5961c04625..a8ed425338 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -16,6 +16,7 @@ cocos2d-x-3.0beta0 ?? 2013 [FIX] Deprecates FileUtils::getFileData, adds FileUtils::getStringFromFile/getDataFromFile. [FIX] GUI refactoring: Removes UI prefix, Widget is inherited from Node, uses new containers(Vector, Map). [FIX] String itself is also modified in `String::componentsSeparatedByString`. + [FIX] Sprites with PhysicsBody move to a wrong position when game resume from background. [Android] [NEW] build/android-build.sh: add supporting to generate .apk file [FIX] XMLHttpRequest receives wrong binary array. diff --git a/cocos/2d/CCActionCatmullRom.cpp b/cocos/2d/CCActionCatmullRom.cpp index e7831d2bab..b00c2c889d 100644 --- a/cocos/2d/CCActionCatmullRom.cpp +++ b/cocos/2d/CCActionCatmullRom.cpp @@ -43,7 +43,7 @@ NS_CC_BEGIN; * Implementation of PointArray */ -PointArray* PointArray::create(int capacity) +PointArray* PointArray::create(ssize_t capacity) { PointArray* pointArray = new PointArray(); if (pointArray) @@ -63,7 +63,7 @@ PointArray* PointArray::create(int capacity) } -bool PointArray::initWithCapacity(int capacity) +bool PointArray::initWithCapacity(ssize_t capacity) { _controlPoints = new vector(); @@ -126,19 +126,19 @@ void PointArray::addControlPoint(Point controlPoint) _controlPoints->push_back(new Point(controlPoint.x, controlPoint.y)); } -void PointArray::insertControlPoint(Point &controlPoint, int index) +void PointArray::insertControlPoint(Point &controlPoint, ssize_t index) { Point *temp = new Point(controlPoint.x, controlPoint.y); _controlPoints->insert(_controlPoints->begin() + index, temp); } -Point PointArray::getControlPointAtIndex(int index) +Point PointArray::getControlPointAtIndex(ssize_t index) { index = static_cast(MIN(_controlPoints->size()-1, MAX(index, 0))); return *(_controlPoints->at(index)); } -void PointArray::replaceControlPoint(cocos2d::Point &controlPoint, int index) +void PointArray::replaceControlPoint(cocos2d::Point &controlPoint, ssize_t index) { Point *temp = _controlPoints->at(index); @@ -146,7 +146,7 @@ void PointArray::replaceControlPoint(cocos2d::Point &controlPoint, int index) temp->y = controlPoint.y; } -void PointArray::removeControlPointAtIndex(int index) +void PointArray::removeControlPointAtIndex(ssize_t index) { vector::iterator iter = _controlPoints->begin() + index; Point* removedPoint = *iter; @@ -154,9 +154,9 @@ void PointArray::removeControlPointAtIndex(int index) delete removedPoint; } -int PointArray::count() const +ssize_t PointArray::count() const { - return static_cast(_controlPoints->size()); + return _controlPoints->size(); } PointArray* PointArray::reverse() const @@ -177,11 +177,11 @@ PointArray* PointArray::reverse() const void PointArray::reverseInline() { - auto l = _controlPoints->size(); + size_t l = _controlPoints->size(); Point *p1 = nullptr; Point *p2 = nullptr; - int x, y; - for (int i = 0; i < l/2; ++i) + float x, y; + for (size_t i = 0; i < l/2; ++i) { p1 = _controlPoints->at(i); p2 = _controlPoints->at(l-i-1); @@ -383,7 +383,7 @@ CardinalSplineBy* CardinalSplineBy::reverse() const // convert "absolutes" to "diffs" // Point p = copyConfig->getControlPointAtIndex(0); - for (unsigned int i = 1; i < copyConfig->count(); ++i) + for (ssize_t i = 1; i < copyConfig->count(); ++i) { Point current = copyConfig->getControlPointAtIndex(i); Point diff = current - p; @@ -405,7 +405,7 @@ CardinalSplineBy* CardinalSplineBy::reverse() const p = -p; pReverse->insertControlPoint(p, 0); - for (unsigned int i = 1; i < pReverse->count(); ++i) + for (ssize_t i = 1; i < pReverse->count(); ++i) { Point current = pReverse->getControlPointAtIndex(i); current = -current; @@ -528,7 +528,7 @@ CatmullRomBy* CatmullRomBy::reverse() const // convert "absolutes" to "diffs" // Point p = copyConfig->getControlPointAtIndex(0); - for (unsigned int i = 1; i < copyConfig->count(); ++i) + for (ssize_t i = 1; i < copyConfig->count(); ++i) { Point current = copyConfig->getControlPointAtIndex(i); Point diff = current - p; @@ -550,7 +550,7 @@ CatmullRomBy* CatmullRomBy::reverse() const p = -p; reverse->insertControlPoint(p, 0); - for (unsigned int i = 1; i < reverse->count(); ++i) + for (ssize_t i = 1; i < reverse->count(); ++i) { Point current = reverse->getControlPointAtIndex(i); current = -current; diff --git a/cocos/2d/CCActionCatmullRom.h b/cocos/2d/CCActionCatmullRom.h index 5678407dc0..0c47a4137f 100644 --- a/cocos/2d/CCActionCatmullRom.h +++ b/cocos/2d/CCActionCatmullRom.h @@ -61,7 +61,7 @@ public: /** creates and initializes a Points array with capacity * @js NA */ - static PointArray* create(int capacity); + static PointArray* create(ssize_t capacity); /** * @js NA @@ -77,7 +77,7 @@ public: /** initializes a Catmull Rom config with a capacity hint * @js NA */ - bool initWithCapacity(int capacity); + bool initWithCapacity(ssize_t capacity); /** appends a control point * @js NA @@ -87,27 +87,27 @@ public: /** inserts a controlPoint at index * @js NA */ - void insertControlPoint(Point &controlPoint, int index); + void insertControlPoint(Point &controlPoint, ssize_t index); /** replaces an existing controlPoint at index * @js NA */ - void replaceControlPoint(Point &controlPoint, int index); + void replaceControlPoint(Point &controlPoint, ssize_t index); /** get the value of a controlPoint at a given index * @js NA */ - Point getControlPointAtIndex(int index); + Point getControlPointAtIndex(ssize_t index); /** deletes a control point at a given index * @js NA */ - void removeControlPointAtIndex(int index); + void removeControlPointAtIndex(ssize_t index); /** returns the number of objects of the control point array * @js NA */ - int count() const; + ssize_t count() const; /** returns a new copy of the array reversed. User is responsible for releasing this copy * @js NA diff --git a/cocos/2d/CCAnimationCache.cpp b/cocos/2d/CCAnimationCache.cpp index 53fd62cd80..59d9144252 100644 --- a/cocos/2d/CCAnimationCache.cpp +++ b/cocos/2d/CCAnimationCache.cpp @@ -102,7 +102,8 @@ void AnimationCache::parseVersion1(const ValueMap& animations) continue; } - Vector frames(static_cast(frameNames.size())); + ssize_t frameNameSize = frameNames.size(); + Vector frames(frameNameSize); for (auto& frameName : frameNames) { @@ -118,12 +119,12 @@ void AnimationCache::parseVersion1(const ValueMap& animations) frames.pushBack(animFrame); } - if ( frames.size() == 0 ) + if ( frames.empty() ) { CCLOG("cocos2d: AnimationCache: None of the frames for animation '%s' were found in the SpriteFrameCache. Animation is not being added to the Animation Cache.", iter->first.c_str()); continue; } - else if ( frames.size() != frameNames.size() ) + else if ( frames.size() != frameNameSize ) { CCLOG("cocos2d: AnimationCache: An animation in your dictionary refers to a frame which is not in the SpriteFrameCache. Some or all of the frames for the animation '%s' may be missing.", iter->first.c_str()); } diff --git a/cocos/2d/CCAtlasNode.cpp b/cocos/2d/CCAtlasNode.cpp index 741197e233..aaaff04c27 100644 --- a/cocos/2d/CCAtlasNode.cpp +++ b/cocos/2d/CCAtlasNode.cpp @@ -263,12 +263,12 @@ TextureAtlas * AtlasNode::getTextureAtlas() const return _textureAtlas; } -int AtlasNode::getQuadsToDraw() const +ssize_t AtlasNode::getQuadsToDraw() const { return _quadsToDraw; } -void AtlasNode::setQuadsToDraw(int quadsToDraw) +void AtlasNode::setQuadsToDraw(ssize_t quadsToDraw) { _quadsToDraw = quadsToDraw; } diff --git a/cocos/2d/CCAtlasNode.h b/cocos/2d/CCAtlasNode.h index fc0636326b..83ea2ae939 100644 --- a/cocos/2d/CCAtlasNode.h +++ b/cocos/2d/CCAtlasNode.h @@ -62,8 +62,8 @@ public: void setTextureAtlas(TextureAtlas* textureAtlas); TextureAtlas* getTextureAtlas() const; - void setQuadsToDraw(int quadsToDraw); - int getQuadsToDraw() const; + void setQuadsToDraw(ssize_t quadsToDraw); + ssize_t getQuadsToDraw() const; // Overrides @@ -125,7 +125,7 @@ protected: BlendFunc _blendFunc; // quads to draw - int _quadsToDraw; + ssize_t _quadsToDraw; // color uniform GLint _uniformColor; // This varible is only used for LabelAtlas FPS display. So plz don't modify its value. diff --git a/cocos/2d/CCDirector.cpp b/cocos/2d/CCDirector.cpp index 40468aa179..b0ecc02c4a 100644 --- a/cocos/2d/CCDirector.cpp +++ b/cocos/2d/CCDirector.cpp @@ -847,13 +847,10 @@ void Director::resume() setAnimationInterval(_oldAnimationInterval); - if (gettimeofday(_lastUpdate, nullptr) != 0) - { - CCLOG("cocos2d: Director: Error in gettimeofday"); - } - _paused = false; _deltaTime = 0; + // fix issue #3509, skip one fps to avoid incorrect time calculation. + setNextDeltaTimeZero(true); } // display the FPS using a LabelAtlas @@ -1076,6 +1073,8 @@ void DisplayLinkDirector::startAnimation() } _invalid = false; + + Application::getInstance()->setAnimationInterval(_animationInterval); } void DisplayLinkDirector::mainLoop() diff --git a/cocos/2d/CCEventDispatcher.cpp b/cocos/2d/CCEventDispatcher.cpp index 21c8a9b82f..151a6c267c 100644 --- a/cocos/2d/CCEventDispatcher.cpp +++ b/cocos/2d/CCEventDispatcher.cpp @@ -97,10 +97,10 @@ static EventListener::ListenerID __getListenerID(Event* event) return ret; } -EventDispatcher::EventListenerVector::EventListenerVector() -: _sceneGraphListeners(nullptr) -, _fixedListeners(nullptr) -, _gt0Index(0) +EventDispatcher::EventListenerVector::EventListenerVector() : + _fixedListeners(nullptr), + _sceneGraphListeners(nullptr), + _gt0Index(0) { } @@ -501,11 +501,12 @@ void EventDispatcher::dispatchEventToListeners(EventListenerVector* listeners, s auto fixedPriorityListeners = listeners->getFixedPriorityListeners(); auto sceneGraphPriorityListeners = listeners->getSceneGraphPriorityListeners(); - int i = 0; + ssize_t i = 0; // priority < 0 if (fixedPriorityListeners) { - for (; !fixedPriorityListeners->empty() && i < listeners->getGt0Index(); ++i) + bool isEmpty = fixedPriorityListeners->empty(); + for (; !isEmpty && i < listeners->getGt0Index(); ++i) { auto l = fixedPriorityListeners->at(i); if (!l->isPaused() && l->isRegistered() && onEvent(l)) @@ -537,7 +538,8 @@ void EventDispatcher::dispatchEventToListeners(EventListenerVector* listeners, s if (!shouldStopPropagation) { // priority > 0 - for (; i < fixedPriorityListeners->size(); ++i) + ssize_t size = fixedPriorityListeners->size(); + for (; i < size; ++i) { auto l = fixedPriorityListeners->at(i); diff --git a/cocos/2d/CCEventListenerMouse.cpp b/cocos/2d/CCEventListenerMouse.cpp index ae1f3dd4c4..63ebebd501 100644 --- a/cocos/2d/CCEventListenerMouse.cpp +++ b/cocos/2d/CCEventListenerMouse.cpp @@ -67,8 +67,8 @@ EventListenerMouse* EventListenerMouse::clone() } EventListenerMouse::EventListenerMouse() -: onMouseUp(nullptr) -, onMouseDown(nullptr) +: onMouseDown(nullptr) +, onMouseUp(nullptr) , onMouseMove(nullptr) , onMouseScroll(nullptr) { diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index f61c1124a3..c2a512d482 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -102,16 +102,20 @@ Label* Label::createWithAtlas(FontAtlas *atlas, TextHAlignment alignment, int li Label::Label(FontAtlas *atlas, TextHAlignment alignment, bool useDistanceField,bool useA8Shader) : _reusedLetter(nullptr) +, _multilineEnable(true) +, _commonLineHeight(0.0f) , _lineBreakWithoutSpaces(false) -,_multilineEnable(true) +, _width(0.0f) , _alignment(alignment) , _currentUTF16String(0) , _originalUTF16String(0) -, _advances(0) +, _advances(nullptr) , _fontAtlas(atlas) , _isOpacityModifyRGB(true) -,_useDistanceField(useDistanceField) -,_useA8Shader(useA8Shader) +, _useDistanceField(useDistanceField) +, _useA8Shader(useA8Shader) +, _fontSize(0) +, _uniformEffectColor(0) { } diff --git a/cocos/2d/CCLabelAtlas.cpp b/cocos/2d/CCLabelAtlas.cpp index cab9f98472..63511eec7d 100644 --- a/cocos/2d/CCLabelAtlas.cpp +++ b/cocos/2d/CCLabelAtlas.cpp @@ -113,7 +113,7 @@ bool LabelAtlas::initWithString(const std::string& theString, const std::string& //CCLabelAtlas - Atlas generation void LabelAtlas::updateAtlasValues() { - auto n = _string.length(); + ssize_t n = _string.length(); const unsigned char *s = (unsigned char*)_string.c_str(); @@ -130,7 +130,7 @@ void LabelAtlas::updateAtlasValues() CCASSERT(n <= _textureAtlas->getCapacity(), "updateAtlasValues: Invalid String length"); V3F_C4B_T2F_Quad* quads = _textureAtlas->getQuads(); - for(int i = 0; i < n; i++) { + for(ssize_t i = 0; i < n; i++) { unsigned char a = s[i] - _mapStartChar; float row = (float) (a % _itemsPerRow); @@ -178,7 +178,7 @@ void LabelAtlas::updateAtlasValues() } if (n > 0 ){ _textureAtlas->setDirty(true); - auto totalQuads = _textureAtlas->getTotalQuads(); + ssize_t totalQuads = _textureAtlas->getTotalQuads(); if (n > totalQuads) { _textureAtlas->increaseTotalQuadsWith(static_cast(n - totalQuads)); } @@ -188,10 +188,10 @@ void LabelAtlas::updateAtlasValues() //CCLabelAtlas - LabelProtocol void LabelAtlas::setString(const std::string &label) { - auto len = label.size(); + ssize_t len = label.size(); if (len > _textureAtlas->getTotalQuads()) { - _textureAtlas->resizeCapacity(static_cast(len)); + _textureAtlas->resizeCapacity(len); } _string.clear(); _string = label; @@ -201,7 +201,7 @@ void LabelAtlas::setString(const std::string &label) this->setContentSize(s); - _quadsToDraw = static_cast(len); + _quadsToDraw = len; } const std::string& LabelAtlas::getString(void) const diff --git a/cocos/2d/CCLabelBMFont.cpp b/cocos/2d/CCLabelBMFont.cpp index 74b33783d5..7c2860fc2f 100644 --- a/cocos/2d/CCLabelBMFont.cpp +++ b/cocos/2d/CCLabelBMFont.cpp @@ -947,7 +947,7 @@ void LabelBMFont::updateLabel() size_t size = multiline_string.size(); unsigned short* str_new = new unsigned short[size + 1]; - for (int j = 0; j < size; ++j) + for (size_t j = 0; j < size; ++j) { str_new[j] = multiline_string[j]; } diff --git a/cocos/2d/CCLabelTextFormatter.cpp b/cocos/2d/CCLabelTextFormatter.cpp index 1094fda4b9..7967c6a80d 100644 --- a/cocos/2d/CCLabelTextFormatter.cpp +++ b/cocos/2d/CCLabelTextFormatter.cpp @@ -200,7 +200,7 @@ bool LabelTextFormatter::multilineText(LabelTextFormatProtocol *theLabel) size_t size = multiline_string.size(); unsigned short* strNew = new unsigned short[size + 1]; - for (int j = 0; j < size; ++j) + for (size_t j = 0; j < size; ++j) { strNew[j] = multiline_string[j]; } diff --git a/cocos/2d/CCLayer.cpp b/cocos/2d/CCLayer.cpp index 71c0b16dbc..07d6dcf300 100644 --- a/cocos/2d/CCLayer.cpp +++ b/cocos/2d/CCLayer.cpp @@ -53,11 +53,11 @@ Layer::Layer() : _touchEnabled(false) , _accelerometerEnabled(false) , _keyboardEnabled(false) -, _touchMode(Touch::DispatchMode::ALL_AT_ONCE) -, _swallowsTouches(true) , _touchListener(nullptr) , _keyboardListener(nullptr) , _accelerationListener(nullptr) +, _touchMode(Touch::DispatchMode::ALL_AT_ONCE) +, _swallowsTouches(true) { _ignoreAnchorPointForPosition = true; setAnchorPoint(Point(0.5f, 0.5f)); diff --git a/cocos/2d/CCMenu.cpp b/cocos/2d/CCMenu.cpp index 5f30d8f504..c6d2b787eb 100644 --- a/cocos/2d/CCMenu.cpp +++ b/cocos/2d/CCMenu.cpp @@ -346,7 +346,7 @@ void Menu::alignItemsInColumns(int columns, va_list args) void Menu::alignItemsInColumnsWithArray(const ValueVector& rows) { int height = -5; - int row = 0; + size_t row = 0; int rowHeight = 0; int columnsOccupied = 0; int rowColumns = 0; @@ -441,7 +441,7 @@ void Menu::alignItemsInRowsWithArray(const ValueVector& columns) int width = -10; int columnHeight = -5; - int column = 0; + size_t column = 0; int columnWidth = 0; int rowsOccupied = 0; int columnRows; diff --git a/cocos/2d/CCNode.cpp b/cocos/2d/CCNode.cpp index 496fcb4a11..aaee1921c7 100644 --- a/cocos/2d/CCNode.cpp +++ b/cocos/2d/CCNode.cpp @@ -44,7 +44,7 @@ THE SOFTWARE. #include "CCEventTouch.h" #include "CCScene.h" -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS #include "CCPhysicsBody.h" #endif @@ -123,7 +123,7 @@ Node::Node(void) , _isTransitionFinished(false) , _updateScriptHandler(0) , _componentContainer(nullptr) -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS , _physicsBody(nullptr) #endif , _displayedOpacity(255) @@ -178,7 +178,7 @@ Node::~Node() CC_SAFE_DELETE(_componentContainer); -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS CC_SAFE_RELEASE(_physicsBody); #endif } @@ -264,7 +264,7 @@ void Node::setRotation(float newRotation) _rotationX = _rotationY = newRotation; _transformDirty = _inverseDirty = true; -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS if (_physicsBody) { _physicsBody->setRotation(newRotation); @@ -354,7 +354,7 @@ void Node::setPosition(const Point& newPosition) _position = newPosition; _transformDirty = _inverseDirty = true; -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS if (_physicsBody) { _physicsBody->setPosition(newPosition); @@ -604,7 +604,7 @@ void Node::addChild(Node *child, int zOrder, int tag) this->insertChild(child, zOrder); -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS for (Node* node = this->getParent(); node != nullptr; node = node->getParent()) { if (dynamic_cast(node) != nullptr) @@ -739,7 +739,7 @@ void Node::detachChild(Node *child, ssize_t childIndex, bool doCleanup) child->onExit(); } -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS if (child->_physicsBody != nullptr) { child->_physicsBody->removeFromWorld(); @@ -848,7 +848,7 @@ void Node::transformAncestors() void Node::transform() { -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS updatePhysicsTransform(); #endif @@ -1170,8 +1170,8 @@ const kmMat4& Node::getNodeToParentTransform() const // If skew is needed, apply skew and then anchor point if (needsSkewMatrix) { - kmMat4 skewMatrix = { 1, tanf(CC_DEGREES_TO_RADIANS(_skewY)), 0, 0, - tanf(CC_DEGREES_TO_RADIANS(_skewX)), 1, 0, 0, + kmMat4 skewMatrix = { 1, (float)tanf(CC_DEGREES_TO_RADIANS(_skewY)), 0, 0, + (float)tanf(CC_DEGREES_TO_RADIANS(_skewX)), 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}; @@ -1324,7 +1324,7 @@ Point Node::convertTouchToNodeSpaceAR(Touch *touch) const return this->convertToNodeSpaceAR(point); } -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS bool Node::updatePhysicsTransform() { if (_physicsBody != nullptr && _physicsBody->getWorld() != nullptr && !_physicsBody->isResting()) @@ -1374,7 +1374,7 @@ void Node::removeAllComponents() _componentContainer->removeAll(); } -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS void Node::setPhysicsBody(PhysicsBody* body) { if (_physicsBody != nullptr) diff --git a/cocos/2d/CCNode.h b/cocos/2d/CCNode.h index af95adc220..46cac36cdb 100644 --- a/cocos/2d/CCNode.h +++ b/cocos/2d/CCNode.h @@ -54,7 +54,7 @@ class Component; class ComponentContainer; class EventDispatcher; class Scene; -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS class PhysicsBody; #endif @@ -590,7 +590,7 @@ public: * * @return a Node object whose tag equals to the input parameter */ - Node * getChildByTag(int tag); + virtual Node * getChildByTag(int tag); /** * Return an array of children * @@ -615,7 +615,7 @@ public: * * @return The amount of children. */ - ssize_t getChildrenCount() const; + virtual ssize_t getChildrenCount() const; /** * Sets the parent node @@ -1341,7 +1341,7 @@ public: /// @} end of component functions -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS /** * set the PhysicsBody that let the sprite effect with physics */ @@ -1465,7 +1465,7 @@ protected: ComponentContainer *_componentContainer; ///< Dictionary of components -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS PhysicsBody* _physicsBody; ///< the physicsBody the node have #endif diff --git a/cocos/2d/CCNodeGrid.cpp b/cocos/2d/CCNodeGrid.cpp index 7053d184cf..1f8eabc137 100644 --- a/cocos/2d/CCNodeGrid.cpp +++ b/cocos/2d/CCNodeGrid.cpp @@ -47,8 +47,8 @@ NodeGrid* NodeGrid::create() } NodeGrid::NodeGrid() -: _nodeGrid(nullptr) -, _gridTarget(nullptr) +: _gridTarget(nullptr) +, _nodeGrid(nullptr) { } diff --git a/cocos/2d/CCScene.cpp b/cocos/2d/CCScene.cpp index b31a499af6..2dcf75283c 100644 --- a/cocos/2d/CCScene.cpp +++ b/cocos/2d/CCScene.cpp @@ -34,7 +34,7 @@ THE SOFTWARE. NS_CC_BEGIN Scene::Scene() -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS : _physicsWorld(nullptr) #endif { @@ -44,7 +44,7 @@ Scene::Scene() Scene::~Scene() { -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS CC_SAFE_DELETE(_physicsWorld); #endif } @@ -88,7 +88,22 @@ Scene* Scene::getScene() return this; } -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS +void Scene::addChild(Node* child, int zOrder, int tag) +{ + Node::addChild(child, zOrder, tag); + addChildToPhysicsWorld(child); +} + +void Scene::update(float delta) +{ + Node::update(delta); + if (nullptr != _physicsWorld) + { + _physicsWorld->update(delta); + } +} + Scene *Scene::createWithPhysics() { Scene *ret = new Scene(); @@ -121,13 +136,6 @@ bool Scene::initWithPhysics() return ret; } -void Scene::addChild(Node* child, int zOrder, int tag) -{ - Node::addChild(child, zOrder, tag); - - addChildToPhysicsWorld(child); -} - void Scene::addChildToPhysicsWorld(Node* child) { if (_physicsWorld) @@ -149,18 +157,6 @@ void Scene::addChildToPhysicsWorld(Node* child) addToPhysicsWorldFunc(child); } } - -void Scene::update(float delta) -{ - Node::update(delta); - - if (nullptr != _physicsWorld) - { - _physicsWorld->update(delta); - } - -} #endif - NS_CC_END diff --git a/cocos/2d/CCScene.h b/cocos/2d/CCScene.h index b52d38e969..21576a87a7 100644 --- a/cocos/2d/CCScene.h +++ b/cocos/2d/CCScene.h @@ -52,42 +52,36 @@ class CC_DLL Scene : public Node public: /** creates a new Scene object */ static Scene *create(); -#ifdef CC_USE_PHYSICS - static Scene *createWithPhysics(); -#endif // Overrides virtual Scene *getScene() override; -#ifdef CC_USE_PHYSICS -public: - - inline PhysicsWorld* getPhysicsWorld() { return _physicsWorld; } - using Node::addChild; - virtual void addChild(Node* child, int zOrder, int tag) override; - virtual void update(float delta) override; virtual std::string getDescription() const override; +protected: + Scene(); + virtual ~Scene(); + bool init(); + + friend class Node; + friend class SpriteBatchNode; + +private: + CC_DISALLOW_COPY_AND_ASSIGN(Scene); + +#if CC_USE_PHYSICS +public: + virtual void addChild(Node* child, int zOrder, int tag) override; + virtual void update(float delta) override; + inline PhysicsWorld* getPhysicsWorld() { return _physicsWorld; } + static Scene *createWithPhysics(); protected: bool initWithPhysics(); void addChildToPhysicsWorld(Node* child); PhysicsWorld* _physicsWorld; #endif // CC_USE_PHYSICS - - - -protected: - Scene(); - virtual ~Scene(); - bool init(); - - friend class Node; - friend class SpriteBatchNode; - -private: - CC_DISALLOW_COPY_AND_ASSIGN(Scene); }; // end of scene group diff --git a/cocos/2d/CCShaderCache.cpp b/cocos/2d/CCShaderCache.cpp index f9c9da8f2a..5c751aa843 100644 --- a/cocos/2d/CCShaderCache.cpp +++ b/cocos/2d/CCShaderCache.cpp @@ -185,6 +185,11 @@ void ShaderCache::reloadDefaultShaders() p->reset(); loadDefaultShader(p, kShaderType_PositionTextureColor); + // Position Texture Color without MVP shader + p = getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP); + p->reset(); + loadDefaultShader(p, kShaderType_PositionTextureColor_noMVP); + // Position Texture Color alpha test p = getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST); p->reset(); diff --git a/cocos/2d/CCSprite.cpp b/cocos/2d/CCSprite.cpp index 642e865aee..ee07bfca4c 100644 --- a/cocos/2d/CCSprite.cpp +++ b/cocos/2d/CCSprite.cpp @@ -502,7 +502,7 @@ void Sprite::updateTransform(void) { CCASSERT(_batchNode, "updateTransform is only valid when Sprite is being rendered using an SpriteBatchNode"); -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS if (updatePhysicsTransform()) { setDirty(true); @@ -711,7 +711,7 @@ bool Sprite::culling() const void Sprite::updateQuadVertices() { -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS updatePhysicsTransform(); setDirty(true); #endif diff --git a/cocos/2d/CCTextFieldTTF.cpp b/cocos/2d/CCTextFieldTTF.cpp index 6924296cfc..4c26627956 100644 --- a/cocos/2d/CCTextFieldTTF.cpp +++ b/cocos/2d/CCTextFieldTTF.cpp @@ -209,7 +209,7 @@ void TextFieldTTF::deleteBackward() } // get the delete byte number - int deleteLen = 1; // default, erase 1 byte + size_t deleteLen = 1; // default, erase 1 byte while(0x80 == (0xC0 & _inputText.at(len - deleteLen))) { diff --git a/cocos/2d/CCTextImage.cpp b/cocos/2d/CCTextImage.cpp index 14b5880ea9..97ab7dd8a0 100644 --- a/cocos/2d/CCTextImage.cpp +++ b/cocos/2d/CCTextImage.cpp @@ -51,7 +51,7 @@ TextPageDef::~TextPageDef() { size_t numLines = _lines.size(); - for( int c = 0; c", _textures.size()); + return StringUtils::format("", _textures.size()); } void TextureCache::addImageAsync(const std::string &path, Object *target, SEL_CallFuncO selector) diff --git a/cocos/2d/ccConfig.h b/cocos/2d/ccConfig.h index 5858fe88a0..e411a8d658 100644 --- a/cocos/2d/ccConfig.h +++ b/cocos/2d/ccConfig.h @@ -268,7 +268,7 @@ To enable set it to a value different than 0. Disabled by default. /** Use physics integration API */ #ifndef CC_USE_PHYSICS -#define CC_USE_PHYSICS +#define CC_USE_PHYSICS 1 #endif #endif // __CCCONFIG_H__ diff --git a/cocos/2d/platform/CCImageCommon_cpp.h b/cocos/2d/platform/CCImageCommon_cpp.h index a05e11e4fa..64cef42ea1 100644 --- a/cocos/2d/platform/CCImageCommon_cpp.h +++ b/cocos/2d/platform/CCImageCommon_cpp.h @@ -1200,7 +1200,8 @@ bool Image::initWithPVRv2Data(const unsigned char * data, ssize_t dataLen) } if (! configuration->supportsNPOT() && - (header->width != ccNextPOT(header->width) || header->height != ccNextPOT(header->height))) + (static_cast(header->width) != ccNextPOT(header->width) + || static_cast(header->height) != ccNextPOT(header->height))) { CCLOG("cocos2d: ERROR: Loading an NPOT texture (%dx%d) but is not supported on this device", header->width, header->height); return false; diff --git a/cocos/2d/platform/win32/CCFileUtilsWin32.cpp b/cocos/2d/platform/win32/CCFileUtilsWin32.cpp index 6f79091506..0572b95591 100644 --- a/cocos/2d/platform/win32/CCFileUtilsWin32.cpp +++ b/cocos/2d/platform/win32/CCFileUtilsWin32.cpp @@ -150,7 +150,7 @@ static Data getData(const std::string& filename, bool forString) } DWORD sizeRead = 0; BOOL successed = FALSE; - successed = ::ReadFile(fileHandle, buffer, *size, &sizeRead, NULL); + successed = ::ReadFile(fileHandle, buffer, size, &sizeRead, NULL); ::CloseHandle(fileHandle); if (!successed) @@ -180,22 +180,21 @@ static Data getData(const std::string& filename, bool forString) return ret; } -std::string FileUtilsAndroid::getStringFromFile(const std::string& filename) +std::string FileUtilsWin32::getStringFromFile(const std::string& filename) { Data data = getData(filename, true); std::string ret((const char*)data.getBytes()); return ret; } -Data FileUtilsAndroid::getDataFromFile(const std::string& filename) +Data FileUtilsWin32::getDataFromFile(const std::string& filename) { return getData(filename, false); } -unsigned char* FileUtilsWin32::getFileData(const char* filename, const char* mode, ssize_t* size) +unsigned char* FileUtilsWin32::getFileData(const std::string& filename, const char* mode, ssize_t* size) { unsigned char * pBuffer = NULL; - CCASSERT(filename != NULL && size != NULL && mode != NULL, "Invalid parameters."); *size = 0; do { diff --git a/cocos/2d/platform/win32/CCFileUtilsWin32.h b/cocos/2d/platform/win32/CCFileUtilsWin32.h index 78680a1c10..bfbdd5c725 100644 --- a/cocos/2d/platform/win32/CCFileUtilsWin32.h +++ b/cocos/2d/platform/win32/CCFileUtilsWin32.h @@ -58,7 +58,7 @@ protected: * @return Upon success, a pointer to the data is returned, otherwise NULL. * @warning Recall: you are responsible for calling delete[] on any Non-NULL pointer returned. */ - CC_DEPRECATED_ATTRIBUTE virtual unsigned char* getFileData(const char* filename, const char* mode, ssize_t * size) override; + CC_DEPRECATED_ATTRIBUTE virtual unsigned char* getFileData(const std::string& filename, const char* mode, ssize_t * size) override; /** * Gets string from a file. diff --git a/cocos/2d/renderer/CCCustomCommand.cpp b/cocos/2d/renderer/CCCustomCommand.cpp index 49e7a0a06c..741ba2ea3a 100644 --- a/cocos/2d/renderer/CCCustomCommand.cpp +++ b/cocos/2d/renderer/CCCustomCommand.cpp @@ -29,9 +29,9 @@ RenderCommandPool CustomCommand::_commandPool; CustomCommand::CustomCommand() :RenderCommand() +, func(nullptr) , _viewport(0) , _depth(0) -, func(nullptr) { _type = RenderCommand::Type::CUSTOM_COMMAND; } diff --git a/cocos/2d/renderer/CCRenderer.cpp b/cocos/2d/renderer/CCRenderer.cpp index 0eeca3844f..22ef74fb05 100644 --- a/cocos/2d/renderer/CCRenderer.cpp +++ b/cocos/2d/renderer/CCRenderer.cpp @@ -41,9 +41,9 @@ using namespace std; Renderer::Renderer() :_lastMaterialID(0) -,_numQuads(0) ,_firstCommand(0) ,_lastCommand(0) +,_numQuads(0) ,_glViewAssigned(false) { _commandGroupStack.push(DEFAULT_RENDER_QUEUE); @@ -65,11 +65,14 @@ Renderer::~Renderer() glDeleteVertexArrays(1, &_quadVAO); GL::bindVAO(0); } +#if CC_ENABLE_CACHE_TEXTURE_DATA + NotificationCenter::getInstance()->removeObserver(this, EVNET_COME_TO_FOREGROUND); +#endif } void Renderer::initGLView() { -#if 0//CC_ENABLE_CACHE_TEXTURE_DATA +#if CC_ENABLE_CACHE_TEXTURE_DATA // listen the event when app go to background NotificationCenter::getInstance()->addObserver(this, callfuncO_selector(Renderer::onBackToForeground), diff --git a/cocos/base/CCData.cpp b/cocos/base/CCData.cpp index 689d104886..77674c853d 100644 --- a/cocos/base/CCData.cpp +++ b/cocos/base/CCData.cpp @@ -39,13 +39,17 @@ _size(0) CCLOGINFO("In the empty constructor of Data."); } -Data::Data(Data&& other) +Data::Data(Data&& other) : +_bytes(nullptr), +_size(0) { CCLOGINFO("In the move constructor of Data."); move(other); } -Data::Data(const Data& other) +Data::Data(const Data& other) : +_bytes(nullptr), +_size(0) { CCLOGINFO("In the copy constructor of Data."); copy(other._bytes, other._size); diff --git a/cocos/base/CCData.h b/cocos/base/CCData.h index 40c1d53c06..7ba7431c94 100644 --- a/cocos/base/CCData.h +++ b/cocos/base/CCData.h @@ -28,6 +28,7 @@ #include "CCPlatformMacros.h" #include // for ssize_t on android #include // for ssize_t on linux +#include "CCStdC.h" // for ssize_t on window NS_CC_BEGIN diff --git a/cocos/base/CCMap.h b/cocos/base/CCMap.h index e9e2eb1e37..44c7846076 100644 --- a/cocos/base/CCMap.h +++ b/cocos/base/CCMap.h @@ -107,10 +107,22 @@ public: _data.reserve(capacity); } - /** Returns capacity of the map */ - ssize_t capacity() const + /** Returns the number of buckets in the Map container. */ + ssize_t bucketCount() const { - return _data.capacity(); + return _data.bucket_count(); + } + + /** Returns the number of elements in bucket n. */ + ssize_t bucketSize(ssize_t n) const + { + return _data.bucket_size(n); + } + + /** Returns the bucket number where the element with key k is located. */ + ssize_t bucket(const K& k) const + { + return _data.bucket(k); } /** The number of elements in the map. */ diff --git a/cocos/base/CCNS.cpp b/cocos/base/CCNS.cpp index aa19a7a0af..d9732d03ea 100644 --- a/cocos/base/CCNS.cpp +++ b/cocos/base/CCNS.cpp @@ -34,18 +34,19 @@ NS_CC_BEGIN typedef std::vector strArray; // string toolkit -static inline void split(std::string src, const char* token, strArray& vect) +static inline void split(const std::string& src, const std::string& token, strArray& vect) { - size_t nend=0; - size_t nbegin=0; - while(nend != -1) + size_t nend = 0; + size_t nbegin = 0; + size_t tokenSize = token.size(); + while(nend != std::string::npos) { nend = src.find(token, nbegin); - if(nend == -1) + if(nend == std::string::npos) vect.push_back(src.substr(nbegin, src.length()-nbegin)); else vect.push_back(src.substr(nbegin, nend-nbegin)); - nbegin = nend + strlen(token); + nbegin = nend + tokenSize; } } @@ -69,7 +70,7 @@ static bool splitWithForm(const std::string& str, strArray& strs) size_t nPosRight = content.find('}'); // don't have '{' and '}' - CC_BREAK_IF(nPosLeft == (int)std::string::npos || nPosRight == (int)std::string::npos); + CC_BREAK_IF(nPosLeft == std::string::npos || nPosRight == std::string::npos); // '}' is before '{' CC_BREAK_IF(nPosLeft > nPosRight); @@ -80,7 +81,7 @@ static bool splitWithForm(const std::string& str, strArray& strs) size_t nPos1 = pointStr.find('{'); size_t nPos2 = pointStr.find('}'); // contain '{' or '}' - CC_BREAK_IF(nPos1 != (int)std::string::npos || nPos2 != (int)std::string::npos); + CC_BREAK_IF(nPos1 != std::string::npos || nPos2 != std::string::npos); split(pointStr, ",", strs); if (strs.size() != 2 || strs[0].length() == 0 || strs[1].length() == 0) @@ -111,19 +112,19 @@ Rect RectFromString(const std::string& str) size_t nPosRight = content.find('}'); for (int i = 1; i < 3; ++i) { - if (nPosRight == (int)std::string::npos) + if (nPosRight == std::string::npos) { break; } nPosRight = content.find('}', nPosRight + 1); } - CC_BREAK_IF(nPosLeft == (int)std::string::npos || nPosRight == (int)std::string::npos); + CC_BREAK_IF(nPosLeft == std::string::npos || nPosRight == std::string::npos); content = content.substr(nPosLeft + 1, nPosRight - nPosLeft - 1); size_t nPointEnd = content.find('}'); - CC_BREAK_IF(nPointEnd == (int)std::string::npos); + CC_BREAK_IF(nPointEnd == std::string::npos); nPointEnd = content.find(',', nPointEnd); - CC_BREAK_IF(nPointEnd == (int)std::string::npos); + CC_BREAK_IF(nPointEnd == std::string::npos); // get the point string and size string std::string pointStr = content.substr(0, nPointEnd); diff --git a/cocos/editor-support/cocostudio/CCArmature.cpp b/cocos/editor-support/cocostudio/CCArmature.cpp index f063fe60f4..8c6f5d9e2f 100644 --- a/cocos/editor-support/cocostudio/CCArmature.cpp +++ b/cocos/editor-support/cocostudio/CCArmature.cpp @@ -181,9 +181,6 @@ bool Armature::init(const std::string& name) setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); - unscheduleUpdate(); - scheduleUpdate(); - setCascadeOpacityEnabled(true); setCascadeColorEnabled(true); @@ -432,6 +429,18 @@ void Armature::draw() } } +void Armature::onEnter() +{ + Node::onEnter(); + scheduleUpdate(); +} + +void Armature::onExit() +{ + Node::onExit(); + unscheduleUpdate(); +} + void Armature::visit() { diff --git a/cocos/editor-support/cocostudio/CCArmature.h b/cocos/editor-support/cocostudio/CCArmature.h index dead282395..f601c057f7 100644 --- a/cocos/editor-support/cocostudio/CCArmature.h +++ b/cocos/editor-support/cocostudio/CCArmature.h @@ -161,6 +161,9 @@ public: virtual void update(float dt) override; virtual void draw() override; + virtual void onEnter() override; + virtual void onExit() override; + virtual const kmMat4& getNodeToParentTransform() const override; /** * @js NA diff --git a/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp b/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp index 1b6c17bc60..fb7ff59299 100644 --- a/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp +++ b/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp @@ -246,8 +246,12 @@ void ArmatureAnimation::play(const std::string& animationName, int durationTo, _armature->update(0); } - void ArmatureAnimation::playByIndex(int animationIndex, int durationTo, int loop) +{ + playWithIndex(animationIndex, durationTo, loop); +} + +void ArmatureAnimation::playWithIndex(int animationIndex, int durationTo, int loop) { std::vector &movName = _animationData->movementNames; CC_ASSERT((animationIndex > -1) && ((unsigned int)animationIndex < movName.size())); @@ -257,7 +261,7 @@ void ArmatureAnimation::playByIndex(int animationIndex, int durationTo, int loop } -void ArmatureAnimation::play(const std::vector& movementNames, int durationTo, bool loop) +void ArmatureAnimation::playWithNames(const std::vector& movementNames, int durationTo, bool loop) { _movementList.clear(); _movementListLoop = loop; @@ -270,7 +274,7 @@ void ArmatureAnimation::play(const std::vector& movementNames, int updateMovementList(); } -void ArmatureAnimation::playByIndex(const std::vector& movementIndexes, int durationTo, bool loop) +void ArmatureAnimation::playWithIndexes(const std::vector& movementIndexes, int durationTo, bool loop) { _movementList.clear(); _movementListLoop = loop; diff --git a/cocos/editor-support/cocostudio/CCArmatureAnimation.h b/cocos/editor-support/cocostudio/CCArmatureAnimation.h index b5fe2a01d9..f135501cb1 100644 --- a/cocos/editor-support/cocostudio/CCArmatureAnimation.h +++ b/cocos/editor-support/cocostudio/CCArmatureAnimation.h @@ -127,13 +127,14 @@ public: /** * Play animation by index, the other param is the same to play. + * @deprecated, please use playWithIndex * @param animationIndex the animation index you want to play */ - virtual void playByIndex(int animationIndex, int durationTo = -1, int loop = -1); + CC_DEPRECATED_ATTRIBUTE virtual void playByIndex(int animationIndex, int durationTo = -1, int loop = -1); + virtual void playWithIndex(int animationIndex, int durationTo = -1, int loop = -1); - - virtual void play(const std::vector& movementNames, int durationTo = -1, bool loop = true); - virtual void playByIndex(const std::vector& movementIndexes, int durationTo = -1, bool loop = true); + virtual void playWithNames(const std::vector& movementNames, int durationTo = -1, bool loop = true); + virtual void playWithIndexes(const std::vector& movementIndexes, int durationTo = -1, bool loop = true); /** * Go to specified frame and play current movement. diff --git a/cocos/editor-support/cocostudio/CCArmatureDataManager.h b/cocos/editor-support/cocostudio/CCArmatureDataManager.h index 137fbe5d3e..1b9abe4308 100644 --- a/cocos/editor-support/cocostudio/CCArmatureDataManager.h +++ b/cocos/editor-support/cocostudio/CCArmatureDataManager.h @@ -199,7 +199,7 @@ private: bool _autoLoadSpriteFile; - std::map _relativeDatas; + std::unordered_map _relativeDatas; }; diff --git a/cocos/gui/UIListView.cpp b/cocos/gui/UIListView.cpp index 5d608ac6dc..91c15934f4 100644 --- a/cocos/gui/UIListView.cpp +++ b/cocos/gui/UIListView.cpp @@ -298,6 +298,12 @@ void ListView::removeLastItem() { removeItem(_items.size() -1); } + +void ListView::removeAllItems() +{ + _items.clear(); + removeAllChildren(); +} Widget* ListView::getItem(unsigned int index) { @@ -434,7 +440,7 @@ void ListView::onSizeChanged() std::string ListView::getDescription() const { - return "ListViewEx"; + return "ListView"; } Widget* ListView::createCloneInstance() @@ -444,7 +450,7 @@ Widget* ListView::createCloneInstance() void ListView::copyClonedWidgetChildren(Widget* model) { - auto& arrayItems = getItems(); + auto& arrayItems = static_cast(model)->getItems(); for (auto& item : arrayItems) { pushBackCustomItem(item->clone()); diff --git a/cocos/gui/UIListView.h b/cocos/gui/UIListView.h index 0eac270d6e..2d37d986ea 100644 --- a/cocos/gui/UIListView.h +++ b/cocos/gui/UIListView.h @@ -112,6 +112,8 @@ public: */ void removeItem(int index); + void removeAllItems(); + /** * Returns a item whose index is same as the parameter. * @@ -173,9 +175,13 @@ protected: virtual void addChild(Node* child, int zOrder, int tag) override{ScrollView::addChild(child, zOrder, tag);}; virtual void removeChild(Node* widget, bool cleanup = true) override{ScrollView::removeChild(widget, cleanup);}; - virtual void removeAllChildren() override{ScrollView::removeAllChildren();}; + virtual void removeAllChildren() override{removeAllChildrenWithCleanup(true);}; + virtual void removeAllChildrenWithCleanup(bool cleanup) override {ScrollView::removeAllChildrenWithCleanup(cleanup);}; virtual Vector& getChildren() override{return ScrollView::getChildren();}; virtual const Vector& getChildren() const override{return ScrollView::getChildren();}; + virtual ssize_t getChildrenCount() const override {return ScrollView::getChildrenCount();}; + virtual Node * getChildByTag(int tag) override {return ScrollView::getChildByTag(tag);}; + virtual Widget* getChildByName(const char* name) override {return ScrollView::getChildByName(name);}; virtual bool init() override; void updateInnerContainerSize(); void remedyLayoutParameter(Widget* item); diff --git a/cocos/gui/UILoadingBar.cpp b/cocos/gui/UILoadingBar.cpp index 4822f0cca8..aec388a8c0 100644 --- a/cocos/gui/UILoadingBar.cpp +++ b/cocos/gui/UILoadingBar.cpp @@ -217,32 +217,18 @@ void LoadingBar::setPercent(int percent) return; } _percent = percent; - float res = _percent/100.0; + float res = _percent / 100.0f; - int x = 0, y = 0; - switch (_renderBarTexType) - { - case UI_TEX_TYPE_PLIST: - { - Sprite* barNode = dynamic_cast(_barRenderer); - if (barNode) - { - Point to = barNode->getTextureRect().origin; - x = to.x; - y = to.y; - } - break; - } - default: - break; - } if (_scale9Enabled) { setScale9Scale(); } else { - static_cast(_barRenderer)->setTextureRect(Rect(x, y, _barRendererTextureSize.width * res, _barRendererTextureSize.height)); + Sprite* spriteRenderer = static_cast(_barRenderer); + Rect rect = spriteRenderer->getTextureRect(); + rect.size.width = _barRendererTextureSize.width * res; + spriteRenderer->setTextureRect(rect, spriteRenderer->isTextureRectRotated(), rect.size); } } @@ -324,7 +310,7 @@ void LoadingBar::barRendererScaleChangedWithSize() void LoadingBar::setScale9Scale() { - float width = (float)(_percent) / 100 * _totalLength; + float width = (float)(_percent) / 100.0f * _totalLength; static_cast(_barRenderer)->setPreferredSize(Size(width, _size.height)); } diff --git a/cocos/gui/UIPageView.cpp b/cocos/gui/UIPageView.cpp index dcc0dbf593..d702ef88e4 100644 --- a/cocos/gui/UIPageView.cpp +++ b/cocos/gui/UIPageView.cpp @@ -295,9 +295,14 @@ void PageView::updateChildrenPosition() } void PageView::removeAllChildren() +{ + removeAllChildrenWithCleanup(true); +} + +void PageView::removeAllChildrenWithCleanup(bool cleanup) { _pages.clear(); - Layout::removeAllChildren(); + Layout::removeAllChildrenWithCleanup(cleanup); } void PageView::scrollToPage(int idx) @@ -602,7 +607,7 @@ Widget* PageView::createCloneInstance() void PageView::copyClonedWidgetChildren(Widget* model) { - auto& modelPages = dynamic_cast(model)->getPages(); + auto& modelPages = static_cast(model)->getPages(); for (auto& page : modelPages) { addPage(dynamic_cast(page->clone())); diff --git a/cocos/gui/UIPageView.h b/cocos/gui/UIPageView.h index bd564b6c04..466434c8cd 100644 --- a/cocos/gui/UIPageView.h +++ b/cocos/gui/UIPageView.h @@ -158,15 +158,19 @@ public: * Returns the "class name" of widget. */ virtual std::string getDescription() const override; - + protected: virtual void addChild(Node * child) override; virtual void addChild(Node * child, int zOrder) override; virtual void addChild(Node* child, int zOrder, int tag) override; virtual void removeChild(Node* widget, bool cleanup = true) override; virtual void removeAllChildren() override; + virtual void removeAllChildrenWithCleanup(bool cleanup) override; virtual Vector& getChildren() override{return Widget::getChildren();}; virtual const Vector& getChildren() const override{return Widget::getChildren();}; + virtual ssize_t getChildrenCount() const override {return Widget::getChildrenCount();}; + virtual Node * getChildByTag(int tag) override {return Widget::getChildByTag(tag);}; + virtual Widget* getChildByName(const char* name) override {return Widget::getChildByName(name);}; virtual bool init() override; Layout* createPage(); float getPositionXByIndex(int idx); diff --git a/cocos/gui/UIScrollView.cpp b/cocos/gui/UIScrollView.cpp index de3c07931c..436cb52ea7 100644 --- a/cocos/gui/UIScrollView.cpp +++ b/cocos/gui/UIScrollView.cpp @@ -231,7 +231,12 @@ void ScrollView::addChild(Node *child, int zOrder, int tag) void ScrollView::removeAllChildren() { - _innerContainer->removeAllChildren(); + removeAllChildrenWithCleanup(true); +} + +void ScrollView::removeAllChildrenWithCleanup(bool cleanup) +{ + _innerContainer->removeAllChildrenWithCleanup(cleanup); } void ScrollView::removeChild(Node* child, bool cleanup) @@ -249,6 +254,21 @@ const Vector& ScrollView::getChildren() const return _innerContainer->getChildren(); } +ssize_t ScrollView::getChildrenCount() const +{ + return _innerContainer->getChildrenCount(); +} + +Node* ScrollView::getChildByTag(int tag) +{ + return _innerContainer->getChildByTag(tag); +} + +Widget* ScrollView::getChildByName(const char *name) +{ + return _innerContainer->getChildByName(name); +} + void ScrollView::moveChildren(float offsetX, float offsetY) { _moveChildPoint = _innerContainer->getPosition() + Point(offsetX, offsetY); diff --git a/cocos/gui/UIScrollView.h b/cocos/gui/UIScrollView.h index 3e2e6907c7..6075a02adf 100644 --- a/cocos/gui/UIScrollView.h +++ b/cocos/gui/UIScrollView.h @@ -259,6 +259,8 @@ public: //override "removeAllChildrenAndCleanUp" method of widget. virtual void removeAllChildren() override; + virtual void removeAllChildrenWithCleanup(bool cleanup) override; + //override "removeChild" method of widget. virtual void removeChild(Node* child, bool cleaup = true) override; @@ -266,6 +268,12 @@ public: virtual Vector& getChildren() override; virtual const Vector& getChildren() const override; + virtual ssize_t getChildrenCount() const override; + + virtual Node * getChildByTag(int tag) override; + + virtual Widget* getChildByName(const char* name) override; + virtual bool onTouchBegan(Touch *touch, Event *unusedEvent) override; virtual void onTouchMoved(Touch *touch, Event *unusedEvent) override; virtual void onTouchEnded(Touch *touch, Event *unusedEvent) override; diff --git a/cocos/gui/UISlider.cpp b/cocos/gui/UISlider.cpp index a25e205d4f..30fc583524 100644 --- a/cocos/gui/UISlider.cpp +++ b/cocos/gui/UISlider.cpp @@ -339,7 +339,8 @@ void Slider::setPercent(int percent) percent = 0; } _percent = percent; - float dis = _barLength*(percent/100.0f); + float res = percent / 100.0f; + float dis = _barLength * res; _slidBallRenderer->setPosition(Point(-_barLength/2.0f + dis, 0.0f)); if (_scale9Enabled) { @@ -347,24 +348,10 @@ void Slider::setPercent(int percent) } else { - int x = 0, y = 0; - switch (_progressBarTexType) - { - case UI_TEX_TYPE_PLIST: - { - Sprite* barNode = dynamic_cast(_progressBarRenderer); - if (barNode) - { - Point to = barNode->getTextureRect().origin; - x = to.x; - y = to.y; - } - break; - } - default: - break; - } - static_cast(_progressBarRenderer)->setTextureRect(Rect(x, y, _progressBarTextureSize.width * (percent/100.0f), _progressBarTextureSize.height)); + Sprite* spriteRenderer = static_cast(_progressBarRenderer); + Rect rect = spriteRenderer->getTextureRect(); + rect.size.width = _progressBarTextureSize.width * res; + spriteRenderer->setTextureRect(rect, spriteRenderer->isTextureRectRotated(), rect.size); } } diff --git a/cocos/gui/UIWidget.cpp b/cocos/gui/UIWidget.cpp index 495821cd99..11a5c1dbf7 100644 --- a/cocos/gui/UIWidget.cpp +++ b/cocos/gui/UIWidget.cpp @@ -165,7 +165,7 @@ const Vector& Widget::getChildren() const return _widgetChildren; } -long Widget::getChildrenCount() const +ssize_t Widget::getChildrenCount() const { return _widgetChildren.size(); } diff --git a/cocos/gui/UIWidget.h b/cocos/gui/UIWidget.h index 308587879f..379fc04003 100644 --- a/cocos/gui/UIWidget.h +++ b/cocos/gui/UIWidget.h @@ -232,7 +232,7 @@ public: * * @return a Node object whose tag equals to the input parameter */ - Node * getChildByTag(int tag); + virtual Node * getChildByTag(int tag) override; virtual void sortAllChildren() override; /** @@ -259,14 +259,14 @@ public: * * @return The amount of children. */ - long getChildrenCount() const; + virtual ssize_t getChildrenCount() const override; /** * Removes this node itself from its parent node with a cleanup. * If the node orphan, then nothing happens. * @see `removeFromParentAndCleanup(bool)` */ - virtual void removeFromParent(); + virtual void removeFromParent() override; /** * Removes this node itself from its parent node. * If the node orphan, then nothing happens. @@ -274,7 +274,7 @@ public: * @js removeFromParent * @lua removeFromParent */ - virtual void removeFromParentAndCleanup(bool cleanup); + virtual void removeFromParentAndCleanup(bool cleanup) override; /** * Removes a child from the container. It will also cleanup all running actions depending on the cleanup parameter. @@ -282,7 +282,7 @@ public: * @param child The child node which will be removed. * @param cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise. */ - virtual void removeChild(Node* child, bool cleanup = true); + virtual void removeChild(Node* child, bool cleanup = true) override; /** * Removes a child from the container by tag value. It will also cleanup all running actions depending on the cleanup parameter @@ -290,13 +290,13 @@ public: * @param tag An interger number that identifies a child node * @param cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise. */ - virtual void removeChildByTag(int tag, bool cleanup = true); + virtual void removeChildByTag(int tag, bool cleanup = true) override; /** * Removes all children from the container with a cleanup. * * @see `removeAllChildrenWithCleanup(bool)` */ - virtual void removeAllChildren(); + virtual void removeAllChildren() override; /** * Removes all children from the container, and do a cleanup to all running actions depending on the cleanup parameter. * @@ -304,7 +304,7 @@ public: * @js removeAllChildren * @lua removeAllChildren */ - virtual void removeAllChildrenWithCleanup(bool cleanup); + virtual void removeAllChildrenWithCleanup(bool cleanup) override; /** * Gets a child from the container with its name @@ -313,7 +313,7 @@ public: * * @return a Widget object whose name equals to the input parameter */ - Widget* getChildByName(const char* name); + virtual Widget* getChildByName(const char* name); virtual void visit(); @@ -663,36 +663,27 @@ protected: bool _focus; ///< is the widget on focus BrightStyle _brightStyle; ///< bright style bool _updateEnabled; ///< is "update" method scheduled -// Node* _renderer; ///< base renderer Point _touchStartPos; ///< touch began point Point _touchMovePos; ///< touch moved point Point _touchEndPos; ///< touch ended point - Object* _touchEventListener; SEL_TouchEvent _touchEventSelector; - - - std::string _name; WidgetType _widgetType; int _actionTag; Size _size; Size _customSize; - Map _layoutParameterDictionary; bool _ignoreSize; - Vector _widgetChildren; bool _affectByClipping; - SizeType _sizeType; Point _sizePercent; PositionType _positionType; Point _positionPercent; - bool _reorderWidgetChildDirty; - bool _hitted; - EventListenerTouchOneByOne* _touchListener; + Map _layoutParameterDictionary; + Vector _widgetChildren; }; } diff --git a/cocos/gui/proj.win32/libGUI.vcxproj b/cocos/gui/proj.win32/libGUI.vcxproj index 2712ae3900..caf83df195 100644 --- a/cocos/gui/proj.win32/libGUI.vcxproj +++ b/cocos/gui/proj.win32/libGUI.vcxproj @@ -16,18 +16,15 @@ - - - @@ -40,18 +37,15 @@ - - - diff --git a/cocos/gui/proj.win32/libGUI.vcxproj.filters b/cocos/gui/proj.win32/libGUI.vcxproj.filters index 092f28f7e0..148977b79d 100644 --- a/cocos/gui/proj.win32/libGUI.vcxproj.filters +++ b/cocos/gui/proj.win32/libGUI.vcxproj.filters @@ -63,18 +63,9 @@ System - - System - - - System - Layouts - - BaseClasses - BaseClasses @@ -128,18 +119,9 @@ System - - System - - - System - Layouts - - BaseClasses - BaseClasses diff --git a/cocos/physics/CCPhysicsBody.cpp b/cocos/physics/CCPhysicsBody.cpp index 8b9451f873..c626389290 100644 --- a/cocos/physics/CCPhysicsBody.cpp +++ b/cocos/physics/CCPhysicsBody.cpp @@ -22,7 +22,7 @@ THE SOFTWARE. ****************************************************************************/ #include "CCPhysicsBody.h" -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS #include #include diff --git a/cocos/physics/CCPhysicsBody.h b/cocos/physics/CCPhysicsBody.h index 8d31d82e61..a843732ad9 100644 --- a/cocos/physics/CCPhysicsBody.h +++ b/cocos/physics/CCPhysicsBody.h @@ -26,7 +26,7 @@ #define __CCPHYSICS_BODY_H__ #include "ccConfig.h" -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS #include "CCObject.h" #include "CCGeometry.h" diff --git a/cocos/physics/CCPhysicsContact.cpp b/cocos/physics/CCPhysicsContact.cpp index a32266eed2..c04b295f46 100644 --- a/cocos/physics/CCPhysicsContact.cpp +++ b/cocos/physics/CCPhysicsContact.cpp @@ -22,7 +22,7 @@ THE SOFTWARE. ****************************************************************************/ #include "CCPhysicsContact.h" -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS #include "chipmunk.h" #include "CCPhysicsBody.h" diff --git a/cocos/physics/CCPhysicsContact.h b/cocos/physics/CCPhysicsContact.h index f734574565..552ab81e63 100644 --- a/cocos/physics/CCPhysicsContact.h +++ b/cocos/physics/CCPhysicsContact.h @@ -26,7 +26,7 @@ #define __CCPHYSICS_CONTACT_H__ #include "ccConfig.h" -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS #include "CCObject.h" #include "CCGeometry.h" diff --git a/cocos/physics/CCPhysicsJoint.cpp b/cocos/physics/CCPhysicsJoint.cpp index 7300b01dd7..2d5cddd7ab 100644 --- a/cocos/physics/CCPhysicsJoint.cpp +++ b/cocos/physics/CCPhysicsJoint.cpp @@ -23,7 +23,7 @@ ****************************************************************************/ #include "CCPhysicsJoint.h" -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS #include "chipmunk.h" #include "CCPhysicsBody.h" diff --git a/cocos/physics/CCPhysicsJoint.h b/cocos/physics/CCPhysicsJoint.h index 58cc5f83e3..b5e80e1c42 100644 --- a/cocos/physics/CCPhysicsJoint.h +++ b/cocos/physics/CCPhysicsJoint.h @@ -26,7 +26,7 @@ #define __CCPHYSICS_JOINT_H__ #include "ccConfig.h" -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS #include "CCObject.h" #include "CCGeometry.h" diff --git a/cocos/physics/CCPhysicsShape.cpp b/cocos/physics/CCPhysicsShape.cpp index f7e9c524b2..543bbf0333 100644 --- a/cocos/physics/CCPhysicsShape.cpp +++ b/cocos/physics/CCPhysicsShape.cpp @@ -23,7 +23,7 @@ ****************************************************************************/ #include "CCPhysicsShape.h" -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS #include diff --git a/cocos/physics/CCPhysicsShape.h b/cocos/physics/CCPhysicsShape.h index 52e765b414..1146b2d291 100644 --- a/cocos/physics/CCPhysicsShape.h +++ b/cocos/physics/CCPhysicsShape.h @@ -26,7 +26,7 @@ #define __CCPHYSICS_SHAPE_H__ #include "ccConfig.h" -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS #include "CCObject.h" #include "CCGeometry.h" diff --git a/cocos/physics/CCPhysicsWorld.cpp b/cocos/physics/CCPhysicsWorld.cpp index 9a80ef2bce..ebb12e4ec2 100644 --- a/cocos/physics/CCPhysicsWorld.cpp +++ b/cocos/physics/CCPhysicsWorld.cpp @@ -23,7 +23,7 @@ ****************************************************************************/ #include "CCPhysicsWorld.h" -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS #include diff --git a/cocos/physics/CCPhysicsWorld.h b/cocos/physics/CCPhysicsWorld.h index 80af28d260..6991071679 100644 --- a/cocos/physics/CCPhysicsWorld.h +++ b/cocos/physics/CCPhysicsWorld.h @@ -26,7 +26,7 @@ #define __CCPHYSICS_WORLD_H__ #include "ccConfig.h" -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS #include "CCVector.h" #include "CCObject.h" diff --git a/cocos/physics/chipmunk/CCPhysicsBodyInfo_chipmunk.cpp b/cocos/physics/chipmunk/CCPhysicsBodyInfo_chipmunk.cpp index 701783402c..eb74a8ecc2 100644 --- a/cocos/physics/chipmunk/CCPhysicsBodyInfo_chipmunk.cpp +++ b/cocos/physics/chipmunk/CCPhysicsBodyInfo_chipmunk.cpp @@ -23,7 +23,7 @@ ****************************************************************************/ #include "CCPhysicsBodyInfo_chipmunk.h" -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS NS_CC_BEGIN PhysicsBodyInfo::PhysicsBodyInfo() diff --git a/cocos/physics/chipmunk/CCPhysicsBodyInfo_chipmunk.h b/cocos/physics/chipmunk/CCPhysicsBodyInfo_chipmunk.h index 7c695885b2..7f3d6aa177 100644 --- a/cocos/physics/chipmunk/CCPhysicsBodyInfo_chipmunk.h +++ b/cocos/physics/chipmunk/CCPhysicsBodyInfo_chipmunk.h @@ -26,7 +26,7 @@ #define __CCPHYSICS_BODY_INFO_CHIPMUNK_H__ #include "ccConfig.h" -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS #include "chipmunk.h" #include "CCPlatformMacros.h" diff --git a/cocos/physics/chipmunk/CCPhysicsContactInfo_chipmunk.cpp b/cocos/physics/chipmunk/CCPhysicsContactInfo_chipmunk.cpp index bd0d46515e..54041c0a85 100644 --- a/cocos/physics/chipmunk/CCPhysicsContactInfo_chipmunk.cpp +++ b/cocos/physics/chipmunk/CCPhysicsContactInfo_chipmunk.cpp @@ -23,7 +23,7 @@ ****************************************************************************/ #include "CCPhysicsContactInfo_chipmunk.h" -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS NS_CC_BEGIN PhysicsContactInfo::PhysicsContactInfo(PhysicsContact* contact) diff --git a/cocos/physics/chipmunk/CCPhysicsContactInfo_chipmunk.h b/cocos/physics/chipmunk/CCPhysicsContactInfo_chipmunk.h index 78e377e434..f6c63fceda 100644 --- a/cocos/physics/chipmunk/CCPhysicsContactInfo_chipmunk.h +++ b/cocos/physics/chipmunk/CCPhysicsContactInfo_chipmunk.h @@ -26,7 +26,7 @@ #define __CCPHYSICS_CONTACT_INFO_CHIPMUNK_H__ #include "ccConfig.h" -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS #include "chipmunk.h" #include "CCPlatformMacros.h" diff --git a/cocos/physics/chipmunk/CCPhysicsHelper_chipmunk.h b/cocos/physics/chipmunk/CCPhysicsHelper_chipmunk.h index eb420ce3b1..c10990e669 100644 --- a/cocos/physics/chipmunk/CCPhysicsHelper_chipmunk.h +++ b/cocos/physics/chipmunk/CCPhysicsHelper_chipmunk.h @@ -26,7 +26,7 @@ #define __CCPHYSICS_HELPER_CHIPMUNK_H__ #include "ccConfig.h" -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS #include "chipmunk.h" #include "CCPlatformMacros.h" diff --git a/cocos/physics/chipmunk/CCPhysicsJointInfo_chipmunk.cpp b/cocos/physics/chipmunk/CCPhysicsJointInfo_chipmunk.cpp index 0df8c2a7c6..9443a9f36c 100644 --- a/cocos/physics/chipmunk/CCPhysicsJointInfo_chipmunk.cpp +++ b/cocos/physics/chipmunk/CCPhysicsJointInfo_chipmunk.cpp @@ -23,7 +23,7 @@ ****************************************************************************/ #include "CCPhysicsJointInfo_chipmunk.h" -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS #include #include diff --git a/cocos/physics/chipmunk/CCPhysicsJointInfo_chipmunk.h b/cocos/physics/chipmunk/CCPhysicsJointInfo_chipmunk.h index e3d57eff32..30817b66f0 100644 --- a/cocos/physics/chipmunk/CCPhysicsJointInfo_chipmunk.h +++ b/cocos/physics/chipmunk/CCPhysicsJointInfo_chipmunk.h @@ -26,7 +26,7 @@ #define __CCPHYSICS_JOINT_INFO_CHIPMUNK_H__ #include "ccConfig.h" -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS #include "chipmunk.h" #include "CCPlatformMacros.h" diff --git a/cocos/physics/chipmunk/CCPhysicsShapeInfo_chipmunk.cpp b/cocos/physics/chipmunk/CCPhysicsShapeInfo_chipmunk.cpp index 3df70185ee..c1b8693259 100644 --- a/cocos/physics/chipmunk/CCPhysicsShapeInfo_chipmunk.cpp +++ b/cocos/physics/chipmunk/CCPhysicsShapeInfo_chipmunk.cpp @@ -23,7 +23,7 @@ ****************************************************************************/ #include "CCPhysicsShapeInfo_chipmunk.h" -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS #include #include diff --git a/cocos/physics/chipmunk/CCPhysicsShapeInfo_chipmunk.h b/cocos/physics/chipmunk/CCPhysicsShapeInfo_chipmunk.h index 5ac25a2eb8..cbdaca53b1 100644 --- a/cocos/physics/chipmunk/CCPhysicsShapeInfo_chipmunk.h +++ b/cocos/physics/chipmunk/CCPhysicsShapeInfo_chipmunk.h @@ -26,7 +26,7 @@ #define __CCPHYSICS_SHAPE_INFO_CHIPMUNK_H__ #include "ccConfig.h" -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS #include #include diff --git a/cocos/physics/chipmunk/CCPhysicsWorldInfo_chipmunk.cpp b/cocos/physics/chipmunk/CCPhysicsWorldInfo_chipmunk.cpp index 8b7f078215..23890b2198 100644 --- a/cocos/physics/chipmunk/CCPhysicsWorldInfo_chipmunk.cpp +++ b/cocos/physics/chipmunk/CCPhysicsWorldInfo_chipmunk.cpp @@ -23,7 +23,7 @@ ****************************************************************************/ #include "CCPhysicsWorldInfo_chipmunk.h" -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS #include "CCPhysicsHelper_chipmunk.h" #include "CCPhysicsBodyInfo_chipmunk.h" #include "CCPhysicsShapeInfo_chipmunk.h" diff --git a/cocos/physics/chipmunk/CCPhysicsWorldInfo_chipmunk.h b/cocos/physics/chipmunk/CCPhysicsWorldInfo_chipmunk.h index 5554573101..b6de1dea20 100644 --- a/cocos/physics/chipmunk/CCPhysicsWorldInfo_chipmunk.h +++ b/cocos/physics/chipmunk/CCPhysicsWorldInfo_chipmunk.h @@ -26,7 +26,7 @@ #define __CCPHYSICS_WORLD_INFO_CHIPMUNK_H__ #include "ccConfig.h" -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS #include #include "chipmunk.h" diff --git a/cocos/scripting/auto-generated b/cocos/scripting/auto-generated index 6f6b1240ec..331edfd4a3 160000 --- a/cocos/scripting/auto-generated +++ b/cocos/scripting/auto-generated @@ -1 +1 @@ -Subproject commit 6f6b1240ecac0cbf3e4a2a0bd7356b708c054daf +Subproject commit 331edfd4a379ae9ff746d1b4e2b8decbc6ece1a2 diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp index f1afd308cd..64b217fa61 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp @@ -305,7 +305,7 @@ void TestDirectLoading::onEnter() ArmatureDataManager::getInstance()->addArmatureFileInfo("armature/bear.ExportJson"); Armature *armature = Armature::create("bear"); - armature->getAnimation()->playByIndex(0); + armature->getAnimation()->playWithIndex(0); armature->setPosition(Point(VisibleRect::center().x, VisibleRect::center().y)); addChild(armature); } @@ -320,7 +320,7 @@ void TestCSWithSkeleton::onEnter() ArmatureTestLayer::onEnter(); Armature *armature = nullptr; armature = Armature::create("Cowboy"); - armature->getAnimation()->playByIndex(0); + armature->getAnimation()->playWithIndex(0); armature->setScale(0.2f); armature->setPosition(Point(VisibleRect::center().x, VisibleRect::center().y/*-100*/)); @@ -341,7 +341,7 @@ void TestDragonBones20::onEnter() Armature *armature = nullptr; armature = Armature::create("Dragon"); - armature->getAnimation()->playByIndex(1); + armature->getAnimation()->playWithIndex(1); armature->getAnimation()->setSpeedScale(0.4f); armature->setPosition(VisibleRect::center().x, VisibleRect::center().y * 0.3f); armature->setScale(0.6f); @@ -415,7 +415,7 @@ void TestPerformance::addArmature(int number) Armature *armature = nullptr; armature = new Armature(); armature->init("Knight_f/Knight"); - armature->getAnimation()->playByIndex(0); + armature->getAnimation()->playWithIndex(0); armature->setPosition(50 + armatureCount * 2, 150); armature->setScale(0.6f); addArmatureToParent(armature); @@ -470,21 +470,21 @@ void TestChangeZorder::onEnter() currentTag = -1; armature = Armature::create("Knight_f/Knight"); - armature->getAnimation()->playByIndex(0); + armature->getAnimation()->playWithIndex(0); armature->setPosition(Point(VisibleRect::center().x, VisibleRect::center().y - 100)); ++currentTag; armature->setScale(0.6f); addChild(armature, currentTag, currentTag); armature = Armature::create("Cowboy"); - armature->getAnimation()->playByIndex(0); + armature->getAnimation()->playWithIndex(0); armature->setScale(0.24f); armature->setPosition(Point(VisibleRect::center().x, VisibleRect::center().y - 100)); ++currentTag; addChild(armature, currentTag, currentTag); armature = Armature::create("Dragon"); - armature->getAnimation()->playByIndex(0); + armature->getAnimation()->playWithIndex(0); armature->setPosition(Point(VisibleRect::center().x , VisibleRect::center().y - 100)); ++currentTag; armature->setScale(0.6f); @@ -623,7 +623,7 @@ void TestParticleDisplay::onEnter() animationID = 0; armature = Armature::create("robot"); - armature->getAnimation()->playByIndex(0); + armature->getAnimation()->playWithIndex(0); armature->setPosition(VisibleRect::center()); armature->setScale(0.48f); armature->getAnimation()->setSpeedScale(0.5f); @@ -669,7 +669,7 @@ void TestParticleDisplay::onTouchesEnded(const std::vector& touches, Eve { ++animationID; animationID = animationID % armature->getAnimation()->getMovementCount(); - armature->getAnimation()->playByIndex(animationID); + armature->getAnimation()->playWithIndex(animationID); } void TestUseMutiplePicture::onEnter() @@ -683,7 +683,7 @@ void TestUseMutiplePicture::onEnter() displayIndex = 0; armature = Armature::create("Knight_f/Knight"); - armature->getAnimation()->playByIndex(0); + armature->getAnimation()->playWithIndex(0); armature->setPosition(Point(VisibleRect::center().x, VisibleRect::left().y)); armature->setScale(1.2f); addChild(armature); @@ -1080,7 +1080,7 @@ void TestBoundingBox::onEnter() ArmatureTestLayer::onEnter(); armature = Armature::create("Cowboy"); - armature->getAnimation()->playByIndex(0); + armature->getAnimation()->playWithIndex(0); armature->setPosition(VisibleRect::center()); armature->setScale(0.2f); addChild(armature); @@ -1119,7 +1119,7 @@ void TestAnchorPoint::onEnter() for (int i = 0; i < 5; i++) { Armature *armature = Armature::create("Cowboy"); - armature->getAnimation()->playByIndex(0); + armature->getAnimation()->playWithIndex(0); armature->setPosition(VisibleRect::center()); armature->setScale(0.2f); addChild(armature, 0, i); @@ -1146,7 +1146,7 @@ void TestArmatureNesting::onEnter() _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); armature = Armature::create("cyborg"); - armature->getAnimation()->playByIndex(1); + armature->getAnimation()->playWithIndex(1); armature->setPosition(VisibleRect::center()); armature->setScale(1.2f); armature->getAnimation()->setSpeedScale(0.4f); @@ -1172,8 +1172,8 @@ void TestArmatureNesting::onTouchesEnded(const std::vector& touches, Eve if(armature != nullptr) { - armature->getBone("armInside")->getChildArmature()->getAnimation()->playByIndex(weaponIndex); - armature->getBone("armOutside")->getChildArmature()->getAnimation()->playByIndex(weaponIndex); + armature->getBone("armInside")->getChildArmature()->getAnimation()->playWithIndex(weaponIndex); + armature->getBone("armOutside")->getChildArmature()->getAnimation()->playWithIndex(weaponIndex); } } @@ -1204,7 +1204,7 @@ void Hero::changeMount(Armature *armature) { retain(); - playByIndex(0); + playWithIndex(0); //Remove hero from display list m_pMount->getBone("hero")->removeDisplay(0); m_pMount->stopAllActions(); @@ -1236,7 +1236,7 @@ void Hero::changeMount(Armature *armature) setPosition(Point(0,0)); //Change animation - playByIndex(1); + playWithIndex(1); setScale(1); @@ -1245,12 +1245,12 @@ void Hero::changeMount(Armature *armature) } -void Hero::playByIndex(int index) +void Hero::playWithIndex(int index) { - _animation->playByIndex(index); + _animation->playWithIndex(index); if (m_pMount) { - m_pMount->getAnimation()->playByIndex(index); + m_pMount->getAnimation()->playWithIndex(index); } } @@ -1277,7 +1277,7 @@ void TestArmatureNesting2::onEnter() //Create a hero hero = Hero::create("hero"); hero->setLayer(this); - hero->playByIndex(0); + hero->playWithIndex(0); hero->setPosition(Point(VisibleRect::left().x + 20, VisibleRect::left().y)); addChild(hero); @@ -1350,7 +1350,7 @@ void TestArmatureNesting2::ChangeMountCallback(Object* pSender) Armature * TestArmatureNesting2::createMount(const char *name, Point position) { Armature *armature = Armature::create(name); - armature->getAnimation()->playByIndex(0); + armature->getAnimation()->playWithIndex(0); armature->setPosition(position); addChild(armature); @@ -1373,8 +1373,8 @@ void TestPlaySeveralMovement::onEnter() Armature *armature = NULL; armature = Armature::create("Cowboy"); - armature->getAnimation()->play(names); -// armature->getAnimation()->playByIndex(indexes); + armature->getAnimation()->playWithNames(names); +// armature->getAnimation()->playWithIndexes(indexes); armature->setScale(0.2f); armature->setPosition(Point(VisibleRect::center().x, VisibleRect::center().y/*-100*/)); @@ -1402,7 +1402,7 @@ void TestEasing::onEnter() animationID = 0; armature = Armature::create("testEasing"); - armature->getAnimation()->playByIndex(0); + armature->getAnimation()->playWithIndex(0); armature->setScale(0.8f); armature->setPosition(Point(VisibleRect::center().x, VisibleRect::center().y)); @@ -1423,7 +1423,7 @@ void TestEasing::onTouchesEnded(const std::vector& touches, Event* event { animationID++; animationID = animationID % armature->getAnimation()->getMovementCount(); - armature->getAnimation()->playByIndex(animationID); + armature->getAnimation()->playWithIndex(animationID); updateSubTitle(); } @@ -1444,7 +1444,7 @@ void TestChangeAnimationInternal::onEnter() Armature *armature = NULL; armature = Armature::create("Cowboy"); - armature->getAnimation()->playByIndex(0); + armature->getAnimation()->playWithIndex(0); armature->setScale(0.2f); armature->setPosition(Point(VisibleRect::center().x, VisibleRect::center().y)); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h index 1fce072d63..0cff46155f 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h @@ -325,7 +325,7 @@ public: Hero(); virtual void changeMount(cocostudio::Armature *armature); - virtual void playByIndex(int index); + virtual void playWithIndex(int index); CC_SYNTHESIZE(cocostudio::Armature*, m_pMount, Mount); CC_SYNTHESIZE(cocos2d::Layer*, m_pLayer, Layer); diff --git a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp index 1aef4a2a94..b9c97830bd 100644 --- a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp @@ -6,7 +6,7 @@ USING_NS_CC; namespace { static std::function createFunctions[] = { -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS CL(PhysicsDemoLogoSmash), CL(PhysicsDemoPyramidStack), CL(PhysicsDemoClickAdd), @@ -55,7 +55,7 @@ namespace } PhysicsTestScene::PhysicsTestScene() -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS : TestScene(false, true) #else : TestScene() @@ -73,13 +73,13 @@ void PhysicsTestScene::runThisTest() void PhysicsTestScene::toggleDebug() { -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS _debugDraw = !_debugDraw; getPhysicsWorld()->setDebugDrawMask(_debugDraw ? PhysicsWorld::DEBUGDRAW_ALL : PhysicsWorld::DEBUGDRAW_NONE); #endif } -#ifndef CC_USE_PHYSICS +#if CC_USE_PHYSICS == 0 void PhysicsDemoDisabled::onEnter() { auto label = LabelTTF::create("Should define CC_USE_PHYSICS\n to run this test case", diff --git a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.h b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.h index dbb8938b2b..2bbf6b1aee 100644 --- a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.h +++ b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.h @@ -22,7 +22,7 @@ private: bool _debugDraw; }; -#ifndef CC_USE_PHYSICS +#if CC_USE_PHYSICS == 0 class PhysicsDemoDisabled : public BaseTest { public: diff --git a/samples/Cpp/TestCpp/Classes/testBasic.cpp b/samples/Cpp/TestCpp/Classes/testBasic.cpp index cffd5acbef..67e68da3af 100644 --- a/samples/Cpp/TestCpp/Classes/testBasic.cpp +++ b/samples/Cpp/TestCpp/Classes/testBasic.cpp @@ -7,7 +7,7 @@ TestScene::TestScene(bool bPortrait, bool physics/* = false*/) { if (physics) { -#ifdef CC_USE_PHYSICS +#if CC_USE_PHYSICS TestScene::initWithPhysics(); #else Scene::init(); diff --git a/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj b/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj index a1b18efb49..b69b1f411b 100644 --- a/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj +++ b/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj @@ -153,23 +153,20 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\websockets\prebuilt\win32\*.*" "$ - + - - - - + @@ -298,23 +295,20 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\websockets\prebuilt\win32\*.*" "$ - + - - - - + diff --git a/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj.filters b/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj.filters index c02d7a1021..a5f386187d 100644 --- a/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj.filters +++ b/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj.filters @@ -250,27 +250,15 @@ {493fcd85-c749-482d-9404-905e99aa0103} - - {5c1960de-24ba-4b72-be18-cc160dd2a50d} - - - {175b363b-a41a-4b1d-bde1-970e77e64cff} - {2e08949f-bf73-4fdc-85e8-34b8c69aa978} {c57c0453-a096-44d7-830b-1cf24c712cfd} - - {c4dbbfb3-0e91-492f-bbbf-f03fb26f3f54} - {01097388-e538-4081-8e16-d1ff3a86292a} - - {160da6f0-a0f1-4a53-8e5e-cf0a63ee82a3} - {fadff96e-c19a-41f5-a755-547cf1f8a5fb} @@ -289,9 +277,6 @@ {dedcabba-959c-40e3-9959-7ccf4e31c792} - - {cfc87c30-a7b4-4b6f-bc5d-da45360466b6} - {5caf2179-ae22-4040-8bac-17e9f22efbf7} @@ -310,6 +295,12 @@ {688e201c-77fe-4665-931e-e508a58141f5} + + {160da6f0-a0f1-4a53-8e5e-cf0a63ee82a3} + + + {c4dbbfb3-0e91-492f-bbbf-f03fb26f3f54} + @@ -649,9 +640,6 @@ Classes\ExtensionsTest\CocoStudioGUITest\UICheckBoxTest - - Classes\ExtensionsTest\CocoStudioGUITest\UIDragPanelTest - Classes\ExtensionsTest\CocoStudioGUITest\UIImageViewTest @@ -670,27 +658,15 @@ Classes\ExtensionsTest\CocoStudioGUITest\UILoadingBarTest - - Classes\ExtensionsTest\CocoStudioGUITest\UINodeContainerTest - Classes\ExtensionsTest\CocoStudioGUITest\UIPageViewTest - - Classes\ExtensionsTest\CocoStudioGUITest\UIPanelTest - Classes\ExtensionsTest\CocoStudioGUITest\UIScrollViewTest Classes\ExtensionsTest\CocoStudioGUITest\UISliderTest - - Classes\ExtensionsTest\CocoStudioGUITest\UITextAreaTest - - - Classes\ExtensionsTest\CocoStudioGUITest\UITextButtonTest - Classes\ExtensionsTest\CocoStudioGUITest\UITextFieldTest @@ -718,6 +694,12 @@ Classes\NewRendererTest + + Classes\ExtensionsTest\CocoStudioGUITest\UIWidgetAddNodeTest + + + Classes\ExtensionsTest\CocoStudioGUITest\UILayoutTest + @@ -1234,9 +1216,6 @@ Classes\ExtensionsTest\CocoStudioGUITest\UICheckBoxTest - - Classes\ExtensionsTest\CocoStudioGUITest\UIDragPanelTest - Classes\ExtensionsTest\CocoStudioGUITest\UIImageViewTest @@ -1255,27 +1234,15 @@ Classes\ExtensionsTest\CocoStudioGUITest\UILoadingBarTest - - Classes\ExtensionsTest\CocoStudioGUITest\UINodeContainerTest - Classes\ExtensionsTest\CocoStudioGUITest\UIPageViewTest - - Classes\ExtensionsTest\CocoStudioGUITest\UIPanelTest - Classes\ExtensionsTest\CocoStudioGUITest\UIScrollViewTest Classes\ExtensionsTest\CocoStudioGUITest\UISliderTest - - Classes\ExtensionsTest\CocoStudioGUITest\UITextAreaTest - - - Classes\ExtensionsTest\CocoStudioGUITest\UITextButtonTest - Classes\ExtensionsTest\CocoStudioGUITest\UITextFieldTest @@ -1318,5 +1285,11 @@ Classes\NewRendererTest + + Classes\ExtensionsTest\CocoStudioGUITest\UIWidgetAddNodeTest + + + Classes\ExtensionsTest\CocoStudioGUITest\UILayoutTest + \ No newline at end of file