Skip to content

Commit 8d119ba

Browse files
committed
更新了 readme.md
1 parent d854154 commit 8d119ba

File tree

2 files changed

+51
-10
lines changed

2 files changed

+51
-10
lines changed

EleCho.ScratchGame/EleCho.ScratchGame.csproj

+2-9
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
88
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
9-
<Version>0.1.2-alpha</Version>
9+
<Version>0.2.1-alpha</Version>
1010
<Copyright>Copyright EleCho 2022</Copyright>
1111
<RepositoryUrl>https://github.com/EleChoNet/EleCho.ScratchGame</RepositoryUrl>
1212
<RepositoryType>git</RepositoryType>
@@ -17,14 +17,7 @@
1717
<Authors>EleCho</Authors>
1818
<PackageReadmeFile>readme.md</PackageReadmeFile>
1919
<PackageTags>2D game_engine GDI+</PackageTags>
20-
<PackageReleaseNotes>添加了盒背景, 背景, 边框角度, 边框拓展</PackageReleaseNotes>
20+
<PackageReleaseNotes>为 GameSprite 添加了 Opacity</PackageReleaseNotes>
2121
</PropertyGroup>
2222

23-
<ItemGroup>
24-
<None Include="..\readme.md">
25-
<Pack>True</Pack>
26-
<PackagePath>\</PackagePath>
27-
</None>
28-
</ItemGroup>
29-
3023
</Project>

readme.md

+49-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# EleCho.ScratchGame
22

3-
一个小型的的, 基于 GDI+ 的 2D 游戏引擎. [点击查看预览视频](resrc/videos/preview.mp4)
3+
一个小型的的, 基于 GDI+ 的 2D 游戏引擎. [点击查看预览视频](https://www.bilibili.com/video/BV1RD4y167JH)
44

55
> 灵感来自于: MIT 的 [Scratch](https://scratch.mit.edu/)
66
@@ -62,4 +62,52 @@ class MoveRightForever : GameSprite
6262
Position += new SizeF(Speed, 0) * Game.DeltaTime;
6363
}
6464
}
65+
```
66+
67+
### 碰撞检测
68+
69+
GameSprite 包含默认的简单的碰撞检测, 它基于多边形的碰撞检测.
70+
71+
通过 Game 类的静态 IsCollided 方法来判断两个游戏对象是否碰撞
72+
73+
```csharp
74+
Game.IsCollided(a, b)
75+
```
76+
77+
你可以自定义游戏对象的碰撞器多边形, 只需要为其 Collider 属性赋值即可
78+
79+
```csharp
80+
gameSprite.Collider = new GameObjectCollider(
81+
new PointF(.25f, .25f), // 多边形顶点坐标 (0,0 为左上角, 1,1 为右下角)
82+
new PointF(.75f, .25f),
83+
new PointF(.75f, .75f),
84+
new PointF(.75f, .25f));
85+
```
86+
87+
### 精灵动画
88+
89+
通过变换 Sprite 的值, 来实现简单的动画
90+
91+
```csharp
92+
class Warplane : GameSprite
93+
{
94+
Bitmap[] bodies;
95+
public Warplane(Bitmap[] bodies)
96+
{
97+
this.bodies = bodies;
98+
SpriteChangeLoop();
99+
}
100+
101+
private async void SpriteChangeLoop()
102+
{
103+
while (true)
104+
{
105+
foreach (var me in bodies)
106+
{
107+
await Task.Delay(100);
108+
Sprite = me;
109+
}
110+
}
111+
}
112+
}
65113
```

0 commit comments

Comments
 (0)