1. 程式人生 > >cocos2d-x觸控點使精靈移動到觸控點的位置

cocos2d-x觸控點使精靈移動到觸控點的位置

程式碼

auto target = static_cast<Sprite*>(event->getCurrentTarget());
//獲取觸控事件
Point locationInNode = target->convertToNodeSpace(touch->getLocation());
//轉換座標點
auto curveMove = MoveTo::create(0.5f,locationInNode);
//移動事件
this->getChildByTag(150)->runAction(curveMove);
//獲取精靈標籤已經賦予動作事件