extends Node2D # 2 onready var oil_tanker_inside_2 = $InsideOilTanker2 onready var camera = $InsideOilTanker2/Camera2D onready var player = $InsideOilTanker2/Player func _ready(): $OilTanker.connect('animation_finished', self, 'end_oil_tanker') $InsideOilTanker/NextTrigger.connect("body_entered", self, 'end_inside_oil_tanker') # $OilTanker.frame = 12 # end_oil_tanker() # end_inside_oil_tanker($InsideOilTanker/Player) func end_oil_tanker(): print('end_oil_tanker') if $OilTanker.frame > 1: $OilTanker.queue_free() $InsideOilTanker/Player.sleep = false func end_inside_oil_tanker(body : Node): print('end_inside_oil_tanker') if body.name == "Player": $InsideOilTanker.queue_free() $InsideOilTanker2/Player.sleep = false $InsideOilTanker2/Camera2D.current = true func _input(event): if $OilTanker != null: if event.is_action_pressed('right'): if !$OilTanker.is_playing(): $OilTanker.play('default') if event.is_action_released('right'): $OilTanker.stop() if event.is_action_pressed('left'): if !$OilTanker.is_playing() && $OilTanker.frame > 0: $OilTanker.play('default', true) if event.is_action_released('left'): $OilTanker.stop() func _process(delta): if !$InsideOilTanker2/Player.sleep: var screen_width = ProjectSettings.get_setting("display/window/size/width") camera.position.x = floor(clamp(player.position.x - screen_width / 2.0, 0, oil_tanker_inside_2.texture.get_width() - screen_width)) $InsideOilTanker2/Parallax/Prop2.position.x = floor((260 - camera.position.x) * 0.5) $InsideOilTanker2/Parallax/Prop1.position.x = floor((300 - camera.position.x) * 0.75)