0
\$\begingroup\$

I am using Crafty.js. I want the player to die when they hit the side of the viewport (they need to keep moving to stay alive). How do I detect a collision between the player entity and the side/edge of the viewport? I have looked at Crafty.viewport, but have not been able to find anything useful.

\$\endgroup\$
0
\$\begingroup\$

Use your entity's 2D method within combined with your viewport's property bounds as input argument. It will check if your player's rectangle is within the viewport.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.