Skip to content
This repository has been archived by the owner on Nov 12, 2024. It is now read-only.

docs(types.ts): add rotate() example #843

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,18 @@ export interface KaboomCtx {
scale(): ScaleComp,
/**
* Rotation (in degrees).
*
* @example
* ```js
* // bean WITH anchor: rotates bean based on sprite center
* // bean WITHOUT anchor: rotates bean relative to local space
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel this explanation makes no sense, all objects have a default achor and it is topleft.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I noticed that without anchor("center"), it will rotate the sprite on a different origin, or in this case the default anchor top left, but if I wanted to rotate the sprite without changing it's position at all, I'd use anchor("center"). I will rewrite the explanation to be more clear about that.

* const rotateBean = add([
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable should be rotatedBean or simply bean

* sprite("bean"),
* pos(200,140),
* anchor("center"),
* rotate(-90),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be indentation.

* ])
* ```
*/
rotate(a: number): RotateComp,
/**
Expand Down