cocos2d-x tips(二)关于cocosbuilder中的动画和2dx的action同时正常运行的问题
2013-05-01 16:11
513 查看
目前这个问题有些博客上有解决方案,不过并不完美。
http://jetion.diandian.com/post/2012-12-04/40047798280
如这位的解决方案
这样可以解决根节点的动画与2dx的action同时运作,但是无法解决子节点的问题。
完整的修改方案还需要增加这个部分的修改
以及
http://jetion.diandian.com/post/2012-12-04/40047798280
如这位的解决方案
这样可以解决根节点的动画与2dx的action同时运作,但是无法解决子节点的问题。
完整的修改方案还需要增加这个部分的修改
void CCBAnimationManager::runAction(CCNode *pNode, CCBSequenceProperty *pSeqProp, float fTweenDuration) { CCArray *keyframes = pSeqProp->getKeyframes(); int numKeyframes = keyframes->count(); if (numKeyframes > 1) { // Make an animation! CCArray *actions = CCArray::create(); CCBKeyframe *keyframeFirst = (CCBKeyframe*)keyframes->objectAtIndex(0); float timeFirst = keyframeFirst->getTime() + fTweenDuration; if (timeFirst > 0) { actions->addObject(CCDelayTime::create(timeFirst)); } for (int i = 0; i < numKeyframes - 1; ++i) { CCBKeyframe *kf0 = (CCBKeyframe*)keyframes->objectAtIndex(i); CCBKeyframe *kf1 = (CCBKeyframe*)keyframes->objectAtIndex(i+1); CCActionInterval *action = getAction(kf0, kf1, pSeqProp->getName(), pNode); if (action) { // Apply easing action = getEaseAction(action, kf0->getEasingType(), kf0->getEasingOpt()); actions->addObject(action); } } CCFiniteTimeAction *seq = CCSequence::create(actions); // 修改 const int childActionTag = 200; seq->setTag(childActionTag); pNode->runAction(seq); } }
以及
void CCBAnimationManager::runAnimationsForSequenceIdTweenDuration(int nSeqId, float fTweenDuration) { CCAssert(nSeqId != -1, "Sequence id couldn't be found"); // 修改部分 const int currentActionTag = 1000; mRootNode->stopActionByTag(currentActionTag); //mRootNode->stopAllActions(); CCDictElement* pElement = NULL; CCDICT_FOREACH(mNodeSequences, pElement) { CCNode *node = (CCNode*)pElement->getIntKey(); // 修改部分 const int childActionTag = 200; node->stopActionByTag(childActionTag); //node->stopAllActions(); // Refer to CCBReader::readKeyframe() for the real type of value CCDictionary *seqs = (CCDictionary*)pElement->getObject(); CCDictionary *seqNodeProps = (CCDictionary*)seqs->objectForKey(nSeqId); set<string> seqNodePropNames; if (seqNodeProps) { // Reset nodes that have sequence node properties, and run actions on them CCDictElement* pElement1 = NULL; CCDICT_FOREACH(seqNodeProps, pElement1) { const char *propName = pElement1->getStrKey(); CCBSequenceProperty *seqProp = (CCBSequenceProperty*)seqNodeProps->objectForKey(propName); seqNodePropNames.insert(propName); setFirstFrame(node, seqProp, fTweenDuration); runAction(node, seqProp, fTweenDuration); } } // Reset the nodes that may have been changed by other timelines CCDictionary *nodeBaseValues = (CCDictionary*)mBaseValues->objectForKey(pElement->getIntKey()); if (nodeBaseValues) { CCDictElement* pElement2 = NULL; CCDICT_FOREACH(nodeBaseValues, pElement2) { if (seqNodePropNames.find(pElement2->getStrKey()) == seqNodePropNames.end()) { CCObject *value = pElement2->getObject(); if (value) { setAnimatedProperty(pElement2->getStrKey(), node, value, fTweenDuration); } } } } } // Make callback at end of sequence CCBSequence *seq = getSequence(nSeqId); CCAction *completeAction = CCSequence::createWithTwoActions(CCDelayTime::create(seq->getDuration() + fTweenDuration), CCCallFunc::create(this, callfunc_selector(CCBAnimationManager::sequenceCompleted))); // 修改部分 completeAction->setTag(currentActionTag); mRootNode->runAction(completeAction); // Set the running scene if(seq->getCallbackChannel() != NULL) { CCAction* action = (CCAction *)actionForCallbackChannel(seq->getCallbackChannel()); if(action != NULL) { mRootNode->runAction(action); } } if(seq->getSoundChannel() != NULL) { CCAction* action = (CCAction *)actionForSoundChannel(seq->getSoundChannel()); if(action != NULL) { mRootNode->runAction(action); } } mRunningSequence = getSequence(nSeqId); }
相关文章推荐
- cocos2d-x-2.0.4中使用CocosBuilder创建动画注意的问题
- cocos2d-x js binding tips 1 使用cocosbuilder导入jsb后无法响应触摸的问题
- 关于Cocos2d-x2.1.x与CocosBuilder3.0a 的自动资源目录摆放
- 关于java路径的获取问题,保证部署(jar)到机器上正常运行
- 关于Cocos2d-x中获取正在播放动画第几帧的问题
- 工作中遇到的问题(cocos2d-x cocosbuilder 以及周边工具)
- 文件问题cocos2d-x&cocosbuilder折腾记
- 使用CocosBuilder2.1结合cocos2d-x2.0.3创建动画场景
- 关于cocosbuilder,引入ccbfile后,播放的问题。
- COCOS2D-X 关于 fatal error C1083: 无法打开包括文件:“CCStdC.h” 的问题(同时避免copy文件夹和库)
- 如何使用CocosBuilder2.1结合cocos2d-x2.0.3创建动画场景 分享0
- Cocos2d-x——CocosBuilder官方帮助文档翻译3 动画
- 关于BHO不能够正常运行的问题!
- 关于http协议在windos 的vs下面正常运行,在Mac下的xcode运行不报错,但不成功的问题
- cocos2d-x tips(一)关于tilemap滚动时黑线闪动的问题
- 关于Android6.0以上动态获取运行时权限、及无法正常运行百度地图API的问题
- 使用CocosBuilder2.1结合cocos2d-x2.0.3创建动画场景
- 关于Debug版正常运行,release版运行崩溃的问题
- 关于Dev c++ 不能在Win8系统下正常编译、运行的问题
- 在cocos2d-js 中 手动播放cocos builder 编辑的动画