void MovieClip::finalize() { switch (type_) { case eFrame: maxframe_ = 1; break; case eTime: maxframe_ = 0; break; } for (std::size_t i = 0; i < frames_.size(); ++i) { allFrames_[frames_[i].start].push_back(&frames_[i]); maxframe_ = std::max(maxframe_, frames_[i].end); } switch (type_) { case eFrame: gotoAndPlay(1); break; case eTime: gotoAndPlay(0); break; } }
bool GAFObject::gotoAndPlay(const std::string& frameLabel) { uint32_t f = getStartFrame(frameLabel); if (IDNONE == f) { uint32_t frameNumber = atoi(frameLabel.c_str()); if (frameNumber == 0) { return false; } return gotoAndPlay(frameNumber - 1); } return gotoAndPlay(f); }
SWFAction action_in_frame4() { SWFAction ac; ac = compileSWFActionCode(" \ if ( ++loop_back < 2 ) gotoAndPlay(2); \ " ); return ac; }
bool GAFAnimation::gotoAndPlay(const char * frameLabel) { int f = getStartFrame(frameLabel); if (-1 == f) { return false; } return gotoAndPlay(f); }
SWFAction action_in_frame4() { SWFAction ac; ac = compileSWFActionCode(" \ if ( ++loop_back < 2 ) gotoAndPlay(2); \ else { _root.totals(); stop(); } \ " ); return ac; }
/** * Play the animation from the current position. */ void Animation::play() { if (_animationDataList.size() == 0) { return; } if(!_lastAnimationState) { gotoAndPlay(_animationDataList[0]->name); } else if (!_isPlaying) { _isPlaying = true; } else { gotoAndPlay(_lastAnimationState->name); } }
void CCTween::gotoAndPause(int frameIndex) { gotoAndPlay(frameIndex); pause(); }
void ArmatureAnimation::gotoAndPause(int frameIndex) { gotoAndPlay(frameIndex); pause(); }
void GAFObject::realizeFrame(cocos2d::Node* out, uint32_t frameIndex) { const AnimationFrames_t& animationFrames = m_timeline->getAnimationFrames(); if (animationFrames.size() <= frameIndex) { return; } GAFAnimationFrame *currentFrame = animationFrames[frameIndex]; const GAFAnimationFrame::SubobjectStates_t& states = currentFrame->getObjectStates(); for (const GAFSubobjectState* state : states) { GAFObject* subObject = m_displayList[state->objectIdRef]; CCASSERT(subObject, "Error. SubObject with current ID not found"); if (!subObject) continue; if (state->colorMults()[GAFColorTransformIndex::GAFCTI_A] >= 0.f && subObject->m_isInResetState) { subObject->m_currentFrame = subObject->m_currentSequenceStart; } subObject->m_isInResetState = state->colorMults()[GAFColorTransformIndex::GAFCTI_A] < 0.f; if (!state->isVisible()) continue; if (subObject->m_charType == GAFCharacterType::Timeline) { if (!subObject->m_isInResetState) { cocos2d::AffineTransform stateTransform = state->affineTransform; float csf = m_timeline->usedAtlasScale(); stateTransform.tx *= csf; stateTransform.ty *= csf; cocos2d::AffineTransform t = GAF_CGAffineTransformCocosFormatFromFlashFormat(state->affineTransform); subObject->setAdditionalTransform(t); subObject->m_parentFilters.clear(); const Filters_t& filters = state->getFilters(); subObject->m_parentFilters.insert(subObject->m_parentFilters.end(), filters.begin(), filters.end()); const float* cm = state->colorMults(); subObject->m_parentColorTransforms[0] = cocos2d::Vec4( m_parentColorTransforms[0].x * cm[0], m_parentColorTransforms[0].y * cm[1], m_parentColorTransforms[0].z * cm[2], m_parentColorTransforms[0].w * cm[3]); subObject->m_parentColorTransforms[1] = cocos2d::Vec4(state->colorOffsets()) + m_parentColorTransforms[1]; if (m_masks[state->objectIdRef]) { rearrangeSubobject(out, m_masks[state->objectIdRef], state->zIndex); } else { //subObject->removeFromParentAndCleanup(false); if (state->maskObjectIdRef == IDNONE) { rearrangeSubobject(out, subObject, state->zIndex); } else { // If the state has a mask, then attach it // to the clipping node. Clipping node will be attached on its state auto mask = m_masks[state->maskObjectIdRef]; CCASSERT(mask, "Error. No mask found for this ID"); if (mask) rearrangeSubobject(mask, subObject, state->zIndex); } } subObject->step(); } } else if (subObject->m_charType == GAFCharacterType::Texture) { cocos2d::Vect prevAP = subObject->getAnchorPoint(); cocos2d::Size prevCS = subObject->getContentSize(); #if ENABLE_RUNTIME_FILTERS if (subObject->m_objectType == GAFObjectType::MovieClip) { // Validate sprite type (w/ or w/o filter) const Filters_t& filters = state->getFilters(); GAFFilterData* filter = NULL; GAFMovieClip* mc = static_cast<GAFMovieClip*>(subObject); if (m_parentFilters.size() > 0) { filter = *m_parentFilters.begin(); } else if (filters.size() > 0) { filter = *filters.begin(); } if (filter) { filter->apply(mc); } if (!filter || filter->getType() != GAFFilterType::GFT_Blur) { mc->setBlurFilterData(nullptr); } if (!filter || filter->getType() != GAFFilterType::GFT_ColorMatrix) { mc->setColorMarixFilterData(nullptr); } if (!filter || filter->getType() != GAFFilterType::GFT_Glow) { mc->setGlowFilterData(nullptr); } if (!filter || filter->getType() != GAFFilterType::GFT_DropShadow) { GAFDropShadowFilterData::reset(mc); } } #endif cocos2d::Size newCS = subObject->getContentSize(); cocos2d::Vect newAP = cocos2d::Vect(((prevAP.x - 0.5f) * prevCS.width) / newCS.width + 0.5f, ((prevAP.y - 0.5f) * prevCS.height) / newCS.height + 0.5f); subObject->setAnchorPoint(newAP); if (m_masks[state->objectIdRef]) { rearrangeSubobject(out, m_masks[state->objectIdRef], state->zIndex); } else { //subObject->removeFromParentAndCleanup(false); if (state->maskObjectIdRef == IDNONE) { rearrangeSubobject(out, subObject, state->zIndex); } else { // If the state has a mask, then attach it // to the clipping node. Clipping node will be attached on its state auto mask = m_masks[state->maskObjectIdRef]; CCASSERT(mask, "Error. No mask found for this ID"); if (mask) rearrangeSubobject(mask, subObject, state->zIndex); } } cocos2d::AffineTransform stateTransform = state->affineTransform; float csf = m_timeline->usedAtlasScale(); stateTransform.tx *= csf; stateTransform.ty *= csf; cocos2d::AffineTransform t = GAF_CGAffineTransformCocosFormatFromFlashFormat(state->affineTransform); if (isFlippedX() || isFlippedY()) { float flipMulX = isFlippedX() ? -1 : 1; float flipOffsetX = isFlippedX() ? getContentSize().width - m_asset->getHeader().frameSize.getMinX() : 0; float flipMulY = isFlippedY() ? -1 : 1; float flipOffsetY = isFlippedY() ? -getContentSize().height + m_asset->getHeader().frameSize.getMinY() : 0; cocos2d::AffineTransform flipCenterTransform = cocos2d::AffineTransformMake(flipMulX, 0, 0, flipMulY, flipOffsetX, flipOffsetY); t = AffineTransformConcat(t, flipCenterTransform); } subObject->setExternalTransform(t); if (subObject->m_objectType == GAFObjectType::MovieClip) { GAFMovieClip* mc = static_cast<GAFMovieClip*>(subObject); float colorMults[4] = { state->colorMults()[0] * m_parentColorTransforms[0].x, state->colorMults()[1] * m_parentColorTransforms[0].y, state->colorMults()[2] * m_parentColorTransforms[0].z, state->colorMults()[3] * m_parentColorTransforms[0].w }; float colorOffsets[4] = { state->colorOffsets()[0] + m_parentColorTransforms[1].x, state->colorOffsets()[1] + m_parentColorTransforms[1].y, state->colorOffsets()[2] + m_parentColorTransforms[1].z, state->colorOffsets()[3] + m_parentColorTransforms[1].w }; mc->setColorTransform(colorMults, colorOffsets); } } else if (subObject->m_charType == GAFCharacterType::TextField) { GAFTextField *tf = static_cast<GAFTextField*>(subObject); rearrangeSubobject(out, subObject, state->zIndex); cocos2d::AffineTransform stateTransform = state->affineTransform; float csf = m_timeline->usedAtlasScale(); stateTransform.tx *= csf; stateTransform.ty *= csf; cocos2d::AffineTransform t = GAF_CGAffineTransformCocosFormatFromFlashFormat(state->affineTransform); if (isFlippedX() || isFlippedY()) { float flipMulX = isFlippedX() ? -1 : 1; float flipOffsetX = isFlippedX() ? getContentSize().width - m_asset->getHeader().frameSize.getMinX() : 0; float flipMulY = isFlippedY() ? -1 : 1; float flipOffsetY = isFlippedY() ? -getContentSize().height + m_asset->getHeader().frameSize.getMinY() : 0; cocos2d::AffineTransform flipCenterTransform = cocos2d::AffineTransformMake(flipMulX, 0, 0, flipMulY, flipOffsetX, flipOffsetY); t = AffineTransformConcat(t, flipCenterTransform); } subObject->setExternalTransform(t); } if (state->isVisible()) { subObject->m_lastVisibleInFrame = frameIndex + 1; } } GAFAnimationFrame::TimelineActions_t timelineActions = currentFrame->getTimelineActions(); for (GAFTimelineAction action : timelineActions) { switch (action.getType()) { case GAFActionType::Stop: pauseAnimation(); break; case GAFActionType::Play: resumeAnimation(); break; case GAFActionType::GotoAndStop: gotoAndStop(action.getParam(GAFTimelineAction::PI_FRAME)); break; case GAFActionType::GotoAndPlay: gotoAndPlay(action.getParam(GAFTimelineAction::PI_FRAME)); break; case GAFActionType::DispatchEvent: _eventDispatcher->dispatchCustomEvent(action.getParam(GAFTimelineAction::PI_EVENT_TYPE), &action); break; case GAFActionType::None: default: break; } } }
void ofxMovieClip<ImageType>::gotoAndPlay(string frameLabel, int frameNumber) { loopComplete = false; frameLabelId = imageSequence->getAssetsId(frameLabel); activeAsset = imageSequence->assetCollections[frameLabelId]; gotoAndPlay(frameNumber); }