Пример #1
0
void RotateSpriteState::Rotate(const sm::vec2& dst)
{
	ee::RotateSpriteState::Rotate(dst);

	SkeletonData* skeleton = get_curr_skeleton();
	if (!skeleton) {
		return;
	}

	ee::SpriteSelection* selection = GetSelection();
	if (selection->IsEmpty()) {
		return;
	}

	std::vector<ee::SprPtr> sprs;
	selection->Traverse(ee::FetchAllRefVisitor<ee::Sprite>(sprs));

	skeleton->FixJoint(sprs[0]);
	float dAngle = sm::get_angle_in_direction(sprs[0]->GetPosition(), GetLastPos(), dst);
	skeleton->UpdateJoint(sprs[0], dAngle);
}