Compare commits

...

1 Commits

Author SHA1 Message Date
Gary Wang
e18f50ee98 first camera test, not happy with the result 2020-11-23 23:27:10 +08:00
2 changed files with 52 additions and 2 deletions

View File

@ -30,6 +30,8 @@ var var_jump = 0
onready var sprite = $Sprite onready var sprite = $Sprite
onready var camera = $Camera2D
onready var area_camera = $AreaCamera2D
func _physics_process(delta): func _physics_process(delta):
@ -83,3 +85,32 @@ func _physics_process(delta):
# Apply movement # Apply movement
speed = move_and_slide(speed, Vector2.UP) speed = move_and_slide(speed, Vector2.UP)
func _on_CameraLimitArea_body_shape_entered(body_id, body, body_shape, area_shape):
if body is TileMap:
return
var body_shape_owner_id = body.shape_find_owner(body_shape)
var body_shape_owner = body.shape_owner_get_owner(body_shape_owner_id)
var body_shape_2d = body.shape_owner_get_shape(body_shape_owner_id, 0)
var body_global_transform = body_shape_owner.global_transform
var area_shape_owner_id = shape_find_owner(area_shape)
var area_shape_owner = shape_owner_get_owner(area_shape_owner_id)
var area_shape_2d = shape_owner_get_shape(area_shape_owner_id, 0)
var area_global_transform = area_shape_owner.global_transform
var collision_points = area_shape_2d.collide_and_get_contacts(area_global_transform,
body_shape_2d,
body_global_transform)
print(body_shape_2d.extents, area_shape_2d.extents)
area_camera.limit_left = 0
area_camera.limit_top = 0
area_camera.limit_right = 320
area_camera.limit_bottom = 176
area_camera.make_current()
print(area_global_transform.x.x, area_global_transform.y.y, area_global_transform.y.x, area_global_transform.x.y)
func _on_CameraLimitArea_body_shape_exited(body_id, body, body_shape, area_shape):
camera.make_current()

File diff suppressed because one or more lines are too long