pub struct Sprite { /* private fields */ }Expand description
A struct to render texture in game scene tree hierarchy.
Implementations§
Source§impl Sprite
impl Sprite
Sourcepub fn set_depth_write(&mut self, val: bool)
pub fn set_depth_write(&mut self, val: bool)
Sets whether the depth buffer should be written to when rendering the sprite.
Sourcepub fn is_depth_write(&self) -> bool
pub fn is_depth_write(&self) -> bool
Gets whether the depth buffer should be written to when rendering the sprite.
Sourcepub fn set_alpha_ref(&mut self, val: f32)
pub fn set_alpha_ref(&mut self, val: f32)
Sets the alpha reference value for alpha testing. Pixels with alpha values less than or equal to this value will be discarded.
Only works with sprite.effect = SpriteEffect::new("builtin:vs_sprite", "builtin:fs_spritealphatest");.
Sourcepub fn get_alpha_ref(&self) -> f32
pub fn get_alpha_ref(&self) -> f32
Gets the alpha reference value for alpha testing. Pixels with alpha values less than or equal to this value will be discarded.
Only works with sprite.effect = SpriteEffect::new("builtin:vs_sprite", "builtin:fs_spritealphatest");.
Sourcepub fn set_texture_rect(&mut self, val: &Rect)
pub fn set_texture_rect(&mut self, val: &Rect)
Sets the texture rectangle for the sprite.
Sourcepub fn get_texture_rect(&self) -> Rect
pub fn get_texture_rect(&self) -> Rect
Gets the texture rectangle for the sprite.
Sourcepub fn get_texture(&self) -> Option<Texture2D>
pub fn get_texture(&self) -> Option<Texture2D>
Gets the texture for the sprite.
Sourcepub fn set_blend_func(&mut self, val: BlendFunc)
pub fn set_blend_func(&mut self, val: BlendFunc)
Sets the blend function for the sprite.
Sourcepub fn get_blend_func(&self) -> BlendFunc
pub fn get_blend_func(&self) -> BlendFunc
Gets the blend function for the sprite.
Sourcepub fn set_effect(&mut self, val: &SpriteEffect)
pub fn set_effect(&mut self, val: &SpriteEffect)
Sets the sprite shader effect.
Sourcepub fn get_effect(&self) -> SpriteEffect
pub fn get_effect(&self) -> SpriteEffect
Gets the sprite shader effect.
Sourcepub fn set_uwrap(&mut self, val: TextureWrap)
pub fn set_uwrap(&mut self, val: TextureWrap)
Sets the texture wrapping mode for the U (horizontal) axis.
Sourcepub fn get_uwrap(&self) -> TextureWrap
pub fn get_uwrap(&self) -> TextureWrap
Gets the texture wrapping mode for the U (horizontal) axis.
Sourcepub fn set_vwrap(&mut self, val: TextureWrap)
pub fn set_vwrap(&mut self, val: TextureWrap)
Sets the texture wrapping mode for the V (vertical) axis.
Sourcepub fn get_vwrap(&self) -> TextureWrap
pub fn get_vwrap(&self) -> TextureWrap
Gets the texture wrapping mode for the V (vertical) axis.
Sourcepub fn set_filter(&mut self, val: TextureFilter)
pub fn set_filter(&mut self, val: TextureFilter)
Sets the texture filtering mode for the sprite.
Sourcepub fn get_filter(&self) -> TextureFilter
pub fn get_filter(&self) -> TextureFilter
Gets the texture filtering mode for the sprite.
Sourcepub fn set_effect_as_default(&mut self)
pub fn set_effect_as_default(&mut self)
Removes the sprite effect and sets the default effect.
Sourcepub fn with_texture_rect(texture: &Texture2D, texture_rect: &Rect) -> Sprite
pub fn with_texture_rect(texture: &Texture2D, texture_rect: &Rect) -> Sprite
A method for creating a Sprite object.
§Arguments
texture- The texture to be used for the sprite.texture_rect- An optional rectangle defining the portion of the texture to use for the sprite. If not provided, the whole texture will be used for rendering.
§Returns
Sprite- A new instance of the Sprite class.
Sourcepub fn with_texture(texture: &Texture2D) -> Sprite
pub fn with_texture(texture: &Texture2D) -> Sprite
Sourcepub fn with_file(clip_str: &str) -> Option<Sprite>
pub fn with_file(clip_str: &str) -> Option<Sprite>
A method for creating a Sprite object.
§Arguments
clip_str- The string containing format for loading a texture file. Can be “Image/file.png” and “Image/items.clip|itemA”. Supports image file format: jpg, png, dds, pvr, ktx.
§Returns
Option<Sprite>- A new instance of the Sprite class. If the texture file is not found, it will returnNone.
Trait Implementations§
Source§impl INode for Sprite
impl INode for Sprite
Source§fn set_angle_x(&mut self, val: f32)
fn set_angle_x(&mut self, val: f32)
Source§fn get_angle_x(&self) -> f32
fn get_angle_x(&self) -> f32
Source§fn set_angle_y(&mut self, val: f32)
fn set_angle_y(&mut self, val: f32)
Source§fn get_angle_y(&self) -> f32
fn get_angle_y(&self) -> f32
Source§fn set_scale_x(&mut self, val: f32)
fn set_scale_x(&mut self, val: f32)
Source§fn get_scale_x(&self) -> f32
fn get_scale_x(&self) -> f32
Source§fn set_scale_y(&mut self, val: f32)
fn set_scale_y(&mut self, val: f32)
Source§fn get_scale_y(&self) -> f32
fn get_scale_y(&self) -> f32
Source§fn set_position(&mut self, val: &Vec2)
fn set_position(&mut self, val: &Vec2)
Source§fn get_position(&self) -> Vec2
fn get_position(&self) -> Vec2
Source§fn set_skew_x(&mut self, val: f32)
fn set_skew_x(&mut self, val: f32)
Source§fn get_skew_x(&self) -> f32
fn get_skew_x(&self) -> f32
Source§fn set_skew_y(&mut self, val: f32)
fn set_skew_y(&mut self, val: f32)
Source§fn get_skew_y(&self) -> f32
fn get_skew_y(&self) -> f32
Source§fn set_visible(&mut self, val: bool)
fn set_visible(&mut self, val: bool)
Source§fn is_visible(&self) -> bool
fn is_visible(&self) -> bool
Source§fn set_anchor(&mut self, val: &Vec2)
fn set_anchor(&mut self, val: &Vec2)
Source§fn get_anchor(&self) -> Vec2
fn get_anchor(&self) -> Vec2
Source§fn set_height(&mut self, val: f32)
fn set_height(&mut self, val: f32)
Source§fn get_height(&self) -> f32
fn get_height(&self) -> f32
Source§fn set_opacity(&mut self, val: f32)
fn set_opacity(&mut self, val: f32)
Source§fn get_opacity(&self) -> f32
fn get_opacity(&self) -> f32
Source§fn set_color3(&mut self, val: &Color3)
fn set_color3(&mut self, val: &Color3)
Source§fn get_color3(&self) -> Color3
fn get_color3(&self) -> Color3
Source§fn set_pass_opacity(&mut self, val: bool)
fn set_pass_opacity(&mut self, val: bool)
Source§fn is_pass_opacity(&self) -> bool
fn is_pass_opacity(&self) -> bool
Source§fn set_pass_color3(&mut self, val: bool)
fn set_pass_color3(&mut self, val: bool)
Source§fn is_pass_color3(&self) -> bool
fn is_pass_color3(&self) -> bool
Source§fn set_transform_target(&mut self, val: &dyn INode)
fn set_transform_target(&mut self, val: &dyn INode)
Source§fn get_transform_target(&self) -> Option<Node>
fn get_transform_target(&self) -> Option<Node>
Source§fn set_scheduler(&mut self, val: &Scheduler)
fn set_scheduler(&mut self, val: &Scheduler)
Source§fn get_scheduler(&self) -> Scheduler
fn get_scheduler(&self) -> Scheduler
Source§fn get_children(&self) -> Option<Array>
fn get_children(&self) -> Option<Array>
Source§fn get_parent(&self) -> Option<Node>
fn get_parent(&self) -> Option<Node>
Source§fn is_running(&self) -> bool
fn is_running(&self) -> bool
Source§fn is_scheduled(&self) -> bool
fn is_scheduled(&self) -> bool
Source§fn get_action_count(&self) -> i32
fn get_action_count(&self) -> i32
Source§fn get_data(&self) -> Dictionary
fn get_data(&self) -> Dictionary
Source§fn set_touch_enabled(&mut self, val: bool)
fn set_touch_enabled(&mut self, val: bool)
Source§fn is_touch_enabled(&self) -> bool
fn is_touch_enabled(&self) -> bool
Source§fn set_swallow_touches(&mut self, val: bool)
fn set_swallow_touches(&mut self, val: bool)
Source§fn is_swallow_touches(&self) -> bool
fn is_swallow_touches(&self) -> bool
Source§fn set_swallow_mouse_wheel(&mut self, val: bool)
fn set_swallow_mouse_wheel(&mut self, val: bool)
Source§fn is_swallow_mouse_wheel(&self) -> bool
fn is_swallow_mouse_wheel(&self) -> bool
Source§fn set_keyboard_enabled(&mut self, val: bool)
fn set_keyboard_enabled(&mut self, val: bool)
Source§fn is_keyboard_enabled(&self) -> bool
fn is_keyboard_enabled(&self) -> bool
Source§fn set_controller_enabled(&mut self, val: bool)
fn set_controller_enabled(&mut self, val: bool)
Source§fn is_controller_enabled(&self) -> bool
fn is_controller_enabled(&self) -> bool
Source§fn set_render_group(&mut self, val: bool)
fn set_render_group(&mut self, val: bool)
Source§fn is_render_group(&self) -> bool
fn is_render_group(&self) -> bool
Source§fn set_show_debug(&mut self, val: bool)
fn set_show_debug(&mut self, val: bool)
Source§fn is_show_debug(&self) -> bool
fn is_show_debug(&self) -> bool
Source§fn set_render_order(&mut self, val: i32)
fn set_render_order(&mut self, val: i32)
Source§fn get_render_order(&self) -> i32
fn get_render_order(&self) -> i32
Source§fn add_child_with_order_tag(&mut self, child: &dyn INode, order: i32, tag: &str)
fn add_child_with_order_tag(&mut self, child: &dyn INode, order: i32, tag: &str)
Source§fn add_child_with_order(&mut self, child: &dyn INode, order: i32)
fn add_child_with_order(&mut self, child: &dyn INode, order: i32)
Source§fn add_to_with_order_tag(
&mut self,
parent: &dyn INode,
order: i32,
tag: &str,
) -> Node
fn add_to_with_order_tag( &mut self, parent: &dyn INode, order: i32, tag: &str, ) -> Node
Source§fn add_to_with_order(&mut self, parent: &dyn INode, order: i32) -> Node
fn add_to_with_order(&mut self, parent: &dyn INode, order: i32) -> Node
Source§fn add_to(&mut self, parent: &dyn INode) -> Node
fn add_to(&mut self, parent: &dyn INode) -> Node
Source§fn remove_child(&mut self, child: &dyn INode, cleanup: bool)
fn remove_child(&mut self, child: &dyn INode, cleanup: bool)
Source§fn remove_child_by_tag(&mut self, tag: &str, cleanup: bool)
fn remove_child_by_tag(&mut self, tag: &str, cleanup: bool)
Source§fn remove_all_children(&mut self, cleanup: bool)
fn remove_all_children(&mut self, cleanup: bool)
Source§fn remove_from_parent(&mut self, cleanup: bool)
fn remove_from_parent(&mut self, cleanup: bool)
Source§fn move_to_parent(&mut self, parent: &dyn INode)
fn move_to_parent(&mut self, parent: &dyn INode)
Source§fn schedule(&mut self, update_func: Box<dyn FnMut(f64) -> bool>)
fn schedule(&mut self, update_func: Box<dyn FnMut(f64) -> bool>)
Source§fn unschedule(&mut self)
fn unschedule(&mut self)
Source§fn convert_to_node_space(&mut self, world_point: &Vec2) -> Vec2
fn convert_to_node_space(&mut self, world_point: &Vec2) -> Vec2
Source§fn convert_to_world_space(&mut self, node_point: &Vec2) -> Vec2
fn convert_to_world_space(&mut self, node_point: &Vec2) -> Vec2
Source§fn convert_to_window_space(
&mut self,
node_point: &Vec2,
callback: Box<dyn FnMut(&Vec2)>,
)
fn convert_to_window_space( &mut self, node_point: &Vec2, callback: Box<dyn FnMut(&Vec2)>, )
Source§fn each_child(
&mut self,
visitor_func: Box<dyn FnMut(&dyn INode) -> bool>,
) -> bool
fn each_child( &mut self, visitor_func: Box<dyn FnMut(&dyn INode) -> bool>, ) -> bool
Source§fn traverse(&mut self, visitor_func: Box<dyn FnMut(&dyn INode) -> bool>) -> bool
fn traverse(&mut self, visitor_func: Box<dyn FnMut(&dyn INode) -> bool>) -> bool
TraverseEnabled flag are not visited. Read more