JS4Scratch Reference Manual:
Say For Seconds
Syntax:
sprite.sayWait('text',sec)Example:
//Example: Say 'Hello' for 2 seconds then 'bye' for 2 seconds
spriteA.whenFlag(function(){
this.show()
this.sayWait('Hello',2)
this.sayWait('Bye',2)
})Say
Syntax:
sprite.say('text')Example:
//Example: Say 'Hello'
spriteA.whenFlag(function(){
this.show()
this.say('Hello')
})Think For Seconds
Syntax:
sprite.thinkWait('text',sec)Example:
//Example: think 'Hello' for 2s then 'bye' for 2s
spriteA.whenFlag(function () {
this.show()
this.thinkWait('Hello',2)
this.thinkWait('Bye',2)
})Think
Syntax:
sprite.think('text')Example:
spriteA.whenFlag(function () {
this.show()
this.think('Hello')
})Switch Costume
Syntax:
sprite.switchCostumeToNum(number)Example:
// Example: switchCostumeToNum(number)
spriteA.whenFlag(function () {
this.show()
this.switchCostumeToNum(0)
this.wait(1)
this.switchCostumeToNum(1)
this.wait(1)
this.switchCostumeToNum(2)
this.wait(1)
this.switchCostumeToNum(3)
})Next Costume
Syntax:
sprite.nextCostume()Example:
// Example: cycle between all the costumes
spriteA.whenFlag(function () {
this.show()
while(true){
this.nextCostume()
this.wait(0.25)
}
})Switch Backdrop
Syntax:
stage.switchBackdropTo(backdrop)Example:
stage.whenFlag(function () {
this.switchBackdropTo(backdropA)
this.wait(1)
this.switchBackdropTo(backdropB)
this.wait(1)
this.switchBackdropTo(backdropC)
this.wait(1)
this.switchBackdropTo(backdropD)
})Next Backdrop
Syntax:
stage.nextBackdrop()Example:
stage.whenFlag(function () {
while(true){
this.nextBackdrop()
this.wait(0.25)
}
})Change size
Syntax:
sprite.changeSize(percentage)Example:
spriteA.whenFlag(function () {
this.show()
this.wait(2)
this.changeSize(200)
this.wait(2)
this.changeSize(-200)
})Set Size
Syntax:
sprite.setSize(absolute size)Example:
spriteA.whenFlag(function () {
this.show()
this.wait(2)
this.setSize(200)
this.wait(2)
this.setSize(50)
})Show
Syntax:
sprite.show()Example:
spriteA.whenFlag(function () {
this.show()
this.wait(2)
this.hide()
spriteB.show()
this.wait(2)
spriteB.hide()
})Hide
Syntax:
sprite.hide()Example:
spriteA.whenFlag(function () {
this.show()
this.wait(2)
this.hide()
spriteB.show()
this.wait(2)
spriteB.hide()
})GoTo Front/Back Layer
Syntax:
sendSpriteToBack(sprite)
sendSpriteToFront(sprite)Example:
stage.whenFlag(function () {
spriteA.show()
spriteB.show()
spriteC.show()
spriteD.show()
this.wait(2)
this.sendSpriteToFront(spriteA)
this.wait(2)
this.sendSpriteToBack(spriteA)
})Go Forwards/Backwards a Layer
Syntax:
sendSpriteBackward(sprite)
sendSpriteForward(sprite)Example:
stage.whenFlag(function () {
spriteC.show()
spriteD.show()
this.wait(2)
this.sendSpriteForward(spriteC)
this.wait(2)
this.sendSpriteBackwards(spriteC)
})