AudioAsset
Ease
FastString
FontAsset
NineSlice
PackedSprite
PackedSpriteID
RB
   HardwareSettings
   IRetroBlitGame
RBAsset
Rect2i
ShaderAsset
SoundReference
SpriteGrid
SpriteSheetAsset
TMXMapAsset
   TMXLayer
   TMXLayerLoadState
   TMXObject
   TMXObjectGroup
   TMXProperties
Vector2i

RB.DrawCopy

Method  -  Static

public static void DrawCopy(Rect2i srcRect, Vector2i pos)
public static void DrawCopy(Rect2i srcRect, Vector2i pos, int flags = 0)
public static void DrawCopy(Rect2i srcRect, Vector2i pos, Vector2i pivot, float rotation)
public static void DrawCopy(Rect2i srcRect, Vector2i pos, Vector2i pivot, float rotation, int flags = 0)
public static void DrawCopy(Rect2i srcRect, Rect2i destRect)
public static void DrawCopy(Rect2i srcRect, Rect2i destRect, int flags = 0)
public static void DrawCopy(Rect2i srcRect, Rect2i destRect, Vector2i pivot, float rotation)
public static void DrawCopy(Rect2i srcRect, Rect2i destRect, Vector2i pivot, float rotation, int flags = 0)

Parameters

srcRect Rect2i Source rectangle on the sprite sheet
pos Vector2i Position
flags int Any combination of flags: RB.FLIP_H, RB.FLIP_V, RB.ROT_90_CW, RB.ROT_180_CW, RB.ROT_270_CW, RB.ROT_90_CCW, RB.ROT_180_CCW, RB.ROT_270_CCW.
pivot Vector2i Rotation pivot point, specified as an offset from the rectangles top left corner
rotation float Rotation in degrees
destRect Rect2i Destination rectangle

Returns

Nothing.

Description

Draw to display by copying from a rectangular region in a sprite sheet.

The destination position is specified by pos, or destRect. When using destRect the destination size could be different than the source rectangle size, which allows for scaling to any size.

Optional parameter flags allows for flipping the copied region horizontally or vertically by using RB.FLIP_H and RB.FLIP_V respectively. The RB.ROT_90_CW flag can be used to rotate the region by 90 degrees. A combination of these flags can be used to rotate and flip in any cardinal direction, for convenience these combinations are provided:

For arbitrary rotations the pivot parameter can specify the rotation center (offset from the source region top-left corner), and the rotation parameter can specify any angle in degrees.

Example

SpriteSheetAsset  spritesBackground;

PackedSprite explosionSprite;

void Initialize() {
    spritesBackground.Load("spritesheets/backgrounds");
}

void Render() {
    RB.SpriteSheetSet(spritesBackground);

    // Copy a 256x128 region from the sprite sheet into a 512x256 destination (x2 scale)
    RB.DrawCopy(new Rect2i(00256128), new Rect2i(00512256));
}

See Also

RB.DrawSprite
RB.DrawNineSlice
RB.SpriteSheetSet
SpriteSheetAsset

See Docs

Features - Drawing
Features - Sprite Sheets