objc2_sprite_kit/generated/
SKScene.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-app-kit")]
7#[cfg(target_os = "macos")]
8use objc2_app_kit::*;
9#[cfg(feature = "objc2-avf-audio")]
10use objc2_avf_audio::*;
11#[cfg(feature = "objc2-core-foundation")]
12use objc2_core_foundation::*;
13use objc2_foundation::*;
14
15use crate::*;
16
17/// [Apple's documentation](https://developer.apple.com/documentation/spritekit/skscenescalemode?language=objc)
18// NS_ENUM
19#[repr(transparent)]
20#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
21pub struct SKSceneScaleMode(pub NSInteger);
22impl SKSceneScaleMode {
23    #[doc(alias = "SKSceneScaleModeFill")]
24    pub const Fill: Self = Self(0);
25    #[doc(alias = "SKSceneScaleModeAspectFill")]
26    pub const AspectFill: Self = Self(1);
27    #[doc(alias = "SKSceneScaleModeAspectFit")]
28    pub const AspectFit: Self = Self(2);
29    #[doc(alias = "SKSceneScaleModeResizeFill")]
30    pub const ResizeFill: Self = Self(3);
31}
32
33unsafe impl Encode for SKSceneScaleMode {
34    const ENCODING: Encoding = NSInteger::ENCODING;
35}
36
37unsafe impl RefEncode for SKSceneScaleMode {
38    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
39}
40
41extern_protocol!(
42    /// [Apple's documentation](https://developer.apple.com/documentation/spritekit/skscenedelegate?language=objc)
43    pub unsafe trait SKSceneDelegate: NSObjectProtocol {
44        #[cfg(all(
45            feature = "SKEffectNode",
46            feature = "SKNode",
47            feature = "objc2-app-kit"
48        ))]
49        #[cfg(target_os = "macos")]
50        #[optional]
51        #[unsafe(method(update:forScene:))]
52        #[unsafe(method_family = none)]
53        unsafe fn update_forScene(&self, current_time: NSTimeInterval, scene: &SKScene);
54
55        #[cfg(all(
56            feature = "SKEffectNode",
57            feature = "SKNode",
58            feature = "objc2-app-kit"
59        ))]
60        #[cfg(target_os = "macos")]
61        #[optional]
62        #[unsafe(method(didEvaluateActionsForScene:))]
63        #[unsafe(method_family = none)]
64        unsafe fn didEvaluateActionsForScene(&self, scene: &SKScene);
65
66        #[cfg(all(
67            feature = "SKEffectNode",
68            feature = "SKNode",
69            feature = "objc2-app-kit"
70        ))]
71        #[cfg(target_os = "macos")]
72        #[optional]
73        #[unsafe(method(didSimulatePhysicsForScene:))]
74        #[unsafe(method_family = none)]
75        unsafe fn didSimulatePhysicsForScene(&self, scene: &SKScene);
76
77        #[cfg(all(
78            feature = "SKEffectNode",
79            feature = "SKNode",
80            feature = "objc2-app-kit"
81        ))]
82        #[cfg(target_os = "macos")]
83        #[optional]
84        #[unsafe(method(didApplyConstraintsForScene:))]
85        #[unsafe(method_family = none)]
86        unsafe fn didApplyConstraintsForScene(&self, scene: &SKScene);
87
88        #[cfg(all(
89            feature = "SKEffectNode",
90            feature = "SKNode",
91            feature = "objc2-app-kit"
92        ))]
93        #[cfg(target_os = "macos")]
94        #[optional]
95        #[unsafe(method(didFinishUpdateForScene:))]
96        #[unsafe(method_family = none)]
97        unsafe fn didFinishUpdateForScene(&self, scene: &SKScene);
98    }
99);
100
101extern_class!(
102    /// A scene is the root node of your content. It is used to display SpriteKit content on an SKView.
103    ///
104    ///
105    /// See: SKView
106    ///
107    /// See also [Apple's documentation](https://developer.apple.com/documentation/spritekit/skscene?language=objc)
108    #[unsafe(super(SKEffectNode, SKNode, NSResponder, NSObject))]
109    #[derive(Debug, PartialEq, Eq, Hash)]
110    #[cfg(all(
111        feature = "SKEffectNode",
112        feature = "SKNode",
113        feature = "objc2-app-kit"
114    ))]
115    #[cfg(target_os = "macos")]
116    pub struct SKScene;
117);
118
119#[cfg(all(
120    feature = "SKEffectNode",
121    feature = "SKNode",
122    feature = "objc2-app-kit"
123))]
124#[cfg(target_os = "macos")]
125extern_conformance!(
126    unsafe impl NSCoding for SKScene {}
127);
128
129#[cfg(all(
130    feature = "SKEffectNode",
131    feature = "SKNode",
132    feature = "objc2-app-kit"
133))]
134#[cfg(target_os = "macos")]
135extern_conformance!(
136    unsafe impl NSCopying for SKScene {}
137);
138
139#[cfg(all(
140    feature = "SKEffectNode",
141    feature = "SKNode",
142    feature = "objc2-app-kit"
143))]
144#[cfg(target_os = "macos")]
145unsafe impl CopyingHelper for SKScene {
146    type Result = Self;
147}
148
149#[cfg(all(
150    feature = "SKEffectNode",
151    feature = "SKNode",
152    feature = "objc2-app-kit"
153))]
154#[cfg(target_os = "macos")]
155extern_conformance!(
156    unsafe impl NSObjectProtocol for SKScene {}
157);
158
159#[cfg(all(
160    feature = "SKEffectNode",
161    feature = "SKNode",
162    feature = "objc2-app-kit"
163))]
164#[cfg(target_os = "macos")]
165extern_conformance!(
166    unsafe impl NSSecureCoding for SKScene {}
167);
168
169#[cfg(all(
170    feature = "SKEffectNode",
171    feature = "SKNode",
172    feature = "SKWarpGeometry",
173    feature = "objc2-app-kit"
174))]
175#[cfg(target_os = "macos")]
176extern_conformance!(
177    unsafe impl SKWarpable for SKScene {}
178);
179
180#[cfg(all(
181    feature = "SKEffectNode",
182    feature = "SKNode",
183    feature = "objc2-app-kit"
184))]
185#[cfg(target_os = "macos")]
186impl SKScene {
187    extern_methods!(
188        #[cfg(feature = "objc2-core-foundation")]
189        /// A scene is infinitely large, but it has a viewport that is the frame through which you present the content of the scene.
190        /// The passed in size defines the size of this viewport that you use to present the scene.
191        ///
192        ///
193        /// Parameter `size`: a size in points that signifies the viewport into the scene that defines your framing of the scene.
194        #[unsafe(method(initWithSize:))]
195        #[unsafe(method_family = init)]
196        pub unsafe fn initWithSize(this: Allocated<Self>, size: CGSize) -> Retained<Self>;
197
198        #[cfg(feature = "objc2-core-foundation")]
199        #[unsafe(method(sceneWithSize:))]
200        #[unsafe(method_family = none)]
201        pub unsafe fn sceneWithSize(size: CGSize, mtm: MainThreadMarker) -> Retained<Self>;
202
203        #[unsafe(method(sceneDidLoad))]
204        #[unsafe(method_family = none)]
205        pub unsafe fn sceneDidLoad(&self);
206
207        #[cfg(feature = "objc2-core-foundation")]
208        #[unsafe(method(size))]
209        #[unsafe(method_family = none)]
210        pub unsafe fn size(&self) -> CGSize;
211
212        #[cfg(feature = "objc2-core-foundation")]
213        /// Setter for [`size`][Self::size].
214        #[unsafe(method(setSize:))]
215        #[unsafe(method_family = none)]
216        pub unsafe fn setSize(&self, size: CGSize);
217
218        /// Used to determine how to scale the scene to match the SKView it is being displayed in.
219        #[unsafe(method(scaleMode))]
220        #[unsafe(method_family = none)]
221        pub unsafe fn scaleMode(&self) -> SKSceneScaleMode;
222
223        /// Setter for [`scaleMode`][Self::scaleMode].
224        #[unsafe(method(setScaleMode:))]
225        #[unsafe(method_family = none)]
226        pub unsafe fn setScaleMode(&self, scale_mode: SKSceneScaleMode);
227
228        #[cfg(feature = "SKCameraNode")]
229        /// The camera that is used to obtain the view scale and translation based on where the camera is in relation to the scene.
230        #[unsafe(method(camera))]
231        #[unsafe(method_family = none)]
232        pub unsafe fn camera(&self) -> Option<Retained<SKCameraNode>>;
233
234        #[cfg(feature = "SKCameraNode")]
235        /// Setter for [`camera`][Self::camera].
236        ///
237        /// This is a [weak property][objc2::topics::weak_property].
238        #[unsafe(method(setCamera:))]
239        #[unsafe(method_family = none)]
240        pub unsafe fn setCamera(&self, camera: Option<&SKCameraNode>);
241
242        /// The node that is currently the listener for positional audio coming from SKAudioNodes
243        ///
244        /// See: SKAudioNode
245        #[unsafe(method(listener))]
246        #[unsafe(method_family = none)]
247        pub unsafe fn listener(&self) -> Option<Retained<SKNode>>;
248
249        /// Setter for [`listener`][Self::listener].
250        ///
251        /// This is a [weak property][objc2::topics::weak_property].
252        #[unsafe(method(setListener:))]
253        #[unsafe(method_family = none)]
254        pub unsafe fn setListener(&self, listener: Option<&SKNode>);
255
256        #[cfg(feature = "objc2-avf-audio")]
257        #[unsafe(method(audioEngine))]
258        #[unsafe(method_family = none)]
259        pub unsafe fn audioEngine(&self) -> Retained<AVAudioEngine>;
260
261        /// Background color, defaults to gray
262        #[unsafe(method(backgroundColor))]
263        #[unsafe(method_family = none)]
264        pub unsafe fn backgroundColor(&self) -> Retained<NSColor>;
265
266        /// Setter for [`backgroundColor`][Self::backgroundColor].
267        #[unsafe(method(setBackgroundColor:))]
268        #[unsafe(method_family = none)]
269        pub unsafe fn setBackgroundColor(&self, background_color: &NSColor);
270
271        #[unsafe(method(delegate))]
272        #[unsafe(method_family = none)]
273        pub unsafe fn delegate(&self) -> Option<Retained<ProtocolObject<dyn SKSceneDelegate>>>;
274
275        /// Setter for [`delegate`][Self::delegate].
276        ///
277        /// This is a [weak property][objc2::topics::weak_property].
278        #[unsafe(method(setDelegate:))]
279        #[unsafe(method_family = none)]
280        pub unsafe fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn SKSceneDelegate>>);
281
282        #[cfg(feature = "objc2-core-foundation")]
283        /// Used to choose the origin of the scene's coordinate system
284        #[unsafe(method(anchorPoint))]
285        #[unsafe(method_family = none)]
286        pub unsafe fn anchorPoint(&self) -> CGPoint;
287
288        #[cfg(feature = "objc2-core-foundation")]
289        /// Setter for [`anchorPoint`][Self::anchorPoint].
290        #[unsafe(method(setAnchorPoint:))]
291        #[unsafe(method_family = none)]
292        pub unsafe fn setAnchorPoint(&self, anchor_point: CGPoint);
293
294        #[cfg(feature = "SKPhysicsWorld")]
295        /// Physics simulation functionality
296        #[unsafe(method(physicsWorld))]
297        #[unsafe(method_family = none)]
298        pub unsafe fn physicsWorld(&self) -> Retained<SKPhysicsWorld>;
299
300        #[cfg(feature = "SKView")]
301        /// The SKView this scene is currently presented in, or nil if it is not being presented.
302        #[unsafe(method(view))]
303        #[unsafe(method_family = none)]
304        pub unsafe fn view(&self) -> Option<Retained<SKView>>;
305
306        #[cfg(feature = "objc2-core-foundation")]
307        #[unsafe(method(convertPointFromView:))]
308        #[unsafe(method_family = none)]
309        pub unsafe fn convertPointFromView(&self, point: CGPoint) -> CGPoint;
310
311        #[cfg(feature = "objc2-core-foundation")]
312        #[unsafe(method(convertPointToView:))]
313        #[unsafe(method_family = none)]
314        pub unsafe fn convertPointToView(&self, point: CGPoint) -> CGPoint;
315
316        /// Override this to perform per-frame game logic. Called exactly once per frame before any actions are evaluated and any physics are simulated.
317        ///
318        ///
319        /// Parameter `currentTime`: the current time in the app. This must be monotonically increasing.
320        #[unsafe(method(update:))]
321        #[unsafe(method_family = none)]
322        pub unsafe fn update(&self, current_time: NSTimeInterval);
323
324        /// Override this to perform game logic. Called exactly once per frame after any actions have been evaluated but before any physics are simulated. Any additional actions applied is not evaluated until the next update.
325        #[unsafe(method(didEvaluateActions))]
326        #[unsafe(method_family = none)]
327        pub unsafe fn didEvaluateActions(&self);
328
329        /// Override this to perform game logic. Called exactly once per frame after any actions have been evaluated and any physics have been simulated. Any additional actions applied is not evaluated until the next update. Any changes to physics bodies is not simulated until the next update.
330        #[unsafe(method(didSimulatePhysics))]
331        #[unsafe(method_family = none)]
332        pub unsafe fn didSimulatePhysics(&self);
333
334        /// Override this to perform game logic. Called exactly once per frame after any enabled constraints have been applied. Any additional actions applied is not evaluated until the next update. Any changes to physics bodies is not simulated until the next update. Any changes to constraints will not be applied until the next update.
335        #[unsafe(method(didApplyConstraints))]
336        #[unsafe(method_family = none)]
337        pub unsafe fn didApplyConstraints(&self);
338
339        /// Override this to perform game logic. Called after all update logic has been completed. Any additional actions applied are not evaluated until the next update. Any changes to physics bodies are not simulated until the next update. Any changes to constraints will not be applied until the next update.
340        ///
341        /// No futher update logic will be applied to the scene after this call. Any values set on nodes here will be used when the scene is rendered for the current frame.
342        #[unsafe(method(didFinishUpdate))]
343        #[unsafe(method_family = none)]
344        pub unsafe fn didFinishUpdate(&self);
345
346        #[cfg(feature = "SKView")]
347        #[unsafe(method(didMoveToView:))]
348        #[unsafe(method_family = none)]
349        pub unsafe fn didMoveToView(&self, view: &SKView);
350
351        #[cfg(feature = "SKView")]
352        #[unsafe(method(willMoveFromView:))]
353        #[unsafe(method_family = none)]
354        pub unsafe fn willMoveFromView(&self, view: &SKView);
355
356        #[cfg(feature = "objc2-core-foundation")]
357        #[unsafe(method(didChangeSize:))]
358        #[unsafe(method_family = none)]
359        pub unsafe fn didChangeSize(&self, old_size: CGSize);
360    );
361}
362
363/// Methods declared on superclass `SKNode`.
364#[cfg(all(
365    feature = "SKEffectNode",
366    feature = "SKNode",
367    feature = "objc2-app-kit"
368))]
369#[cfg(target_os = "macos")]
370impl SKScene {
371    extern_methods!(
372        #[unsafe(method(init))]
373        #[unsafe(method_family = init)]
374        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
375
376        /// Support coding and decoding via NSKeyedArchiver.
377        ///
378        /// # Safety
379        ///
380        /// `a_decoder` possibly has further requirements.
381        #[unsafe(method(initWithCoder:))]
382        #[unsafe(method_family = init)]
383        pub unsafe fn initWithCoder(
384            this: Allocated<Self>,
385            a_decoder: &NSCoder,
386        ) -> Option<Retained<Self>>;
387
388        #[unsafe(method(node))]
389        #[unsafe(method_family = none)]
390        pub unsafe fn node(mtm: MainThreadMarker) -> Retained<Self>;
391
392        #[unsafe(method(nodeWithFileNamed:))]
393        #[unsafe(method_family = none)]
394        pub unsafe fn nodeWithFileNamed(
395            filename: &NSString,
396            mtm: MainThreadMarker,
397        ) -> Option<Retained<Self>>;
398
399        /// # Safety
400        ///
401        /// `classes` generic probably has further requirements.
402        #[unsafe(method(nodeWithFileNamed:securelyWithClasses:andError:_))]
403        #[unsafe(method_family = none)]
404        pub unsafe fn nodeWithFileNamed_securelyWithClasses_andError(
405            filename: &NSString,
406            classes: &NSSet<AnyClass>,
407            mtm: MainThreadMarker,
408        ) -> Result<Retained<Self>, Retained<NSError>>;
409    );
410}
411
412/// Methods declared on superclass `NSObject`.
413#[cfg(all(
414    feature = "SKEffectNode",
415    feature = "SKNode",
416    feature = "objc2-app-kit"
417))]
418#[cfg(target_os = "macos")]
419impl SKScene {
420    extern_methods!(
421        #[unsafe(method(new))]
422        #[unsafe(method_family = new)]
423        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
424    );
425}