objc2_sprite_kit/generated/
SKTileDefinition.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12/// Adjust the rotation of the tile definition image, in 90 degree increments.
13///
14/// See also [Apple's documentation](https://developer.apple.com/documentation/spritekit/sktiledefinitionrotation?language=objc)
15// NS_ENUM
16#[repr(transparent)]
17#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
18pub struct SKTileDefinitionRotation(pub NSUInteger);
19impl SKTileDefinitionRotation {
20    #[doc(alias = "SKTileDefinitionRotation0")]
21    pub const Rotation0: Self = Self(0);
22    #[doc(alias = "SKTileDefinitionRotation90")]
23    pub const Rotation90: Self = Self(1);
24    #[doc(alias = "SKTileDefinitionRotation180")]
25    pub const Rotation180: Self = Self(2);
26    #[doc(alias = "SKTileDefinitionRotation270")]
27    pub const Rotation270: Self = Self(3);
28}
29
30unsafe impl Encode for SKTileDefinitionRotation {
31    const ENCODING: Encoding = NSUInteger::ENCODING;
32}
33
34unsafe impl RefEncode for SKTileDefinitionRotation {
35    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
36}
37
38extern_class!(
39    /// A tile definition contains the information needed to represent a single type of tile within a tile map.
40    ///
41    /// See also [Apple's documentation](https://developer.apple.com/documentation/spritekit/sktiledefinition?language=objc)
42    #[unsafe(super(NSObject))]
43    #[derive(Debug, PartialEq, Eq, Hash)]
44    pub struct SKTileDefinition;
45);
46
47extern_conformance!(
48    unsafe impl NSCoding for SKTileDefinition {}
49);
50
51extern_conformance!(
52    unsafe impl NSCopying for SKTileDefinition {}
53);
54
55unsafe impl CopyingHelper for SKTileDefinition {
56    type Result = Self;
57}
58
59extern_conformance!(
60    unsafe impl NSObjectProtocol for SKTileDefinition {}
61);
62
63extern_conformance!(
64    unsafe impl NSSecureCoding for SKTileDefinition {}
65);
66
67impl SKTileDefinition {
68    extern_methods!(
69        #[cfg(feature = "SKTexture")]
70        /// Create a tile definition with an SKTexture, and set its size to the SKTexture's width/height.
71        ///
72        /// Parameter `texture`: the texture to reference for size and content
73        #[unsafe(method(tileDefinitionWithTexture:))]
74        #[unsafe(method_family = none)]
75        pub unsafe fn tileDefinitionWithTexture(texture: &SKTexture) -> Retained<Self>;
76
77        #[cfg(all(feature = "SKTexture", feature = "objc2-core-foundation"))]
78        /// Create a tile definition with an SKTexture and the specified size.
79        ///
80        /// Parameter `texture`: the texture to reference for content
81        ///
82        /// Parameter `size`: the size of the tile in points
83        #[unsafe(method(tileDefinitionWithTexture:size:))]
84        #[unsafe(method_family = none)]
85        pub unsafe fn tileDefinitionWithTexture_size(
86            texture: &SKTexture,
87            size: CGSize,
88        ) -> Retained<Self>;
89
90        #[cfg(all(feature = "SKTexture", feature = "objc2-core-foundation"))]
91        /// Create a tile definition with an SKTexture and the specified size.
92        ///
93        /// Parameter `texture`: the texture to reference for content
94        ///
95        /// Parameter `normalTexture`: the normal texture to use for generating normals for lighting
96        ///
97        /// Parameter `size`: the size of the tile in points
98        #[unsafe(method(tileDefinitionWithTexture:normalTexture:size:))]
99        #[unsafe(method_family = none)]
100        pub unsafe fn tileDefinitionWithTexture_normalTexture_size(
101            texture: &SKTexture,
102            normal_texture: &SKTexture,
103            size: CGSize,
104        ) -> Retained<Self>;
105
106        #[cfg(all(feature = "SKTexture", feature = "objc2-core-foundation"))]
107        /// Create an animated tile definition with an array of SKTextures, the specified size, and the length of time each texture should be displayed for in the animation.
108        ///
109        /// Parameter `textures`: the textures to reference for animated content
110        ///
111        /// Parameter `size`: the size of the tile in points
112        ///
113        /// Parameter `timePerFrame`: the duration, in seconds, that each texture in the textures array is displayed before switching to the next texture in the sequence
114        #[unsafe(method(tileDefinitionWithTextures:size:timePerFrame:))]
115        #[unsafe(method_family = none)]
116        pub unsafe fn tileDefinitionWithTextures_size_timePerFrame(
117            textures: &NSArray<SKTexture>,
118            size: CGSize,
119            time_per_frame: CGFloat,
120        ) -> Retained<Self>;
121
122        #[cfg(all(feature = "SKTexture", feature = "objc2-core-foundation"))]
123        /// Create an animated tile definition with an array of SKTextures, the specified size, and the length of time each texture should be displayed for in the animation.
124        ///
125        /// Parameter `textures`: the textures to reference for animated content
126        ///
127        /// Parameter `normalTextures`: the normal textures to use for generating normals for lighting
128        ///
129        /// Parameter `size`: the size of the tile in points
130        ///
131        /// Parameter `timePerFrame`: the duration, in seconds, that each texture in the textures array is displayed before switching to the next texture in the sequence
132        #[unsafe(method(tileDefinitionWithTextures:normalTextures:size:timePerFrame:))]
133        #[unsafe(method_family = none)]
134        pub unsafe fn tileDefinitionWithTextures_normalTextures_size_timePerFrame(
135            textures: &NSArray<SKTexture>,
136            normal_textures: &NSArray<SKTexture>,
137            size: CGSize,
138            time_per_frame: CGFloat,
139        ) -> Retained<Self>;
140
141        #[cfg(feature = "SKTexture")]
142        /// Initilize a tile definition with an SKTexture, and set its size to the SKTexture's width/height.
143        ///
144        /// Parameter `texture`: the texture to reference for size and content
145        #[unsafe(method(initWithTexture:))]
146        #[unsafe(method_family = init)]
147        pub unsafe fn initWithTexture(this: Allocated<Self>, texture: &SKTexture)
148            -> Retained<Self>;
149
150        #[cfg(all(feature = "SKTexture", feature = "objc2-core-foundation"))]
151        /// Initilize a tile definition with an SKTexture and the specified size.
152        ///
153        /// Parameter `texture`: the texture to reference for content
154        ///
155        /// Parameter `size`: the size of the tile in points
156        #[unsafe(method(initWithTexture:size:))]
157        #[unsafe(method_family = init)]
158        pub unsafe fn initWithTexture_size(
159            this: Allocated<Self>,
160            texture: &SKTexture,
161            size: CGSize,
162        ) -> Retained<Self>;
163
164        #[cfg(all(feature = "SKTexture", feature = "objc2-core-foundation"))]
165        /// Initilize a tile definition with an SKTexture and the specified size.
166        ///
167        /// Parameter `texture`: the texture to reference for content
168        ///
169        /// Parameter `normalTexture`: the normal texture to use for generating normals for lighting
170        ///
171        /// Parameter `size`: the size of the tile in points
172        #[unsafe(method(initWithTexture:normalTexture:size:))]
173        #[unsafe(method_family = init)]
174        pub unsafe fn initWithTexture_normalTexture_size(
175            this: Allocated<Self>,
176            texture: &SKTexture,
177            normal_texture: &SKTexture,
178            size: CGSize,
179        ) -> Retained<Self>;
180
181        #[cfg(all(feature = "SKTexture", feature = "objc2-core-foundation"))]
182        /// Initilize an animated tile definition with an array of SKTextures, the specified size, and the length of time each texture should be displayed for in the animation.
183        ///
184        /// Parameter `textures`: the textures to reference for animated content
185        ///
186        /// Parameter `size`: the size of the tile in points
187        ///
188        /// Parameter `timePerFrame`: the duration, in seconds, that each texture in the textures array is displayed before switching to the next texture in the sequence
189        #[unsafe(method(initWithTextures:size:timePerFrame:))]
190        #[unsafe(method_family = init)]
191        pub unsafe fn initWithTextures_size_timePerFrame(
192            this: Allocated<Self>,
193            textures: &NSArray<SKTexture>,
194            size: CGSize,
195            time_per_frame: CGFloat,
196        ) -> Retained<Self>;
197
198        #[cfg(all(feature = "SKTexture", feature = "objc2-core-foundation"))]
199        /// Initilize an animated tile definition with an array of SKTextures, the specified size, and the length of time each texture should be displayed for in the animation.
200        ///
201        /// Parameter `textures`: the textures to reference for animated content
202        ///
203        /// Parameter `normalTextures`: the normal textures to use for generating normals for lighting
204        ///
205        /// Parameter `size`: the size of the tile in points
206        ///
207        /// Parameter `timePerFrame`: the duration, in seconds, that each texture in the textures array is displayed before switching to the next texture in the sequence
208        #[unsafe(method(initWithTextures:normalTextures:size:timePerFrame:))]
209        #[unsafe(method_family = init)]
210        pub unsafe fn initWithTextures_normalTextures_size_timePerFrame(
211            this: Allocated<Self>,
212            textures: &NSArray<SKTexture>,
213            normal_textures: &NSArray<SKTexture>,
214            size: CGSize,
215            time_per_frame: CGFloat,
216        ) -> Retained<Self>;
217
218        #[cfg(feature = "SKTexture")]
219        /// The textures used to draw the tile. Non-animated tiles use only one texture. When more than one texture is present, the tile will swap through them in sequence, showing each for the duration specified in the timePerFrame property. After displaying the last texture in the array, the sequence is repeated from the first texture.
220        #[unsafe(method(textures))]
221        #[unsafe(method_family = none)]
222        pub unsafe fn textures(&self) -> Retained<NSArray<SKTexture>>;
223
224        #[cfg(feature = "SKTexture")]
225        /// Setter for [`textures`][Self::textures].
226        #[unsafe(method(setTextures:))]
227        #[unsafe(method_family = none)]
228        pub unsafe fn setTextures(&self, textures: &NSArray<SKTexture>);
229
230        #[cfg(feature = "SKTexture")]
231        /// The textures to use for generating normals that lights use to light this tile. These will only be used if the tile is lit by at least one light. Each normal texture corresponds to a texture in the textures property.
232        #[unsafe(method(normalTextures))]
233        #[unsafe(method_family = none)]
234        pub unsafe fn normalTextures(&self) -> Retained<NSArray<SKTexture>>;
235
236        #[cfg(feature = "SKTexture")]
237        /// Setter for [`normalTextures`][Self::normalTextures].
238        #[unsafe(method(setNormalTextures:))]
239        #[unsafe(method_family = none)]
240        pub unsafe fn setNormalTextures(&self, normal_textures: &NSArray<SKTexture>);
241
242        /// An optional dictionary that can be used to store your own data for each tile definition. Defaults to nil.
243        #[unsafe(method(userData))]
244        #[unsafe(method_family = none)]
245        pub unsafe fn userData(&self) -> Option<Retained<NSMutableDictionary>>;
246
247        /// Setter for [`userData`][Self::userData].
248        #[unsafe(method(setUserData:))]
249        #[unsafe(method_family = none)]
250        pub unsafe fn setUserData(&self, user_data: Option<&NSMutableDictionary>);
251
252        /// Client-assignable name for the tile definition. Defaults to nil.
253        #[unsafe(method(name))]
254        #[unsafe(method_family = none)]
255        pub unsafe fn name(&self) -> Option<Retained<NSString>>;
256
257        /// Setter for [`name`][Self::name].
258        #[unsafe(method(setName:))]
259        #[unsafe(method_family = none)]
260        pub unsafe fn setName(&self, name: Option<&NSString>);
261
262        #[cfg(feature = "objc2-core-foundation")]
263        /// The size of the tile in points.
264        #[unsafe(method(size))]
265        #[unsafe(method_family = none)]
266        pub unsafe fn size(&self) -> CGSize;
267
268        #[cfg(feature = "objc2-core-foundation")]
269        /// Setter for [`size`][Self::size].
270        #[unsafe(method(setSize:))]
271        #[unsafe(method_family = none)]
272        pub unsafe fn setSize(&self, size: CGSize);
273
274        #[cfg(feature = "objc2-core-foundation")]
275        /// The duration, in seconds, that each texture in the textures array is displayed before switching to the next texture in the sequence. Only used when there is more than one texture available.
276        #[unsafe(method(timePerFrame))]
277        #[unsafe(method_family = none)]
278        pub unsafe fn timePerFrame(&self) -> CGFloat;
279
280        #[cfg(feature = "objc2-core-foundation")]
281        /// Setter for [`timePerFrame`][Self::timePerFrame].
282        #[unsafe(method(setTimePerFrame:))]
283        #[unsafe(method_family = none)]
284        pub unsafe fn setTimePerFrame(&self, time_per_frame: CGFloat);
285
286        /// This value is used to determine how likely this tile definition is to be chosen for placement when a SKTileGroupRule has mulitple tile definitions assigned to it. A higher value relative to the other definitions assigned to the rule make it more likely for this definition to be selected; lower values make it less likely. Defaults to 1. When set to 0, the definition will never be chosen as long as there is at least one other definition with a placementWeight above 0.
287        #[unsafe(method(placementWeight))]
288        #[unsafe(method_family = none)]
289        pub unsafe fn placementWeight(&self) -> NSUInteger;
290
291        /// Setter for [`placementWeight`][Self::placementWeight].
292        #[unsafe(method(setPlacementWeight:))]
293        #[unsafe(method_family = none)]
294        pub unsafe fn setPlacementWeight(&self, placement_weight: NSUInteger);
295
296        /// The rotation of the tile definition's images can be set in 90 degree increments. Defaults to SKTileDefinitionRotation0.
297        #[unsafe(method(rotation))]
298        #[unsafe(method_family = none)]
299        pub unsafe fn rotation(&self) -> SKTileDefinitionRotation;
300
301        /// Setter for [`rotation`][Self::rotation].
302        #[unsafe(method(setRotation:))]
303        #[unsafe(method_family = none)]
304        pub unsafe fn setRotation(&self, rotation: SKTileDefinitionRotation);
305
306        /// When set to YES, the tile definition's images will be flipped vertically (i.e., the top of the image becomes the bottom). Defaults to NO.
307        #[unsafe(method(flipVertically))]
308        #[unsafe(method_family = none)]
309        pub unsafe fn flipVertically(&self) -> bool;
310
311        /// Setter for [`flipVertically`][Self::flipVertically].
312        #[unsafe(method(setFlipVertically:))]
313        #[unsafe(method_family = none)]
314        pub unsafe fn setFlipVertically(&self, flip_vertically: bool);
315
316        /// When set to YES, the tile definition's images will be flipped horizontally (i.e., the left of the image becomes the right). Defaults to NO.
317        #[unsafe(method(flipHorizontally))]
318        #[unsafe(method_family = none)]
319        pub unsafe fn flipHorizontally(&self) -> bool;
320
321        /// Setter for [`flipHorizontally`][Self::flipHorizontally].
322        #[unsafe(method(setFlipHorizontally:))]
323        #[unsafe(method_family = none)]
324        pub unsafe fn setFlipHorizontally(&self, flip_horizontally: bool);
325    );
326}
327
328/// Methods declared on superclass `NSObject`.
329impl SKTileDefinition {
330    extern_methods!(
331        #[unsafe(method(init))]
332        #[unsafe(method_family = init)]
333        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
334
335        #[unsafe(method(new))]
336        #[unsafe(method_family = new)]
337        pub unsafe fn new() -> Retained<Self>;
338    );
339}