Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: added some examples, added docs for drawon() #460

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Changes from all commits
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
59 changes: 59 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,32 @@ export interface KAPLAYCtx<
*
* @param popt The options for the particles.
* @param eopt The options for the emitter.
*
* @example
* ```js
* // beansplosion
*
* // create the emitter
* const emitter = add([
* pos(center()),
* particles({
* max: 100,
* speed: [75, 100],
* lifeTime: [0.75,1.0],
* angle: [0, 360],
* opacities: [1.0, 0.0],
* texture: getSprite("bean").tex, // texture of a sprite
* quads: getSprite("bean").frames, // frames of a sprite
* }, {
* direction: 0,
* spread: 360,
* }),
* ])
*
* onUpdate(() => {
* emitter.emit(1)
* })
* ```
*
* @group Components
* @since v3001.0
Expand Down Expand Up @@ -655,6 +681,23 @@ export interface KAPLAYCtx<
/**
* Applies a force on a colliding object in order to make it move along the collision tangent vector.
* Good for conveyor belts.
*
* @example
* ```js
* loadSprite("belt", "/sprites/jumpy.png")
*
* // conveyor belt
* add([
* pos(center()),
* sprite("belt"),
* rotate(90),
* area(),
* body({ isStatic: true }),
* surfaceEffector({
* speed: 50,
* })
* ])
* ```
*
* @since v3001.0
* @group Components
Expand Down Expand Up @@ -967,6 +1010,22 @@ export interface KAPLAYCtx<
* @group Components
*/
mask(maskType?: Mask): MaskComp;
/**
* Specifies the FrameBuffer the object should be drawn on.
*
* @example
* ```js
* // Draw on another canvas
* let canvas = makeCanvas(width(), height())
*
* let beanOnCanvas = add([
* sprite("bean"),
* drawon(canvas.fb),
* ])
* ```
*
* @param canvas
*/
drawon(canvas: FrameBuffer): Comp;
/**
* A tile on a tile map.
Expand Down