Revert "fix scale9sprite gray state opacity issue."

This commit is contained in:
zilongshanren 2016-01-07 17:07:27 +08:00
parent a05e15d17e
commit 2797277de8
3 changed files with 0 additions and 60 deletions

View File

@ -10,7 +10,6 @@ const char* ccPositionTexture_GrayScale_frag = STRINGIFY(
\nvoid main(void)\n \nvoid main(void)\n
\n{\n \n{\n
\nvec4 c = texture2D(CC_Texture0, v_texCoord);\n \nvec4 c = texture2D(CC_Texture0, v_texCoord);\n
\n c = v_fragmentColor * c; \n
\ngl_FragColor.xyz = vec3(0.2126*c.r + 0.7152*c.g + 0.0722*c.b);\n \ngl_FragColor.xyz = vec3(0.2126*c.r + 0.7152*c.g + 0.0722*c.b);\n
\ngl_FragColor.w = c.w;\n \ngl_FragColor.w = c.w;\n
\n}\n \n}\n

View File

@ -59,7 +59,6 @@ UIScale9SpriteTests::UIScale9SpriteTests()
ADD_TEST_CASE(UIS9ToggleRenderingTypeTest); ADD_TEST_CASE(UIS9ToggleRenderingTypeTest);
ADD_TEST_CASE(UIS9GlobalZOrderTest); ADD_TEST_CASE(UIS9GlobalZOrderTest);
ADD_TEST_CASE(UIS9EnableScale9FalseTest); ADD_TEST_CASE(UIS9EnableScale9FalseTest);
ADD_TEST_CASE(UIS9GrayStateOpacityTest);
} }
// UIScale9SpriteTest // UIScale9SpriteTest
@ -1141,52 +1140,3 @@ bool UIS9EnableScale9FalseTest::init()
return false; return false;
} }
bool UIS9GrayStateOpacityTest::init()
{
if (UIScene::init()) {
auto winSize = Director::getInstance()->getWinSize();
float x = winSize.width / 2;
float y = 0 + (winSize.height / 2 + 10);
auto label = Label::createWithSystemFont("Drap slider to change opacity of the scale9Sprite", "Arial", 15);
label->setPosition(Vec2(winSize.width/2, winSize.height - 60));
this->addChild(label);
auto blocks = ui::Scale9Sprite::create("Images/blocks9.png");
blocks->setPosition(Vec2(x, y));
blocks->setPreferredSize(Size(96*2, 96*1.5));
blocks->setOpacity(100);
blocks->setState(Scale9Sprite::State::GRAY);
blocks->setGlobalZOrder(1);
blocks->setName("GrayScale9");
this->addChild(blocks);
Slider* slider = Slider::create();
slider->loadBarTexture("cocosui/sliderTrack.png");
slider->loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", "");
slider->loadProgressBarTexture("cocosui/sliderProgress.png");
slider->setContentSize(Size(300, slider->getContentSize().height * 1.5));
slider->setMaxPercent(100);
slider->setPercent(100 * 100.0 / 255.0);
slider->setPosition(Vec2(winSize.width / 2.0f, winSize.height / 2.0f - 100));
slider->addEventListener(CC_CALLBACK_2(UIS9GrayStateOpacityTest::sliderEvent, this));
_uiLayer->addChild(slider);
return true;
}
return false;
}
void UIS9GrayStateOpacityTest::sliderEvent(cocos2d::Ref *sender, cocos2d::ui::Slider::EventType type)
{
if (type == Slider::EventType::ON_PERCENTAGE_CHANGED)
{
Slider* slider = dynamic_cast<Slider*>(sender);
int percent = slider->getPercent();
int maxPercent = slider->getMaxPercent();
auto scale9Sprite = (Scale9Sprite*)this->getChildByName("GrayScale9");
scale9Sprite->setOpacity(1.0 * percent / maxPercent * 255.0);
}
}

View File

@ -311,13 +311,4 @@ public:
virtual bool init() override; virtual bool init() override;
}; };
class UIS9GrayStateOpacityTest: public UIScene
{
public:
CREATE_FUNC(UIS9GrayStateOpacityTest);
void sliderEvent(cocos2d::Ref* sender, cocos2d::ui::Slider::EventType type);
virtual bool init() override;
};
#endif /* defined(__cocos2d_tests__UIScale9SpriteTest__) */ #endif /* defined(__cocos2d_tests__UIScale9SpriteTest__) */