Compare commits
1 Commits
master
...
test-camer
Author | SHA1 | Date | |
---|---|---|---|
|
e18f50ee98 |
31
Player.gd
31
Player.gd
@ -30,6 +30,8 @@ var var_jump = 0
|
||||
|
||||
|
||||
onready var sprite = $Sprite
|
||||
onready var camera = $Camera2D
|
||||
onready var area_camera = $AreaCamera2D
|
||||
|
||||
|
||||
func _physics_process(delta):
|
||||
@ -83,3 +85,32 @@ func _physics_process(delta):
|
||||
# Apply movement
|
||||
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
Loading…
Reference in New Issue
Block a user