Add spine and dialogic museums
This commit is contained in:
17
docs/museums/spine/examples/01-helloworld/helloworld.tscn
Normal file
17
docs/museums/spine/examples/01-helloworld/helloworld.tscn
Normal file
@@ -0,0 +1,17 @@
|
||||
[gd_scene format=3 uid="uid://d0v5rhv2ysej8"]
|
||||
|
||||
[ext_resource type="SpineSkeletonDataResource" uid="uid://cb6rn6vonqbx0" path="res://docs/museums/spine/assets/spineboy/spineboy-data-res.tres" id="3"]
|
||||
|
||||
[node name="Node2D" type="Node2D" unique_id=1221230663]
|
||||
|
||||
[node name="Spineboy" type="SpineSprite" parent="." unique_id=538013976]
|
||||
skeleton_data_res = ExtResource("3")
|
||||
bones_color = Color(0.968627, 1, 0, 0.501961)
|
||||
paths_color = Color(1, 0.498039, 0, 0.466667)
|
||||
paths_clipping = Color(0.8, 0, 0, 0.5)
|
||||
preview_skin = "Default"
|
||||
preview_animation = "-- Empty --"
|
||||
preview_frame = false
|
||||
preview_time = 0.0
|
||||
position = Vector2(505, 466)
|
||||
scale = Vector2(0.466832, 0.466832)
|
||||
@@ -0,0 +1,4 @@
|
||||
extends SpineSprite
|
||||
|
||||
func _ready():
|
||||
get_animation_state().set_animation("walk", true, 0)
|
||||
@@ -0,0 +1 @@
|
||||
uid://bqoowjvbanswg
|
||||
@@ -0,0 +1,39 @@
|
||||
extends Node2D
|
||||
|
||||
@onready var footstep_audio: AudioStreamPlayer = $FootstepAudio
|
||||
|
||||
func _animation_started(sprite: SpineSprite, animation_state: SpineAnimationState, track_entry: SpineTrackEntry):
|
||||
print("Animation started: " + track_entry.get_animation().get_name())
|
||||
|
||||
func _animation_interrupted(sprite: SpineSprite, animation_state: SpineAnimationState, track_entry: SpineTrackEntry):
|
||||
print("Animation interrupted: " + track_entry.get_animation().get_name())
|
||||
|
||||
func _animation_ended(sprite: SpineSprite, animation_state: SpineAnimationState, track_entry: SpineTrackEntry):
|
||||
print("Animation ended: " + track_entry.get_animation().get_name())
|
||||
|
||||
func _animation_completed(sprite: SpineSprite, animation_state: SpineAnimationState, track_entry: SpineTrackEntry):
|
||||
print("Animation completed: " + track_entry.get_animation().get_name())
|
||||
|
||||
func _animation_disposed(sprite: SpineSprite, animation_state: SpineAnimationState, track_entry: SpineTrackEntry):
|
||||
print("Animation disposed: " + track_entry.get_animation().get_name())
|
||||
|
||||
func _animation_event(sprite: SpineSprite, animation_state: SpineAnimationState, track_entry: SpineTrackEntry, event: SpineEvent):
|
||||
print("Animation event: " + track_entry.get_animation().get_name() + ", " + event.get_data().get_event_name())
|
||||
if (event.get_data().get_event_name() == "footstep"):
|
||||
footstep_audio.play()
|
||||
|
||||
func _ready():
|
||||
var spineboy = $Spineboy
|
||||
spineboy.animation_started.connect(_animation_started)
|
||||
spineboy.animation_interrupted.connect(_animation_interrupted)
|
||||
spineboy.animation_ended.connect(_animation_ended)
|
||||
spineboy.animation_completed.connect(_animation_completed)
|
||||
spineboy.animation_disposed.connect(_animation_disposed)
|
||||
spineboy.animation_event.connect(_animation_event)
|
||||
|
||||
var animation_state = spineboy.get_animation_state()
|
||||
animation_state.set_animation("jump", false, 0)
|
||||
animation_state.add_animation("walk", 0, true, 0)
|
||||
animation_state.add_animation("run", 2, true, 0)
|
||||
|
||||
pass
|
||||
@@ -0,0 +1 @@
|
||||
uid://y8pd4giv7cmt
|
||||
@@ -0,0 +1,18 @@
|
||||
[gd_scene format=3 uid="uid://c738i3nbdkn0h"]
|
||||
|
||||
[ext_resource type="SpineSkeletonDataResource" uid="uid://cb6rn6vonqbx0" path="res://docs/museums/spine/assets/spineboy/spineboy-data-res.tres" id="2"]
|
||||
[ext_resource type="AudioStream" uid="uid://can7k84o8svum" path="res://docs/museums/spine/assets/footstep.ogg" id="3"]
|
||||
|
||||
[node name="Node2D" type="Node2D" unique_id=1601974791]
|
||||
|
||||
[node name="Spineboy" type="SpineSprite" parent="." unique_id=1213124179]
|
||||
skeleton_data_res = ExtResource("2")
|
||||
preview_skin = "Default"
|
||||
preview_animation = "-- Empty --"
|
||||
preview_frame = false
|
||||
preview_time = 0.0
|
||||
position = Vector2(473, 487)
|
||||
scale = Vector2(0.575051, 0.575051)
|
||||
|
||||
[node name="FootstepAudio" type="AudioStreamPlayer" parent="." unique_id=282578071]
|
||||
stream = ExtResource("3")
|
||||
@@ -0,0 +1,22 @@
|
||||
extends SpineSprite
|
||||
|
||||
func _ready():
|
||||
var data = get_skeleton().get_data()
|
||||
var custom_skin = new_skin("custom-skin")
|
||||
var skin_base = data.find_skin("skin-base")
|
||||
custom_skin.add_skin(skin_base)
|
||||
custom_skin.add_skin(data.find_skin("nose/short"))
|
||||
custom_skin.add_skin(data.find_skin("eyelids/girly"))
|
||||
custom_skin.add_skin(data.find_skin("eyes/violet"))
|
||||
custom_skin.add_skin(data.find_skin("hair/brown"))
|
||||
custom_skin.add_skin(data.find_skin("clothes/hoodie-orange"))
|
||||
custom_skin.add_skin(data.find_skin("legs/pants-jeans"))
|
||||
custom_skin.add_skin(data.find_skin("accessories/bag"))
|
||||
custom_skin.add_skin(data.find_skin("accessories/hat-red-yellow"))
|
||||
get_skeleton().set_skin(custom_skin);
|
||||
|
||||
for el in custom_skin.get_attachments():
|
||||
var entry: SpineSkinEntry = el
|
||||
print(str(entry.get_slot_index()) + " " + entry.get_name())
|
||||
|
||||
get_animation_state().set_animation("dance", true, 0)
|
||||
@@ -0,0 +1 @@
|
||||
uid://cgv3vry706p84
|
||||
@@ -0,0 +1,16 @@
|
||||
[gd_scene format=3 uid="uid://dodvuj07fsynd"]
|
||||
|
||||
[ext_resource type="SpineSkeletonDataResource" uid="uid://btsqcvy7c5y8x" path="res://docs/museums/spine/assets/mix-and-match/mix-and-match-data.tres" id="2"]
|
||||
[ext_resource type="Script" uid="uid://cgv3vry706p84" path="res://docs/museums/spine/examples/03-mix-and-match/mix-and-match.gd" id="2_clsj7"]
|
||||
|
||||
[node name="Node2D" type="Node2D" unique_id=2006583665]
|
||||
|
||||
[node name="MixAndMatch" type="SpineSprite" parent="." unique_id=1522896059]
|
||||
skeleton_data_res = ExtResource("2")
|
||||
preview_skin = "Default"
|
||||
preview_animation = "-- Empty --"
|
||||
preview_frame = false
|
||||
preview_time = 0.0
|
||||
position = Vector2(532.982, 480.287)
|
||||
scale = Vector2(0.441932, 0.441932)
|
||||
script = ExtResource("2_clsj7")
|
||||
@@ -0,0 +1,16 @@
|
||||
[gd_scene format=3 uid="uid://bgdpghp11j3kg"]
|
||||
|
||||
[ext_resource type="SpineSkeletonDataResource" uid="uid://cb6rn6vonqbx0" path="res://docs/museums/spine/assets/spineboy/spineboy-data-res.tres" id="1"]
|
||||
[ext_resource type="Script" uid="uid://djgow48y0sfrs" path="res://docs/museums/spine/examples/04-simple-input/spineboy-simple-input.gd" id="2_nao5a"]
|
||||
|
||||
[node name="Node2D" type="Node2D" unique_id=674511270]
|
||||
|
||||
[node name="Spineboy" type="SpineSprite" parent="." unique_id=1820819420]
|
||||
skeleton_data_res = ExtResource("1")
|
||||
preview_skin = "Default"
|
||||
preview_animation = "-- Empty --"
|
||||
preview_frame = false
|
||||
preview_time = 0.0
|
||||
position = Vector2(501.503, 472.035)
|
||||
scale = Vector2(0.518624, 0.518624)
|
||||
script = ExtResource("2_nao5a")
|
||||
@@ -0,0 +1,19 @@
|
||||
extends SpineSprite
|
||||
|
||||
func _ready():
|
||||
get_animation_state().set_animation("idle", true, 0)
|
||||
|
||||
func _process(_delta):
|
||||
if Input.is_action_just_pressed("ui_left"):
|
||||
get_animation_state().set_animation("run", true, 0)
|
||||
get_skeleton().set_scale_x(-1)
|
||||
|
||||
if Input.is_action_just_released("ui_left"):
|
||||
get_animation_state().set_animation("idle", true, 0)
|
||||
|
||||
if (Input.is_action_just_pressed("ui_right")):
|
||||
get_animation_state().set_animation("run", true, 0)
|
||||
get_skeleton().set_scale_x(1)
|
||||
|
||||
if Input.is_action_just_released("ui_right"):
|
||||
get_animation_state().set_animation("idle", true, 0)
|
||||
@@ -0,0 +1 @@
|
||||
uid://djgow48y0sfrs
|
||||
@@ -0,0 +1,11 @@
|
||||
extends Node2D
|
||||
|
||||
@onready var spineboy: SpineSprite = $Spineboy
|
||||
@onready var crosshair_bone: SpineBoneNode = $Spineboy/CrosshairBone
|
||||
|
||||
func _ready():
|
||||
spineboy.get_animation_state().set_animation("walk", true, 0)
|
||||
spineboy.get_animation_state().set_animation("aim", true, 1)
|
||||
|
||||
func _process(_delta):
|
||||
crosshair_bone.global_position = get_viewport().get_mouse_position()
|
||||
@@ -0,0 +1 @@
|
||||
uid://d0elhdqlsl71d
|
||||
@@ -0,0 +1,23 @@
|
||||
[gd_scene format=3 uid="uid://borp2l17n5xw1"]
|
||||
|
||||
[ext_resource type="SpineSkeletonDataResource" uid="uid://cb6rn6vonqbx0" path="res://docs/museums/spine/assets/spineboy/spineboy-data-res.tres" id="2"]
|
||||
[ext_resource type="Script" uid="uid://d0elhdqlsl71d" path="res://docs/museums/spine/examples/05-mouse-following/mouse-following.gd" id="2_34rgh"]
|
||||
|
||||
[node name="Node2D" type="Node2D" unique_id=1482411552]
|
||||
script = ExtResource("2_34rgh")
|
||||
|
||||
[node name="Spineboy" type="SpineSprite" parent="." unique_id=1478267410]
|
||||
skeleton_data_res = ExtResource("2")
|
||||
preview_skin = "Default"
|
||||
preview_animation = "-- Empty --"
|
||||
preview_frame = false
|
||||
preview_time = 0.0
|
||||
position = Vector2(147, 493)
|
||||
scale = Vector2(0.5, 0.5)
|
||||
|
||||
[node name="CrosshairBone" type="SpineBoneNode" parent="Spineboy" unique_id=292478074]
|
||||
bone_mode = 1
|
||||
bone_name = "crosshair"
|
||||
show_behind_parent = true
|
||||
position = Vector2(302.333, -569.714)
|
||||
rotation = -0.000872665
|
||||
@@ -0,0 +1,5 @@
|
||||
extends Node2D
|
||||
|
||||
func _ready():
|
||||
var spineboy: SpineSprite = $Spineboy
|
||||
spineboy.get_animation_state().set_animation("walk", true, 0)
|
||||
@@ -0,0 +1 @@
|
||||
uid://jn3m3i55x7gg
|
||||
@@ -0,0 +1,27 @@
|
||||
[gd_scene format=3 uid="uid://bir7yvf0qwdge"]
|
||||
|
||||
[ext_resource type="SpineSkeletonDataResource" uid="uid://cb6rn6vonqbx0" path="res://docs/museums/spine/assets/spineboy/spineboy-data-res.tres" id="1"]
|
||||
[ext_resource type="Script" uid="uid://jn3m3i55x7gg" path="res://docs/museums/spine/examples/06-bone-following/bone-following.gd" id="2"]
|
||||
[ext_resource type="Texture2D" uid="uid://dooue2ov32xt3" path="res://icon.svg" id="3"]
|
||||
|
||||
[node name="Node2D" type="Node2D" unique_id=965182892]
|
||||
script = ExtResource("2")
|
||||
|
||||
[node name="Spineboy" type="SpineSprite" parent="." unique_id=2084711622]
|
||||
skeleton_data_res = ExtResource("1")
|
||||
preview_skin = "Default"
|
||||
preview_animation = ""
|
||||
preview_frame = false
|
||||
preview_time = 0.0
|
||||
position = Vector2(478, 483)
|
||||
scale = Vector2(0.58461, 0.58461)
|
||||
|
||||
[node name="GunTipBone" type="SpineBoneNode" parent="Spineboy" unique_id=1826381494]
|
||||
bone_name = "gun-tip"
|
||||
show_behind_parent = true
|
||||
position = Vector2(214.34015, -162.08942)
|
||||
rotation = 0.7131082
|
||||
scale = Vector2(0.9999999, -1.0000001)
|
||||
|
||||
[node name="Sprite" type="Sprite2D" parent="Spineboy/GunTipBone" unique_id=2083405906]
|
||||
texture = ExtResource("3")
|
||||
11
docs/museums/spine/examples/07-slot-node/slot-node.gd
Normal file
11
docs/museums/spine/examples/07-slot-node/slot-node.gd
Normal file
@@ -0,0 +1,11 @@
|
||||
extends Node2D
|
||||
|
||||
@onready var spineboy: SpineSprite = $Spineboy
|
||||
@onready var raptor: SpineSprite = $Spineboy/GunSlot/Raptor
|
||||
@onready var tiny_spineboy: SpineSprite = $Spineboy/FrontFistSlot/TinySpineboy
|
||||
|
||||
func _ready():
|
||||
var entry = spineboy.get_animation_state().set_animation("run", true, 0)
|
||||
entry.set_time_scale(0.1)
|
||||
raptor.get_animation_state().set_animation("walk", true, 0)
|
||||
tiny_spineboy.get_animation_state().set_animation("walk", true, 0)
|
||||
@@ -0,0 +1 @@
|
||||
uid://cyqbvgy3ak4v6
|
||||
59
docs/museums/spine/examples/07-slot-node/slot-node.tscn
Normal file
59
docs/museums/spine/examples/07-slot-node/slot-node.tscn
Normal file
@@ -0,0 +1,59 @@
|
||||
[gd_scene format=3 uid="uid://bhht8dees2pyq"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cyqbvgy3ak4v6" path="res://docs/museums/spine/examples/07-slot-node/slot-node.gd" id="1"]
|
||||
[ext_resource type="SpineSkeletonDataResource" uid="uid://cb6rn6vonqbx0" path="res://docs/museums/spine/assets/spineboy/spineboy-data-res.tres" id="2"]
|
||||
[ext_resource type="SpineSkeletonDataResource" uid="uid://c53t4xfil8g8g" path="res://docs/museums/spine/assets/raptor/raptor-data.tres" id="3"]
|
||||
[ext_resource type="Texture2D" uid="uid://dooue2ov32xt3" path="res://icon.svg" id="4"]
|
||||
|
||||
[node name="Node2D" type="Node2D" unique_id=1053987390]
|
||||
script = ExtResource("1")
|
||||
|
||||
[node name="Spineboy" type="SpineSprite" parent="." unique_id=1493770367]
|
||||
skeleton_data_res = ExtResource("2")
|
||||
preview_skin = "Default"
|
||||
preview_animation = "-- Empty --"
|
||||
preview_frame = false
|
||||
preview_time = 0.0
|
||||
position = Vector2(474, 506)
|
||||
scale = Vector2(0.560712, 0.560712)
|
||||
|
||||
[node name="GunSlot" type="SpineSlotNode" parent="Spineboy" unique_id=1904042535]
|
||||
slot_name = "gun"
|
||||
show_behind_parent = true
|
||||
position = Vector2(40.8752, -276.036)
|
||||
rotation = 0.837234
|
||||
|
||||
[node name="Raptor" type="SpineSprite" parent="Spineboy/GunSlot" unique_id=37242989]
|
||||
skeleton_data_res = ExtResource("3")
|
||||
preview_skin = "Default"
|
||||
preview_animation = "-- Empty --"
|
||||
preview_frame = false
|
||||
preview_time = 0.0
|
||||
position = Vector2(84.6909, -67.9174)
|
||||
scale = Vector2(0.193472, 0.193472)
|
||||
|
||||
[node name="EyeSlot" type="SpineSlotNode" parent="Spineboy" unique_id=258812187]
|
||||
slot_name = "eye"
|
||||
show_behind_parent = true
|
||||
position = Vector2(-23.4598, -402.301)
|
||||
rotation = -1.71793
|
||||
|
||||
[node name="Sprite" type="Sprite2D" parent="Spineboy/EyeSlot" unique_id=188427405]
|
||||
position = Vector2(84.4734, 43.4469)
|
||||
rotation = 1.66344
|
||||
texture = ExtResource("4")
|
||||
|
||||
[node name="FrontFistSlot" type="SpineSlotNode" parent="Spineboy" unique_id=171733589]
|
||||
slot_name = "front-fist"
|
||||
show_behind_parent = true
|
||||
position = Vector2(-29.0298, -241.577)
|
||||
rotation = 0.995187
|
||||
|
||||
[node name="TinySpineboy" type="SpineSprite" parent="Spineboy/FrontFistSlot" unique_id=1500136576]
|
||||
skeleton_data_res = ExtResource("2")
|
||||
preview_skin = "Default"
|
||||
preview_animation = "-- Empty --"
|
||||
preview_frame = false
|
||||
preview_time = 0.0
|
||||
position = Vector2(-2.64624, -10.8111)
|
||||
scale = Vector2(0.193389, 0.193389)
|
||||
@@ -0,0 +1,33 @@
|
||||
extends Node2D
|
||||
|
||||
@onready var player = $AnimationPlayer
|
||||
@onready var spineboy = $Spineboy
|
||||
|
||||
var speed = 400;
|
||||
var velocity_x = 0;
|
||||
|
||||
func _ready():
|
||||
player.play("cutscene")
|
||||
pass
|
||||
|
||||
func _process(delta):
|
||||
if (!player.is_playing()):
|
||||
if Input.is_action_just_released("ui_left"):
|
||||
spineboy.get_animation_state().set_animation("idle", true, 0)
|
||||
velocity_x = 0
|
||||
|
||||
if Input.is_action_just_released("ui_right"):
|
||||
spineboy.get_animation_state().set_animation("idle", true, 0)
|
||||
velocity_x = 0
|
||||
|
||||
if (Input.is_action_just_pressed("ui_right")):
|
||||
spineboy.get_animation_state().set_animation("run", true, 0)
|
||||
spineboy.get_skeleton().set_scale_x(1)
|
||||
velocity_x = 1
|
||||
|
||||
if Input.is_action_just_pressed("ui_left"):
|
||||
spineboy.get_animation_state().set_animation("run", true, 0)
|
||||
spineboy.get_skeleton().set_scale_x(-1)
|
||||
velocity_x = -1
|
||||
|
||||
spineboy.position.x += velocity_x * speed * delta
|
||||
@@ -0,0 +1 @@
|
||||
uid://dq4tj8mk4vpqh
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,44 @@
|
||||
[gd_scene format=3 uid="uid://b4p2vn7bwm52a"]
|
||||
|
||||
[ext_resource type="SpineSkeletonDataResource" uid="uid://cb6rn6vonqbx0" path="res://docs/museums/spine/assets/spineboy/spineboy-data-res.tres" id="1"]
|
||||
|
||||
[sub_resource type="Shader" id="1"]
|
||||
code = "shader_type canvas_item;
|
||||
|
||||
void fragment() {
|
||||
COLOR = texture(TEXTURE, UV);
|
||||
COLOR.r = 0.0;
|
||||
}"
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="2"]
|
||||
shader = SubResource("1")
|
||||
|
||||
[sub_resource type="Shader" id="3"]
|
||||
code = "shader_type canvas_item;
|
||||
|
||||
void fragment() {
|
||||
COLOR = texture(TEXTURE, UV);
|
||||
COLOR.b = 0.0;
|
||||
}"
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="4"]
|
||||
shader = SubResource("3")
|
||||
|
||||
[node name="Node2D" type="Node2D" unique_id=128822378]
|
||||
|
||||
[node name="SpineSprite" type="SpineSprite" parent="." unique_id=1332652767]
|
||||
skeleton_data_res = ExtResource("1")
|
||||
normal_material = SubResource("2")
|
||||
preview_skin = "Default"
|
||||
preview_animation = "-- Empty --"
|
||||
preview_frame = false
|
||||
preview_time = 0.0
|
||||
position = Vector2(501, 507)
|
||||
scale = Vector2(0.546374, 0.546373)
|
||||
|
||||
[node name="GunSlot" type="SpineSlotNode" parent="SpineSprite" unique_id=1275601575]
|
||||
normal_material = SubResource("4")
|
||||
slot_name = "gun"
|
||||
show_behind_parent = true
|
||||
position = Vector2(40.8753, -276.036)
|
||||
rotation = 0.837234
|
||||
@@ -0,0 +1,4 @@
|
||||
extends Node2D
|
||||
|
||||
func _ready():
|
||||
$SpineSprite.get_animation_state().set_animation("walk");
|
||||
@@ -0,0 +1 @@
|
||||
uid://dhqla6kxkv0ce
|
||||
27
docs/museums/spine/examples/10-2d-lighting/2d-lighting.tscn
Normal file
27
docs/museums/spine/examples/10-2d-lighting/2d-lighting.tscn
Normal file
@@ -0,0 +1,27 @@
|
||||
[gd_scene format=3 uid="uid://rt2llskmx7xm"]
|
||||
|
||||
[ext_resource type="SpineSkeletonDataResource" uid="uid://c53t4xfil8g8g" path="res://docs/museums/spine/assets/raptor/raptor-data.tres" id="1"]
|
||||
[ext_resource type="Texture2D" uid="uid://cggfs567rn1ay" path="res://docs/museums/spine/assets/raptor/light-sprite.png" id="2"]
|
||||
[ext_resource type="Script" uid="uid://dhqla6kxkv0ce" path="res://docs/museums/spine/examples/10-2d-lighting/2d-lighting.gd" id="3"]
|
||||
|
||||
[node name="Node2D" type="Node2D" unique_id=1849486266]
|
||||
script = ExtResource("3")
|
||||
|
||||
[node name="SpineSprite" type="SpineSprite" parent="." unique_id=967171539]
|
||||
skeleton_data_res = ExtResource("1")
|
||||
preview_skin = "Default"
|
||||
preview_animation = "-- Empty --"
|
||||
preview_frame = false
|
||||
preview_time = 0.0
|
||||
position = Vector2(576, 506)
|
||||
scale = Vector2(0.458967, 0.458967)
|
||||
|
||||
[node name="Light2D" type="PointLight2D" parent="." unique_id=447652711]
|
||||
position = Vector2(691, 283)
|
||||
scale = Vector2(1.51563, 1.51563)
|
||||
color = Color(1, 0.0117647, 0.0117647, 1)
|
||||
texture = ExtResource("2")
|
||||
height = 100.0
|
||||
|
||||
[node name="CanvasModulate" type="CanvasModulate" parent="." unique_id=1888774714]
|
||||
color = Color(0.223529, 0.160784, 0.160784, 1)
|
||||
26
docs/museums/spine/examples/11-bone-node/bone-node.gd
Normal file
26
docs/museums/spine/examples/11-bone-node/bone-node.gd
Normal file
@@ -0,0 +1,26 @@
|
||||
extends Node2D
|
||||
|
||||
@onready var spineboy = $SpineSprite
|
||||
@onready var center_bone = $SpineSprite/HoverboardCenterBone
|
||||
@onready var center_ray = $SpineSprite/HoverboardCenterBone/CenterRay
|
||||
@onready var target_bone = $SpineSprite/HoverboardTargetBone
|
||||
@onready var target_ray = $SpineSprite/HoverboardTargetBone/TargetRay
|
||||
@onready var hip_bone = $SpineSprite/HipBone
|
||||
var center_hip_distance = 0
|
||||
|
||||
func _ready():
|
||||
spineboy.get_animation_state().set_animation("hoverboard", true, 0)
|
||||
spineboy.update_skeleton(0);
|
||||
center_hip_distance = hip_bone.global_position.y - center_bone.global_position.y
|
||||
|
||||
func _physics_process(delta):
|
||||
if target_ray.is_colliding():
|
||||
target_bone.global_position.y = target_ray.get_collision_point().y - 30
|
||||
|
||||
if center_ray.is_colliding():
|
||||
center_bone.global_position.y = center_ray.get_collision_point().y - 30
|
||||
|
||||
if abs(hip_bone.global_position.y - center_bone.global_position.y) - abs(center_hip_distance) < 20:
|
||||
hip_bone.global_position.y = center_bone.global_position.y + center_hip_distance
|
||||
|
||||
spineboy.global_position.x += delta * 150;
|
||||
@@ -0,0 +1 @@
|
||||
uid://dpp8doijia0ii
|
||||
53
docs/museums/spine/examples/11-bone-node/bone-node.tscn
Normal file
53
docs/museums/spine/examples/11-bone-node/bone-node.tscn
Normal file
@@ -0,0 +1,53 @@
|
||||
[gd_scene format=3 uid="uid://chrw4i0nksphn"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dpp8doijia0ii" path="res://docs/museums/spine/examples/11-bone-node/bone-node.gd" id="1"]
|
||||
[ext_resource type="SpineSkeletonDataResource" uid="uid://cb6rn6vonqbx0" path="res://docs/museums/spine/assets/spineboy/spineboy-data-res.tres" id="2"]
|
||||
|
||||
[node name="Node2D" type="Node2D" unique_id=367328645]
|
||||
script = ExtResource("1")
|
||||
|
||||
[node name="SpineSprite" type="SpineSprite" parent="." unique_id=1148185683]
|
||||
skeleton_data_res = ExtResource("2")
|
||||
update_mode = 1
|
||||
preview_skin = "Default"
|
||||
preview_animation = "hoverboard"
|
||||
preview_frame = true
|
||||
preview_time = 0.0
|
||||
position = Vector2(13, 569)
|
||||
scale = Vector2(0.278096, 0.278096)
|
||||
|
||||
[node name="HoverboardCenterBone" type="SpineBoneNode" parent="SpineSprite" unique_id=727054300]
|
||||
bone_mode = 1
|
||||
bone_name = "hoverboard-controller"
|
||||
show_behind_parent = true
|
||||
position = Vector2(-10.1996, -68.2213)
|
||||
rotation = -0.00403465
|
||||
|
||||
[node name="CenterRay" type="RayCast2D" parent="SpineSprite/HoverboardCenterBone" unique_id=1808453320]
|
||||
target_position = Vector2(0, 10000)
|
||||
|
||||
[node name="HoverboardTargetBone" type="SpineBoneNode" parent="SpineSprite" unique_id=1807276564]
|
||||
bone_mode = 1
|
||||
bone_name = "board-ik"
|
||||
show_behind_parent = true
|
||||
position = Vector2(258.903, -71.9176)
|
||||
rotation = -0.000872665
|
||||
|
||||
[node name="TargetRay" type="RayCast2D" parent="SpineSprite/HoverboardTargetBone" unique_id=1417066321]
|
||||
position = Vector2(-3.59872, 3.59277)
|
||||
target_position = Vector2(0, 10000)
|
||||
|
||||
[node name="HipBone" type="SpineBoneNode" parent="SpineSprite" unique_id=1093270661]
|
||||
bone_mode = 1
|
||||
bone_name = "hip"
|
||||
show_behind_parent = true
|
||||
position = Vector2(-53.7338, -279.363)
|
||||
rotation = -0.000872665
|
||||
|
||||
[node name="Polygon2D" type="Polygon2D" parent="." unique_id=877226877]
|
||||
polygon = PackedVector2Array(0, 596, 309, 471, 516, 515, 762, 447, 984, 504, 1023, 505, 1024, 596)
|
||||
|
||||
[node name="StaticBody2D" type="StaticBody2D" parent="Polygon2D" unique_id=114416425]
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Polygon2D/StaticBody2D" unique_id=1562584718]
|
||||
polygon = PackedVector2Array(3, 592, 304, 469, 516, 514, 762, 443, 984, 499, 1252, 498, 1280, 596)
|
||||
32
docs/museums/spine/examples/12-physics/physics.gd
Normal file
32
docs/museums/spine/examples/12-physics/physics.gd
Normal file
@@ -0,0 +1,32 @@
|
||||
extends Node2D
|
||||
|
||||
@onready var celestial_circus: SpineSprite = $"celestial-circus"
|
||||
|
||||
var last_x = -1
|
||||
var last_y = -1
|
||||
var isMouseOver = false
|
||||
|
||||
func _ready():
|
||||
celestial_circus.get_animation_state().set_animation("wind-idle", true, 0)
|
||||
celestial_circus.get_animation_state().set_animation("eyeblink-long", true, 1)
|
||||
celestial_circus.get_animation_state().set_animation("stars", true, 2)
|
||||
|
||||
func _process(_delta):
|
||||
if (Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT) and isMouseOver):
|
||||
var pos = get_viewport().get_mouse_position()
|
||||
if (last_x != -1):
|
||||
var dx = pos.x - last_x
|
||||
var dy = pos.y - last_y
|
||||
celestial_circus.global_position += Vector2(dx, dy)
|
||||
celestial_circus.get_skeleton().physics_translate(dx * 1 / celestial_circus.scale.x, dy * 1 / celestial_circus.scale.y)
|
||||
last_x = pos.x
|
||||
last_y = pos.y
|
||||
else:
|
||||
last_x = -1
|
||||
last_y = -1
|
||||
|
||||
func _on_area_2d_mouse_entered():
|
||||
isMouseOver = true
|
||||
|
||||
func _on_area_2d_mouse_exited():
|
||||
isMouseOver = false
|
||||
1
docs/museums/spine/examples/12-physics/physics.gd.uid
Normal file
1
docs/museums/spine/examples/12-physics/physics.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://0uo0citk3n4f
|
||||
31
docs/museums/spine/examples/12-physics/physics.tscn
Normal file
31
docs/museums/spine/examples/12-physics/physics.tscn
Normal file
@@ -0,0 +1,31 @@
|
||||
[gd_scene format=3 uid="uid://re2mg31p3vln"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://0uo0citk3n4f" path="res://docs/museums/spine/examples/12-physics/physics.gd" id="1_7guqn"]
|
||||
[ext_resource type="SpineSkeletonDataResource" uid="uid://d1ordmjpe5kt7" path="res://docs/museums/spine/assets/celestial-circus/celestial-circus-data.tres" id="2_t2blj"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_do8w3"]
|
||||
size = Vector2(270, 573)
|
||||
|
||||
[node name="Node2D" type="Node2D" unique_id=165002328]
|
||||
script = ExtResource("1_7guqn")
|
||||
|
||||
[node name="celestial-circus" type="SpineSprite" parent="." unique_id=2141137119]
|
||||
skeleton_data_res = ExtResource("2_t2blj")
|
||||
preview_skin = "Default"
|
||||
preview_animation = "-- Empty --"
|
||||
preview_frame = false
|
||||
preview_time = 0.0
|
||||
position = Vector2(600, 485)
|
||||
scale = Vector2(0.25, 0.25)
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="celestial-circus" unique_id=525144279]
|
||||
show_behind_parent = true
|
||||
scale = Vector2(4, 4)
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="celestial-circus/Area2D" unique_id=1673342862]
|
||||
show_behind_parent = true
|
||||
position = Vector2(0, -158.5)
|
||||
shape = SubResource("RectangleShape2D_do8w3")
|
||||
|
||||
[connection signal="mouse_entered" from="celestial-circus/Area2D" to="." method="_on_area_2d_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="celestial-circus/Area2D" to="." method="_on_area_2d_mouse_exited"]
|
||||
@@ -0,0 +1,6 @@
|
||||
[gd_scene format=3 uid="uid://dr1u7vj8mm6ed"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cvtny4hsitjbo" path="res://docs/museums/spine/examples/13-load-from-disk/load_from_disk.gd" id="1_krs2n"]
|
||||
|
||||
[node name="Load-from-disk" type="Node2D" unique_id=41040463]
|
||||
script = ExtResource("1_krs2n")
|
||||
@@ -0,0 +1,24 @@
|
||||
extends Node2D
|
||||
|
||||
func _ready():
|
||||
# Load the skeleton file
|
||||
var skeleton_file_res = SpineSkeletonFileResource.new();
|
||||
skeleton_file_res.load_from_file("/Users/badlogic/workspaces/spine-runtimes/examples/coin/export/coin-pro.skel");
|
||||
|
||||
# Load the atlas file
|
||||
var atlas_res = SpineAtlasResource.new();
|
||||
atlas_res.load_from_atlas_file("/Users/badlogic/workspaces/spine-runtimes/examples/coin/export/coin.atlas");
|
||||
|
||||
# Create a skeleton data resource, you can share this across multiple sprites
|
||||
var skeleton_data_res = SpineSkeletonDataResource.new();
|
||||
skeleton_data_res.skeleton_file_res = skeleton_file_res;
|
||||
skeleton_data_res.atlas_res = atlas_res
|
||||
|
||||
# Create a sprite from the skeleton data and add it as a child
|
||||
var sprite = SpineSprite.new();
|
||||
sprite.skeleton_data_res = skeleton_data_res;
|
||||
sprite.position.x = 200;
|
||||
sprite.position.y = 200;
|
||||
sprite.get_animation_state().set_animation("animation", true, 0);
|
||||
self.add_child(sprite)
|
||||
pass
|
||||
@@ -0,0 +1 @@
|
||||
uid://cvtny4hsitjbo
|
||||
Reference in New Issue
Block a user