Skip to content

v1.15.0

Compare
Choose a tag to compare
@mikebarkmin mikebarkmin released this 25 Nov 07:49
bb6f470

The Standalone Release

This release does not change the behaviour of the Processing library!

You can now use the scratch-standalone.jar for using this library in any Java environment. When you use this library outside of processing, you have to create a new object of the class ScratchStage. The init-method will only work in Processing.

import eu.barkmin.processing.scratch.*;

public class MyProgram
{
    public MyProgram() {
        ScratchStage s = new ScratchStage(800, 400);
        s.addSprite(new Cat());   
    }
}

class Cat extends ScratchSprite
{
  public Cat() {
    this.addCostume("sitzen", "sprites/cat.png");
    this.setOnEdgeBounce(true);
  }
  
  public void run() {
      this.move(1);
  }
}

You can also use this library outside of Processing in a more imperative way, similar to Shapes and Sprites. For this to work, the wait-method was added to the ScratchStage class.

import eu.barkmin.processing.scratch.*;

public class MyProgram
{
    public MyProgram() {
        ScratchStage s = new ScratchStage(400, 400);
        ScratchSprite cat = new ScratchSprite(
            "sitzen", "sprites/cat.png"
        );
        s.addSprite(cat);
        
        cat.setOnEdgeBounce(true);
        
        while(!s.isKeyPressed(27)) {
            cat.move(1);
            s.wait(100);
        }
    }
}