GDevelopApp / GDevelop-extensions

Repository of behaviors, actions, conditions and expressions to be used in GDevelop for creating games
https://gdevelop.io
MIT License
131 stars 52 forks source link

MousePointerLockExtension #114

Closed PANDAKO-GitHub closed 3 years ago

PANDAKO-GitHub commented 3 years ago

Describe the extension

This behavior removes the limit on the distance the mouse can move and hides the cursor. For example, a user can rotate or continue to manipulate an object by moving the mouse endlessly. Without the pointer lock, the rotation or operation will stop the moment the pointer reaches the edge of the browser or screen. Game players don't have to worry about leaving the gameplay area or accidentally clicking on another application that moves the mouse focus away from the game.

Locking the pointer locks MouseX() and MouseY(). Use MovementX() and MovementY() instead.

Checklist

Extension file

MousePointerLockExtension0.1.1.zip

Repository

https://github.com/PANDAKO-GitHub/MousePointerLockExtension

Sample

https://pandako-github.github.io/MousePointerLockExtension/

Bouh commented 3 years ago

Thank this can be very helpful. I've made some change on descriptions for follow the best pratices of extensions. I've bumped the version of the extension tp 0.1.2 with this changes:

One doubt I see you get the first element canvas by the tag name in the page. This can be wrong in some case where the game is include on a web page with others canvas element. @4ian can we see for add a unique ID on the canvas html element, like 'GDevelop-Game-Engine' ?

MousePointerLockExtension0.1.2.zip

4ian commented 3 years ago

Very nice extension!

Thanks Bouh for all the additions.

@4ian can we see for add a unique ID on the canvas html element, like 'GDevelop-Game-Engine' ?

I think you could even use runtimeGame.getRenderer().getCanvas()?

PANDAKO-GitHub commented 3 years ago

@Bouh thank you for improving😄

PANDAKO-GitHub commented 3 years ago

@4ian thank you for your advice.😊

I think you could even use runtimeGame.getRenderer().getCanvas()?

I made this change and it worked fine.🙌

const canvas = runtimeScene.getGame().getRenderer().getCanvas();

I created v0.1.3 using v0.1.2.

MousePointerLockExtension0.1.3.zip

Bouh commented 3 years ago

Thx guys! The extension has been added :) Commit https://github.com/4ian/GDevelop-extensions/commit/e63e939d06dc981f9a4ed5f74187fa13702ddc57

4ian commented 3 years ago

Great work, thanks all! 👍👍

tristanbob commented 3 years ago

I just tried installing this extension and I get the "Unable to download and install extension" error.

4ian commented 3 years ago

Should be fixed and safety checks added against the mistake in the extension name :) Thanks for reporting.