Releases: openpatch/scratch-for-java
v2.0.0
The Processing library Scratch changed owners. It is now hosted under the OpenPatch organization, therefore the package name change. You can now access the classes of this library like so:
import org.openpatch.scratch.*
v1.15.0
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);
}
}
}
v1.14.2
- Remove System.out.print statements
v1.14.1
- improve ScratchText rendering
v1.14.0
- add think and say to ScratchSprite
- add display to ScratchStage
- add whenClicked to Sprite
- add whenBackdropSwitches to Sprite
v1.13.1
- Optimize image loading
v1.13.0
- add stage.removeSprites
- add stage.findSprites
- use CopyOnWriteArrayList instead of ArrayList
v1.12.0
v1.11.0
Changelog
- add method
raiseSprite
to stage - add method
lowerSprite
to stage - add method
removeBackdrop
to stage - update docs
v1.10.0
Simplify the usage of sprites by remove the usage of super.
You can now simply add a sprite to the stage by stage.addSprite(sprite)
. This means that the draw method of the sprite will be implicit called. To change the behavior of the sprite override the run
-method.
Before (and still possible):
MySprite mySprite;
void setup() {
ScratchStage.init(this);
mySprite = new MySprite();
}
void draw() {
mySprite.draw();
}
class MySprite extends ScratchSprite {
void draw() {
super.draw();
this.move();
}
}
After:
ScratchStage stage;
void setup() {
ScratchStage.init(this);
stage = ScratchStage.getInstance()
stage.addSprite(new MySprite());
}
void draw() {}
class MySprite extends ScratchSprite {
void run() {
this.move();
}
}
Changelog
- Add method run to ScratchSprite
- Add method whenKeyPressed to ScratchSprite
- Add method whenMouseMoved to ScratchSprite
- Add method addSprite to ScratchStage
- Add methode removeSprite to ScratchStage