Reposition camera, add text to stacks

This commit is contained in:
Hamcha 2019-05-07 01:25:08 +02:00
parent 69e0f4ce75
commit f398d6cefa
Signed by: hamcha
GPG key ID: A40413D21021EAEE
5 changed files with 83 additions and 5 deletions

View file

@ -18,11 +18,12 @@ size = Vector2( 16, 9 )
script = ExtResource( 1 ) script = ExtResource( 1 )
[node name="Camera" type="Camera" parent="."] [node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 0.367808, 0.929902, 0, -0.929902, 0.367808, 0, 5.05934, 3.29185 ) transform = Transform( 1, 0, 0, 0, 0.224381, 0.974502, 0, -0.974502, 0.224381, 0, 8.4261, 2.52658 )
fov = 50.0
script = ExtResource( 2 ) script = ExtResource( 2 )
[node name="Hand" type="Spatial" parent="Camera"] [node name="Hand" type="Spatial" parent="Camera"]
transform = Transform( 0.4, 0, 0, 0, 0, -0.4, 0, 0.4, 0, 0, -0.552465, -0.87444 ) transform = Transform( 0.4, 0, 0, 0, 2.98023e-008, -0.4, 0, 0.4, 2.98023e-008, 0, -0.6, -1.3 )
[node name="MeshInstance" type="MeshInstance" parent="."] [node name="MeshInstance" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.001, 0 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.001, 0 )
@ -34,3 +35,13 @@ material/0 = null
[node name="Cards" type="Spatial" parent="."] [node name="Cards" type="Spatial" parent="."]
[node name="Deck" parent="Cards" instance=ExtResource( 5 )] [node name="Deck" parent="Cards" instance=ExtResource( 5 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -4.30889, 0, 3.52858 )
title = "Deck"
[node name="Graveyard" parent="Cards" instance=ExtResource( 5 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -5.23371, 0, 3.52858 )
title = "Graveyard"
[node name="Banished" parent="Cards" instance=ExtResource( 5 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -5.23371, 0, 2.40401 )
title = "Banished"

View file

@ -0,0 +1,9 @@
extends Spatial
export var title: String
func _ready():
set_title(title)
func set_title(title: String):
$LabelViewport/Label.text = title

View file

@ -1,3 +1,60 @@
[gd_scene format=2] [gd_scene load_steps=5 format=2]
[ext_resource path="res://Scenes/Components/Stack.gd" type="Script" id=1]
[sub_resource type="DynamicFontData" id=2]
font_path = "res://UIAssets/Fonts/Catamaran-Bold.ttf"
[sub_resource type="DynamicFont" id=3]
outline_size = 2
outline_color = Color( 0, 0, 0, 0.54902 )
font_data = SubResource( 2 )
[sub_resource type="ViewportTexture" id=1]
viewport_path = NodePath("LabelViewport")
[node name="Stack" type="Spatial"] [node name="Stack" type="Spatial"]
script = ExtResource( 1 )
[node name="CSGBox" type="CSGBox" parent="."]
transform = Transform( 0.85598, 0, 0, 0, 1, 0, 0, 0, 0.871019, 0, 0, 0 )
width = 0.946586
height = 0.002
depth = 1.18809
[node name="CSGBox2" type="CSGBox" parent="CSGBox"]
operation = 2
width = 0.891339
height = 0.102173
depth = 1.1406
[node name="CSGBox3" type="CSGBox" parent="CSGBox"]
operation = 2
width = 0.191127
height = 0.102173
depth = 1.57935
[node name="CSGBox4" type="CSGBox" parent="CSGBox"]
transform = Transform( -4.37114e-008, 0, -1, 0, 1, 0, 1, 0, -4.37114e-008, 0, 0, 0 )
operation = 2
width = 0.650255
height = 0.102173
depth = 1.57935
[node name="LabelViewport" type="Viewport" parent="."]
size = Vector2( 100, 100 )
transparent_bg = true
handle_input_locally = false
usage = 0
[node name="Label" type="Label" parent="LabelViewport"]
anchor_right = 1.0
anchor_bottom = 1.0
custom_fonts/font = SubResource( 3 )
align = 1
valign = 1
[node name="LabelSprite" type="Sprite3D" parent="."]
transform = Transform( 0.5853, 0.810817, -3.54419e-008, 0, -4.37114e-008, -1, -0.810817, 0.5853, -2.55843e-008, 1.05839e-009, 0.0298628, 7.64017e-010 )
texture = SubResource( 1 )
region_rect = Rect2( 0, 0, 30, 30 )

View file

@ -52,8 +52,9 @@ func _process(delta: float):
camera.transform.origin = lastCameraTransform.origin - Vector3(mousePos.x, 0, mousePos.y) camera.transform.origin = lastCameraTransform.origin - Vector3(mousePos.x, 0, mousePos.y)
# If holding a card, move it between board/hand # If holding a card, move it between board/hand
if holdingCard != null: if holdingCard != null:
var relPos: float = absMousePos.y / get_viewport().size.y var relPos: Vector2 = absMousePos / get_viewport().size
var selectingHand: bool = relPos > mouseHandThreshold var xMargin = 1.0-HAND_SCREEN_PERC
var selectingHand: bool = relPos.y > mouseHandThreshold and (relPos.x > xMargin/2 and relPos.x < (1.0-xMargin/2))
if selectingHand and not holdingCard.inHand: if selectingHand and not holdingCard.inHand:
holdingCard.inHand = true holdingCard.inHand = true
call_deferred("reparent", holdingCard, cards, hand) call_deferred("reparent", holdingCard, cards, hand)

Binary file not shown.