Skip to content

Operators functions

Free functions you can call directly in sprite code.

arrayIncludes(array: any[], value: any): boolean

Check whether an array contains a value.

Delegates to Sprite.arrayIncludes

compare(v1: any, v2: any): number

Compare two values, Scratch-style.

Delegates to Sprite.compare

degToRad(deg: number): number

Convert degrees to radians.

Delegates to Sprite.degToRad

degToScratch(deg: number): number

Convert degrees to a Scratch direction.

Delegates to Sprite.degToScratch

indexInArray(array: any[], value: any): number

Get the 1-based index of a value in an array.

Delegates to Sprite.indexInArray

itemOf(array: any[], index: number): any

Get the item of an array at a 1-based index.

Delegates to Sprite.itemOf

letterOf(string: string, index: number): string

Get the letter of a string at a 1-based index.

Delegates to Sprite.letterOf

normalizeDeg(deg: number): number

Normalize a degree value into the range (-180, 180].

Delegates to Sprite.normalizeDeg

radToDeg(rad: number): number

Convert radians to degrees.

Delegates to Sprite.radToDeg

radToScratch(rad: number): number

Convert radians to a Scratch direction.

Delegates to Sprite.radToScratch

random(a: number, b: number): number

Pick a random number between two values.

Delegates to Sprite.random

scratchTan(angle: number): number

Compute the tangent of a Scratch angle.

Delegates to Sprite.scratchTan

scratchToDeg(scratchDir: number): number

Convert a Scratch direction to degrees.

Delegates to Sprite.scratchToDeg

scratchToRad(scratchDir: number): number

Convert a Scratch direction to radians.

Delegates to Sprite.scratchToRad

stringIncludes(string: string, substring: string): boolean

Check whether a string contains a substring.

Delegates to Sprite.stringIncludes

toBoolean(value: any): boolean

Coerce a value to a boolean, Scratch-style.

Delegates to Sprite.toBoolean

toNumber(value: any): number

Coerce a value to a number, Scratch-style.

Delegates to Sprite.toNumber

toStr(value: any): string

Coerce a value to a string, Scratch-style.

Delegates to Sprite.toString

wrapClamp(n: number, min: number, max: number): number

Wrap a number into a range.

Delegates to Sprite.wrapClamp