parent
6868d746da
commit
b4404db7b7
|
|
@ -62,10 +62,14 @@ namespace easy2d
|
|||
if (pause_)
|
||||
return;
|
||||
|
||||
OnUpdate(dt);
|
||||
UpdateActions(this, dt);
|
||||
UpdateTasks(dt);
|
||||
|
||||
if (cb_update_)
|
||||
cb_update_(dt);
|
||||
|
||||
OnUpdate(dt);
|
||||
|
||||
if (!children_.IsEmpty())
|
||||
{
|
||||
NodePtr next;
|
||||
|
|
@ -225,11 +229,7 @@ namespace easy2d
|
|||
dirty_transform_ = false;
|
||||
dirty_transform_inverse_ = true;
|
||||
|
||||
// matrix multiplication is optimized by expression template
|
||||
transform_matrix_ = Matrix::Scaling(transform_.scale)
|
||||
* Matrix::Skewing(transform_.skew.x, transform_.skew.y)
|
||||
* Matrix::Rotation(transform_.rotation)
|
||||
* Matrix::Translation(transform_.position);
|
||||
transform_matrix_ = transform_.ToMatrix();
|
||||
|
||||
Point offset{ -size_.x * anchor_.x, -size_.y * anchor_.y };
|
||||
transform_matrix_.Translate(offset);
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ namespace easy2d
|
|||
friend class IntrusiveList<NodePtr>;
|
||||
|
||||
using Children = IntrusiveList<NodePtr>;
|
||||
using UpdateCallback = std::function<void(Duration)>;
|
||||
|
||||
public:
|
||||
Node();
|
||||
|
|
@ -349,7 +350,13 @@ namespace easy2d
|
|||
void ResumeUpdating();
|
||||
|
||||
// 节点更新是否暂停
|
||||
inline bool IsUpdatePausing() const { return pause_; }
|
||||
inline bool IsUpdatePausing() const { return pause_; }
|
||||
|
||||
// 设置更新时的回调函数
|
||||
inline void SetCallbackOnUpdate(UpdateCallback const& cb) { cb_update_ = cb; }
|
||||
|
||||
// 获取更新时的回调函数
|
||||
inline UpdateCallback const& GetCallbackOnUpdate() { return cb_update_; }
|
||||
|
||||
// 设置默认锚点
|
||||
static void SetDefaultAnchor(
|
||||
|
|
@ -384,6 +391,7 @@ namespace easy2d
|
|||
Node* parent_;
|
||||
Scene* scene_;
|
||||
Children children_;
|
||||
UpdateCallback cb_update_;
|
||||
|
||||
mutable bool dirty_transform_;
|
||||
mutable bool dirty_transform_inverse_;
|
||||
|
|
|
|||
|
|
@ -46,5 +46,14 @@ namespace easy2d
|
|||
skew == other.skew &&
|
||||
rotation == other.rotation;
|
||||
}
|
||||
|
||||
inline math::Matrix ToMatrix() const
|
||||
{
|
||||
// matrix multiplication is optimized by expression template
|
||||
return Matrix::Scaling(scale)
|
||||
* Matrix::Skewing(skew.x, skew.y)
|
||||
* Matrix::Rotation(rotation)
|
||||
* Matrix::Translation(position);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue