void HelloWorld::updateSpeed() { CCXLOG("%d", speedY); if (isJumping) { if (speedY == 1 ) { armature->getAnimation()->playTo("fall"); } speedY -= 1; } if (speedX != 0) { armature->getDisplay()->setPositionX( armature->getDisplay()->getPositionX() + speedX ) ; if (armature->getDisplay()->getPositionX() < 0) { armature->getDisplay()->setPositionX( 0 ); } else if (armature->getDisplay()->getPositionX() > 800) { armature->getDisplay()->setPositionX( 800 ); } } if (speedY != 0) { armature->getDisplay()->setPositionY( armature->getDisplay()->getPositionY() + speedY ) ; if (armature->getDisplay()->getPositionY() <150) { armature->getDisplay()->setPositionY( 150 ); isJumping = false; speedY = 0; } } }
void CCConnectionData::decodeAnimations(TiXmlElement *_animationsXML){ TiXmlElement *_animationXML = _animationsXML->FirstChildElement(ANIMATION); while (_animationXML) { const char* _name = _animationXML->Attribute(A_NAME); CCArmatureAniData *_aniData = (CCArmatureAniData*)mAnimationDatas->objectForKey(_name); if (_aniData) { CCXLOG("CCArmatureAniData (%s) is already exit", _name); return; } _aniData = CCArmatureAniData::create(); mAnimationDatas->setObject( _aniData, _name); TiXmlElement* _movement = _animationXML->FirstChildElement(MOVEMENT); while( _movement ) { const char* _aniName; const char* _boneName; CCBoneAniData* _boneAniData = NULL; _aniName = _movement->Attribute(A_NAME); _boneAniData = CCBoneAniData::create(); _aniData->addAnimation(_aniName, _boneAniData); int _duration, _durationTo, _durationTween, _loop = 0; float _tweenEasing = 0.0f; if( _movement->QueryIntAttribute(A_DURATION, &(_duration)) == TIXML_SUCCESS){ _boneAniData->setDuration(_duration); } if( _movement->QueryIntAttribute(A_DURATION_TO, &(_durationTo)) == TIXML_SUCCESS){ _boneAniData->setDurationTo(_durationTo); } if( _movement->QueryIntAttribute(A_DURATION_TWEEN, &(_durationTween)) == TIXML_SUCCESS){ _boneAniData->setDurationTween(_durationTween); } if( _movement->QueryIntAttribute(A_LOOP, &(_loop)) == TIXML_SUCCESS){ _boneAniData->setLoop((bool)_loop); } if( _movement->QueryFloatAttribute(A_TWEEN_EASING, &(_tweenEasing)) == TIXML_SUCCESS){ _boneAniData->setTweenEasing(_tweenEasing); } TiXmlElement *_bone = _movement->FirstChildElement(BONE); while(_bone) { _boneName = _bone->Attribute(A_NAME); //CCXLOG(_boneName); if (_boneAniData->getAnimation(_boneName)) { _bone = _bone->NextSiblingElement(); continue; } _boneAniData->addAnimation(getFrameNodeList(_bone, _boneName), _boneName); _bone = _bone->NextSiblingElement(BONE); } /*TiXmlElement *_eventFrameElement = _movement->FirstChildElement(EVENT_FRAME); if(_eventFrameElement) { CCEventFrame* _eventFrame; int _frame = 0; while( _eventFrameElement ) { int _frames; _eventFrameElement->QueryIntAttribute(FRAME, &_frames); _eventFrame = CCEventFrame::create(_eventFrameElement->Attribute(A_NAME), _frames); _boneAniData->getEventList()->addObject(_eventFrame); _frame += _eventFrame->getFrame(); _eventFrameElement = _eventFrameElement->NextSiblingElement(EVENT_FRAME); } _boneAniData->getEventList()->insertObject(CCEventFrame::create("init", _boneAniData->getFrame() - _frame), 0); }*/ _movement = _movement->NextSiblingElement(MOVEMENT); } _animationXML = _animationXML->NextSiblingElement(ANIMATION); } }