#[repr(C)]pub struct SKTileDefinition { /* private fields */ }SKTileDefinition only.Expand description
A tile definition contains the information needed to represent a single type of tile within a tile map.
See also Apple’s documentation
Implementations§
Source§impl SKTileDefinition
impl SKTileDefinition
Sourcepub unsafe fn tileDefinitionWithTexture(texture: &SKTexture) -> Retained<Self>
Available on crate feature SKTexture only.
pub unsafe fn tileDefinitionWithTexture(texture: &SKTexture) -> Retained<Self>
SKTexture only.Create a tile definition with an SKTexture, and set its size to the SKTexture’s width/height.
Parameter texture: the texture to reference for size and content
Sourcepub unsafe fn tileDefinitionWithTexture_size(
texture: &SKTexture,
size: CGSize,
) -> Retained<Self>
Available on crate features SKTexture and objc2-core-foundation only.
pub unsafe fn tileDefinitionWithTexture_size( texture: &SKTexture, size: CGSize, ) -> Retained<Self>
SKTexture and objc2-core-foundation only.Create a tile definition with an SKTexture and the specified size.
Parameter texture: the texture to reference for content
Parameter size: the size of the tile in points
Sourcepub unsafe fn tileDefinitionWithTexture_normalTexture_size(
texture: &SKTexture,
normal_texture: &SKTexture,
size: CGSize,
) -> Retained<Self>
Available on crate features SKTexture and objc2-core-foundation only.
pub unsafe fn tileDefinitionWithTexture_normalTexture_size( texture: &SKTexture, normal_texture: &SKTexture, size: CGSize, ) -> Retained<Self>
SKTexture and objc2-core-foundation only.Create a tile definition with an SKTexture and the specified size.
Parameter texture: the texture to reference for content
Parameter normalTexture: the normal texture to use for generating normals for lighting
Parameter size: the size of the tile in points
Sourcepub unsafe fn tileDefinitionWithTextures_size_timePerFrame(
textures: &NSArray<SKTexture>,
size: CGSize,
time_per_frame: CGFloat,
) -> Retained<Self>
Available on crate features SKTexture and objc2-core-foundation only.
pub unsafe fn tileDefinitionWithTextures_size_timePerFrame( textures: &NSArray<SKTexture>, size: CGSize, time_per_frame: CGFloat, ) -> Retained<Self>
SKTexture and objc2-core-foundation only.Create an animated tile definition with an array of SKTextures, the specified size, and the length of time each texture should be displayed for in the animation.
Parameter textures: the textures to reference for animated content
Parameter size: the size of the tile in points
Parameter timePerFrame: the duration, in seconds, that each texture in the textures array is displayed before switching to the next texture in the sequence
Sourcepub unsafe fn tileDefinitionWithTextures_normalTextures_size_timePerFrame(
textures: &NSArray<SKTexture>,
normal_textures: &NSArray<SKTexture>,
size: CGSize,
time_per_frame: CGFloat,
) -> Retained<Self>
Available on crate features SKTexture and objc2-core-foundation only.
pub unsafe fn tileDefinitionWithTextures_normalTextures_size_timePerFrame( textures: &NSArray<SKTexture>, normal_textures: &NSArray<SKTexture>, size: CGSize, time_per_frame: CGFloat, ) -> Retained<Self>
SKTexture and objc2-core-foundation only.Create an animated tile definition with an array of SKTextures, the specified size, and the length of time each texture should be displayed for in the animation.
Parameter textures: the textures to reference for animated content
Parameter normalTextures: the normal textures to use for generating normals for lighting
Parameter size: the size of the tile in points
Parameter timePerFrame: the duration, in seconds, that each texture in the textures array is displayed before switching to the next texture in the sequence
Sourcepub unsafe fn initWithTexture(
this: Allocated<Self>,
texture: &SKTexture,
) -> Retained<Self>
Available on crate feature SKTexture only.
pub unsafe fn initWithTexture( this: Allocated<Self>, texture: &SKTexture, ) -> Retained<Self>
SKTexture only.Initilize a tile definition with an SKTexture, and set its size to the SKTexture’s width/height.
Parameter texture: the texture to reference for size and content
Sourcepub unsafe fn initWithTexture_size(
this: Allocated<Self>,
texture: &SKTexture,
size: CGSize,
) -> Retained<Self>
Available on crate features SKTexture and objc2-core-foundation only.
pub unsafe fn initWithTexture_size( this: Allocated<Self>, texture: &SKTexture, size: CGSize, ) -> Retained<Self>
SKTexture and objc2-core-foundation only.Initilize a tile definition with an SKTexture and the specified size.
Parameter texture: the texture to reference for content
Parameter size: the size of the tile in points
Sourcepub unsafe fn initWithTexture_normalTexture_size(
this: Allocated<Self>,
texture: &SKTexture,
normal_texture: &SKTexture,
size: CGSize,
) -> Retained<Self>
Available on crate features SKTexture and objc2-core-foundation only.
pub unsafe fn initWithTexture_normalTexture_size( this: Allocated<Self>, texture: &SKTexture, normal_texture: &SKTexture, size: CGSize, ) -> Retained<Self>
SKTexture and objc2-core-foundation only.Initilize a tile definition with an SKTexture and the specified size.
Parameter texture: the texture to reference for content
Parameter normalTexture: the normal texture to use for generating normals for lighting
Parameter size: the size of the tile in points
Sourcepub unsafe fn initWithTextures_size_timePerFrame(
this: Allocated<Self>,
textures: &NSArray<SKTexture>,
size: CGSize,
time_per_frame: CGFloat,
) -> Retained<Self>
Available on crate features SKTexture and objc2-core-foundation only.
pub unsafe fn initWithTextures_size_timePerFrame( this: Allocated<Self>, textures: &NSArray<SKTexture>, size: CGSize, time_per_frame: CGFloat, ) -> Retained<Self>
SKTexture and objc2-core-foundation only.Initilize an animated tile definition with an array of SKTextures, the specified size, and the length of time each texture should be displayed for in the animation.
Parameter textures: the textures to reference for animated content
Parameter size: the size of the tile in points
Parameter timePerFrame: the duration, in seconds, that each texture in the textures array is displayed before switching to the next texture in the sequence
Sourcepub unsafe fn initWithTextures_normalTextures_size_timePerFrame(
this: Allocated<Self>,
textures: &NSArray<SKTexture>,
normal_textures: &NSArray<SKTexture>,
size: CGSize,
time_per_frame: CGFloat,
) -> Retained<Self>
Available on crate features SKTexture and objc2-core-foundation only.
pub unsafe fn initWithTextures_normalTextures_size_timePerFrame( this: Allocated<Self>, textures: &NSArray<SKTexture>, normal_textures: &NSArray<SKTexture>, size: CGSize, time_per_frame: CGFloat, ) -> Retained<Self>
SKTexture and objc2-core-foundation only.Initilize an animated tile definition with an array of SKTextures, the specified size, and the length of time each texture should be displayed for in the animation.
Parameter textures: the textures to reference for animated content
Parameter normalTextures: the normal textures to use for generating normals for lighting
Parameter size: the size of the tile in points
Parameter timePerFrame: the duration, in seconds, that each texture in the textures array is displayed before switching to the next texture in the sequence
Sourcepub unsafe fn textures(&self) -> Retained<NSArray<SKTexture>>
Available on crate feature SKTexture only.
pub unsafe fn textures(&self) -> Retained<NSArray<SKTexture>>
SKTexture only.The textures used to draw the tile. Non-animated tiles use only one texture. When more than one texture is present, the tile will swap through them in sequence, showing each for the duration specified in the timePerFrame property. After displaying the last texture in the array, the sequence is repeated from the first texture.
Sourcepub unsafe fn setTextures(&self, textures: &NSArray<SKTexture>)
Available on crate feature SKTexture only.
pub unsafe fn setTextures(&self, textures: &NSArray<SKTexture>)
SKTexture only.Setter for textures.
Sourcepub unsafe fn normalTextures(&self) -> Retained<NSArray<SKTexture>>
Available on crate feature SKTexture only.
pub unsafe fn normalTextures(&self) -> Retained<NSArray<SKTexture>>
SKTexture only.The textures to use for generating normals that lights use to light this tile. These will only be used if the tile is lit by at least one light. Each normal texture corresponds to a texture in the textures property.
Sourcepub unsafe fn setNormalTextures(&self, normal_textures: &NSArray<SKTexture>)
Available on crate feature SKTexture only.
pub unsafe fn setNormalTextures(&self, normal_textures: &NSArray<SKTexture>)
SKTexture only.Setter for normalTextures.
Sourcepub unsafe fn userData(&self) -> Option<Retained<NSMutableDictionary>>
pub unsafe fn userData(&self) -> Option<Retained<NSMutableDictionary>>
An optional dictionary that can be used to store your own data for each tile definition. Defaults to nil.
Sourcepub unsafe fn setUserData(&self, user_data: Option<&NSMutableDictionary>)
pub unsafe fn setUserData(&self, user_data: Option<&NSMutableDictionary>)
Setter for userData.
Sourcepub unsafe fn name(&self) -> Option<Retained<NSString>>
pub unsafe fn name(&self) -> Option<Retained<NSString>>
Client-assignable name for the tile definition. Defaults to nil.
Sourcepub unsafe fn size(&self) -> CGSize
Available on crate feature objc2-core-foundation only.
pub unsafe fn size(&self) -> CGSize
objc2-core-foundation only.The size of the tile in points.
Sourcepub unsafe fn setSize(&self, size: CGSize)
Available on crate feature objc2-core-foundation only.
pub unsafe fn setSize(&self, size: CGSize)
objc2-core-foundation only.Setter for size.
Sourcepub unsafe fn timePerFrame(&self) -> CGFloat
Available on crate feature objc2-core-foundation only.
pub unsafe fn timePerFrame(&self) -> CGFloat
objc2-core-foundation only.The duration, in seconds, that each texture in the textures array is displayed before switching to the next texture in the sequence. Only used when there is more than one texture available.
Sourcepub unsafe fn setTimePerFrame(&self, time_per_frame: CGFloat)
Available on crate feature objc2-core-foundation only.
pub unsafe fn setTimePerFrame(&self, time_per_frame: CGFloat)
objc2-core-foundation only.Setter for timePerFrame.
Sourcepub unsafe fn placementWeight(&self) -> NSUInteger
pub unsafe fn placementWeight(&self) -> NSUInteger
This value is used to determine how likely this tile definition is to be chosen for placement when a SKTileGroupRule has mulitple tile definitions assigned to it. A higher value relative to the other definitions assigned to the rule make it more likely for this definition to be selected; lower values make it less likely. Defaults to 1. When set to 0, the definition will never be chosen as long as there is at least one other definition with a placementWeight above 0.
Sourcepub unsafe fn setPlacementWeight(&self, placement_weight: NSUInteger)
pub unsafe fn setPlacementWeight(&self, placement_weight: NSUInteger)
Setter for placementWeight.
Sourcepub unsafe fn rotation(&self) -> SKTileDefinitionRotation
pub unsafe fn rotation(&self) -> SKTileDefinitionRotation
The rotation of the tile definition’s images can be set in 90 degree increments. Defaults to SKTileDefinitionRotation0.
Sourcepub unsafe fn setRotation(&self, rotation: SKTileDefinitionRotation)
pub unsafe fn setRotation(&self, rotation: SKTileDefinitionRotation)
Setter for rotation.
Sourcepub unsafe fn flipVertically(&self) -> bool
pub unsafe fn flipVertically(&self) -> bool
When set to YES, the tile definition’s images will be flipped vertically (i.e., the top of the image becomes the bottom). Defaults to NO.
Sourcepub unsafe fn setFlipVertically(&self, flip_vertically: bool)
pub unsafe fn setFlipVertically(&self, flip_vertically: bool)
Setter for flipVertically.
Sourcepub unsafe fn flipHorizontally(&self) -> bool
pub unsafe fn flipHorizontally(&self) -> bool
When set to YES, the tile definition’s images will be flipped horizontally (i.e., the left of the image becomes the right). Defaults to NO.
Sourcepub unsafe fn setFlipHorizontally(&self, flip_horizontally: bool)
pub unsafe fn setFlipHorizontally(&self, flip_horizontally: bool)
Setter for flipHorizontally.
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 AsRef<AnyObject> for SKTileDefinition
impl AsRef<AnyObject> for SKTileDefinition
Source§impl AsRef<NSObject> for SKTileDefinition
impl AsRef<NSObject> for SKTileDefinition
Source§impl AsRef<SKTileDefinition> for SKTileDefinition
impl AsRef<SKTileDefinition> for SKTileDefinition
Source§impl Borrow<AnyObject> for SKTileDefinition
impl Borrow<AnyObject> for SKTileDefinition
Source§impl Borrow<NSObject> for SKTileDefinition
impl Borrow<NSObject> for SKTileDefinition
Source§impl ClassType for SKTileDefinition
impl ClassType for SKTileDefinition
Source§const NAME: &'static str = "SKTileDefinition"
const NAME: &'static str = "SKTileDefinition"
Source§type ThreadKind = <<SKTileDefinition as ClassType>::Super as ClassType>::ThreadKind
type ThreadKind = <<SKTileDefinition as ClassType>::Super as ClassType>::ThreadKind
Source§impl CopyingHelper for SKTileDefinition
impl CopyingHelper for SKTileDefinition
Source§type Result = SKTileDefinition
type Result = SKTileDefinition
Self if the type has no
immutable counterpart. Read moreSource§impl Debug for SKTileDefinition
impl Debug for SKTileDefinition
Source§impl Deref for SKTileDefinition
impl Deref for SKTileDefinition
Source§impl Hash for SKTileDefinition
impl Hash for SKTileDefinition
Source§impl Message for SKTileDefinition
impl Message for SKTileDefinition
Source§impl NSCoding for SKTileDefinition
impl NSCoding for SKTileDefinition
Source§impl NSCopying for SKTileDefinition
impl NSCopying for SKTileDefinition
Source§impl NSObjectProtocol for SKTileDefinition
impl NSObjectProtocol for SKTileDefinition
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