Cocos2d-x_播放帧动画

来源:互联网 发布:js跨域cookie 编辑:程序博客网 时间:2024/04/30 16:00
void HelloWorld::mcallBack(CCObject *pSend){CCSprite *pSpr = (CCSprite *)pSend;pSpr->removeFromParentAndCleanup(true);}bool HelloWorld::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent){CCLOG(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");CCPoint pt = pTouch->getLocation();CCSpriteFrameCache *cache = CCSpriteFrameCache::sharedSpriteFrameCache();cache->addSpriteFramesWithFile("frame_ani/pointer.plist", "frame_ani/pointer.png");CCSprite *light = CCSprite::create();light->setPosition(pt);this->addChild(light);CCArray *spriteArray = CCArray::create();char str[100] = { 0 };for (int i = 1; i <= 9; i++){sprintf(str, "pointer/%02d.png", i);CCSpriteFrame *frame = cache->spriteFrameByName(str);spriteArray->addObject(frame);}CCAnimation *animation = CCAnimation::createWithSpriteFrames(spriteArray, 0.05f);CCAnimate *animate = CCAnimate::create(animation);CCFiniteTimeAction *actSeq = CCSequence::create(animate, CCCallFuncO::create(this, callfuncO_selector(HelloWorld::mcallBack), light), NULL);light->runAction(actSeq);return true;}

0 0
原创粉丝点击