From 3027e4f080fdf0c48b41ebc62a70309e1d1e1792 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=AEittaG=20ordnasselA?= Date: Fri, 3 May 2019 18:10:06 +0200 Subject: [PATCH] WIP scaling --- Scenes/Game.tscn | 18 ++++++++---------- Scenes/Scripts/Game.gd | 15 +++++++++++++++ project.godot | 15 +++++++++++++++ 3 files changed, 38 insertions(+), 10 deletions(-) create mode 100644 Scenes/Scripts/Game.gd diff --git a/Scenes/Game.tscn b/Scenes/Game.tscn index 4459c85..e0c6bd6 100644 --- a/Scenes/Game.tscn +++ b/Scenes/Game.tscn @@ -1,17 +1,15 @@ -[gd_scene load_steps=2 format=2] +[gd_scene load_steps=3 format=2] -[ext_resource path="res://Scenes/Components/Card.tscn" type="PackedScene" id=1] +[ext_resource path="res://Scenes/Scripts/Game.gd" type="Script" id=1] +[ext_resource path="res://Scenes/Components/Card.tscn" type="PackedScene" id=2] [node name="Node2D" type="Control"] anchor_right = 1.0 anchor_bottom = 1.0 +script = ExtResource( 1 ) -[node name="Node2D2" parent="." instance=ExtResource( 1 )] -position = Vector2( 412.914, 481.231 ) -rotation = -0.188775 -scale = Vector2( 0.479999, 0.479999 ) +[node name="Board" type="Node2D" parent="."] -[node name="Node2D3" parent="." instance=ExtResource( 1 )] -position = Vector2( 459.073, 504.964 ) -rotation = -0.0665061 -scale = Vector2( 0.479999, 0.479999 ) +[node name="Node2D3" parent="Board" instance=ExtResource( 2 )] +position = Vector2( 736.851, 566.497 ) +scale = Vector2( 0.3, 0.3 ) diff --git a/Scenes/Scripts/Game.gd b/Scenes/Scripts/Game.gd new file mode 100644 index 0000000..4b88a02 --- /dev/null +++ b/Scenes/Scripts/Game.gd @@ -0,0 +1,15 @@ +extends Control + +func _input(event: InputEvent): + if event.is_action_pressed("zoom_in"): + zoom(true) + elif event.is_action_pressed("zoom_out"): + zoom(false) + +const SCALE_FACTOR := 0.1 + +func zoom(direction: bool): + var scaleFactor := 1 + SCALE_FACTOR + if not direction: + scaleFactor = 1 - SCALE_FACTOR + $Board.scale *= scaleFactor \ No newline at end of file diff --git a/project.godot b/project.godot index fee1035..a9ca1c1 100644 --- a/project.godot +++ b/project.godot @@ -23,6 +23,21 @@ config/icon="res://icon.png" window/size/width=1280 window/size/height=800 +[input] + +zoom_in={ +"deadzone": 0.5, +"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":4,"pressed":false,"doubleclick":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":61,"unicode":0,"echo":false,"script":null) + ] +} +zoom_out={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":45,"unicode":0,"echo":false,"script":null) +, Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":5,"pressed":false,"doubleclick":false,"script":null) + ] +} + [rendering] quality/driver/driver_name="GLES2"