-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
4.2 physics example for the spine-godot and the spine-ue runtime (#2497)
* Add a new example level '10-physics' and assets of celestial-circus * Fixed typos and grammatical errors in comments * Add a new example scene to example-v4 * Add a new example scene to example-v4-charp * Add a new example scene to example
- Loading branch information
1 parent
11c0bf8
commit 439991e
Showing
38 changed files
with
1,108 additions
and
1 deletion.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
spine-godot/example-v4-csharp/assets/celestial-circus/celestial-circus-data.tres
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[gd_resource type="SpineSkeletonDataResource" load_steps=3 format=3 uid="uid://ivqmuytdfvde"] | ||
|
||
[ext_resource type="SpineAtlasResource" uid="uid://cybfgp4juu2hn" path="res://assets/celestial-circus/celestial-circus.atlas" id="1_fivh8"] | ||
[ext_resource type="SpineSkeletonFileResource" uid="uid://rr3h7cd7a3d5" path="res://assets/celestial-circus/celestial-circus.skel" id="2_gq3wo"] | ||
|
||
[resource] | ||
atlas_res = ExtResource("1_fivh8") | ||
skeleton_file_res = ExtResource("2_gq3wo") |
169 changes: 169 additions & 0 deletions
169
spine-godot/example-v4-csharp/assets/celestial-circus/celestial-circus.atlas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
celestial-circus.png | ||
size:984,1032 | ||
filter:Linear,Linear | ||
scale:0.4 | ||
arm-back-down | ||
bounds:774,7,38,82 | ||
rotate:90 | ||
arm-back-up | ||
bounds:819,437,83,116 | ||
rotate:90 | ||
arm-front-down | ||
bounds:863,49,36,78 | ||
arm-front-up | ||
bounds:784,47,77,116 | ||
bench | ||
bounds:798,668,189,48 | ||
rotate:90 | ||
body-bottom | ||
bounds:724,165,154,124 | ||
rotate:90 | ||
body-top | ||
bounds:819,522,126,132 | ||
offsets:0,0,126,133 | ||
chest | ||
bounds:848,656,104,93 | ||
rotate:90 | ||
cloud-back | ||
bounds:520,154,202,165 | ||
cloud-front | ||
bounds:492,411,325,196 | ||
collar | ||
bounds:935,108,47,26 | ||
ear | ||
bounds:462,789,20,28 | ||
rotate:90 | ||
eye-back-shadow | ||
bounds:947,522,14,10 | ||
rotate:90 | ||
eye-front-shadow | ||
bounds:819,411,24,14 | ||
rotate:90 | ||
eye-reflex-back | ||
bounds:774,55,8,7 | ||
eye-reflex-front | ||
bounds:841,321,10,7 | ||
rotate:90 | ||
eye-white-back | ||
bounds:214,322,13,16 | ||
rotate:90 | ||
eye-white-front | ||
bounds:348,2,22,17 | ||
rotate:90 | ||
eyelashes-down-back | ||
bounds:214,314,11,6 | ||
eyelashes-down-front | ||
bounds:943,721,15,6 | ||
rotate:90 | ||
eyelashes-top-back | ||
bounds:816,656,18,10 | ||
eyelashes-top-front | ||
bounds:798,636,30,16 | ||
rotate:90 | ||
face | ||
bounds:841,333,91,102 | ||
offsets:2,0,93,102 | ||
feathers-back | ||
bounds:444,811,46,46 | ||
feathers-front | ||
bounds:767,323,72,86 | ||
fringe-middle-back | ||
bounds:929,54,33,52 | ||
fringe-middle-front | ||
bounds:575,2,60,50 | ||
rotate:90 | ||
fringe-side-back | ||
bounds:848,763,27,94 | ||
fringe-side-front | ||
bounds:901,34,26,93 | ||
glove-bottom-back | ||
bounds:941,403,51,41 | ||
rotate:90 | ||
glove-bottom-front | ||
bounds:935,136,47,48 | ||
hair-back-1 | ||
bounds:214,6,132,306 | ||
hair-back-2 | ||
bounds:438,27,80,285 | ||
hair-back-3 | ||
bounds:879,762,70,268 | ||
hair-back-4 | ||
bounds:520,64,88,262 | ||
rotate:90 | ||
hair-back-5 | ||
bounds:486,321,88,279 | ||
rotate:90 | ||
hair-back-6 | ||
bounds:348,26,88,286 | ||
hair-hat-shadow | ||
bounds:850,186,89,41 | ||
offsets:1,0,90,41 | ||
hand-back | ||
bounds:627,2,60,47 | ||
rotate:90 | ||
hand-front | ||
bounds:520,2,53,60 | ||
hat-back | ||
bounds:937,456,64,45 | ||
rotate:90 | ||
hat-front | ||
bounds:676,6,96,56 | ||
head-back | ||
bounds:850,229,102,86 | ||
rotate:90 | ||
jabot | ||
bounds:863,129,70,55 | ||
leg-back | ||
bounds:2,2,210,333 | ||
leg-front | ||
bounds:232,462,258,320 | ||
logo-brooch | ||
bounds:444,784,16,25 | ||
mouth | ||
bounds:943,738,22,6 | ||
rotate:90 | ||
neck | ||
bounds:938,278,39,56 | ||
nose | ||
bounds:943,712,6,7 | ||
nose-highlight | ||
bounds:486,456,4,4 | ||
nose-shadow | ||
bounds:724,155,7,8 | ||
pupil-back | ||
bounds:972,228,10,14 | ||
pupil-front | ||
bounds:964,94,12,18 | ||
rotate:90 | ||
rope-back | ||
bounds:951,538,10,492 | ||
rope-front | ||
bounds:951,538,10,492 | ||
rope-front-bottom | ||
bounds:934,336,42,65 | ||
skirt | ||
bounds:2,784,440,246 | ||
sock-bow | ||
bounds:938,244,33,32 | ||
spine-logo-body | ||
bounds:938,229,13,32 | ||
rotate:90 | ||
star-big | ||
bounds:963,1007,17,23 | ||
offsets:1,0,18,24 | ||
star-medium | ||
bounds:774,47,6,8 | ||
rotate:90 | ||
star-small | ||
bounds:462,784,3,4 | ||
rotate:90 | ||
underskirt | ||
bounds:2,337,445,228 | ||
rotate:90 | ||
underskirt-back | ||
bounds:444,859,433,171 | ||
wing-back | ||
bounds:232,314,146,252 | ||
rotate:90 | ||
wing-front | ||
bounds:492,609,304,248 |
15 changes: 15 additions & 0 deletions
15
spine-godot/example-v4-csharp/assets/celestial-circus/celestial-circus.atlas.import
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[remap] | ||
|
||
importer="spine.atlas" | ||
type="SpineAtlasResource" | ||
uid="uid://cybfgp4juu2hn" | ||
path="res://.godot/imported/celestial-circus.atlas-8277f39286d729eed930dc8584632c9d.spatlas" | ||
|
||
[deps] | ||
|
||
source_file="res://assets/celestial-circus/celestial-circus.atlas" | ||
dest_files=["res://.godot/imported/celestial-circus.atlas-8277f39286d729eed930dc8584632c9d.spatlas"] | ||
|
||
[params] | ||
|
||
normal_map_prefix="n" |
Binary file added
BIN
+1.01 MB
spine-godot/example-v4-csharp/assets/celestial-circus/celestial-circus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions
34
spine-godot/example-v4-csharp/assets/celestial-circus/celestial-circus.png.import
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[remap] | ||
|
||
importer="texture" | ||
type="CompressedTexture2D" | ||
uid="uid://clhc1actm0381" | ||
path="res://.godot/imported/celestial-circus.png-362082edc9ee92c57423ee448ab8be8a.ctex" | ||
metadata={ | ||
"vram_texture": false | ||
} | ||
|
||
[deps] | ||
|
||
source_file="res://assets/celestial-circus/celestial-circus.png" | ||
dest_files=["res://.godot/imported/celestial-circus.png-362082edc9ee92c57423ee448ab8be8a.ctex"] | ||
|
||
[params] | ||
|
||
compress/mode=0 | ||
compress/high_quality=false | ||
compress/lossy_quality=0.7 | ||
compress/hdr_compression=1 | ||
compress/normal_map=0 | ||
compress/channel_pack=0 | ||
mipmaps/generate=false | ||
mipmaps/limit=-1 | ||
roughness/mode=0 | ||
roughness/src_normal="" | ||
process/fix_alpha_border=true | ||
process/premult_alpha=false | ||
process/normal_map_invert_y=false | ||
process/hdr_as_srgb=false | ||
process/hdr_clamp_exposure=false | ||
process/size_limit=0 | ||
detect_3d/compress_to=1 |
Binary file added
BIN
+51.3 KB
spine-godot/example-v4-csharp/assets/celestial-circus/celestial-circus.skel
Binary file not shown.
14 changes: 14 additions & 0 deletions
14
spine-godot/example-v4-csharp/assets/celestial-circus/celestial-circus.skel.import
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[remap] | ||
|
||
importer="spine.skel" | ||
type="SpineSkeletonFileResource" | ||
uid="uid://rr3h7cd7a3d5" | ||
path="res://.godot/imported/celestial-circus.skel-57e15df02c4ab2ec1bbb6a38273235f3.spskel" | ||
|
||
[deps] | ||
|
||
source_file="res://assets/celestial-circus/celestial-circus.skel" | ||
dest_files=["res://.godot/imported/celestial-circus.skel-57e15df02c4ab2ec1bbb6a38273235f3.spskel"] | ||
|
||
[params] | ||
|
48 changes: 48 additions & 0 deletions
48
spine-godot/example-v4-csharp/examples/12-physics/physics.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using Godot; | ||
using System; | ||
|
||
public partial class physics : Node2D | ||
{ | ||
private SpineSprite celestial_circus; | ||
|
||
private float last_x = -1; | ||
private float last_y = -1; | ||
private bool isMouseOver = false; | ||
|
||
public override void _Ready() | ||
{ | ||
celestial_circus = GetNode<SpineSprite>("celestial-circus"); | ||
celestial_circus.GetAnimationState().SetAnimation("wind-idle", true, 0); | ||
celestial_circus.GetAnimationState().SetAnimation("eyeblink-long", true, 1); | ||
celestial_circus.GetAnimationState().SetAnimation("stars", true, 2); | ||
} | ||
|
||
public override void _Process(double delta) | ||
{ | ||
if (Input.IsMouseButtonPressed(MouseButton.Left) && isMouseOver){ | ||
var pos = GetViewport().GetMousePosition(); | ||
if(last_x != -1){ | ||
var dx = pos.X - last_x; | ||
var dy = pos.Y - last_y; | ||
celestial_circus.GlobalPosition += new Vector2(dx, dy); | ||
celestial_circus.GetSkeleton().PhysicsTranslate(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; | ||
} | ||
} | ||
|
||
private void _on_area_2d_mouse_entered() | ||
{ | ||
isMouseOver = true; | ||
} | ||
|
||
private void _on_area_2d_mouse_exited() | ||
{ | ||
isMouseOver = false; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
spine-godot/example-v4-csharp/examples/12-physics/physics.tscn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
[gd_scene load_steps=4 format=3 uid="uid://re2mg31p3vln"] | ||
|
||
[ext_resource type="Script" path="res://examples/12-physics/physics.cs" id="1_t1cxt"] | ||
[ext_resource type="SpineSkeletonDataResource" uid="uid://ivqmuytdfvde" path="res://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"] | ||
script = ExtResource("1_t1cxt") | ||
|
||
[node name="celestial-circus" type="SpineSprite" parent="."] | ||
position = Vector2(600, 485) | ||
scale = Vector2(0.25, 0.25) | ||
skeleton_data_res = ExtResource("2_t2blj") | ||
preview_skin = "Default" | ||
preview_animation = "-- Empty --" | ||
preview_frame = false | ||
preview_time = 0.0 | ||
|
||
[node name="Area2D" type="Area2D" parent="celestial-circus"] | ||
show_behind_parent = true | ||
scale = Vector2(4, 4) | ||
|
||
[node name="CollisionShape2D" type="CollisionShape2D" parent="celestial-circus/Area2D"] | ||
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"] |
8 changes: 8 additions & 0 deletions
8
spine-godot/example-v4/assets/celestial-circus/celestial-circus-data.tres
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[gd_resource type="SpineSkeletonDataResource" load_steps=3 format=3 uid="uid://d1ordmjpe5kt7"] | ||
|
||
[ext_resource type="SpineAtlasResource" uid="uid://syvy0bxbnwgi" path="res://assets/celestial-circus/celestial-circus.atlas" id="1_fs1an"] | ||
[ext_resource type="SpineSkeletonFileResource" uid="uid://doan7yl2by7vm" path="res://assets/celestial-circus/celestial-circus.skel" id="2_sbom4"] | ||
|
||
[resource] | ||
atlas_res = ExtResource("1_fs1an") | ||
skeleton_file_res = ExtResource("2_sbom4") |
Oops, something went wrong.