Merge pull request #1740 from thecodingmachine/feature-move-character-api
Feature move character api
This commit is contained in:
commit
ad2dd1c8d5
13 changed files with 397 additions and 27 deletions
|
@ -173,6 +173,37 @@ Example:
|
|||
WA.player.state.toto //will retrieve the variable
|
||||
```
|
||||
|
||||
### Move player to position
|
||||
```typescript
|
||||
WA.player.moveTo(x: number, y: number, speed?: number): Promise<{ x: number, y: number, cancelled: boolean }>;
|
||||
```
|
||||
Player will try to find shortest path to the destination point and proceed to move there.
|
||||
```typescript
|
||||
// Let's move player to x: 250 y: 250 with speed of 10
|
||||
WA.player.moveTo(250, 250, 10);
|
||||
```
|
||||
You can also chain movement like this:
|
||||
```typescript
|
||||
// Player will move to the next point after reaching first one
|
||||
await WA.player.moveTo(250, 250, 10);
|
||||
await WA.player.moveTo(500, 0, 10);
|
||||
```
|
||||
Or like this:
|
||||
```typescript
|
||||
// Player will move to the next point after reaching first one or stop if the movement was cancelled
|
||||
WA.player.moveTo(250, 250, 10).then((result) => {
|
||||
if (!result.cancelled) {
|
||||
WA.player.moveTo(500, 0, 10);
|
||||
}
|
||||
});
|
||||
```
|
||||
It is possible to get the information about current player's position on stop and if the movement was interrupted
|
||||
```typescript
|
||||
// Result will store x and y of Player at the moment of movement's end and information if the movement was interrupted
|
||||
const result = await WA.player.moveTo(250, 250, 10);
|
||||
// result: { x: number, y: number, cancelled: boolean }
|
||||
```
|
||||
|
||||
### Set the outline color of the player
|
||||
```
|
||||
WA.player.setOutlineColor(red: number, green: number, blue: number): Promise<void>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue