src / stages / gimmicks / strawberry / strawberry.tscn

Diagram

Diagram

Assets

200

Overridden virtual functions

_ready

func _ready() -> void:
	if obtained: hide()

_physics_process

func _physics_process(_delta: float) -> void:
	if player:
		var target := player.global_position + OFFSET
		%Pivot.global_position = %Pivot.global_position.lerp(target, 0.1)

Scene Tree

  • Strawberry Area2D

    • Pivot Node2D

      • Sprite2D Sprite2D

      • HitArea Area2D

        • CollisionShape2D CollisionShape2D

    • AnimationPlayer AnimationPlayer

Signal Connections

$.:[area_entered]⇒$.
func _on_area_entered(_area: Area2D) -> void:
	if not obtained and player: ascend()
$Pivot/HitArea:[area_entered]⇒$.
func _on_hit_area_entered(area: Area2D) -> void:
	player = area.owner as Player

Animations

idle (autoplay)

Diagram

Animation_rlj1e

Diagram

ascend

Diagram

Properties

Table 1. Root properties
Name Value

scale

Vector2(4.6, 4.6)

collision_layer

0

collision_mask

2

script

Table 2. $Pivot properties
Name Value

unique_name_in_owner

true

Table 3. $Pivot/Sprite2D properties
Name Value

texture

Strawberry
Figure 1. res://assets/images/stages/gimmicks/Strawberry.png

hframes

24

Table 4. $Pivot/HitArea properties
Name Value

collision_layer

0

collision_mask

2

Table 5. $Pivot/HitArea/CollisionShape2D properties
Name Value

position

Vector2(0.43478262, -0.43478262)

shape

SubResource("CircleShape2D_6ayuk")

Table 6. $AnimationPlayer properties
Name Value

unique_name_in_owner

true

libraries

{ &"": SubResource("AnimationLibrary_nrel5") }

autoplay

idle

strawberry.gd

extends Area2D

@onready var player : Player
@export var obtained : bool = false
const OFFSET := Vector2(0, -200)


func _ready() -> void:
	if obtained: hide()


func reset() -> void:
	player = null
	%Pivot.position = Vector2(0, 0)
	if obtained: hide()
	play(&'RESET')
	play.call_deferred(&'idle')


func _physics_process(_delta: float) -> void:
	if player:
		var target := player.global_position + OFFSET
		%Pivot.global_position = %Pivot.global_position.lerp(target, 0.1)


func ascend() -> void:
	play(&'ascend')
	obtained = true


func play(key: StringName) -> void:
	%AnimationPlayer.play(key)


func _on_hit_area_entered(area: Area2D) -> void:
	player = area.owner as Player


func _on_area_entered(_area: Area2D) -> void:
	if not obtained and player: ascend()