You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/de/book/multiple-approach-design.md
+11-3Lines changed: 11 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,16 +18,18 @@ Der Nachteil ist, dass das Verhalten der Sprite-Objekte in einer globalen Klasse
18
18
Das heißt, dass mit diesem Ansatz die Einfachheit im Umgang mit Java gegen Kompatibilität mit dem Scratch-Modell getauscht wird.
19
19
20
20
```java
21
+
importorg.openpatch.scratch.*;
22
+
21
23
publicclassMyProgram {
22
24
publicMyProgram() {
23
25
Stage myStage =newStage();
24
26
Sprite zebra =newSprite();
25
27
zebra.addCostume("walk_1", "assets/walk_1.png");
26
28
zebra.setOnEdgeBounce(true);
27
29
28
-
while(true) {
29
-
zebra.move(1);
30
-
}
30
+
zebra.setRun(s -> {
31
+
s.move(1);
32
+
})
31
33
}
32
34
}
33
35
```
@@ -45,6 +47,8 @@ Hier sind ein paar Vergleiche, die man verwenden könnte:
45
47
- 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.
46
48
47
49
```java
50
+
importorg.openpatch.scratch.*;
51
+
48
52
classZebraextendsSprite {
49
53
publicZebra() {
50
54
this.addCostume("walk_1", "assets/walk_1.png");
@@ -72,6 +76,8 @@ Der erweiterte Scratch Ansatz basiert auf dem objektorientierten Ansatz, aber f
72
76
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.
73
77
74
78
```java
79
+
importorg.openpatch.scratch.*;
80
+
75
81
publicclassMyProjectextendsWindow {
76
82
publicMyProject() {
77
83
super(800, 600);
@@ -88,6 +94,8 @@ public class MyProject extends Window {
88
94
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.
Copy file name to clipboardExpand all lines: docs/en/book/multiple-approach-design.md
+11-3Lines changed: 11 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,16 +17,18 @@ The downside to this approach is that you define the behavior of the Sprites ins
17
17
So by using this approach you are trading simplicity with compatibility to the Scratch model.
18
18
19
19
```java
20
+
importorg.openpatch.scratch.*;
21
+
20
22
publicclassMyProgram {
21
23
publicMyProgram() {
22
24
Stage myStage =newStage();
23
25
Sprite zebra =newSprite();
24
26
zebra.addCostume("walk_1", "assets/walk_1.png");
25
27
zebra.setOnEdgeBounce(true);
26
28
27
-
while(true) {
28
-
zebra.move(1);
29
-
}
29
+
zebra.setRun(s -> {
30
+
s.move(1);
31
+
})
30
32
}
31
33
}
32
34
```
@@ -44,6 +46,8 @@ Here are a few comparisons you could draw:
44
46
- 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.
45
47
46
48
```java
49
+
importorg.openpatch.scratch.*;
50
+
47
51
classZebraextendsSprite {
48
52
publicZebra() {
49
53
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
71
75
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.
72
76
73
77
```java
78
+
importorg.openpatch.scratch.*;
79
+
74
80
publicclassMyProjectextendsWindow {
75
81
publicMyProject() {
76
82
super(800, 600);
@@ -87,6 +93,8 @@ public class MyProject extends Window {
87
93
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.
0 commit comments