WIP scaling

This commit is contained in:
Hamcha 2019-05-03 18:10:06 +02:00
parent 3680de0c12
commit 3027e4f080
Signed by: hamcha
GPG key ID: A40413D21021EAEE
3 changed files with 38 additions and 10 deletions

View file

@ -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"] [node name="Node2D" type="Control"]
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
script = ExtResource( 1 )
[node name="Node2D2" parent="." instance=ExtResource( 1 )] [node name="Board" type="Node2D" parent="."]
position = Vector2( 412.914, 481.231 )
rotation = -0.188775
scale = Vector2( 0.479999, 0.479999 )
[node name="Node2D3" parent="." instance=ExtResource( 1 )] [node name="Node2D3" parent="Board" instance=ExtResource( 2 )]
position = Vector2( 459.073, 504.964 ) position = Vector2( 736.851, 566.497 )
rotation = -0.0665061 scale = Vector2( 0.3, 0.3 )
scale = Vector2( 0.479999, 0.479999 )

15
Scenes/Scripts/Game.gd Normal file
View file

@ -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

View file

@ -23,6 +23,21 @@ config/icon="res://icon.png"
window/size/width=1280 window/size/width=1280
window/size/height=800 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] [rendering]
quality/driver/driver_name="GLES2" quality/driver/driver_name="GLES2"