From 3e5c62f905990bc7366508d79ff95215903f4a3c Mon Sep 17 00:00:00 2001 From: pktangyue Date: Mon, 8 Jul 2013 17:00:27 +0800 Subject: [PATCH 01/16] fix CCScale9Sprite CapInsets bug for rotated sprite frame --- .../GUI/CCControlExtension/CCScale9Sprite.cpp | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp b/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp index 8dd240e62d..285a866f57 100644 --- a/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp +++ b/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp @@ -687,20 +687,10 @@ void Scale9Sprite::updateCapInset() } else { - if (_spriteFrameRotated) - { - insets = CCRectMake(_insetBottom, - _insetLeft, - _spriteRect.size.width-_insetRight-_insetLeft, - _spriteRect.size.height-_insetTop-_insetBottom); - } - else - { - insets = CCRectMake(_insetLeft, - _insetTop, - _spriteRect.size.width-_insetLeft-_insetRight, - _spriteRect.size.height-_insetTop-_insetBottom); - } + insets = CCRectMake(_insetLeft, + _insetTop, + _spriteRect.size.width-_insetLeft-_insetRight, + _spriteRect.size.height-_insetTop-_insetBottom); } this->setCapInsets(insets); } From 571aeaed7e7b567b7e0aa65b6f4e67f0cfe44fc8 Mon Sep 17 00:00:00 2001 From: zhangbin Date: Wed, 10 Jul 2013 10:40:42 +0800 Subject: [PATCH 02/16] closed #2390, Resolve the bug in modify game projects tools. --- .../proj.android/src/org/cocos2dx/plugin/QH360Wrapper.java | 2 +- .../uc/proj.android/src/org/cocos2dx/plugin/UCWrapper.java | 2 +- plugin/tools/gameDevGuide.sh | 3 +++ plugin/tools/toolsForGame/modifyProject.py | 2 ++ plugin/tools/toolsForGame/steps.py | 2 +- 5 files changed, 8 insertions(+), 3 deletions(-) diff --git a/plugin/plugins/qh360/proj.android/src/org/cocos2dx/plugin/QH360Wrapper.java b/plugin/plugins/qh360/proj.android/src/org/cocos2dx/plugin/QH360Wrapper.java index 60fc6fca68..6f2365b975 100644 --- a/plugin/plugins/qh360/proj.android/src/org/cocos2dx/plugin/QH360Wrapper.java +++ b/plugin/plugins/qh360/proj.android/src/org/cocos2dx/plugin/QH360Wrapper.java @@ -66,7 +66,7 @@ public class QH360Wrapper { if (orientation != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE || orientation != ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) { - orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; + orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; } return (orientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); diff --git a/plugin/plugins/uc/proj.android/src/org/cocos2dx/plugin/UCWrapper.java b/plugin/plugins/uc/proj.android/src/org/cocos2dx/plugin/UCWrapper.java index fc2bfcd9c5..a519688b3f 100644 --- a/plugin/plugins/uc/proj.android/src/org/cocos2dx/plugin/UCWrapper.java +++ b/plugin/plugins/uc/proj.android/src/org/cocos2dx/plugin/UCWrapper.java @@ -112,7 +112,7 @@ public class UCWrapper { if (orientation != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE || orientation != ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) { - orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; + orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; } return (orientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); diff --git a/plugin/tools/gameDevGuide.sh b/plugin/tools/gameDevGuide.sh index e106524e8b..701768cd6a 100755 --- a/plugin/tools/gameDevGuide.sh +++ b/plugin/tools/gameDevGuide.sh @@ -1,4 +1,7 @@ SHELL_DIR=$(cd "$(dirname "$0")"; pwd) + +type gawk >/dev/null 2>&1 || { echo >&2 "gawk is required, PLZ install it first."; exit 1; } + pushd ${SHELL_DIR} # include the config diff --git a/plugin/tools/toolsForGame/modifyProject.py b/plugin/tools/toolsForGame/modifyProject.py index 9a4becc5b7..93d07454fc 100644 --- a/plugin/tools/toolsForGame/modifyProject.py +++ b/plugin/tools/toolsForGame/modifyProject.py @@ -29,6 +29,8 @@ if nodeLinkRes != None: if linkNodes != None and len(linkNodes) > 0: for node in linkNodes: locNode = node.find('locationURI') + if locNode == None: + continue tempText = locNode.text tempText = tempText.strip(' \n\r\t') if tempText == targetPath: diff --git a/plugin/tools/toolsForGame/steps.py b/plugin/tools/toolsForGame/steps.py index 6f2013402b..8c74c65ac9 100644 --- a/plugin/tools/toolsForGame/steps.py +++ b/plugin/tools/toolsForGame/steps.py @@ -18,7 +18,7 @@ class step1(step): step_tip = Label(self.stepFrame, text="Input the android project path of your game:") step_tip.pack(anchor='nw', padx=30) - step_tip2 = Label(self.stepFrame, text="(Please keep your game project path away from spaces)") + step_tip2 = Label(self.stepFrame, text="(Pleasd avoid using spaces in your project path)") step_tip2.pack(anchor='nw', padx=30) self.step_entry = Entry(self.stepFrame) self.step_entry.pack(anchor='nw', fill=X, padx=30) From 54995745cfaf4037fa2df62e45e951fb04e423be Mon Sep 17 00:00:00 2001 From: zhangbin Date: Wed, 10 Jul 2013 15:34:29 +0800 Subject: [PATCH 03/16] closed #2390, Resolve the bug plugin/tools/config.sh. --- plugin/tools/config.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugin/tools/config.sh b/plugin/tools/config.sh index 20c34ad1ff..906841d604 100755 --- a/plugin/tools/config.sh +++ b/plugin/tools/config.sh @@ -10,11 +10,11 @@ export TARGET_DIR_NAME="publish" if [ ! ${PLUGIN_ROOT} ]; then pushd ../ export PLUGIN_ROOT=`pwd` - export TARGET_ROOT=${PLUGIN_ROOT}/${TARGET_DIR_NAME} - echo PLUGIN_ROOT = ${PLUGIN_ROOT} - echo TARGET_ROOT = ${TARGET_ROOT} popd fi +export TARGET_ROOT=${PLUGIN_ROOT}/${TARGET_DIR_NAME} +echo PLUGIN_ROOT = ${PLUGIN_ROOT} +echo TARGET_ROOT = ${TARGET_ROOT} # get a string include all plugins name(separate with ':') export PLUGINS_CAN_SELECT="" From ae9dbd26ce0f5fdf9f95723dc779930e6e56354f Mon Sep 17 00:00:00 2001 From: zhangbin Date: Wed, 10 Jul 2013 16:21:16 +0800 Subject: [PATCH 04/16] issue #2390, Resolve the bug in file plugin/tools/toolsForGame/modifyClassPath.py. --- plugin/tools/toolsForGame/modifyClassPath.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugin/tools/toolsForGame/modifyClassPath.py b/plugin/tools/toolsForGame/modifyClassPath.py index 20c5644ed5..8f3c06c365 100644 --- a/plugin/tools/toolsForGame/modifyClassPath.py +++ b/plugin/tools/toolsForGame/modifyClassPath.py @@ -39,7 +39,8 @@ for pluginName in plugins: if os.path.splitext(fileName)[1] == '.jar': needAdd = True for linkedJar in linkedLibs: - if -1 != linkedJar.find(fileName): + jarName = os.path.basename(linkedJar) + if fileName == jarName: needAdd = False break From 5727d7099b3675c533eeab0b7341c6196fd624e5 Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 11 Jul 2013 13:59:57 +0800 Subject: [PATCH 05/16] issue #2395: Scale9Sprite's default anchor point is center now. --- extensions/GUI/CCControlExtension/CCScale9Sprite.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp b/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp index eaca83b345..47ee0da52c 100644 --- a/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp +++ b/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp @@ -96,8 +96,9 @@ bool Scale9Sprite::initWithBatchNode(SpriteBatchNode* batchnode, Rect rect, bool if(batchnode) { this->updateWithBatchNode(batchnode, rect, rotated, capInsets); - this->setAnchorPoint(ccp(0.5f, 0.5f)); } + + this->setAnchorPoint(ccp(0.5f, 0.5f)); this->_positionsAreDirty = true; return true; From 2e9d727466d63fdd5d0fff4c2e2031e03d584f7f Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 11 Jul 2013 14:00:26 +0800 Subject: [PATCH 06/16] issue #2395: Removing unused codes in ActionTest.h. --- .../TestCpp/Classes/ActionsTest/ActionsTest.h | 47 ------------------- 1 file changed, 47 deletions(-) diff --git a/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.h b/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.h index 3f94eb1c3d..1e70ea8fed 100644 --- a/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.h +++ b/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.h @@ -8,53 +8,6 @@ USING_NS_CC; -enum -{ - ACTION_MANUAL_LAYER = 0, - ACTION_MOVE_LAYER, - ACTION_SCALE_LAYER, - ACTION_ROTATE_LAYER, - ACTION_SKEW_LAYER, - ACTION_ROTATIONAL_SKEW_LAYER, - ACTION_ROTATIONAL_SKEW_VS_STANDARD_SKEW_LAYER, - ACTION_SKEWROTATE_LAYER, - ACTION_JUMP_LAYER, - ACTION_CARDINALSPLINE_LAYER, - ACTION_CATMULLROM_LAYER, - ACTION_BEZIER_LAYER, - ACTION_BLINK_LAYER, - ACTION_FADE_LAYER, - ACTION_TINT_LAYER, - ACTION_ANIMATE_LAYER, - ACTION_SEQUENCE_LAYER, - ACTION_SEQUENCE2_LAYER, - ACTION_SPAWN_LAYER, - ACTION_REVERSE, - ACTION_DELAYTIME_LAYER, - ACTION_REPEAT_LAYER, - ACTION_REPEATEFOREVER_LAYER, - ACTION_ROTATETOREPEATE_LAYER, - ACTION_ROTATEJERK_LAYER, - ACTION_CALLFUNC_LAYER, - ACTION_CALLFUNCND_LAYER, - ACTION_CALLFUNCTION_LAYER, - ACTION_REVERSESEQUENCE_LAYER, - ACTION_REVERSESEQUENCE2_LAYER, - ACTION_ORBIT_LAYER, - ACTION_FLLOW_LAYER, - ACTION_TARGETED_LAYER, - PAUSERESUMEACTIONS_LAYER, - ACTION_ISSUE1305_LAYER, - ACTION_ISSUE1305_2_LAYER, - ACTION_ISSUE1288_LAYER, - ACTION_ISSUE1288_2_LAYER, - ACTION_ISSUE1327_LAYER, - ACTION_ISSUE1398_LAYER, - ACTION_LAYER_COUNT, - ACTION_REMOVE_SELF, -}; - - // the class inherit from TestScene // every Scene each test used must inherit from TestScene, // make sure the test have the menu item for back to main menu From ad95ba4894faf073d2317f24b1e323de683dd1b1 Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 11 Jul 2013 14:07:14 +0800 Subject: [PATCH 07/16] closed #2395: Adding Scale9SpriteTest for TestCpp --- .../Classes/ExtensionsTest/ExtensionsTest.cpp | 11 + .../Scale9SpriteTest/Scale9SpriteTest.cpp | 603 ++++++++++++++++++ .../Scale9SpriteTest/Scale9SpriteTest.h | 180 ++++++ samples/Cpp/TestCpp/Classes/testResource.h | 5 + .../project.pbxproj.REMOVED.git-id | 2 +- 5 files changed, 800 insertions(+), 1 deletion(-) create mode 100644 samples/Cpp/TestCpp/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp create mode 100644 samples/Cpp/TestCpp/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.h diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ExtensionsTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ExtensionsTest.cpp index c13a6a59b3..2b6b849a56 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ExtensionsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ExtensionsTest.cpp @@ -18,6 +18,8 @@ #include "EditBoxTest/EditBoxTest.h" #endif +#include "Scale9SpriteTest/Scale9SpriteTest.h" + enum { LINE_SPACE = 40, @@ -30,6 +32,15 @@ static struct { } g_extensionsTests[] = { { "NotificationCenterTest", [](Object* sender) { runNotificationCenterTest(); } }, + { "Scale9SpriteTest", [](Object* sender) { + S9SpriteTestScene* pScene = new S9SpriteTestScene(); + if (pScene) + { + pScene->runThisTest(); + pScene->release(); + } + } + }, { "CCControlButtonTest", [](Object *sender){ ControlSceneManager* pManager = ControlSceneManager::sharedControlSceneManager(); Scene* pScene = pManager->currentControlScene(); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp new file mode 100644 index 0000000000..728edc00dd --- /dev/null +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp @@ -0,0 +1,603 @@ +/**************************************************************************** + Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011 Zynga Inc. + Copyright (c) 2013 Surith Thekkiam + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "Scale9SpriteTest.h" +#include "testResource.h" +#include "cocos2d.h" +#include "cocos-ext.h" + +USING_NS_CC_EXT; + +static std::function createFunctions[] = { + CL(S9BatchNodeBasic), + CL(S9FrameNameSpriteSheet), + CL(S9FrameNameSpriteSheetRotated), + CL(S9BatchNodeScaledNoInsets), + CL(S9FrameNameSpriteSheetScaledNoInsets), + CL(S9FrameNameSpriteSheetRotatedScaledNoInsets), + CL(S9BatchNodeScaleWithCapInsets), + CL(S9FrameNameSpriteSheetInsets), + CL(S9FrameNameSpriteSheetInsetsScaled), + CL(S9FrameNameSpriteSheetRotatedInsets), + CL(S9_TexturePacker), + CL(S9FrameNameSpriteSheetRotatedInsetsScaled) +}; + +static int sceneIdx=-1; +#define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0])) + +static Layer* nextAction() +{ + sceneIdx++; + sceneIdx = sceneIdx % MAX_LAYER; + + Layer* pLayer = (createFunctions[sceneIdx])(); + pLayer->init(); + pLayer->autorelease(); + + return pLayer; +} + +static Layer* backAction() +{ + sceneIdx--; + int total = MAX_LAYER; + if( sceneIdx < 0 ) + sceneIdx += total; + + Layer* pLayer = (createFunctions[sceneIdx])(); + pLayer->init(); + pLayer->autorelease(); + + return pLayer; +} + +static Layer* restartAction() +{ + Layer* pLayer = (createFunctions[sceneIdx])(); + pLayer->init(); + pLayer->autorelease(); + + return pLayer; +} + +void S9SpriteTestScene::runThisTest() +{ + sceneIdx = -1; + addChild(nextAction()); + + Director::sharedDirector()->replaceScene(this); +} + +//------------------------------------------------------------------ +// +// S9SpriteTestDemo +// +//------------------------------------------------------------------ + +void S9SpriteTestDemo::onEnter() +{ + BaseTest::onEnter(); + SpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(s_s9s_blocks9_plist); + CCLOG("sprite frames added to sprite frame cache..."); +} + +void S9SpriteTestDemo::restartCallback(Object* sender) +{ + Scene* s = new S9SpriteTestScene(); + s->addChild( restartAction() ); + Director::sharedDirector()->replaceScene(s); + s->release(); +} + +void S9SpriteTestDemo::nextCallback(Object* sender) +{ + Scene* s = new S9SpriteTestScene(); + s->addChild( nextAction() ); + Director::sharedDirector()->replaceScene(s); + s->release(); +} + +void S9SpriteTestDemo::backCallback(Object* sender) +{ + Scene* s = new S9SpriteTestScene(); + s->addChild( backAction() ); + Director::sharedDirector()->replaceScene(s); + s->release(); +} + + +// S9BatchNodeBasic + +void S9BatchNodeBasic::onEnter() +{ + S9SpriteTestDemo::onEnter(); + Size winSize = Director::sharedDirector()->getWinSize(); + float x = winSize.width / 2; + float y = 0 + (winSize.height / 2); + + CCLog("S9BatchNodeBasic ..."); + + auto batchNode = SpriteBatchNode::create("Images/blocks9.png"); + CCLog("batchNode created with : Images/blocks9.png"); + + auto blocks = Scale9Sprite::create(); + CCLog("... created"); + + blocks->updateWithBatchNode(batchNode, Rect(0, 0, 96, 96), false, Rect(0, 0, 96, 96)); + CCLog("... updateWithBatchNode"); + + blocks->setPosition(Point(x, y)); + CCLog("... setPosition"); + + this->addChild(blocks); + CCLog("this->addChild"); + + CCLog("... S9BatchNodeBasic done."); +} + +std::string S9BatchNodeBasic::title() +{ + return "Scale9Sprite created empty and updated from SpriteBatchNode"; +} + +std::string S9BatchNodeBasic::subtitle() +{ + return "updateWithBatchNode(); capInsets=full size"; +} + + +// S9FrameNameSpriteSheet + +void S9FrameNameSpriteSheet::onEnter() +{ + S9SpriteTestDemo::onEnter(); + Size winSize = Director::sharedDirector()->getWinSize(); + float x = winSize.width / 2; + float y = 0 + (winSize.height / 2); + + CCLog("S9FrameNameSpriteSheet ..."); + + auto blocks = Scale9Sprite::createWithSpriteFrameName("blocks9.png"); + CCLog("... created"); + + blocks->setPosition(Point(x, y)); + CCLog("... setPosition"); + + this->addChild(blocks); + CCLog("this->addChild"); + + CCLog("... S9FrameNameSpriteSheet done."); +} + +std::string S9FrameNameSpriteSheet::title() +{ + return "Scale9Sprite from sprite sheet"; +} + +std::string S9FrameNameSpriteSheet::subtitle() +{ + return "createWithSpriteFrameName(); default cap insets"; +} + +// +//// S9FrameNameSpriteSheetRotated +// +void S9FrameNameSpriteSheetRotated::onEnter() +{ + S9SpriteTestDemo::onEnter(); + Size winSize = Director::sharedDirector()->getWinSize(); + float x = winSize.width / 2; + float y = 0 + (winSize.height / 2); + + CCLog("S9FrameNameSpriteSheetRotated ..."); + + auto blocks = Scale9Sprite::createWithSpriteFrameName("blocks9r.png"); + CCLog("... created"); + + blocks->setPosition(Point(x, y)); + CCLog("... setPosition"); + + this->addChild(blocks); + CCLog("this->addChild"); + + CCLog("... S9FrameNameSpriteSheetRotated done."); +} + +std::string S9FrameNameSpriteSheetRotated::title() +{ + return "Scale9Sprite from sprite sheet (stored rotated)"; +} + +std::string S9FrameNameSpriteSheetRotated::subtitle() +{ + return "createWithSpriteFrameName(); default cap insets"; +} + +// +//// S9BatchNodeScaledNoInsets +// + +void S9BatchNodeScaledNoInsets::onEnter() +{ + S9SpriteTestDemo::onEnter(); + Size winSize = Director::sharedDirector()->getWinSize(); + float x = winSize.width / 2; + float y = 0 + (winSize.height / 2); + + CCLog("S9BatchNodeScaledNoInsets ..."); + + // scaled without insets + auto batchNode_scaled = SpriteBatchNode::create("Images/blocks9.png"); + CCLog("batchNode_scaled created with : Images/blocks9.png"); + + auto blocks_scaled = Scale9Sprite::create(); + CCLog("... created"); + blocks_scaled->updateWithBatchNode(batchNode_scaled, Rect(0, 0, 96, 96), false, Rect(0, 0, 96, 96)); + CCLog("... updateWithBatchNode"); + + blocks_scaled->setPosition(Point(x, y)); + CCLog("... setPosition"); + + blocks_scaled->setContentSize(Size(96 * 4, 96*2)); + CCLog("... setContentSize"); + + this->addChild(blocks_scaled); + CCLog("this->addChild"); + + CCLog("... S9BtchNodeScaledNoInsets done."); +} + +std::string S9BatchNodeScaledNoInsets::title() +{ + return "Scale9Sprite created empty and updated from SpriteBatchNode"; +} + +std::string S9BatchNodeScaledNoInsets::subtitle() +{ + return "updateWithBatchNode(); capInsets=full size; rendered 4 X width, 2 X height"; +} + +// +//// S9FrameNameSpriteSheetScaledNoInsets +// + +void S9FrameNameSpriteSheetScaledNoInsets::onEnter() +{ + S9SpriteTestDemo::onEnter(); + Size winSize = Director::sharedDirector()->getWinSize(); + float x = winSize.width / 2; + float y = 0 + (winSize.height / 2); + + CCLog("S9FrameNameSpriteSheetScaledNoInsets ..."); + + auto blocks_scaled = Scale9Sprite::createWithSpriteFrameName("blocks9.png"); + CCLog("... created"); + + blocks_scaled->setPosition(Point(x, y)); + CCLog("... setPosition"); + + blocks_scaled->setContentSize(Size(96 * 4, 96*2)); + CCLog("... setContentSize"); + + this->addChild(blocks_scaled); + CCLog("this->addChild"); + + CCLog("... S9FrameNameSpriteSheetScaledNoInsets done."); +} + +std::string S9FrameNameSpriteSheetScaledNoInsets::title() +{ + return "Scale9Sprite from sprite sheet"; +} + +std::string S9FrameNameSpriteSheetScaledNoInsets::subtitle() +{ + return "createWithSpriteFrameName(); default cap insets; rendered 4 X width, 2 X height"; +} + + +// +//// S9FrameNameSpriteSheetRotatedScaledNoInsets +// + +void S9FrameNameSpriteSheetRotatedScaledNoInsets::onEnter() +{ + S9SpriteTestDemo::onEnter(); + Size winSize = Director::sharedDirector()->getWinSize(); + float x = winSize.width / 2; + float y = 0 + (winSize.height / 2); + + CCLog("S9FrameNameSpriteSheetRotatedScaledNoInsets ..."); + + auto blocks_scaled = Scale9Sprite::createWithSpriteFrameName("blocks9r.png"); + CCLog("... created"); + + blocks_scaled->setPosition(Point(x, y)); + CCLog("... setPosition"); + + blocks_scaled->setContentSize(Size(96 * 4, 96*2)); + CCLog("... setContentSize"); + + this->addChild(blocks_scaled); + CCLog("this->addChild"); + + CCLog("... S9FrameNameSpriteSheetRotatedScaledNoInsets done."); +} + +std::string S9FrameNameSpriteSheetRotatedScaledNoInsets::title() +{ + return "Scale9Sprite from sprite sheet (stored rotated)"; +} + +std::string S9FrameNameSpriteSheetRotatedScaledNoInsets::subtitle() +{ + return "createWithSpriteFrameName(); default cap insets; rendered 4 X width, 2 X height"; +} + +// +// +//// S9BatchNodeScaleWithCapInsets +// + +void S9BatchNodeScaleWithCapInsets::onEnter() +{ + S9SpriteTestDemo::onEnter(); + Size winSize = Director::sharedDirector()->getWinSize(); + float x = winSize.width / 2; + float y = 0 + (winSize.height / 2); + + CCLog("S9BatchNodeScaleWithCapInsets ..."); + + auto batchNode_scaled_with_insets = SpriteBatchNode::create("Images/blocks9.png"); + CCLog("batchNode_scaled_with_insets created with : Images/blocks9.png"); + + auto blocks_scaled_with_insets = Scale9Sprite::create(); + CCLog("... created"); + + blocks_scaled_with_insets->updateWithBatchNode(batchNode_scaled_with_insets, Rect(0, 0, 96, 96), false, Rect(32, 32, 32, 32)); + CCLog("... updateWithBatchNode"); + + blocks_scaled_with_insets->setContentSize(Size(96 * 4.5, 96 * 2.5)); + CCLog("... setContentSize"); + + blocks_scaled_with_insets->setPosition(Point(x, y)); + CCLog("... setPosition"); + + this->addChild(blocks_scaled_with_insets); + CCLog("this->addChild"); + + CCLog("... S9BatchNodeScaleWithCapInsets done."); +} + +std::string S9BatchNodeScaleWithCapInsets::title() +{ + return "Scale9Sprite created empty and updated from SpriteBatchNode"; +} + +std::string S9BatchNodeScaleWithCapInsets::subtitle() +{ + return "updateWithBatchNode(); capInsets=(32, 32, 32, 32)"; +} + +// +//// S9FrameNameSpriteSheetInsets +// + +void S9FrameNameSpriteSheetInsets::onEnter() +{ + S9SpriteTestDemo::onEnter(); + Size winSize = Director::sharedDirector()->getWinSize(); + float x = winSize.width / 2; + float y = 0 + (winSize.height / 2); + + CCLog("S9FrameNameSpriteSheetInsets ..."); + + auto blocks_with_insets = Scale9Sprite::createWithSpriteFrameName("blocks9.png", Rect(32, 32, 32, 32)); + CCLog("... created"); + + blocks_with_insets->setPosition(Point(x, y)); + CCLog("... setPosition"); + + this->addChild(blocks_with_insets); + CCLog("this->addChild"); + + CCLog("... S9FrameNameSpriteSheetInsets done."); +} + +std::string S9FrameNameSpriteSheetInsets::title() +{ + return "Scale9Sprite scaled with insets sprite sheet"; +} + +std::string S9FrameNameSpriteSheetInsets::subtitle() +{ + return "createWithSpriteFrameName(); cap insets=(32, 32, 32, 32)"; +} + +// +//// S9FrameNameSpriteSheetInsetsScaled +// +void S9FrameNameSpriteSheetInsetsScaled::onEnter() +{ + S9SpriteTestDemo::onEnter(); + Size winSize = Director::sharedDirector()->getWinSize(); + float x = winSize.width / 2; + float y = 0 + (winSize.height / 2); + + CCLog("S9FrameNameSpriteSheetInsetsScaled ..."); + + auto blocks_scaled_with_insets = Scale9Sprite::createWithSpriteFrameName("blocks9.png", Rect(32, 32, 32, 32)); + CCLog("... created"); + + blocks_scaled_with_insets->setContentSize(Size(96 * 4.5, 96 * 2.5)); + CCLog("... setContentSize"); + + blocks_scaled_with_insets->setPosition(Point(x, y)); + CCLog("... setPosition"); + + this->addChild(blocks_scaled_with_insets); + CCLog("this->addChild"); + + CCLog("... S9FrameNameSpriteSheetInsetsScaled done."); +} + +std::string S9FrameNameSpriteSheetInsetsScaled::title() +{ + return "Scale9Sprite scaled with insets sprite sheet"; +} + +std::string S9FrameNameSpriteSheetInsetsScaled::subtitle() +{ + return "createWithSpriteFrameName(); default cap insets; rendered scaled 4.5 X width, 2.5 X height"; +} + +//// S9FrameNameSpriteSheetRotatedInsets +// + +void S9FrameNameSpriteSheetRotatedInsets::onEnter() +{ + S9SpriteTestDemo::onEnter(); + Size winSize = Director::sharedDirector()->getWinSize(); + float x = winSize.width / 2; + float y = 0 + (winSize.height / 2); + + CCLog("S9FrameNameSpriteSheetRotatedInsets ..."); + + auto blocks_with_insets = Scale9Sprite::createWithSpriteFrameName("blocks9r.png", Rect(32, 32, 32, 32)); + CCLog("... created"); + + blocks_with_insets->setPosition(Point(x, y)); + CCLog("... setPosition"); + + this->addChild(blocks_with_insets); + CCLog("this->addChild"); + + CCLog("... S9FrameNameSpriteSheetRotatedInsets done."); +} + +std::string S9FrameNameSpriteSheetRotatedInsets::title() +{ + return "Scale9Sprite scaled with insets sprite sheet (stored rotated)"; +} + +std::string S9FrameNameSpriteSheetRotatedInsets::subtitle() +{ + return "createWithSpriteFrameName(); cap insets=(32, 32, 32, 32)"; +} + +// +//// S9_TexturePacker +// + +void S9_TexturePacker::onEnter() +{ + S9SpriteTestDemo::onEnter(); + Size winSize = Director::sharedDirector()->getWinSize(); + SpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(s_s9s_ui_plist); + + float x = winSize.width / 4; + float y = 0 + (winSize.height / 2); + + CCLog("S9_TexturePacker ..."); + + auto s = Scale9Sprite::createWithSpriteFrameName("button_normal.png"); + CCLog("... created"); + + s->setPosition(Point(x, y)); + CCLog("... setPosition"); + + s->setContentSize(Size(21 * 16, 13 * 16)); + CCLog("... setContentSize"); + + this->addChild(s); + CCLog("this->addChild"); + + x = winSize.width * 3/4; + + auto s2 = Scale9Sprite::createWithSpriteFrameName("button_actived.png"); + CCLog("... created"); + + s2->setPosition(Point(x, y)); + CCLog("... setPosition"); + + s2->setContentSize(Size(21 * 16, 13 * 16)); + CCLog("... setContentSize"); + + this->addChild(s2); + CCLog("this->addChild"); + + CCLog("... S9_TexturePacker done."); +} + +std::string S9_TexturePacker::title() +{ + return "Scale9Sprite from a spritesheet created with TexturePacker"; +} + +std::string S9_TexturePacker::subtitle() +{ + return "createWithSpriteFrameName('button_normal.png');createWithSpriteFrameName('button_actived.png');"; +} + +// +//// S9FrameNameSpriteSheetRotatedInsetsScaled +// + +void S9FrameNameSpriteSheetRotatedInsetsScaled::onEnter() +{ + S9SpriteTestDemo::onEnter(); + Size winSize = Director::sharedDirector()->getWinSize(); + float x = winSize.width / 2; + float y = 0 + (winSize.height / 2); + + CCLog("S9FrameNameSpriteSheetRotatedInsetsScaled ..."); + + auto blocks_scaled_with_insets = Scale9Sprite::createWithSpriteFrameName("blocks9.png", Rect(32, 32, 32, 32)); + CCLog("... created"); + + blocks_scaled_with_insets->setContentSize(Size(96 * 4.5, 96 * 2.5)); + CCLog("... setContentSize"); + + blocks_scaled_with_insets->setPosition(Point(x, y)); + CCLog("... setPosition"); + + this->addChild(blocks_scaled_with_insets); + CCLog("this->addChild"); + + CCLog("... S9FrameNameSpriteSheetRotatedInsetsScaled done."); +} + +std::string S9FrameNameSpriteSheetRotatedInsetsScaled::title() +{ + return "Scale9Sprite scaled with insets sprite sheet (stored rotated)"; +} + +std::string S9FrameNameSpriteSheetRotatedInsetsScaled::subtitle() +{ + return "createWithSpriteFrameName(); default cap insets; rendered scaled 4.5 X width, 2.5 X height"; +} diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.h new file mode 100644 index 0000000000..d2f6274502 --- /dev/null +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.h @@ -0,0 +1,180 @@ +/**************************************************************************** + Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011 Zynga Inc. + Copyright (c) 2013 Surith Thekkiam + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "testBasic.h" +#include "BaseTest.h" + + +class S9SpriteTestScene : public TestScene +{ +public: + virtual void runThisTest(); +}; + +class S9SpriteTestDemo : public BaseTest +{ +public: + virtual void onEnter(); + + virtual void restartCallback(Object* sender); + virtual void nextCallback(Object* sender); + virtual void backCallback(Object* sender); +}; + +// S9BatchNodeBasic + +class S9BatchNodeBasic : public S9SpriteTestDemo +{ +public: + virtual void onEnter(); + + virtual std::string title(); + virtual std::string subtitle(); +}; + +// S9FrameNameSpriteSheet + +class S9FrameNameSpriteSheet : public S9SpriteTestDemo +{ +public: + virtual void onEnter(); + + virtual std::string title(); + virtual std::string subtitle(); +}; + +// S9FrameNameSpriteSheetRotated + +class S9FrameNameSpriteSheetRotated : public S9SpriteTestDemo +{ +public: + virtual void onEnter(); + + virtual std::string title(); + virtual std::string subtitle(); +}; + +// S9BatchNodeScaledNoInsets + +class S9BatchNodeScaledNoInsets : public S9SpriteTestDemo +{ +public: + virtual void onEnter(); + + virtual std::string title(); + virtual std::string subtitle(); +}; + +// S9FrameNameSpriteSheetScaledNoInsets + +class S9FrameNameSpriteSheetScaledNoInsets : public S9SpriteTestDemo +{ +public: + virtual void onEnter(); + + virtual std::string title(); + virtual std::string subtitle(); +}; + +// S9FrameNameSpriteSheetRotatedScaledNoInsets + +class S9FrameNameSpriteSheetRotatedScaledNoInsets : public S9SpriteTestDemo +{ +public: + virtual void onEnter(); + + virtual std::string title(); + virtual std::string subtitle(); +}; + + +// S9BatchNodeScaleWithCapInsets + +class S9BatchNodeScaleWithCapInsets : public S9SpriteTestDemo +{ +public: + virtual void onEnter(); + + virtual std::string title(); + virtual std::string subtitle(); +}; + +// S9FrameNameSpriteSheetInsets + +class S9FrameNameSpriteSheetInsets : public S9SpriteTestDemo +{ +public: + virtual void onEnter(); + + virtual std::string title(); + virtual std::string subtitle(); +}; + +// S9FrameNameSpriteSheetInsetsScaled + +class S9FrameNameSpriteSheetInsetsScaled : public S9SpriteTestDemo +{ +public: + virtual void onEnter(); + + virtual std::string title(); + virtual std::string subtitle(); +}; + +// S9FrameNameSpriteSheetRotatedInsets + +class S9FrameNameSpriteSheetRotatedInsets : public S9SpriteTestDemo +{ +public: + virtual void onEnter(); + + virtual std::string title(); + virtual std::string subtitle(); +}; + +// S9_TexturePacker + +class S9_TexturePacker : public S9SpriteTestDemo +{ +public: + virtual void onEnter(); + + virtual std::string title(); + virtual std::string subtitle(); +}; + +// S9FrameNameSpriteSheetRotatedInsetsScaled + +class S9FrameNameSpriteSheetRotatedInsetsScaled : public S9SpriteTestDemo +{ +public: + virtual void onEnter(); + + virtual std::string title(); + virtual std::string subtitle(); +}; + diff --git a/samples/Cpp/TestCpp/Classes/testResource.h b/samples/Cpp/TestCpp/Classes/testResource.h index 6293e6a1d6..72b72c286e 100644 --- a/samples/Cpp/TestCpp/Classes/testResource.h +++ b/samples/Cpp/TestCpp/Classes/testResource.h @@ -39,5 +39,10 @@ static const char s_AtlasTest[] = "Images/atlastest.png"; static const char s_TilesPng[] = "TileMaps/tiles.png"; static const char s_LevelMapTga[] = "TileMaps/levelmap.tga"; +// Scale9Sprite resource +static const char s_s9s_blocks9[] = "Images/blocks9ss.png"; +static const char s_s9s_blocks9_plist[] = "Images/blocks9ss.plist"; +static const char s_s9s_ui[] = "Images/ui.png"; +static const char s_s9s_ui_plist[] = "Images/ui.plist"; #endif diff --git a/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id b/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id index 303698521a..3c29d0e657 100644 --- a/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -678e714c9c548501d076d34e2af0b13619e0a5aa \ No newline at end of file +14e0d7211e9d0c638e41502416e3d944890dd856 \ No newline at end of file From 9946bc4f00e19b6cf36fd753328048fec8f19c32 Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 11 Jul 2013 14:13:01 +0800 Subject: [PATCH 08/16] issue #2395: Adding Scale9SpriteTest for other platforms. --- samples/Cpp/TestCpp/Android.mk | 1 + samples/Cpp/TestCpp/proj.emscripten/Makefile | 13 +++++++------ samples/Cpp/TestCpp/proj.linux/Makefile | 13 +++++++------ samples/Cpp/TestCpp/proj.nacl/Makefile | 13 +++++++------ 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/samples/Cpp/TestCpp/Android.mk b/samples/Cpp/TestCpp/Android.mk index f60492fda4..d865004371 100644 --- a/samples/Cpp/TestCpp/Android.mk +++ b/samples/Cpp/TestCpp/Android.mk @@ -66,6 +66,7 @@ Classes/ExtensionsTest/NetworkTest/WebSocketTest.cpp \ Classes/ExtensionsTest/EditBoxTest/EditBoxTest.cpp \ Classes/ExtensionsTest/TableViewTest/TableViewTestScene.cpp \ Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.cpp \ +Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp \ Classes/FontTest/FontTest.cpp \ Classes/IntervalTest/IntervalTest.cpp \ Classes/KeypadTest/KeypadTest.cpp \ diff --git a/samples/Cpp/TestCpp/proj.emscripten/Makefile b/samples/Cpp/TestCpp/proj.emscripten/Makefile index c580d89eb9..6f069f65bd 100644 --- a/samples/Cpp/TestCpp/proj.emscripten/Makefile +++ b/samples/Cpp/TestCpp/proj.emscripten/Makefile @@ -49,13 +49,14 @@ SOURCES = ../Classes/AccelerometerTest/AccelerometerTest.cpp \ ../Classes/ExtensionsTest/ExtensionsTest.cpp \ ../Classes/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.cpp \ ../Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp \ - ../Classes/ExtensionsTest/ComponentsTest/ComponentsTestScene.cpp \ - ../Classes/ExtensionsTest/ComponentsTest/EnemyController.cpp \ - ../Classes/ExtensionsTest/ComponentsTest/GameOverScene.cpp \ - ../Classes/ExtensionsTest/ComponentsTest/PlayerController.cpp \ - ../Classes/ExtensionsTest/ComponentsTest/ProjectileController.cpp \ - ../Classes/ExtensionsTest/ComponentsTest/SceneController.cpp \ + ../Classes/ExtensionsTest/ComponentsTest/ComponentsTestScene.cpp \ + ../Classes/ExtensionsTest/ComponentsTest/EnemyController.cpp \ + ../Classes/ExtensionsTest/ComponentsTest/GameOverScene.cpp \ + ../Classes/ExtensionsTest/ComponentsTest/PlayerController.cpp \ + ../Classes/ExtensionsTest/ComponentsTest/ProjectileController.cpp \ + ../Classes/ExtensionsTest/ComponentsTest/SceneController.cpp \ ../Classes/ExtensionsTest/ArmatureTest/ArmatureScene.cpp \ + ../Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp \ ../Classes/FontTest/FontTest.cpp \ ../Classes/IntervalTest/IntervalTest.cpp \ ../Classes/KeypadTest/KeypadTest.cpp \ diff --git a/samples/Cpp/TestCpp/proj.linux/Makefile b/samples/Cpp/TestCpp/proj.linux/Makefile index 62c38a39cc..6299d76db2 100644 --- a/samples/Cpp/TestCpp/proj.linux/Makefile +++ b/samples/Cpp/TestCpp/proj.linux/Makefile @@ -52,13 +52,14 @@ SOURCES = ../Classes/AccelerometerTest/AccelerometerTest.cpp \ ../Classes/ExtensionsTest/ExtensionsTest.cpp \ ../Classes/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.cpp \ ../Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp \ - ../Classes/ExtensionsTest/ComponentsTest/ComponentsTestScene.cpp \ - ../Classes/ExtensionsTest/ComponentsTest/EnemyController.cpp \ - ../Classes/ExtensionsTest/ComponentsTest/GameOverScene.cpp \ - ../Classes/ExtensionsTest/ComponentsTest/PlayerController.cpp \ - ../Classes/ExtensionsTest/ComponentsTest/ProjectileController.cpp \ - ../Classes/ExtensionsTest/ComponentsTest/SceneController.cpp \ + ../Classes/ExtensionsTest/ComponentsTest/ComponentsTestScene.cpp \ + ../Classes/ExtensionsTest/ComponentsTest/EnemyController.cpp \ + ../Classes/ExtensionsTest/ComponentsTest/GameOverScene.cpp \ + ../Classes/ExtensionsTest/ComponentsTest/PlayerController.cpp \ + ../Classes/ExtensionsTest/ComponentsTest/ProjectileController.cpp \ + ../Classes/ExtensionsTest/ComponentsTest/SceneController.cpp \ ../Classes/ExtensionsTest/ArmatureTest/ArmatureScene.cpp \ + ../Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp \ ../Classes/FontTest/FontTest.cpp \ ../Classes/IntervalTest/IntervalTest.cpp \ ../Classes/KeyboardTest/KeyboardTest.cpp \ diff --git a/samples/Cpp/TestCpp/proj.nacl/Makefile b/samples/Cpp/TestCpp/proj.nacl/Makefile index 870354d05b..6dac4828f1 100644 --- a/samples/Cpp/TestCpp/proj.nacl/Makefile +++ b/samples/Cpp/TestCpp/proj.nacl/Makefile @@ -55,13 +55,14 @@ SOURCES = ../Classes/AccelerometerTest/AccelerometerTest.cpp \ ../Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.cpp \ ../Classes/ExtensionsTest/ExtensionsTest.cpp \ ../Classes/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.cpp \ - ../Classes/ExtensionsTest/ComponentsTest/ComponentsTestScene.cpp \ - ../Classes/ExtensionsTest/ComponentsTest/EnemyController.cpp \ - ../Classes/ExtensionsTest/ComponentsTest/GameOverScene.cpp \ - ../Classes/ExtensionsTest/ComponentsTest/PlayerController.cpp \ - ../Classes/ExtensionsTest/ComponentsTest/ProjectileController.cpp \ - ../Classes/ExtensionsTest/ComponentsTest/SceneController.cpp \ + ../Classes/ExtensionsTest/ComponentsTest/ComponentsTestScene.cpp \ + ../Classes/ExtensionsTest/ComponentsTest/EnemyController.cpp \ + ../Classes/ExtensionsTest/ComponentsTest/GameOverScene.cpp \ + ../Classes/ExtensionsTest/ComponentsTest/PlayerController.cpp \ + ../Classes/ExtensionsTest/ComponentsTest/ProjectileController.cpp \ + ../Classes/ExtensionsTest/ComponentsTest/SceneController.cpp \ ../Classes/ExtensionsTest/ArmatureTest/ArmatureScene.cpp \ + ../Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp \ ../Classes/FileUtilsTest/FileUtilsTest.cpp \ ../Classes/FontTest/FontTest.cpp \ ../Classes/IntervalTest/IntervalTest.cpp \ From ab4e9749b6f3341194eb4cd15ec4042b75232479 Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 11 Jul 2013 14:17:43 +0800 Subject: [PATCH 09/16] issue #2395: [Win32] Updating TestCpp project configuration --- samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj | 2 ++ samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj.filters | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj b/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj index fac41ae5e7..09a603fc73 100644 --- a/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj +++ b/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj @@ -151,6 +151,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\libwebsockets\win32\lib\*.*" "$(O + @@ -258,6 +259,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\libwebsockets\win32\lib\*.*" "$(O + diff --git a/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj.filters b/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj.filters index da6a8674db..967126a591 100644 --- a/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj.filters +++ b/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj.filters @@ -232,6 +232,9 @@ {285cdfb8-5749-4969-ae31-99ec25f15e6e} + + {3d73aa04-d66e-43d3-921f-b867a753c113} + @@ -543,6 +546,9 @@ Classes\ExtensionsTest\ComponentsTest + + Classes\ExtensionsTest\Scale9SpriteTest + @@ -1034,5 +1040,8 @@ Classes\ExtensionsTest\ComponentsTest + + Classes\ExtensionsTest\Scale9SpriteTest + \ No newline at end of file From 1527c1b4c3fe19a8b3343dafd3df537205336166 Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 11 Jul 2013 15:09:13 +0800 Subject: [PATCH 10/16] issue #2395: Updating TestCpp/Android.mk --- samples/Cpp/TestCpp/Android.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/samples/Cpp/TestCpp/Android.mk b/samples/Cpp/TestCpp/Android.mk index d865004371..55e2bdd3c2 100644 --- a/samples/Cpp/TestCpp/Android.mk +++ b/samples/Cpp/TestCpp/Android.mk @@ -111,6 +111,8 @@ Classes/AppDelegate.cpp \ Classes/BaseTest.cpp \ Classes/VisibleRect.cpp +LOCAL_C_INCLUDES := $(LOCAL_PATH)/Classes + LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static LOCAL_WHOLE_STATIC_LIBRARIES += box2d_static From f414803e9214915f44efdaab52e19f097d2fb4ea Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 11 Jul 2013 15:36:00 +0800 Subject: [PATCH 11/16] Minor fix of PR 3128. --- cocos2dx/cocoa/CCObject.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2dx/cocoa/CCObject.h b/cocos2dx/cocoa/CCObject.h index edfb7aeae6..b70e184edb 100644 --- a/cocos2dx/cocoa/CCObject.h +++ b/cocos2dx/cocoa/CCObject.h @@ -53,7 +53,7 @@ public: /** returns a copy of the object. @deprecated Use clone() instead */ - CC_DEPRECATED_ATTRIBUTE void copy() const + CC_DEPRECATED_ATTRIBUTE Object* copy() const { // use "clone" instead CC_ASSERT(false); From a5470aaa45a88110a3bc20ebc080696da1dbeb40 Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 11 Jul 2013 15:41:05 +0800 Subject: [PATCH 12/16] Minor fix in BezierTo::initWithDuration and BezierTo::clone. --- cocos2dx/actions/CCActionInterval.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cocos2dx/actions/CCActionInterval.cpp b/cocos2dx/actions/CCActionInterval.cpp index 997bd30ba0..48b71fa67a 100644 --- a/cocos2dx/actions/CCActionInterval.cpp +++ b/cocos2dx/actions/CCActionInterval.cpp @@ -1380,21 +1380,20 @@ BezierTo* BezierTo::create(float t, const ccBezierConfig& c) bool BezierTo::initWithDuration(float t, const ccBezierConfig &c) { - bool bRet = false; - if (ActionInterval::initWithDuration(t)) { _toConfig = c; + return true; } - return bRet; + return false; } BezierTo* BezierTo::clone(void) const { // no copy constructor auto a = new BezierTo(); - a->initWithDuration(_duration, _config); + a->initWithDuration(_duration, _toConfig); a->autorelease(); return a; } From 5e8de73061e25c4f3f1bb6818cd929c8c485ae49 Mon Sep 17 00:00:00 2001 From: pktangyue Date: Thu, 11 Jul 2013 16:08:23 +0800 Subject: [PATCH 13/16] add S9FrameNameSpriteSheetRotatedSetCapInsetLater test --- .../Scale9SpriteTest/Scale9SpriteTest.cpp | 41 ++++++++++++++++++- .../Scale9SpriteTest/Scale9SpriteTest.h | 10 +++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp index 728edc00dd..23bcf25e13 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp @@ -44,7 +44,8 @@ static std::function createFunctions[] = { CL(S9FrameNameSpriteSheetInsetsScaled), CL(S9FrameNameSpriteSheetRotatedInsets), CL(S9_TexturePacker), - CL(S9FrameNameSpriteSheetRotatedInsetsScaled) + CL(S9FrameNameSpriteSheetRotatedInsetsScaled), + CL(S9FrameNameSpriteSheetRotatedSetCapInsetLater) }; static int sceneIdx=-1; @@ -601,3 +602,41 @@ std::string S9FrameNameSpriteSheetRotatedInsetsScaled::subtitle() { return "createWithSpriteFrameName(); default cap insets; rendered scaled 4.5 X width, 2.5 X height"; } + +// +//// Scale9FrameNameSpriteSheetRotatedSetCapInsetLater +// + +void S9FrameNameSpriteSheetRotatedSetCapInsetLater::onEnter() +{ + S9SpriteTestDemo::onEnter(); + Size winSize = Director::sharedDirector()->getWinSize(); + float x = winSize.width / 2; + float y = 0 + (winSize.height / 2); + + CCLog("Scale9FrameNameSpriteSheetRotatedSetCapInsetLater ..."); + + auto blocks_scaled_with_insets = Scale9Sprite::createWithSpriteFrameName("blocks9r.png"); + CCLog("... created"); + + blocks_scaled_with_insets->setInsetLeft(32); + blocks_scaled_with_insets->setInsetRight(32); + + blocks_scaled_with_insets->setPosition(Point(x, y)); + CCLog("... setPosition"); + + this->addChild(blocks_scaled_with_insets); + CCLog("this->addChild"); + + CCLog("... Scale9FrameNameSpriteSheetRotatedSetCapInsetLater done."); +} + +std::string S9FrameNameSpriteSheetRotatedSetCapInsetLater::title() +{ + return "Scale9Sprite from sprite sheet (stored rotated), with setting CapInset later"; +} + +std::string S9FrameNameSpriteSheetRotatedSetCapInsetLater::subtitle() +{ + return "createWithSpriteFrameName(); setInsetLeft(32); setInsetRight(32);"; +} diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.h index d2f6274502..3c2fb69a7b 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.h @@ -178,3 +178,13 @@ public: virtual std::string subtitle(); }; +// S9FrameNameSpriteSheetRotatedInsetsScaled + +class S9FrameNameSpriteSheetRotatedSetCapInsetLater : public S9SpriteTestDemo +{ +public: + virtual void onEnter(); + + virtual std::string title(); + virtual std::string subtitle(); +}; From 093d9a507c48524f5724b14afb8829ca55f0447e Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 11 Jul 2013 17:07:41 +0800 Subject: [PATCH 14/16] closed #2396: indentation fix. --- extensions/GUI/CCControlExtension/CCScale9Sprite.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp b/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp index 8f01666bd5..9d9d782216 100644 --- a/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp +++ b/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp @@ -384,11 +384,11 @@ bool Scale9Sprite::updateWithBatchNode(SpriteBatchNode* batchnode, Rect rect, bo this->addChild(_scale9Image); if (_spritesGenerated) - { - // Restore color and opacity - this->setOpacity(opacity); - this->setColor(color); - } + { + // Restore color and opacity + this->setOpacity(opacity); + this->setColor(color); + } _spritesGenerated = true; return true; From 3c64bc897246a4b8b1697e3138dc3c8da3738429 Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 11 Jul 2013 17:08:09 +0800 Subject: [PATCH 15/16] issue #2396: Updating Scale9SpriteTest.cpp. --- .../ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp index 23bcf25e13..011e9a6252 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp @@ -532,7 +532,7 @@ void S9_TexturePacker::onEnter() s->setPosition(Point(x, y)); CCLog("... setPosition"); - s->setContentSize(Size(21 * 16, 13 * 16)); + s->setContentSize(Size(14 * 16, 10 * 16)); CCLog("... setContentSize"); this->addChild(s); @@ -546,7 +546,7 @@ void S9_TexturePacker::onEnter() s2->setPosition(Point(x, y)); CCLog("... setPosition"); - s2->setContentSize(Size(21 * 16, 13 * 16)); + s2->setContentSize(Size(14 * 16, 10 * 16)); CCLog("... setContentSize"); this->addChild(s2); @@ -621,7 +621,8 @@ void S9FrameNameSpriteSheetRotatedSetCapInsetLater::onEnter() 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"); From cfc12d780c154af0815a020cd0b8cf3644d6d30b Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 11 Jul 2013 17:11:18 +0800 Subject: [PATCH 16/16] Update AUTHORS [ci skip] --- AUTHORS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/AUTHORS b/AUTHORS index 767d8ff7d7..0f97937e53 100644 --- a/AUTHORS +++ b/AUTHORS @@ -514,6 +514,9 @@ Developers: hannon235 (Chris) Fixing a bug that the submenu of ExtensionTest in TestCpp can't scroll. + + pktangyue + Fixing a bug that CCScale9Sprite::setInsetLeft/XXX can't work for rotated sprite frame. Retired Core Developers: WenSheng Yang