Differences to Scratch
Probably the most noticeable differences to Scratch are the following:
- There is not wait-block on a Sprite-level, you need to use Timers.
If you want to achieve something like this inside a Sprite:
when green flag clicked forever next costume wait (1) seconds
You can use a timer.
public class Cat extends Sprite {
// executes 60-times a second, if the sprite is added to a stage.
public void run() {
if (this.getTimer().everyMillis(1000)) {
this.nextCostume();
}
}
}
-
There is a sprite and sound library, like in Scratch: 838 pictures and 266
sounds ship with Scratch for Java, and you use them by name with
addCostume("bunny1_stand"). Browse them on the Sprites and Sounds pages. What Scratch has and this does not is a choose from a categorised catalogue with previews inside the editor - here it is a documentation page you search. - There are no built-in editors, so for drawing or recording your own files you need external tools like GIMP, Inkscape, Audacity and so on.
- If you want to share your project with others, you have to used external sharing platforms like Nextcloud, iCloud, Dropbox or better a code sharing platform like GitHub.
- You can not use a forever loop. This will halt you program.
If you want to achieve something like this inside a Sprite:
when green flag clicked forever move (10) steps
You can use the run-method of the Sprite-class.
public class Cat extends Sprite {
// executes 60-times a second, if the sprite is added to a stage.
public void run() {
this.move(10);
}
}
- If you want to have a variable for all sprites, you have to use a static attribute. Static attributes are available across all objects.
public class Cat extends Sprite {
public static int hitCounter = 1;
}
public class MyProgram {
public MyProgram() {
Cat.hitCounter += 1;
}
}