This commit is contained in:
6
packages/example/src/tween/Tween.ts
Normal file
6
packages/example/src/tween/Tween.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { Control } from "godot"
|
||||
import { Class } from "react-godot-renderer"
|
||||
import { TweenRoot } from "./TweenRoot"
|
||||
|
||||
|
||||
export default class Tween extends Class.make(Control, TweenRoot) {}
|
||||
1
packages/example/src/tween/Tween.ts.uid
Normal file
1
packages/example/src/tween/Tween.ts.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cau87pj31qgqr
|
||||
12
packages/example/src/tween/Tween.tscn
Normal file
12
packages/example/src/tween/Tween.tscn
Normal file
@@ -0,0 +1,12 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://cc4bbuq05f7us"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cau87pj31qgqr" path="res://src/tween/Tween.ts" id="1_cpsg0"]
|
||||
|
||||
[node name="Tween" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_cpsg0")
|
||||
45
packages/example/src/tween/TweenRoot.tsx
Normal file
45
packages/example/src/tween/TweenRoot.tsx
Normal file
@@ -0,0 +1,45 @@
|
||||
import Godot, { Vector2 } from "godot"
|
||||
import { useState } from "react"
|
||||
import { CenterContainer, CheckBox, HBoxContainer, Label, VBoxContainer } from "../components"
|
||||
|
||||
|
||||
export function TweenRoot() {
|
||||
const [show, setShow] = useState(false)
|
||||
|
||||
return (
|
||||
<CenterContainer
|
||||
anchors_preset={Godot.Control.LayoutPreset.PRESET_FULL_RECT}
|
||||
>
|
||||
<VBoxContainer>
|
||||
<HBoxContainer>
|
||||
<CheckBox
|
||||
button_pressed={show}
|
||||
toggled={setShow}
|
||||
/>
|
||||
|
||||
<Label text="Show" />
|
||||
</HBoxContainer>
|
||||
|
||||
{show &&
|
||||
<Label
|
||||
anchors_preset={Godot.Control.LayoutPreset.PRESET_CENTER}
|
||||
text="Hello World!"
|
||||
ready={async function(this) {
|
||||
// If the Control node is a child of a [Container] node, the scale will be reset to Vector2(1, 1) when the scene is instantiated.
|
||||
// To set the Control's scale when it's instantiated, wait for one frame using await get_tree().process_frame then set its [member scale] property.
|
||||
await this.get_tree().process_frame.as_promise()
|
||||
|
||||
this.scale = new Vector2(0, 0)
|
||||
const tween = this.create_tween()
|
||||
tween.tween_property(this, "scale", new Godot.Vector2(1, 1), 2)
|
||||
tween.tween_callback(Godot.Callable.create(() => console.log("Tween done!")))
|
||||
|
||||
// await tween.finished.as_promise()
|
||||
// console.log("Tween done!")
|
||||
}}
|
||||
/>
|
||||
}
|
||||
</VBoxContainer>
|
||||
</CenterContainer>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user