Home Getting Started Examples Documentation

Getting Started

This documentation currently only covers using Scratch-JS on Mac and Linux (with python installed):

 

Getting started with Scratch-JS is very simple. Just download the index.html, and open a terminal. Then, type the following:

 

ADD STUFF HERE

Sprite Creation

    In Scratch-JS there are two types of sprites. But for the sake of simplicity only one type of sprite is covered in this section. Please refer to the advanced section of the documentation for more information about creating HTML tag sprites.

 

Here we will be explaining how to use image sprites, which are powerful enough for most beginners. As its name implies, image sprites use an image as the sprite. The image for the sprite can be any image file type including png, jpg and even gif, which allows for animating the sprites.

 

The basic syntax for a sprite is simple:

 

whenPageLoads {

var mySpriteName = new Sprite(x,y,”myImageFileName.jpg”);

}

 

To create a sprite all you have to do is replace the values that are highlighted in yellow.

 

Let’s breakdown what the values should be in the order they appear:

 

 

And that’s it you now created your own sprite. Here is an example of what you code should look like:

 

whenPageLoads = function(){

var myDog = new Sprite(20,90,”doggy.png”);

}

 

This will create a sprite using the picture of the dog that I provided and add it 20 pixels to the left and 90 pixels to the right from the center of the screen.

 

For those of you wondering what the “whenPageLoads” does. It is essentially the equivalent of the “when green flag is pressed” block in Scratch.

 

Note

The rest of this document will use the sprite name mySpriteName in all examples.

 

Scratch-JS “blocks”

Below are all of the Scratch blocks that have been implemented into Scratch-JS

  • Wait
  • Forever
  • Stop
  • Say
  • Ask