Operators functions
Free functions you can call directly in sprite code.
arrayIncludes
Section titled “arrayIncludes”arrayIncludes(array: any[], value: any): booleanCheck whether an array contains a value.
Delegates to Sprite.arrayIncludes
compare
Section titled “compare”compare(v1: any, v2: any): numberCompare two values, Scratch-style.
Delegates to Sprite.compare
degToRad
Section titled “degToRad”degToRad(deg: number): numberConvert degrees to radians.
Delegates to Sprite.degToRad
degToScratch
Section titled “degToScratch”degToScratch(deg: number): numberConvert degrees to a Scratch direction.
Delegates to Sprite.degToScratch
indexInArray
Section titled “indexInArray”indexInArray(array: any[], value: any): numberGet the 1-based index of a value in an array.
Delegates to Sprite.indexInArray
itemOf
Section titled “itemOf”itemOf(array: any[], index: number): anyGet the item of an array at a 1-based index.
Delegates to Sprite.itemOf
letterOf
Section titled “letterOf”letterOf(string: string, index: number): stringGet the letter of a string at a 1-based index.
Delegates to Sprite.letterOf
normalizeDeg
Section titled “normalizeDeg”normalizeDeg(deg: number): numberNormalize a degree value into the range (-180, 180].
Delegates to Sprite.normalizeDeg
radToDeg
Section titled “radToDeg”radToDeg(rad: number): numberConvert radians to degrees.
Delegates to Sprite.radToDeg
radToScratch
Section titled “radToScratch”radToScratch(rad: number): numberConvert radians to a Scratch direction.
Delegates to Sprite.radToScratch
random
Section titled “random”random(a: number, b: number): numberPick a random number between two values.
Delegates to Sprite.random
scratchTan
Section titled “scratchTan”scratchTan(angle: number): numberCompute the tangent of a Scratch angle.
Delegates to Sprite.scratchTan
scratchToDeg
Section titled “scratchToDeg”scratchToDeg(scratchDir: number): numberConvert a Scratch direction to degrees.
Delegates to Sprite.scratchToDeg
scratchToRad
Section titled “scratchToRad”scratchToRad(scratchDir: number): numberConvert a Scratch direction to radians.
Delegates to Sprite.scratchToRad
stringIncludes
Section titled “stringIncludes”stringIncludes(string: string, substring: string): booleanCheck whether a string contains a substring.
Delegates to Sprite.stringIncludes
toBoolean
Section titled “toBoolean”toBoolean(value: any): booleanCoerce a value to a boolean, Scratch-style.
Delegates to Sprite.toBoolean
toNumber
Section titled “toNumber”toNumber(value: any): numberCoerce a value to a number, Scratch-style.
Delegates to Sprite.toNumber
toStr(value: any): stringCoerce a value to a string, Scratch-style.
Delegates to Sprite.toString
wrapClamp
Section titled “wrapClamp”wrapClamp(n: number, min: number, max: number): numberWrap a number into a range.
Delegates to Sprite.wrapClamp