coco2d-x中引用离子效果,游戏计数的方法
来源:互联网 发布:极品飞车ol mac 编辑:程序博客网 时间:2024/05/02 03:00
引用粒子效果主要是在游戏中实现例如炸弹爆炸效果的实现,首先可以利用离子编辑器编辑你需要的效果,这里给大家推荐一款软件——particle designer 这款软件可以进行编辑离子效果,我用的还不错。
这里给大家贴一段代码 第一段是普通的动画实现效果,第二段是离子编辑效果。
Boom * Boom::createBoom(int type,int x,int y){
Boom * newB=Boom::create();å
Sprite * sp=nullptr;
//添加纹理和动画
switch (type) {
case 1://第一种爆炸效果
{sp=Sprite::create("boom.png",Rect(0,0,44,49));
sp->setPosition(x,y);
sp->setScale(2);
newB->addChild(sp);
Vector<SpriteFrame*> allframe;
for (int i=0; i<7; i++) {
SpriteFrame* sf=SpriteFrame::create("boom.png",
Rect(i*44,0,44,49));
allframe.pushBack(sf);
}
auto animation=Animation::createWithSpriteFrames(allframe);
animation->setDelayPerUnit(0.05);
auto ani=Animate::create(animation);
//action 序列
auto act=Sequence::create(ani,CallFunc::create(CC_CALLBACK_0(Boom::killMe, newB)), NULL);
sp->runAction(act);
}
break;
case2://第2种爆炸效果
{
auto particle=ParticleSystemQuad::create("boom1.plist");
newB->addChild(particle);
particle->setPosition(x,y);
//action 序列
auto act=Sequence::create(DelayTime::create(1),CallFunc::create(CC_CALLBACK_0(Boom::killMe, newB)), NULL);
newB->runAction(act);
}
break;
}
return newB;
需要注意的事这两端代码都需要进行回掉
void Boom::killMe(){
this->removeFromParentAndCleanup(true);
进行释放 2计数
首先引入ui组件
#include"cocosGui.h" uisng namespace ui;
调用 TextAtlas组件在Game.h中 int m_score;
在 Game.cpp中初始化分数 m_score=0
case 1:this->m_score+=100;
case2:this->m_score+=300;
this->m_score=0;
auto tscore=TextAtlas::create("0","",,“0”);//这里的零我忘什么意思了 明天解释
this->addChild(tscore)
tscore->setTag(111);
auto score==(TextAtals*)this->getChildByTag(111);
char ms[15="0000000"
int tmp=m_score/100;
int end =6;
while tmp!0){
ms[end]='/0'
tmp=tmp /10;
end--;
score->setstring(String Utils::format(%s%d,ms,m_score);
}
- coco2d-x中引用离子效果,游戏计数的方法
- coco2d-x 游戏背景音乐的添加
- iOS中影响引用计数的方法
- COCO2D-X中ScrollView的使用实现
- 游戏客户端之内存管理(cocos2d-x 引用计数)
- coco2d-x 实现风雪飘动效果
- coco2d-x 实现风雪飘动效果
- 最近很火的手机游戏都是Coco2d-x做的吗、看着很牛的样子哇
- cocos2d-x-3.1 vs 输出Log的几种方法 (coco2d-x 学习笔记三)
- coco2d-x 中box2d选中刚体
- coco2d-x 3.0游戏实例学习笔记 《跑酷》 第二步---游戏界面&全新的3.0物理世界
- Objective C 中NSNumber的引用计数
- php中$this的引用计数
- php中$this的引用计数
- coco2d-x 使用Action中的Animate实现动画效果
- 查看变量引用计数及是否引用的方法
- coco2d-x开发之文字的设置
- 读coco2d-x里的hellolua
- android-关于处理Bitmap
- Windows XP硬盘安装Ubuntu 12.04双系统图文详解
- 转:模板类中重载<<和>>操作符
- KMP资料
- Filter基础
- coco2d-x中引用离子效果,游戏计数的方法
- 001_你使用过Objective-C的运行时编程(Runtime Programming)么?如果使用过,你用它做了什么?你还能记得你所使用的相关的头文件或者某些方法的名称吗?
- Frequent values - POJ 3368 RMQ
- (转)OC学习那些事:Block
- QT Creator使用共享库(一)创建共享库
- C++设计模式之原型模式
- 014写程序将一个栈按升序排序,对这个栈是如何实现的,你不应该做任何特殊的假设(keep it up)
- 【leetcode】Jump Game I, II 跳跃游戏一和二
- NYOJ 295 取余(大数取余)