Magic_Game/src/kiwano/2d/Actor.h

697 lines
16 KiB
C
Raw Normal View History

2019-04-11 14:40:54 +08:00
// Copyright (c) 2016-2018 Kiwano - Nomango
2020-01-21 10:09:55 +08:00
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
2020-01-21 10:09:55 +08:00
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
2020-01-21 10:09:55 +08:00
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#pragma once
2020-01-09 08:45:00 +08:00
#include <kiwano/2d/action/ActionManager.h>
2020-01-21 10:09:55 +08:00
#include <kiwano/core/EventDispatcher.h>
#include <kiwano/core/ObjectBase.h>
#include <kiwano/core/Time.h>
#include <kiwano/core/TimerManager.h>
2020-02-15 17:32:32 +08:00
#include <kiwano/core/IntrusiveList.h>
2020-02-06 16:54:47 +08:00
#include <kiwano/math/Math.h>
2019-04-11 14:40:54 +08:00
namespace kiwano
{
2020-01-21 10:09:55 +08:00
class Stage;
class Director;
class RenderContext;
KGE_DECLARE_SMART_PTR(Actor);
/**
* \~chinese
2020-02-10 17:32:04 +08:00
* \defgroup Actors
2020-01-21 10:09:55 +08:00
*/
/**
* \addtogroup Actors
* @{
*/
/**
* \~chinese
2020-02-10 17:32:04 +08:00
* @brief
2020-01-21 10:09:55 +08:00
* @details
2020-02-10 17:32:04 +08:00
*
2020-01-21 10:09:55 +08:00
*/
class KGE_API Actor
: public virtual ObjectBase
, public TimerManager
, public ActionManager
, public EventDispatcher
2020-02-15 17:32:32 +08:00
, protected IntrusiveListValue<ActorPtr>
2020-01-21 10:09:55 +08:00
{
friend class Director;
friend class Transition;
friend IntrusiveList<ActorPtr>;
public:
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 子成员列表
2020-01-21 10:09:55 +08:00
using Children = IntrusiveList<ActorPtr>;
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 角色更新回调函数
2020-01-21 10:09:55 +08:00
using UpdateCallback = Function<void(Duration)>;
2020-02-06 16:54:47 +08:00
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 创建角色
2020-02-06 16:54:47 +08:00
static ActorPtr Create();
2020-01-21 10:09:55 +08:00
Actor();
virtual ~Actor();
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 更新角色
/// @details 每帧画面刷新前调用该函数,重载该函数以实现角色的更新处理
/// @param dt 距上一次更新的时间间隔
2020-01-21 10:09:55 +08:00
virtual void OnUpdate(Duration dt);
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 渲染角色
2020-01-21 10:09:55 +08:00
/// @details
2020-02-10 17:32:04 +08:00
/// 每帧画面刷新时调用该函数,默认不进行渲染,重载该函数以实现具体渲染过程
/// @param ctx 渲染上下文
2020-01-21 10:09:55 +08:00
virtual void OnRender(RenderContext& ctx);
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 获取显示状态
2020-01-21 10:09:55 +08:00
bool IsVisible() const;
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 获取响应状态
2020-01-21 10:09:55 +08:00
bool IsResponsible() const;
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 是否启用级联透明度
2020-01-21 10:09:55 +08:00
bool IsCascadeOpacityEnabled() const;
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 获取名称的 Hash 值
2020-01-21 10:09:55 +08:00
size_t GetHashName() const;
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 获取 Z 轴顺序
2020-01-21 10:09:55 +08:00
int GetZOrder() const;
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 获取坐标
2020-01-21 10:09:55 +08:00
Point const& GetPosition() const;
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 获取 x 坐标
2020-01-21 10:09:55 +08:00
float GetPositionX() const;
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 获取 y 坐标
2020-01-21 10:09:55 +08:00
float GetPositionY() const;
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 获取宽度
2020-01-21 10:09:55 +08:00
float GetWidth() const;
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 获取高度
2020-01-21 10:09:55 +08:00
float GetHeight() const;
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 获取大小
2020-01-21 10:09:55 +08:00
Size const& GetSize() const;
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 获取缩放后的宽度
2020-01-21 10:09:55 +08:00
float GetScaledWidth() const;
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 获取缩放后的高度
2020-01-21 10:09:55 +08:00
float GetScaledHeight() const;
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 获取缩放后的大小
2020-01-21 10:09:55 +08:00
Size GetScaledSize() const;
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 获取锚点
2020-01-21 10:09:55 +08:00
Point const& GetAnchor() const;
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 获取 x 方向锚点
2020-01-21 10:09:55 +08:00
float GetAnchorX() const;
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 获取 y 方向锚点
2020-01-21 10:09:55 +08:00
float GetAnchorY() const;
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 获取透明度
2020-01-21 10:09:55 +08:00
float GetOpacity() const;
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 获取显示透明度
2020-01-21 10:09:55 +08:00
float GetDisplayedOpacity() const;
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 获取旋转角度
2020-01-21 10:09:55 +08:00
float GetRotation() const;
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 获取缩放比例
2020-01-21 10:09:55 +08:00
Point const& GetScale() const;
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 获取横向缩放比例
2020-01-21 10:09:55 +08:00
float GetScaleX() const;
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 获取纵向缩放比例
2020-01-21 10:09:55 +08:00
float GetScaleY() const;
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 获取错切角度
2020-01-21 10:09:55 +08:00
Point const& GetSkew() const;
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 获取横向错切角度
2020-01-21 10:09:55 +08:00
float GetSkewX() const;
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 获取纵向错切角度
2020-01-21 10:09:55 +08:00
float GetSkewY() const;
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 获取变换
2020-01-21 10:09:55 +08:00
Transform GetTransform() const;
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 获取父角色
2020-01-21 10:09:55 +08:00
Actor* GetParent() const;
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 获取所在舞台
2020-01-21 10:09:55 +08:00
Stage* GetStage() const;
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 获取边框
2020-01-21 10:09:55 +08:00
virtual Rect GetBounds() const;
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 获取外切包围盒
2020-01-21 10:09:55 +08:00
virtual Rect GetBoundingBox() const;
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 获取二维变换矩阵
2020-01-21 10:09:55 +08:00
Matrix3x2 const& GetTransformMatrix() const;
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 获取二维变换的逆矩阵
2020-01-21 10:09:55 +08:00
Matrix3x2 const& GetTransformInverseMatrix() const;
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 设置角色是否可见
2020-01-21 10:09:55 +08:00
void SetVisible(bool val);
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 设置名称
2020-01-21 10:09:55 +08:00
void SetName(String const& name);
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 设置坐标
2020-01-21 10:09:55 +08:00
virtual void SetPosition(Point const& point);
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 设置坐标
2020-01-21 10:09:55 +08:00
void SetPosition(float x, float y);
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 设置横坐标
2020-01-21 10:09:55 +08:00
void SetPositionX(float x);
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 设置纵坐标
2020-01-21 10:09:55 +08:00
void SetPositionY(float y);
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 移动坐标
2020-01-21 10:09:55 +08:00
void Move(Vec2 const& v);
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 移动坐标
2020-01-21 10:09:55 +08:00
void Move(float vx, float vy);
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 设置缩放比例,默认为 (1.0, 1.0)
2020-01-21 10:09:55 +08:00
virtual void SetScale(Vec2 const& scale);
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 设置缩放比例,默认为 (1.0, 1.0)
2020-01-21 10:09:55 +08:00
void SetScale(float scalex, float scaley);
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 设置错切角度,默认为 (0, 0)
2020-01-21 10:09:55 +08:00
virtual void SetSkew(Vec2 const& skew);
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 设置错切角度,默认为 (0, 0)
2020-01-21 10:09:55 +08:00
void SetSkew(float skewx, float skewy);
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 设置旋转角度,默认为 0
2020-01-21 10:09:55 +08:00
virtual void SetRotation(float rotation);
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 设置锚点位置,默认为 (0, 0), 范围 [0, 1]
2020-01-21 10:09:55 +08:00
virtual void SetAnchor(Vec2 const& anchor);
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 设置锚点位置,默认为 (0, 0), 范围 [0, 1]
2020-01-21 10:09:55 +08:00
void SetAnchor(float anchorx, float anchory);
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 修改宽度
2020-01-21 10:09:55 +08:00
virtual void SetWidth(float width);
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 修改高度
2020-01-21 10:09:55 +08:00
virtual void SetHeight(float height);
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 修改大小
2020-01-21 10:09:55 +08:00
virtual void SetSize(Size const& size);
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 修改大小
2020-01-21 10:09:55 +08:00
void SetSize(float width, float height);
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 设置透明度,默认为 1.0, 范围 [0, 1]
2020-01-21 10:09:55 +08:00
virtual void SetOpacity(float opacity);
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 启用或禁用级联透明度
2020-01-21 10:09:55 +08:00
void SetCascadeOpacityEnabled(bool enabled);
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 设置二维仿射变换
2020-01-21 10:09:55 +08:00
void SetTransform(Transform const& transform);
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 设置 Z 轴顺序,默认为 0
2020-01-21 10:09:55 +08:00
void SetZOrder(int zorder);
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 设置角色是否可响应,默认为 false
/// @details 可响应的角色会收到鼠标的 Hover | Out | Click 消息
2020-01-21 10:09:55 +08:00
void SetResponsible(bool enable);
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 添加子角色
2020-01-21 10:09:55 +08:00
void AddChild(ActorPtr child, int zorder = 0);
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 添加子角色
2020-01-21 10:09:55 +08:00
void AddChild(Actor* child, int zorder = 0);
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 添加多个子角色
2020-01-21 10:09:55 +08:00
void AddChildren(Vector<ActorPtr> const& children);
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 获取名称相同的子角色
2020-02-15 17:32:32 +08:00
ActorPtr GetChild(String const& name) const;
2020-01-21 10:09:55 +08:00
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 获取所有名称相同的子角色
2020-01-21 10:09:55 +08:00
Vector<ActorPtr> GetChildren(String const& name) const;
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 获取全部子角色
2020-01-21 10:09:55 +08:00
Children& GetAllChildren();
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 获取全部子角色
2020-01-21 10:09:55 +08:00
Children const& GetAllChildren() const;
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 移除子角色
2020-01-21 10:09:55 +08:00
void RemoveChild(ActorPtr child);
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 移除子角色
2020-01-21 10:09:55 +08:00
void RemoveChild(Actor* child);
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 移除所有名称相同的子角色
2020-01-21 10:09:55 +08:00
void RemoveChildren(String const& child_name);
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 移除所有角色
2020-01-21 10:09:55 +08:00
void RemoveAllChildren();
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 从父角色移除
2020-01-21 10:09:55 +08:00
void RemoveFromParent();
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 暂停角色更新
2020-01-21 10:09:55 +08:00
void PauseUpdating();
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 继续角色更新
2020-01-21 10:09:55 +08:00
void ResumeUpdating();
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 角色更新是否暂停
2020-01-21 10:09:55 +08:00
bool IsUpdatePausing() const;
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 设置更新时的回调函数
2020-01-21 10:09:55 +08:00
void SetCallbackOnUpdate(UpdateCallback const& cb);
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 获取更新时的回调函数
2020-01-21 10:09:55 +08:00
UpdateCallback GetCallbackOnUpdate() const;
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 判断点是否在角色内
2020-01-21 10:09:55 +08:00
virtual bool ContainsPoint(const Point& point) const;
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 渲染角色边界
2020-01-21 10:09:55 +08:00
void ShowBorder(bool show);
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 分发事件
/// @param evt 事件
/// @return 是否继续分发该事件
2020-01-21 10:09:55 +08:00
virtual bool DispatchEvent(Event* evt);
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 设置默认锚点
2020-01-21 10:09:55 +08:00
static void SetDefaultAnchor(float anchor_x, float anchor_y);
protected:
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 更新自身和所有子角色
2020-01-21 10:09:55 +08:00
virtual void Update(Duration dt);
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 渲染自身和所有子角色
2020-01-21 10:09:55 +08:00
virtual void Render(RenderContext& ctx);
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 绘制自身和所有子角色的边界
2020-01-21 10:09:55 +08:00
virtual void RenderBorder(RenderContext& ctx);
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 检查是否在渲染上下文的视区内
2020-01-21 10:09:55 +08:00
virtual bool CheckVisibility(RenderContext& ctx) const;
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 渲染前初始化渲染上下文状态,仅当 CheckVisibility 返回真时调用该函数
2020-01-21 10:09:55 +08:00
virtual void PrepareToRender(RenderContext& ctx);
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 更新自己的二维变换,并通知所有子角色
2020-01-21 10:09:55 +08:00
void UpdateTransform() const;
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 更新自己和所有子角色的透明度
2020-01-21 10:09:55 +08:00
void UpdateOpacity();
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 将所有子角色按Z轴顺序排序
2020-01-21 10:09:55 +08:00
void Reorder();
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 设置节点所在舞台
2020-01-21 10:09:55 +08:00
void SetStage(Stage* stage);
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 处理事件
2020-01-21 10:09:55 +08:00
void HandleEvent(Event* evt);
private:
bool visible_;
bool update_pausing_;
bool cascade_opacity_;
bool show_border_;
bool hover_;
bool pressed_;
bool responsible_;
int z_order_;
float opacity_;
float displayed_opacity_;
Actor* parent_;
Stage* stage_;
size_t hash_name_;
Point anchor_;
Size size_;
Children children_;
UpdateCallback cb_update_;
Transform transform_;
bool is_fast_transform_;
mutable bool visible_in_rt_;
mutable bool dirty_visibility_;
mutable bool dirty_transform_;
mutable bool dirty_transform_inverse_;
mutable Matrix3x2 transform_matrix_;
mutable Matrix3x2 transform_matrix_inverse_;
};
/** @} */
inline void Actor::OnUpdate(Duration dt)
{
KGE_NOT_USED(dt);
}
inline void Actor::OnRender(RenderContext& ctx)
{
KGE_NOT_USED(ctx);
}
2020-01-21 10:09:55 +08:00
inline bool Actor::IsVisible() const
{
return visible_;
}
inline bool Actor::IsResponsible() const
{
return responsible_;
}
2019-07-29 13:42:13 +08:00
2020-01-21 10:09:55 +08:00
inline bool Actor::IsCascadeOpacityEnabled() const
{
return cascade_opacity_;
}
2020-01-09 08:45:00 +08:00
2020-01-21 10:09:55 +08:00
inline size_t Actor::GetHashName() const
{
return hash_name_;
}
2020-01-09 08:45:00 +08:00
2020-01-21 10:09:55 +08:00
inline int Actor::GetZOrder() const
{
return z_order_;
}
2020-01-09 08:45:00 +08:00
2020-01-21 10:09:55 +08:00
inline Point const& Actor::GetPosition() const
{
return transform_.position;
}
2020-01-09 08:45:00 +08:00
2020-01-21 10:09:55 +08:00
inline float Actor::GetPositionX() const
{
return GetPosition().x;
}
2020-01-09 08:45:00 +08:00
2020-01-21 10:09:55 +08:00
inline float Actor::GetPositionY() const
{
return GetPosition().y;
}
2020-01-09 08:45:00 +08:00
2020-01-21 10:09:55 +08:00
inline Point const& Actor::GetScale() const
{
return transform_.scale;
}
2020-01-09 08:45:00 +08:00
2020-01-21 10:09:55 +08:00
inline float Actor::GetScaleX() const
{
return GetScale().x;
}
2019-09-29 22:23:13 +08:00
2020-01-21 10:09:55 +08:00
inline float Actor::GetScaleY() const
{
return GetScale().y;
}
2019-09-29 22:23:13 +08:00
2020-01-21 10:09:55 +08:00
inline Point const& Actor::GetSkew() const
{
return transform_.skew;
}
2020-01-21 10:09:55 +08:00
inline float Actor::GetSkewX() const
{
return GetSkew().x;
}
2020-01-21 10:09:55 +08:00
inline float Actor::GetSkewY() const
{
return GetSkew().y;
}
2020-01-21 10:09:55 +08:00
inline float Actor::GetRotation() const
{
return transform_.rotation;
}
2020-01-21 10:09:55 +08:00
inline float Actor::GetWidth() const
{
return GetSize().x;
}
2020-01-21 10:09:55 +08:00
inline float Actor::GetHeight() const
{
return GetSize().y;
}
2019-12-23 18:05:08 +08:00
2020-01-21 10:09:55 +08:00
inline Size const& Actor::GetSize() const
{
return size_;
}
2019-12-23 18:05:08 +08:00
2020-01-21 10:09:55 +08:00
inline float Actor::GetScaledWidth() const
{
return GetWidth() * GetScaleX();
}
2019-12-23 18:05:08 +08:00
2020-01-21 10:09:55 +08:00
inline float Actor::GetScaledHeight() const
{
return GetHeight() * GetScaleY();
}
2019-12-23 18:05:08 +08:00
2020-01-21 10:09:55 +08:00
inline Size Actor::GetScaledSize() const
{
return Size{ GetScaledWidth(), GetScaledHeight() };
}
2019-12-23 18:05:08 +08:00
2020-01-21 10:09:55 +08:00
inline Point const& Actor::GetAnchor() const
{
return anchor_;
}
2019-12-23 18:05:08 +08:00
2020-01-21 10:09:55 +08:00
inline float Actor::GetAnchorX() const
{
return GetAnchor().x;
}
2019-12-23 18:05:08 +08:00
2020-01-21 10:09:55 +08:00
inline float Actor::GetAnchorY() const
{
return GetAnchor().y;
}
2019-12-23 18:05:08 +08:00
2020-01-21 10:09:55 +08:00
inline float Actor::GetOpacity() const
{
return opacity_;
}
2019-12-23 18:05:08 +08:00
2020-01-21 10:09:55 +08:00
inline float Actor::GetDisplayedOpacity() const
{
return displayed_opacity_;
}
2019-12-23 18:05:08 +08:00
2020-01-21 10:09:55 +08:00
inline Transform Actor::GetTransform() const
{
return transform_;
}
2019-12-23 18:05:08 +08:00
2020-01-21 10:09:55 +08:00
inline Actor* Actor::GetParent() const
{
return parent_;
}
2019-12-23 18:05:08 +08:00
2020-01-21 10:09:55 +08:00
inline Stage* Actor::GetStage() const
{
return stage_;
}
2019-12-23 18:05:08 +08:00
2020-01-21 10:09:55 +08:00
inline void Actor::PauseUpdating()
{
update_pausing_ = true;
}
2019-12-23 18:05:08 +08:00
2020-01-21 10:09:55 +08:00
inline void Actor::ResumeUpdating()
{
update_pausing_ = false;
}
2019-12-23 18:05:08 +08:00
2020-01-21 10:09:55 +08:00
inline bool Actor::IsUpdatePausing() const
{
return update_pausing_;
}
2019-12-23 18:05:08 +08:00
2020-01-21 10:09:55 +08:00
inline void Actor::SetCallbackOnUpdate(UpdateCallback const& cb)
{
cb_update_ = cb;
}
2019-12-23 18:05:08 +08:00
2020-01-21 10:09:55 +08:00
inline Actor::UpdateCallback Actor::GetCallbackOnUpdate() const
{
return cb_update_;
}
2019-12-23 18:05:08 +08:00
2020-01-21 10:09:55 +08:00
inline void Actor::ShowBorder(bool show)
{
show_border_ = show;
}
2019-12-23 18:05:08 +08:00
2020-01-21 10:09:55 +08:00
inline void Actor::SetPosition(float x, float y)
{
SetPosition(Point{ x, y });
}
2019-12-23 18:05:08 +08:00
2020-01-21 10:09:55 +08:00
inline void Actor::Move(float vx, float vy)
{
Move(Vec2{ vx, vy });
}
2019-12-23 18:05:08 +08:00
2020-01-21 10:09:55 +08:00
inline void Actor::SetScale(float scalex, float scaley)
{
SetScale(Vec2{ scalex, scaley });
}
2019-12-23 18:05:08 +08:00
2020-01-21 10:09:55 +08:00
inline void Actor::SetAnchor(float anchorx, float anchory)
{
SetAnchor(Vec2{ anchorx, anchory });
}
2019-12-23 18:05:08 +08:00
2020-01-21 10:09:55 +08:00
inline void Actor::SetSize(float width, float height)
{
SetSize(Size{ width, height });
}
2019-11-07 18:16:28 +08:00
2020-01-21 10:09:55 +08:00
inline void Actor::SetSkew(float skewx, float skewy)
{
SetSkew(Vec2{ skewx, skewy });
}
2020-01-21 10:09:55 +08:00
} // namespace kiwano