https://github.com/ialex32x/layabase
一些简单的功能
https://github.com/ialex32x/layabase
behavior-tree laya layaair library quadtree
Last synced: 3 months ago
JSON representation
一些简单的功能
- Host: GitHub
- URL: https://github.com/ialex32x/layabase
- Owner: ialex32x
- License: mit
- Created: 2018-09-20T02:05:24.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-05-08T15:05:27.000Z (over 6 years ago)
- Last Synced: 2025-10-09T02:04:30.972Z (3 months ago)
- Topics: behavior-tree, laya, layaair, library, quadtree
- Language: TypeScript
- Size: 240 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# layabase
一些简单的功能
比如简化的 behaviour tree, astar pathfinding 等
Behaviour Tree
```typescript
let prl = new BehaveParallel()
// 只执行一轮的序列 (无限执行不传参即可)
let seq1 = new BehaveSequence(1)
seq1.addChild(new BehaveWait(3000))
// 执行指定函数动作的行为节点
seq1.addChild(new BehaveAction(ctx => {
console.log("bt.action1", Laya.timer.currTimer / 1000)
}))
prl.addChild(seq1)
let seq2 = new BehaveSequence(6)
seq2.addChild(new BehaveWait(1000))
seq2.addChild(new BehaveAction(ctx => {
console.log("bt.action2", Laya.timer.currTimer / 1000)
}))
prl.addChild(seq2)
let mgr = new BehaveManager()
mgr.add("test", prl)
let runner1 = mgr.run("test", null)
let restart = true
Laya.timer.loop(1, this, () => {
if (!runner1.update(Laya.timer.delta)) {
if (restart) {
// 执行结束后可以重启
runner1.restart()
restart = false
}
}
})
```
Request
```typescript
HttpRequest.sharedBaseUrl = "https://yourdomain"
// 发起GET请求 (payload会转换成url的一部分)
HttpRequest.GET("/your/api/path", {
data1: "test",
data2: 123,
}, (status, res) => {
console.log("GET", status, res)
}).timeout(3)
// POST/FORM 接口与 GET 方式一致
```