Cocos2d-3.x 开机logo动画实例
【摘要】
1.淡入淡出动画
最近在做一个项目,分享给大家一个不错的例子,我们可以用这个模板去设计我们的游戏开机动画哦。
2.效果如下
3.例子如下
AppDelegate加入如下代码,记住导入LogoScene的头文件
// cr...
1.淡入淡出动画
最近在做一个项目,分享给大家一个不错的例子,我们可以用这个模板去设计我们的游戏开机动画哦。
2.效果如下
3.例子如下
AppDelegate加入如下代码,记住导入LogoScene的头文件
-
// create a scene. it's an autorelease object
-
auto scene = LogoScene::createScene();
-
-
// run
-
director->runWithScene(scene);
-
return true;
//LogoScene类
-
#include "LogoScene.h"
-
#include "AppDelegate.h"
-
-
-
-
USING_NS_CC;
-
-
Scene* LogoScene::createScene()
-
{
-
auto scene = Scene::create();
-
auto layer = LogoScene::create();
-
auto s = Director::getInstance()->getVisibleSize();
-
//开机第一张图片,选择自己喜欢的图片哦
-
Sprite* pSprite = Sprite::create("logo_telecom.png");
-
-
if (pSprite)
-
{
-
//屏幕的位置
-
pSprite->setPosition(s.width/2,s.height/2);
-
//99号节点
-
layer->addChild(pSprite, 0, 99);
-
}
-
-
scene->addChild(layer);
-
return scene;
-
}
-
-
// on "init" you need to initialize your instance
-
bool LogoScene::init()
-
{
-
if ( !Layer::init() )
-
{
-
return false;
-
}
-
auto pCCLayerColor = LayerColor::create(Color4B(255, 255, 255, 255));
-
addChild(pCCLayerColor);
-
scheduleOnce(schedule_selector(LogoScene::logoshowCallback), 1.0f);
-
return true;
-
}
-
-
-
void LogoScene::logoshowCallback(float temp)
-
{
-
{
-
//背景图淡入消去
-
Sprite* pSprite = (Sprite*)(getChildByTag(99));
-
FadeOut* pAction = FadeOut::create(0.625f);
-
pSprite->runAction(pAction);
-
}
-
-
auto pCCLayerColor = LayerColor::create(Color4B(255, 255, 255, 255));
-
{
-
//延迟纯白色背景加载0.625秒动作
-
addChild(pCCLayerColor);
-
pCCLayerColor->setOpacity(0);
-
DelayTime* pAction1 = DelayTime::create(0.625f);
-
FadeIn* pAction2 = FadeIn::create(0.625f);
-
//DelayTime* pAction3 = DelayTime::create(1.0f);
-
pCCLayerColor->runAction(Sequence::create(pAction1, pAction2, NULL));
-
}
-
-
auto s = Director::getInstance()->getVisibleSize();
-
//logo的图片
-
Sprite* pSprite = Sprite::create("gamedo.png");
-
{
-
pSprite->setPosition(s.width / 2, s.height / 2);
-
pCCLayerColor->addChild(pSprite);
-
pSprite->setOpacity(0);
-
DelayTime* pAction1 = DelayTime::create(0.625f);
-
FadeIn* pAction2 = CCFadeIn::create(0.625f);
-
//DelayTime* pAction3 = DelayTime::create(1.0f);
-
pSprite->runAction(Sequence::create(pAction1, pAction2, NULL));
-
}
-
-
scheduleOnce(schedule_selector(LogoScene::logoshowOver), 2.00f);
-
}
-
-
void LogoScene::logoshowOver(float temp)
-
{
-
//场景迁移 ,这里我们以后可以单独做一个 控制场景迁移的类
-
//CCDirector::sharedDirector()->replaceScene(MainScene::Create());
-
-
}
不懂的大家可以在下面留言哦~
文章来源: yujiang.blog.csdn.net,作者:鱼酱2333,版权归原作者所有,如需转载,请联系作者。
原文链接:yujiang.blog.csdn.net/article/details/51511423
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)