Cocos2d-x3.1粒子使用
2014-09-04 00:18
197 查看
1、头文件
#include "cocos2d.h"
USING_NS_CC;
class WaterWaveDemo : public Layer
{
public:
static cocos2d::Scene* createScene();
// Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
virtual bool init();
// a selector callback
void menuCloseCallback(cocos2d::Ref* pSender);
// implement the "static create()" method manually
CREATE_FUNC(WaterWaveDemo);
};
2、cpp文件
#include "WaterWaveDemo.h"
#include "SimpleAudioEngine.h"
using namespace CocosDenshion;
Scene* WaterWaveDemo::createScene()
{
// 'scene' is an autorelease object
auto scene = Scene::create();
// 'layer' is an autorelease object
auto layer = WaterWaveDemo::create();
// add layer as a child to scene
scene->addChild(layer);
// return the scene
return scene;
}
bool WaterWaveDemo::init()
{
bool bRet = false;
do{
CC_BREAK_IF(!Layer::init());
auto listener = EventListenerTouchOneByOne::create();
listener->setSwallowTouches(true);
listener->onTouchBegan = [&](Touch* touch,Event* event){
auto touchPosition = touch->getLocation();
ParticleSystemQuad* mParticle = ParticleSystemQuad::create("showClick.plist");
mParticle->setScale(0.5);
mParticle->setPosition(touchPosition);
mParticle->setAutoRemoveOnFinish(true);
addChild(mParticle);
return false;
};
Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener, this);
bRet = true;
}while(0);
return bRet;
}
void WaterWaveDemo::menuCloseCallback(Ref* pSender)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
MessageBox("You pressed the close button. Windows Store Apps do not implement a close button.","Alert");
return;
#endif
Director::getInstance()->end();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
exit(0);
#endif
}代码下载:http://download.csdn.net/detail/yuxikuo_1/7861203
#include "cocos2d.h"
USING_NS_CC;
class WaterWaveDemo : public Layer
{
public:
static cocos2d::Scene* createScene();
// Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
virtual bool init();
// a selector callback
void menuCloseCallback(cocos2d::Ref* pSender);
// implement the "static create()" method manually
CREATE_FUNC(WaterWaveDemo);
};
2、cpp文件
#include "WaterWaveDemo.h"
#include "SimpleAudioEngine.h"
using namespace CocosDenshion;
Scene* WaterWaveDemo::createScene()
{
// 'scene' is an autorelease object
auto scene = Scene::create();
// 'layer' is an autorelease object
auto layer = WaterWaveDemo::create();
// add layer as a child to scene
scene->addChild(layer);
// return the scene
return scene;
}
bool WaterWaveDemo::init()
{
bool bRet = false;
do{
CC_BREAK_IF(!Layer::init());
auto listener = EventListenerTouchOneByOne::create();
listener->setSwallowTouches(true);
listener->onTouchBegan = [&](Touch* touch,Event* event){
auto touchPosition = touch->getLocation();
ParticleSystemQuad* mParticle = ParticleSystemQuad::create("showClick.plist");
mParticle->setScale(0.5);
mParticle->setPosition(touchPosition);
mParticle->setAutoRemoveOnFinish(true);
addChild(mParticle);
return false;
};
Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener, this);
bRet = true;
}while(0);
return bRet;
}
void WaterWaveDemo::menuCloseCallback(Ref* pSender)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
MessageBox("You pressed the close button. Windows Store Apps do not implement a close button.","Alert");
return;
#endif
Director::getInstance()->end();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
exit(0);
#endif
}代码下载:http://download.csdn.net/detail/yuxikuo_1/7861203
相关文章推荐
- cocos2d-x学习笔记14:粒子系统1:简介&工具使用
- Cocos2d-x常用函数:随机函数,数据显示,动画播放,CCMenuItemToggle,使用粒子
- cocos2d-js 粒子系统使用自定义图片,还原原来的图片宽高
- Cocos2d-x 粒子编辑器使用和渲染特效
- Cocos2d-x3.1 HttpClient封装与使用
- 在cocos2d中使用粒子系统
- Cocos2d-x 3.0 开发(十二)在CocoStudio中使用粒子挂载与曲线动画
- Cocos2d-x3.1中ClippingNode的使用实例
- 使用 Cocos2d-x 和粒子编辑器实现“天天爱消除”场景特效
- 使用XCode6.0.1将Cocos2d-x3.1工程打包ipa(支持iOS8)
- Cocos2d-x 3.0 开发(十二)在CocoStudio中使用粒子挂载与曲线动画
- Cocos2d-x3.1 粒子效果示例
- 使用 Cocos2d-x 和粒子编辑器实现“天天爱消除”场景特效
- Cocos2d-x3.1中DrawNode的使用
- Cocos2d-x3.1中ListView的使用
- 在cocos2d中使用粒子系统
- 粒子效果CCParticleSystemQuad粒子编辑器ParticleEditor的使用---cocos2d-x学习之路[5]
- Cocos2d Particle Builder粒子编辑器的使用
- Cocos2d-x 3.0 开发(十二)在CocoStudio中使用粒子挂载与曲线动画
- 使用 Cocos2d-x 和粒子编辑器实现