-
-
Notifications
You must be signed in to change notification settings - Fork 35
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 many examples for on events #477
base: master
Are you sure you want to change the base?
Conversation
commit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many are fine, let some comments
* @example | ||
* ```js | ||
* // This will run when the object is added. | ||
* onAdd("addTag", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addTag looks as bad example, maybe bomb
, enemy
or any real world name
* @example | ||
* ```js | ||
* // This will run when the object is destroyed. | ||
* onDestroy("destroyTag", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same as onAdd
* debug.log("ohbye") | ||
* }) | ||
* | ||
* let objectToDestroy = add([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the same as onAdd, should be generic names like enemy or bullet
* if (m == `left`) | ||
* cookies++ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use our format with brackets or change to inline if(m == "left") cookies++;
* let player = add([ | ||
* pos(center()), | ||
* anchor(`center`), | ||
* sprite(`bean`), | ||
* area(), | ||
* body(), | ||
* { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Example doesn't need all this components, with pos and sprite is already understable
@@ -1717,6 +2140,40 @@ export interface KAPLAYCtx< | |||
): KEventController; | |||
/** | |||
* Register an event that runs when user releases any gamepad button. | |||
* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Complicated, but looks good
* // gamepad player controls | ||
* setGravity(200) | ||
* | ||
* let player = add([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same, not that much comps needed
* // gamepad player jump | ||
* setGravity(200) | ||
* | ||
* let player = add([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same about many comps
* @example | ||
* ```js | ||
* // basic car with brakes | ||
* let car = add([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same about comps, I think we should mantain simple the ones in controller, I like these examples but can be real examples, not the example of the function, should be simpler
* | ||
* @since v3001.0 | ||
* @group Events | ||
*/ | ||
onShow(action: () => void): KEventController; | ||
/** | ||
* Register an event that runs every frame when certain gamepad buttons are held down. | ||
* | ||
* @example |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same about complexity
Added examples for the following events:
onAdd()
onDestroy()
onLoading()
onError()
onResize()
onCleanup()
onGamepadConnect()
onGamepadDisconnect()
onKeyRelease()
onMouseDown()
onMousePress()
onMouseRelease()
onMouseMove()
onHide()
onShow()
onGamepadButtonDown()
onGamepadButtonPress()
onGamepadButtonRelease()
onGamepadStick()