0
爲什麼在cocos2dx中拖動一個精靈非常困難!這樣做在我的touchesBegan方法讓一個精靈出現在觸摸的地方並將其拖拽到
void HelloWorld::ccTouchesBegan(cocos2d::CCSet* touches, cocos2d::CCEvent* event){
CCSprite *splash = CCSprite::spriteWithFile("splash3.png");
CCTouch* pTouch = (CCTouch*)(touches->anyObject());
CCPoint location = pTouch->locationInView();
location = CCDirector::sharedDirector()->convertToGL(location);
splash->setPosition(ccp(location.x,location.y));
this->addChild(splash,5);
}
void HelloWorld::ccTouchesMoved(cocos2d::CCSet* touches, cocos2d::CCEvent* event){
CCSprite *splash = CCSprite::spriteWithFile("splash3.png");
CCTouch* pTouch = (CCTouch*)(touches->anyObject());
CCPoint location = pTouch->locationInView();
location = CCDirector::sharedDirector()->convertToGL(location);
splash->setPosition(ccp(location.x,location.y));
this->addChild(splash,5);
}
我究竟做錯了什麼,並更多的工作要做?並有一個更簡單的方法來做到這一點?