| @ -2,19 +2,28 @@ extends KinematicBody2D |
| export var speed=5 |
| var collide_obj |
| var collide_name |
| var PlayerUi=load("res://PlayerUi.tscn").instance() |
| func _ready(): |
| pass # Replace with function body. |
| # Called every frame. 'delta' is the elapsed time since the previous frame. |
| func _process(delta): |
| if Input.is_action_pressed("ui_up"): |
| move_and_collide(Vector2(0,-speed)) |
| collide_obj=move_and_collide(Vector2(0,-speed)) |
| if Input.is_action_pressed("ui_down"): |
| move_and_collide(Vector2(0,speed)) |
| collide_obj=move_and_collide(Vector2(0,speed)) |
| if Input.is_action_pressed("ui_left"): |
| move_and_collide(Vector2(-speed,0)) |
| collide_obj=move_and_collide(Vector2(-speed,0)) |
| if Input.is_action_pressed("ui_right"): |
| move_and_collide(Vector2(speed,0)) |
| collide_obj=move_and_collide(Vector2(speed,0)) |
| if collide_obj: |
| collide_name=collide_obj.get_collider().name |
| print(collide_name) |
| if collide_name=="home": |
| get_tree().current_scene.add_child(PlayerUi) |
| else: |
| get_tree().current_scene.remove_child(PlayerUi) |
| pass |


暂无关于此日志的评论。