22#include <kiwano/math/Math.h>
23#include <kiwano/core/Time.h>
24#include <kiwano/base/ObjectBase.h>
25#include <kiwano/base/component/ComponentManager.h>
26#include <kiwano/event/EventDispatcher.h>
27#include <kiwano/utils/TaskScheduler.h>
28#include <kiwano/2d/animation/Animator.h>
38typedef IntrusiveList<RefPtr<Actor>> ActorList;
92 bool IsVisible()
const;
96 bool IsCascadeOpacityEnabled()
const;
100 bool IsEventDispatchEnabled()
const;
104 size_t GetHashName()
const;
108 int GetZOrder()
const;
112 virtual Point GetPosition()
const;
116 float GetPositionX()
const;
120 float GetPositionY()
const;
124 virtual Size GetSize()
const;
128 float GetWidth()
const;
132 float GetHeight()
const;
136 float GetScaledWidth()
const;
140 float GetScaledHeight()
const;
144 Size GetScaledSize()
const;
148 virtual Point GetAnchor()
const;
152 float GetAnchorX()
const;
156 float GetAnchorY()
const;
160 virtual float GetOpacity()
const;
164 float GetDisplayedOpacity()
const;
168 virtual float GetRotation()
const;
172 virtual Point GetScale()
const;
176 float GetScaleX()
const;
180 float GetScaleY()
const;
184 virtual Point GetSkew()
const;
188 float GetSkewX()
const;
192 float GetSkewY()
const;
200 Actor* GetParent()
const;
204 Stage* GetStage()
const;
208 virtual Rect GetBounds()
const;
212 virtual Rect GetBoundingBox()
const;
216 const Matrix3x2& GetTransformMatrix()
const;
220 const Matrix3x2& GetTransformInverseMatrix()
const;
224 const Matrix3x2& GetTransformMatrixToParent()
const;
228 void SetVisible(
bool val);
236 virtual void SetPosition(
const Point& point);
240 void SetPosition(
float x,
float y);
244 void SetPositionX(
float x);
248 void SetPositionY(
float y);
252 void MoveTo(
const Point& p);
256 void MoveTo(
float x,
float y);
260 void MoveBy(
const Vec2& trans);
264 void MoveBy(
float trans_x,
float trans_y);
268 virtual void SetScale(
const Vec2& scale);
272 void SetScale(
float scalex,
float scaley);
276 virtual void SetSkew(
const Vec2& skew);
280 void SetSkew(
float skewx,
float skewy);
284 virtual void SetRotation(
float rotation);
288 virtual void SetAnchor(
const Vec2& anchor);
292 void SetAnchor(
float anchorx,
float anchory);
296 virtual void SetSize(
const Size& size);
300 void SetSize(
float width,
float height);
304 void SetWidth(
float width);
308 void SetHeight(
float height);
312 virtual void SetOpacity(
float opacity);
316 void SetCascadeOpacityEnabled(
bool enabled);
320 void SetTransform(
const Transform& transform);
324 void SetZOrder(
int zorder);
344 Vector<RefPtr<Actor>> GetChildren(
StringView name)
const;
364 void RemoveAllChildren();
368 void RemoveFromParent();
372 void PauseUpdating();
376 void ResumeUpdating();
380 bool IsUpdatePausing()
const;
392 virtual bool ContainsPoint(
const Point& point)
const;
396 Point ConvertToLocal(
const Point& point)
const;
400 Point ConvertToWorld(
const Point& point)
const;
404 void ShowBorder(
bool show);
410 virtual bool DispatchEvent(
Event* evt);
415 bool HandleEvent(
Event* evt);
420 void SetEventDispatchEnabled(
bool enabled);
424 void DoSerialize(
Serializer* serializer)
const override;
428 void DoDeserialize(
Deserializer* deserializer)
override;
432 static void SetDefaultAnchor(
float anchor_x,
float anchor_y);
457 void UpdateTransform()
const;
462 void UpdateTransformUpwards()
const;
466 void UpdateOpacity();
474 void SetStage(
Stage* stage);
478 bool update_pausing_;
479 bool cascade_opacity_;
481 bool evt_dispatch_enabled_;
482 mutable bool visible_in_rt_;
484 enum DirtyFlag : uint8_t
488 DirtyTransformInverse = 1 << 1,
489 DirtyOpacity = 1 << 2,
490 DirtyVisibility = 1 << 3
496 float displayed_opacity_;
503 UpdateCallback cb_update_;
507 mutable Matrix3x2 transform_matrix_inverse_;
508 mutable Matrix3x2 transform_matrix_to_parent_;
530 return cascade_opacity_;
535 return evt_dispatch_enabled_;
565 return transform_.
scale;
580 return transform_.
skew;
650 return displayed_opacity_;
670 update_pausing_ =
true;
675 update_pausing_ =
false;
680 return update_pausing_;
UpdateCallback GetCallbackOnUpdate() const
获取更新时的回调函数
Definition: Actor.h:688
Transform GetTransform() const
获取变换
Definition: Actor.h:653
Function< void(Duration)> UpdateCallback
角色更新回调函数
Definition: Actor.h:71
virtual void SetSize(const Size &size)
修改大小
Definition: Actor.cpp:421
bool IsVisible() const
获取显示状态
Definition: Actor.h:523
float GetPositionX() const
获取 x 坐标
Definition: Actor.h:553
virtual void OnRender(RenderContext &ctx)
渲染角色
Definition: Actor.h:518
virtual Point GetSkew() const
获取错切角度
Definition: Actor.h:578
bool IsCascadeOpacityEnabled() const
是否启用级联透明度
Definition: Actor.h:528
void MoveTo(const Point &p)
移动至坐标
Definition: Actor.h:713
virtual void SetPosition(const Point &point)
设置坐标
Definition: Actor.cpp:447
Stage * GetStage() const
获取所在舞台
Definition: Actor.h:663
float GetAnchorY() const
获取 y 方向锚点
Definition: Actor.h:638
size_t GetHashName() const
获取名称的 Hash 值
Definition: Actor.h:538
void SetCallbackOnUpdate(const UpdateCallback &cb)
设置更新时的回调函数
Definition: Actor.h:683
Actor * GetParent() const
获取父角色
Definition: Actor.h:658
virtual Point GetPosition() const
获取坐标
Definition: Actor.h:548
Size GetScaledSize() const
获取缩放后的大小
Definition: Actor.h:623
float GetDisplayedOpacity() const
获取显示透明度
Definition: Actor.h:648
virtual void SetSkew(const Vec2 &skew)
设置错切角度,默认为 (0, 0)
Definition: Actor.cpp:465
virtual void SetScale(const Vec2 &scale)
设置缩放比例,默认为 (1.0, 1.0)
Definition: Actor.cpp:456
bool IsUpdatePausing() const
角色更新是否暂停
Definition: Actor.h:678
float GetScaleY() const
获取纵向缩放比例
Definition: Actor.h:573
virtual Point GetAnchor() const
获取锚点
Definition: Actor.h:628
int GetZOrder() const
获取 Z 轴顺序
Definition: Actor.h:543
float GetScaledHeight() const
获取缩放后的高度
Definition: Actor.h:618
float GetSkewX() const
获取横向错切角度
Definition: Actor.h:583
void SetWidth(float width)
修改宽度
Definition: Actor.h:748
float GetScaleX() const
获取横向缩放比例
Definition: Actor.h:568
void ResumeUpdating()
继续角色更新
Definition: Actor.h:673
virtual Size GetSize() const
获取大小
Definition: Actor.h:608
void SetHeight(float height)
修改高度
Definition: Actor.h:753
float GetAnchorX() const
获取 x 方向锚点
Definition: Actor.h:633
void MoveBy(const Vec2 &trans)
移动相对坐标
Definition: Actor.h:723
bool IsEventDispatchEnabled() const
是否启用事件分发
Definition: Actor.h:533
float GetScaledWidth() const
获取缩放后的宽度
Definition: Actor.h:613
void ShowBorder(bool show)
渲染角色边界
Definition: Actor.h:693
virtual float GetOpacity() const
获取透明度
Definition: Actor.h:643
void SetPositionX(float x)
设置横坐标
Definition: Actor.h:703
float GetSkewY() const
获取纵向错切角度
Definition: Actor.h:588
float GetPositionY() const
获取 y 坐标
Definition: Actor.h:558
void PauseUpdating()
暂停角色更新
Definition: Actor.h:668
float GetWidth() const
获取宽度
Definition: Actor.h:598
virtual void OnUpdate(Duration dt)
更新角色
Definition: Actor.h:513
virtual void SetAnchor(const Vec2 &anchor)
设置锚点位置,默认为 (0, 0), 范围 [0, 1]
Definition: Actor.cpp:412
virtual float GetRotation() const
获取旋转角度
Definition: Actor.h:593
float GetHeight() const
获取高度
Definition: Actor.h:603
void SetPositionY(float y)
设置纵坐标
Definition: Actor.h:708
virtual Point GetScale() const
获取缩放比例
Definition: Actor.h:563
动画调度器
Definition: Animator.h:37
组件管理器
Definition: ComponentManager.h:42
导演
Definition: Director.h:38
事件分发器
Definition: EventDispatcher.h:36
Definition: Function.h:228
侵入式链表元素
Definition: IntrusiveList.h:434
侵入式链表
Definition: IntrusiveList.h:34
基础对象
Definition: ObjectBase.h:138
引用计数智能指针
Definition: RefBasePtr.hpp:35
渲染上下文
Definition: RenderContext.h:62
任务调度器
Definition: TaskScheduler.h:36
舞台过渡动画
Definition: Transition.h:45
反序列化器
Definition: Serializable.h:147
时间段
Definition: Duration.h:48
序列化器
Definition: Serializable.h:40