Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@tks2shimizu
Created January 13, 2013 15:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tks2shimizu/4524527 to your computer and use it in GitHub Desktop.
Save tks2shimizu/4524527 to your computer and use it in GitHub Desktop.
パーティクルの表示
#include "HelloWorldScene.h"
#include "SimpleAudioEngine.h"
using namespace cocos2d;
using namespace CocosDenshion;
CCScene* HelloWorld::scene()
{
CCScene *scene = CCScene::create();
HelloWorld *layer = HelloWorld::create();
scene->addChild(layer);
return scene;
}
bool HelloWorld::init()
{
if ( !CCLayer::init() )
{
return false;
}
this->setTouchEnabled(true);
this->setTouchMode(kCCTouchesOneByOne);
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
//パーティクルを表示
particle = CCParticleSystemQuad::create("particle1.plist");
particle->setPosition(ccp(winSize.width / 2,
winSize.height / 2));
this->addChild(particle);
return true;
}
bool HelloWorld::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent)
{
return true;
}
void HelloWorld::ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent)
{
// タップポイント取得
CCDirector* pDirector = CCDirector::sharedDirector();
CCPoint touchPoint = pDirector->convertToGL(pTouch->getLocationInView());
// タップ位置へパーティクルを移動
particle->setPosition(touchPoint);
}
//#ifndef __HELLOWORLD_SCENE_H__
//#define __HELLOWORLD_SCENE_H__
#include "cocos2d.h"
class HelloWorld : public cocos2d::CCLayer
{
private:
cocos2d::CCParticleSystemQuad* particle;
public:
virtual bool init();
static cocos2d::CCScene* scene();
CREATE_FUNC(HelloWorld);
virtual bool ccTouchBegan(cocos2d::CCTouch *pTouch, cocos2d::CCEvent *pEvent);
virtual void ccTouchMoved(cocos2d::CCTouch *pTouch, cocos2d::CCEvent *pEvent);
};
//#endif // __HELLOWORLD_SCENE_H__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment