Skip to content

How to access the Math functions like clamp() #2603

Answered by eonarheim
bpikaar asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @bpikaar

Great question, clamp() is available at the top level import if you are doing commonjs style modules

If you include excalibur.js as a script on the page it will be hanging off of the ex global.

<!DOCTYPE html>
<html>
  <head></head>
  <body>
    <script src="https://unpkg.com/[email protected]"></script>
    <script src="./main.js"></script>
  </body>
</html>
// main.js
console.log(ex.clamp(6, 0, 4));

Let me know if this helps!

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@bpikaar
Comment options

Answer selected by bpikaar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants