mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 09:16:01 +08:00
[ios] Provide the ability to convert an Attachment into a BoundingBoxAttachment. (#2671)
Co-authored-by: liqiang <liqiangbj01@kanyun.com>
This commit is contained in:
parent
a815fc40d8
commit
648170f325
@ -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;
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user