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\$

1 Answer 1

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\$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .