diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp index 70e38afe42..dd5628d656 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp @@ -38,8 +38,6 @@ UIScale9SpriteTests::UIScale9SpriteTests() ADD_TEST_CASE(UIS9FrameNameSpriteSheetRotated); ADD_TEST_CASE(UIS9FrameNameSpriteSheetCropped); ADD_TEST_CASE(UIS9FrameNameSpriteSheetCroppedRotated); - ADD_TEST_CASE(UIS9FrameNameSpriteSheetCroppedImage); - ADD_TEST_CASE(UIS9FrameNameSpriteSheetCroppedRotatedImage); ADD_TEST_CASE(UIS9FrameNameSpriteSheetCroppedSimple); ADD_TEST_CASE(UIS9FrameNameSpriteSheetCroppedRotatedSimple); ADD_TEST_CASE(UIS9BatchNodeScaledNoInsets); @@ -357,9 +355,14 @@ bool UIS9FrameNameSpriteSheetCropped::init() auto blocks = ui::Scale9Sprite::createWithSpriteFrameName("blocks9c.png"); blocks->setPreferredSize(Size(400,80)); - blocks->setPosition(Vec2(x, y)); + blocks->setPosition(Vec2(x, y + 45)); this->addChild(blocks); + auto blocks2 = ui::Scale9Sprite::create("Images/blocks9c.png"); + blocks2->setPreferredSize(Size(400,80)); + blocks2->setPosition(Vec2(x, y - 45)); + this->addChild(blocks2); + return true; } @@ -377,48 +380,13 @@ bool UIS9FrameNameSpriteSheetCroppedRotated::init() auto blocks = ui::Scale9Sprite::createWithSpriteFrameName("blocks9cr.png"); blocks->setPreferredSize(Size(400,80)); - blocks->setPosition(Vec2(x, y)); + blocks->setPosition(Vec2(x, y + 45)); this->addChild(blocks); - return true; - } - - return false; -} - -bool UIS9FrameNameSpriteSheetCroppedImage::init() -{ - if (UIScene::init()) { - auto winSize = Director::getInstance()->getWinSize(); - float x = winSize.width / 2; - float y = 0 + (winSize.height / 2); - - SpriteFrameCache::getInstance()->addSpriteFramesWithFile(s_s9s_blocks9_plist); - - auto blocks = Sprite::createWithSpriteFrameName("blocks9c.png"); - blocks->setScale(400/blocks->getContentSize().width, 80/blocks->getContentSize().height); - blocks->setPosition(Vec2(x, y)); - this->addChild(blocks); - - return true; - } - - return false; -} - -bool UIS9FrameNameSpriteSheetCroppedRotatedImage::init() -{ - if (UIScene::init()) { - auto winSize = Director::getInstance()->getWinSize(); - float x = winSize.width / 2; - float y = 0 + (winSize.height / 2); - - SpriteFrameCache::getInstance()->addSpriteFramesWithFile(s_s9s_blocks9_plist); - - auto blocks = Sprite::createWithSpriteFrameName("blocks9cr.png"); - blocks->setScale(400/blocks->getContentSize().width, 80/blocks->getContentSize().height); - blocks->setPosition(Vec2(x, y)); - this->addChild(blocks); + auto blocks2 = ui::Scale9Sprite::create("Images/blocks9cr.png"); + blocks2->setPreferredSize(Size(400,80)); + blocks2->setPosition(Vec2(x, y - 45)); + this->addChild(blocks2); return true; } @@ -438,9 +406,14 @@ bool UIS9FrameNameSpriteSheetCroppedSimple::init() auto blocks = ui::Scale9Sprite::createWithSpriteFrameName("blocks9c.png"); blocks->setRenderingType(Scale9Sprite::RenderingType::SIMPLE); blocks->setPreferredSize(Size(400,80)); - blocks->setPosition(Vec2(x, y)); + blocks->setPosition(Vec2(x, y + 45)); this->addChild(blocks); + auto blocksSprite = Sprite::createWithSpriteFrameName("blocks9c.png"); + blocksSprite->setScale(400/blocksSprite->getContentSize().width, 80/blocksSprite->getContentSize().height); + blocksSprite->setPosition(Vec2(x, y - 45)); + this->addChild(blocksSprite); + return true; } @@ -459,9 +432,14 @@ bool UIS9FrameNameSpriteSheetCroppedRotatedSimple::init() auto blocks = ui::Scale9Sprite::createWithSpriteFrameName("blocks9cr.png"); blocks->setRenderingType(Scale9Sprite::RenderingType::SIMPLE); blocks->setPreferredSize(Size(400,80)); - blocks->setPosition(Vec2(x, y)); + blocks->setPosition(Vec2(x, y + 45)); this->addChild(blocks); + auto blocksSprite = Sprite::createWithSpriteFrameName("blocks9cr.png"); + blocksSprite->setScale(400/blocksSprite->getContentSize().width, 80/blocksSprite->getContentSize().height); + blocksSprite->setPosition(Vec2(x, y - 45)); + this->addChild(blocksSprite); + return true; } diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.h index 8d6f872b15..11042a7990 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.h @@ -91,27 +91,7 @@ public: virtual bool init() override; }; -// S9FrameNameSpriteSheetCropped - -class UIS9FrameNameSpriteSheetCroppedImage : public UIScene -{ -public: - CREATE_FUNC(UIS9FrameNameSpriteSheetCroppedImage); - - virtual bool init() override; -}; - -// S9FrameNameSpriteSheetCroppedRotated - -class UIS9FrameNameSpriteSheetCroppedRotatedImage : public UIScene -{ -public: - CREATE_FUNC(UIS9FrameNameSpriteSheetCroppedRotatedImage); - - virtual bool init() override; -}; - -// S9FrameNameSpriteSheetCropped +// S9FrameNameSpriteSheetCroppedSimple class UIS9FrameNameSpriteSheetCroppedSimple : public UIScene { @@ -121,7 +101,7 @@ public: virtual bool init() override; }; -// S9FrameNameSpriteSheetCroppedRotated +// S9FrameNameSpriteSheetCroppedRotatedSimple class UIS9FrameNameSpriteSheetCroppedRotatedSimple : public UIScene { diff --git a/tests/cpp-tests/Resources/Images/blocks9cr.png b/tests/cpp-tests/Resources/Images/blocks9cr.png index 0f25bdc6b9..beea86d7f8 100644 Binary files a/tests/cpp-tests/Resources/Images/blocks9cr.png and b/tests/cpp-tests/Resources/Images/blocks9cr.png differ diff --git a/tests/cpp-tests/Resources/hd/Images/blocks9cr.png b/tests/cpp-tests/Resources/hd/Images/blocks9cr.png index f32d316174..74fc6c8b01 100644 Binary files a/tests/cpp-tests/Resources/hd/Images/blocks9cr.png and b/tests/cpp-tests/Resources/hd/Images/blocks9cr.png differ