| 238 | } |
| 239 | |
| 240 | NewClippingNodeTest::NewClippingNodeTest() |
| 241 | { |
| 242 | auto s = Director::getInstance()->getWinSize(); |
| 243 | |
| 244 | auto clipper = ClippingNode::create(); |
| 245 | clipper->setTag(kTagClipperNode); |
| 246 | clipper->setContentSize(Size(200.0f, 200.0f)); |
| 247 | clipper->setAnchorPoint(Vec2(0.5f, 0.5f)); |
| 248 | clipper->setPosition(Vec2(s.width / 2, s.height / 2)); |
| 249 | |
| 250 | clipper->runAction(RepeatForever::create(RotateBy::create(1, 45))); |
| 251 | this->addChild(clipper); |
| 252 | |
| 253 | // TODO: Fix draw node as clip node |
| 254 | // auto stencil = NewDrawNode::create(); |
| 255 | // Vec2 rectangle[4]; |
| 256 | // rectangle[0] = Vec2(0, 0); |
| 257 | // rectangle[1] = Vec2(clipper->getContentSize().width, 0); |
| 258 | // rectangle[2] = Vec2(clipper->getContentSize().width, clipper->getContentSize().height); |
| 259 | // rectangle[3] = Vec2(0, clipper->getContentSize().height); |
| 260 | // |
| 261 | // Color4F white(1, 1, 1, 1); |
| 262 | // stencil->drawPolygon(rectangle, 4, white, 1, white); |
| 263 | // clipper->setStencil(stencil); |
| 264 | |
| 265 | // Test with alpha Test |
| 266 | clipper->setAlphaThreshold(0.05f); |
| 267 | auto stencil = Sprite::create("Images/grossini.png"); |
| 268 | stencil->setPosition(s.width / 2, s.height / 2); |
| 269 | clipper->setStencil(stencil); |
| 270 | |
| 271 | auto content = Sprite::create("Images/background2.png"); |
| 272 | content->setTag(kTagContentNode); |
| 273 | content->setAnchorPoint(Vec2(0.5f, 0.5f)); |
| 274 | content->setPosition(Vec2(clipper->getContentSize().width / 2, clipper->getContentSize().height / 2)); |
| 275 | clipper->addChild(content); |
| 276 | |
| 277 | _scrolling = false; |
| 278 | |
| 279 | auto listener = EventListenerTouchAllAtOnce::create(); |
| 280 | listener->onTouchesBegan = AX_CALLBACK_2(NewClippingNodeTest::onTouchesBegan, this); |
| 281 | listener->onTouchesMoved = AX_CALLBACK_2(NewClippingNodeTest::onTouchesMoved, this); |
| 282 | listener->onTouchesEnded = AX_CALLBACK_2(NewClippingNodeTest::onTouchesEnded, this); |
| 283 | _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); |
| 284 | } |
| 285 | |
| 286 | NewClippingNodeTest::~NewClippingNodeTest() {} |
| 287 |
nothing calls this directly
no test coverage detected