Skip to content

User Input, "Camera", isTouching update 1.0.8 #13

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

Merged
merged 3 commits into from
Apr 4, 2023
Merged

Conversation

Moderrek
Copy link
Owner

@Moderrek Moderrek commented Apr 4, 2023

JSGL - User Input, "Camera", isTouching update 1.0.8

  • Added changelogs
  • Game Events
    • mouseScroll - emits GameMouseEvent
    • keyDown - emits GameKeyEvent
    • keyUp - emits GameKeyEvent
  • "Camera" is more like to view offset. You can find it in game.canvasViewOffset. This property is a Vector2.
  • Added DrawableGameObject.IsTouching(drawGameObj, drawGameObj2) static method and drawableGameObject.isTouching(drawGameObj)
  • Added JSGL.log(content), JSGL.warn(content), JSGL.error(content). Prints message to dev console with format [DATE] [LEVEL] content

Changes

  • Deprecated
    • game.mousePos - Instead use game.input.mouseWorldPosition
    • game.mouseClientPos - Instead use game.input.mouseClientPosition
    • game.mousePrecisePos - Instead use game.input.mousePreciseWorldPosition
    • game.isMousePrimaryButtonDown() - Instead use game.input.isMousePrimaryButtonDown
  • Now GameMouseEvent has properties from game.input. (Only about mouse)

Fixes

  • None.

Presentation of news

Mouse wheel handling

In GameObject

...
Update(event){
    event.game.input.mouseScrollDelta.y; // x is ignored
}
...

Without GameObject

game.on('mouseScroll', (event) => {
    event.mouseScrollDelta.y; // x is ignored
});

How to work with input

In GameObject

...
Update(event){
    event.game.input.isKeyDown('w'); // <-- returns is 'w' pressed down
    event.game.input.isKeyUp('s'); // <-- returns is 's' clicked
}
...

Without GameObject

...
game.on('keyUp' (event) => {
    event.input.isKeyUp('s'); // <-- returns is 's' clicked
});
game.on('keyDown' (event) => {
    event.input.isKeyDown('w'); // <-- returns is 'w' pressed down
});
...

@Moderrek Moderrek merged commit 5e7f417 into release Apr 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant