Skip to content
Stephen P edited this page Apr 30, 2020 · 1 revision

Holds a string for drawing. To update the string held and have the texture update, you must run updateCText(cText*, char*).

Members

str

char* str
The string stored internally. If this is modified without using updateCText(cText*, char*), this will necessarily not correspond to the text on-string.

texture

SDL_Texture*
The SDL texture used for rendering.

rect

cDoubleRect
The rectangle that stores where the text will be drawn and how wide and tall it is on the window.

renderLayer

int
Defines which layer the text is rendered on. 0 -> Not rendered. 1 -> rendered last, 2 -> rendered after 1, etc. until the last layer renderLayers -> rendered first. renderLayers is defined when running initCoSprite(), and defaults to 5.

textColor

SDL_Color
The color used for the letters and other characters.

bgColor

SDL_Color
The color drawn behind the text within the borders of rect.

scale

double
The multiplicative scaling factor for drawing the text. To resize the sprite by a certain factor, you must just modify this variable.

flip

SDL_RendererFlip
The SDL flipping flag. SDL_FLIP_HORIZONTAL for mirroring across the y-axis, SDL_FLIP_VERTICAL for mirroring across the x-axis, and SDL_FLIP_NONE for no mirroring.

degrees

double
The rotation value of the text, in degrees clockwise from the +x axis.

fixed

bool
If true, the sprite won't be affected by the camera. It's useful in creating a HUD, or letting something important stick to the screen without camera rotation, panning, zoom, or scaling coming into play.

Functions

initCText

void initCText(cText* text, char* str, cDoubleRect rect, SDL_Color textColor, SDL_Color bgColor, double scale, SDL_RendererFlip flip, double degrees, bool fixed, int drawPriority)
Initializes a cText with the string to use, the rectangle within to draw, the text and background colors, the scaling, flipping, and rotation values, fixed flag, and draw priority.

updateCText

void updateCText(cText* text, char* str)
After initializing a cText, update the string drawn to the screen with this function.

destroyCText

void destroyCText(cText* text)
Destroys a given cText, de-allocating all the memory associated with it. This must be done individually if the sprite is not both in a cScene and de-allocated by destroying that cScene.

drawCText

void drawCText(cText text, cCamera camera, bool update)
Draws a cText to the screen given a certain camera. Pass true to update if you want the changes to be shown, or in other words, if you want the SDL_Renderer to be presented.

Clone this wiki locally