2018-01-29 16:25:32 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2018-01-29 16:25:32 +08:00
|
|
|
http://www.cocos2d-x.org
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2018-01-29 16:25:32 +08:00
|
|
|
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:
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2018-01-29 16:25:32 +08:00
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2018-01-29 16:25:32 +08:00
|
|
|
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.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2010-11-18 14:50:28 +08:00
|
|
|
#include "LayerTest.h"
|
|
|
|
#include "../testResource.h"
|
2021-12-31 14:39:08 +08:00
|
|
|
#include "../core/ui/UIText.h"
|
2010-11-18 14:50:28 +08:00
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
USING_NS_CC;
|
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
enum
|
2010-08-31 17:03:58 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
kTagLayer = 1,
|
2010-08-31 17:03:58 +08:00
|
|
|
};
|
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
LayerTests::LayerTests()
|
|
|
|
{
|
|
|
|
ADD_TEST_CASE(LayerTestCascadingOpacityA);
|
|
|
|
ADD_TEST_CASE(LayerTestCascadingOpacityB);
|
|
|
|
ADD_TEST_CASE(LayerTestCascadingOpacityC);
|
|
|
|
ADD_TEST_CASE(LayerTestCascadingColorA);
|
|
|
|
ADD_TEST_CASE(LayerTestCascadingColorB);
|
|
|
|
ADD_TEST_CASE(LayerTestCascadingColorC);
|
|
|
|
ADD_TEST_CASE(LayerTest1);
|
|
|
|
ADD_TEST_CASE(LayerTest2);
|
|
|
|
ADD_TEST_CASE(LayerTestBlend);
|
|
|
|
ADD_TEST_CASE(LayerGradientTest);
|
|
|
|
ADD_TEST_CASE(LayerGradientTest2);
|
|
|
|
ADD_TEST_CASE(LayerIgnoreAnchorPointPos);
|
|
|
|
ADD_TEST_CASE(LayerIgnoreAnchorPointRot);
|
|
|
|
ADD_TEST_CASE(LayerIgnoreAnchorPointScale);
|
|
|
|
ADD_TEST_CASE(LayerExtendedBlendOpacityTest);
|
|
|
|
ADD_TEST_CASE(LayerBug3162A);
|
|
|
|
ADD_TEST_CASE(LayerBug3162B);
|
2019-05-22 10:00:05 +08:00
|
|
|
ADD_TEST_CASE(LayerColorOccludeBug);
|
|
|
|
ADD_TEST_CASE(LayerRadialGradientTest);
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
2014-03-26 14:54:50 +08:00
|
|
|
// Cascading support extensions
|
2013-02-28 16:03:55 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
static void setEnableRecursiveCascading(Node* node, bool enable)
|
2013-02-28 16:03:55 +08:00
|
|
|
{
|
2013-12-06 18:07:16 +08:00
|
|
|
node->setCascadeColorEnabled(enable);
|
|
|
|
node->setCascadeOpacityEnabled(enable);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2013-12-17 17:45:29 +08:00
|
|
|
auto& children = node->getChildren();
|
2021-12-28 16:06:23 +08:00
|
|
|
for (const auto& child : children)
|
|
|
|
{
|
2013-02-28 16:45:59 +08:00
|
|
|
setEnableRecursiveCascading(child, enable);
|
2013-12-20 05:34:41 +08:00
|
|
|
}
|
2013-02-28 16:03:55 +08:00
|
|
|
}
|
|
|
|
|
2015-04-22 10:20:21 +08:00
|
|
|
std::string LayerTest::title() const
|
|
|
|
{
|
|
|
|
return "Layer Test";
|
|
|
|
}
|
|
|
|
|
2013-02-28 16:45:59 +08:00
|
|
|
// LayerTestCascadingOpacityA
|
|
|
|
void LayerTestCascadingOpacityA::onEnter()
|
2013-02-28 16:03:55 +08:00
|
|
|
{
|
2013-02-28 16:45:59 +08:00
|
|
|
LayerTest::onEnter();
|
2021-12-28 16:06:23 +08:00
|
|
|
|
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2013-12-06 18:07:16 +08:00
|
|
|
auto layer1 = Layer::create();
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto sister1 = Sprite::create("Images/grossinis_sister1.png");
|
|
|
|
auto sister2 = Sprite::create("Images/grossinis_sister2.png");
|
2021-12-28 16:06:23 +08:00
|
|
|
auto label = Label::createWithBMFont("fonts/bitmapFontTest.fnt", "Test");
|
|
|
|
|
2013-02-28 16:45:59 +08:00
|
|
|
layer1->addChild(sister1);
|
|
|
|
layer1->addChild(sister2);
|
|
|
|
layer1->addChild(label);
|
2021-12-28 16:06:23 +08:00
|
|
|
this->addChild(layer1, 0, kTagLayer);
|
|
|
|
|
|
|
|
sister1->setPosition(Vec2(s.width * 1 / 3, s.height / 2));
|
|
|
|
sister2->setPosition(Vec2(s.width * 2 / 3, s.height / 2));
|
|
|
|
label->setPosition(Vec2(s.width / 2, s.height / 2));
|
|
|
|
|
|
|
|
layer1->runAction(RepeatForever::create(
|
|
|
|
Sequence::create(FadeTo::create(4, 0), FadeTo::create(4, 255), DelayTime::create(1), nullptr)));
|
2013-11-14 09:36:33 +08:00
|
|
|
|
2013-02-28 16:45:59 +08:00
|
|
|
sister1->runAction(
|
2021-12-28 16:06:23 +08:00
|
|
|
RepeatForever::create(Sequence::create(FadeTo::create(2, 0), FadeTo::create(2, 255), FadeTo::create(2, 0),
|
|
|
|
FadeTo::create(2, 255), DelayTime::create(1), nullptr)));
|
|
|
|
|
2013-02-28 16:45:59 +08:00
|
|
|
// Enable cascading in scene
|
|
|
|
setEnableRecursiveCascading(this, true);
|
2013-02-28 16:03:55 +08:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:02:22 +08:00
|
|
|
std::string LayerTestCascadingOpacityA::subtitle() const
|
2013-02-28 16:03:55 +08:00
|
|
|
{
|
2013-12-06 18:07:16 +08:00
|
|
|
return "Layer: cascading opacity";
|
2013-02-28 16:03:55 +08:00
|
|
|
}
|
|
|
|
|
2013-02-28 16:45:59 +08:00
|
|
|
// LayerTestCascadingOpacityB
|
|
|
|
void LayerTestCascadingOpacityB::onEnter()
|
2013-02-28 16:03:55 +08:00
|
|
|
{
|
2013-02-28 16:45:59 +08:00
|
|
|
LayerTest::onEnter();
|
2021-12-28 16:06:23 +08:00
|
|
|
|
|
|
|
auto s = Director::getInstance()->getWinSize();
|
|
|
|
auto layer1 = LayerColor::create(Color4B(192, 0, 0, 255), s.width, s.height / 2);
|
2013-02-28 16:45:59 +08:00
|
|
|
layer1->setCascadeColorEnabled(false);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
|
|
|
layer1->setPosition(Vec2(0.0f, s.height / 2));
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto sister1 = Sprite::create("Images/grossinis_sister1.png");
|
|
|
|
auto sister2 = Sprite::create("Images/grossinis_sister2.png");
|
2021-12-28 16:06:23 +08:00
|
|
|
auto label = Label::createWithBMFont("fonts/bitmapFontTest.fnt", "Test");
|
|
|
|
|
2013-02-28 16:45:59 +08:00
|
|
|
layer1->addChild(sister1);
|
|
|
|
layer1->addChild(sister2);
|
|
|
|
layer1->addChild(label);
|
2021-12-28 16:06:23 +08:00
|
|
|
this->addChild(layer1, 0, kTagLayer);
|
|
|
|
|
|
|
|
sister1->setPosition(Vec2(s.width * 1 / 3, 0.0f));
|
|
|
|
sister2->setPosition(Vec2(s.width * 2 / 3, 0.0f));
|
|
|
|
label->setPosition(Vec2(s.width / 2, 0.0f));
|
|
|
|
|
|
|
|
layer1->runAction(RepeatForever::create(
|
|
|
|
Sequence::create(FadeTo::create(4, 0), FadeTo::create(4, 255), DelayTime::create(1), nullptr)));
|
|
|
|
|
2013-02-28 16:45:59 +08:00
|
|
|
sister1->runAction(
|
2021-12-28 16:06:23 +08:00
|
|
|
RepeatForever::create(Sequence::create(FadeTo::create(2, 0), FadeTo::create(2, 255), FadeTo::create(2, 0),
|
|
|
|
FadeTo::create(2, 255), DelayTime::create(1), nullptr)));
|
|
|
|
|
2013-02-28 16:45:59 +08:00
|
|
|
// Enable cascading in scene
|
|
|
|
setEnableRecursiveCascading(this, true);
|
2013-02-28 16:03:55 +08:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:02:22 +08:00
|
|
|
std::string LayerTestCascadingOpacityB::subtitle() const
|
2013-02-28 16:03:55 +08:00
|
|
|
{
|
2013-02-28 16:45:59 +08:00
|
|
|
return "CCLayerColor: cascading opacity";
|
2013-02-28 16:03:55 +08:00
|
|
|
}
|
|
|
|
|
2013-02-28 16:45:59 +08:00
|
|
|
// LayerTestCascadingOpacityC
|
|
|
|
void LayerTestCascadingOpacityC::onEnter()
|
2013-02-28 16:03:55 +08:00
|
|
|
{
|
2013-02-28 16:45:59 +08:00
|
|
|
LayerTest::onEnter();
|
2021-12-28 16:06:23 +08:00
|
|
|
|
|
|
|
auto s = Director::getInstance()->getWinSize();
|
|
|
|
auto layer1 = LayerColor::create(Color4B(192, 0, 0, 255), s.width, s.height / 2);
|
2013-02-28 16:45:59 +08:00
|
|
|
layer1->setCascadeColorEnabled(false);
|
|
|
|
layer1->setCascadeOpacityEnabled(false);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
|
|
|
layer1->setPosition(Vec2(0.0f, s.height / 2));
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto sister1 = Sprite::create("Images/grossinis_sister1.png");
|
|
|
|
auto sister2 = Sprite::create("Images/grossinis_sister2.png");
|
2021-12-28 16:06:23 +08:00
|
|
|
auto label = Label::createWithBMFont("fonts/bitmapFontTest.fnt", "Test");
|
|
|
|
|
2013-02-28 16:45:59 +08:00
|
|
|
layer1->addChild(sister1);
|
|
|
|
layer1->addChild(sister2);
|
|
|
|
layer1->addChild(label);
|
2021-12-28 16:06:23 +08:00
|
|
|
this->addChild(layer1, 0, kTagLayer);
|
|
|
|
|
|
|
|
sister1->setPosition(Vec2(s.width * 1 / 3, 0.0f));
|
|
|
|
sister2->setPosition(Vec2(s.width * 2 / 3, 0.0f));
|
|
|
|
label->setPosition(Vec2(s.width / 2, 0.0f));
|
|
|
|
|
|
|
|
layer1->runAction(RepeatForever::create(
|
|
|
|
Sequence::create(FadeTo::create(4, 0), FadeTo::create(4, 255), DelayTime::create(1), nullptr)));
|
|
|
|
|
2013-02-28 16:45:59 +08:00
|
|
|
sister1->runAction(
|
2021-12-28 16:06:23 +08:00
|
|
|
RepeatForever::create(Sequence::create(FadeTo::create(2, 0), FadeTo::create(2, 255), FadeTo::create(2, 0),
|
|
|
|
FadeTo::create(2, 255), DelayTime::create(1), nullptr)));
|
2013-02-28 16:03:55 +08:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:02:22 +08:00
|
|
|
std::string LayerTestCascadingOpacityC::subtitle() const
|
2013-02-28 16:03:55 +08:00
|
|
|
{
|
2013-02-28 16:45:59 +08:00
|
|
|
return "CCLayerColor: non-cascading opacity";
|
2013-02-28 16:03:55 +08:00
|
|
|
}
|
|
|
|
|
2014-03-26 14:54:50 +08:00
|
|
|
//// Example LayerTestCascadingColor
|
2013-02-28 16:45:59 +08:00
|
|
|
|
|
|
|
// LayerTestCascadingColorA
|
|
|
|
void LayerTestCascadingColorA::onEnter()
|
2013-02-28 16:03:55 +08:00
|
|
|
{
|
2013-02-28 16:45:59 +08:00
|
|
|
LayerTest::onEnter();
|
2021-12-28 16:06:23 +08:00
|
|
|
|
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2013-12-06 18:07:16 +08:00
|
|
|
auto layer1 = Layer::create();
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto sister1 = Sprite::create("Images/grossinis_sister1.png");
|
|
|
|
auto sister2 = Sprite::create("Images/grossinis_sister2.png");
|
2021-12-28 16:06:23 +08:00
|
|
|
auto label = Label::createWithBMFont("fonts/bitmapFontTest.fnt", "Test");
|
|
|
|
|
2013-02-28 16:45:59 +08:00
|
|
|
layer1->addChild(sister1);
|
|
|
|
layer1->addChild(sister2);
|
|
|
|
layer1->addChild(label);
|
2021-12-28 16:06:23 +08:00
|
|
|
this->addChild(layer1, 0, kTagLayer);
|
|
|
|
|
|
|
|
sister1->setPosition(Vec2(s.width * 1 / 3, s.height / 2));
|
|
|
|
sister2->setPosition(Vec2(s.width * 2 / 3, s.height / 2));
|
|
|
|
label->setPosition(Vec2(s.width / 2, s.height / 2));
|
|
|
|
|
|
|
|
layer1->runAction(RepeatForever::create(Sequence::create(
|
|
|
|
TintTo::create(6, 255, 0, 255), TintTo::create(6, 255, 255, 255), DelayTime::create(1), nullptr)));
|
|
|
|
|
|
|
|
sister1->runAction(RepeatForever::create(Sequence::create(
|
|
|
|
TintTo::create(2, 255, 255, 0), TintTo::create(2, 255, 255, 255), TintTo::create(2, 0, 255, 255),
|
|
|
|
TintTo::create(2, 255, 255, 255), TintTo::create(2, 255, 0, 255), TintTo::create(2, 255, 255, 255),
|
|
|
|
DelayTime::create(1), nullptr)));
|
|
|
|
|
2013-02-28 16:45:59 +08:00
|
|
|
// Enable cascading in scene
|
|
|
|
setEnableRecursiveCascading(this, true);
|
2013-02-28 16:03:55 +08:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:02:22 +08:00
|
|
|
std::string LayerTestCascadingColorA::subtitle() const
|
2013-02-28 16:03:55 +08:00
|
|
|
{
|
2013-12-06 18:07:16 +08:00
|
|
|
return "Layer: cascading color";
|
2013-02-28 16:03:55 +08:00
|
|
|
}
|
|
|
|
|
2013-02-28 16:45:59 +08:00
|
|
|
// LayerTestCascadingColorB
|
|
|
|
void LayerTestCascadingColorB::onEnter()
|
2013-02-28 16:03:55 +08:00
|
|
|
{
|
2013-02-28 16:45:59 +08:00
|
|
|
LayerTest::onEnter();
|
2021-12-28 16:06:23 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
|
|
|
auto layer1 = LayerColor::create(Color4B(255, 255, 255, 255), s.width, s.height / 2);
|
|
|
|
|
|
|
|
layer1->setPosition(Vec2(0.0f, s.height / 2));
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto sister1 = Sprite::create("Images/grossinis_sister1.png");
|
|
|
|
auto sister2 = Sprite::create("Images/grossinis_sister2.png");
|
2021-12-28 16:06:23 +08:00
|
|
|
auto label = Label::createWithBMFont("fonts/bitmapFontTest.fnt", "Test");
|
|
|
|
|
2013-02-28 16:45:59 +08:00
|
|
|
layer1->addChild(sister1);
|
|
|
|
layer1->addChild(sister2);
|
|
|
|
layer1->addChild(label);
|
2021-12-28 16:06:23 +08:00
|
|
|
this->addChild(layer1, 0, kTagLayer);
|
|
|
|
|
|
|
|
sister1->setPosition(Vec2(s.width * 1 / 3, 0.0f));
|
|
|
|
sister2->setPosition(Vec2(s.width * 2 / 3, 0.0f));
|
|
|
|
label->setPosition(Vec2(s.width / 2, 0.0f));
|
|
|
|
|
|
|
|
layer1->runAction(RepeatForever::create(Sequence::create(
|
|
|
|
TintTo::create(6, 255, 0, 255), TintTo::create(6, 255, 255, 255), DelayTime::create(1), nullptr)));
|
|
|
|
|
|
|
|
sister1->runAction(RepeatForever::create(Sequence::create(
|
|
|
|
TintTo::create(2, 255, 255, 0), TintTo::create(2, 255, 255, 255), TintTo::create(2, 0, 255, 255),
|
|
|
|
TintTo::create(2, 255, 255, 255), TintTo::create(2, 255, 0, 255), TintTo::create(2, 255, 255, 255),
|
|
|
|
DelayTime::create(1), nullptr)));
|
|
|
|
|
2013-02-28 16:45:59 +08:00
|
|
|
// Enable cascading in scene
|
|
|
|
setEnableRecursiveCascading(this, true);
|
2013-02-28 16:03:55 +08:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:02:22 +08:00
|
|
|
std::string LayerTestCascadingColorB::subtitle() const
|
2013-02-28 16:03:55 +08:00
|
|
|
{
|
2013-02-28 16:45:59 +08:00
|
|
|
return "CCLayerColor: cascading color";
|
2013-02-28 16:03:55 +08:00
|
|
|
}
|
|
|
|
|
2013-02-28 16:45:59 +08:00
|
|
|
// LayerTestCascadingColorC
|
|
|
|
void LayerTestCascadingColorC::onEnter()
|
2013-02-28 16:03:55 +08:00
|
|
|
{
|
2013-02-28 16:45:59 +08:00
|
|
|
LayerTest::onEnter();
|
2021-12-28 16:06:23 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
|
|
|
auto layer1 = LayerColor::create(Color4B(255, 255, 255, 255), s.width, s.height / 2);
|
2013-02-28 16:45:59 +08:00
|
|
|
layer1->setCascadeColorEnabled(false);
|
2021-12-28 16:06:23 +08:00
|
|
|
layer1->setPosition(Vec2(0.0f, s.height / 2));
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto sister1 = Sprite::create("Images/grossinis_sister1.png");
|
|
|
|
auto sister2 = Sprite::create("Images/grossinis_sister2.png");
|
2021-12-28 16:06:23 +08:00
|
|
|
auto label = Label::createWithBMFont("fonts/bitmapFontTest.fnt", "Test");
|
|
|
|
|
2013-02-28 16:45:59 +08:00
|
|
|
layer1->addChild(sister1);
|
|
|
|
layer1->addChild(sister2);
|
|
|
|
layer1->addChild(label);
|
2021-12-28 16:06:23 +08:00
|
|
|
this->addChild(layer1, 0, kTagLayer);
|
|
|
|
|
|
|
|
sister1->setPosition(Vec2(s.width * 1 / 3, 0.0f));
|
|
|
|
sister2->setPosition(Vec2(s.width * 2 / 3, 0.0f));
|
|
|
|
label->setPosition(Vec2(s.width / 2, 0.0f));
|
|
|
|
|
|
|
|
layer1->runAction(RepeatForever::create(Sequence::create(
|
|
|
|
TintTo::create(6, 255, 0, 255), TintTo::create(6, 255, 255, 255), DelayTime::create(1), nullptr)));
|
|
|
|
|
|
|
|
sister1->runAction(RepeatForever::create(Sequence::create(
|
|
|
|
TintTo::create(2, 255, 255, 0), TintTo::create(2, 255, 255, 255), TintTo::create(2, 0, 255, 255),
|
|
|
|
TintTo::create(2, 255, 255, 255), TintTo::create(2, 255, 0, 255), TintTo::create(2, 255, 255, 255),
|
|
|
|
DelayTime::create(1), nullptr)));
|
2013-02-28 16:03:55 +08:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:02:22 +08:00
|
|
|
std::string LayerTestCascadingColorC::subtitle() const
|
2013-02-28 16:03:55 +08:00
|
|
|
{
|
2013-02-28 16:45:59 +08:00
|
|
|
return "CCLayerColor: non-cascading color";
|
2013-02-28 16:03:55 +08:00
|
|
|
}
|
|
|
|
|
2010-08-31 17:03:58 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// LayerTest1
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void LayerTest1::onEnter()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
LayerTest::onEnter();
|
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
auto listener = EventListenerTouchAllAtOnce::create();
|
2013-10-23 16:14:03 +08:00
|
|
|
listener->onTouchesBegan = CC_CALLBACK_2(LayerTest1::onTouchesBegan, this);
|
|
|
|
listener->onTouchesMoved = CC_CALLBACK_2(LayerTest1::onTouchesMoved, this);
|
|
|
|
listener->onTouchesEnded = CC_CALLBACK_2(LayerTest1::onTouchesEnded, this);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2013-10-26 15:04:01 +08:00
|
|
|
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
|
|
|
auto s = Director::getInstance()->getWinSize();
|
|
|
|
auto layer = LayerColor::create(Color4B(0xFF, 0x00, 0x00, 0x80), 200, 200);
|
|
|
|
|
2016-04-25 19:43:42 +08:00
|
|
|
layer->setIgnoreAnchorPointForPosition(false);
|
2021-12-28 16:06:23 +08:00
|
|
|
layer->setPosition(Vec2(s.width / 2, s.height / 2));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(layer, 1, kTagLayer);
|
2010-08-31 17:03:58 +08:00
|
|
|
}
|
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
void LayerTest1::updateSize(Vec2& touchLocation)
|
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
auto newSize = Size(fabs(touchLocation.x - s.width / 2) * 2, fabs(touchLocation.y - s.height / 2) * 2);
|
|
|
|
|
|
|
|
auto l = (LayerColor*)getChildByTag(kTagLayer);
|
|
|
|
|
|
|
|
l->setContentSize(newSize);
|
2010-08-31 17:03:58 +08:00
|
|
|
}
|
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
void LayerTest1::onTouchesBegan(const std::vector<Touch*>& touches, Event* event)
|
2010-08-31 17:03:58 +08:00
|
|
|
{
|
2013-09-03 18:22:03 +08:00
|
|
|
onTouchesMoved(touches, event);
|
2010-08-31 17:03:58 +08:00
|
|
|
}
|
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
void LayerTest1::onTouchesMoved(const std::vector<Touch*>& touches, Event* event)
|
2010-08-31 17:03:58 +08:00
|
|
|
{
|
2013-09-03 18:22:03 +08:00
|
|
|
auto touchLocation = touches[0]->getLocation();
|
2012-03-22 13:59:47 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
updateSize(touchLocation);
|
2010-08-31 17:03:58 +08:00
|
|
|
}
|
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
void LayerTest1::onTouchesEnded(const std::vector<Touch*>& touches, Event* event)
|
2010-08-31 17:03:58 +08:00
|
|
|
{
|
2013-09-03 18:22:03 +08:00
|
|
|
onTouchesMoved(touches, event);
|
2010-08-31 17:03:58 +08:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:02:22 +08:00
|
|
|
std::string LayerTest1::subtitle() const
|
2010-08-31 17:03:58 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "ColorLayer resize (tap & move)";
|
2010-08-31 17:03:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// LayerTest2
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void LayerTest2::onEnter()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
LayerTest::onEnter();
|
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
|
|
|
auto layer1 = LayerColor::create(Color4B(255, 255, 0, 80), 100, 300);
|
|
|
|
layer1->setPosition(Vec2(s.width / 3, s.height / 2));
|
2016-04-25 19:43:42 +08:00
|
|
|
layer1->setIgnoreAnchorPointForPosition(false);
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(layer1, 1);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
|
|
|
auto layer2 = LayerColor::create(Color4B(0, 0, 255, 255), 100, 300);
|
|
|
|
layer2->setPosition(Vec2((s.width / 3) * 2, s.height / 2));
|
2016-04-25 19:43:42 +08:00
|
|
|
layer2->setIgnoreAnchorPointForPosition(false);
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(layer2, 1);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
|
|
|
auto actionTint = TintBy::create(2, -255, -127, 0);
|
2013-08-16 16:05:27 +08:00
|
|
|
auto actionTintBack = actionTint->reverse();
|
2021-12-28 16:06:23 +08:00
|
|
|
auto seq1 = Sequence::create(actionTint, actionTintBack, nullptr);
|
2012-04-19 14:35:52 +08:00
|
|
|
layer1->runAction(seq1);
|
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
auto actionFade = FadeOut::create(2.0f);
|
2013-08-16 16:05:27 +08:00
|
|
|
auto actionFadeBack = actionFade->reverse();
|
2021-12-28 16:06:23 +08:00
|
|
|
auto seq2 = Sequence::create(actionFade, actionFadeBack, nullptr);
|
2012-04-19 14:35:52 +08:00
|
|
|
layer2->runAction(seq2);
|
2010-08-31 17:03:58 +08:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:02:22 +08:00
|
|
|
std::string LayerTest2::subtitle() const
|
2010-08-31 17:03:58 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "ColorLayer: fade and tint";
|
2010-08-31 17:03:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// LayerTestBlend
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
|
2010-11-18 14:50:28 +08:00
|
|
|
LayerTestBlend::LayerTestBlend()
|
|
|
|
{
|
2021-12-28 16:06:23 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
|
|
|
auto layer1 = LayerColor::create(Color4B(255, 255, 255, 80));
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto sister1 = Sprite::create(s_pathSister1);
|
|
|
|
auto sister2 = Sprite::create(s_pathSister2);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(sister1);
|
|
|
|
addChild(sister2);
|
|
|
|
addChild(layer1, 100, kTagLayer);
|
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
sister1->setPosition(Vec2(s.width * 1 / 3, s.height / 2));
|
|
|
|
sister2->setPosition(Vec2(s.width * 2 / 3, s.height / 2));
|
|
|
|
|
|
|
|
schedule(CC_SCHEDULE_SELECTOR(LayerTestBlend::newBlend), 1.0f);
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
2012-06-08 13:55:28 +08:00
|
|
|
void LayerTestBlend::newBlend(float dt)
|
2010-11-18 14:50:28 +08:00
|
|
|
{
|
2021-12-28 16:06:23 +08:00
|
|
|
auto layer = (LayerColor*)getChildByTag(kTagLayer);
|
2010-11-18 14:50:28 +08:00
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
backend::BlendFactor src;
|
|
|
|
backend::BlendFactor dst;
|
2010-11-18 14:50:28 +08:00
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
if (layer->getBlendFunc().dst == backend::BlendFactor::ZERO)
|
2010-11-18 14:50:28 +08:00
|
|
|
{
|
metal support for cocos2d-x (#19305)
* remove deprecated files
* remove some deprecated codes
* remove more deprecated codes
* remove ui deprecated codes
* remove more deprecated codes
* remove deprecated codes in ccmenuitem
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes
* remove more deprecated codes
* remove more deprecated codes
* remove vr related codes and ignore some modules
* remove allocator
* remove some config
* 【Feature】add back-end project file
* [Feature] add back-end file
* add pipeline descriptor and shader cache
* [Feature] support sprite for backend
* [Feature] remove unneeded code
* [Feature] according to es2.0 spec, you must use clamp-to-edge as texture wrap mode, and no mipmapping for non-power-of-two texture
* [Feature] set texture wrap mode to clamp-to-edge, and no mipmapping for non-power-of-two texture
* [Feature] remove macro define to .cpp file
* [Feature] add log info
* [Feature] add PipelineDescriptor for TriangleCommand
* [Feature] add PipelineDescriptor object as member of TriangleCommand
* [Feature] add getPipelineDescriptor method
* add renderbackend
* complete pipeline descriptor
* [Feature] add viewport in RenderCommand
* set viewport when rendrering
* [Feature] occur error when using RendererBackend, to be fixed.
* a workaround to fix black screen on macOS 10.14 (#19090)
* add rendererbackend init function
* fix typo
* [Feature] modify testFile
* [BugFix] modify shader path
* [Feature] set default viewport
* fix projection
* [Feature] modify log info
* [BugFix] change viewport data type to int
* [BugFix] add BindGroup to PipelienDescriptor
* [BugFix] change a_position to vec3 in sprite.vert
* [BugFix] set vertexLayout according to V3F_C4B_T2F structure
* [Feature] revert a_position to vec4
* [Feature] renderer should not use gl codes directly
* [Feature] it's better not use default value parameter
* fix depth test setting
* rendererbackend -> renderer
* clear color and depth at begin
* add metal backend
* metal support normalized attribute
* simplify codes
* update external
* add render pass desctriptor in pipeline descriptor
* fix warnings
* fix crash and memeory leak
* refactor Texture2D
* put pipeline descriptor into render command
* simplify codes
* [Feature] update Sprite
* fix crash when closing app
* [Feature] update SpriteBatchNode and TextureAtlas
* support render texture(not finish)
* [Feature] remove unused code
* make tests work on mac
* fix download-deps path error
* make tests work on iOS
* [Feature] support ttf under normal label effect
* refactor triangle command processing
* let renderer handle more common commands
* refactor backend
* make render texture work
* [Feature] refactor backend for GL
* [Feature]Renaming to make it easy to understand
* [Feature] change warp mode to CLAMP_TO_EDGE
* fix ghost
* simplify visit render queue logic
* support progress timer without rial mode
* support partcile system
* Feature/update label (#149)
* [BugFix] fix compile error
* [Feature] support outline effect in ios
* [Feature] add shader file
* [BugFix] fix begin and end RenderPass
* [Feature] update CustomCommand
* [Feature] revert project.pbxproj
* [Feature] simplify codes
* [BugFix] pack AI88 to RGBA8888 only when outline enable
* [Feature] support shadow effect in Label
* [Feature] support BMFont
* [Feature] support glow effect
* [Feature] simplify shader files
* LabelAtlas work
* handle blend function correctly
* support tile map
* don't share buffer in metal
* alloc buffer size as needed
* support more tilemap
* Merge branch 'minggo/metal-support' into feature/updateLabel
* minggo/metal-support:
support tile map
handle blend function correctly
LabelAtlas work
Feature/update label (#149)
support partcile system
# Conflicts:
# cocos/2d/CCLabel.cpp
# cocos/2d/CCSprite.cpp
# cocos/2d/CCSpriteBatchNode.cpp
# cocos/renderer/CCQuadCommand.cpp
# cocos/renderer/CCQuadCommand.h
* render texture work without saving file
* use global viewport
* grid3d works
* remove grabber
* tiled3d works
* [BugFix] fix label bug
* [Feature] add updateSubData for buffer
* [Feature] remove setVertexCount
* support depth test
* add callback command
* [Feature] add UITest
* [Feature] update UITest
* [Feature] remove unneeded codes
* fix custom command issue
* fix layer color blend issue
* [BugFix] fix iOS compile error
* [Feature] remove unneeded codes
* [Feature] fix updateVertexBuffer
* layerradial works
* add draw test back
* fix batch issue
* fix compiling error
* [BugFix] support ETC1
* [BugFix] get the correct pipelineDescriptor
* [BugFix] skip draw when backendTexture nullptr
* clipping node support
* [Feature] add shader files
* fix stencil issue in metal
* [Feature] update UILayoutTest
* [BugFix] skip drawing when vertexCount is zero
* refactor renderer
* add set global z order for stencil manager commands
* fix warnings caused by type
* remove viewport in render command
* [Feature] fix warnings caused by type
* [BugFix] clear vertexCount and indexCount for CustomComand when needed
* [Feature] update clear for CustomCommand
* ios use metal
* fix viewport issue
* fix LayerColorGradient crash
* [cmake] transport to android and windows (#160)
* save point 1
* compile on windows
* run on android
* revert useless change
* android set CC_ENABLE_CACHE_TEXTURE_DATA to 1
* add initGlew
* fix android crash
* add TODO new-renderer
* review update
* revert onGLFWWindowPosCallback
* fix android compiling error
* Impl progress radial (#162)
* progresstimer add radial impl
* default drawType to element
* dec invoke times of createVertexBuffer (#163)
* support depth/stencil format for gl backend
* simplify progress timer codes
* support motionstreak, effect is wrong
* fix motionstreak issue
* [Feature] update Scissor Test (#161)
* [Feature] update Scissor Test
* [Feature] update ScissorTest
* [Feature] rename function
* [Feature] get constant reference if needed
* [Feature] show render status (#164)
* improve performance
* fix depth state
* fill error that triangle vertex/index number bigger than buffer
* fix compiline error in release mode
* fix buffer conflict between CPU and GPU on iOS/macOS
* Renderer refactor (#165)
* use one vertes/index buffer with opengl
* fix error on windows
* custom command support index format config
* CCLayer: compact vertex data structure
* update comment
* fix doc
* support fast tilemap
* pass index format instead
* fix some wrong effect
* fix render texture error
* fix texture per-element size
* fix texture format error
* BlendFunc type refactor, GLenum -> backend::BlendFactor (#167)
* BlendFunc use backend::BlendFactor as inner field
* update comments
* use int to replace GLenum
* update xcode project fiel
* rename to GLBlendConst
* add ccConstants.h
* update xcode project file
* update copyright
* remove primitive command
* remove CCPrimitive.cpp/.h
* remove deprecated files
* remove unneeded files
* remove multiple view support
* remove multiple view support
* remove the usage of frame buffer in camera
* director don't use frame buffer
* remove FrameBuffer
* remove BatchCommand
* add some api reference
* add physics2d back
* fix crash when close app on mac
* improve render texture
* fix rendertexture issue
* fix rendertexture issue
* simplify codes
* CMake support for mac & ios (#169)
* update cmake
* fix compile error
* update 3rd libs version
* remove CCThread.h/.cpp
* remove ccthread
* use audio engine to implement simple audio engine
* remove unneeded codes
* remove deprecated codes
* remove winrt macro
* remove CC_USE_WIC
* set partcile blend function in more elegant way
* remove unneeded codes
* remove unneeded codes
* cmake works on windows
* update project setting
* improve performance
* GLFloat -> float
* sync v3 cmake improvements into metal-support (#172)
* pick: modern cmake, compile definitions improvement (#19139)
* modern cmake, use target_compile_definitions partly
* simplify macro define, remove USE_*
* modern cmake, macro define
* add physics 2d macro define into ccConfig.h
* remove USE_CHIPMUNK macro in build.gradle
* remove CocosSelectModule.cmake
* shrink useless define
* simplify compile options config, re-add if necessary
* update external for tmp CI test
* un-quote target_compile_options value
* add "-g" parameter only when debug mode
* keep single build type when generator Xcode & VS projecy
* update external for tmp CI tes
* add static_cast<char>(-1), fix -Wc++11-narrowing
* simplify win32 compile define
* not modify code, only improve compile options
# Conflicts:
# .gitignore
# cmake/Modules/CocosConfigDepend.cmake
# cocos/CMakeLists.txt
# external/config.json
# tests/cpp-tests/CMakeLists.txt
* modern cmake, improve cmake_compiler_flags (#19145)
* cmake_compiler_flags
* Fix typo
* Fix typo2
* Remove chanages from Android.mk
* correct lua template cmake build (#19149)
* don't add -Wno-deprecated into jsb target
* correct lua template cmake build
* fix win32 lua template compile error
* prevent cmake in-source-build friendly (#19151)
* pick: Copy resources to "Resources/" on win32 like in linux configuration
* add "/Z7" for cpp-tests on windows
* [cmake] fix iOS xcode property setting failed (#19208)
* fix iOS xcode property setting failed
* use search_depend_libs_recursive at dlls collect
* fix typo
* [cmake] add find_host_library into iOS toolchain file (#19230)
* pick: [lua android] use luajit & template cmake update (#19239)
* increase cmake stability , remove tests/CMakeLists.txt (#19261)
* cmake win32 Precompiled header (#19273)
* Precompiled header
* Fix
* Precompiled header for cocos
* Precompiled header jscocos2d
* Fix for COCOS2D_DEBUG is always 1 on Android (#19291)
Related #19289
* little build fix, tests cpp-tests works on mac
* sync v3 build related codes into metal-support (#173)
* strict initialization for std::array
* remove proj.win32 project configs
* modern cmake, cmake_cleanup_remove_unused_variables (#19146)
* Switch travis CI to xenial (#19207)
* Switch travis CI to xenial
* Remove language: android
* Set language: cpp
* Fix java problem
* Update sdkmanager
* Fix sdkmanger
* next sdkmanager fix
* Remove xenial from android
* revert to sdk-tools-{system}-3859397
* Remove linux cmake install
* Update before-install.sh
* Update .travis.yml
* Simplify install-deps-linux.sh, tested on Ubuntu 16.04 (#19212)
* Simplify install-deps-linux.sh
* Cleanup
* pick: install ninja
* update cocos2d-console submodule
* for metal-support alpha release, we only test cpp
* add HelloCpp into project(Cocos2d-x) for tmp test
* update extenal metal-support-4
* update uniform setting
* [Feature] update BindGroup
* [Feature] empty-test
* [Feature] cpp-test
* [Feature] fix GL compiler error
* [Feature] fix GL crash
* [Feature] empty-test
* [Feature] cpp-tests
* [feature] improve frameRate
* [feature] fix opengl compile error
* [feature] fix opengl compile error
* [BugFix] fix compute maxLocation error
* [Feature] update setting unifrom
* [Feature] fix namespace
* [Feature] remove unneeded code
* [Bugfix] fix project file
* [Feature] update review
* [texture2d] impl texture format support (#175)
* texture update
* update
* update texture
* commit
* compile on windows
* ddd
* rename
* rename methods
* no crash
* save gl
* save
* save
* rename
* move out pixel format convert functions
* metal crash
* update
* update android
* support gles compressed texture format
* support more compress format
* add more conversion methods
* ss
* save
* update conversion methods
* add PVRTC format support
* reformat
* add marco linux
* fix GL marcro
* pvrtc supported only by ios 8.0+
* remove unused cmake
* revert change
* refactor Texture2D::initWithData
* fix conversion log
* refactor Texture2D::initWithData
* remove some OpenGL constants for PVRTC
* add todo
* fix typo
* AutoTest works on mac/iOS by disable part cases, sync v3 bug fix (#174)
* review cpp-tests, and fix part issues on start auto test
* sync png format fix: Node:Particle3D abnormal texture effects #19204
* fix cpp-tests SpritePolygon crash, wrong png format (#19170)
* fix wrong png convert format from sRGB to Gray
* erase plist index if all frames was erased
* test_A8.png have I8 format, fix it
* [CCSpriteCache] allow re-add plist & add testcase (#19175)
* allow re-add plist & add testcase
* remove comments/rename method/update testcase
* fix isSpriteFramesWithFileLoaded & add testcase
* remove used variable
* remove unused variable
* fix double free issues when js/lua-tests exit on iOS (#19236)
* disable part cases, AutoTest works without crash on mac
* update cocos2dx files json, to test cocos new next
* fix spritecache plist parsing issue (#19269)
* [linux] Fix FileUtils::getContents with folder (#19157)
* fix FileUtils::getContents on linux/mac
* use stat.st_mode
* simplify
* [CCFileUtils] win32 getFileSize (#19176)
* win32 getFileSize
* fix stat
* [cpp test-Android]20:FileUtils/2 change title (#19197)
* sync #19200
* sync #19231
* [android lua] improve performance of lua loader (#19234)
* [lua] improve performance of lua loader
* remove cache fix
* Revert "fix spritecache plist parsing issue (#19269)"
This reverts commit f3a85ece4307a7b90816c34489d1ed2c8fd11baf.
* remove win32 project files ref in template.json
* add metal framework lnk ref into cpp template
* test on iOS, and disable part cases
* alBufferData instead of alBufferDataStatic for small audio file on Apple (#19227)
* changes AudioCache to use alBufferData instead of alBufferDataStatic
(also makes test 19 faster to trigger openal bugs faster)
The original problem: CrashIfClientProvidedBogusAudioBufferList
https://github.com/cocos2d/cocos2d-x/issues/18948
is not happening anymore, but there's still a not very frequent issue
that makes OpenAL crash with a call stack like this.
AudioCache::readDataTask > alBufferData > CleanUpDeadBufferList
It happes more frequently when the device is "cold", which means after
half an hour of not using the device (locked).
I could not find the actual source code for iOS OpenAL, so I used the
macOS versions:
https://opensource.apple.com/source/OpenAL/OpenAL-48.7/Source/OpenAL/oalImp.cpp.auto.html
They seem to use CAGuard.h to make sure the dead buffer list
has no threading issues. I'm worried because the CAGuard code I found
has macos and win32 define but no iOS, so I'm not sure. I guess the
iOS version is different and has the guard.
I could not find a place in the code that's unprotected by the locks
except the InitializeBufferMap() which should not be called more than
once from cocos, and there's a workaround in AudioEngine-impl for it.
I reduced the occurence of the CleanUpDeadBufferList crash by moving
the guard in ~AudioCache to cover the alDeleteBuffers call.
* remove hack method "setTimeout" on audio
* AutoTest works on iOS
* support set ios deployment target for root project
* enable all texture2d cases, since Jiang have fixed
* add CCTextureUtils to xcode project file (#176)
* add leak cases for SpriteFrameCache (#177)
* re-add SpriteFrameCache cases
* update template file json
* Update SpriteFrameCacheTest.cpp
* fix compiling error
2019-01-18 15:08:25 +08:00
|
|
|
src = backend::BlendFactor::SRC_ALPHA;
|
|
|
|
dst = backend::BlendFactor::ONE_MINUS_SRC_ALPHA;
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
2012-04-19 14:35:52 +08:00
|
|
|
else
|
2010-11-18 14:50:28 +08:00
|
|
|
{
|
metal support for cocos2d-x (#19305)
* remove deprecated files
* remove some deprecated codes
* remove more deprecated codes
* remove ui deprecated codes
* remove more deprecated codes
* remove deprecated codes in ccmenuitem
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes
* remove more deprecated codes
* remove more deprecated codes
* remove vr related codes and ignore some modules
* remove allocator
* remove some config
* 【Feature】add back-end project file
* [Feature] add back-end file
* add pipeline descriptor and shader cache
* [Feature] support sprite for backend
* [Feature] remove unneeded code
* [Feature] according to es2.0 spec, you must use clamp-to-edge as texture wrap mode, and no mipmapping for non-power-of-two texture
* [Feature] set texture wrap mode to clamp-to-edge, and no mipmapping for non-power-of-two texture
* [Feature] remove macro define to .cpp file
* [Feature] add log info
* [Feature] add PipelineDescriptor for TriangleCommand
* [Feature] add PipelineDescriptor object as member of TriangleCommand
* [Feature] add getPipelineDescriptor method
* add renderbackend
* complete pipeline descriptor
* [Feature] add viewport in RenderCommand
* set viewport when rendrering
* [Feature] occur error when using RendererBackend, to be fixed.
* a workaround to fix black screen on macOS 10.14 (#19090)
* add rendererbackend init function
* fix typo
* [Feature] modify testFile
* [BugFix] modify shader path
* [Feature] set default viewport
* fix projection
* [Feature] modify log info
* [BugFix] change viewport data type to int
* [BugFix] add BindGroup to PipelienDescriptor
* [BugFix] change a_position to vec3 in sprite.vert
* [BugFix] set vertexLayout according to V3F_C4B_T2F structure
* [Feature] revert a_position to vec4
* [Feature] renderer should not use gl codes directly
* [Feature] it's better not use default value parameter
* fix depth test setting
* rendererbackend -> renderer
* clear color and depth at begin
* add metal backend
* metal support normalized attribute
* simplify codes
* update external
* add render pass desctriptor in pipeline descriptor
* fix warnings
* fix crash and memeory leak
* refactor Texture2D
* put pipeline descriptor into render command
* simplify codes
* [Feature] update Sprite
* fix crash when closing app
* [Feature] update SpriteBatchNode and TextureAtlas
* support render texture(not finish)
* [Feature] remove unused code
* make tests work on mac
* fix download-deps path error
* make tests work on iOS
* [Feature] support ttf under normal label effect
* refactor triangle command processing
* let renderer handle more common commands
* refactor backend
* make render texture work
* [Feature] refactor backend for GL
* [Feature]Renaming to make it easy to understand
* [Feature] change warp mode to CLAMP_TO_EDGE
* fix ghost
* simplify visit render queue logic
* support progress timer without rial mode
* support partcile system
* Feature/update label (#149)
* [BugFix] fix compile error
* [Feature] support outline effect in ios
* [Feature] add shader file
* [BugFix] fix begin and end RenderPass
* [Feature] update CustomCommand
* [Feature] revert project.pbxproj
* [Feature] simplify codes
* [BugFix] pack AI88 to RGBA8888 only when outline enable
* [Feature] support shadow effect in Label
* [Feature] support BMFont
* [Feature] support glow effect
* [Feature] simplify shader files
* LabelAtlas work
* handle blend function correctly
* support tile map
* don't share buffer in metal
* alloc buffer size as needed
* support more tilemap
* Merge branch 'minggo/metal-support' into feature/updateLabel
* minggo/metal-support:
support tile map
handle blend function correctly
LabelAtlas work
Feature/update label (#149)
support partcile system
# Conflicts:
# cocos/2d/CCLabel.cpp
# cocos/2d/CCSprite.cpp
# cocos/2d/CCSpriteBatchNode.cpp
# cocos/renderer/CCQuadCommand.cpp
# cocos/renderer/CCQuadCommand.h
* render texture work without saving file
* use global viewport
* grid3d works
* remove grabber
* tiled3d works
* [BugFix] fix label bug
* [Feature] add updateSubData for buffer
* [Feature] remove setVertexCount
* support depth test
* add callback command
* [Feature] add UITest
* [Feature] update UITest
* [Feature] remove unneeded codes
* fix custom command issue
* fix layer color blend issue
* [BugFix] fix iOS compile error
* [Feature] remove unneeded codes
* [Feature] fix updateVertexBuffer
* layerradial works
* add draw test back
* fix batch issue
* fix compiling error
* [BugFix] support ETC1
* [BugFix] get the correct pipelineDescriptor
* [BugFix] skip draw when backendTexture nullptr
* clipping node support
* [Feature] add shader files
* fix stencil issue in metal
* [Feature] update UILayoutTest
* [BugFix] skip drawing when vertexCount is zero
* refactor renderer
* add set global z order for stencil manager commands
* fix warnings caused by type
* remove viewport in render command
* [Feature] fix warnings caused by type
* [BugFix] clear vertexCount and indexCount for CustomComand when needed
* [Feature] update clear for CustomCommand
* ios use metal
* fix viewport issue
* fix LayerColorGradient crash
* [cmake] transport to android and windows (#160)
* save point 1
* compile on windows
* run on android
* revert useless change
* android set CC_ENABLE_CACHE_TEXTURE_DATA to 1
* add initGlew
* fix android crash
* add TODO new-renderer
* review update
* revert onGLFWWindowPosCallback
* fix android compiling error
* Impl progress radial (#162)
* progresstimer add radial impl
* default drawType to element
* dec invoke times of createVertexBuffer (#163)
* support depth/stencil format for gl backend
* simplify progress timer codes
* support motionstreak, effect is wrong
* fix motionstreak issue
* [Feature] update Scissor Test (#161)
* [Feature] update Scissor Test
* [Feature] update ScissorTest
* [Feature] rename function
* [Feature] get constant reference if needed
* [Feature] show render status (#164)
* improve performance
* fix depth state
* fill error that triangle vertex/index number bigger than buffer
* fix compiline error in release mode
* fix buffer conflict between CPU and GPU on iOS/macOS
* Renderer refactor (#165)
* use one vertes/index buffer with opengl
* fix error on windows
* custom command support index format config
* CCLayer: compact vertex data structure
* update comment
* fix doc
* support fast tilemap
* pass index format instead
* fix some wrong effect
* fix render texture error
* fix texture per-element size
* fix texture format error
* BlendFunc type refactor, GLenum -> backend::BlendFactor (#167)
* BlendFunc use backend::BlendFactor as inner field
* update comments
* use int to replace GLenum
* update xcode project fiel
* rename to GLBlendConst
* add ccConstants.h
* update xcode project file
* update copyright
* remove primitive command
* remove CCPrimitive.cpp/.h
* remove deprecated files
* remove unneeded files
* remove multiple view support
* remove multiple view support
* remove the usage of frame buffer in camera
* director don't use frame buffer
* remove FrameBuffer
* remove BatchCommand
* add some api reference
* add physics2d back
* fix crash when close app on mac
* improve render texture
* fix rendertexture issue
* fix rendertexture issue
* simplify codes
* CMake support for mac & ios (#169)
* update cmake
* fix compile error
* update 3rd libs version
* remove CCThread.h/.cpp
* remove ccthread
* use audio engine to implement simple audio engine
* remove unneeded codes
* remove deprecated codes
* remove winrt macro
* remove CC_USE_WIC
* set partcile blend function in more elegant way
* remove unneeded codes
* remove unneeded codes
* cmake works on windows
* update project setting
* improve performance
* GLFloat -> float
* sync v3 cmake improvements into metal-support (#172)
* pick: modern cmake, compile definitions improvement (#19139)
* modern cmake, use target_compile_definitions partly
* simplify macro define, remove USE_*
* modern cmake, macro define
* add physics 2d macro define into ccConfig.h
* remove USE_CHIPMUNK macro in build.gradle
* remove CocosSelectModule.cmake
* shrink useless define
* simplify compile options config, re-add if necessary
* update external for tmp CI test
* un-quote target_compile_options value
* add "-g" parameter only when debug mode
* keep single build type when generator Xcode & VS projecy
* update external for tmp CI tes
* add static_cast<char>(-1), fix -Wc++11-narrowing
* simplify win32 compile define
* not modify code, only improve compile options
# Conflicts:
# .gitignore
# cmake/Modules/CocosConfigDepend.cmake
# cocos/CMakeLists.txt
# external/config.json
# tests/cpp-tests/CMakeLists.txt
* modern cmake, improve cmake_compiler_flags (#19145)
* cmake_compiler_flags
* Fix typo
* Fix typo2
* Remove chanages from Android.mk
* correct lua template cmake build (#19149)
* don't add -Wno-deprecated into jsb target
* correct lua template cmake build
* fix win32 lua template compile error
* prevent cmake in-source-build friendly (#19151)
* pick: Copy resources to "Resources/" on win32 like in linux configuration
* add "/Z7" for cpp-tests on windows
* [cmake] fix iOS xcode property setting failed (#19208)
* fix iOS xcode property setting failed
* use search_depend_libs_recursive at dlls collect
* fix typo
* [cmake] add find_host_library into iOS toolchain file (#19230)
* pick: [lua android] use luajit & template cmake update (#19239)
* increase cmake stability , remove tests/CMakeLists.txt (#19261)
* cmake win32 Precompiled header (#19273)
* Precompiled header
* Fix
* Precompiled header for cocos
* Precompiled header jscocos2d
* Fix for COCOS2D_DEBUG is always 1 on Android (#19291)
Related #19289
* little build fix, tests cpp-tests works on mac
* sync v3 build related codes into metal-support (#173)
* strict initialization for std::array
* remove proj.win32 project configs
* modern cmake, cmake_cleanup_remove_unused_variables (#19146)
* Switch travis CI to xenial (#19207)
* Switch travis CI to xenial
* Remove language: android
* Set language: cpp
* Fix java problem
* Update sdkmanager
* Fix sdkmanger
* next sdkmanager fix
* Remove xenial from android
* revert to sdk-tools-{system}-3859397
* Remove linux cmake install
* Update before-install.sh
* Update .travis.yml
* Simplify install-deps-linux.sh, tested on Ubuntu 16.04 (#19212)
* Simplify install-deps-linux.sh
* Cleanup
* pick: install ninja
* update cocos2d-console submodule
* for metal-support alpha release, we only test cpp
* add HelloCpp into project(Cocos2d-x) for tmp test
* update extenal metal-support-4
* update uniform setting
* [Feature] update BindGroup
* [Feature] empty-test
* [Feature] cpp-test
* [Feature] fix GL compiler error
* [Feature] fix GL crash
* [Feature] empty-test
* [Feature] cpp-tests
* [feature] improve frameRate
* [feature] fix opengl compile error
* [feature] fix opengl compile error
* [BugFix] fix compute maxLocation error
* [Feature] update setting unifrom
* [Feature] fix namespace
* [Feature] remove unneeded code
* [Bugfix] fix project file
* [Feature] update review
* [texture2d] impl texture format support (#175)
* texture update
* update
* update texture
* commit
* compile on windows
* ddd
* rename
* rename methods
* no crash
* save gl
* save
* save
* rename
* move out pixel format convert functions
* metal crash
* update
* update android
* support gles compressed texture format
* support more compress format
* add more conversion methods
* ss
* save
* update conversion methods
* add PVRTC format support
* reformat
* add marco linux
* fix GL marcro
* pvrtc supported only by ios 8.0+
* remove unused cmake
* revert change
* refactor Texture2D::initWithData
* fix conversion log
* refactor Texture2D::initWithData
* remove some OpenGL constants for PVRTC
* add todo
* fix typo
* AutoTest works on mac/iOS by disable part cases, sync v3 bug fix (#174)
* review cpp-tests, and fix part issues on start auto test
* sync png format fix: Node:Particle3D abnormal texture effects #19204
* fix cpp-tests SpritePolygon crash, wrong png format (#19170)
* fix wrong png convert format from sRGB to Gray
* erase plist index if all frames was erased
* test_A8.png have I8 format, fix it
* [CCSpriteCache] allow re-add plist & add testcase (#19175)
* allow re-add plist & add testcase
* remove comments/rename method/update testcase
* fix isSpriteFramesWithFileLoaded & add testcase
* remove used variable
* remove unused variable
* fix double free issues when js/lua-tests exit on iOS (#19236)
* disable part cases, AutoTest works without crash on mac
* update cocos2dx files json, to test cocos new next
* fix spritecache plist parsing issue (#19269)
* [linux] Fix FileUtils::getContents with folder (#19157)
* fix FileUtils::getContents on linux/mac
* use stat.st_mode
* simplify
* [CCFileUtils] win32 getFileSize (#19176)
* win32 getFileSize
* fix stat
* [cpp test-Android]20:FileUtils/2 change title (#19197)
* sync #19200
* sync #19231
* [android lua] improve performance of lua loader (#19234)
* [lua] improve performance of lua loader
* remove cache fix
* Revert "fix spritecache plist parsing issue (#19269)"
This reverts commit f3a85ece4307a7b90816c34489d1ed2c8fd11baf.
* remove win32 project files ref in template.json
* add metal framework lnk ref into cpp template
* test on iOS, and disable part cases
* alBufferData instead of alBufferDataStatic for small audio file on Apple (#19227)
* changes AudioCache to use alBufferData instead of alBufferDataStatic
(also makes test 19 faster to trigger openal bugs faster)
The original problem: CrashIfClientProvidedBogusAudioBufferList
https://github.com/cocos2d/cocos2d-x/issues/18948
is not happening anymore, but there's still a not very frequent issue
that makes OpenAL crash with a call stack like this.
AudioCache::readDataTask > alBufferData > CleanUpDeadBufferList
It happes more frequently when the device is "cold", which means after
half an hour of not using the device (locked).
I could not find the actual source code for iOS OpenAL, so I used the
macOS versions:
https://opensource.apple.com/source/OpenAL/OpenAL-48.7/Source/OpenAL/oalImp.cpp.auto.html
They seem to use CAGuard.h to make sure the dead buffer list
has no threading issues. I'm worried because the CAGuard code I found
has macos and win32 define but no iOS, so I'm not sure. I guess the
iOS version is different and has the guard.
I could not find a place in the code that's unprotected by the locks
except the InitializeBufferMap() which should not be called more than
once from cocos, and there's a workaround in AudioEngine-impl for it.
I reduced the occurence of the CleanUpDeadBufferList crash by moving
the guard in ~AudioCache to cover the alDeleteBuffers call.
* remove hack method "setTimeout" on audio
* AutoTest works on iOS
* support set ios deployment target for root project
* enable all texture2d cases, since Jiang have fixed
* add CCTextureUtils to xcode project file (#176)
* add leak cases for SpriteFrameCache (#177)
* re-add SpriteFrameCache cases
* update template file json
* Update SpriteFrameCacheTest.cpp
* fix compiling error
2019-01-18 15:08:25 +08:00
|
|
|
src = backend::BlendFactor::ONE_MINUS_DST_COLOR;
|
|
|
|
dst = backend::BlendFactor::ZERO;
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
2013-07-05 16:49:22 +08:00
|
|
|
BlendFunc bf = {src, dst};
|
2021-12-28 16:06:23 +08:00
|
|
|
layer->setBlendFunc(bf);
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:02:22 +08:00
|
|
|
std::string LayerTestBlend::subtitle() const
|
2010-11-18 14:50:28 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "ColorLayer: blend";
|
2010-11-18 14:50:28 +08:00
|
|
|
}
|
|
|
|
|
2011-02-23 16:47:25 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
2013-06-29 10:02:10 +08:00
|
|
|
// LayerGradientTest
|
2011-02-23 16:47:25 +08:00
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
2013-06-20 13:43:40 +08:00
|
|
|
LayerGradientTest::LayerGradientTest()
|
2012-04-08 14:16:29 +08:00
|
|
|
{
|
2021-12-28 16:06:23 +08:00
|
|
|
auto layer1 = LayerGradient::create(Color4B(255, 0, 0, 255), Color4B(0, 255, 0, 255), Vec2(0.9f, 0.9f));
|
2012-04-08 14:16:29 +08:00
|
|
|
addChild(layer1, 0, kTagLayer);
|
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
auto listener = EventListenerTouchAllAtOnce::create();
|
2013-10-23 16:14:03 +08:00
|
|
|
listener->onTouchesMoved = CC_CALLBACK_2(LayerGradientTest::onTouchesMoved, this);
|
2013-10-26 15:04:01 +08:00
|
|
|
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
|
2012-04-08 14:16:29 +08:00
|
|
|
|
2014-04-09 23:31:05 +08:00
|
|
|
auto label1 = Label::createWithTTF("Compressed Interpolation: Enabled", "fonts/Marker Felt.ttf", 26);
|
|
|
|
auto label2 = Label::createWithTTF("Compressed Interpolation: Disabled", "fonts/Marker Felt.ttf", 26);
|
2021-12-28 16:06:23 +08:00
|
|
|
auto item1 = MenuItemLabel::create(label1);
|
|
|
|
auto item2 = MenuItemLabel::create(label2);
|
|
|
|
auto item =
|
|
|
|
MenuItemToggle::createWithCallback(CC_CALLBACK_1(LayerGradientTest::toggleItem, this), item1, item2, nullptr);
|
2012-04-08 14:16:29 +08:00
|
|
|
|
2014-07-10 00:45:27 +08:00
|
|
|
auto menu = Menu::create(item, nullptr);
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(menu);
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2019-09-24 11:31:35 +08:00
|
|
|
menu->setPosition(Vec2(s.width / 2, 100.0f));
|
2012-04-08 14:16:29 +08:00
|
|
|
}
|
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
void LayerGradientTest::toggleItem(Ref* sender)
|
2012-04-08 14:16:29 +08:00
|
|
|
{
|
2021-12-28 16:06:23 +08:00
|
|
|
auto gradient = static_cast<LayerGradient*>(getChildByTag(kTagLayer));
|
|
|
|
gradient->setCompressedInterpolation(!gradient->isCompressedInterpolation());
|
2012-04-08 14:16:29 +08:00
|
|
|
}
|
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
void LayerGradientTest::onTouchesMoved(const std::vector<Touch*>& touches, Event* event)
|
2012-04-08 14:16:29 +08:00
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-04-08 14:16:29 +08:00
|
|
|
|
2013-09-03 18:22:03 +08:00
|
|
|
auto touch = touches[0];
|
2021-12-28 16:06:23 +08:00
|
|
|
auto start = touch->getLocation();
|
2012-04-08 14:16:29 +08:00
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
auto diff = Vec2(s.width / 2, s.height / 2) - start;
|
|
|
|
diff = diff.getNormalized();
|
2012-04-08 14:16:29 +08:00
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
auto gradient = static_cast<LayerGradient*>(getChildByTag(1));
|
2012-04-08 14:16:29 +08:00
|
|
|
gradient->setVector(diff);
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string LayerGradientTest::title() const
|
2012-04-08 14:16:29 +08:00
|
|
|
{
|
2013-06-20 13:43:40 +08:00
|
|
|
return "LayerGradientTest";
|
2011-02-23 16:47:25 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string LayerGradientTest::subtitle() const
|
2011-07-06 14:56:05 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return "Touch the screen and move your finger";
|
2011-07-06 14:56:05 +08:00
|
|
|
}
|
|
|
|
|
2013-06-29 10:02:10 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// LayerGradientTest2
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
LayerGradientTest2::LayerGradientTest2()
|
|
|
|
{
|
2021-12-28 16:06:23 +08:00
|
|
|
auto layer = LayerGradient::create(Color4B(255, 0, 0, 255), Color4B(255, 255, 0, 255));
|
2013-06-29 10:02:10 +08:00
|
|
|
addChild(layer);
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string LayerGradientTest2::title() const
|
2013-06-29 10:02:10 +08:00
|
|
|
{
|
|
|
|
return "LayerGradientTest 2";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string LayerGradientTest2::subtitle() const
|
2013-06-29 10:02:10 +08:00
|
|
|
{
|
|
|
|
return "You should see a gradient";
|
|
|
|
}
|
|
|
|
|
2012-06-15 15:10:40 +08:00
|
|
|
// LayerIgnoreAnchorPointPos
|
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
#define kLayerIgnoreAnchorPoint 1000
|
2012-06-15 15:10:40 +08:00
|
|
|
|
|
|
|
void LayerIgnoreAnchorPointPos::onEnter()
|
|
|
|
{
|
|
|
|
LayerTest::onEnter();
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-06-15 15:10:40 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto l = LayerColor::create(Color4B(255, 0, 0, 255), 150, 150);
|
2012-06-15 15:10:40 +08:00
|
|
|
|
2014-05-15 01:07:09 +08:00
|
|
|
l->setAnchorPoint(Vec2(0.5f, 0.5f));
|
2021-12-28 16:06:23 +08:00
|
|
|
l->setPosition(Vec2(s.width / 2, s.height / 2));
|
2012-06-15 15:10:40 +08:00
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
auto move = MoveBy::create(2, Vec2(100, 2));
|
|
|
|
auto back = (MoveBy*)move->reverse();
|
|
|
|
auto seq = Sequence::create(move, back, nullptr);
|
2013-06-20 14:17:10 +08:00
|
|
|
l->runAction(RepeatForever::create(seq));
|
2012-06-15 15:10:40 +08:00
|
|
|
this->addChild(l, 0, kLayerIgnoreAnchorPoint);
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto child = Sprite::create("Images/grossini.png");
|
2012-06-15 15:10:40 +08:00
|
|
|
l->addChild(child);
|
2013-08-16 16:05:27 +08:00
|
|
|
auto lsize = l->getContentSize();
|
2021-12-28 16:06:23 +08:00
|
|
|
child->setPosition(Vec2(lsize.width / 2, lsize.height / 2));
|
2012-06-15 15:10:40 +08:00
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
auto item =
|
|
|
|
MenuItemFont::create("Toggle ignore anchor point", CC_CALLBACK_1(LayerIgnoreAnchorPointPos::onToggle, this));
|
2012-06-15 15:10:40 +08:00
|
|
|
|
2014-07-10 00:45:27 +08:00
|
|
|
auto menu = Menu::create(item, nullptr);
|
2012-06-15 15:10:40 +08:00
|
|
|
this->addChild(menu);
|
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
menu->setPosition(Vec2(s.width / 2, s.height / 2));
|
2012-06-15 15:10:40 +08:00
|
|
|
}
|
|
|
|
|
2014-02-20 10:53:49 +08:00
|
|
|
void LayerIgnoreAnchorPointPos::onToggle(Ref* pObject)
|
2012-06-15 15:10:40 +08:00
|
|
|
{
|
2021-12-28 16:06:23 +08:00
|
|
|
auto layer = this->getChildByTag(kLayerIgnoreAnchorPoint);
|
2013-07-23 08:25:44 +08:00
|
|
|
bool ignore = layer->isIgnoreAnchorPointForPosition();
|
2021-12-28 16:06:23 +08:00
|
|
|
layer->setIgnoreAnchorPointForPosition(!ignore);
|
2012-06-15 15:10:40 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string LayerIgnoreAnchorPointPos::title() const
|
2012-06-12 15:14:01 +08:00
|
|
|
{
|
|
|
|
return "IgnoreAnchorPoint - Position";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string LayerIgnoreAnchorPointPos::subtitle() const
|
2012-06-15 15:10:40 +08:00
|
|
|
{
|
2014-05-15 01:07:09 +08:00
|
|
|
return "Ignoring Anchor Vec2 for position";
|
2012-06-15 15:10:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// LayerIgnoreAnchorPointRot
|
|
|
|
|
|
|
|
void LayerIgnoreAnchorPointRot::onEnter()
|
|
|
|
{
|
|
|
|
LayerTest::onEnter();
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-06-15 15:10:40 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto l = LayerColor::create(Color4B(255, 0, 0, 255), 200, 200);
|
2012-06-15 15:10:40 +08:00
|
|
|
|
2014-05-15 01:07:09 +08:00
|
|
|
l->setAnchorPoint(Vec2(0.5f, 0.5f));
|
2021-12-28 16:06:23 +08:00
|
|
|
l->setPosition(Vec2(s.width / 2, s.height / 2));
|
2012-06-15 15:10:40 +08:00
|
|
|
|
|
|
|
this->addChild(l, 0, kLayerIgnoreAnchorPoint);
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto rot = RotateBy::create(2, 360);
|
2013-06-20 14:17:10 +08:00
|
|
|
l->runAction(RepeatForever::create(rot));
|
2012-06-15 15:10:40 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto child = Sprite::create("Images/grossini.png");
|
2012-06-15 15:10:40 +08:00
|
|
|
l->addChild(child);
|
2013-08-16 16:05:27 +08:00
|
|
|
auto lsize = l->getContentSize();
|
2021-12-28 16:06:23 +08:00
|
|
|
child->setPosition(Vec2(lsize.width / 2, lsize.height / 2));
|
2012-06-15 15:10:40 +08:00
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
auto item =
|
|
|
|
MenuItemFont::create("Toggle ignore anchor point", CC_CALLBACK_1(LayerIgnoreAnchorPointRot::onToggle, this));
|
2012-06-15 15:10:40 +08:00
|
|
|
|
2014-07-10 00:45:27 +08:00
|
|
|
auto menu = Menu::create(item, nullptr);
|
2012-06-15 15:10:40 +08:00
|
|
|
this->addChild(menu);
|
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
menu->setPosition(Vec2(s.width / 2, s.height / 2));
|
2012-06-15 15:10:40 +08:00
|
|
|
}
|
|
|
|
|
2014-02-20 10:53:49 +08:00
|
|
|
void LayerIgnoreAnchorPointRot::onToggle(Ref* pObject)
|
2012-06-15 15:10:40 +08:00
|
|
|
{
|
2021-12-28 16:06:23 +08:00
|
|
|
auto layer = this->getChildByTag(kLayerIgnoreAnchorPoint);
|
2013-07-23 08:25:44 +08:00
|
|
|
bool ignore = layer->isIgnoreAnchorPointForPosition();
|
2021-12-28 16:06:23 +08:00
|
|
|
layer->setIgnoreAnchorPointForPosition(!ignore);
|
2012-06-15 15:10:40 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string LayerIgnoreAnchorPointRot::title() const
|
2012-06-12 15:14:01 +08:00
|
|
|
{
|
|
|
|
return "IgnoreAnchorPoint - Rotation";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string LayerIgnoreAnchorPointRot::subtitle() const
|
2012-06-15 15:10:40 +08:00
|
|
|
{
|
2014-05-15 01:07:09 +08:00
|
|
|
return "Ignoring Anchor Vec2 for rotations";
|
2012-06-15 15:10:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// LayerIgnoreAnchorPointScale
|
|
|
|
void LayerIgnoreAnchorPointScale::onEnter()
|
|
|
|
{
|
|
|
|
LayerTest::onEnter();
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-06-15 15:10:40 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto l = LayerColor::create(Color4B(255, 0, 0, 255), 200, 200);
|
2012-06-15 15:10:40 +08:00
|
|
|
|
2014-05-15 01:07:09 +08:00
|
|
|
l->setAnchorPoint(Vec2(0.5f, 1.0f));
|
2021-12-28 16:06:23 +08:00
|
|
|
l->setPosition(Vec2(s.width / 2, s.height / 2));
|
2012-06-15 15:10:40 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto scale = ScaleBy::create(2, 2);
|
2021-12-28 16:06:23 +08:00
|
|
|
auto back = (ScaleBy*)scale->reverse();
|
|
|
|
auto seq = Sequence::create(scale, back, nullptr);
|
2012-06-15 15:10:40 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
l->runAction(RepeatForever::create(seq));
|
2012-06-15 15:10:40 +08:00
|
|
|
|
|
|
|
this->addChild(l, 0, kLayerIgnoreAnchorPoint);
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto child = Sprite::create("Images/grossini.png");
|
2012-06-15 15:10:40 +08:00
|
|
|
l->addChild(child);
|
2013-08-16 16:05:27 +08:00
|
|
|
auto lsize = l->getContentSize();
|
2021-12-28 16:06:23 +08:00
|
|
|
child->setPosition(Vec2(lsize.width / 2, lsize.height / 2));
|
2012-06-15 15:10:40 +08:00
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
auto item =
|
|
|
|
MenuItemFont::create("Toggle ignore anchor point", CC_CALLBACK_1(LayerIgnoreAnchorPointScale::onToggle, this));
|
2012-06-15 15:10:40 +08:00
|
|
|
|
2014-07-10 00:45:27 +08:00
|
|
|
auto menu = Menu::create(item, nullptr);
|
2012-06-15 15:10:40 +08:00
|
|
|
this->addChild(menu);
|
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
menu->setPosition(Vec2(s.width / 2, s.height / 2));
|
2012-06-15 15:10:40 +08:00
|
|
|
}
|
|
|
|
|
2014-02-20 10:53:49 +08:00
|
|
|
void LayerIgnoreAnchorPointScale::onToggle(Ref* pObject)
|
2012-06-15 15:10:40 +08:00
|
|
|
{
|
2021-12-28 16:06:23 +08:00
|
|
|
auto layer = this->getChildByTag(kLayerIgnoreAnchorPoint);
|
2013-07-23 08:25:44 +08:00
|
|
|
bool ignore = layer->isIgnoreAnchorPointForPosition();
|
2021-12-28 16:06:23 +08:00
|
|
|
layer->setIgnoreAnchorPointForPosition(!ignore);
|
2012-06-15 15:10:40 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string LayerIgnoreAnchorPointScale::title() const
|
2012-06-12 15:14:01 +08:00
|
|
|
{
|
|
|
|
return "IgnoreAnchorPoint - Scale";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string LayerIgnoreAnchorPointScale::subtitle() const
|
2012-06-15 15:10:40 +08:00
|
|
|
{
|
2014-05-15 01:07:09 +08:00
|
|
|
return "Ignoring Anchor Vec2 for scale";
|
2012-06-12 15:14:01 +08:00
|
|
|
}
|
|
|
|
|
2012-11-20 18:00:27 +08:00
|
|
|
LayerExtendedBlendOpacityTest::LayerExtendedBlendOpacityTest()
|
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
auto layer1 = LayerGradient::create(Color4B(255, 0, 0, 255), Color4B(255, 0, 255, 255));
|
2019-09-24 11:31:35 +08:00
|
|
|
layer1->setContentSize(Size(80.0f, 80.0f));
|
2021-12-28 16:06:23 +08:00
|
|
|
layer1->setPosition(Vec2(50.0f, 50.0f));
|
2012-11-20 18:00:27 +08:00
|
|
|
addChild(layer1);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto layer2 = LayerGradient::create(Color4B(0, 0, 0, 127), Color4B(255, 255, 255, 127));
|
2019-09-24 11:31:35 +08:00
|
|
|
layer2->setContentSize(Size(80.0f, 80.0f));
|
2021-12-28 16:06:23 +08:00
|
|
|
layer2->setPosition(Vec2(100.0f, 90.0f));
|
2012-11-20 18:00:27 +08:00
|
|
|
addChild(layer2);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto layer3 = LayerGradient::create();
|
2019-09-24 11:31:35 +08:00
|
|
|
layer3->setContentSize(Size(80.0f, 80.0f));
|
2021-12-28 16:06:23 +08:00
|
|
|
layer3->setPosition(Vec2(150.0f, 140.0f));
|
2013-07-05 16:49:22 +08:00
|
|
|
layer3->setStartColor(Color3B(255, 0, 0));
|
|
|
|
layer3->setEndColor(Color3B(255, 0, 255));
|
2012-11-20 18:00:27 +08:00
|
|
|
layer3->setStartOpacity(255);
|
|
|
|
layer3->setEndOpacity(255);
|
2021-12-28 16:06:23 +08:00
|
|
|
layer3->setBlendFunc(BlendFunc::ALPHA_NON_PREMULTIPLIED);
|
2012-11-20 18:00:27 +08:00
|
|
|
addChild(layer3);
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string LayerExtendedBlendOpacityTest::title() const
|
2012-11-20 18:00:27 +08:00
|
|
|
{
|
|
|
|
return "Extended Blend & Opacity";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string LayerExtendedBlendOpacityTest::subtitle() const
|
2012-11-20 18:00:27 +08:00
|
|
|
{
|
|
|
|
return "You should see 3 layers";
|
|
|
|
}
|
|
|
|
|
2013-12-11 15:57:20 +08:00
|
|
|
// LayerBug3162A
|
|
|
|
void LayerBug3162A::onEnter()
|
|
|
|
{
|
|
|
|
LayerTest::onEnter();
|
2021-12-28 16:06:23 +08:00
|
|
|
|
|
|
|
Size size = VisibleRect::getVisibleRect().size;
|
|
|
|
size.width = size.width / 2;
|
|
|
|
size.height = size.height / 3;
|
2013-12-11 15:57:20 +08:00
|
|
|
Color4B color[3] = {Color4B(255, 0, 0, 255), Color4B(0, 255, 0, 255), Color4B(0, 0, 255, 255)};
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2013-12-11 15:57:20 +08:00
|
|
|
for (int i = 0; i < 3; ++i)
|
|
|
|
{
|
|
|
|
_layer[i] = LayerColor::create(color[i]);
|
|
|
|
_layer[i]->setContentSize(size);
|
2021-12-28 16:06:23 +08:00
|
|
|
_layer[i]->setPosition(Vec2(size.width / 2, size.height / 2) - Vec2(20.0f, 20.0f));
|
2013-12-11 15:57:20 +08:00
|
|
|
_layer[i]->setOpacity(150);
|
|
|
|
_layer[i]->setCascadeOpacityEnabled(true);
|
|
|
|
if (i > 0)
|
|
|
|
{
|
2021-12-28 16:06:23 +08:00
|
|
|
_layer[i - 1]->addChild(_layer[i]);
|
2013-12-11 15:57:20 +08:00
|
|
|
}
|
|
|
|
}
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2013-12-11 15:57:20 +08:00
|
|
|
this->addChild(_layer[0]);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2014-10-04 00:38:36 +08:00
|
|
|
schedule(CC_SCHEDULE_SELECTOR(LayerBug3162A::step), 0.5, CC_REPEAT_FOREVER, 0);
|
2013-12-11 15:57:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void LayerBug3162A::step(float dt)
|
|
|
|
{
|
|
|
|
_layer[0]->setCascadeOpacityEnabled(!_layer[0]->isCascadeOpacityEnabled());
|
|
|
|
}
|
|
|
|
|
2013-12-20 04:23:42 +08:00
|
|
|
std::string LayerBug3162A::title() const
|
2013-12-11 15:57:20 +08:00
|
|
|
{
|
2017-02-24 12:45:41 +08:00
|
|
|
return "Bug 3162 red layer cascade opacity enable/disable";
|
2013-12-11 15:57:20 +08:00
|
|
|
}
|
|
|
|
|
2013-12-20 04:23:42 +08:00
|
|
|
std::string LayerBug3162A::subtitle() const
|
2013-12-11 15:57:20 +08:00
|
|
|
{
|
|
|
|
return "g and b layer opacity is effected/diseffected with r layer";
|
|
|
|
}
|
|
|
|
|
|
|
|
// LayerBug3162B
|
|
|
|
void LayerBug3162B::onEnter()
|
|
|
|
{
|
|
|
|
LayerTest::onEnter();
|
2021-12-28 16:06:23 +08:00
|
|
|
|
|
|
|
Size size = VisibleRect::getVisibleRect().size;
|
|
|
|
size.width = size.width / 2;
|
|
|
|
size.height = size.height / 3;
|
2013-12-11 15:57:20 +08:00
|
|
|
Color4B color[3] = {Color4B(200, 0, 0, 255), Color4B(150, 0, 0, 255), Color4B(100, 0, 0, 255)};
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2013-12-11 15:57:20 +08:00
|
|
|
for (int i = 0; i < 3; ++i)
|
|
|
|
{
|
|
|
|
_layer[i] = LayerColor::create(color[i]);
|
|
|
|
_layer[i]->setContentSize(size);
|
2021-12-28 16:06:23 +08:00
|
|
|
_layer[i]->setPosition(Vec2(size.width / 2, size.height / 2) - Vec2(20.0f, 20.0f));
|
2013-12-11 15:57:20 +08:00
|
|
|
//_layer[i]->setOpacity(150);
|
|
|
|
if (i > 0)
|
|
|
|
{
|
2021-12-28 16:06:23 +08:00
|
|
|
_layer[i - 1]->addChild(_layer[i]);
|
2013-12-11 15:57:20 +08:00
|
|
|
}
|
|
|
|
}
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2013-12-11 15:57:20 +08:00
|
|
|
this->addChild(_layer[0]);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2013-12-11 15:57:20 +08:00
|
|
|
_layer[0]->setCascadeColorEnabled(true);
|
|
|
|
_layer[1]->setCascadeColorEnabled(true);
|
|
|
|
_layer[2]->setCascadeColorEnabled(true);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2014-10-04 00:38:36 +08:00
|
|
|
schedule(CC_SCHEDULE_SELECTOR(LayerBug3162B::step), 0.5, CC_REPEAT_FOREVER, 0);
|
2013-12-11 15:57:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void LayerBug3162B::step(float dt)
|
|
|
|
{
|
|
|
|
_layer[0]->setCascadeColorEnabled(!_layer[0]->isCascadeColorEnabled());
|
|
|
|
}
|
|
|
|
|
2013-12-20 04:23:42 +08:00
|
|
|
std::string LayerBug3162B::title() const
|
2013-12-11 15:57:20 +08:00
|
|
|
{
|
2017-02-24 12:45:41 +08:00
|
|
|
return "Bug 3162 bottom layer cascade color enable/disable";
|
2013-12-11 15:57:20 +08:00
|
|
|
}
|
|
|
|
|
2013-12-20 04:23:42 +08:00
|
|
|
std::string LayerBug3162B::subtitle() const
|
2013-12-11 15:57:20 +08:00
|
|
|
{
|
2013-12-16 04:13:49 +08:00
|
|
|
return "u and m layer color is effected/diseffected with b layer";
|
2013-12-11 15:57:20 +08:00
|
|
|
}
|
2014-01-09 14:50:29 +08:00
|
|
|
|
|
|
|
std::string LayerColorOccludeBug::title() const
|
|
|
|
{
|
|
|
|
return "Layer Color Occlude Bug Test";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string LayerColorOccludeBug::subtitle() const
|
|
|
|
{
|
2021-12-28 16:06:23 +08:00
|
|
|
return "Layer Color Should not occlude titles and any sprites";
|
2014-01-09 14:50:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void LayerColorOccludeBug::onEnter()
|
|
|
|
{
|
|
|
|
LayerTest::onEnter();
|
2019-06-30 11:36:52 +08:00
|
|
|
Director::getInstance()->getRenderer()->setDepthTest(true);
|
2014-01-09 14:50:29 +08:00
|
|
|
_layer = LayerColor::create(Color4B(0, 80, 95, 255));
|
|
|
|
addChild(_layer);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LayerColorOccludeBug::onExit()
|
|
|
|
{
|
|
|
|
LayerTest::onExit();
|
2019-06-30 11:36:52 +08:00
|
|
|
Director::getInstance()->getRenderer()->setDepthTest(false);
|
2014-01-09 14:50:29 +08:00
|
|
|
}
|
2017-05-22 13:42:00 +08:00
|
|
|
|
|
|
|
// LayerRadialGradient
|
|
|
|
|
|
|
|
std::string LayerRadialGradientTest::title() const
|
|
|
|
{
|
|
|
|
return "LayerRadialGradient test";
|
|
|
|
}
|
|
|
|
|
|
|
|
void LayerRadialGradientTest::onEnter()
|
|
|
|
{
|
|
|
|
LayerTest::onEnter();
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2017-05-22 13:42:00 +08:00
|
|
|
_currentSeletedItemIndex = 0;
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2017-05-22 13:42:00 +08:00
|
|
|
auto director = Director::getInstance();
|
|
|
|
director->setClearColor(Color4F(0, 0, 0, 0));
|
|
|
|
auto origin = director->getVisibleOrigin();
|
2021-12-28 16:06:23 +08:00
|
|
|
auto size = director->getVisibleSize();
|
|
|
|
Vec2 center(origin.x + size.width / 2 + 50, origin.y + size.height / 2);
|
2017-05-22 13:42:00 +08:00
|
|
|
float radius = (size.height - 50) / 2;
|
2021-12-28 16:06:23 +08:00
|
|
|
_layer = LayerRadialGradient::create(Color4B(145, 106, 209, 140), Color4B(0, 0, 0, 0), radius, center, 1.0f);
|
2017-05-22 13:42:00 +08:00
|
|
|
addChild(_layer);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2017-05-22 13:42:00 +08:00
|
|
|
auto scaleSlider = LayerRadialGradientTest::createSlider();
|
2019-09-24 11:31:35 +08:00
|
|
|
scaleSlider->setPosition(Vec2(50.0f, 130.0f));
|
2017-05-22 13:42:00 +08:00
|
|
|
addChild(scaleSlider);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2017-05-22 13:42:00 +08:00
|
|
|
auto listview = createListView();
|
2019-09-24 11:31:35 +08:00
|
|
|
listview->setPosition(Vec2(100.0f, 150.0f));
|
2017-05-22 13:42:00 +08:00
|
|
|
addChild(listview);
|
|
|
|
}
|
|
|
|
|
|
|
|
cocos2d::ui::Slider* LayerRadialGradientTest::createSlider()
|
|
|
|
{
|
|
|
|
auto slider = ui::Slider::create();
|
|
|
|
slider->setTouchEnabled(true);
|
|
|
|
slider->loadBarTexture("cocosui/sliderTrack.png");
|
|
|
|
slider->loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", "");
|
|
|
|
slider->loadProgressBarTexture("cocosui/sliderProgress.png");
|
|
|
|
slider->addEventListener(CC_CALLBACK_2(LayerRadialGradientTest::sliderCallback, this));
|
|
|
|
slider->setRotation(90);
|
|
|
|
slider->setTag(101);
|
|
|
|
slider->setPercent(50);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2017-05-22 13:42:00 +08:00
|
|
|
return slider;
|
|
|
|
}
|
|
|
|
|
|
|
|
void LayerRadialGradientTest::listviewCallback(cocos2d::Ref* sender, cocos2d::ui::ListView::EventType type)
|
|
|
|
{
|
|
|
|
// clear all text to white
|
|
|
|
auto listview = static_cast<cocos2d::ui::ListView*>(sender);
|
2021-12-28 16:06:23 +08:00
|
|
|
for (auto& item : listview->getItems())
|
2017-05-22 13:42:00 +08:00
|
|
|
static_cast<cocos2d::ui::Text*>(item)->setColor(cocos2d::Color3B::WHITE);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2017-05-22 13:42:00 +08:00
|
|
|
_currentSeletedItemIndex = (int)listview->getCurSelectedIndex();
|
|
|
|
listview->getItem(_currentSeletedItemIndex)->setColor(cocos2d::Color3B::RED);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2017-05-22 13:42:00 +08:00
|
|
|
int percent = 100;
|
|
|
|
auto slider = static_cast<cocos2d::ui::Slider*>(getChildByTag(101));
|
|
|
|
switch (_currentSeletedItemIndex)
|
|
|
|
{
|
2021-12-28 16:06:23 +08:00
|
|
|
case 0:
|
|
|
|
// scale
|
|
|
|
slider->setPercent(_layer->getScaleX() / 2 * percent);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
// skewx
|
|
|
|
slider->setPercent(_layer->getSkewX() / 90 * percent);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
// skewy
|
|
|
|
slider->setPercent(_layer->getSkewY() / 90 * percent);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
// expand
|
|
|
|
slider->setPercent(_layer->getExpand() * percent);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
// radius
|
|
|
|
slider->setPercent(_layer->getRadius() / 300 * percent);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2017-05-22 13:42:00 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void LayerRadialGradientTest::sliderCallback(cocos2d::Ref* sender, cocos2d::ui::Slider::EventType type)
|
|
|
|
{
|
2021-12-28 16:06:23 +08:00
|
|
|
auto slider = static_cast<cocos2d::ui::Slider*>(sender);
|
2017-05-22 13:42:00 +08:00
|
|
|
float percent = slider->getPercent() / 100.f;
|
|
|
|
switch (_currentSeletedItemIndex)
|
|
|
|
{
|
2021-12-28 16:06:23 +08:00
|
|
|
case 0:
|
|
|
|
// scale
|
|
|
|
_layer->setScale(percent * 2);
|
|
|
|
CCLOG("scale is %f", percent * 2);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
// skewx
|
|
|
|
_layer->setSkewX(90 * percent);
|
|
|
|
CCLOG("SkewX is %f", 90 * percent);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
// skewy
|
|
|
|
_layer->setSkewY(90 * percent);
|
|
|
|
CCLOG("SkewY is %f", 90 * percent);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
// expand
|
|
|
|
_layer->setExpand(percent);
|
|
|
|
CCLOG("expand is %f", percent);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
// radius
|
|
|
|
_layer->setRadius(300 * percent);
|
|
|
|
CCLOG("radius is %f", 300 * percent);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2017-05-22 13:42:00 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
cocos2d::ui::ListView* LayerRadialGradientTest::createListView()
|
|
|
|
{
|
|
|
|
auto listview = cocos2d::ui::ListView::create();
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2017-05-22 13:42:00 +08:00
|
|
|
auto scale = cocos2d::ui::Text::create();
|
|
|
|
scale->setString("scale[0-2]");
|
2021-12-28 16:06:23 +08:00
|
|
|
scale->setColor(cocos2d::Color3B::RED); // default seleted item
|
2017-05-22 13:42:00 +08:00
|
|
|
scale->setTouchEnabled(true);
|
|
|
|
listview->pushBackCustomItem(scale);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2017-05-22 13:42:00 +08:00
|
|
|
auto skewx = cocos2d::ui::Text::create();
|
|
|
|
skewx->setString("skewx[0-90]");
|
|
|
|
skewx->setTouchEnabled(true);
|
|
|
|
listview->pushBackCustomItem(skewx);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2017-05-22 13:42:00 +08:00
|
|
|
auto skewy = cocos2d::ui::Text::create();
|
|
|
|
skewy->setString("skewy[0-90]");
|
|
|
|
skewy->setTouchEnabled(true);
|
|
|
|
listview->pushBackCustomItem(skewy);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2017-05-22 13:42:00 +08:00
|
|
|
auto expand = cocos2d::ui::Text::create();
|
|
|
|
expand->setString("expand[0-1]");
|
|
|
|
expand->setTouchEnabled(true);
|
|
|
|
listview->pushBackCustomItem(expand);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2017-05-22 13:42:00 +08:00
|
|
|
auto radius = cocos2d::ui::Text::create();
|
2017-06-12 08:57:40 +08:00
|
|
|
radius->setString("radius[0-300]");
|
2017-05-22 13:42:00 +08:00
|
|
|
radius->setTouchEnabled(true);
|
|
|
|
listview->pushBackCustomItem(radius);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2017-05-22 13:42:00 +08:00
|
|
|
listview->setContentSize(scale->getContentSize() * 5);
|
|
|
|
listview->setCurSelectedIndex(0);
|
|
|
|
listview->setTouchEnabled(true);
|
2021-12-28 16:06:23 +08:00
|
|
|
listview->addEventListener(
|
|
|
|
(ui::ListView::ccListViewCallback)CC_CALLBACK_2(LayerRadialGradientTest::listviewCallback, this));
|
2017-05-22 13:42:00 +08:00
|
|
|
listview->setTag(100);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2017-05-22 13:42:00 +08:00
|
|
|
return listview;
|
|
|
|
}
|