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
47unsafe impl NSCoding for SKTileDefinition {}
48
49unsafe impl NSCopying for SKTileDefinition {}
50
51unsafe impl CopyingHelper for SKTileDefinition {
52 type Result = Self;
53}
54
55unsafe impl NSObjectProtocol for SKTileDefinition {}
56
57unsafe impl NSSecureCoding for SKTileDefinition {}
58
59impl SKTileDefinition {
60 extern_methods!(
61 #[cfg(feature = "SKTexture")]
62 /// Create a tile definition with an SKTexture, and set its size to the SKTexture's width/height.
63 ///
64 /// Parameter `texture`: the texture to reference for size and content
65 #[unsafe(method(tileDefinitionWithTexture:))]
66 #[unsafe(method_family = none)]
67 pub unsafe fn tileDefinitionWithTexture(texture: &SKTexture) -> Retained<Self>;
68
69 #[cfg(all(feature = "SKTexture", feature = "objc2-core-foundation"))]
70 /// Create a tile definition with an SKTexture and the specified size.
71 ///
72 /// Parameter `texture`: the texture to reference for content
73 ///
74 /// Parameter `size`: the size of the tile in points
75 #[unsafe(method(tileDefinitionWithTexture:size:))]
76 #[unsafe(method_family = none)]
77 pub unsafe fn tileDefinitionWithTexture_size(
78 texture: &SKTexture,
79 size: CGSize,
80 ) -> Retained<Self>;
81
82 #[cfg(all(feature = "SKTexture", feature = "objc2-core-foundation"))]
83 /// Create a tile definition with an SKTexture and the specified size.
84 ///
85 /// Parameter `texture`: the texture to reference for content
86 ///
87 /// Parameter `normalTexture`: the normal texture to use for generating normals for lighting
88 ///
89 /// Parameter `size`: the size of the tile in points
90 #[unsafe(method(tileDefinitionWithTexture:normalTexture:size:))]
91 #[unsafe(method_family = none)]
92 pub unsafe fn tileDefinitionWithTexture_normalTexture_size(
93 texture: &SKTexture,
94 normal_texture: &SKTexture,
95 size: CGSize,
96 ) -> Retained<Self>;
97
98 #[cfg(all(feature = "SKTexture", feature = "objc2-core-foundation"))]
99 /// 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.
100 ///
101 /// Parameter `textures`: the textures to reference for animated content
102 ///
103 /// Parameter `size`: the size of the tile in points
104 ///
105 /// Parameter `timePerFrame`: the duration, in seconds, that each texture in the textures array is displayed before switching to the next texture in the sequence
106 #[unsafe(method(tileDefinitionWithTextures:size:timePerFrame:))]
107 #[unsafe(method_family = none)]
108 pub unsafe fn tileDefinitionWithTextures_size_timePerFrame(
109 textures: &NSArray<SKTexture>,
110 size: CGSize,
111 time_per_frame: CGFloat,
112 ) -> Retained<Self>;
113
114 #[cfg(all(feature = "SKTexture", feature = "objc2-core-foundation"))]
115 /// 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.
116 ///
117 /// Parameter `textures`: the textures to reference for animated content
118 ///
119 /// Parameter `normalTextures`: the normal textures to use for generating normals for lighting
120 ///
121 /// Parameter `size`: the size of the tile in points
122 ///
123 /// Parameter `timePerFrame`: the duration, in seconds, that each texture in the textures array is displayed before switching to the next texture in the sequence
124 #[unsafe(method(tileDefinitionWithTextures:normalTextures:size:timePerFrame:))]
125 #[unsafe(method_family = none)]
126 pub unsafe fn tileDefinitionWithTextures_normalTextures_size_timePerFrame(
127 textures: &NSArray<SKTexture>,
128 normal_textures: &NSArray<SKTexture>,
129 size: CGSize,
130 time_per_frame: CGFloat,
131 ) -> Retained<Self>;
132
133 #[cfg(feature = "SKTexture")]
134 /// Initilize a tile definition with an SKTexture, and set its size to the SKTexture's width/height.
135 ///
136 /// Parameter `texture`: the texture to reference for size and content
137 #[unsafe(method(initWithTexture:))]
138 #[unsafe(method_family = init)]
139 pub unsafe fn initWithTexture(this: Allocated<Self>, texture: &SKTexture)
140 -> Retained<Self>;
141
142 #[cfg(all(feature = "SKTexture", feature = "objc2-core-foundation"))]
143 /// Initilize a tile definition with an SKTexture and the specified size.
144 ///
145 /// Parameter `texture`: the texture to reference for content
146 ///
147 /// Parameter `size`: the size of the tile in points
148 #[unsafe(method(initWithTexture:size:))]
149 #[unsafe(method_family = init)]
150 pub unsafe fn initWithTexture_size(
151 this: Allocated<Self>,
152 texture: &SKTexture,
153 size: CGSize,
154 ) -> Retained<Self>;
155
156 #[cfg(all(feature = "SKTexture", feature = "objc2-core-foundation"))]
157 /// Initilize a tile definition with an SKTexture and the specified size.
158 ///
159 /// Parameter `texture`: the texture to reference for content
160 ///
161 /// Parameter `normalTexture`: the normal texture to use for generating normals for lighting
162 ///
163 /// Parameter `size`: the size of the tile in points
164 #[unsafe(method(initWithTexture:normalTexture:size:))]
165 #[unsafe(method_family = init)]
166 pub unsafe fn initWithTexture_normalTexture_size(
167 this: Allocated<Self>,
168 texture: &SKTexture,
169 normal_texture: &SKTexture,
170 size: CGSize,
171 ) -> Retained<Self>;
172
173 #[cfg(all(feature = "SKTexture", feature = "objc2-core-foundation"))]
174 /// 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.
175 ///
176 /// Parameter `textures`: the textures to reference for animated content
177 ///
178 /// Parameter `size`: the size of the tile in points
179 ///
180 /// Parameter `timePerFrame`: the duration, in seconds, that each texture in the textures array is displayed before switching to the next texture in the sequence
181 #[unsafe(method(initWithTextures:size:timePerFrame:))]
182 #[unsafe(method_family = init)]
183 pub unsafe fn initWithTextures_size_timePerFrame(
184 this: Allocated<Self>,
185 textures: &NSArray<SKTexture>,
186 size: CGSize,
187 time_per_frame: CGFloat,
188 ) -> Retained<Self>;
189
190 #[cfg(all(feature = "SKTexture", feature = "objc2-core-foundation"))]
191 /// 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.
192 ///
193 /// Parameter `textures`: the textures to reference for animated content
194 ///
195 /// Parameter `normalTextures`: the normal textures to use for generating normals for lighting
196 ///
197 /// Parameter `size`: the size of the tile in points
198 ///
199 /// Parameter `timePerFrame`: the duration, in seconds, that each texture in the textures array is displayed before switching to the next texture in the sequence
200 #[unsafe(method(initWithTextures:normalTextures:size:timePerFrame:))]
201 #[unsafe(method_family = init)]
202 pub unsafe fn initWithTextures_normalTextures_size_timePerFrame(
203 this: Allocated<Self>,
204 textures: &NSArray<SKTexture>,
205 normal_textures: &NSArray<SKTexture>,
206 size: CGSize,
207 time_per_frame: CGFloat,
208 ) -> Retained<Self>;
209
210 #[cfg(feature = "SKTexture")]
211 /// 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.
212 #[unsafe(method(textures))]
213 #[unsafe(method_family = none)]
214 pub unsafe fn textures(&self) -> Retained<NSArray<SKTexture>>;
215
216 #[cfg(feature = "SKTexture")]
217 /// Setter for [`textures`][Self::textures].
218 #[unsafe(method(setTextures:))]
219 #[unsafe(method_family = none)]
220 pub unsafe fn setTextures(&self, textures: &NSArray<SKTexture>);
221
222 #[cfg(feature = "SKTexture")]
223 /// 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.
224 #[unsafe(method(normalTextures))]
225 #[unsafe(method_family = none)]
226 pub unsafe fn normalTextures(&self) -> Retained<NSArray<SKTexture>>;
227
228 #[cfg(feature = "SKTexture")]
229 /// Setter for [`normalTextures`][Self::normalTextures].
230 #[unsafe(method(setNormalTextures:))]
231 #[unsafe(method_family = none)]
232 pub unsafe fn setNormalTextures(&self, normal_textures: &NSArray<SKTexture>);
233
234 /// An optional dictionary that can be used to store your own data for each tile definition. Defaults to nil.
235 #[unsafe(method(userData))]
236 #[unsafe(method_family = none)]
237 pub unsafe fn userData(&self) -> Option<Retained<NSMutableDictionary>>;
238
239 /// Setter for [`userData`][Self::userData].
240 #[unsafe(method(setUserData:))]
241 #[unsafe(method_family = none)]
242 pub unsafe fn setUserData(&self, user_data: Option<&NSMutableDictionary>);
243
244 /// Client-assignable name for the tile definition. Defaults to nil.
245 #[unsafe(method(name))]
246 #[unsafe(method_family = none)]
247 pub unsafe fn name(&self) -> Option<Retained<NSString>>;
248
249 /// Setter for [`name`][Self::name].
250 #[unsafe(method(setName:))]
251 #[unsafe(method_family = none)]
252 pub unsafe fn setName(&self, name: Option<&NSString>);
253
254 #[cfg(feature = "objc2-core-foundation")]
255 /// The size of the tile in points.
256 #[unsafe(method(size))]
257 #[unsafe(method_family = none)]
258 pub unsafe fn size(&self) -> CGSize;
259
260 #[cfg(feature = "objc2-core-foundation")]
261 /// Setter for [`size`][Self::size].
262 #[unsafe(method(setSize:))]
263 #[unsafe(method_family = none)]
264 pub unsafe fn setSize(&self, size: CGSize);
265
266 #[cfg(feature = "objc2-core-foundation")]
267 /// 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.
268 #[unsafe(method(timePerFrame))]
269 #[unsafe(method_family = none)]
270 pub unsafe fn timePerFrame(&self) -> CGFloat;
271
272 #[cfg(feature = "objc2-core-foundation")]
273 /// Setter for [`timePerFrame`][Self::timePerFrame].
274 #[unsafe(method(setTimePerFrame:))]
275 #[unsafe(method_family = none)]
276 pub unsafe fn setTimePerFrame(&self, time_per_frame: CGFloat);
277
278 /// 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.
279 #[unsafe(method(placementWeight))]
280 #[unsafe(method_family = none)]
281 pub unsafe fn placementWeight(&self) -> NSUInteger;
282
283 /// Setter for [`placementWeight`][Self::placementWeight].
284 #[unsafe(method(setPlacementWeight:))]
285 #[unsafe(method_family = none)]
286 pub unsafe fn setPlacementWeight(&self, placement_weight: NSUInteger);
287
288 /// The rotation of the tile definition's images can be set in 90 degree increments. Defaults to SKTileDefinitionRotation0.
289 #[unsafe(method(rotation))]
290 #[unsafe(method_family = none)]
291 pub unsafe fn rotation(&self) -> SKTileDefinitionRotation;
292
293 /// Setter for [`rotation`][Self::rotation].
294 #[unsafe(method(setRotation:))]
295 #[unsafe(method_family = none)]
296 pub unsafe fn setRotation(&self, rotation: SKTileDefinitionRotation);
297
298 /// 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.
299 #[unsafe(method(flipVertically))]
300 #[unsafe(method_family = none)]
301 pub unsafe fn flipVertically(&self) -> bool;
302
303 /// Setter for [`flipVertically`][Self::flipVertically].
304 #[unsafe(method(setFlipVertically:))]
305 #[unsafe(method_family = none)]
306 pub unsafe fn setFlipVertically(&self, flip_vertically: bool);
307
308 /// 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.
309 #[unsafe(method(flipHorizontally))]
310 #[unsafe(method_family = none)]
311 pub unsafe fn flipHorizontally(&self) -> bool;
312
313 /// Setter for [`flipHorizontally`][Self::flipHorizontally].
314 #[unsafe(method(setFlipHorizontally:))]
315 #[unsafe(method_family = none)]
316 pub unsafe fn setFlipHorizontally(&self, flip_horizontally: bool);
317 );
318}
319
320/// Methods declared on superclass `NSObject`.
321impl SKTileDefinition {
322 extern_methods!(
323 #[unsafe(method(init))]
324 #[unsafe(method_family = init)]
325 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
326
327 #[unsafe(method(new))]
328 #[unsafe(method_family = new)]
329 pub unsafe fn new() -> Retained<Self>;
330 );
331}