Преглед на файлове

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

Co-authored-by: liqiang <[email protected]>
kikiloveswift преди 10 месеца
родител
ревизия
648170f325
променени са 3 файла, в които са добавени 17 реда и са изтрити 0 реда
  1. 10 0
      spine-cpp/spine-cpp-lite/spine-cpp-lite.cpp
  2. 2 0
      spine-cpp/spine-cpp-lite/spine-cpp-lite.h
  3. 5 0
      spine-ios/Sources/Spine/Spine.Generated.swift

+ 10 - 0
spine-cpp/spine-cpp-lite/spine-cpp-lite.cpp

@@ -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;

+ 2 - 0
spine-cpp/spine-cpp-lite/spine-cpp-lite.h

@@ -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);

+ 5 - 0
spine-ios/Sources/Spine/Spine.Generated.swift

@@ -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