Skip to content

Commit c1b4784

Browse files
committed
feat(doc): entities examples
1 parent b2277f7 commit c1b4784

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

playground/graphics/graphics-2-entities.md

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ Every sprite, shape, text, etc are entities displayable in the viewer. They impl
1717
Circle circle = graphicEntityModule.createCircle()
1818
.setRadius(50)
1919
.setLineWidth(0)
20-
.setFillColor(0x00FF00);
20+
.setFillColor(0x00FF00)
21+
.setX(70)
22+
.setY(70);
2123
```
2224
## Moving a circle
2325
```java
@@ -29,21 +31,34 @@ circle
2931
### With a Curve
3032
```java
3133
circle
32-
.setX(player.getX(), Curve.LINEAR)
33-
.setY(player.getY(), Curve.LINEAR);
34+
.setX(player.getX(), Curve.EASE_IN_AND_OUT)
35+
.setY(player.getY(), Curve.EASE_IN_AND_OUT);
3436
```
37+
By default the `Curve.LINEAR` is used.
38+
39+
It should look like this :
40+
![Example](resources/circles.gif)
41+
The first circle is not animated,
42+
the second is animated with the default curve
43+
and the last one is animated with the custom curve.
44+
3545
## Creating a group of sprites <a name="creating-a-group-of-sprites"></a>
3646
```java
3747
Sprite planet1 = graphicEntityModule.createSprite()
38-
.setImage("planet")
48+
.setImage("planet0.png")
49+
.setAnchorX(0.5)
50+
.setAnchorY(0.5)
3951
.setX(-20);
4052
Sprite planet2 = graphicEntityModule.createSprite()
41-
.setImage("planet")
42-
.setX(30);
53+
.setImage("planet1.png")
54+
.setAnchorX(0.5)
55+
.setAnchorY(0.5)
56+
.setX(30)
4357
.setY(-10);
4458
Sprite planet3 = graphicEntityModule.createSprite()
45-
.setImage("planet")
46-
.setY(20);
59+
.setImage("planet2.png")
60+
.setAnchorX(0.5)
61+
.setAnchorY(0.5);
4762

4863
// The planets are around the point (960,540).
4964
Group system = graphicEntityModule.createGroup(planet1, planet2, planet3)
@@ -58,4 +73,6 @@ Group system = graphicEntityModule.createGroup(planet1, planet2, planet3)
5873
planet3.setRotation(planet3.getRotation() + Math.PI / 16);
5974

6075
system.setRotation(system.getRotation() + Math.PI / 2);
61-
```
76+
```
77+
It should look like this :
78+
![Example](resources/planets.gif)
24.8 KB
Loading
458 KB
Loading

0 commit comments

Comments
 (0)