基于cocos2d和C++的项目----保卫萝卜(纪念部分内容

1.4图片背景交替变换

	float tt = 2.0f;
	Sprite* splash = Sprite::create("splash_fall.png");
	splash->setPosition(Vec2(480, 320));
	this->addChild(splash);
	splash->runAction(
		RepeatForever::create(
		Sequence::create(
		FadeOut::create(tt),
		DelayTime::create(tt),
		CallFunc::create([splash](){splash->setTexture("splash_fall.png"); }),
		FadeIn::create(tt),
		DelayTime::create(tt),
		FadeOut::create(tt),
		DelayTime::create(tt),
		CallFunc::create([splash](){splash->setTexture("splash_spring.png"); }),
		FadeIn::create(tt),
		DelayTime::create(tt),
		nullptr
		)));
	Sprite* splash2 = Sprite::create("splash_summer.png");
	splash2->setPosition(Vec2(480, 320));
	splash2->setOpacity(0);
	this->addChild(splash2);
	splash2->runAction(
		RepeatForever::create(
		Sequence::create(
		CallFunc::create([splash2](){splash2->setTexture("splash_summer.png"); }),
		FadeIn::create(tt),
		DelayTime::create(tt),
		FadeOut::create(tt),
		DelayTime::create(tt),
		CallFunc::create([splash2](){splash2->setTexture("splash_winter.png"); }),
		FadeIn::create(tt),
		DelayTime::create(tt),
		FadeOut::create(tt),
		DelayTime::create(tt),
		nullptr
		)));

2.子弹降速

if (bullet->type == SHIT)
			{
				static float newspeed1 = bullet->target->speed * 0.8;
				bullet->target->speed = newspeed1;
				Sprite* bshit = Sprite::create("bullet/PShit-11.png");
				bshit->setPosition(Vec2(30, 0));
				bullet->target->addChild(bshit);
			}

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值