Struct SKAction

Source
#[repr(C)]
pub struct SKAction { /* private fields */ }
Available on crate feature SKAction only.
Expand description

An SKAction object is an action that is executed by a node in the scene. Actions are most often used to change the structure and content of the node to which they are attached, but can also make other changes to the scene. When the scene processes its nodes, actions associated with those nodes are evaluated.

See also Apple’s documentation

Implementations§

Source§

impl SKAction

Source

pub unsafe fn duration(&self) -> NSTimeInterval

The duration required to complete an action, in seconds.

Source

pub unsafe fn setDuration(&self, duration: NSTimeInterval)

Setter for duration.

Source

pub unsafe fn timingMode(&self) -> SKActionTimingMode

The timing mode used to execute an action

See: SKActionTimingMode

Source

pub unsafe fn setTimingMode(&self, timing_mode: SKActionTimingMode)

Setter for timingMode.

Source

pub unsafe fn timingFunction(&self) -> SKActionTimingFunction

Available on crate feature block2 only.

When set, prodives a custom timing via a block. Applies after the ‘timingMode’ property is taken into account, defaults to nil

See: SKActionTimingFunction

Source

pub unsafe fn setTimingFunction(&self, timing_function: SKActionTimingFunction)

Available on crate feature block2 only.

Setter for timingFunction.

Source

pub unsafe fn speed(&self) -> CGFloat

Available on crate feature objc2-core-foundation only.

A speed factor that modifies how fast an action runs. Default value is 1.0

Source

pub unsafe fn setSpeed(&self, speed: CGFloat)

Available on crate feature objc2-core-foundation only.

Setter for speed.

Source

pub unsafe fn reversedAction(&self) -> Retained<SKAction>

Creates an action that reverses the behavior of another action

Returns: This method always returns an action object; however, not all actions are reversible

Source§

impl SKAction

Methods declared on superclass NSObject.

Source

pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>

Source

pub unsafe fn new() -> Retained<Self>

Source§

impl SKAction

SKActions.

Source

pub unsafe fn moveBy_duration( delta: CGVector, duration: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature objc2-core-foundation only.

Creates an action that moves a node relative to its current position

Parameter delta: A vector that describes the change to apply to the node’s position

Parameter duration: The duration of the animation, in seconds

Source

pub unsafe fn moveByX_y_duration( delta_x: CGFloat, delta_y: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature objc2-core-foundation only.
Source

pub unsafe fn moveTo_duration( location: CGPoint, duration: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature objc2-core-foundation only.

Creates an action that moves a node to a new position

Parameter location: The coordinates for the node’s new position

Parameter duration: The duration of the animation, in seconds

Source

pub unsafe fn moveToX_duration( x: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature objc2-core-foundation only.
Source

pub unsafe fn moveToY_duration( y: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature objc2-core-foundation only.
Source

pub unsafe fn rotateByAngle_duration( radians: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature objc2-core-foundation only.

Creates an action that rotates the node by a relative value

Parameter radians: The amount to rotate the node, in radians

Parameter duration: The duration of the animation, in seconds

Source

pub unsafe fn rotateToAngle_duration( radians: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature objc2-core-foundation only.

Creates an action that rotates the node counterclockwise to an absolute angle

Parameter radians: The angle to rotate the node to, in radians

Parameter duration: The duration of the animation

Source

pub unsafe fn rotateToAngle_duration_shortestUnitArc( radians: CGFloat, duration: NSTimeInterval, shortest_unit_arc: bool, ) -> Retained<SKAction>

Available on crate feature objc2-core-foundation only.

Creates an action that rotates the node to an absolute value

Parameter radians: The angle to rotate the node to, in radians

Parameter duration: The duration of the animation, in seconds

Parameter shortestUnitArc: If YES, then the rotation is performed in whichever direction results in the smallest rotation. If NO, then the rotation is interpolated

Source

pub unsafe fn resizeByWidth_height_duration( width: CGFloat, height: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature objc2-core-foundation only.

Creates an action that adjusts the size of a sprite

Parameter width: The amount to add to the sprite’s width

Parameter height: The amount to add to the sprite’s height

Parameter duration: The duration of the animation, in seconds

Source

pub unsafe fn resizeToWidth_height_duration( width: CGFloat, height: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature objc2-core-foundation only.

Creates an action that changes the width and height of a sprite to a new absolute value

Parameter width: The new width of the sprite

Parameter height: The new height of the sprite

Parameter duration: The duration of the animation, in seconds

Source

pub unsafe fn resizeToWidth_duration( width: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature objc2-core-foundation only.
Source

pub unsafe fn resizeToHeight_duration( height: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature objc2-core-foundation only.
Source

pub unsafe fn scaleBy_duration( scale: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature objc2-core-foundation only.

Creates an action that changes the x and y scale values of a node by a relative value

Parameter scale: The amount to modify to the node’s x and y scale values

Parameter duration: The duration of the animation, in seconds

Source

pub unsafe fn scaleXBy_y_duration( x_scale: CGFloat, y_scale: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature objc2-core-foundation only.
Source

pub unsafe fn scaleTo_duration( scale: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature objc2-core-foundation only.

Creates an action that changes the x and y scale values of a node by a relative value

Parameter scale: The new value for the node’s x and y scale values

Parameter duration: The duration of the animation, in seconds

Source

pub unsafe fn scaleXTo_y_duration( x_scale: CGFloat, y_scale: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature objc2-core-foundation only.
Source

pub unsafe fn scaleXTo_duration( scale: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature objc2-core-foundation only.
Source

pub unsafe fn scaleYTo_duration( scale: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature objc2-core-foundation only.
Source

pub unsafe fn scaleToSize_duration( size: CGSize, duration: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature objc2-core-foundation only.

Adjust the sprite’s xScale & yScale to achieve the desired size (in parent’s coordinate space)

Parameter duration: The duration of the animation, in seconds

Source

pub unsafe fn sequence(actions: &NSArray<SKAction>) -> Retained<SKAction>

Creates an action that runs a collection of actions sequentially

Parameter actions: An array of SKAction objects

When the action executes, the first action in the sequence starts and runs to completion. Subsequent actions in the sequence run in a similar fashion until all of the actions in the sequence have executed. The duration of the sequence action is the sum of the durations of the actions in the sequence.

This action is reversible; it creates a new sequence action that reverses the order of the actions. Each action in the reversed sequence is itself reversed. For example, if an action sequence is {1,2,3}, the reversed sequence would be {3R,2R,1R}.

Source

pub unsafe fn group(actions: &NSArray<SKAction>) -> Retained<SKAction>

Creates an action that runs a collection of actions concurrently

Parameter actions: An array of SKAction objects

When the action executes, the actions that comprise the group all start immediately and run in parallel. The duration of the group action is the longest duration among the collection of actions. If an action in the group has a duration less than the group’s duration, the action completes, then idles until the group completes the remaining actions. This matters most when creating a repeating action that repeats a group.

Source

pub unsafe fn repeatAction_count( action: &SKAction, count: NSUInteger, ) -> Retained<SKAction>

Creates an action that repeats another action a specified number of times

Parameter action: The action to execute

Parameter count: The number of times to execute the action

Source

pub unsafe fn repeatActionForever(action: &SKAction) -> Retained<SKAction>

Creates an action that repeats forever

Parameter action: The action to execute

Source

pub unsafe fn fadeInWithDuration(duration: NSTimeInterval) -> Retained<SKAction>

Creates an action that changes the alpha value of the node to 1.0

Parameter duration: The duration of the animation, in seconds

Source

pub unsafe fn fadeOutWithDuration( duration: NSTimeInterval, ) -> Retained<SKAction>

Creates an action that changes the alpha value of the node to 0.0

Parameter duration: The duration of the animation, in seconds

Source

pub unsafe fn fadeAlphaBy_duration( factor: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature objc2-core-foundation only.

Creates an action that adjusts the alpha value of a node by a relative value

Parameter factor: The amount to modify the node’s alpha value

Parameter duration: The duration of the animation, in seconds

Source

pub unsafe fn fadeAlphaTo_duration( alpha: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature objc2-core-foundation only.

Creates an action that adjusts the alpha value of a node to a new value

Parameter alpha: The new value of the node’s alpha

Parameter duration: The duration of the animation, in seconds

Source

pub unsafe fn hide() -> Retained<SKAction>

Creates an action that hides a node

Source

pub unsafe fn unhide() -> Retained<SKAction>

Creates an action that unhides a node

Source

pub unsafe fn setTexture(texture: &SKTexture) -> Retained<SKAction>

Available on crate feature SKTexture only.

Creates an action that changes a sprite’s texture

Parameter texture: The new texture to use on the sprite

Source

pub unsafe fn setNormalTexture(texture: &SKTexture) -> Retained<SKAction>

Available on crate feature SKTexture only.
Source

pub unsafe fn setTexture_resize( texture: &SKTexture, resize: bool, ) -> Retained<SKAction>

Available on crate feature SKTexture only.

Creates an action that changes a sprite’s texture, possibly resizing the sprite

Parameter texture: The new texture to use on the sprite

Parameter resize: If YES, the sprite is resized to match the new texture. If NO, the size of the sprite is unchanged.

Source

pub unsafe fn setNormalTexture_resize( texture: &SKTexture, resize: bool, ) -> Retained<SKAction>

Available on crate feature SKTexture only.
Source

pub unsafe fn animateWithTextures_timePerFrame( textures: &NSArray<SKTexture>, sec: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature SKTexture only.

Creates an action that animates changes to a sprite’s texture

Parameter textures: An array of textures to use when animating a sprite

Parameter sec: The amount of time that each texture is displayed

Source

pub unsafe fn animateWithNormalTextures_timePerFrame( textures: &NSArray<SKTexture>, sec: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature SKTexture only.
Source

pub unsafe fn animateWithTextures_timePerFrame_resize_restore( textures: &NSArray<SKTexture>, sec: NSTimeInterval, resize: bool, restore: bool, ) -> Retained<SKAction>

Available on crate feature SKTexture only.

Creates an action that animates changes to a sprite’s texture

Parameter textures: An array of textures to use when animating a sprite

Parameter sec: The amount of time that each texture is displayed

Parameter resize: If YES, the sprite is resized to match each new texture. If NO, the size of the sprite remains at a constant size.

Parameter restore: If YES, When the action completes, the sprite’s texture is restored to the texture it had before the action completed. (If the resize parameter is YES, the sprite is resized to match the size of the original texture. If NO, when the action completes the sprite’s texture remains set to the final texture in the array.

Source

pub unsafe fn animateWithNormalTextures_timePerFrame_resize_restore( textures: &NSArray<SKTexture>, sec: NSTimeInterval, resize: bool, restore: bool, ) -> Retained<SKAction>

Available on crate feature SKTexture only.
Source

pub unsafe fn playSoundFileNamed_waitForCompletion( sound_file: &NSString, wait: bool, ) -> Retained<SKAction>

Creates an action that plays a sound

Parameter soundFile: The name of a sound file in the app’s bundle

Parameter wait: If YES, then the duration of this action is the same as the length of the audio playback. If NO, the action is considered to have completed immediately.

The file name must be the name or path of a file of a platform supported audio file format. Use a LinearPCM format audio file with 8 or 16 bits per channel for best performance

Source

pub unsafe fn colorizeWithColor_colorBlendFactor_duration( color: &NSColor, color_blend_factor: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature objc2-app-kit and crate feature objc2-core-foundation and macOS only.

Creates an animation that animates a sprite’s color and blend factor

Parameter color: The new color for the sprite

Parameter colorBlendFactor: The new blend factor for the sprite

Parameter duration: The duration of the animation, in seconds

Source

pub unsafe fn colorizeWithColorBlendFactor_duration( color_blend_factor: CGFloat, sec: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature objc2-core-foundation only.
Source

pub unsafe fn falloffTo_duration( falloff: c_float, duration: NSTimeInterval, ) -> Retained<SKAction>

Creates an action that sets the falloff of a field

Parameter falloff: The new value for falloff

Parameter duration: The duration of the animation, in seconds

See: SKFieldNode

Source

pub unsafe fn falloffBy_duration( falloff: c_float, duration: NSTimeInterval, ) -> Retained<SKAction>

Creates an action that sets the falloff of a field

Parameter falloff: The value to modify falloff by

Parameter duration: The duration of the animation, in seconds

See: SKFieldNode

Source

pub unsafe fn followPath_duration( path: &CGPath, duration: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature objc2-core-graphics only.

Creates an action that moves the node along a relative path, orienting the node to the path

Parameter path: A Core Graphics path whose coordinates are relative to the node’s current position

Parameter duration: The duration of the animation, in seconds

Source

pub unsafe fn followPath_asOffset_orientToPath_duration( path: &CGPath, offset: bool, orient: bool, duration: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature objc2-core-graphics only.

Creates an action that moves the node along a path

Parameter path: A Core Graphics path whose coordinates are relative to the node’s current position

Parameter offset: If YES, the points in the path are relative offsets to the node’s starting position. If NO, the points in the node are absolute coordinate values.

Parameter orient: If YES, the node’s zRotation property animates so that the node turns to follow the path. If NO, the zRotation property of the node is unchanged.

Parameter duration: The duration of the animation

Source

pub unsafe fn followPath_speed( path: &CGPath, speed: CGFloat, ) -> Retained<SKAction>

Available on crate features objc2-core-foundation and objc2-core-graphics only.

Creates an action that moves the node along a relative path, orienting the node to the path

Parameter path: A Core Graphics path whose coordinates are relative to the node’s current position

Parameter speed: The speed in pixels per second to move along the path

Source

pub unsafe fn followPath_asOffset_orientToPath_speed( path: &CGPath, offset: bool, orient: bool, speed: CGFloat, ) -> Retained<SKAction>

Available on crate features objc2-core-foundation and objc2-core-graphics only.
Source

pub unsafe fn speedBy_duration( speed: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature objc2-core-foundation only.

Creates an action that changes how fast the node executes actions by a relative value

Parameter speed: amount to modify the speed by

Parameter duration: The duration of the animation, in seconds

Source

pub unsafe fn speedTo_duration( speed: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature objc2-core-foundation only.

Creates an action that changes how fast the node executes actions

Parameter speed: The new value for the node’s speed

Parameter duration: The duration of the animation, in seconds

Source

pub unsafe fn reachTo_rootNode_duration( position: CGPoint, root: &SKNode, duration: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature SKNode and crate feature objc2-app-kit and crate feature objc2-core-foundation and macOS only.

Creates an action that performs an inverse kinematic reach. This action must be run on a descendent of the rootNode for animation to occur. Running this action on the rootNode itself will not cause any animation to occur.

Parameter position: The position (in screen space) to reach for

Parameter root: Where to start the inverse kinematic operation from

Parameter duration: The duration of the animation, in seconds

Source

pub unsafe fn reachTo_rootNode_velocity( position: CGPoint, root: &SKNode, velocity: CGFloat, ) -> Retained<SKAction>

Available on crate feature SKNode and crate feature objc2-app-kit and crate feature objc2-core-foundation and macOS only.

Creates an action that performs an inverse kinematic reach. This action must be run on a descendent of the rootNode for animation to occur. Running this action on the rootNode itself will not cause any animation to occur.

Parameter position: The position (in screen space) to reach for

Parameter root: Where to start the inverse kinematic operation from

Parameter velocity: The speed in points per second of the end node in the chain

Source

pub unsafe fn reachToNode_rootNode_duration( node: &SKNode, root: &SKNode, sec: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature SKNode and crate feature objc2-app-kit and macOS only.

Creates an action that performs an inverse kinematic reach. This action must be run on a descendent of the rootNode for animation to occur. Running this action on the rootNode itself will not cause any animation to occur.

Parameter node: The node to reach for

Parameter root: Where to start the inverse kinematic operation from

Parameter sec: The duration of the animation, in seconds

Source

pub unsafe fn reachToNode_rootNode_velocity( node: &SKNode, root: &SKNode, velocity: CGFloat, ) -> Retained<SKAction>

Available on crate feature SKNode and crate feature objc2-app-kit and crate feature objc2-core-foundation and macOS only.

Creates an action that performs an inverse kinematic reach. This action must be run on a descendent of the rootNode for animation to occur. Running this action on the rootNode itself will not cause any animation to occur.

Parameter node: The node to reach for

Parameter root: Where to start the inverse kinematic operation from

Parameter velocity: The speed in points per second of the end node in the chain

Source

pub unsafe fn strengthTo_duration( strength: c_float, duration: NSTimeInterval, ) -> Retained<SKAction>

Creates an action that sets the strength of a field

Parameter strength: The new value for strength

Parameter duration: The duration of the animation, in seconds

See: SKFieldNode

Source

pub unsafe fn strengthBy_duration( strength: c_float, duration: NSTimeInterval, ) -> Retained<SKAction>

Creates an action that sets the strength of a field

Parameter strength: The value to modify strength by

Parameter duration: The duration of the animation, in seconds

See: SKFieldNode

Source

pub unsafe fn waitForDuration(duration: NSTimeInterval) -> Retained<SKAction>

Creates an action that idles for a specified period of time

Parameter duration: The duration of the idle, in seconds

Source

pub unsafe fn waitForDuration_withRange( duration: NSTimeInterval, duration_range: NSTimeInterval, ) -> Retained<SKAction>

Creates an action that idles for a randomized period of time

Parameter duration: The duration of the idle, in seconds

Parameter durationRange: The range of possible values for the duration

Source

pub unsafe fn removeFromParent() -> Retained<SKAction>

Creates an action that removes the node from its parent

Source

pub unsafe fn performSelector_onTarget( selector: Sel, target: &AnyObject, ) -> Retained<SKAction>

Creates an action that calls a method on an object

Parameter selector: The selector of the method to call

Parameter target: The target object

Source

pub unsafe fn runAction_onChildWithName( action: &SKAction, name: &NSString, ) -> Retained<SKAction>

Creates an action that runs an action on a named child object

Parameter action: the action to run

Parameter name: the name of a child object

See: SKNode.name

Source

pub unsafe fn customActionWithDuration_actionBlock( duration: NSTimeInterval, block: &Block<dyn Fn(NonNull<SKNode>, CGFloat)>, ) -> Retained<SKAction>

Available on crate feature SKNode and crate feature block2 and crate feature objc2-app-kit and crate feature objc2-core-foundation and macOS only.

Creates an action that executes a block over a duration

Parameter duration: The duration of the animation, in seconds

Parameter block: The block to run. The block takes the following parameters: node The node on which the action is running. elapsedTime The amount of time that has passed in the animation.

Source

pub unsafe fn actionNamed(name: &NSString) -> Option<Retained<SKAction>>

Creates an action of the given name from an action file.

Parameter name: The name of the action

Source

pub unsafe fn actionNamed_duration( name: &NSString, duration: NSTimeInterval, ) -> Option<Retained<SKAction>>

Creates an action of the given name from an action file with a new duration.

Parameter name: The name of the action

Parameter duration: The duration of the action

Source

pub unsafe fn actionNamed_fromURL( name: &NSString, url: &NSURL, ) -> Option<Retained<SKAction>>

Creates an action of the given name from an action file.

Parameter name: The name of the action

Parameter url: The url of the file containing the action

Source

pub unsafe fn actionNamed_fromURL_duration( name: &NSString, url: &NSURL, duration: NSTimeInterval, ) -> Option<Retained<SKAction>>

Creates an action of the given name from an action file with a new duration.

Parameter name: The name of the action

Parameter url: The url of the file containing the action

Parameter duration: The duration of the action

Source§

impl SKAction

NodeWithPhysicsBody.

Source

pub unsafe fn changeChargeTo_duration( v: c_float, duration: NSTimeInterval, ) -> Retained<SKAction>

Source

pub unsafe fn changeChargeBy_duration( v: c_float, duration: NSTimeInterval, ) -> Retained<SKAction>

Source

pub unsafe fn changeMassTo_duration( v: c_float, duration: NSTimeInterval, ) -> Retained<SKAction>

Source

pub unsafe fn changeMassBy_duration( v: c_float, duration: NSTimeInterval, ) -> Retained<SKAction>

Source

pub unsafe fn applyForce_duration( force: CGVector, duration: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature objc2-core-foundation only.
Source

pub unsafe fn applyForce_atPoint_duration( force: CGVector, point: CGPoint, duration: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature objc2-core-foundation only.
Source

pub unsafe fn applyTorque_duration( torque: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature objc2-core-foundation only.
Source

pub unsafe fn applyImpulse_duration( impulse: CGVector, duration: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature objc2-core-foundation only.
Source

pub unsafe fn applyImpulse_atPoint_duration( impulse: CGVector, point: CGPoint, duration: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature objc2-core-foundation only.
Source

pub unsafe fn applyAngularImpulse_duration( impulse: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature objc2-core-foundation only.
Source§

impl SKAction

PlaybackControl.

Source§

impl SKAction

MixerControl.

Source§

impl SKAction

SKAudioNode. Actions that are to be used with audio nodes.

Source

pub unsafe fn stereoPanTo_duration( v: c_float, duration: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature SKAudioNode only.
Source

pub unsafe fn stereoPanBy_duration( v: c_float, duration: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature SKAudioNode only.
Source

pub unsafe fn changeReverbTo_duration( v: c_float, duration: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature SKAudioNode only.
Source

pub unsafe fn changeReverbBy_duration( v: c_float, duration: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature SKAudioNode only.
Source

pub unsafe fn changeObstructionTo_duration( v: c_float, duration: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature SKAudioNode only.
Source

pub unsafe fn changeObstructionBy_duration( v: c_float, duration: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature SKAudioNode only.
Source

pub unsafe fn changeOcclusionTo_duration( v: c_float, duration: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature SKAudioNode only.
Source

pub unsafe fn changeOcclusionBy_duration( v: c_float, duration: NSTimeInterval, ) -> Retained<SKAction>

Available on crate feature SKAudioNode only.
Source§

impl SKAction

SKWarpable.

Source

pub unsafe fn warpTo_duration( warp: &SKWarpGeometry, duration: NSTimeInterval, ) -> Option<Retained<SKAction>>

Available on crate feature SKWarpGeometry only.
Source

pub unsafe fn animateWithWarps_times( warps: &NSArray<SKWarpGeometry>, times: &NSArray<NSNumber>, ) -> Option<Retained<SKAction>>

Available on crate feature SKWarpGeometry only.
Source

pub unsafe fn animateWithWarps_times_restore( warps: &NSArray<SKWarpGeometry>, times: &NSArray<NSNumber>, restore: bool, ) -> Option<Retained<SKAction>>

Available on crate feature SKWarpGeometry only.

Methods from Deref<Target = NSObject>§

Source

pub fn doesNotRecognizeSelector(&self, sel: Sel) -> !

Handle messages the object doesn’t recognize.

See Apple’s documentation for details.

Methods from Deref<Target = AnyObject>§

Source

pub fn class(&self) -> &'static AnyClass

Dynamically find the class of this object.

§Example

Check that an instance of NSObject has the precise class NSObject.

use objc2::ClassType;
use objc2::runtime::NSObject;

let obj = NSObject::new();
assert_eq!(obj.class(), NSObject::class());
Source

pub unsafe fn get_ivar<T>(&self, name: &str) -> &T
where T: Encode,

👎Deprecated: this is difficult to use correctly, use Ivar::load instead.

Use Ivar::load instead.

§Safety

The object must have an instance variable with the given name, and it must be of type T.

See Ivar::load_ptr for details surrounding this.

Source

pub fn downcast_ref<T>(&self) -> Option<&T>
where T: DowncastTarget,

Attempt to downcast the object to a class of type T.

This is the reference-variant. Use Retained::downcast if you want to convert a retained object to another type.

§Mutable classes

Some classes have immutable and mutable variants, such as NSString and NSMutableString.

When some Objective-C API signature says it gives you an immutable class, it generally expects you to not mutate that, even though it may technically be mutable “under the hood”.

So using this method to convert a NSString to a NSMutableString, while not unsound, is generally frowned upon unless you created the string yourself, or the API explicitly documents the string to be mutable.

See Apple’s documentation on mutability and on isKindOfClass: for more details.

§Generic classes

Objective-C generics are called “lightweight generics”, and that’s because they aren’t exposed in the runtime. This makes it impossible to safely downcast to generic collections, so this is disallowed by this method.

You can, however, safely downcast to generic collections where all the type-parameters are AnyObject.

§Panics

This works internally by calling isKindOfClass:. That means that the object must have the instance method of that name, and an exception will be thrown (if CoreFoundation is linked) or the process will abort if that is not the case. In the vast majority of cases, you don’t need to worry about this, since both root objects NSObject and NSProxy implement this method.

§Examples

Cast an NSString back and forth from NSObject.

use objc2::rc::Retained;
use objc2_foundation::{NSObject, NSString};

let obj: Retained<NSObject> = NSString::new().into_super();
let string = obj.downcast_ref::<NSString>().unwrap();
// Or with `downcast`, if we do not need the object afterwards
let string = obj.downcast::<NSString>().unwrap();

Try (and fail) to cast an NSObject to an NSString.

use objc2_foundation::{NSObject, NSString};

let obj = NSObject::new();
assert!(obj.downcast_ref::<NSString>().is_none());

Try to cast to an array of strings.

use objc2_foundation::{NSArray, NSObject, NSString};

let arr = NSArray::from_retained_slice(&[NSObject::new()]);
// This is invalid and doesn't type check.
let arr = arr.downcast_ref::<NSArray<NSString>>();

This fails to compile, since it would require enumerating over the array to ensure that each element is of the desired type, which is a performance pitfall.

Downcast when processing each element instead.

use objc2_foundation::{NSArray, NSObject, NSString};

let arr = NSArray::from_retained_slice(&[NSObject::new()]);

for elem in arr {
    if let Some(data) = elem.downcast_ref::<NSString>() {
        // handle `data`
    }
}

Trait Implementations§

Source§

impl AsRef<AnyObject> for SKAction

Source§

fn as_ref(&self) -> &AnyObject

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<NSObject> for SKAction

Source§

fn as_ref(&self) -> &NSObject

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<SKAction> for SKAction

Source§

fn as_ref(&self) -> &Self

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Borrow<AnyObject> for SKAction

Source§

fn borrow(&self) -> &AnyObject

Immutably borrows from an owned value. Read more
Source§

impl Borrow<NSObject> for SKAction

Source§

fn borrow(&self) -> &NSObject

Immutably borrows from an owned value. Read more
Source§

impl ClassType for SKAction

Source§

const NAME: &'static str = "SKAction"

The name of the Objective-C class that this type represents. Read more
Source§

type Super = NSObject

The superclass of this class. Read more
Source§

type ThreadKind = <<SKAction as ClassType>::Super as ClassType>::ThreadKind

Whether the type can be used from any thread, or from only the main thread. Read more
Source§

fn class() -> &'static AnyClass

Get a reference to the Objective-C class that this type represents. Read more
Source§

fn as_super(&self) -> &Self::Super

Get an immutable reference to the superclass.
Source§

impl CopyingHelper for SKAction

Source§

type Result = SKAction

The immutable counterpart of the type, or Self if the type has no immutable counterpart. Read more
Source§

impl Debug for SKAction

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for SKAction

Source§

type Target = NSObject

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl Hash for SKAction

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Message for SKAction

Source§

fn retain(&self) -> Retained<Self>
where Self: Sized,

Increment the reference count of the receiver. Read more
Source§

impl NSCoding for SKAction

Source§

unsafe fn encodeWithCoder(&self, coder: &NSCoder)
where Self: Sized + Message,

Available on crate feature NSCoder only.
Source§

unsafe fn initWithCoder( this: Allocated<Self>, coder: &NSCoder, ) -> Option<Retained<Self>>
where Self: Sized + Message,

Available on crate feature NSCoder only.
Source§

impl NSCopying for SKAction

Source§

fn copy(&self) -> Retained<Self::Result>
where Self: Sized + Message + CopyingHelper,

Returns a new instance that’s a copy of the receiver. Read more
Source§

unsafe fn copyWithZone(&self, zone: *mut NSZone) -> Retained<Self::Result>
where Self: Sized + Message + CopyingHelper,

Returns a new instance that’s a copy of the receiver. Read more
Source§

impl NSObjectProtocol for SKAction

Source§

fn isEqual(&self, other: Option<&AnyObject>) -> bool
where Self: Sized + Message,

Check whether the object is equal to an arbitrary other object. Read more
Source§

fn hash(&self) -> usize
where Self: Sized + Message,

An integer that can be used as a table address in a hash table structure. Read more
Source§

fn isKindOfClass(&self, cls: &AnyClass) -> bool
where Self: Sized + Message,

Check if the object is an instance of the class, or one of its subclasses. Read more
Source§

fn is_kind_of<T>(&self) -> bool
where T: ClassType, Self: Sized + Message,

👎Deprecated: use isKindOfClass directly, or cast your objects with AnyObject::downcast_ref
Check if the object is an instance of the class type, or one of its subclasses. Read more
Source§

fn isMemberOfClass(&self, cls: &AnyClass) -> bool
where Self: Sized + Message,

Check if the object is an instance of a specific class, without checking subclasses. Read more
Source§

fn respondsToSelector(&self, aSelector: Sel) -> bool
where Self: Sized + Message,

Check whether the object implements or inherits a method with the given selector. Read more
Source§

fn conformsToProtocol(&self, aProtocol: &AnyProtocol) -> bool
where Self: Sized + Message,

Check whether the object conforms to a given protocol. Read more
Source§

fn description(&self) -> Retained<NSObject>
where Self: Sized + Message,

A textual representation of the object. Read more
Source§

fn debugDescription(&self) -> Retained<NSObject>
where Self: Sized + Message,

A textual representation of the object to use when debugging. Read more
Source§

fn isProxy(&self) -> bool
where Self: Sized + Message,

Check whether the receiver is a subclass of the NSProxy root class instead of the usual NSObject. Read more
Source§

fn retainCount(&self) -> usize
where Self: Sized + Message,

The reference count of the object. Read more
Source§

impl NSSecureCoding for SKAction

Source§

unsafe fn supportsSecureCoding() -> bool
where Self: Sized + ClassType,

Source§

impl PartialEq for SKAction

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl RefEncode for SKAction

Source§

const ENCODING_REF: Encoding = <NSObject as ::objc2::RefEncode>::ENCODING_REF

The Objective-C type-encoding for a reference of this type. Read more
Source§

impl DowncastTarget for SKAction

Source§

impl Eq for SKAction

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<'a, T> AllocAnyThread for T
where T: ClassType<ThreadKind = dyn AllocAnyThread + 'a> + ?Sized,

Source§

fn alloc() -> Allocated<Self>
where Self: Sized + ClassType,

Allocate a new instance of the class. Read more
Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> AutoreleaseSafe for T
where T: ?Sized,