Fix: overlap problem in bottom drop area

This commit is contained in:
2020-06-04 20:56:01 +08:00
parent 9969a04e7b
commit e2a8f66332
6 changed files with 36 additions and 27 deletions
+8 -4
View File
@@ -6,6 +6,7 @@ extends Node2D
# var b = "text"
var texture
var tiles = []
# Called when the node enters the scene tree for the first time.
@@ -16,7 +17,9 @@ func _ready():
func add_tile(suit, number):
var tile = get_tile_instance(suit, number)
add_child(tile)
show_tiles()
move_child(tile, 0)
tiles.append(tile)
# show_tiles()
func get_tile_instance(suit, number):
var tile = Sprite.new()
@@ -29,13 +32,14 @@ func get_tile_instance(suit, number):
func show_tiles():
var row = -1
for i in range(get_children().size()):
for i in range(tiles.size()):
if i % 14 == 0:
row += 1
get_children()[i].set_z_index(5-row)
get_children()[i].position = Vector2((i%14)*Constants.Tile.BOTTOM_DROP_WIDTH, -row*(Constants.Tile.BOTTOM_DROP_HEIGHT-Constants.Tile.BOTTOM_DROP_THICK))
# get_children()[i].set_z_index(5-row)
tiles[i].position = Vector2((i%14)*Constants.Tile.BOTTOM_DROP_WIDTH, -row*(Constants.Tile.BOTTOM_DROP_HEIGHT-Constants.Tile.BOTTOM_DROP_THICK))
func clear_tiles():
tiles = []
for tile in get_children():
remove_child(tile)
tile.queue_free()
+1 -1
View File
@@ -16,7 +16,7 @@ func _ready():
func add_tile(suit, number):
var tile = get_tile_instance(suit, number)
add_child(tile)
show_tiles()
func get_tile_instance(suit, number):
var tile = Sprite.new()
+1 -1
View File
@@ -16,7 +16,7 @@ func _ready():
func add_tile(suit, number):
var tile = get_tile_instance(suit, number)
add_child(tile)
show_tiles()
func get_tile_instance(suit, number):
var tile = Sprite.new()
+1 -1
View File
@@ -19,7 +19,7 @@ func add_tile(suit, number):
tiles.append(tile)
add_child(tile)
move_child(tile, 0)
show_tiles()
func get_tile_instance(suit, number):
var tile = Sprite.new()
+4
View File
@@ -270,21 +270,25 @@ func set_drop_areas(msg):
if bottom_drop_tiles!=null:
for t in bottom_drop_tiles:
$BottomDropArea.add_tile(t["suit"], t["number"])
$BottomDropArea.show_tiles()
var right_drop_tiles = msg["player_tile"][(my_table_order+1)%4]["drop_tiles"]
$RightDropArea.clear_tiles()
if right_drop_tiles!=null:
for t in right_drop_tiles:
$RightDropArea.add_tile(t["suit"], t["number"])
$RightDropArea.show_tiles()
var oppo_drop_tiles = msg["player_tile"][(my_table_order+2)%4]["drop_tiles"]
$OppositeDropArea.clear_tiles()
if oppo_drop_tiles!=null:
for t in oppo_drop_tiles:
$OppositeDropArea.add_tile(t["suit"], t["number"])
$OppositeDropArea.show_tiles()
var left_drop_tiles = msg["player_tile"][(my_table_order+3)%4]["drop_tiles"]
$LeftDropArea.clear_tiles()
if left_drop_tiles!=null:
for t in left_drop_tiles:
$LeftDropArea.add_tile(t["suit"], t["number"])
$LeftDropArea.show_tiles()
func set_timer_direction(msg):
var current_turn = msg["current_turn"]
+21 -20
View File
@@ -72,36 +72,36 @@ font_data = ExtResource( 41 )
size = 32
font_data = ExtResource( 41 )
[sub_resource type="StyleBoxTexture" id=9]
[sub_resource type="StyleBoxTexture" id=5]
texture = ExtResource( 52 )
region_rect = Rect2( 0, 0, 640, 569 )
[sub_resource type="DynamicFont" id=10]
[sub_resource type="DynamicFont" id=6]
size = 48
font_data = ExtResource( 41 )
[sub_resource type="StreamTexture" id=11]
[sub_resource type="StreamTexture" id=7]
flags = 4
load_path = "res://.import/ExitButton.png-90bb905636ba19a1a2935f9c69eb1cf7.stex"
[sub_resource type="DynamicFont" id=12]
[sub_resource type="DynamicFont" id=8]
size = 64
font_data = ExtResource( 41 )
[sub_resource type="StyleBoxTexture" id=5]
[sub_resource type="StyleBoxTexture" id=9]
texture = ExtResource( 44 )
region_rect = Rect2( 0, 0, 660, 60 )
modulate_color = Color( 1, 1, 1, 0.588235 )
[sub_resource type="DynamicFont" id=6]
[sub_resource type="DynamicFont" id=10]
size = 32
font_data = ExtResource( 41 )
[sub_resource type="StyleBoxTexture" id=7]
[sub_resource type="StyleBoxTexture" id=11]
texture = ExtResource( 52 )
region_rect = Rect2( 0, 0, 640, 569 )
[sub_resource type="DynamicFont" id=8]
[sub_resource type="DynamicFont" id=12]
size = 32
font_data = ExtResource( 41 )
@@ -276,6 +276,7 @@ script = ExtResource( 28 )
script = ExtResource( 29 )
[node name="VBoxContainer" type="VBoxContainer" parent="."]
visible = false
margin_right = 40.0
margin_bottom = 40.0
rect_scale = Vector2( 2, 4 )
@@ -700,7 +701,7 @@ one_shot = true
[node name="DisconnectDialog" type="PopupDialog" parent="."]
margin_right = 600.0
margin_bottom = 400.0
custom_styles/panel = SubResource( 9 )
custom_styles/panel = SubResource( 5 )
popup_exclusive = true
__meta__ = {
"_edit_use_anchors_": false
@@ -723,7 +724,7 @@ __meta__ = {
[node name="Label" type="Label" parent="DisconnectDialog/VBoxContainer"]
margin_right = 240.0
margin_bottom = 70.0
custom_fonts/font = SubResource( 10 )
custom_fonts/font = SubResource( 6 )
custom_colors/font_color = Color( 0, 0, 0, 1 )
text = "连接已断开"
@@ -746,7 +747,7 @@ __meta__ = {
margin_right = 90.0
margin_bottom = 122.0
rect_min_size = Vector2( 90, 122 )
texture_normal = SubResource( 11 )
texture_normal = SubResource( 7 )
expand = true
__meta__ = {
"_edit_use_anchors_": false
@@ -763,7 +764,7 @@ margin_left = 185.0
margin_top = 14.0
margin_right = 220.0
margin_bottom = 108.0
custom_fonts/font = SubResource( 12 )
custom_fonts/font = SubResource( 8 )
text = "0"
__meta__ = {
"_edit_use_anchors_": false
@@ -774,7 +775,7 @@ margin_left = 228.0
margin_top = 14.0
margin_right = 403.0
margin_bottom = 108.0
custom_fonts/font = SubResource( 12 )
custom_fonts/font = SubResource( 8 )
text = "00000"
__meta__ = {
"_edit_use_anchors_": false
@@ -797,8 +798,8 @@ __meta__ = {
margin_right = 423.0
margin_bottom = 51.0
size_flags_horizontal = 3
custom_styles/normal = SubResource( 5 )
custom_fonts/font = SubResource( 6 )
custom_styles/normal = SubResource( 9 )
custom_fonts/font = SubResource( 10 )
custom_colors/font_color = Color( 0, 0, 0, 1 )
context_menu_enabled = false
placeholder_text = "输入聊天消息"
@@ -818,31 +819,31 @@ margin_top = 251.0
margin_right = 1443.0
margin_bottom = 801.0
rect_min_size = Vector2( 950, 550 )
custom_styles/panel = SubResource( 7 )
custom_styles/panel = SubResource( 11 )
script = ExtResource( 53 )
[node name="Nickname0" type="Label" parent="ResultNode/GameResultPanel"]
margin_right = 950.0
margin_bottom = 550.0
custom_fonts/font = SubResource( 8 )
custom_fonts/font = SubResource( 12 )
custom_colors/font_color = Color( 0, 0, 0, 1 )
[node name="Nickname1" type="Label" parent="ResultNode/GameResultPanel"]
margin_right = 950.0
margin_bottom = 550.0
custom_fonts/font = SubResource( 8 )
custom_fonts/font = SubResource( 12 )
custom_colors/font_color = Color( 0, 0, 0, 1 )
[node name="Nickname2" type="Label" parent="ResultNode/GameResultPanel"]
margin_right = 950.0
margin_bottom = 550.0
custom_fonts/font = SubResource( 8 )
custom_fonts/font = SubResource( 12 )
custom_colors/font_color = Color( 0, 0, 0, 1 )
[node name="Nickname3" type="Label" parent="ResultNode/GameResultPanel"]
margin_right = 950.0
margin_bottom = 550.0
custom_fonts/font = SubResource( 8 )
custom_fonts/font = SubResource( 12 )
custom_colors/font_color = Color( 0, 0, 0, 1 )
[connection signal="pressed" from="VBoxContainer/TestButtons/StartButton" to="." method="_on_Button9_pressed"]
[connection signal="pressed" from="VBoxContainer/HBoxContainer/Button" to="." method="_on_Button_pressed"]