objc2_sprite_kit/generated/SKAction.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5#[cfg(feature = "dispatch2")]
6use dispatch2::*;
7use objc2::__framework_prelude::*;
8#[cfg(feature = "objc2-app-kit")]
9#[cfg(target_os = "macos")]
10use objc2_app_kit::*;
11#[cfg(feature = "objc2-core-foundation")]
12use objc2_core_foundation::*;
13#[cfg(feature = "objc2-core-graphics")]
14use objc2_core_graphics::*;
15use objc2_foundation::*;
16
17use crate::*;
18
19/// Adjust the timing of an action
20///
21///
22/// animation to occur evenly over its duration.
23///
24/// animation to begin slowly, and then speed up as it progresses.
25///
26/// the animation to begin quickly, and then slow as it completes.
27///
28/// ease-in ease-out animation begins slowly, accelerates through the middle
29/// of its duration, and then slows again before completing.
30///
31/// See also [Apple's documentation](https://developer.apple.com/documentation/spritekit/skactiontimingmode?language=objc)
32// NS_ENUM
33#[repr(transparent)]
34#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
35pub struct SKActionTimingMode(pub NSInteger);
36impl SKActionTimingMode {
37 #[doc(alias = "SKActionTimingLinear")]
38 pub const Linear: Self = Self(0);
39 #[doc(alias = "SKActionTimingEaseIn")]
40 pub const EaseIn: Self = Self(1);
41 #[doc(alias = "SKActionTimingEaseOut")]
42 pub const EaseOut: Self = Self(2);
43 #[doc(alias = "SKActionTimingEaseInEaseOut")]
44 pub const EaseInEaseOut: Self = Self(3);
45}
46
47unsafe impl Encode for SKActionTimingMode {
48 const ENCODING: Encoding = NSInteger::ENCODING;
49}
50
51unsafe impl RefEncode for SKActionTimingMode {
52 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
53}
54
55/// A custom timing function for SKActions. Input time will be linear 0.0-1.0
56/// over the duration of the action. Return values must be 0.0-1.0 and increasing
57/// and the function must return 1.0 when the input time reaches 1.0.
58///
59/// See also [Apple's documentation](https://developer.apple.com/documentation/spritekit/skactiontimingfunction?language=objc)
60#[cfg(feature = "block2")]
61pub type SKActionTimingFunction = *mut block2::DynBlock<dyn Fn(c_float) -> c_float>;
62
63extern_class!(
64 /// An SKAction object is an action that is executed by a node in the scene.
65 /// Actions are most often used to change the structure and content of the node to
66 /// which they are attached, but can also make other changes to the scene. When
67 /// the scene processes its nodes, actions associated with those nodes are evaluated.
68 ///
69 /// See also [Apple's documentation](https://developer.apple.com/documentation/spritekit/skaction?language=objc)
70 #[unsafe(super(NSObject))]
71 #[derive(Debug, PartialEq, Eq, Hash)]
72 pub struct SKAction;
73);
74
75extern_conformance!(
76 unsafe impl NSCoding for SKAction {}
77);
78
79extern_conformance!(
80 unsafe impl NSCopying for SKAction {}
81);
82
83unsafe impl CopyingHelper for SKAction {
84 type Result = Self;
85}
86
87extern_conformance!(
88 unsafe impl NSObjectProtocol for SKAction {}
89);
90
91extern_conformance!(
92 unsafe impl NSSecureCoding for SKAction {}
93);
94
95impl SKAction {
96 extern_methods!(
97 /// The duration required to complete an action, in seconds.
98 #[unsafe(method(duration))]
99 #[unsafe(method_family = none)]
100 pub unsafe fn duration(&self) -> NSTimeInterval;
101
102 /// Setter for [`duration`][Self::duration].
103 #[unsafe(method(setDuration:))]
104 #[unsafe(method_family = none)]
105 pub unsafe fn setDuration(&self, duration: NSTimeInterval);
106
107 /// The timing mode used to execute an action
108 ///
109 /// See: SKActionTimingMode
110 #[unsafe(method(timingMode))]
111 #[unsafe(method_family = none)]
112 pub unsafe fn timingMode(&self) -> SKActionTimingMode;
113
114 /// Setter for [`timingMode`][Self::timingMode].
115 #[unsafe(method(setTimingMode:))]
116 #[unsafe(method_family = none)]
117 pub unsafe fn setTimingMode(&self, timing_mode: SKActionTimingMode);
118
119 #[cfg(feature = "block2")]
120 /// When set, prodives a custom timing via a block. Applies after
121 /// the 'timingMode' property is taken into account, defaults to nil
122 ///
123 /// See: SKActionTimingFunction
124 #[unsafe(method(timingFunction))]
125 #[unsafe(method_family = none)]
126 pub unsafe fn timingFunction(&self) -> SKActionTimingFunction;
127
128 #[cfg(feature = "block2")]
129 /// Setter for [`timingFunction`][Self::timingFunction].
130 #[unsafe(method(setTimingFunction:))]
131 #[unsafe(method_family = none)]
132 pub unsafe fn setTimingFunction(&self, timing_function: SKActionTimingFunction);
133
134 #[cfg(feature = "objc2-core-foundation")]
135 /// A speed factor that modifies how fast an action runs. Default value is 1.0
136 #[unsafe(method(speed))]
137 #[unsafe(method_family = none)]
138 pub unsafe fn speed(&self) -> CGFloat;
139
140 #[cfg(feature = "objc2-core-foundation")]
141 /// Setter for [`speed`][Self::speed].
142 #[unsafe(method(setSpeed:))]
143 #[unsafe(method_family = none)]
144 pub unsafe fn setSpeed(&self, speed: CGFloat);
145
146 /// Creates an action that reverses the behavior of another action
147 ///
148 ///
149 /// Returns: This method always returns an action object; however, not all actions
150 /// are reversible
151 #[unsafe(method(reversedAction))]
152 #[unsafe(method_family = none)]
153 pub unsafe fn reversedAction(&self) -> Retained<SKAction>;
154 );
155}
156
157/// Methods declared on superclass `NSObject`.
158impl SKAction {
159 extern_methods!(
160 #[unsafe(method(init))]
161 #[unsafe(method_family = init)]
162 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
163
164 #[unsafe(method(new))]
165 #[unsafe(method_family = new)]
166 pub unsafe fn new() -> Retained<Self>;
167 );
168}
169
170/// SKActions.
171impl SKAction {
172 extern_methods!(
173 #[cfg(feature = "objc2-core-foundation")]
174 /// Creates an action that moves a node relative to its current position
175 ///
176 /// Parameter `delta`: A vector that describes the change to apply to the node’s position
177 ///
178 /// Parameter `duration`: The duration of the animation, in seconds
179 #[unsafe(method(moveBy:duration:))]
180 #[unsafe(method_family = none)]
181 pub unsafe fn moveBy_duration(
182 delta: CGVector,
183 duration: NSTimeInterval,
184 ) -> Retained<SKAction>;
185
186 #[cfg(feature = "objc2-core-foundation")]
187 #[unsafe(method(moveByX:y:duration:))]
188 #[unsafe(method_family = none)]
189 pub unsafe fn moveByX_y_duration(
190 delta_x: CGFloat,
191 delta_y: CGFloat,
192 duration: NSTimeInterval,
193 ) -> Retained<SKAction>;
194
195 #[cfg(feature = "objc2-core-foundation")]
196 /// Creates an action that moves a node to a new position
197 ///
198 /// Parameter `location`: The coordinates for the node’s new position
199 ///
200 /// Parameter `duration`: The duration of the animation, in seconds
201 #[unsafe(method(moveTo:duration:))]
202 #[unsafe(method_family = none)]
203 pub unsafe fn moveTo_duration(
204 location: CGPoint,
205 duration: NSTimeInterval,
206 ) -> Retained<SKAction>;
207
208 #[cfg(feature = "objc2-core-foundation")]
209 #[unsafe(method(moveToX:duration:))]
210 #[unsafe(method_family = none)]
211 pub unsafe fn moveToX_duration(x: CGFloat, duration: NSTimeInterval) -> Retained<SKAction>;
212
213 #[cfg(feature = "objc2-core-foundation")]
214 #[unsafe(method(moveToY:duration:))]
215 #[unsafe(method_family = none)]
216 pub unsafe fn moveToY_duration(y: CGFloat, duration: NSTimeInterval) -> Retained<SKAction>;
217
218 #[cfg(feature = "objc2-core-foundation")]
219 /// Creates an action that rotates the node by a relative value
220 ///
221 /// Parameter `radians`: The amount to rotate the node, in radians
222 ///
223 /// Parameter `duration`: The duration of the animation, in seconds
224 #[unsafe(method(rotateByAngle:duration:))]
225 #[unsafe(method_family = none)]
226 pub unsafe fn rotateByAngle_duration(
227 radians: CGFloat,
228 duration: NSTimeInterval,
229 ) -> Retained<SKAction>;
230
231 #[cfg(feature = "objc2-core-foundation")]
232 /// Creates an action that rotates the node counterclockwise to an absolute angle
233 ///
234 /// Parameter `radians`: The angle to rotate the node to, in radians
235 ///
236 /// Parameter `duration`: The duration of the animation
237 #[unsafe(method(rotateToAngle:duration:))]
238 #[unsafe(method_family = none)]
239 pub unsafe fn rotateToAngle_duration(
240 radians: CGFloat,
241 duration: NSTimeInterval,
242 ) -> Retained<SKAction>;
243
244 #[cfg(feature = "objc2-core-foundation")]
245 /// Creates an action that rotates the node to an absolute value
246 ///
247 /// Parameter `radians`: The angle to rotate the node to, in radians
248 ///
249 /// Parameter `duration`: The duration of the animation, in seconds
250 ///
251 /// Parameter `shortestUnitArc`: If YES, then the rotation is performed in whichever
252 /// direction results in the smallest rotation. If NO, then the rotation
253 /// is interpolated
254 #[unsafe(method(rotateToAngle:duration:shortestUnitArc:))]
255 #[unsafe(method_family = none)]
256 pub unsafe fn rotateToAngle_duration_shortestUnitArc(
257 radians: CGFloat,
258 duration: NSTimeInterval,
259 shortest_unit_arc: bool,
260 ) -> Retained<SKAction>;
261
262 #[cfg(feature = "objc2-core-foundation")]
263 /// Creates an action that adjusts the size of a sprite
264 ///
265 /// Parameter `width`: The amount to add to the sprite’s width
266 ///
267 /// Parameter `height`: The amount to add to the sprite’s height
268 ///
269 /// Parameter `duration`: The duration of the animation, in seconds
270 #[unsafe(method(resizeByWidth:height:duration:))]
271 #[unsafe(method_family = none)]
272 pub unsafe fn resizeByWidth_height_duration(
273 width: CGFloat,
274 height: CGFloat,
275 duration: NSTimeInterval,
276 ) -> Retained<SKAction>;
277
278 #[cfg(feature = "objc2-core-foundation")]
279 /// Creates an action that changes the width and height of a sprite to a new absolute value
280 ///
281 /// Parameter `width`: The new width of the sprite
282 ///
283 /// Parameter `height`: The new height of the sprite
284 ///
285 /// Parameter `duration`: The duration of the animation, in seconds
286 #[unsafe(method(resizeToWidth:height:duration:))]
287 #[unsafe(method_family = none)]
288 pub unsafe fn resizeToWidth_height_duration(
289 width: CGFloat,
290 height: CGFloat,
291 duration: NSTimeInterval,
292 ) -> Retained<SKAction>;
293
294 #[cfg(feature = "objc2-core-foundation")]
295 #[unsafe(method(resizeToWidth:duration:))]
296 #[unsafe(method_family = none)]
297 pub unsafe fn resizeToWidth_duration(
298 width: CGFloat,
299 duration: NSTimeInterval,
300 ) -> Retained<SKAction>;
301
302 #[cfg(feature = "objc2-core-foundation")]
303 #[unsafe(method(resizeToHeight:duration:))]
304 #[unsafe(method_family = none)]
305 pub unsafe fn resizeToHeight_duration(
306 height: CGFloat,
307 duration: NSTimeInterval,
308 ) -> Retained<SKAction>;
309
310 #[cfg(feature = "objc2-core-foundation")]
311 /// Creates an action that changes the x and y scale values of a node by a relative value
312 ///
313 /// Parameter `scale`: The amount to modify to the node’s x and y scale values
314 ///
315 /// Parameter `duration`: The duration of the animation, in seconds
316 #[unsafe(method(scaleBy:duration:))]
317 #[unsafe(method_family = none)]
318 pub unsafe fn scaleBy_duration(
319 scale: CGFloat,
320 duration: NSTimeInterval,
321 ) -> Retained<SKAction>;
322
323 #[cfg(feature = "objc2-core-foundation")]
324 #[unsafe(method(scaleXBy:y:duration:))]
325 #[unsafe(method_family = none)]
326 pub unsafe fn scaleXBy_y_duration(
327 x_scale: CGFloat,
328 y_scale: CGFloat,
329 duration: NSTimeInterval,
330 ) -> Retained<SKAction>;
331
332 #[cfg(feature = "objc2-core-foundation")]
333 /// Creates an action that changes the x and y scale values of a node by a relative value
334 ///
335 /// Parameter `scale`: The new value for the node’s x and y scale values
336 ///
337 /// Parameter `duration`: The duration of the animation, in seconds
338 #[unsafe(method(scaleTo:duration:))]
339 #[unsafe(method_family = none)]
340 pub unsafe fn scaleTo_duration(
341 scale: CGFloat,
342 duration: NSTimeInterval,
343 ) -> Retained<SKAction>;
344
345 #[cfg(feature = "objc2-core-foundation")]
346 #[unsafe(method(scaleXTo:y:duration:))]
347 #[unsafe(method_family = none)]
348 pub unsafe fn scaleXTo_y_duration(
349 x_scale: CGFloat,
350 y_scale: CGFloat,
351 duration: NSTimeInterval,
352 ) -> Retained<SKAction>;
353
354 #[cfg(feature = "objc2-core-foundation")]
355 #[unsafe(method(scaleXTo:duration:))]
356 #[unsafe(method_family = none)]
357 pub unsafe fn scaleXTo_duration(
358 scale: CGFloat,
359 duration: NSTimeInterval,
360 ) -> Retained<SKAction>;
361
362 #[cfg(feature = "objc2-core-foundation")]
363 #[unsafe(method(scaleYTo:duration:))]
364 #[unsafe(method_family = none)]
365 pub unsafe fn scaleYTo_duration(
366 scale: CGFloat,
367 duration: NSTimeInterval,
368 ) -> Retained<SKAction>;
369
370 #[cfg(feature = "objc2-core-foundation")]
371 /// Adjust the sprite's xScale
372 /// &
373 /// yScale to achieve the desired size (in parent's coordinate space)
374 ///
375 /// Parameter `duration`: The duration of the animation, in seconds
376 #[unsafe(method(scaleToSize:duration:))]
377 #[unsafe(method_family = none)]
378 pub unsafe fn scaleToSize_duration(
379 size: CGSize,
380 duration: NSTimeInterval,
381 ) -> Retained<SKAction>;
382
383 /// Creates an action that runs a collection of actions sequentially
384 ///
385 /// Parameter `actions`: An array of SKAction objects
386 ///
387 ///
388 /// When the action executes, the first action in the sequence starts
389 /// and runs to completion. Subsequent actions in the sequence run in a
390 /// similar fashion until all of the actions in the sequence have executed.
391 /// The duration of the sequence action is the sum of the durations of the
392 /// actions in the sequence.
393 ///
394 /// This action is reversible; it creates a new sequence action that reverses
395 /// the order of the actions. Each action in the reversed sequence is itself
396 /// reversed. For example, if an action sequence is {1,2,3}, the reversed
397 /// sequence would be {3R,2R,1R}.
398 #[unsafe(method(sequence:))]
399 #[unsafe(method_family = none)]
400 pub unsafe fn sequence(actions: &NSArray<SKAction>) -> Retained<SKAction>;
401
402 /// Creates an action that runs a collection of actions concurrently
403 ///
404 /// Parameter `actions`: An array of SKAction objects
405 ///
406 ///
407 /// When the action executes, the actions that comprise the group
408 /// all start immediately and run in parallel. The duration of the group
409 /// action is the longest duration among the collection of actions. If an
410 /// action in the group has a duration less than the group’s duration, the
411 /// action completes, then idles until the group completes the remaining
412 /// actions. This matters most when creating a repeating action that repeats
413 /// a group.
414 #[unsafe(method(group:))]
415 #[unsafe(method_family = none)]
416 pub unsafe fn group(actions: &NSArray<SKAction>) -> Retained<SKAction>;
417
418 /// Creates an action that repeats another action a specified number of times
419 ///
420 /// Parameter `action`: The action to execute
421 ///
422 /// Parameter `count`: The number of times to execute the action
423 #[unsafe(method(repeatAction:count:))]
424 #[unsafe(method_family = none)]
425 pub unsafe fn repeatAction_count(
426 action: &SKAction,
427 count: NSUInteger,
428 ) -> Retained<SKAction>;
429
430 /// Creates an action that repeats forever
431 ///
432 /// Parameter `action`: The action to execute
433 #[unsafe(method(repeatActionForever:))]
434 #[unsafe(method_family = none)]
435 pub unsafe fn repeatActionForever(action: &SKAction) -> Retained<SKAction>;
436
437 /// Creates an action that changes the alpha value of the node to 1.0
438 ///
439 /// Parameter `duration`: The duration of the animation, in seconds
440 #[unsafe(method(fadeInWithDuration:))]
441 #[unsafe(method_family = none)]
442 pub unsafe fn fadeInWithDuration(duration: NSTimeInterval) -> Retained<SKAction>;
443
444 /// Creates an action that changes the alpha value of the node to 0.0
445 ///
446 /// Parameter `duration`: The duration of the animation, in seconds
447 #[unsafe(method(fadeOutWithDuration:))]
448 #[unsafe(method_family = none)]
449 pub unsafe fn fadeOutWithDuration(duration: NSTimeInterval) -> Retained<SKAction>;
450
451 #[cfg(feature = "objc2-core-foundation")]
452 /// Creates an action that adjusts the alpha value of a node by a relative value
453 ///
454 /// Parameter `factor`: The amount to modify the node’s alpha value
455 ///
456 /// Parameter `duration`: The duration of the animation, in seconds
457 #[unsafe(method(fadeAlphaBy:duration:))]
458 #[unsafe(method_family = none)]
459 pub unsafe fn fadeAlphaBy_duration(
460 factor: CGFloat,
461 duration: NSTimeInterval,
462 ) -> Retained<SKAction>;
463
464 #[cfg(feature = "objc2-core-foundation")]
465 /// Creates an action that adjusts the alpha value of a node to a new value
466 ///
467 /// Parameter `alpha`: The new value of the node’s alpha
468 ///
469 /// Parameter `duration`: The duration of the animation, in seconds
470 #[unsafe(method(fadeAlphaTo:duration:))]
471 #[unsafe(method_family = none)]
472 pub unsafe fn fadeAlphaTo_duration(
473 alpha: CGFloat,
474 duration: NSTimeInterval,
475 ) -> Retained<SKAction>;
476
477 /// Creates an action that hides a node
478 #[unsafe(method(hide))]
479 #[unsafe(method_family = none)]
480 pub unsafe fn hide() -> Retained<SKAction>;
481
482 /// Creates an action that unhides a node
483 #[unsafe(method(unhide))]
484 #[unsafe(method_family = none)]
485 pub unsafe fn unhide() -> Retained<SKAction>;
486
487 #[cfg(feature = "SKTexture")]
488 /// Creates an action that changes a sprite’s texture
489 ///
490 /// Parameter `texture`: The new texture to use on the sprite
491 #[unsafe(method(setTexture:))]
492 #[unsafe(method_family = none)]
493 pub unsafe fn setTexture(texture: &SKTexture) -> Retained<SKAction>;
494
495 #[cfg(feature = "SKTexture")]
496 #[unsafe(method(setNormalTexture:))]
497 #[unsafe(method_family = none)]
498 pub unsafe fn setNormalTexture(texture: &SKTexture) -> Retained<SKAction>;
499
500 #[cfg(feature = "SKTexture")]
501 /// Creates an action that changes a sprite’s texture, possibly resizing the sprite
502 ///
503 /// Parameter `texture`: The new texture to use on the sprite
504 ///
505 /// Parameter `resize`: If YES, the sprite is resized to match the new texture.
506 /// If NO, the size of the sprite is unchanged.
507 #[unsafe(method(setTexture:resize:))]
508 #[unsafe(method_family = none)]
509 pub unsafe fn setTexture_resize(texture: &SKTexture, resize: bool) -> Retained<SKAction>;
510
511 #[cfg(feature = "SKTexture")]
512 #[unsafe(method(setNormalTexture:resize:))]
513 #[unsafe(method_family = none)]
514 pub unsafe fn setNormalTexture_resize(
515 texture: &SKTexture,
516 resize: bool,
517 ) -> Retained<SKAction>;
518
519 #[cfg(feature = "SKTexture")]
520 /// Creates an action that animates changes to a sprite’s texture
521 ///
522 /// Parameter `textures`: An array of textures to use when animating a sprite
523 ///
524 /// Parameter `sec`: The amount of time that each texture is displayed
525 #[unsafe(method(animateWithTextures:timePerFrame:))]
526 #[unsafe(method_family = none)]
527 pub unsafe fn animateWithTextures_timePerFrame(
528 textures: &NSArray<SKTexture>,
529 sec: NSTimeInterval,
530 ) -> Retained<SKAction>;
531
532 #[cfg(feature = "SKTexture")]
533 #[unsafe(method(animateWithNormalTextures:timePerFrame:))]
534 #[unsafe(method_family = none)]
535 pub unsafe fn animateWithNormalTextures_timePerFrame(
536 textures: &NSArray<SKTexture>,
537 sec: NSTimeInterval,
538 ) -> Retained<SKAction>;
539
540 #[cfg(feature = "SKTexture")]
541 /// Creates an action that animates changes to a sprite’s texture
542 ///
543 /// Parameter `textures`: An array of textures to use when animating a sprite
544 ///
545 /// Parameter `sec`: The amount of time that each texture is displayed
546 ///
547 /// Parameter `resize`: If YES, the sprite is resized to match each new texture.
548 /// If NO, the size of the sprite remains at a constant size.
549 ///
550 /// Parameter `restore`: If YES, When the action completes, the sprite’s texture is restored
551 /// to the texture it had before the action completed. (If the
552 /// resize parameter is YES, the sprite is resized to match the
553 /// size of the original texture.
554 /// If NO, when the action completes the sprite’s texture remains
555 /// set to the final texture in the array.
556 #[unsafe(method(animateWithTextures:timePerFrame:resize:restore:))]
557 #[unsafe(method_family = none)]
558 pub unsafe fn animateWithTextures_timePerFrame_resize_restore(
559 textures: &NSArray<SKTexture>,
560 sec: NSTimeInterval,
561 resize: bool,
562 restore: bool,
563 ) -> Retained<SKAction>;
564
565 #[cfg(feature = "SKTexture")]
566 #[unsafe(method(animateWithNormalTextures:timePerFrame:resize:restore:))]
567 #[unsafe(method_family = none)]
568 pub unsafe fn animateWithNormalTextures_timePerFrame_resize_restore(
569 textures: &NSArray<SKTexture>,
570 sec: NSTimeInterval,
571 resize: bool,
572 restore: bool,
573 ) -> Retained<SKAction>;
574
575 /// Creates an action that plays a sound
576 ///
577 /// Parameter `soundFile`: The name of a sound file in the app’s bundle
578 ///
579 /// Parameter `wait`: If YES, then the duration of this action is the same
580 /// as the length of the audio playback. If NO, the action is considered
581 /// to have completed immediately.
582 ///
583 ///
584 /// The file name must be the name or path of a file of a platform
585 /// supported audio file format. Use a LinearPCM format audio file with 8 or 16 bits
586 /// per channel for best performance
587 #[unsafe(method(playSoundFileNamed:waitForCompletion:))]
588 #[unsafe(method_family = none)]
589 pub unsafe fn playSoundFileNamed_waitForCompletion(
590 sound_file: &NSString,
591 wait: bool,
592 ) -> Retained<SKAction>;
593
594 #[cfg(all(feature = "objc2-app-kit", feature = "objc2-core-foundation"))]
595 #[cfg(target_os = "macos")]
596 /// Creates an animation that animates a sprite’s color and blend factor
597 ///
598 /// Parameter `color`: The new color for the sprite
599 ///
600 /// Parameter `colorBlendFactor`: The new blend factor for the sprite
601 ///
602 /// Parameter `duration`: The duration of the animation, in seconds
603 #[unsafe(method(colorizeWithColor:colorBlendFactor:duration:))]
604 #[unsafe(method_family = none)]
605 pub unsafe fn colorizeWithColor_colorBlendFactor_duration(
606 color: &NSColor,
607 color_blend_factor: CGFloat,
608 duration: NSTimeInterval,
609 ) -> Retained<SKAction>;
610
611 #[cfg(feature = "objc2-core-foundation")]
612 #[unsafe(method(colorizeWithColorBlendFactor:duration:))]
613 #[unsafe(method_family = none)]
614 pub unsafe fn colorizeWithColorBlendFactor_duration(
615 color_blend_factor: CGFloat,
616 sec: NSTimeInterval,
617 ) -> Retained<SKAction>;
618
619 /// Creates an action that sets the falloff of a field
620 ///
621 /// Parameter `falloff`: The new value for falloff
622 ///
623 /// Parameter `duration`: The duration of the animation, in seconds
624 ///
625 /// See: SKFieldNode
626 #[unsafe(method(falloffTo:duration:))]
627 #[unsafe(method_family = none)]
628 pub unsafe fn falloffTo_duration(
629 falloff: c_float,
630 duration: NSTimeInterval,
631 ) -> Retained<SKAction>;
632
633 /// Creates an action that sets the falloff of a field
634 ///
635 /// Parameter `falloff`: The value to modify falloff by
636 ///
637 /// Parameter `duration`: The duration of the animation, in seconds
638 ///
639 /// See: SKFieldNode
640 #[unsafe(method(falloffBy:duration:))]
641 #[unsafe(method_family = none)]
642 pub unsafe fn falloffBy_duration(
643 falloff: c_float,
644 duration: NSTimeInterval,
645 ) -> Retained<SKAction>;
646
647 #[cfg(feature = "objc2-core-graphics")]
648 /// Creates an action that moves the node along a relative path, orienting the
649 /// node to the path
650 ///
651 ///
652 /// Parameter `path`: A Core Graphics path whose coordinates are relative to the node’s
653 /// current position
654 ///
655 /// Parameter `duration`: The duration of the animation, in seconds
656 #[unsafe(method(followPath:duration:))]
657 #[unsafe(method_family = none)]
658 pub unsafe fn followPath_duration(
659 path: &CGPath,
660 duration: NSTimeInterval,
661 ) -> Retained<SKAction>;
662
663 #[cfg(feature = "objc2-core-graphics")]
664 /// Creates an action that moves the node along a path
665 ///
666 ///
667 /// Parameter `path`: A Core Graphics path whose coordinates are relative to the node’s
668 /// current position
669 ///
670 /// Parameter `offset`: If YES, the points in the path are relative offsets to the
671 /// node’s starting position. If NO, the points in the node are absolute
672 /// coordinate values.
673 ///
674 /// Parameter `orient`: If YES, the node’s zRotation property animates so that
675 /// the node turns to follow the path. If NO, the zRotation property of
676 /// the node is unchanged.
677 ///
678 /// Parameter `duration`: The duration of the animation
679 #[unsafe(method(followPath:asOffset:orientToPath:duration:))]
680 #[unsafe(method_family = none)]
681 pub unsafe fn followPath_asOffset_orientToPath_duration(
682 path: &CGPath,
683 offset: bool,
684 orient: bool,
685 duration: NSTimeInterval,
686 ) -> Retained<SKAction>;
687
688 #[cfg(all(feature = "objc2-core-foundation", feature = "objc2-core-graphics"))]
689 /// Creates an action that moves the node along a relative path, orienting the
690 /// node to the path
691 ///
692 ///
693 /// Parameter `path`: A Core Graphics path whose coordinates are relative to the node’s
694 /// current position
695 ///
696 /// Parameter `speed`: The speed in pixels per second to move along the path
697 #[unsafe(method(followPath:speed:))]
698 #[unsafe(method_family = none)]
699 pub unsafe fn followPath_speed(path: &CGPath, speed: CGFloat) -> Retained<SKAction>;
700
701 #[cfg(all(feature = "objc2-core-foundation", feature = "objc2-core-graphics"))]
702 #[unsafe(method(followPath:asOffset:orientToPath:speed:))]
703 #[unsafe(method_family = none)]
704 pub unsafe fn followPath_asOffset_orientToPath_speed(
705 path: &CGPath,
706 offset: bool,
707 orient: bool,
708 speed: CGFloat,
709 ) -> Retained<SKAction>;
710
711 #[cfg(feature = "objc2-core-foundation")]
712 /// Creates an action that changes how fast the node executes actions by a
713 /// relative value
714 ///
715 /// Parameter `speed`: amount to modify the speed by
716 ///
717 /// Parameter `duration`: The duration of the animation, in seconds
718 #[unsafe(method(speedBy:duration:))]
719 #[unsafe(method_family = none)]
720 pub unsafe fn speedBy_duration(
721 speed: CGFloat,
722 duration: NSTimeInterval,
723 ) -> Retained<SKAction>;
724
725 #[cfg(feature = "objc2-core-foundation")]
726 /// Creates an action that changes how fast the node executes actions
727 ///
728 /// Parameter `speed`: The new value for the node’s speed
729 ///
730 /// Parameter `duration`: The duration of the animation, in seconds
731 #[unsafe(method(speedTo:duration:))]
732 #[unsafe(method_family = none)]
733 pub unsafe fn speedTo_duration(
734 speed: CGFloat,
735 duration: NSTimeInterval,
736 ) -> Retained<SKAction>;
737
738 #[cfg(all(
739 feature = "SKNode",
740 feature = "objc2-app-kit",
741 feature = "objc2-core-foundation"
742 ))]
743 #[cfg(target_os = "macos")]
744 /// Creates an action that performs an inverse kinematic reach.
745 /// This action must be run on a descendent of the rootNode for animation to occur.
746 /// Running this action on the rootNode itself will not cause any animation to occur.
747 ///
748 /// Parameter `position`: The position (in screen space) to reach for
749 ///
750 /// Parameter `root`: Where to start the inverse kinematic operation from
751 ///
752 /// Parameter `duration`: The duration of the animation, in seconds
753 #[unsafe(method(reachTo:rootNode:duration:))]
754 #[unsafe(method_family = none)]
755 pub unsafe fn reachTo_rootNode_duration(
756 position: CGPoint,
757 root: &SKNode,
758 duration: NSTimeInterval,
759 ) -> Retained<SKAction>;
760
761 #[cfg(all(
762 feature = "SKNode",
763 feature = "objc2-app-kit",
764 feature = "objc2-core-foundation"
765 ))]
766 #[cfg(target_os = "macos")]
767 /// Creates an action that performs an inverse kinematic reach.
768 /// This action must be run on a descendent of the rootNode for animation to occur.
769 /// Running this action on the rootNode itself will not cause any animation to occur.
770 ///
771 /// Parameter `position`: The position (in screen space) to reach for
772 ///
773 /// Parameter `root`: Where to start the inverse kinematic operation from
774 ///
775 /// Parameter `velocity`: The speed in points per second of the end node in the chain
776 #[unsafe(method(reachTo:rootNode:velocity:))]
777 #[unsafe(method_family = none)]
778 pub unsafe fn reachTo_rootNode_velocity(
779 position: CGPoint,
780 root: &SKNode,
781 velocity: CGFloat,
782 ) -> Retained<SKAction>;
783
784 #[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
785 #[cfg(target_os = "macos")]
786 /// Creates an action that performs an inverse kinematic reach.
787 /// This action must be run on a descendent of the rootNode for animation to occur.
788 /// Running this action on the rootNode itself will not cause any animation to occur.
789 ///
790 /// Parameter `node`: The node to reach for
791 ///
792 /// Parameter `root`: Where to start the inverse kinematic operation from
793 ///
794 /// Parameter `sec`: The duration of the animation, in seconds
795 #[unsafe(method(reachToNode:rootNode:duration:))]
796 #[unsafe(method_family = none)]
797 pub unsafe fn reachToNode_rootNode_duration(
798 node: &SKNode,
799 root: &SKNode,
800 sec: NSTimeInterval,
801 ) -> Retained<SKAction>;
802
803 #[cfg(all(
804 feature = "SKNode",
805 feature = "objc2-app-kit",
806 feature = "objc2-core-foundation"
807 ))]
808 #[cfg(target_os = "macos")]
809 /// Creates an action that performs an inverse kinematic reach.
810 /// This action must be run on a descendent of the rootNode for animation to occur.
811 /// Running this action on the rootNode itself will not cause any animation to occur.
812 ///
813 /// Parameter `node`: The node to reach for
814 ///
815 /// Parameter `root`: Where to start the inverse kinematic operation from
816 ///
817 /// Parameter `velocity`: The speed in points per second of the end node in the chain
818 #[unsafe(method(reachToNode:rootNode:velocity:))]
819 #[unsafe(method_family = none)]
820 pub unsafe fn reachToNode_rootNode_velocity(
821 node: &SKNode,
822 root: &SKNode,
823 velocity: CGFloat,
824 ) -> Retained<SKAction>;
825
826 /// Creates an action that sets the strength of a field
827 ///
828 /// Parameter `strength`: The new value for strength
829 ///
830 /// Parameter `duration`: The duration of the animation, in seconds
831 ///
832 /// See: SKFieldNode
833 #[unsafe(method(strengthTo:duration:))]
834 #[unsafe(method_family = none)]
835 pub unsafe fn strengthTo_duration(
836 strength: c_float,
837 duration: NSTimeInterval,
838 ) -> Retained<SKAction>;
839
840 /// Creates an action that sets the strength of a field
841 ///
842 /// Parameter `strength`: The value to modify strength by
843 ///
844 /// Parameter `duration`: The duration of the animation, in seconds
845 ///
846 /// See: SKFieldNode
847 #[unsafe(method(strengthBy:duration:))]
848 #[unsafe(method_family = none)]
849 pub unsafe fn strengthBy_duration(
850 strength: c_float,
851 duration: NSTimeInterval,
852 ) -> Retained<SKAction>;
853
854 /// Creates an action that idles for a specified period of time
855 ///
856 /// Parameter `duration`: The duration of the idle, in seconds
857 #[unsafe(method(waitForDuration:))]
858 #[unsafe(method_family = none)]
859 pub unsafe fn waitForDuration(duration: NSTimeInterval) -> Retained<SKAction>;
860
861 /// Creates an action that idles for a randomized period of time
862 ///
863 /// Parameter `duration`: The duration of the idle, in seconds
864 ///
865 /// Parameter `durationRange`: The range of possible values for the duration
866 #[unsafe(method(waitForDuration:withRange:))]
867 #[unsafe(method_family = none)]
868 pub unsafe fn waitForDuration_withRange(
869 duration: NSTimeInterval,
870 duration_range: NSTimeInterval,
871 ) -> Retained<SKAction>;
872
873 /// Creates an action that removes the node from its parent
874 #[unsafe(method(removeFromParent))]
875 #[unsafe(method_family = none)]
876 pub unsafe fn removeFromParent() -> Retained<SKAction>;
877
878 /// Creates an action that calls a method on an object
879 ///
880 /// Parameter `selector`: The selector of the method to call
881 ///
882 /// Parameter `target`: The target object
883 #[unsafe(method(performSelector:onTarget:))]
884 #[unsafe(method_family = none)]
885 pub unsafe fn performSelector_onTarget(
886 selector: Sel,
887 target: &AnyObject,
888 ) -> Retained<SKAction>;
889
890 #[cfg(feature = "dispatch2")]
891 /// Creates an action that executes a block
892 ///
893 /// Parameter `block`: The block to run
894 #[unsafe(method(runBlock:))]
895 #[unsafe(method_family = none)]
896 pub unsafe fn runBlock(block: dispatch_block_t) -> Retained<SKAction>;
897
898 #[cfg(feature = "dispatch2")]
899 /// Creates an action that executes a block
900 ///
901 /// Parameter `block`: The block to run
902 ///
903 /// Parameter `queue`: The queue to perform the action on
904 #[unsafe(method(runBlock:queue:))]
905 #[unsafe(method_family = none)]
906 pub unsafe fn runBlock_queue(
907 block: dispatch_block_t,
908 queue: &DispatchQueue,
909 ) -> Retained<SKAction>;
910
911 /// Creates an action that runs an action on a named child object
912 ///
913 /// Parameter `action`: the action to run
914 ///
915 /// Parameter `name`: the name of a child object
916 ///
917 /// See: SKNode.name
918 #[unsafe(method(runAction:onChildWithName:))]
919 #[unsafe(method_family = none)]
920 pub unsafe fn runAction_onChildWithName(
921 action: &SKAction,
922 name: &NSString,
923 ) -> Retained<SKAction>;
924
925 #[cfg(all(
926 feature = "SKNode",
927 feature = "block2",
928 feature = "objc2-app-kit",
929 feature = "objc2-core-foundation"
930 ))]
931 #[cfg(target_os = "macos")]
932 /// Creates an action that executes a block over a duration
933 ///
934 /// Parameter `duration`: The duration of the animation, in seconds
935 ///
936 /// Parameter `block`: The block to run. The block takes the following parameters:
937 /// node The node on which the action is running.
938 /// elapsedTime The amount of time that has passed in the animation.
939 #[unsafe(method(customActionWithDuration:actionBlock:))]
940 #[unsafe(method_family = none)]
941 pub unsafe fn customActionWithDuration_actionBlock(
942 duration: NSTimeInterval,
943 block: &block2::DynBlock<dyn Fn(NonNull<SKNode>, CGFloat)>,
944 ) -> Retained<SKAction>;
945
946 /// Creates an action of the given name from an action file.
947 ///
948 /// Parameter `name`: The name of the action
949 #[unsafe(method(actionNamed:))]
950 #[unsafe(method_family = none)]
951 pub unsafe fn actionNamed(name: &NSString) -> Option<Retained<SKAction>>;
952
953 /// Creates an action of the given name from an action file with a new duration.
954 ///
955 /// Parameter `name`: The name of the action
956 ///
957 /// Parameter `duration`: The duration of the action
958 #[unsafe(method(actionNamed:duration:))]
959 #[unsafe(method_family = none)]
960 pub unsafe fn actionNamed_duration(
961 name: &NSString,
962 duration: NSTimeInterval,
963 ) -> Option<Retained<SKAction>>;
964
965 /// Creates an action of the given name from an action file.
966 ///
967 /// Parameter `name`: The name of the action
968 ///
969 /// Parameter `url`: The url of the file containing the action
970 #[unsafe(method(actionNamed:fromURL:))]
971 #[unsafe(method_family = none)]
972 pub unsafe fn actionNamed_fromURL(
973 name: &NSString,
974 url: &NSURL,
975 ) -> Option<Retained<SKAction>>;
976
977 /// Creates an action of the given name from an action file with a new duration.
978 ///
979 /// Parameter `name`: The name of the action
980 ///
981 /// Parameter `url`: The url of the file containing the action
982 ///
983 /// Parameter `duration`: The duration of the action
984 #[unsafe(method(actionNamed:fromURL:duration:))]
985 #[unsafe(method_family = none)]
986 pub unsafe fn actionNamed_fromURL_duration(
987 name: &NSString,
988 url: &NSURL,
989 duration: NSTimeInterval,
990 ) -> Option<Retained<SKAction>>;
991 );
992}
993
994/// NodeWithPhysicsBody.
995impl SKAction {
996 extern_methods!(
997 #[unsafe(method(changeChargeTo:duration:))]
998 #[unsafe(method_family = none)]
999 pub unsafe fn changeChargeTo_duration(
1000 v: c_float,
1001 duration: NSTimeInterval,
1002 ) -> Retained<SKAction>;
1003
1004 #[unsafe(method(changeChargeBy:duration:))]
1005 #[unsafe(method_family = none)]
1006 pub unsafe fn changeChargeBy_duration(
1007 v: c_float,
1008 duration: NSTimeInterval,
1009 ) -> Retained<SKAction>;
1010
1011 #[unsafe(method(changeMassTo:duration:))]
1012 #[unsafe(method_family = none)]
1013 pub unsafe fn changeMassTo_duration(
1014 v: c_float,
1015 duration: NSTimeInterval,
1016 ) -> Retained<SKAction>;
1017
1018 #[unsafe(method(changeMassBy:duration:))]
1019 #[unsafe(method_family = none)]
1020 pub unsafe fn changeMassBy_duration(
1021 v: c_float,
1022 duration: NSTimeInterval,
1023 ) -> Retained<SKAction>;
1024
1025 #[cfg(feature = "objc2-core-foundation")]
1026 #[unsafe(method(applyForce:duration:))]
1027 #[unsafe(method_family = none)]
1028 pub unsafe fn applyForce_duration(
1029 force: CGVector,
1030 duration: NSTimeInterval,
1031 ) -> Retained<SKAction>;
1032
1033 #[cfg(feature = "objc2-core-foundation")]
1034 #[unsafe(method(applyForce:atPoint:duration:))]
1035 #[unsafe(method_family = none)]
1036 pub unsafe fn applyForce_atPoint_duration(
1037 force: CGVector,
1038 point: CGPoint,
1039 duration: NSTimeInterval,
1040 ) -> Retained<SKAction>;
1041
1042 #[cfg(feature = "objc2-core-foundation")]
1043 #[unsafe(method(applyTorque:duration:))]
1044 #[unsafe(method_family = none)]
1045 pub unsafe fn applyTorque_duration(
1046 torque: CGFloat,
1047 duration: NSTimeInterval,
1048 ) -> Retained<SKAction>;
1049
1050 #[cfg(feature = "objc2-core-foundation")]
1051 #[unsafe(method(applyImpulse:duration:))]
1052 #[unsafe(method_family = none)]
1053 pub unsafe fn applyImpulse_duration(
1054 impulse: CGVector,
1055 duration: NSTimeInterval,
1056 ) -> Retained<SKAction>;
1057
1058 #[cfg(feature = "objc2-core-foundation")]
1059 #[unsafe(method(applyImpulse:atPoint:duration:))]
1060 #[unsafe(method_family = none)]
1061 pub unsafe fn applyImpulse_atPoint_duration(
1062 impulse: CGVector,
1063 point: CGPoint,
1064 duration: NSTimeInterval,
1065 ) -> Retained<SKAction>;
1066
1067 #[cfg(feature = "objc2-core-foundation")]
1068 #[unsafe(method(applyAngularImpulse:duration:))]
1069 #[unsafe(method_family = none)]
1070 pub unsafe fn applyAngularImpulse_duration(
1071 impulse: CGFloat,
1072 duration: NSTimeInterval,
1073 ) -> Retained<SKAction>;
1074 );
1075}
1076
1077/// PlaybackControl.
1078impl SKAction {
1079 extern_methods!(
1080 #[unsafe(method(play))]
1081 #[unsafe(method_family = none)]
1082 pub unsafe fn play() -> Retained<SKAction>;
1083
1084 #[unsafe(method(pause))]
1085 #[unsafe(method_family = none)]
1086 pub unsafe fn pause() -> Retained<SKAction>;
1087
1088 #[unsafe(method(stop))]
1089 #[unsafe(method_family = none)]
1090 pub unsafe fn stop() -> Retained<SKAction>;
1091
1092 #[unsafe(method(changePlaybackRateTo:duration:))]
1093 #[unsafe(method_family = none)]
1094 pub unsafe fn changePlaybackRateTo_duration(
1095 v: c_float,
1096 duration: NSTimeInterval,
1097 ) -> Retained<SKAction>;
1098
1099 #[unsafe(method(changePlaybackRateBy:duration:))]
1100 #[unsafe(method_family = none)]
1101 pub unsafe fn changePlaybackRateBy_duration(
1102 v: c_float,
1103 duration: NSTimeInterval,
1104 ) -> Retained<SKAction>;
1105 );
1106}
1107
1108/// MixerControl.
1109impl SKAction {
1110 extern_methods!(
1111 #[unsafe(method(changeVolumeTo:duration:))]
1112 #[unsafe(method_family = none)]
1113 pub unsafe fn changeVolumeTo_duration(
1114 v: c_float,
1115 duration: NSTimeInterval,
1116 ) -> Retained<SKAction>;
1117
1118 #[unsafe(method(changeVolumeBy:duration:))]
1119 #[unsafe(method_family = none)]
1120 pub unsafe fn changeVolumeBy_duration(
1121 v: c_float,
1122 duration: NSTimeInterval,
1123 ) -> Retained<SKAction>;
1124 );
1125}