Motion

JS4Scratch Reference Manual:

Move Steps

Syntax:

move(10)

Example:

spriteA.whenFlag(function () {
    spriteA.show()
    while(true){                                                   
        this.move(10)
        this.wait(1)
    }       
})

Turn

Turn Left

Syntax:

turnLeft(15)

Example:

spriteA.whenFlag(function () {
    spriteA.show()
    while(true){                                                   
        this.turnLeft(15)
        this.wait(1)
    }       
})

Turn Right

Syntax:

turnRight(15)

Example:

spriteA.whenFlag(function () {
    spriteA.show()
    while(true){                                                   
        this.turnRight(15)
        this.wait(1)
    }       
})

GoTo

GoTo XY

Syntax:

goTo(55,-35)

Example:

spriteA.whenFlag(function () {
    spriteA.show()
    while(true){                                                   
        this.goTo(55,-35)
        this.wait(0.5)
        this.goTo(0,0)
        this.wait(0.5) 
    }       
})

GoTo Random Position

Syntax:

goTo(randomRange(-240, 240),randomRange(-180, 180))

Example:

spriteA.whenFlag(function () {                    
    spriteA.show()
    while (true) {
        spriteA.goTo(randomRange(-240, 240),randomRange(-180, 180))
        this.wait(0.5)
    }
})

GoTo Mouse-Pointer

Syntax:

goTo(stage.mouseX,stage.mouseY)

Example:

spriteA.whenFlag(function () {
    spriteA.show()
    while(true){                                                   
      this.goTo(stage.mouseX,stage.mouseY)
      this.say('mouseX: '+ stage.mouseX + '  mouseY: ' + stage.mouseY)

    }       
})

GoTo Sprite

Syntax:

goTowards(sprite)

Example:

spriteA.whenFlag(function () {
   spriteA.show()
   this.goTo(-150,-150)
   spriteB.show()   
   this.wait(2)                                              
   this.goTowards(spriteB)      
})

Glide

Glide To XY

Syntax:

glide(1, 55, -35)

Example:

spriteA.whenFlag(function () {
    spriteA.show()   
    while(true){                                                   
     this.glide(1, 55, -35)
     this.glide(1, 0, 0)
    }       
})

Glide To Random Position

Syntax:

glide(1, randomRange(-240,240), randomRange(-180,180))

Example:

spriteA.whenFlag(function () {
    spriteA.show()
    while(true){
     this.glide(1, randomRange(-240,240), randomRange(-180,180))
  }
})

Glide To Mouse-Pointer

Syntax:

glide(stage.mouseX,stage.mouseY)

Example:

spriteA.whenFlag(function () {
    spriteA.show()
    while(true){
     this.glide(1, stage.mouseX,stage.mouseY)
  }
})

Point

Point in Direction

Syntax:

pointInDirection(90)

Example:

spriteA.whenFlag(function () {
    spriteA.show()
    this.pointInDirection(0)
    this.wait(1)
    this.pointInDirection(90)
})

Point Towards Mouse-Pointer

There is no "point towards mouse-pointer" equivalent. However, you could command a sprite with "goTo"(eg a cross-hair) to move to the mouse-pointer and then point towards that sprite as shown below.

Point Towards Sprite

Syntax:

pointTowards(Sprite1)

Example:

spriteD.whenFlag(function(){
  this.show()
  this.setSize(20)
  while (true){
	this.goTo(stage.mouseX, stage.mouseY)
	}
})

spriteA.whenFlag(function () {
spriteA.show()
  while (true) {
    	this.pointTowards(spriteD)
	}
})

Change X & Y

Syntax:

changeX(10)
changeY(10)

Example:

spriteA.whenFlag(function () {
    spriteA.show()
    this.wait(0.5)
    this.changeX(50)
    this.wait(0.5)
    this.changeY(50)
})

Set X & Y

Syntax:

setX(55)
setY(-35)

Example:

spriteA.whenFlag(function () {
    spriteA.show()
    this.setX(0)
    this.setY(0)
    this.wait(0.5)
    this.setX(55)
    this.wait(0.5)
    this.setY(-35)
})

If on Edge Bounce

Syntax:

ifOnEdgeBounce()

Example:

spriteD.whenFlag(function () {
    spriteD.show()
    while (true){
    this.move(10)
    this.ifOnEdgeBounce()
    }
})

Set Rotation Style

Syntax:

setRotationStyle('left-right')
// 'left-right','all','no'

Example:

spriteA.whenFlag(function () {
    while (true){
        this.setRotationStyle('no')
        this.say('rotation: no')
        this.wait(5)
        this.setRotationStyle('left-right')
        this.say('rotation: left-right')
        this.wait(5)
        this.setRotationStyle('all')
        this.say('rotation: all')
        this.wait(5)
    }
})
spriteA.whenFlag(function () {
    this.show()
    while (true){
        this.move(10)
        this.ifOnEdgeBounce()
    }
})