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")]
125unsafe impl NSCoding for SKScene {}
126
127#[cfg(all(
128    feature = "SKEffectNode",
129    feature = "SKNode",
130    feature = "objc2-app-kit"
131))]
132#[cfg(target_os = "macos")]
133unsafe impl NSCopying for SKScene {}
134
135#[cfg(all(
136    feature = "SKEffectNode",
137    feature = "SKNode",
138    feature = "objc2-app-kit"
139))]
140#[cfg(target_os = "macos")]
141unsafe impl CopyingHelper for SKScene {
142    type Result = Self;
143}
144
145#[cfg(all(
146    feature = "SKEffectNode",
147    feature = "SKNode",
148    feature = "objc2-app-kit"
149))]
150#[cfg(target_os = "macos")]
151unsafe impl NSObjectProtocol for SKScene {}
152
153#[cfg(all(
154    feature = "SKEffectNode",
155    feature = "SKNode",
156    feature = "objc2-app-kit"
157))]
158#[cfg(target_os = "macos")]
159unsafe impl NSSecureCoding for SKScene {}
160
161#[cfg(all(
162    feature = "SKEffectNode",
163    feature = "SKNode",
164    feature = "SKWarpGeometry",
165    feature = "objc2-app-kit"
166))]
167#[cfg(target_os = "macos")]
168unsafe impl SKWarpable for SKScene {}
169
170#[cfg(all(
171    feature = "SKEffectNode",
172    feature = "SKNode",
173    feature = "objc2-app-kit"
174))]
175#[cfg(target_os = "macos")]
176impl SKScene {
177    extern_methods!(
178        #[cfg(feature = "objc2-core-foundation")]
179        /// A scene is infinitely large, but it has a viewport that is the frame through which you present the content of the scene.
180        /// The passed in size defines the size of this viewport that you use to present the scene.
181        ///
182        ///
183        /// Parameter `size`: a size in points that signifies the viewport into the scene that defines your framing of the scene.
184        #[unsafe(method(initWithSize:))]
185        #[unsafe(method_family = init)]
186        pub unsafe fn initWithSize(this: Allocated<Self>, size: CGSize) -> Retained<Self>;
187
188        #[cfg(feature = "objc2-core-foundation")]
189        #[unsafe(method(sceneWithSize:))]
190        #[unsafe(method_family = none)]
191        pub unsafe fn sceneWithSize(size: CGSize, mtm: MainThreadMarker) -> Retained<Self>;
192
193        #[unsafe(method(sceneDidLoad))]
194        #[unsafe(method_family = none)]
195        pub unsafe fn sceneDidLoad(&self);
196
197        #[cfg(feature = "objc2-core-foundation")]
198        #[unsafe(method(size))]
199        #[unsafe(method_family = none)]
200        pub unsafe fn size(&self) -> CGSize;
201
202        #[cfg(feature = "objc2-core-foundation")]
203        /// Setter for [`size`][Self::size].
204        #[unsafe(method(setSize:))]
205        #[unsafe(method_family = none)]
206        pub unsafe fn setSize(&self, size: CGSize);
207
208        /// Used to determine how to scale the scene to match the SKView it is being displayed in.
209        #[unsafe(method(scaleMode))]
210        #[unsafe(method_family = none)]
211        pub unsafe fn scaleMode(&self) -> SKSceneScaleMode;
212
213        /// Setter for [`scaleMode`][Self::scaleMode].
214        #[unsafe(method(setScaleMode:))]
215        #[unsafe(method_family = none)]
216        pub unsafe fn setScaleMode(&self, scale_mode: SKSceneScaleMode);
217
218        #[cfg(feature = "SKCameraNode")]
219        /// The camera that is used to obtain the view scale and translation based on where the camera is in relation to the scene.
220        #[unsafe(method(camera))]
221        #[unsafe(method_family = none)]
222        pub unsafe fn camera(&self) -> Option<Retained<SKCameraNode>>;
223
224        #[cfg(feature = "SKCameraNode")]
225        /// This is a [weak property][objc2::topics::weak_property].
226        /// Setter for [`camera`][Self::camera].
227        #[unsafe(method(setCamera:))]
228        #[unsafe(method_family = none)]
229        pub unsafe fn setCamera(&self, camera: Option<&SKCameraNode>);
230
231        /// The node that is currently the listener for positional audio coming from SKAudioNodes
232        ///
233        /// See: SKAudioNode
234        #[unsafe(method(listener))]
235        #[unsafe(method_family = none)]
236        pub unsafe fn listener(&self) -> Option<Retained<SKNode>>;
237
238        /// This is a [weak property][objc2::topics::weak_property].
239        /// Setter for [`listener`][Self::listener].
240        #[unsafe(method(setListener:))]
241        #[unsafe(method_family = none)]
242        pub unsafe fn setListener(&self, listener: Option<&SKNode>);
243
244        #[cfg(feature = "objc2-avf-audio")]
245        #[unsafe(method(audioEngine))]
246        #[unsafe(method_family = none)]
247        pub unsafe fn audioEngine(&self) -> Retained<AVAudioEngine>;
248
249        /// Background color, defaults to gray
250        #[unsafe(method(backgroundColor))]
251        #[unsafe(method_family = none)]
252        pub unsafe fn backgroundColor(&self) -> Retained<NSColor>;
253
254        /// Setter for [`backgroundColor`][Self::backgroundColor].
255        #[unsafe(method(setBackgroundColor:))]
256        #[unsafe(method_family = none)]
257        pub unsafe fn setBackgroundColor(&self, background_color: &NSColor);
258
259        #[unsafe(method(delegate))]
260        #[unsafe(method_family = none)]
261        pub unsafe fn delegate(&self) -> Option<Retained<ProtocolObject<dyn SKSceneDelegate>>>;
262
263        /// This is a [weak property][objc2::topics::weak_property].
264        /// Setter for [`delegate`][Self::delegate].
265        #[unsafe(method(setDelegate:))]
266        #[unsafe(method_family = none)]
267        pub unsafe fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn SKSceneDelegate>>);
268
269        #[cfg(feature = "objc2-core-foundation")]
270        /// Used to choose the origin of the scene's coordinate system
271        #[unsafe(method(anchorPoint))]
272        #[unsafe(method_family = none)]
273        pub unsafe fn anchorPoint(&self) -> CGPoint;
274
275        #[cfg(feature = "objc2-core-foundation")]
276        /// Setter for [`anchorPoint`][Self::anchorPoint].
277        #[unsafe(method(setAnchorPoint:))]
278        #[unsafe(method_family = none)]
279        pub unsafe fn setAnchorPoint(&self, anchor_point: CGPoint);
280
281        #[cfg(feature = "SKPhysicsWorld")]
282        /// Physics simulation functionality
283        #[unsafe(method(physicsWorld))]
284        #[unsafe(method_family = none)]
285        pub unsafe fn physicsWorld(&self) -> Retained<SKPhysicsWorld>;
286
287        #[cfg(feature = "SKView")]
288        /// The SKView this scene is currently presented in, or nil if it is not being presented.
289        #[unsafe(method(view))]
290        #[unsafe(method_family = none)]
291        pub unsafe fn view(&self) -> Option<Retained<SKView>>;
292
293        #[cfg(feature = "objc2-core-foundation")]
294        #[unsafe(method(convertPointFromView:))]
295        #[unsafe(method_family = none)]
296        pub unsafe fn convertPointFromView(&self, point: CGPoint) -> CGPoint;
297
298        #[cfg(feature = "objc2-core-foundation")]
299        #[unsafe(method(convertPointToView:))]
300        #[unsafe(method_family = none)]
301        pub unsafe fn convertPointToView(&self, point: CGPoint) -> CGPoint;
302
303        /// Override this to perform per-frame game logic. Called exactly once per frame before any actions are evaluated and any physics are simulated.
304        ///
305        ///
306        /// Parameter `currentTime`: the current time in the app. This must be monotonically increasing.
307        #[unsafe(method(update:))]
308        #[unsafe(method_family = none)]
309        pub unsafe fn update(&self, current_time: NSTimeInterval);
310
311        /// 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.
312        #[unsafe(method(didEvaluateActions))]
313        #[unsafe(method_family = none)]
314        pub unsafe fn didEvaluateActions(&self);
315
316        /// 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.
317        #[unsafe(method(didSimulatePhysics))]
318        #[unsafe(method_family = none)]
319        pub unsafe fn didSimulatePhysics(&self);
320
321        /// 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.
322        #[unsafe(method(didApplyConstraints))]
323        #[unsafe(method_family = none)]
324        pub unsafe fn didApplyConstraints(&self);
325
326        /// 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.
327        ///
328        /// 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.
329        #[unsafe(method(didFinishUpdate))]
330        #[unsafe(method_family = none)]
331        pub unsafe fn didFinishUpdate(&self);
332
333        #[cfg(feature = "SKView")]
334        #[unsafe(method(didMoveToView:))]
335        #[unsafe(method_family = none)]
336        pub unsafe fn didMoveToView(&self, view: &SKView);
337
338        #[cfg(feature = "SKView")]
339        #[unsafe(method(willMoveFromView:))]
340        #[unsafe(method_family = none)]
341        pub unsafe fn willMoveFromView(&self, view: &SKView);
342
343        #[cfg(feature = "objc2-core-foundation")]
344        #[unsafe(method(didChangeSize:))]
345        #[unsafe(method_family = none)]
346        pub unsafe fn didChangeSize(&self, old_size: CGSize);
347    );
348}
349
350/// Methods declared on superclass `SKNode`.
351#[cfg(all(
352    feature = "SKEffectNode",
353    feature = "SKNode",
354    feature = "objc2-app-kit"
355))]
356#[cfg(target_os = "macos")]
357impl SKScene {
358    extern_methods!(
359        #[unsafe(method(init))]
360        #[unsafe(method_family = init)]
361        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
362
363        /// Support coding and decoding via NSKeyedArchiver.
364        #[unsafe(method(initWithCoder:))]
365        #[unsafe(method_family = init)]
366        pub unsafe fn initWithCoder(
367            this: Allocated<Self>,
368            a_decoder: &NSCoder,
369        ) -> Option<Retained<Self>>;
370
371        #[unsafe(method(node))]
372        #[unsafe(method_family = none)]
373        pub unsafe fn node(mtm: MainThreadMarker) -> Retained<Self>;
374
375        #[unsafe(method(nodeWithFileNamed:))]
376        #[unsafe(method_family = none)]
377        pub unsafe fn nodeWithFileNamed(
378            filename: &NSString,
379            mtm: MainThreadMarker,
380        ) -> Option<Retained<Self>>;
381
382        #[unsafe(method(nodeWithFileNamed:securelyWithClasses:andError:_))]
383        #[unsafe(method_family = none)]
384        pub unsafe fn nodeWithFileNamed_securelyWithClasses_andError(
385            filename: &NSString,
386            classes: &NSSet<AnyClass>,
387            mtm: MainThreadMarker,
388        ) -> Result<Retained<Self>, Retained<NSError>>;
389    );
390}
391
392/// Methods declared on superclass `NSObject`.
393#[cfg(all(
394    feature = "SKEffectNode",
395    feature = "SKNode",
396    feature = "objc2-app-kit"
397))]
398#[cfg(target_os = "macos")]
399impl SKScene {
400    extern_methods!(
401        #[unsafe(method(new))]
402        #[unsafe(method_family = new)]
403        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
404    );
405}