26 lines
638 B
GDScript3
26 lines
638 B
GDScript3
|
extends Control
|
||
|
class_name CardMachine
|
||
|
const CARD = preload("res://scene/card.tscn")
|
||
|
var distance:float=100
|
||
|
var card_arr:Array[Card]=[]
|
||
|
func get_index_position(index:int)->Vector2:
|
||
|
var center=size/2
|
||
|
var left=center-Vector2(distance*card_arr.size()/2,0)
|
||
|
var rand_y=randf_range(-10,10)
|
||
|
return left+Vector2(distance*index,rand_y)
|
||
|
func _ready() -> void:
|
||
|
add_card("xxx",4)
|
||
|
|
||
|
func get_put_pos():
|
||
|
return size/2
|
||
|
|
||
|
func add_card(card_id:String,num:int):
|
||
|
var data=Global.get_card_data(card_id)
|
||
|
for i in num:
|
||
|
var new_card=CARD.instantiate()
|
||
|
add_child(new_card)
|
||
|
card_arr.append(new_card)
|
||
|
for j in card_arr:
|
||
|
j.request_resize()
|
||
|
pass
|