From 88a1cd73fafc25450df8ea913677de2f63390440 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Sun, 15 Jan 2017 17:30:08 -0800 Subject: [PATCH] improves fix for issue #17119 (v3) (#17188) --- cocos/2d/CCSprite.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cocos/2d/CCSprite.cpp b/cocos/2d/CCSprite.cpp index a25b6d7d78..864d4d781c 100644 --- a/cocos/2d/CCSprite.cpp +++ b/cocos/2d/CCSprite.cpp @@ -669,7 +669,10 @@ void Sprite::updatePoly() void Sprite::setCenterRectNormalized(const cocos2d::Rect &rectTopLeft) { - CCASSERT(_renderMode == RenderMode::QUAD || _renderMode == RenderMode::SLICE9, "centerRect can only be used with SLICE9 or QUAD render modes"); + if (_renderMode != RenderMode::QUAD && _renderMode != RenderMode::SLICE9) { + CCLOGWARN("Warning: Sprite::setCenterRectNormalized() only works with QUAD and SLICE9 render modes"); + return; + } // FIMXE: Rect is has origin on top-left (like text coordinate). // but all the logic has been done using bottom-left as origin. So it is easier to invert Y @@ -716,7 +719,10 @@ void Sprite::setCenterRectNormalized(const cocos2d::Rect &rectTopLeft) void Sprite::setCenterRect(const cocos2d::Rect &rectInPoints) { - CCASSERT(_renderMode == RenderMode::QUAD || _renderMode == RenderMode::SLICE9, "centerRect can only be used with SLICE9 or QUAD render modes"); + if (_renderMode != RenderMode::QUAD && _renderMode != RenderMode::SLICE9) { + CCLOGWARN("Warning: Sprite::setCenterRect() only works with QUAD and SLICE9 render modes"); + return; + } if (!_originalContentSize.equals(Size::ZERO)) {