readme changes
This commit is contained in:
parent
b088e63290
commit
72c7eae559
@ -188,10 +188,20 @@ You can also chain movement like this:
|
|||||||
await WA.player.moveTo(250, 250, 10);
|
await WA.player.moveTo(250, 250, 10);
|
||||||
await WA.player.moveTo(500, 0, 10);
|
await WA.player.moveTo(500, 0, 10);
|
||||||
```
|
```
|
||||||
It is possible to get the information about current player's position on stop or when movement is interrupted
|
Or like this:
|
||||||
```typescript
|
```typescript
|
||||||
// Position will store x and y of Player at the moment of movement's end
|
// Player will move to the next point after reaching first one or stop if the movement was cancelled
|
||||||
const position = await WA.player.moveTo(250, 250, 10);
|
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
|
### Set the outline color of the player
|
||||||
|
@ -14,29 +14,15 @@
|
|||||||
const speedField = document.getElementById('speed');
|
const speedField = document.getElementById('speed');
|
||||||
|
|
||||||
randomChainedMovementButton.addEventListener('click', async () => {
|
randomChainedMovementButton.addEventListener('click', async () => {
|
||||||
try {
|
WA.player.moveTo(500, 500, 10)
|
||||||
WA.player.moveTo(100, 100, 10).then((result) => {
|
const result = await WA.player.moveTo(100, 100, 10).then((result) => {
|
||||||
|
if (result.completed)
|
||||||
if (result.cancelled) {
|
if (result.cancelled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log(result);
|
WA.player.moveTo(500, 100, 20);
|
||||||
WA.player.moveTo(500, 100, 20).then((result) => {
|
|
||||||
if (result.cancelled) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
console.log(result);
|
|
||||||
WA.player.moveTo(500, 500, 10).then((result) => {
|
|
||||||
if (result.cancelled) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
console.log(result);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
console.log('movement was stopped forcefully');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
movePlayerButton.addEventListener('click', async () => {
|
movePlayerButton.addEventListener('click', async () => {
|
||||||
const position = await WA.player.moveTo(
|
const position = await WA.player.moveTo(
|
||||||
|
Loading…
Reference in New Issue
Block a user