#[repr(C)]pub struct SKAction { /* private fields */ }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
impl SKAction
Sourcepub unsafe fn duration(&self) -> NSTimeInterval
pub unsafe fn duration(&self) -> NSTimeInterval
The duration required to complete an action, in seconds.
Sourcepub unsafe fn setDuration(&self, duration: NSTimeInterval)
pub unsafe fn setDuration(&self, duration: NSTimeInterval)
Setter for duration.
Sourcepub unsafe fn timingMode(&self) -> SKActionTimingMode
pub unsafe fn timingMode(&self) -> SKActionTimingMode
The timing mode used to execute an action
See: SKActionTimingMode
Sourcepub unsafe fn setTimingMode(&self, timing_mode: SKActionTimingMode)
pub unsafe fn setTimingMode(&self, timing_mode: SKActionTimingMode)
Setter for timingMode.
Sourcepub unsafe fn timingFunction(&self) -> SKActionTimingFunction
Available on crate feature block2 only.
pub unsafe fn timingFunction(&self) -> SKActionTimingFunction
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
Sourcepub unsafe fn setTimingFunction(&self, timing_function: SKActionTimingFunction)
Available on crate feature block2 only.
pub unsafe fn setTimingFunction(&self, timing_function: SKActionTimingFunction)
block2 only.Setter for timingFunction.
Sourcepub unsafe fn speed(&self) -> CGFloat
Available on crate feature objc2-core-foundation only.
pub unsafe fn speed(&self) -> CGFloat
objc2-core-foundation only.A speed factor that modifies how fast an action runs. Default value is 1.0
Sourcepub unsafe fn setSpeed(&self, speed: CGFloat)
Available on crate feature objc2-core-foundation only.
pub unsafe fn setSpeed(&self, speed: CGFloat)
objc2-core-foundation only.Setter for speed.
Sourcepub unsafe fn reversedAction(&self) -> Retained<SKAction>
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
SKActions.
impl SKAction
SKActions.
Sourcepub unsafe fn moveBy_duration(
delta: CGVector,
duration: NSTimeInterval,
) -> Retained<SKAction>
Available on crate feature objc2-core-foundation only.
pub unsafe fn moveBy_duration( delta: CGVector, duration: NSTimeInterval, ) -> Retained<SKAction>
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
pub unsafe fn moveByX_y_duration( delta_x: CGFloat, delta_y: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>
objc2-core-foundation only.Sourcepub unsafe fn moveTo_duration(
location: CGPoint,
duration: NSTimeInterval,
) -> Retained<SKAction>
Available on crate feature objc2-core-foundation only.
pub unsafe fn moveTo_duration( location: CGPoint, duration: NSTimeInterval, ) -> Retained<SKAction>
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
pub unsafe fn moveToX_duration( x: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>
objc2-core-foundation only.pub unsafe fn moveToY_duration( y: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>
objc2-core-foundation only.Sourcepub unsafe fn rotateByAngle_duration(
radians: CGFloat,
duration: NSTimeInterval,
) -> Retained<SKAction>
Available on crate feature objc2-core-foundation only.
pub unsafe fn rotateByAngle_duration( radians: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>
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
Sourcepub unsafe fn rotateToAngle_duration(
radians: CGFloat,
duration: NSTimeInterval,
) -> Retained<SKAction>
Available on crate feature objc2-core-foundation only.
pub unsafe fn rotateToAngle_duration( radians: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>
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
Sourcepub unsafe fn rotateToAngle_duration_shortestUnitArc(
radians: CGFloat,
duration: NSTimeInterval,
shortest_unit_arc: bool,
) -> Retained<SKAction>
Available on crate feature objc2-core-foundation only.
pub unsafe fn rotateToAngle_duration_shortestUnitArc( radians: CGFloat, duration: NSTimeInterval, shortest_unit_arc: bool, ) -> Retained<SKAction>
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
Sourcepub unsafe fn resizeByWidth_height_duration(
width: CGFloat,
height: CGFloat,
duration: NSTimeInterval,
) -> Retained<SKAction>
Available on crate feature objc2-core-foundation only.
pub unsafe fn resizeByWidth_height_duration( width: CGFloat, height: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>
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
Sourcepub unsafe fn resizeToWidth_height_duration(
width: CGFloat,
height: CGFloat,
duration: NSTimeInterval,
) -> Retained<SKAction>
Available on crate feature objc2-core-foundation only.
pub unsafe fn resizeToWidth_height_duration( width: CGFloat, height: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>
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
pub unsafe fn resizeToWidth_duration( width: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>
objc2-core-foundation only.pub unsafe fn resizeToHeight_duration( height: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>
objc2-core-foundation only.Sourcepub unsafe fn scaleBy_duration(
scale: CGFloat,
duration: NSTimeInterval,
) -> Retained<SKAction>
Available on crate feature objc2-core-foundation only.
pub unsafe fn scaleBy_duration( scale: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>
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
pub unsafe fn scaleXBy_y_duration( x_scale: CGFloat, y_scale: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>
objc2-core-foundation only.Sourcepub unsafe fn scaleTo_duration(
scale: CGFloat,
duration: NSTimeInterval,
) -> Retained<SKAction>
Available on crate feature objc2-core-foundation only.
pub unsafe fn scaleTo_duration( scale: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>
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
pub unsafe fn scaleXTo_y_duration( x_scale: CGFloat, y_scale: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>
objc2-core-foundation only.pub unsafe fn scaleXTo_duration( scale: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>
objc2-core-foundation only.pub unsafe fn scaleYTo_duration( scale: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>
objc2-core-foundation only.Sourcepub unsafe fn scaleToSize_duration(
size: CGSize,
duration: NSTimeInterval,
) -> Retained<SKAction>
Available on crate feature objc2-core-foundation only.
pub unsafe fn scaleToSize_duration( size: CGSize, duration: NSTimeInterval, ) -> Retained<SKAction>
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
Sourcepub unsafe fn sequence(actions: &NSArray<SKAction>) -> Retained<SKAction>
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}.
Sourcepub unsafe fn group(actions: &NSArray<SKAction>) -> Retained<SKAction>
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.
Sourcepub unsafe fn repeatAction_count(
action: &SKAction,
count: NSUInteger,
) -> Retained<SKAction>
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
Sourcepub unsafe fn repeatActionForever(action: &SKAction) -> Retained<SKAction>
pub unsafe fn repeatActionForever(action: &SKAction) -> Retained<SKAction>
Creates an action that repeats forever
Parameter action: The action to execute
Sourcepub unsafe fn fadeInWithDuration(duration: NSTimeInterval) -> Retained<SKAction>
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
Sourcepub unsafe fn fadeOutWithDuration(
duration: NSTimeInterval,
) -> Retained<SKAction>
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
Sourcepub unsafe fn fadeAlphaBy_duration(
factor: CGFloat,
duration: NSTimeInterval,
) -> Retained<SKAction>
Available on crate feature objc2-core-foundation only.
pub unsafe fn fadeAlphaBy_duration( factor: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>
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
Sourcepub unsafe fn fadeAlphaTo_duration(
alpha: CGFloat,
duration: NSTimeInterval,
) -> Retained<SKAction>
Available on crate feature objc2-core-foundation only.
pub unsafe fn fadeAlphaTo_duration( alpha: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>
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
Sourcepub unsafe fn setTexture(texture: &SKTexture) -> Retained<SKAction>
Available on crate feature SKTexture only.
pub unsafe fn setTexture(texture: &SKTexture) -> Retained<SKAction>
SKTexture only.Creates an action that changes a sprite’s texture
Parameter texture: The new texture to use on the sprite
pub unsafe fn setNormalTexture(texture: &SKTexture) -> Retained<SKAction>
SKTexture only.Sourcepub unsafe fn setTexture_resize(
texture: &SKTexture,
resize: bool,
) -> Retained<SKAction>
Available on crate feature SKTexture only.
pub unsafe fn setTexture_resize( texture: &SKTexture, resize: bool, ) -> Retained<SKAction>
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.
pub unsafe fn setNormalTexture_resize( texture: &SKTexture, resize: bool, ) -> Retained<SKAction>
SKTexture only.Sourcepub unsafe fn animateWithTextures_timePerFrame(
textures: &NSArray<SKTexture>,
sec: NSTimeInterval,
) -> Retained<SKAction>
Available on crate feature SKTexture only.
pub unsafe fn animateWithTextures_timePerFrame( textures: &NSArray<SKTexture>, sec: NSTimeInterval, ) -> Retained<SKAction>
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
pub unsafe fn animateWithNormalTextures_timePerFrame( textures: &NSArray<SKTexture>, sec: NSTimeInterval, ) -> Retained<SKAction>
SKTexture only.Sourcepub unsafe fn animateWithTextures_timePerFrame_resize_restore(
textures: &NSArray<SKTexture>,
sec: NSTimeInterval,
resize: bool,
restore: bool,
) -> Retained<SKAction>
Available on crate feature SKTexture only.
pub unsafe fn animateWithTextures_timePerFrame_resize_restore( textures: &NSArray<SKTexture>, sec: NSTimeInterval, resize: bool, restore: bool, ) -> Retained<SKAction>
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.
pub unsafe fn animateWithNormalTextures_timePerFrame_resize_restore( textures: &NSArray<SKTexture>, sec: NSTimeInterval, resize: bool, restore: bool, ) -> Retained<SKAction>
SKTexture only.Sourcepub unsafe fn playSoundFileNamed_waitForCompletion(
sound_file: &NSString,
wait: bool,
) -> Retained<SKAction>
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
Sourcepub 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.
pub unsafe fn colorizeWithColor_colorBlendFactor_duration( color: &NSColor, color_blend_factor: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>
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
pub unsafe fn colorizeWithColorBlendFactor_duration( color_blend_factor: CGFloat, sec: NSTimeInterval, ) -> Retained<SKAction>
objc2-core-foundation only.Sourcepub unsafe fn falloffTo_duration(
falloff: c_float,
duration: NSTimeInterval,
) -> Retained<SKAction>
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
Sourcepub unsafe fn falloffBy_duration(
falloff: c_float,
duration: NSTimeInterval,
) -> Retained<SKAction>
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
Sourcepub unsafe fn followPath_duration(
path: &CGPath,
duration: NSTimeInterval,
) -> Retained<SKAction>
Available on crate feature objc2-core-graphics only.
pub unsafe fn followPath_duration( path: &CGPath, duration: NSTimeInterval, ) -> Retained<SKAction>
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
Sourcepub unsafe fn followPath_asOffset_orientToPath_duration(
path: &CGPath,
offset: bool,
orient: bool,
duration: NSTimeInterval,
) -> Retained<SKAction>
Available on crate feature objc2-core-graphics only.
pub unsafe fn followPath_asOffset_orientToPath_duration( path: &CGPath, offset: bool, orient: bool, duration: NSTimeInterval, ) -> Retained<SKAction>
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
Sourcepub unsafe fn followPath_speed(
path: &CGPath,
speed: CGFloat,
) -> Retained<SKAction>
Available on crate features objc2-core-foundation and objc2-core-graphics only.
pub unsafe fn followPath_speed( path: &CGPath, speed: CGFloat, ) -> Retained<SKAction>
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
pub unsafe fn followPath_asOffset_orientToPath_speed( path: &CGPath, offset: bool, orient: bool, speed: CGFloat, ) -> Retained<SKAction>
objc2-core-foundation and objc2-core-graphics only.Sourcepub unsafe fn speedBy_duration(
speed: CGFloat,
duration: NSTimeInterval,
) -> Retained<SKAction>
Available on crate feature objc2-core-foundation only.
pub unsafe fn speedBy_duration( speed: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>
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
Sourcepub unsafe fn speedTo_duration(
speed: CGFloat,
duration: NSTimeInterval,
) -> Retained<SKAction>
Available on crate feature objc2-core-foundation only.
pub unsafe fn speedTo_duration( speed: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>
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
Sourcepub 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.
pub unsafe fn reachTo_rootNode_duration( position: CGPoint, root: &SKNode, duration: NSTimeInterval, ) -> Retained<SKAction>
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
Sourcepub 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.
pub unsafe fn reachTo_rootNode_velocity( position: CGPoint, root: &SKNode, velocity: CGFloat, ) -> Retained<SKAction>
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
Sourcepub 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.
pub unsafe fn reachToNode_rootNode_duration( node: &SKNode, root: &SKNode, sec: NSTimeInterval, ) -> Retained<SKAction>
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
Sourcepub 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.
pub unsafe fn reachToNode_rootNode_velocity( node: &SKNode, root: &SKNode, velocity: CGFloat, ) -> Retained<SKAction>
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
Sourcepub unsafe fn strengthTo_duration(
strength: c_float,
duration: NSTimeInterval,
) -> Retained<SKAction>
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
Sourcepub unsafe fn strengthBy_duration(
strength: c_float,
duration: NSTimeInterval,
) -> Retained<SKAction>
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
Sourcepub unsafe fn waitForDuration(duration: NSTimeInterval) -> Retained<SKAction>
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
Sourcepub unsafe fn waitForDuration_withRange(
duration: NSTimeInterval,
duration_range: NSTimeInterval,
) -> Retained<SKAction>
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
Sourcepub unsafe fn removeFromParent() -> Retained<SKAction>
pub unsafe fn removeFromParent() -> Retained<SKAction>
Creates an action that removes the node from its parent
Sourcepub unsafe fn performSelector_onTarget(
selector: Sel,
target: &AnyObject,
) -> Retained<SKAction>
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
Sourcepub unsafe fn runAction_onChildWithName(
action: &SKAction,
name: &NSString,
) -> Retained<SKAction>
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
Sourcepub 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.
pub unsafe fn customActionWithDuration_actionBlock( duration: NSTimeInterval, block: &Block<dyn Fn(NonNull<SKNode>, CGFloat)>, ) -> Retained<SKAction>
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.
Sourcepub unsafe fn actionNamed(name: &NSString) -> Option<Retained<SKAction>>
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
Sourcepub unsafe fn actionNamed_duration(
name: &NSString,
duration: NSTimeInterval,
) -> Option<Retained<SKAction>>
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
Sourcepub unsafe fn actionNamed_fromURL(
name: &NSString,
url: &NSURL,
) -> Option<Retained<SKAction>>
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
Sourcepub unsafe fn actionNamed_fromURL_duration(
name: &NSString,
url: &NSURL,
duration: NSTimeInterval,
) -> Option<Retained<SKAction>>
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.
impl SKAction
NodeWithPhysicsBody.
pub unsafe fn changeChargeTo_duration( v: c_float, duration: NSTimeInterval, ) -> Retained<SKAction>
pub unsafe fn changeChargeBy_duration( v: c_float, duration: NSTimeInterval, ) -> Retained<SKAction>
pub unsafe fn changeMassTo_duration( v: c_float, duration: NSTimeInterval, ) -> Retained<SKAction>
pub unsafe fn changeMassBy_duration( v: c_float, duration: NSTimeInterval, ) -> Retained<SKAction>
pub unsafe fn applyForce_duration( force: CGVector, duration: NSTimeInterval, ) -> Retained<SKAction>
objc2-core-foundation only.pub unsafe fn applyForce_atPoint_duration( force: CGVector, point: CGPoint, duration: NSTimeInterval, ) -> Retained<SKAction>
objc2-core-foundation only.pub unsafe fn applyTorque_duration( torque: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>
objc2-core-foundation only.pub unsafe fn applyImpulse_duration( impulse: CGVector, duration: NSTimeInterval, ) -> Retained<SKAction>
objc2-core-foundation only.pub unsafe fn applyImpulse_atPoint_duration( impulse: CGVector, point: CGPoint, duration: NSTimeInterval, ) -> Retained<SKAction>
objc2-core-foundation only.pub unsafe fn applyAngularImpulse_duration( impulse: CGFloat, duration: NSTimeInterval, ) -> Retained<SKAction>
objc2-core-foundation only.Source§impl SKAction
PlaybackControl.
impl SKAction
PlaybackControl.
pub unsafe fn play() -> Retained<SKAction>
pub unsafe fn pause() -> Retained<SKAction>
pub unsafe fn stop() -> Retained<SKAction>
pub unsafe fn changePlaybackRateTo_duration( v: c_float, duration: NSTimeInterval, ) -> Retained<SKAction>
pub unsafe fn changePlaybackRateBy_duration( v: c_float, duration: NSTimeInterval, ) -> Retained<SKAction>
Source§impl SKAction
MixerControl.
impl SKAction
MixerControl.
pub unsafe fn changeVolumeTo_duration( v: c_float, duration: NSTimeInterval, ) -> Retained<SKAction>
pub unsafe fn changeVolumeBy_duration( v: c_float, duration: NSTimeInterval, ) -> Retained<SKAction>
Source§impl SKAction
SKAudioNode.
Actions that are to be used with audio nodes.
impl SKAction
SKAudioNode. Actions that are to be used with audio nodes.
pub unsafe fn stereoPanTo_duration( v: c_float, duration: NSTimeInterval, ) -> Retained<SKAction>
SKAudioNode only.pub unsafe fn stereoPanBy_duration( v: c_float, duration: NSTimeInterval, ) -> Retained<SKAction>
SKAudioNode only.pub unsafe fn changeReverbTo_duration( v: c_float, duration: NSTimeInterval, ) -> Retained<SKAction>
SKAudioNode only.pub unsafe fn changeReverbBy_duration( v: c_float, duration: NSTimeInterval, ) -> Retained<SKAction>
SKAudioNode only.pub unsafe fn changeObstructionTo_duration( v: c_float, duration: NSTimeInterval, ) -> Retained<SKAction>
SKAudioNode only.pub unsafe fn changeObstructionBy_duration( v: c_float, duration: NSTimeInterval, ) -> Retained<SKAction>
SKAudioNode only.pub unsafe fn changeOcclusionTo_duration( v: c_float, duration: NSTimeInterval, ) -> Retained<SKAction>
SKAudioNode only.pub unsafe fn changeOcclusionBy_duration( v: c_float, duration: NSTimeInterval, ) -> Retained<SKAction>
SKAudioNode only.Source§impl SKAction
SKWarpable.
impl SKAction
SKWarpable.
pub unsafe fn warpTo_duration( warp: &SKWarpGeometry, duration: NSTimeInterval, ) -> Option<Retained<SKAction>>
SKWarpGeometry only.pub unsafe fn animateWithWarps_times( warps: &NSArray<SKWarpGeometry>, times: &NSArray<NSNumber>, ) -> Option<Retained<SKAction>>
SKWarpGeometry only.pub unsafe fn animateWithWarps_times_restore( warps: &NSArray<SKWarpGeometry>, times: &NSArray<NSNumber>, restore: bool, ) -> Option<Retained<SKAction>>
SKWarpGeometry only.Methods from Deref<Target = NSObject>§
Sourcepub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
pub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
Handle messages the object doesn’t recognize.
See Apple’s documentation for details.
Methods from Deref<Target = AnyObject>§
Sourcepub fn class(&self) -> &'static AnyClass
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());Sourcepub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
👎Deprecated: this is difficult to use correctly, use Ivar::load instead.
pub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
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.
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
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 ClassType for SKAction
impl ClassType for SKAction
Source§const NAME: &'static str = "SKAction"
const NAME: &'static str = "SKAction"
Source§type ThreadKind = <<SKAction as ClassType>::Super as ClassType>::ThreadKind
type ThreadKind = <<SKAction as ClassType>::Super as ClassType>::ThreadKind
Source§impl CopyingHelper for SKAction
impl CopyingHelper for SKAction
Source§impl NSCopying for SKAction
impl NSCopying for SKAction
Source§impl NSObjectProtocol for SKAction
impl NSObjectProtocol for SKAction
Source§fn isEqual(&self, other: Option<&AnyObject>) -> bool
fn isEqual(&self, other: Option<&AnyObject>) -> bool
Source§fn hash(&self) -> usize
fn hash(&self) -> usize
Source§fn isKindOfClass(&self, cls: &AnyClass) -> bool
fn isKindOfClass(&self, cls: &AnyClass) -> bool
Source§fn is_kind_of<T>(&self) -> bool
fn is_kind_of<T>(&self) -> bool
isKindOfClass directly, or cast your objects with AnyObject::downcast_ref