pretty new to flashpunk. how can you keep your character from going offscreen?
Off-screen help
jacobalbano
(Jacob Albano)
#2
Welcome!
If your camera never moves, it’s quite simple. In your character Entity’s update()
method, add this:
// do all your movement code first
clampVertical(0, FP.height);
clampHorizontal(0, FP.width);
If your camera moves, it’s a little more complicated but not that much:
clampVertical(FP.camera.x, FP.camera.x + FP.width);
clampHorizontal(FP.camera.y, FP.camera.y + FP.height);
gif
(gif)
#3
Thanks!! it worked. This question was just to learn more about flashpunk although I could’ve gone to the documentation page instead. but thanks anyway.