Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Screen scrolling #3

Open
bojidar-bg opened this issue Nov 26, 2015 · 0 comments
Open

Screen scrolling #3

bojidar-bg opened this issue Nov 26, 2015 · 0 comments

Comments

@bojidar-bg
Copy link
Contributor

The camera should be moved when the cursor goes near the edge of the screen (RTS style).

Sample code:

var camera_move = Vector2(0,0)

#...Other ways to move the camera...

var mouse_move = (get_global_mouse_pos() - camera.get_global_pos()) / get_viewport_rect().size * get_viewport_transform().get_scale() * 2
var mouse_distance = max(abs(mouse_move.x), abs(mouse_move.y))

if mouse_distance > 0.9:
    camera_move += mouse_move

camera.set_pos(camera.get_pos() + camera_move * camera_speed * delta )
@bojidar-bg bojidar-bg added this to the v1.0.0 - Initial target milestone Nov 26, 2015
@alketii alketii self-assigned this Nov 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants