mirror of
https://github.com/creyD/ludum_dare_46.git
synced 2026-06-11 21:22:22 +02:00
Merge branch 'dev' of https://github.com/creyD/ludum_dare_46 into dev
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://Menus/DragNDrop/DragSource.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://Menus/DragNDrop/DragSink.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://Objects/Banana/Banana.tscn" type="PackedScene" id=3]
|
||||
|
||||
[node name="DragNDropUI" type="Control"]
|
||||
anchor_right = 1.0
|
||||
@@ -12,9 +13,13 @@ __meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="DragSource" parent="." instance=ExtResource( 1 )]
|
||||
margin_left = 12.7532
|
||||
margin_top = 230.124
|
||||
margin_right = 44.7532
|
||||
margin_bottom = 262.124
|
||||
Item = ExtResource( 3 )
|
||||
|
||||
[node name="DragSink" parent="." instance=ExtResource( 2 )]
|
||||
margin_left = 1.19746
|
||||
margin_right = 1.19745
|
||||
|
||||
[node name="DragSource" parent="." instance=ExtResource( 1 )]
|
||||
PreviewIcon = "res://icon.png"
|
||||
margin_right = 1.19745
|
||||
@@ -1,23 +1,25 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[sub_resource type="GDScript" id=2]
|
||||
[sub_resource type="GDScript" id=1]
|
||||
script/source = "extends Container
|
||||
#DropZone
|
||||
|
||||
#stuff can be dropped here
|
||||
func can_drop_data(_pos, data):
|
||||
return typeof(data) == TYPE_INT
|
||||
return typeof(data) == typeof(PackedScene)
|
||||
|
||||
#what is to be done when data is dropped
|
||||
func drop_data(_pos, data):
|
||||
print(data)
|
||||
func drop_data(_pos, data:PackedScene):
|
||||
var child = data.instance()
|
||||
child.position= _pos
|
||||
self.add_child(child)
|
||||
"
|
||||
|
||||
[node name="DragSink" type="Container"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 0.789
|
||||
margin_bottom = -0.0200043
|
||||
script = SubResource( 2 )
|
||||
script = SubResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
@@ -5,18 +5,15 @@
|
||||
[sub_resource type="GDScript" id=1]
|
||||
script/source = "extends TextureRect
|
||||
#CardDeck
|
||||
export var ItemID:int=0
|
||||
export var PreviewIcon:String = \"\"
|
||||
export var Item:PackedScene
|
||||
export var PreviewIcon:Texture
|
||||
export var DeleteOnGrab:bool = false
|
||||
|
||||
#if a drag is initiated here
|
||||
func get_drag_data(_pos):
|
||||
print(_pos)
|
||||
var preview = load(PreviewIcon)
|
||||
var ctrl = Control.new()
|
||||
|
||||
var TR = TextureRect.new()
|
||||
TR.texture = get_resized_texture(preview,self.rect_size[0],self.rect_size[1])
|
||||
TR.texture = get_resized_texture(PreviewIcon,self.rect_size[0],self.rect_size[1])
|
||||
TR.rect_size= self.rect_size
|
||||
TR.set_position(_pos*-1,false)
|
||||
ctrl.add_child(TR)
|
||||
@@ -24,12 +21,12 @@ func get_drag_data(_pos):
|
||||
|
||||
if DeleteOnGrab :
|
||||
self.queue_free()
|
||||
return ItemID
|
||||
return Item
|
||||
|
||||
#stuff can be dropped here
|
||||
#eg you picked the wrong thing up, let go and it returns to nothingness
|
||||
func can_drop_data(_pos, data):
|
||||
return typeof(data) == TYPE_INT
|
||||
return typeof(data) == typeof(PackedScene)
|
||||
|
||||
#do nothing if stuff is dropped here
|
||||
func drop_data(_pos, _data):
|
||||
@@ -55,3 +52,4 @@ script = SubResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
PreviewIcon = ExtResource( 1 )
|
||||
|
||||
Reference in New Issue
Block a user