reveal 2 cards for oya
This commit is contained in:
parent
be42f116d7
commit
d4e5a921d8
|
@ -68,3 +68,36 @@ func _set_card_month(new_month: int) -> void:
|
||||||
|
|
||||||
func _set_card_type(new_type: int) -> void:
|
func _set_card_type(new_type: int) -> void:
|
||||||
value.type = new_type
|
value.type = new_type
|
||||||
|
|
||||||
|
func set_size(new_size: Vector2) -> void:
|
||||||
|
if not _is_ready:
|
||||||
|
yield(self, "ready")
|
||||||
|
|
||||||
|
var texture_size = $Frontside.texture.get_size()
|
||||||
|
var scale = new_size / texture_size
|
||||||
|
self.scale = scale
|
||||||
|
|
||||||
|
func set_min_dimension(dim: int) -> void:
|
||||||
|
if not _is_ready:
|
||||||
|
yield(self, "ready")
|
||||||
|
|
||||||
|
var texture_size = $Frontside.texture.get_size()
|
||||||
|
var scale = Vector2(dim, dim) / texture_size
|
||||||
|
var max_scale = max(scale.x, scale.y)
|
||||||
|
self.scale = Vector2(max_scale, max_scale)
|
||||||
|
|
||||||
|
func set_max_dimension(dim: int) -> void:
|
||||||
|
if not _is_ready:
|
||||||
|
yield(self, "ready")
|
||||||
|
|
||||||
|
var texture_size = $Frontside.texture.get_size()
|
||||||
|
var scale = Vector2(dim, dim) / texture_size
|
||||||
|
var min_scale = min(scale.x, scale.y)
|
||||||
|
self.scale = Vector2(min_scale, min_scale)
|
||||||
|
|
||||||
|
func get_size() -> Vector2:
|
||||||
|
if not _is_ready:
|
||||||
|
yield(self, "ready")
|
||||||
|
|
||||||
|
var texture_size = $Frontside.texture.get_size()
|
||||||
|
return texture_size * self.scale
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[gd_scene load_steps=5 format=2]
|
[gd_scene load_steps=5 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://HanafudaCard.gd" type="Script" id=1]
|
[ext_resource path="res://HanafudaCard.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://assets/png/Hanafuda_July_Kasu_1.png" type="Texture" id=2]
|
[ext_resource path="res://assets/png/Hanafuda_January_Hikari.png" type="Texture" id=2]
|
||||||
[ext_resource path="res://assets/png/Hanafuda_border.png" type="Texture" id=3]
|
[ext_resource path="res://assets/png/Hanafuda_border.png" type="Texture" id=3]
|
||||||
[ext_resource path="res://assets/japanese_pattern_01.png" type="Texture" id=4]
|
[ext_resource path="res://assets/japanese_pattern_01.png" type="Texture" id=4]
|
||||||
|
|
||||||
|
|
25
Main.gd
25
Main.gd
|
@ -10,19 +10,30 @@ func _ready():
|
||||||
|
|
||||||
func oya():
|
func oya():
|
||||||
tween.start()
|
tween.start()
|
||||||
|
var deck_position = Vector2(10, 10)
|
||||||
|
var card_reveal_duration = 0.5
|
||||||
|
var card_dim = 150
|
||||||
|
|
||||||
var card_1 = HanafudaCard.instance().init_card($Deck.draw_card())
|
var card_1 = HanafudaCard.instance().init_card($Deck.draw_card())
|
||||||
|
card_1.set_min_dimension(card_dim)
|
||||||
add_child(card_1)
|
add_child(card_1)
|
||||||
# card_1.show()
|
|
||||||
|
var card_size = card_1.get_size()
|
||||||
|
var padding = 20
|
||||||
|
var delta_x = (card_size.x + padding) / 2
|
||||||
|
|
||||||
tween.interpolate_property(card_1, "position",
|
tween.interpolate_property(card_1, "position",
|
||||||
Vector2(0, 0), Vector2(100, 100), 3,
|
deck_position, Vector2(get_viewport().size.x / 2 - delta_x, get_viewport().size.y / 2),
|
||||||
|
card_reveal_duration,
|
||||||
Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
|
Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
|
||||||
|
|
||||||
# var card_2 = $Deck.card($Deck.draw_card())
|
var card_2 = HanafudaCard.instance().init_card($Deck.draw_card())
|
||||||
# card_2.show()
|
card_2.set_min_dimension(card_dim)
|
||||||
# tween.interpolate_property(card_2, "position",
|
add_child(card_2)
|
||||||
# Vector2(0, 0), Vector2(-100, 100), 0.4,
|
tween.interpolate_property(card_2, "position",
|
||||||
# Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
|
deck_position, Vector2(get_viewport().size.x / 2 + delta_x, get_viewport().size.y / 2),
|
||||||
|
card_reveal_duration,
|
||||||
|
Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
|
||||||
|
|
||||||
yield(tween, "tween_all_completed")
|
yield(tween, "tween_all_completed")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue