Document stub.png This article or section may not have content matching Scratch Wiki editing standards. Please improve it according to Scratch Wiki:Guidelines and Scratch Wiki:Editing Conventions. (Feb 2021)
Reason: unfinished
Document.png Please expand this article or section. You can help by adding more information if you are an editor. More information might be found in a section of the talk page. (Feb 2021)

It is possible to find how many costume numbers a sprite has in Scratch. This is a tutorial on how to find how much costumes a sprite has.

This can be used to debug sprites.

Setup

One method is to use the following script:

when gf clicked
switch costume to ((0) * (1)) // If you use the join block with 0 and nothing, if a costume is called "0" it will not work.
set [# of costumes v] to (costume [number v]) // it is a local variable
switch costume to (costume1 v) // Start costume.

Then, run your project and the variable should report how many costumes a sprite has.

This method works because the switch costume to ( v) block uses the formula:

(((input) - (1)) - (([floor v] of (((input) - (1)) / (# costumes))) * (# costumes))) + (1)

[1][2][3][4]

to determine which Costume Number to select, which—with 0 as the input—evaluates to:

(((0) - (1)) - (([floor v] of (((0) - (1)) / (# costumes))) * (# costumes))) + (1)
((-1) - (([floor v] of ((-1) / (# costumes))) * (# costumes))) + (1)
((-1) - ((-1) * (# costumes))) + (1)
((-1) + (# costumes)) + (1)
(# costumes)

References

Cookies help us deliver our services. By using our services, you agree to our use of cookies.