Skip to content

Commit a8b5578

Browse files
committed
update multiple approach
1 parent 9ce77cd commit a8b5578

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

docs/de/book/multiple-approach-design.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,18 @@ Der Nachteil ist, dass das Verhalten der Sprite-Objekte in einer globalen Klasse
1818
Das heißt, dass mit diesem Ansatz die Einfachheit im Umgang mit Java gegen Kompatibilität mit dem Scratch-Modell getauscht wird.
1919

2020
```java
21+
import org.openpatch.scratch.*;
22+
2123
public class MyProgram {
2224
public MyProgram() {
2325
Stage myStage = new Stage();
2426
Sprite zebra = new Sprite();
2527
zebra.addCostume("walk_1", "assets/walk_1.png");
2628
zebra.setOnEdgeBounce(true);
2729

28-
while(true) {
29-
zebra.move(1);
30-
}
30+
zebra.setRun(s -> {
31+
s.move(1);
32+
})
3133
}
3234
}
3335
```
@@ -45,6 +47,8 @@ Hier sind ein paar Vergleiche, die man verwenden könnte:
4547
- In Scratch haben wir Nachrichten zu und von Figure geschickt, indem wir einen Block benutzt haben. In Java definieren wir eigene Methoden und rufen diese dann auf.
4648

4749
```java
50+
import org.openpatch.scratch.*;
51+
4852
class Zebra extends Sprite {
4953
public Zebra() {
5054
this.addCostume("walk_1", "assets/walk_1.png");
@@ -72,6 +76,8 @@ Der erweiterte Scratch Ansatz basiert auf dem objektorientierten Ansatz, aber f
7276
Zum Beispiel gibt es in Scratch for Java die Window-Klasse. Welches nur einmalig instanziiert werden kann. Dieses Objekt kann mehrere Bühnen enthalten und zwischen ihnen wechseln. Du kannst auch die Größe des Fensters verändern.
7377

7478
```java
79+
import org.openpatch.scratch.*;
80+
7581
public class MyProject extends Window {
7682
public MyProject() {
7783
super(800, 600);
@@ -88,6 +94,8 @@ public class MyProject extends Window {
8894
Eine andere Erweiterung ist die Klasse AnimatedSprite, welches es sehr einfach macht Animation zu verwenden. Die Klasse kann sehr früh verwendet werden, denn sie beseitig den Nachteil, dass Skripte nicht pausiert werden können.
8995

9096
```java
97+
import org.openpatch.scratch.extensions.animation.*;
98+
9199
public Zebra extends AnimatedSprite {
92100
public Zebra() {
93101
this.addAnimation("walk", "walk_%d.png", 4);

docs/en/book/multiple-approach-design.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,18 @@ The downside to this approach is that you define the behavior of the Sprites ins
1717
So by using this approach you are trading simplicity with compatibility to the Scratch model.
1818

1919
```java
20+
import org.openpatch.scratch.*;
21+
2022
public class MyProgram {
2123
public MyProgram() {
2224
Stage myStage = new Stage();
2325
Sprite zebra = new Sprite();
2426
zebra.addCostume("walk_1", "assets/walk_1.png");
2527
zebra.setOnEdgeBounce(true);
2628

27-
while(true) {
28-
zebra.move(1);
29-
}
29+
zebra.setRun(s -> {
30+
s.move(1);
31+
})
3032
}
3133
}
3234
```
@@ -44,6 +46,8 @@ Here are a few comparisons you could draw:
4446
- In Scratch we send messages to and from sprites by using a block. In Java we call methods on an object `mySprite.goLeft()`. A method is similar to a custom block.
4547

4648
```java
49+
import org.openpatch.scratch.*;
50+
4751
class Zebra extends Sprite {
4852
public Zebra() {
4953
this.addCostume("walk_1", "assets/walk_1.png");
@@ -71,6 +75,8 @@ The enhanced Scratch approach is based on the object-oriented approach, but intr
7175
For example in Scratch for Java you can create an object from the Window-class. This object can hold multiple stages and can switch between those. You can also define the size of the window - by default it uses the same size as a Scratch project.
7276

7377
```java
78+
import org.openpatch.scratch.*;
79+
7480
public class MyProject extends Window {
7581
public MyProject() {
7682
super(800, 600);
@@ -87,6 +93,8 @@ public class MyProject extends Window {
8793
Another enhancement is the class AnimatedSprite, which makes it easy to use an animated for Sprites. This class should be used early since it overcomes the downside of not having a per-sprite wait-block by abstracting the timing.
8894

8995
```java
96+
import org.openpatch.scratch.extensions.animation.*;
97+
9098
public Zebra extends AnimatedSprite {
9199
public Zebra() {
92100
this.addAnimation("walk", "walk_%d.png", 4);

0 commit comments

Comments
 (0)