Esempio n. 1
0
void NestedTest::setup()
{
    static int depth = 9;
    
    Node* parent = this;
    
    for (int i = 0; i < depth; i++) {
                
        int size = 225 - i * (225 / (depth * 2));

        auto clipper = ClippingNode::create();
        clipper->setContentSize(Size(size, size));
        clipper->setAnchorPoint(Vec2(0.5, 0.5));
        clipper->setPosition(parent->getContentSize().width / 2, parent->getContentSize().height / 2);
        clipper->setAlphaThreshold(0.05f);
        clipper->runAction(RepeatForever::create(RotateBy::create(i % 3 ? 1.33 : 1.66, i % 2 ? 90 : -90)));
        parent->addChild(clipper);
        
        auto stencil = Sprite::create(s_pathGrossini);
        stencil->setScale( 2.5 - (i * (2.5 / depth)) );
        stencil->setAnchorPoint( Vec2(0.5, 0.5) );
        stencil->setPosition(clipper->getContentSize().width / 2, clipper->getContentSize().height / 2);
        stencil->setVisible(false);
        stencil->runAction(Sequence::createWithTwoActions(DelayTime::create(i), Show::create()));
        clipper->setStencil(stencil);

        clipper->addChild(stencil);
        
        parent = clipper;
    }

}
Esempio n. 2
0
void PlayStage::countAnimeBoom(Point position)
{
	auto mask = ClippingNode::create();
	mask->setStencil(LayerColor::create(Color4B(0, 0, 0, 255), _screenSize.width, 240.0f));
	mask->setAlphaThreshold(255);
	mask->setInverted(false);

    auto count_boom_anime = ParticleSystemQuad::create("count_boom_ver2.plist");
	count_boom_anime->setAutoRemoveOnFinish(true);
	count_boom_anime->setPosition(position);
	count_boom_anime->setLifeVar(0.2f);
    
    auto chainLabel = Label::createWithBMFont("ui_font.fnt", std::to_string(chains) + " Chains!!");
    chainLabel->setScale(0);
    chainLabel->runAction(Sequence::create(EaseBackIn::create(ScaleTo::create(0.4f, 2.0f)),
                                           EaseBackOut::create(ScaleTo::create(0.18f, 1.0f)),
                                           DelayTime::create(0.4f),
                                           FadeOut::create(0.3f),
										   CallFunc::create(CC_CALLBACK_0(Label::removeFromParentAndCleanup, chainLabel, true)),
										   NULL));
    chainLabel->setPosition(position);
    
    //anime_sprite->addChild(count_anime);
    
	mask->addChild(count_boom_anime);
	mask->addChild(chainLabel);
	ballSheetMask->addChild(mask, 500);
}
Esempio n. 3
0
ClippingNode* SpriteInvertedTest::clipper()
{
    auto clipper = SpriteTest::clipper();
    clipper->setAlphaThreshold(0.05f);
    clipper->setInverted(true);
    return clipper;
}
Esempio n. 4
0
bool JigTile::init()
{
    Return_False_If(!ClippingNode::init());
    
    setAnchorPoint(Point::ANCHOR_MIDDLE);
    setAlphaThreshold(0.5f);
    
    return true;
}
Esempio n. 5
0
NewClippingNodeTest::NewClippingNodeTest()
{
    auto s = Director::getInstance()->getWinSize();

    auto clipper = ClippingNode::create();
    clipper->setTag( kTagClipperNode );
    clipper->setContentSize(  Size(200, 200) );
    clipper->setAnchorPoint(  Vec2(0.5, 0.5) );
    clipper->setPosition( Vec2(s.width / 2, s.height / 2) );

    clipper->runAction(RepeatForever::create(RotateBy::create(1, 45)));
    this->addChild(clipper);

    // TODO: Fix draw node as clip node
//    auto stencil = NewDrawNode::create();
//    Vec2 rectangle[4];
//    rectangle[0] = Vec2(0, 0);
//    rectangle[1] = Vec2(clipper->getContentSize().width, 0);
//    rectangle[2] = Vec2(clipper->getContentSize().width, clipper->getContentSize().height);
//    rectangle[3] = Vec2(0, clipper->getContentSize().height);
//
//    Color4F white(1, 1, 1, 1);
//    stencil->drawPolygon(rectangle, 4, white, 1, white);
//    clipper->setStencil(stencil);

    //Test with alpha Test
    clipper->setAlphaThreshold(0.05f);
    auto stencil = Sprite::create("Images/grossini.png");
    stencil->setPosition(s.width/2, s.height/2);
    clipper->setStencil(stencil);

    auto content = Sprite::create("Images/background2.png");
    content->setTag( kTagContentNode );
    content->setAnchorPoint(  Vec2(0.5, 0.5) );
    content->setPosition( Vec2(clipper->getContentSize().width / 2, clipper->getContentSize().height / 2) );
    clipper->addChild(content);

    _scrolling = false;

    auto listener = EventListenerTouchAllAtOnce::create();
    listener->onTouchesBegan = CC_CALLBACK_2(NewClippingNodeTest::onTouchesBegan, this);
    listener->onTouchesMoved = CC_CALLBACK_2(NewClippingNodeTest::onTouchesMoved, this);
    listener->onTouchesEnded = CC_CALLBACK_2(NewClippingNodeTest::onTouchesEnded, this);
    _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
}
Esempio n. 6
0
void PlayStage::countAnime(Point position)
{
    
    //auto anime_sprite = Sprite::create();
	auto mask = ClippingNode::create();
	mask->setStencil(LayerColor::create(Color4B(0, 0, 0, 255), _screenSize.width, 240.0f));
	mask->setAlphaThreshold(255);
	mask->setInverted(false);
    
    auto count_anime = ParticleSystemQuad::create("Count_anime.plist");
    count_anime->setAutoRemoveOnFinish(true);
    count_anime->setPosition(position);
    
    //anime_sprite->addChild(count_anime);
    
	mask->addChild(count_anime);
	ballSheetMask->addChild(mask, 500);
}
Esempio n. 7
0
void HoleDemo::setup()
{
    auto target = Sprite::create(s_pathBlock);
    target->setAnchorPoint(Vec2::ZERO);
    target->setScale(3);
    
    _outerClipper = ClippingNode::create();
    _outerClipper->retain();
    AffineTransform tranform = AffineTransform::IDENTITY;
    tranform = AffineTransformScale(tranform, target->getScale(), target->getScale());

    _outerClipper->setContentSize( SizeApplyAffineTransform(target->getContentSize(), tranform));
    _outerClipper->setAnchorPoint( Vec2(0.5, 0.5) );
    _outerClipper->setPosition(Vec2(this->getContentSize()) * 0.5f);
    _outerClipper->runAction(RepeatForever::create(RotateBy::create(1, 45)));
    
    _outerClipper->setStencil( target );
    
    auto holesClipper = ClippingNode::create();
    holesClipper->setInverted(true);
    holesClipper->setAlphaThreshold( 0.05f );
    
    holesClipper->addChild(target);
    
    _holes = Node::create();
    _holes->retain();
    
    holesClipper->addChild(_holes);
    
    _holesStencil = Node::create();
    _holesStencil->retain();
    
    holesClipper->setStencil( _holesStencil);
    
    _outerClipper->addChild(holesClipper);
    
    this->addChild(_outerClipper);
    
    auto listener = EventListenerTouchAllAtOnce::create();
    listener->onTouchesBegan = CC_CALLBACK_2(HoleDemo::onTouchesBegan, this);
    _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
}
Esempio n. 8
0
bool ScrollText::initClipper( cocos2d::Sprite* &pMask,cocos2d::Node* &pMoveChild)
{
	auto clipper = ClippingNode::create();
	IF_RETURN_FALSE(!clipper);
	IF_RETURN_FALSE(!pMask);
	setContentSize(pMask->getContentSize());
	IF_RETURN_FALSE(!pMask->getTexture());
	auto _clipperStencil = Sprite::createWithTexture(pMask->getTexture());
	//_clipperStencil->setAnchorPoint((0.5,0.5));
	IF_RETURN_FALSE(!_clipperStencil);
	_clipperStencil->retain();
	clipper->setAlphaThreshold(0.1f);
	clipper->setStencil(_clipperStencil);
	clipper->addChild(pMoveChild,1);
	addChild(clipper);
	for (auto child:_mNodes)
	{
		IF_RETURN_FALSE(!child);
		clipper->addChild(child);
	}
	return true;
}
Esempio n. 9
0
ClippingNode* SpriteNoAlphaTest::clipper()
{
    auto clipper = SpriteTest::clipper();
    clipper->setAlphaThreshold(1);
    return clipper;
}
Esempio n. 10
0
ClippingNode* SpriteTest::clipper()
{
    auto clipper = BasicTest::clipper();
    clipper->setAlphaThreshold(0.05f);
    return clipper;
}
Esempio n. 11
0
bool HelloWorld::init()
{

	if ( !Layer::init() )
	{
		return false;
	}

	CReadFile::getInstance()->init();

	Size visibleSize = Director::getInstance()->getVisibleSize();
	Vec2 origin = Director::getInstance()->getVisibleOrigin();

	auto closeItem = MenuItemImage::create(
		"picture/blue1_menu.png",
		"picture/blue2_menu.png" 
		, CC_CALLBACK_1(HelloWorld::menuCloseCallback, this));
	closeItem->setScale(0.3f);
	closeItem->setPosition(Vec2(origin.x + visibleSize.width - closeItem->getContentSize().width/2-310 ,
		origin.y + closeItem->getContentSize().height/2+160));

	auto closeItem1 = MenuItemImage::create(
		"picture/blue1_menu.png",
		"picture/blue2_menu.png",
		CC_CALLBACK_1(HelloWorld::menuCloseCallback1, this));

	closeItem1->setScale(0.5f);

	closeItem1->setPosition(Vec2(origin.x + visibleSize.width - closeItem1->getContentSize().width/2-310 ,
		origin.y + closeItem1->getContentSize().height/2+330));

	auto SetMenu = MenuItemImage::create(
		"picture/shezhi2_cover.png",
		"picture/shezhi1_cover.png",
		CC_CALLBACK_1(HelloWorld::menuCloseCallback3, this));
	SetMenu->setScale(0.8f);

	SetMenu->setPosition(Vec2(origin.x + visibleSize.width - SetMenu->getContentSize().width/2-390 ,
		origin.y + SetMenu->getContentSize().height/2+260));

	auto menu = Menu::create(closeItem,closeItem1,SetMenu, NULL);
	menu->setPosition(Vec2::ZERO);		
	this->addChild(menu, 1);
#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
	auto label = Label::createWithTTF(Tools::Unicode2Utf8(L"开始游戏"), "fonts/msyh.ttc", 24);
#else
	auto label = Label::createWithTTF("开始游戏", "fonts/msyh.ttc", 24);
#endif
	label->setPosition(Vec2(closeItem1->getPositionX(), closeItem1->getPositionY()));
	label->setScale(0.8f);
	this->addChild(label, 1);
#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
	auto label1 = Label::createWithTTF(Tools::Unicode2Utf8(L"退出"), "fonts/msyh.ttc", 24);
#else
	auto label1 = Label::createWithTTF("退出", "fonts/msyh.ttc", 24);
#endif
	label1->setPosition(Vec2(closeItem->getPositionX(), closeItem->getPositionY()));
	label1->setScale(0.8f);
	this->addChild(label1,1);

	auto sprite = Sprite::create("picture/shumabaobei.jpg");

	Size sprSize = sprite->getContentSize();

	sprite->setScaleX(visibleSize.width/sprSize.width);
	sprite->setScaleY(visibleSize.height/sprSize.height);
	sprite->setPosition(Vec2(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
	this->addChild(sprite, 0);	

	auto logo = Sprite::create("picture/logo.png");
	Size logoSize = logo->getContentSize();

	auto spark = Sprite::create("picture/spark.png");
	spark->setPosition(-logoSize.width,0);
	auto clippingNode = ClippingNode::create();
	clippingNode->setPosition(500,560);
	this->addChild(clippingNode);
	clippingNode->setAlphaThreshold(0.05f);
	clippingNode->setContentSize(logoSize);

	clippingNode->setStencil(logo);
	clippingNode->addChild(logo,1);
	clippingNode->addChild(spark,2);

	auto moveAction = MoveTo::create(2.0f,Vec2(logoSize.width,0));
	auto moveBackAction = MoveTo::create(2.0f,Vec2(-logoSize.width,0));
	spark->runAction(RepeatForever::create(Sequence::create(moveAction,moveBackAction,NULL)));
	if (CReadFile::getInstance()->getshuomingkg())
	{
		CReadFile::getInstance()->setshuomingkg(false);
		CSound::getInstance()->playBG("Butter-Fly.mp3",CSound::getInstance()->getIsPlay());
		CSound::getInstance()->setIsPlay(true);


		auto shuominglayer = LayerColor::create(Color4B(120,120,120,200));
#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
		auto wenzi = Label::createWithTTF(Tools::Unicode2Utf8(L"欢迎来到宝库设计的数码宝贝记忆消除游戏"),"fonts/msyh.ttc", 28);
#else
		auto wenzi = Label::createWithTTF("欢迎来到宝库设计的数码宝贝记忆消除游戏","fonts/msyh.ttc", 28);
#endif
		wenzi->setMaxLineWidth(460);
		wenzi->setLineBreakWithoutSpace(true);
		wenzi->setPosition(480,520);
		wenzi->setColor(ccc3(0,0,0));
		shuominglayer->runAction(FadeOut::create(5));
		wenzi->runAction(FadeOut::create(3));
		shuominglayer->addChild(wenzi,2);
		this->addChild(shuominglayer,2);
	}
	return true;
}