void TestScene::Play(Animation *animation, float fps) { this->fps = fps; currentAnimation = animation; animationFrame = 0.0f; isPlaying = true; ApplyFrame(); }
void SkeletController::ChangeData( const SkeletonDataPtr& data ) { sb_assert(data); if (m_data) { if (m_animation) { m_animation = data->GetAnimation( m_animation->GetName() ).get(); } } m_data = data; m_crnt_frame = 0; m_frame_time = 0; ApplyFrame(); }
bool SkeletController::Update(float dt) { if (m_animation && m_started) { bool stop = false; m_frame_time += dt; size_t frames_drop = m_frame_time * m_animation->GetFPS(); size_t from_frame = m_crnt_frame; m_crnt_frame += frames_drop; m_frame_time -= float(frames_drop) / m_animation->GetFPS(); if (m_crnt_frame >= m_animation->GetFrames()){ if (m_loop != 1) { m_crnt_frame = m_crnt_frame % m_animation->GetFrames(); EmmitEvents(from_frame,m_animation->GetFrames()); EmmitEvents(0,m_crnt_frame); if (m_loop > 0) { m_loop--; } } else { m_crnt_frame = m_animation->GetFrames() - 1; EmmitEvents(from_frame,m_animation->GetFrames()); ApplyFrame(); stop = true; if (m_end_signal) { m_end_signal->Emmit(); } m_started = false; if (!m_added_animations.empty()) { StartAnimation(m_added_animations.front().name.c_str(), m_added_animations.front().loop); m_added_animations.pop_front(); stop = false; } } } else { EmmitEvents(from_frame,m_crnt_frame); } ApplyFrame(); } return false; }
void TestScene::UpdateAnimation(Animation *animation) { if (isPlaying) { animationFrame += Monocle::deltaTime * fps; if (animationFrame > animation->GetMaxFrames()-1) { animationFrame = animation->GetMaxFrames()-1; Pause(); } ApplyFrame(); } }
void TestScene::GoPrevFrame(int num) { DeleteOnionSkins(); animationFrame = int(animationFrame) - num; if (animationFrame < 0) { animationFrame = 0; } ApplyFrame(); CreateOnionSkins(); StoreBackupPartFrame(); }
void TestScene::GoNextFrame(int num) { DeleteOnionSkins(); animationFrame = int(animationFrame) + num; if (animationFrame > currentAnimation->GetMaxFrames()-1) { animationFrame = currentAnimation->GetMaxFrames()-1; } ApplyFrame(); CreateOnionSkins(); StoreBackupPartFrame(); }
void SkeletController::SetAnimation(const char *name) { m_animation = m_data->GetAnimation(name).get(); m_crnt_frame = 0; m_frame_time = 0; ApplyFrame(); }
void SkeletController::SetFrame(size_t frame) { if (!m_animation) return; m_crnt_frame = frame % m_animation->GetFrames(); ApplyFrame(); }