关于cocos2d-x中的一些动作的简单使用(淡入淡出,贝塞尔曲线等)

关于cocos2d-x中的一些动作的简单使用(淡入淡出,贝塞尔曲线等),第1张

概述Size size = Director::getInstance()->getWinSize(); auto sprite3 = Sprite::create("4.png"); sprite3->setPosition(size.width/2, size.height/2); this->addChild(sprite3); auto sprite = Sprite::create
Size size = Director::getInstance()->getWinSize();	auto sprite3 = Sprite::create("4.png");	sprite3->setposition(size.wIDth/2,size.height/2);	this->addChild(sprite3);	auto sprite = Sprite::create("paoku00188.png");	sprite->setposition(300,300);	this->addChild(sprite);	auto animation = Animation::create();	for (int i = 188; i <= 199; i++)	{	std::string str = StringUtils::format("paoku00%d.png",i);	animation->addSpriteFrameWithfile(str);	}	animation->setDelayPerUnit(0.05);//间隔时间	animation->setLoops(-1);//播放的次数	auto animate = Animate::create(animation);// 	auto pointa = PointArray::create(10);// 	pointa->addControlPoint(Point(100,0));// 	pointa->addControlPoint(Point(100,100));	//auto mov = CardinalSplineBy::create(5,pointa,1);	ccBezIErConfig ccbe = {Point(900,300),Point(400,400),Point(800,200)};	auto pointa=BezIErTo:: create(2,ccbe);	auto act = Spawn::create(animate,nullptr);	sprite->runAction(act);	auto sprite1 = Sprite::create("Closenormal.png");	sprite1->setposition(100,100);	//sprite1->setVisible(false);	//sprite1->setopacity(0);	sprite1->setAnchorPoint(Point(0,0));	this->addChild(sprite1);	//vectArray->push_back(sprite1);		for (int i = 0; i < 10; i++)	{		Point p(rand() % 960,rand() % 640);		sp2 = Sprite::create("Closenormal.png");		sp2->setposition(p);		this->addChild(sp2);	}	auto spt1 = Sprite::create("Closenormal.png");	spt1->setposition(size.wIDth / 2,size.height / 2);	this->addChild(spt1);	auto spt2 = Sprite::create("Closenormal.png");	spt2->setposition(size.wIDth / 2,size.height / 2);	this->addChild(spt2);	auto spt3 = Sprite::create("Closenormal.png");	spt3->setposition(size.wIDth / 2,size.height / 2);	this->addChild(spt3);	auto spt4 = Sprite::create("Closenormal.png");	spt4->setposition(size.wIDth / 2,size.height / 2);	this->addChild(spt4);	auto sprite2 = Sprite::create("Closenormal.png");	sprite2->setposition(100,200);	this->addChild(sprite2);	//vectArray->push_back(sprite2);	auto item = MenuItemFont::create("out",[=](Ref* f){		//淡出		auto fadeout = FadeOut::create(2);		sprite1->runAction(fadeout);			});	auto item2 = MenuItemFont::create("in",[=](Ref* f){		//淡入		auto fadein = FadeIn::create(3);		sprite1->runAction(fadein);		//auto act1 = RotateBy::create(3,-360 * 10);			});	auto item3 = MenuItemFont::create("moveBy",[=](Ref*f){				auto moveb = MoveBy::create(3,0));				sprite1->runAction(moveb);// 		auto moveb = Moveto::create(3,500));// 		sprite1->runAction(moveb);	});	auto item4 = MenuItemFont::create("jumpBy",[=](Ref*f){		auto jumpb = JumpBy::create(1,Point(100,0),50,2);		//sprite1->runAction(jumpb);		//闪烁		auto blink = Blink::create(2,2);		//sprite1->runAction(blink);		auto aa = DelayTime::create(2);//间隔时间		auto sq = Sequence::create(jumpb,aa,blink,nullptr);				sprite1->runAction(sq);	});	auto item5 = MenuItemFont::create("suijiMove",[=](Ref*f){		Point p(rand()%960,rand()%640);		auto moveb = Moveto::create(3,p);		sprite1->runAction(moveb);			});	auto item6 = MenuItemFont::create("disappear",[=](Ref*f){				Point p(rand() % 960,rand() % 640);		auto moveb = Moveto::create(3,p);		//sprite1->runAction(moveb);				sprite2->runAction(moveb);		auto sp1 = sprite1->getBoundingBox();		auto sp2 = sprite2->getBoundingBox();		if (sp1.intersectsRect(sp2))		{			sprite1->removeFromParentAndCleanup(true);			sprite2->removeFromParentAndCleanup(true);		}	});	auto item7 = MenuItemFont::create("disappearTen",[=](Ref*f){		Point p(rand() % 960,rand() % 640);		//Point p1(CCRANDOM_0_1*size.wIDth,CCRANDOM_0_1*size.height);		auto moveb = Moveto::create(3,p);		auto act = JumpBy::create(1,Point(0,100,1);		sprite1->runAction(act);			});	auto item8 = MenuItemFont::create("back",[=](Ref*f){		auto act = Moveto::create(1,Point(200,100));		auto act1 = DelayTime::create(1);		auto act2 = JumpTo::create(2,100),2);		//stopAction(act2);		auto sq = Sequence::create(act,act1,act2,nullptr);				sprite1->runAction(sq);	});	auto item9 = MenuItemFont::create("bingxingRun",[=](Ref* f){		auto act1 = RotateBy::create(3,-360 * 10);		//auto act1 = RotateBy::create(3,Vertex3F(0,360,0));//Vertex3F		auto act2 = ScaleBy::create(3,0.2);//放大		auto act3 = MoveBy::create(3,Point(300,0));		auto act = Spawn::create(act1,act3,nullptr);		sprite1->runAction(act);	});	auto item10 = MenuItemFont::create("fangda",[=](Ref* f){		auto act2 = Scaleto::create(3,1.5);		auto act3 = RotateBy::create(2,360*10);		auto act4 = Spawn::create(act2,nullptr);//并行		sprite3->runAction(act4);	});	auto item11 = MenuItemFont::create("zuhe",[=](Ref* f){		SimpleAudioEngine::getInstance()->playBackgroundMusic("11.mp3");		//auto act33 = DelayTime::create(3);		auto act1 = Moveto::create(3,100)); 		auto act2 = JumpTo::create(3,1);		auto act3 = RotateBy::create(3,3600));		auto Call = CallFuncN::create([](Node* node){			SimpleAudioEngine::getInstance()->playEffect("11.mp3");		});		auto act4 = Sequence::create(act1,Call,nullptr);//过程执行		auto reps = Repeat::create(act4,4);//循环动画		sprite1->runAction(reps);	});	auto item12 = MenuItemFont::create("CallFuncN",[=](Ref* f){		//水平与垂直翻转		auto fx = FlipX::create(true);		auto fy = FlipY::create(true);		auto act = Sequence::create(fx,fy,nullptr);		sprite1->runAction(act);		//动画回调		auto actMove = MoveBy:: create(2,Point(500,0));		auto actCall = CallFuncN::create([](Node* node){			node->removeFromParentAndCleanup(true);		});		auto actSque = Sequence::create(actMove,actCall,nullptr);		sprite1->runAction(actSque);	});	auto item13 = MenuItemFont::create("CallFuncNN",[=](Ref* f){		auto spt1Move = Moveto::create(2,Point(60,40));		auto act1Call = CallFuncN::create([=](Node* node){			auto act2Call = CallFuncN::create([=](Node* node){				auto act3Call = CallFuncN::create([=](Node* node){					auto spt4Move = Moveto::create(2,600));					spt4->runAction(spt4Move);				});				auto spt3Move = Moveto::create(2,Point(900,600));				auto b = Sequence::create(spt3Move,act3Call,nullptr);				spt3->runAction(b);			});			auto spt2Move = Moveto::create(2,40));			auto a = Sequence::create(spt2Move,act2Call,nullptr);			spt2->runAction(a);		});		auto act = Sequence::create(spt1Move,act1Call,nullptr);		spt1->runAction(act);	});	auto item14 = MenuItemFont::create("zhendonghua",[=](Ref* f){			});	Menu* menu = Menu::create(item,item2,item3,item4,item5,item6,item7,item8,item9,item10,item11,item12,item13,item14,nullptr);	this->addChild(menu);	menu->alignItemsvertically();

都是一些简单的动作使用,我就不具体的说明了啊 。

总结

以上是内存溢出为你收集整理的关于cocos2d-x中的一些动作的简单使用(淡入淡出,贝塞尔曲线等)全部内容,希望文章能够帮你解决关于cocos2d-x中的一些动作的简单使用(淡入淡出,贝塞尔曲线等)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1026282.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存