Kiwano Engine v1.3.x
PathAnimation.h
1// Copyright (c) 2016-2018 Kiwano - Nomango
2//
3// Permission is hereby granted, free of charge, to any person obtaining a copy
4// of this software and associated documentation files (the "Software"), to deal
5// in the Software without restriction, including without limitation the rights
6// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7// copies of the Software, and to permit persons to whom the Software is
8// furnished to do so, subject to the following conditions:
9//
10// The above copyright notice and this permission notice shall be included in
11// all copies or substantial portions of the Software.
12//
13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19// THE SOFTWARE.
20
21#pragma once
22#include <kiwano/2d/animation/TweenAnimation.h>
23#include <kiwano/render/Shape.h>
24
25namespace kiwano
26{
34class KGE_API PathAnimation : public TweenAnimation
35{
36public:
44 PathAnimation(Duration duration, RefPtr<Shape> path, bool rotating = false, float start = 0.f, float end = 1.f);
45
48 RefPtr<Shape> GetPath() const;
49
52 bool IsRotating() const;
53
56 float GetStartValue() const;
57
60 float GetEndValue() const;
61
64 void SetPath(RefPtr<Shape> path);
65
68 void SetRotating(bool rotating);
69
72 void SetStartValue(float start);
73
76 void SetEndValue(float end);
77
80 PathAnimation* Clone() const override;
81
84 PathAnimation* Reverse() const override;
85
86protected:
87 void Init(Actor* target) override;
88
89 void UpdateTween(Actor* target, float percent) override;
90
91private:
92 bool rotating_;
93 float start_;
94 float end_;
95 float length_;
96 Point start_pos_;
97 RefPtr<Shape> path_;
98};
99
103{
104 return path_;
105}
106
107inline bool PathAnimation::IsRotating() const
108{
109 return rotating_;
110}
111
113{
114 return start_;
115}
116
117inline float PathAnimation::GetEndValue() const
118{
119 return end_;
120}
121
123{
124 path_ = path;
125}
126
127inline void PathAnimation::SetRotating(bool rotating)
128{
129 rotating_ = rotating;
130}
131
132inline void PathAnimation::SetStartValue(float start)
133{
134 start_ = start;
135}
136
137inline void PathAnimation::SetEndValue(float end)
138{
139 end_ = end;
140}
141
142} // namespace kiwano
角色
Definition: Actor.h:63
路径行走动画
Definition: PathAnimation.h:35
float GetEndValue() const
获取路径终点(百分比)
Definition: PathAnimation.h:117
float GetStartValue() const
获取路径起点(百分比)
Definition: PathAnimation.h:112
bool IsRotating() const
是否沿路径切线方向旋转
Definition: PathAnimation.h:107
RefPtr< Shape > GetPath() const
获取路线
Definition: PathAnimation.h:102
void SetEndValue(float end)
设置路径终点(百分比)
Definition: PathAnimation.h:137
void SetPath(RefPtr< Shape > path)
设置路径形状
Definition: PathAnimation.h:122
void SetRotating(bool rotating)
设置沿路径切线方向旋转
Definition: PathAnimation.h:127
void SetStartValue(float start)
设置路径起点(百分比)
Definition: PathAnimation.h:132
引用计数智能指针
Definition: RefBasePtr.hpp:35
补间动画
Definition: TweenAnimation.h:37
时间段
Definition: Duration.h:48