_images/logo_large.png

v2.0.0

API Reference

class RB

RetroBlit game framework

Public Types

enum Effect

Post-processing effect type

Values:

Scanlines

Retro CRT scanline effect

Noise

Retro CRT screen noise

Desaturation

Desaturate colors

Curvature

Retro CRT screen curvature

Slide

Slide display in or out from given direction

Wipe

Wipe display out from given direction

Shake

Shake the display

Zoom

Zoom display in or out

Rotation

Rotate display by given angle

ColorFade

Fade the screen to given color

ColorTint

Apply a tint of given color

Negative

Turn colors to negative

Pixelate

Pixelate effect

Pinhole

Pinhole

InvertedPinhole

Inverted pinhole

Fizzle

Fizzle out

enum PixelStyle

Display pixel style

Values:

Square

Normal square pixels

Wide

Wide pixels

Tall

Tall pixels

enum Filter

Texture filter to apply when using custom shaders

Values:

Nearest

No smoothing, sample from a single nearest texel only

Linear

Linear interpolation, averaged between neighbouring texels

Public Functions

delegate bool RB.InputOverrideMethod(int button, int player, out bool handled)

Delegate for overriding input mapping

Return
Return true if the button is currently held down, or false if it is up
Parameters
  • button: The button being queried
  • player: The player for which the button is being queried
  • handled: Set to true if the button override was handled, or false if default RetroBlit mapping should be used

Public Members

const int RB.SPRITE_INVALID = 0x7FFFFFFF

Invalid sprite index

const int RB.SPRITE_EMPTY = 0x7FFFFFFE

An empty sprite index, use this to clear a tile in a tilemap

const int RB.FLIP_H = 1 << 0

Flip sprite horizontally

const int RB.FLIP_V = 1 << 1

Flip sprite vertically

const int RB.ROT_90_CW = 1 << 2

Rotate sprite 90 degrees clockwise

const int RB.ROT_90_CCW = ROT_90_CW | FLIP_H | FLIP_V

Rotate sprite 90 degrees counter-clockwise. This is equivalent to RB.ROT_90_CW | RB.FLIP_H | RB.FLIP_V

const int RB.ROT_180_CCW = FLIP_H | FLIP_V

Rotate sprite 180 degrees counter-clockwise. This is equivalent to RB.FLIP_H | RB.FLIP_V

const int RB.ROT_180_CW = FLIP_H | FLIP_V

Rotate sprite 90 degrees clockwise. This is equivalent to RB.FLIP_H | RB.FLIP_V

const int RB.ROT_270_CW = ROT_90_CW | FLIP_H | FLIP_V

Rotate sprite 270 degrees clockwise. This is equivalent to RB.ROT_90_CW | RB.FLIP_H | RB.FLIP_V

const int RB.ROT_270_CCW = ROT_90_CW

Rotate sprite 270 degrees counter-clockwise. This is equivalent to RB.ROT_90_CW

const int RB.ALIGN_H_LEFT = 1 << 9

Align to the left edge

const int RB.ALIGN_H_RIGHT = 1 << 10

Align to the right edge

const int RB.ALIGN_H_CENTER = 1 << 11

Center horizontally

const int RB.ALIGN_V_TOP = 1 << 12

Align to the top edge

const int RB.ALIGN_V_BOTTOM = 1 << 13

Align to the bottom edge

const int RB.ALIGN_V_CENTER = 1 << 14

Center vertically

const int RB.TEXT_OVERFLOW_CLIP = 1 << 16

Clip text to given rectangular area

const int RB.TEXT_OVERFLOW_WRAP = 1 << 17

Wrap text to the next line so that it doesn’t overflow the given text area horizontally.

const int RB.NO_INLINE_COLOR = 1 << 18

Ignore any inline color changes when printing text

const int RB.BTN_UP = 1 << 0

Up D-pad Button on gamepad, or KeyCode.W for player one, or KeyCode.UpArrow for player two. Use RB.InputOverride(InputOverrideMethod) to override input mapping

const int RB.BTN_DOWN = 1 << 1

Down D-pad Button on gamepad, or KeyCode.S for player one, or KeyCode.DownArrow for player two. Use RB.InputOverride(InputOverrideMethod) to override input mapping

const int RB.BTN_LEFT = 1 << 2

Left D-pad Button on gamepad, or KeyCode.A for player one, or KeyCode.LeftArrow for player two. Use RB.InputOverride(InputOverrideMethod) to override input mapping

const int RB.BTN_RIGHT = 1 << 3

Right D-pad Button on gamepad, or KeyCode.D for player one, or KeyCode.RightArrow for player two. Use RB.InputOverride(InputOverrideMethod) to override input mapping

const int RB.BTN_A = 1 << 4

A Button on gamepad, or KeyCode.B, KeyCode.Space for player one, or KeyCode.Semicolon, KeyCode.Keypad1, KeyCode.RightControl for player two. Use RB.InputOverride(InputOverrideMethod) to override input mapping

const int RB.BTN_B = 1 << 5

B Button on gamepad, or KeyCode.N for player one, or KeyCode.Quote, KeyCode.Keypad2 for player two. Use RB.InputOverride(InputOverrideMethod) to override input mapping

const int RB.BTN_X = 1 << 6

X Button on gamepad, or KeyCode.G for player one, or KeyCode.P, KeyCode.Keypad4 for player two. Use RB.InputOverride(InputOverrideMethod) to override input mapping

const int RB.BTN_Y = 1 << 7

Y Button on gamepad, or KeyCode.H for player one, or KeyCode.LeftBracket, KeyCode.Keypad5 for player two. Use RB.InputOverride(InputOverrideMethod) to override input mapping

const int RB.BTN_LS = 1 << 8

Left Shoulder Button on gamepad, or KeyCode.T for player one, or KeyCode.Alpha0, KeyCode.Keypad7 for player two. Use RB.InputOverride(InputOverrideMethod) to override input mapping

const int RB.BTN_RS = 1 << 9

Right Shoulder Button on gamepad, or KeyCode.Y for player one, or KeyCode.Minus, KeyCode.Keypad8 for player two. Use RB.InputOverride(InputOverrideMethod) to override input mapping

const int RB.BTN_MENU = 1 << 10

Menu Button on gamepad, or KeyCode.Alpha5 for player one, or KeyCode.Backspace, KeyCode.KeypadDivide for player two. Use RB.InputOverride(InputOverrideMethod) to override input mapping

const int RB.BTN_SYSTEM = 1 << 11

System Button on either gamepad, or KeyCode.Escape Use RB.InputOverride(InputOverrideMethod) to override input mapping

const int RB.BTN_POINTER_A = 1 << 12

Screen touch, or KeyCode.Mouse0 Use RB.InputOverride(InputOverrideMethod) to override input mapping

const int RB.BTN_POINTER_B = 1 << 13

KeyCode.Mouse1 Use RB.InputOverride(InputOverrideMethod) to override input mapping

const int RB.BTN_POINTER_C = 1 << 14

KeyCode.Mouse2 Use RB.InputOverride(InputOverrideMethod) to override input mapping

const int RB.BTN_ABXY = BTN_A | BTN_B | BTN_X | BTN_Y

Equivalent to RB.BTN_A | RB.BTN_B | RB.BTN_X | RB.BTN_Y Use RB.InputOverride(InputOverrideMethod) to override input mapping

const int RB.BTN_POINTER_ABC = BTN_POINTER_A | BTN_POINTER_B | BTN_POINTER_C

Equivalent to RB.BTN_POINTER_A | RB.BTN_POINTER_B | RB.BTN_POINTER_C Use RB.InputOverride(InputOverrideMethod) to override input mapping

const int RB.BTN_SHOUDLER = BTN_LS | BTN_RS

Equivalent to RB.BTN_LS | RB.BTN_RS Use RB.InputOverride(InputOverrideMethod) to override input mapping

const int RB.PLAYER_ONE = 1 << 0

Specifies player one, can be used with RB.ButtonDown(int, int), RB.ButtonPressed(int, int) and RB.ButtonReleased(int, int)

const int RB.PLAYER_TWO = 1 << 1

Specifies player two, can be used with RB.ButtonDown(int, int), RB.ButtonPressed(int, int) and RB.ButtonReleased(int, int)

const int RB.PLAYER_THREE = 1 << 2

Specifies player two, can be used with RB.ButtonDown(int, int), RB.ButtonPressed(int, int) and RB.ButtonReleased(int, int)

const int RB.PLAYER_FOUR = 1 << 3

Specifies player two, can be used with RB.ButtonDown(int, int), RB.ButtonPressed(int, int) and RB.ButtonReleased(int, int)

const int RB.PLAYER_ANY = PLAYER_ONE | PLAYER_TWO | PLAYER_THREE | PLAYER_FOUR

Equivalent to RB.PLAYER_ONE | RB.PLAYER_TWO | RB.PLAYER_THREE | RB.PLAYER_FOUR

Property

property RB::Game

Reference to the Game running under RetroBlit. This is the same instance that is given to RetroBlit by the RB.Initialize method.

property RB::DisplaySize

Display size as given in IRetroBlitGame.QueryHardware.

property RB::DisplaySurface

Returns the display surface, which can then be rendered in a custom fashion

property RB::MapSize

Tilemap size as given in IRetroBlitGame.QueryHardware.

property RB::MapChunkSize

Tilemap chunk size as given in IRetroBlitGame.QueryHardware

property RB::MapLayers

Amount of map layers as given in IRetroBlitGame.QueryHardware.

property RB::FPS

Get target FPS as set by IRetroBlitGame.QueryHardware.

property RB::UpdateInterval

Get update interval which is equivalent to 1.0f / RB.FPS.

property RB::Ticks

Represents the count of calls to IRetroBlitGame.Update since startup, or since RB.TicksReset was called.

Public Static Functions

static bool RB.Initialize(IRetroBlitGame game)

Initialize RetroBlit with the given game instance. As part of initialization RetroBlit will call IRetroBlitGame.QueryHardware, followed by IRetroBlitGame.Initialize.

Return
True if successful
Parameters
  • game: A RetroBlit Game

static void RB.PresentDisable()

Disable rendering to display, you may instead render yourself by using RB.DisplaySurface with your own material.

static void RB.PresentEnable()

Re-enable rendering to display.

static void RB.TicksReset()

Reset the ticks counter

static bool RB.DisplayModeSet(Vector2i resolution, PixelStyle pixelStyle = PixelStyle.Square)

Set display mode to given resolution and pixel style. Note that this sets only the RetroBlit pixel resolution, and does not affect the native window size. To change the native window size you can use the Unity Screen.SetResolution() API.

Return
True if mode was successfully set, false otherwise
Parameters

static Vector2i RB.SpriteSize()

Get Sprite size of the current sprite sheet.

Return
Sprite size

static Vector2i RB.SpriteSize(int index)

Get Sprite size of the given sprite sheet.

Return
Sprite size
Parameters
  • index: Spritesheet index

static Vector2i RB.SpriteSheetSize()

Get Sprite sheet size of the current sprite sheet.

Return
Sprite sheet size

static Vector2i RB.SpriteSheetSize(int index)

Get size of the given sprite sheet.

Return
Return sprite sheet size
Parameters
  • index: Spritesheet index

static void RB.Clear(Color32 color)

Clear the current target.

Parameters
  • color: Color to clear with

static void RB.Clear(Color32 color, Rect2i rect)

Clear a region of the current target. Useful for clearing sprite sheet areas to alpha 0.

Parameters
  • color: Color to clear with
  • rect: Region to clear

static int RB.SpriteIndex(int column, int row)

Helper function for calculating sprite index given sprite sheet column and row.

There is no bounds checking performed, invalid column/row will produce invalid sprite index

Return
Sprite index
Parameters
  • column: Column
  • row: Row

static int RB.SpriteIndex(int spriteSheetIndex, int column, int row)

Helper function for calculating sprite index given sprite sheet column and row.

There is no bounds checking performed, invalid column/row will produce invalid sprite index

Return
Sprite index
Parameters
  • spriteSheetIndex: Spritesheet for which to get sprite index for
  • column: Column
  • row: Row

static int RB.SpriteIndex(int spriteSheetIndex, Vector2i cell)

Helper function for calculating sprite index given sprite sheet column and row

There is no bounds checking performed, invalid column/row will produce invalid sprite index

Return
Sprite index
Parameters
  • spriteSheetIndex: Spritesheet for which to get sprite index for
  • cell: Cell in sprite sheet where Vector2i.x is the column and Vector2i.y is the row.

static void RB.SpriteSheetSetup(int index, string filename)

Load a sprite sheet, sprite size will be set to default of 16 x 16.

The sprite size is used by tilemaps to layout tiles, and when using RB.DrawSprite APIs. It is also possible to use a sprite sheet with a variety of sprite sizes and use the RB.DrawCopy APIs to render them.

///

Parameters
  • index: Sprite sheet slot index to load into
  • filename: Filename of the sprite sheet file, must be within a Resources folder

static void RB.SpriteSheetSetup(int index, string filename, Vector2i spriteSize)

Load a sprite sheet and define the size of the sprites in it.

The sprite size is used by tilemaps to layout tiles, and when using RB.DrawSprite APIs. It is also possible to use a sprite sheet with a variety of sprite sizes and use the RB.DrawCopy APIs to render them.

Parameters
  • index: Sprite sheet slot index to load into
  • filename: Filename of the sprite sheet file, must be within a Resources folder
  • spriteSize: The size of sprites in this sprite sheet

static void RB.SpriteSheetSetup(int index, Vector2i size)

Setup a blank sprite sheet, which can be used as an offscreen surface for rendering.

Parameters
  • index: Sprite sheet slot index to load into
  • size: Size of the sprite sheet

static void RB.SpriteSheetSetup(int index, Vector2i size, Vector2i spriteSize)

Setup a blank sprite sheet, which can be used as an offscreen surface for rendering

The sprite size is used by tilemaps to layout tiles, and when using RB.DrawSprite APIs. It is also possible to use a sprite sheet with a variety of sprite sizes and use the RB.DrawCopy APIs to render them.

Parameters
  • index: Sprite sheet slot index to load into
  • size: Size of the sprite sheet
  • spriteSize: The size of sprites in this sprite sheet

static void RB.SpriteSheetDelete(int index)

Delete the given sprite sheet, freeing up GPU resources

Parameters
  • index: Sprite sheet slot index to delete

static void RB.SpriteSheetSet(int index)

Switch to the given sprite sheet.

All sprite rendering from this point on will use this sprite sheet until a different sprite sheet is chosen.

Parameters
  • index: Sprite sheet slot index to switch to.

static int RB.SpriteSheetGet()

Gets the index of the current sprite sheet.

Return
Index of the current sprite sheet

static void RB.DrawSprite(int spriteIndex, Vector2i pos)

Draw a sprite with a given sprite index from the sprite sheet.

Parameters
  • spriteIndex: Sprite index
  • pos: Position on display

static void RB.DrawSprite(int spriteIndex, Rect2i destRect)

Draw a sprite with a given sprite index from the sprite sheet, and a destination rectangle.

Parameters
  • spriteIndex: Sprite index
  • destRect: Destination rectangle

static void RB.DrawSprite(int spriteIndex, Vector2i pos, int flags = 0)

Draw a sprite with a given sprite index from the sprite sheet.

Parameters

static void RB.DrawSprite(int spriteIndex, Rect2i destRect, int flags = 0)

Draw a sprite with a given sprite index from the sprite sheet, and a destination rectangle.

Parameters

static void RB.DrawSprite(int spriteIndex, Vector2i pos, Vector2i pivot, float rotation)

Draw a sprite with a given sprite index from the sprite sheet, a position, a pivot point and a rotation in degrees.

Parameters
  • spriteIndex: Sprite index
  • pos: Position on display
  • pivot: Rotation pivot point, specified as an offset from the sprites top left corner
  • rotation: Rotation in degrees

static void RB.DrawSprite(int spriteIndex, Rect2i destRect, Vector2i pivot, float rotation)

Draw a sprite with a given sprite index from the sprite sheet, a destination rectangle, a pivot point and a rotation in degrees.

Parameters
  • spriteIndex: Sprite index
  • destRect: Position on display
  • pivot: Rotation pivot point, specified as an offset from the destination rectangle’s top left corner
  • rotation: Rotation in degrees

static void RB.DrawSprite(int spriteIndex, Vector2i pos, Vector2i pivot, float rotation, int flags = 0)

Draw a sprite with a given sprite index from the sprite sheet, a position, a pivot point and a rotation in degrees.

Parameters

static void RB.DrawSprite(int spriteIndex, Rect2i destRect, Vector2i pivot, float rotation, int flags = 0)

Draw a sprite with a given sprite index from the sprite sheet, a destination rectangle, a pivot point and a rotation in degrees.

Parameters

static void RB.DrawCopy(Rect2i srcRect, Vector2i pos)

Copy a rectangular region from the sprite sheet to the given position.

Parameters
  • srcRect: Source rectangle on the sprite sheet
  • pos: Position

static void RB.DrawCopy(Rect2i srcRect, Vector2i pos, int flags = 0)

Copy a rectangular region from the sprite sheet to the given position.

Parameters

static void RB.DrawCopy(Rect2i srcRect, Vector2i pos, Vector2i pivot, float rotation)

Copy a rectangular region from the sprite sheet to the given position, a pivot point and a rotation in degrees.

Parameters
  • srcRect: Source rectangle on the sprite sheet
  • pos: Position
  • pivot: Rotation pivot point, specified as an offset from the rectangles top left corner
  • rotation: Rotation in degrees

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

Copy a rectangular region from the sprite sheet to the given position, a pivot point and a rotation in degrees.

Parameters

static void RB.DrawCopy(Rect2i srcRect, Rect2i destRect)

Copy a rectangular region from the sprite sheet to a destination rectangle.

Parameters
  • srcRect: Source rectangle on the sprite sheet
  • destRect: Destination rectangle

static void RB.DrawCopy(Rect2i srcRect, Rect2i destRect, int flags = 0)

Copy a rectangular region from the sprite sheet to a destination rectangle.

Parameters

static void RB.DrawCopy(Rect2i srcRect, Rect2i destRect, Vector2i pivot, float rotation)

Copy a rectangular region from the sprite sheet to a destination rectangle, with the given pivot point and rotation in degrees.

Parameters
  • srcRect: Source rectangle on the sprite sheet
  • destRect: Destination rectangle
  • pivot: Rotation pivot point, specified as an offset from the destination rectangle’s top left corner
  • rotation: Rotation in degrees

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

Copy a rectangular region from the sprite sheet to a destination rectangle, with the given pivot point and rotation in degrees.

Parameters

static void RB.DrawNineSlice(Rect2i destRect, Rect2i srcTopLeftCornerRect, Rect2i srcTopSideRect, Rect2i srcMiddleRect)

Draw a nine-slice sprite. Only need to pass one corner, one side, and middle, the rest is mirrored.

Parameters
  • destRect: Destination rectangle
  • srcTopLeftCornerRect: Source rectangle of the top left corner
  • srcTopSideRect: Source rectangle of the top side
  • srcMiddleRect: Source rectangle of the middle

static void RB.DrawNineSlice(Rect2i destRect, Rect2i srcTopLeftCornerRect, Rect2i srcTopSideRect, Rect2i srcTopRightCornerRect, Rect2i srcLeftSideRect, Rect2i srcMiddleRect, Rect2i srcRightSideRect, Rect2i srcBottomLeftCornerRect, Rect2i srcBottomSideRect, Rect2i srcBottomRightCornerRect)

Draw a nine-slice sprite.

Parameters
  • destRect: Destination rectangle
  • srcTopLeftCornerRect: Source rectangle of the top left corner
  • srcTopSideRect: Source rectangle of the top side
  • srcTopRightCornerRect: Source rectangle of the top right corner
  • srcLeftSideRect: Source rectangle of the left side
  • srcMiddleRect: Source rectangle of the middle
  • srcRightSideRect: Source rectangle of the right side
  • srcBottomLeftCornerRect: Source rectangle of the bottom left corner
  • srcBottomSideRect: Source rectangle of the bottom side
  • srcBottomRightCornerRect: Source rectangle of the bottom right corner

static void RB.DrawNineSlice(Rect2i destRect, NineSlice nineSlice)

Draw a nine-slice sprite.

Parameters
  • destRect: Destination rectangle
  • nineSlice: NineSlice defining the parts of the nine-slice image

static void RB.DrawPixel(Vector2i pos, Color32 color)

Draw a pixel.

Parameters
  • pos: Position
  • color: Color

static void RB.DrawTriangle(Vector2i p0, Vector2i p1, Vector2i p2, Color32 color)

Draw a triangle outline

Parameters
  • p0: First point of the triangle
  • p1: Second point of the triangle
  • p2: Third point of the triangle
  • color: Color

static void RB.DrawTriangle(Vector2i p0, Vector2i p1, Vector2i p2, Color32 color, Vector2i pivot, float rotation)

Draw a triangle outline with a pivot point and rotation in degrees

Parameters
  • p0: First point of the triangle
  • p1: Second point of the triangle
  • p2: Third point of the triangle
  • color: Color
  • pivot: Rotation pivot point, specified as an offset from the rectangle’s top left corner
  • rotation: Rotation in degrees

static void RB.DrawTriangleFill(Vector2i p0, Vector2i p1, Vector2i p2, Color32 color)

Draw a filled triangle

Parameters
  • p0: First point of the triangle
  • p1: Second point of the triangle
  • p2: Third point of the triangle
  • color: Color

static void RB.DrawTriangleFill(Vector2i p0, Vector2i p1, Vector2i p2, Color32 color, Vector2i pivot, float rotation)

Draw a filled triangle with a pivot point and rotation in degrees

Parameters
  • p0: First point of the triangle
  • p1: Second point of the triangle
  • p2: Third point of the triangle
  • color: Color
  • pivot: Rotation pivot point, specified as an offset from the rectangle’s top left corner
  • rotation: Rotation in degrees

static void RB.DrawRect(Rect2i rect, Color32 color)

Draw a rectangle outline

Parameters
  • rect: Rectangular area
  • color: Color

static void RB.DrawRect(Rect2i rect, Color32 color, Vector2i pivot, float rotation)

Draw a rectangle outline with a pivot point and rotation in degrees

Parameters
  • rect: Rectangular area
  • color: Color
  • pivot: Rotation pivot point, specified as an offset from the rectangle’s top left corner
  • rotation: Rotation in degrees

static void RB.DrawRectFill(Rect2i rect, Color32 color)

Draw a filled rectangle

Parameters
  • rect: Rectangular area
  • color: Color

static void RB.DrawRectFill(Rect2i rect, Color32 color, Vector2i pivot, float rotation)

Draw a filled rectangle with a pivot point and rotation in degrees

Parameters
  • rect: Rectangular area
  • color: Color
  • pivot: Rotation pivot point, specified as an offset from the rectangle’s top left corner
  • rotation: Rotation in degrees

static void RB.DrawLine(Vector2i p0, Vector2i p1, Color32 color)

Draw a line between two points.

Parameters
  • p0: One end of the line
  • p1: The other end of the line
  • color: Color

static void RB.DrawLine(Vector2i p0, Vector2i p1, Color32 color, Vector2i pivot, float rotation)

Draw a line between two points, with a pivot point and rotation in degrees.

Parameters
  • p0: One end of the line
  • p1: The other end of the line
  • color: Color
  • pivot: Pivot point
  • rotation: Rotation in degrees

static void RB.DrawEllipse(Vector2i center, Vector2i radius, Color32 color)

Draw an ellipse outline.

Parameters
  • center: Center position
  • radius: Radius
  • color: Color

static void RB.DrawEllipseFill(Vector2i center, Vector2i radius, Color32 color)

Draw a filled ellipse.

Parameters
  • center: Center position
  • radius: Radius
  • color: Color

static void RB.DrawEllipseInvertedFill(Vector2i center, Vector2i radius, Color32 color)

Draw an inversely filled ellipse. The fill covers the area outside of the ellipse, while leaving the inside of the ellipse empty.

Parameters
  • center: Center position
  • radius: Radius
  • color: Color

static void RB.DrawMapLayer(int layer)

Draw the given map layer to the display.

Parameters
  • layer: Layer number to draw

static void RB.DrawMapLayer(int layer, Vector2i pos)

Draw the given map layer to the display with an offset.

Parameters
  • layer: Layer number to draw
  • pos: Offset

static void RB.AlphaSet(byte a)

Set the alpha transparency value for drawing.

Parameters
  • a: A value between 0 (invisible) to 255 (solid)

static byte RB.AlphaGet()

Get the current alpha transparency value

Return
Transparency

static void RB.TintColorSet(Color32 tintColor)

Set the tint color for drawing.

Parameters
  • tintColor: Tint color

static Color32 RB.TintColorGet()

Get the current tint color.

Return
Tint color

static void RB.CameraSet(Vector2i pos)

Set the current camera position for drawing

Parameters
  • pos: Position

static void RB.CameraReset()

Reset the camera position back to 0, 0. This is equivalent to RB.CameraSet(0, 0).

static Vector2i RB.CameraGet()

Get the current camera position

Return
Camera position

static void RB.ClipSet(Rect2i rect)

Set a rectangular clipping region. All drawing outside of this region will be clipped away. By default the clipping region covers the entire display.

Parameters
  • rect: Rectangular clip region

static void RB.ClipReset()

Reset the clipping region back to covering the entire render surface, be it the display, or current offscreen target.

static Rect2i RB.ClipGet()

Get the current clipping region.

Return
Clipping region

static void RB.ClipDebugEnable(Color32 color)

Enable clip region debugging by drawing rectangles around the clip regions with the given color index. Subsequent calls to ClipDebugEnable will change the color for subsequent calls to <ref>RetroBlit.ClipSet</ref>. This debug state is reset at the start of each frame.

Parameters
  • color: RGBA color

static void RB.ClipDebugDisable()

Disable clip region debugging, will not draw clip region outlines for subsequent calls to <ref>RetroBlit.ClipSet</ref>.

static void RB.BatchDebugEnable(Color32 fontColor, Color32 backgroundColor)

Enable a batch debugging overlay which shows how many draw batches are being used

Parameters
  • fontColor: Font color to use
  • backgroundColor: Background color to use

static void RB.BatchDebugDisable()

Disable batch debugging overlay

static void RB.Offscreen(int spriteSheetIndex)

Switch to drawing to the a sprite sheet surface. All subsequent drawing calls will target this sprite sheet

Parameters
  • spriteSheetIndex: SpriteSheet to switch to

static void RB.Onscreen()

Switch to drawing to the display.

static void RB.MapSpriteSet(int layer, Vector2i tilePos, int sprite, int flags = 0)

Set the tilemap sprite index at the given tile position, with optional flags.

Parameters
  • layer: Map layer
  • tilePos: Tile position
  • sprite: Sprite index
  • flags: Sprite flags

static void RB.MapSpriteSet(int layer, Vector2i tilePos, int sprite, Color32 tintColor, int flags = 0)

Set the tilemap sprite index at the given tile position, with color tint and optional flags.

Parameters
  • layer: Map layer
  • tilePos: Tile position
  • sprite: Sprite index
  • tintColor: Tint color
  • flags: Sprite flags

static int RB.MapSpriteGet(int layer, Vector2i tilePos)

Get the sprite index at the given tile position

Return
Sprite index
Parameters
  • layer: Map layer
  • tilePos: Tile position

static void RB.MapDataSet< T >(int layer, Vector2i tilePos, T data)

Set user data for the tilemap at the given tile position

Template Parameters
  • T: Type of data
Parameters
  • layer: Tilemap layer
  • tilePos: Tile position
  • data: Data

static T RB.MapDataGet< T >(int layer, Vector2i tilePos)

Get user data for the tilemap at the given tile position

Return
Data
Template Parameters
  • T: Type of data
Parameters
  • layer: Tilemap layer
  • tilePos: Tile position

static void RB.MapClear()

Clear the entire tilemap, on all layers.

static void RB.MapClear(int layer)

Clear only the given tilemap layer.

Parameters
  • layer: Layer to clear

static TMXMap RB.MapLoadTMX(string fileName)

Load a tilemap definition from the given TMX file.

The filename should point to the original TMX file in your Resources folder, but internally RetroBlit will actually load a binary version of the TMX file that it generates using RetroBlitTMXPostProcessor. If there is a problem loading your TMX file then please try to re-import it which will cause a new binary TMX file to be generated and any import errors will be logged to Unity console.

Return
Tilemap definition, or null if loading failed
Parameters
  • fileName: TMX file, must be within a Resources folder.

static bool RB.MapLoadTMXLayer(TMXMap tmx, string sourceLayerName, int destinationLayer)

Load a layer from a TMX tilemap definition previously loaded by RB.MapLoadTMX.

Only valid with non-infinite maps

Return
True if successful
Parameters
  • tmx: TMX tilemap definition
  • sourceLayerName: Name of the TMX layer. Duplicate layer names are not supported
  • destinationLayer: The RetroBlit layer to load into

static bool RB.MapLoadTMXLayer(TMXMap tmx, string sourceLayerName, int destinationLayer, Rect2i sourceRect, Vector2i destPos)

Load a layer from a TMX tilemap definition previously loaded by RB.MapLoadTMX. Can be used to load only a section of the layer.

Only valid with non-infinite maps

Return
True if successful
Parameters
  • tmx: TMX tilemap definition
  • sourceLayerName: Name of the TMX layer. Duplicate layer names are not supported
  • destinationLayer: The RetroBlit layer to load into
  • sourceRect: Source rectangular tilemap area to load from
  • destPos: Destination position in the RetroBlit layer in tile coordinates

static bool RB.MapLoadTMXLayerChunk(TMXMap tmx, string sourceLayerName, int destinationLayer, Vector2i chunkOffset, Vector2i destPos)

Load a single layer chunk from a TMX tilemap definition loaded by RB.MapLoadTMX. This method is used for loading infinite maps chunk by chunk.

Only valid with infinite maps

Return
True if successful
Parameters
  • tmx: TMX tilemap definition
  • sourceLayerName: Name of the TMX layer. Duplicate layer names are not supported
  • destinationLayer: The RetroBlit layer to load into
  • chunkOffset: Chunk offset in the TMX layer in tile coordinates
  • destPos: Destination position in the RetroBlit layer in tile coordinates

static void RB.MapLayerSpriteSheetSet(int mapLayer, int spriteSheetIndex)

Set the sprite sheet to be used by the given tilemap layer.

Each layer can use a different sprite sheet, and therefore each layer can have different tile sizes that match it’s sprite sheet’s sprite size.

Parameters
  • mapLayer: Map layer number
  • spriteSheetIndex: Sprite sheet slot index to use

static bool RB.MapChunkEmpty(int layer, Vector2i pos)

Check if a map chunk at the given position is empty/unloaded. A chunk can become empty if its been shifted out (see RB.MapShiftChunks(int, Vector2i), or has been released internally because it has not been visible for some time.

Return
True if empty, false otherwise
Parameters
  • layer: Chunk layer
  • pos: Offset of the chunk in tile coordinates

static void RB.MapShiftChunks(int layer, Vector2i shiftChunks)

Shift the tilemap chunks by the given amount chunks in the X and Y direction. This method is particularly useful while loading infinite maps chunk by chunk.

In an infinite map you will typically monitor the player position and when they move out of a chunk you can shift the entire map in the direction opposite to the movement, and load new chunks in the newly vacated map chunks.

Parameters
  • layer: Map layer
  • shiftChunks: Shift amount in chunk numbers in the x and y direction.

static void RB.Print(Vector2i pos, Color32 color, string text)

Print text to display using system font at the given position.

In the text string the “@” character is an escape character, and it enables the following options:

  • “@@” - Print @
  • “@######” - Color change in the format RRGGBB, where each color channel has a hex value between 00 and FF
  • “@-” - Revert back to the color specified in the color parameter.
  • “@w###” - Apply a wavy text effect in the format APS (wave amplitude, period, and speed), where each parameter has a value between 0 and 9. Default is “@w000”
  • “@s#” - Apply a shaky text effect in the format M (magnitude), where M has a value between 0 and 9. Default is “@s0”
  • “@g##” - Change the font to the given 2 digit font index. Default is “@g99” which is a special value indicating built-in system font.

Parameters
  • pos: Position
  • color: Color
  • text: Text

static void RB.Print(Vector2i pos, Color32 color, int flags, string text)

Print text to display using system font at the given position.

In the text string the “@” character is an escape character, and it enables the following options:

  • “@@” - Print @
  • “@######” - Color change in the format RRGGBB, where each color channel has a hex value between 00 and FF
  • “@-” - Revert back to the color specified in the color parameter.
  • “@w###” - Apply a wavy text effect in the format APS (wave amplitude, period, and speed), where each parameter has a value between 0 and 9. Default is “@w000”
  • “@s#” - Apply a shaky text effect in the format M (magnitude), where M has a value between 0 and 9. Default is “@s0”
  • “@g##” - Change the font to the given 2 digit font index. Default is “@g99” which is a special value indicating built-in system font.

Parameters

static void RB.Print(Rect2i rect, Color32 color, int alignFlags, string text)

Print text to display using system font at the given position.

In the text string the “@” character is an escape character, and it enables the following options:

  • “@@” - Print @
  • “@######” - Color change in the format RRGGBB, where each color channel has a hex value between 00 and FF
  • “@-” - Revert back to the color specified in the color parameter.
  • “@w###” - Apply a wavy text effect in the format APS (wave amplitude, period, and speed), where each parameter has a value between 0 and 9. Default is “@w000”
  • “@s#” - Apply a shaky text effect in the format M (magnitude), where M has a value between 0 and 9. Default is “@s0”
  • “@g##” - Change the font to the given 2 digit font index. Default is “@g99” which is a special value indicating built-in system font.

Parameters

static void RB.Print(Vector2i pos, Color32 color, FastString text)

Print text to display using system font at the given position.

In the text string the “@” character is an escape character, and it enables the following options:

  • “@@” - Print @
  • “@######” - Color change in the format RRGGBB, where each color channel has a hex value between 00 and FF
  • “@-” - Revert back to the color specified in the color parameter.
  • “@w###” - Apply a wavy text effect in the format APS (wave amplitude, period, and speed), where each parameter has a value between 0 and 9. Default is “@w000”
  • “@s#” - Apply a shaky text effect in the format M (magnitude), where M has a value between 0 and 9. Default is “@s0”
  • “@g##” - Change the font to the given 2 digit font index. Default is “@g99” which is a special value indicating built-in system font.

Parameters
  • pos: Position
  • color: Color
  • text: Text

static void RB.Print(Vector2i pos, Color32 color, int flags, FastString text)

Print text to display using system font at the given position.

In the text string the “@” character is an escape character, and it enables the following options:

  • “@@” - Print @
  • “@######” - Color change in the format RRGGBB, where each color channel has a hex value between 00 and FF
  • “@-” - Revert back to the color specified in the color parameter.
  • “@w###” - Apply a wavy text effect in the format APS (wave amplitude, period, and speed), where each parameter has a value between 0 and 9. Default is “@w000”
  • “@s#” - Apply a shaky text effect in the format M (magnitude), where M has a value between 0 and 9. Default is “@s0”
  • “@g##” - Change the font to the given 2 digit font index. Default is “@g99” which is a special value indicating built-in system font.

Parameters

static void RB.Print(Rect2i rect, Color32 color, int alignFlags, FastString text)

Print text to display using system font at the given position.

In the text string the “@” character is an escape character, and it enables the following options:

  • “@@” - Print @
  • “@######” - Color change in the format RRGGBB, where each color channel has a hex value between 00 and FF
  • “@-” - Revert back to the color specified in the color parameter.
  • “@w###” - Apply a wavy text effect in the format APS (wave amplitude, period, and speed), where each parameter has a value between 0 and 9. Default is “@w000”
  • “@s#” - Apply a shaky text effect in the format M (magnitude), where M has a value between 0 and 9. Default is “@s0”
  • “@g##” - Change the font to the given 2 digit font index. Default is “@g99” which is a special value indicating built-in system font.

Parameters

static Vector2i RB.PrintMeasure(string text)

Measure a text string without printing it, using system font.

Return
Dimensions
Parameters
  • text: Text

static Vector2i RB.PrintMeasure(Rect2i rect, int alignFlags, string text)

Measure a text string without printing it, using system font.

Return
Dimensions
Parameters

static Vector2i RB.PrintMeasure(FastString text)

Measure a text string without printing it, using system font.

Return
Dimensions
Parameters
  • text: Text

static Vector2i RB.PrintMeasure(Rect2i rect, int alignFlags, FastString text)

Measure a text string without printing it, using system font.

Return
Dimensions
Parameters

static void RB.Print(int fontIndex, Vector2i pos, Color32 color, string text)

Print text to display using custom font at the given position.

In the text string the “@” character is an escape character, and it enables the following options:

  • “@@” - Print @
  • “@######” - Color change in the format RRGGBB, where each color channel has a hex value between 00 and FF
  • “@-” - Revert back to the color specified in the color parameter.
  • “@w###” - Apply a wavy text effect in the format APS (wave amplitude, period, and speed), where each parameter has a value between 0 and 9. Default is “@w000”
  • “@s#” - Apply a shaky text effect in the format M (magnitude), where M has a value between 0 and 9. Default is “@s0”
  • “@g##” - Change the font to the given 2 digit font index. Default is “@g99” which is a special value indicating built-in system font.

Parameters
  • fontIndex: Font index
  • pos: Position
  • color: Color
  • text: Text

static void RB.Print(int fontIndex, Vector2i pos, Color32 color, int flags, string text)

Print text to display using custom font at the given position.

In the text string the “@” character is an escape character, and it enables the following options:

  • “@@” - Print @
  • “@######” - Color change in the format RRGGBB, where each color channel has a hex value between 00 and FF
  • “@-” - Revert back to the color specified in the color parameter.
  • “@w###” - Apply a wavy text effect in the format APS (wave amplitude, period, and speed), where each parameter has a value between 0 and 9. Default is “@w000”
  • “@s#” - Apply a shaky text effect in the format M (magnitude), where M has a value between 0 and 9. Default is “@s0”
  • “@g##” - Change the font to the given 2 digit font index. Default is “@g99” which is a special value indicating built-in system font.

Parameters
  • fontIndex: Font index
  • pos: Position
  • color: Color
  • flags: Optional flag RB.NO_INLINE_COLOR
  • text: Text

static void RB.Print(int fontIndex, Rect2i rect, Color32 color, int alignFlags, string text)

Print text to display using custom font at the given position.

In the text string the “@” character is an escape character, and it enables the following options:

  • “@@” - Print @
  • “@######” - Color change in the format RRGGBB, where each color channel has a hex value between 00 and FF
  • “@-” - Revert back to the color specified in the color parameter.
  • “@w###” - Apply a wavy text effect in the format APS (wave amplitude, period, and speed), where each parameter has a value between 0 and 9. Default is “@w000”
  • “@s#” - Apply a shaky text effect in the format M (magnitude), where M has a value between 0 and 9. Default is “@s0”
  • “@g##” - Change the font to the given 2 digit font index. Default is “@g99” which is a special value indicating built-in system font.

Parameters

static Vector2i RB.PrintMeasure(int fontIndex, string text)

Measure a text string without printing it, using custom font.

Return
Dimensions
Parameters
  • fontIndex: Font index
  • text: Text

static Vector2i RB.PrintMeasure(int fontIndex, Rect2i rect, int alignFlags, string text)

Measure a text string without printing it, using custom font.

Return
Dimensions
Parameters

static void RB.Print(int fontIndex, Vector2i pos, Color32 color, FastString text)

Print text to display using custom font at the given position.

In the text string the “@” character is an escape character, and it enables the following options:

  • “@@” - Print @
  • “@######” - Color change in the format RRGGBB, where each color channel has a hex value between 00 and FF
  • “@-” - Revert back to the color specified in the color parameter.
  • “@w###” - Apply a wavy text effect in the format APS (wave amplitude, period, and speed), where each parameter has a value between 0 and 9. Default is “@w000”
  • “@s#” - Apply a shaky text effect in the format M (magnitude), where M has a value between 0 and 9. Default is “@s0”
  • “@g##” - Change the font to the given 2 digit font index. Default is “@g99” which is a special value indicating built-in system font.

Parameters
  • fontIndex: Font index
  • pos: Position
  • color: Color
  • text: Text

static void RB.Print(int fontIndex, Vector2i pos, Color32 color, int flags, FastString text)

Print text to display using custom font at the given position.

In the text string the “@” character is an escape character, and it enables the following options:

  • “@@” - Print @
  • “@######” - Color change in the format RRGGBB, where each color channel has a hex value between 00 and FF
  • “@-” - Revert back to the color specified in the color parameter.
  • “@w###” - Apply a wavy text effect in the format APS (wave amplitude, period, and speed), where each parameter has a value between 0 and 9. Default is “@w000”
  • “@s#” - Apply a shaky text effect in the format M (magnitude), where M has a value between 0 and 9. Default is “@s0”
  • “@g##” - Change the font to the given 2 digit font index. Default is “@g99” which is a special value indicating built-in system font.

Parameters
  • fontIndex: Font index
  • pos: Position
  • color: Color
  • flags: Optional flag RB.NO_INLINE_COLOR
  • text: Text

static void RB.Print(int fontIndex, Rect2i rect, Color32 color, int alignFlags, FastString text)

Print text to display using custom font at the given position.

In the text string the “@” character is an escape character, and it enables the following options:

  • “@@” - Print @
  • “@######” - Color change in the format RRGGBB, where each color channel has a hex value between 00 and FF
  • “@-” - Revert back to the color specified in the color parameter.
  • “@w###” - Apply a wavy text effect in the format APS (wave amplitude, period, and speed), where each parameter has a value between 0 and 9. Default is “@w000”
  • “@s#” - Apply a shaky text effect in the format M (magnitude), where M has a value between 0 and 9. Default is “@s0”
  • “@g##” - Change the font to the given 2 digit font index. Default is “@g99” which is a special value indicating built-in system font.

8

Parameters

static Vector2i RB.PrintMeasure(int fontIndex, FastString text)

Measure a text string without printing it, using custom font.

Return
Dimensions
Parameters
  • fontIndex: Font index
  • text: Text

static Vector2i RB.PrintMeasure(int fontIndex, Rect2i rect, int alignFlags, FastString text)

Measure a text string without printing it, using custom font.

Return
Dimensions
Parameters

static void RB.FontSetup(int fontIndex, int asciiStart, int asciiEnd, Vector2i srcPos, int spriteSheetIndex, Vector2i glyphSize, int glyphsPerRow, int characterSpacing, int lineSpacing, bool monospaced)

Setup a custom font from the sprite sheet.

The glyphs in your sprite sheet should be organized into a grid, with each cell size being the same. If monospaced is false then RetroBlit will automatically trim any horizontal empty space on either side of the glyph. If monospaced is true then the empty space is retained.

Parameters
  • fontIndex: Font index
  • asciiStart: First ascii character in the font
  • asciiEnd: Last ascii character in the font
  • srcPos: Top left corner of the set of glyphs in the sprite sheet
  • spriteSheetIndex: The index of the sprite sheet containing the font
  • glyphSize: Dimensions of a single glyph
  • glyphsPerRow: Amount of glyphs per row in the sprite sheet
  • characterSpacing: Spacing between characters
  • lineSpacing: Line spacing between lines of text
  • monospaced: True if font is monospaced

static bool RB.ButtonDown(int button, int player = RB.PLAYER_ONE)

Return true if any of the given button(s) are held down.

Return
True if button(s) held down
Parameters
  • button: A bitmask of one or multiple buttons.
  • player: Player to check, or RB.PLAYER_ANY to check any player. Defaults to RB.PLAYER_ONE

static bool RB.ButtonPressed(int button, int player = RB.PLAYER_ONE)

Return true if any of the given button(s) went from an up to down state since last IRetroBlitGame.Update call.

Return
True if button(s) pressed
Parameters
  • button: A bitmask of one or multiple buttons.
  • player: Player to check, or RB.PLAYER_ANY to check any player. Defaults to RB.PLAYER_ONE

static bool RB.ButtonReleased(int button, int player = RB.PLAYER_ONE)

Return true if any of the given button(s) went from a down to up state since last IRetroBlitGame.Update call.

Return
True if button(s) released
Parameters
  • button: A bitmask of one or multiple buttons.
  • player: Player to check, or RB.PLAYER_ANY to check any player. Defaults to RB.PLAYER_ONE

static bool RB.KeyDown(KeyCode keyCode)

Return true if given key is held down.

Return
True if key held down
Parameters
  • keyCode: Key code

static bool RB.KeyPressed(KeyCode keyCode)

Return true if given key went from an up to down state since last IRetroBlitGame.Update call.

Return
True if key pressed
Parameters
  • keyCode: Key code

static bool RB.KeyReleased(KeyCode keyCode)

Return true if given key went from a down to up state since last IRetroBlitGame.Update call.

Return
True if key released
Parameters
  • keyCode: Key code

static string RB.InputString()

Returns of string of characters entered since last IRetroBlitGame.Update call. Normally this string will be 0 or 1 characters long, but it is possible that the user may quickly perform two key strokes within the spawn of a single game loop.

Return
Character string

static Vector2i RB.PointerPos()

Get the current pointer position. If there is a mouse detected then the position is the position of the mouse pointer in game display coordinates. If there is a touch device then the position is the current touch position. If there is no mouse connected, and there are no active touches then the position is undefined. See RB.PointerPosValid for checking if the pointer position is valid.

Return
Pointer position

static bool RB.PointerPosValid()

Returns true if the pointer position is valid. A pointer position may be undefined if there is no mouse connected, and there are no current touches.

Return
True if pointer position is valid

static float RB.PointerScrollDelta()

Get the delta of the mouse scroll position since last IRetroBlitGame.Update call. The delta is always 0 if there is no mouse connected.

Return
Delta position

static void RB.InputOverride(InputOverrideMethod overrideMethod)

Provide a delegate for overriding RetroBlit button mapping. The delegate implementation takes a button and returns true if the button is held down, or false otherwise. How the button state is determined is entirely up to the delegate implementation. Delegate should set the “handled” out parameter to true if it was able to determine the state of the button, or false if it wants to fallback on RetroBlit using its default mapping for this button.

Parameters
  • overrideMethod: Input override delegate

static void RB.SoundSetup(int slotIndex, string fileName)

Setup sound clip at the given sound slot index.

Parameters
  • slotIndex: Sound slot index
  • fileName: Filename of the sound file, must be within a Resources folder

static void RB.SoundDelete(int slotIndex)

Remove sound clip from the given slot index, freeing up resources.

Parameters
  • slotIndex: Sound slot index

static SoundReference RB.SoundPlay(int slotIndex, float volume = 1.0f, float pitch = 1.0f)

Play the sound at the given sound slot index. This function returns the SoundReference of the playing sound, which can then be used to adjust the playback of the sound.

Return
Sound reference
Parameters
  • slotIndex: Sound slot index
  • volume: Volume to play at where 0 is silent, 1 is the original clip volume and values beyond 1 indicate amplification beyond the recorded volume. Defaults to 1
  • pitch: Pitch to play at, where 1 is the original sound pitch, values less than 1 indicate lower pitch, and values greater than 1 indicate higher pitch. Defaults to 1

static bool RB.SoundIsPlaying(SoundReference soundReference)

Check if a sound is playing by using its SoundReference. If a sound is no longer playing it’s reference is considered no longer valid and can be disposed of.

Return
True if still playing, false otherwise.
Parameters
  • soundReference: Sound reference

static void RB.SoundVolumeSet(SoundReference soundReference, float volume)

Set the volume of the currently playing sound by using its SoundReference

Parameters
  • soundReference: Sound reference
  • volume: New volume to play at where 0 is silent, 1 is the original clip volume and values beyond 1 indicate amplification beyond the recorded volume

static void RB.SoundPitchSet(SoundReference soundReference, float pitch)

Set the pitch of the currently playing sound by using its SoundReference

Parameters
  • soundReference: Sound reference
  • pitch: New pitch to play at, where 1 is the original sound pitch, values less than 1 indicate lower pitch, and values greater than 1 indicate higher pitch

static float RB.SoundVolumeGet(SoundReference soundReference)

Get the volume of the currently playing sound by using its SoundReference

Return
Volume
Parameters
  • soundReference: Sound reference

static float RB.SoundPitchGet(SoundReference soundReference)

Get the pitch of the currently playing sound by using its SoundReference

Return
Pitch
Parameters
  • soundReference: Sound reference

static void RB.SoundStop(SoundReference soundReference)

Stop the sound currently playing by using its SoundReference. Once the sound is stopped it can no longer be resumed and the specified RB.SoundReference is no longer valid.

Parameters
  • soundReference: Sound reference

static void RB.SoundLoopSet(SoundReference soundReference, bool loop)

Specify whether the currently playing sound specified by SoundReference should keep looping.

Parameters
  • soundReference: Sound reference
  • loop: True if sound should loop

static void RB.MusicSetup(int slotIndex, string fileName)

Setup music at the given music slot index.

Parameters
  • slotIndex: Music slot index
  • fileName: Filename of the music file, must be within a Resources folder

static void RB.MusicDelete(int slotIndex)

Remove music clip from the given slot index, freeing up resources.

Parameters
  • slotIndex: Music slot index

static void RB.MusicPlay(int slotIndex)

Play music stored at the given slot index. If there already is music playing then it is cross-faded to the newly specified music.

Parameters
  • slotIndex: Music slot index

static void RB.MusicStop()

Stop currently playing music.

static void RB.MusicVolumeSet(float volume = 1.0f)

Set the volume of music.

Parameters
  • volume: New volume to play at where 0 is silent, 1 is the original music volume and values beyond 1 indicate amplification beyond the recorded volume

static void RB.MusicPitchSet(float pitch = 1.0f)

Set the pitch of music.

Parameters
  • pitch: New pitch to play at, where 1 is the original music pitch, values less than 1 indicate lower pitch, and values greater than 1 indicate higher pitch

static float RB.MusicVolumeGet()

Get the current music volume.

Return
Volume

static float RB.MusicPitchGet()

Get the current music pitch.

Return
Pitch

static void RB.EffectSet(Effect type, float intensity, Vector2i parameters, Color32 color)

Set values for the given post processing effect. Setting intensity to 0 turns off the effect entirely.

Parameters
  • type: Effect type
  • intensity: Intensity
  • parameters: Additional parameters
  • color: Color

static void RB.EffectSet(Effect type, float intensity)

Set intensity for the given post processing effect. Setting intensity to 0 turns off the effect entirely.

Parameters
  • type: Effect type
  • intensity: Intensity

static void RB.EffectSet(Effect type, Vector2i parameters)

Set parameters for the given post processing effect. The effect is not yet active if its intensity is 0.

Parameters
  • type: Effect type
  • parameters: Additional parameters

static void RB.EffectSet(Effect type, Color32 color)

Set color for the given post processing effect. The effect is not yet active if its intensity is 0.

Parameters
  • type: Effect type
  • color: Color

static void RB.EffectShader(int shaderIndex)

Set a custom post-processing effect shader. Note that some RetroBlit built-in shaders may not work if a custom shader is specified. For loading shaders see ShaderSetup

Parameters
  • shaderIndex: Shader index

static void RB.EffectFilter(Filter filter)

Specify texture filtering to use with custom post-processing effect shader, see EffectShader. Default filter is RB.Filter.Nearest.

Parameters

static void RB.EffectReset()

Reset all post-processing effect back to default/off state.

static void RB.EffectApplyNow()

Apply post-processing effects at this point. This is useful if you don’t want to apply effects to all layers, for example you may want your GUI to not be affected by post processing effects. After EffectApplyNow you will likely want to change your effects, or call EffectReset. EffectApplyNow is called automatically at the end of IRetroBlitGame.Render.

static void RB.ShaderSetup(int shaderIndex, string filename)

Load a shader into the given shader slot, from the given filename.

Parameters
  • shaderIndex: Shader index
  • filename: Shader filename, must be within a Resources folder

static void RB.ShaderSet(int shaderIndex)

Set the current shader

Parameters
  • shaderIndex: Shader index

static void RB.ShaderApplyNow()

Apply shader now, this causes an implicit flush of the rendering pipeline. You may want to call ShaderApplyNow if you want the current shader parameters to apply to earlier Draw calls before you make further changes to the shader parameters.

static void RB.ShaderReset()

Reset the shader back to the default RetroBlit shader.

static int RB.ShaderPropertyID(string name)

Get a unique ID of a shader property as specified in a shader file. It is more efficient to pass around a shader ID then its string name.

Return
Unique ID
Parameters
  • name: Name of the property

static void RB.ShaderColorSet(int shaderIndex, string name, Color32 color)

Set a shader color property

Parameters
  • shaderIndex: Shader index
  • name: Property name
  • color: Color

static void RB.ShaderColorSet(int shaderIndex, int propertyID, Color32 color)

Set a shader color property

Parameters
  • shaderIndex: Shader index
  • propertyID: Property ID
  • color: Color

static void RB.ShaderColorArraySet(int shaderIndex, string name, List< Color32 > colorArray)

Set a shader color array

Parameters
  • shaderIndex: Shader index
  • name: Property name
  • colorArray: Color list

static void RB.ShaderColorArraySet(int shaderIndex, int propertyID, List< Color32 > colorArray)

Set a shader color array

Parameters
  • shaderIndex: Shader index
  • propertyID: Property ID
  • colorArray: Color list

static void RB.ShaderColorArraySet(int shaderIndex, string name, Color32 [] colorArray)

Set a shader color array

Parameters
  • shaderIndex: Shader index
  • name: Property name
  • colorArray: Color array

static void RB.ShaderColorArraySet(int shaderIndex, int propertyID, Color32 [] colorArray)

Set a shader color array

Parameters
  • shaderIndex: Shader index
  • propertyID: Property ID
  • colorArray: Color array

static void RB.ShaderFloatSet(int shaderIndex, string name, float value)

Set a shader float property

Parameters
  • shaderIndex: Shader index
  • name: Property name
  • value: Float value

static void RB.ShaderFloatSet(int shaderIndex, int propertyID, float value)

Set a shader float property

Parameters
  • shaderIndex: Shader index
  • propertyID: Property ID
  • value: Float value

static void RB.ShaderFloatArraySet(int shaderIndex, string name, float [] values)

Set a shader float array

Parameters
  • shaderIndex: Shader index
  • name: Property name
  • values: Float array

static void RB.ShaderFloatArraySet(int shaderIndex, int propertyID, float [] values)

Set a shader float array

Parameters
  • shaderIndex: Shader index
  • propertyID: Property ID
  • values: Float array

static void RB.ShaderFloatArraySet(int shaderIndex, string name, List< float > values)

Set a shader float array

Parameters
  • shaderIndex: Shader index
  • name: Property name
  • values: Float list

static void RB.ShaderFloatArraySet(int shaderIndex, int propertyID, List< float > values)

Set a shader float array

Parameters
  • shaderIndex: Shader index
  • propertyID: Property name
  • values: Float list

static void RB.ShaderIntSet(int shaderIndex, string name, int value)

Set a shader integer property

Parameters
  • shaderIndex: Shader index
  • name: Property name
  • value: Integer value

static void RB.ShaderIntSet(int shaderIndex, int propertyID, int value)

Set a shader integer property

Parameters
  • shaderIndex: Shader index
  • propertyID: Property ID
  • value: Integer value

static void RB.ShaderMatrixSet(int shaderIndex, string name, Matrix4x4 matrix)

Set a shader matrix

Parameters
  • shaderIndex: Shader index
  • name: Property name
  • matrix: Matrix

static void RB.ShaderMatrixSet(int shaderIndex, int propertyID, Matrix4x4 matrix)

Set a shader matrix

Parameters
  • shaderIndex: Shader index
  • propertyID: Property ID
  • matrix: Matrix

static void RB.ShaderMatrixArraySet(int shaderIndex, string name, Matrix4x4 [] matrices)

Set a shader matrix array

Parameters
  • shaderIndex: Shader index
  • name: Property name
  • matrices: Matrix array

static void RB.ShaderMatrixArraySet(int shaderIndex, int propertyID, Matrix4x4 [] matrices)

Set a shader matrix array

Parameters
  • shaderIndex: Shader index
  • propertyID: Property ID
  • matrices: Matrix array

static void RB.ShaderMatrixArraySet(int shaderIndex, string name, List< Matrix4x4 > matrices)

Set a shader matrix array

Parameters
  • shaderIndex: Shader index
  • name: Property name
  • matrices: Matrix list

static void RB.ShaderMatrixArraySet(int shaderIndex, int propertyID, List< Matrix4x4 > matrices)

Set a shader matrix array

Parameters
  • shaderIndex: Shader index
  • propertyID: Property ID
  • matrices: Matrix list

static void RB.ShaderVectorSet(int shaderIndex, string name, Vector4 vector)

Set a shader vector property

Parameters
  • shaderIndex: Shader index
  • name: Property name
  • vector: Vector

static void RB.ShaderVectorSet(int shaderIndex, int propertyID, Vector4 vector)

Set a shader vector property

Parameters
  • shaderIndex: Shader index
  • propertyID: Property ID
  • vector: Vector

static void RB.ShaderVectorArraySet(int shaderIndex, string name, Vector4 [] vectors)

Set a shader vector array

Parameters
  • shaderIndex: Shader index
  • name: Property name
  • vectors: Vector array

static void RB.ShaderVectorArraySet(int shaderIndex, int propertyID, Vector4 [] vectors)

Set a shader vector array

Parameters
  • shaderIndex: Shader index
  • propertyID: Property ID
  • vectors: Vector array

static void RB.ShaderVectorArraySet(int shaderIndex, string name, List< Vector4 > vectors)

Set a shader vector array

Parameters
  • shaderIndex: Shader index
  • name: Property name
  • vectors: Vector list

static void RB.ShaderVectorArraySet(int shaderIndex, int propertyID, List< Vector4 > vectors)

Set a shader vector array

Parameters
  • shaderIndex: Shader index
  • propertyID: Property ID
  • vectors: Vector list

static void RB.ShaderSpriteSheetTextureSet(int shaderIndex, string name, int spriteSheetIndex)

Set a shader spritesheet texture

Parameters
  • shaderIndex: Shader index
  • name: Property name
  • spriteSheetIndex: Spritesheet index

static void RB.ShaderSpriteSheetTextureSet(int shaderIndex, int propertyID, int spriteSheetIndex)

Set a shader offscreen texture

Parameters
  • shaderIndex: Shader index
  • propertyID: Property ID
  • spriteSheetIndex: Spritesheet index

static void RB.ShaderSpriteSheetFilterSet(int shaderIndex, int spriteSheetIndex, Filter filter)

Set an spritesheet texture filter to be used by the shader. The default filter is Filter.Nearest.

Parameters

class HardwareSettings

Defines hardware settings for the RetroBlit game. A RetroBlit Game fills out this structure in response to the call to IRetroBlitGame.QueryHardware.

Public Members

Vector2i RB.HardwareSettings.DisplaySize = new Vector2i(480, 270)

Display size, dimensions must be divisible by 2

Vector2i RB.HardwareSettings.MapSize = new Vector2i(256, 256)

Maximum tilemap size, in tiles. This number should be kept close to the maximum size required by your game, in order to conserve memory.

int RB.HardwareSettings.MapLayers = 8

Maximum amount of tilemap layers. This number should be kept close to the maximum layer count required by your game, in order to conserve memory.

Vector2i RB.HardwareSettings.MapChunkSize = new Vector2i(16, 16)

The internal size of a single map chunk. For majority of projects this value can be left at the default 16 x 16, however a custom size might be desired if chunks of different sizes are being paged in manually for infinite maps or other purposes. Chunk size is a balance between fast drawing (large chunk size) or fast individual tile changes (small chunk size).

int RB.HardwareSettings.FPS = 60

Target frames per second. Defaults to 60.

PixelStyle RB.HardwareSettings.PixelStyle = PixelStyle.Square

Display pixel style

interface IRetroBlitGame

Defines IRetroBlitGame interface. Every RetroBlit game must implement this interface.

Public Functions

HardwareSettings RB.IRetroBlitGame.QueryHardware()

Called once on startup to query the game for its hardware capabilities. This call happens before any other call to this interface.

Return
Hardware capabilities

bool RB.IRetroBlitGame.Initialize()

Called once after QueryHardware. The game should initialize it’s state here.

Return
Return true if initialization was successful, false otherwise

void RB.IRetroBlitGame.Update()

Called at a fixed interval set in IRetroBlitGame.QueryHardware (60 fps by default). Game logic goes in here.

void RB.IRetroBlitGame.Render()

Called to render to display, all draw APIs should be called here. Unlike IRetroBlitGame.Update this method is not called at a fixed framerate.

struct SoundReference

A reference to currently playing sound. This structure is returned by RB.SoundPlay and can be used with RB.SoundStop, RB.SoundVolumeSet, RB.SoundVolumeGet, RB.SoundPitchSet and RB.SoundPitchGet to manage the sound as it plays.

Public Functions

RB.SoundReference.SoundReference(int channel, long seq)

Sound reference constructor. Used internally by RetroBlit.

Parameters
  • channel: Sound channel
  • seq: Sound sequence

Public Members

int RB.SoundReference.SoundChannel

Sound channel. Do not modify.

long RB.SoundReference.Sequence

Sound sequence. Do not modify