[ios] Provide the ability to convert an Attachment into a BoundingBoxAttachment. (#2671)

Co-authored-by: liqiang <liqiangbj01@kanyun.com>
This commit is contained in:
kikiloveswift 2024-11-14 19:19:17 +08:00 committed by GitHub
parent a815fc40d8
commit 648170f325
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 0 deletions

View File

@ -2424,6 +2424,16 @@ spine_attachment spine_attachment_copy(spine_attachment attachment) {
return (spine_attachment) _attachment->copy();
}
spine_bounding_box_attachment spine_attachment_cast_to_bounding_box_attachment(spine_attachment attachment) {
if (attachment == nullptr) return nullptr;
Attachment *_attachment = (Attachment *)attachment;
if (_attachment->getRTTI().isExactly(BoundingBoxAttachment::rtti)) {
BoundingBoxAttachment *boundingBox = static_cast<BoundingBoxAttachment *>(_attachment);
return (spine_bounding_box_attachment)boundingBox;
}
return nullptr;
}
void spine_attachment_dispose(spine_attachment attachment) {
if (attachment == nullptr) return;
Attachment *_attachment = (Attachment *) attachment;

View File

@ -630,6 +630,8 @@ SPINE_CPP_LITE_EXPORT const utf8 *spine_attachment_get_name(spine_attachment att
SPINE_CPP_LITE_EXPORT spine_attachment_type spine_attachment_get_type(spine_attachment attachment);
// @ignore
SPINE_CPP_LITE_EXPORT spine_attachment spine_attachment_copy(spine_attachment attachment);
// @optional
SPINE_CPP_LITE_EXPORT spine_bounding_box_attachment spine_attachment_cast_to_bounding_box_attachment(spine_attachment attachment);
SPINE_CPP_LITE_EXPORT void spine_attachment_dispose(spine_attachment attachment);
SPINE_CPP_LITE_EXPORT spine_vector spine_point_attachment_compute_world_position(spine_point_attachment attachment, spine_bone bone);

View File

@ -2553,6 +2553,11 @@ public final class Attachment: NSObject {
return spine_attachment_get_type(wrappee)
}
@discardableResult
public func castToBoundingBoxAttachment() -> BoundingBoxAttachment? {
return spine_attachment_cast_to_bounding_box_attachment(wrappee).flatMap { .init($0) }
}
public func dispose() {
if disposed { return }
disposed = true