1
0
mirror of https://gitee.com/freeyz/godot-mota.git synced 2024-12-22 19:49:21 +08:00

怪物图鉴增加触摸移动

This commit is contained in:
freewu32 2020-09-03 23:05:18 +08:00
parent 2501cb81b8
commit 39d476ec76
2 changed files with 34 additions and 3 deletions

View File

@ -1,6 +1,7 @@
[gd_scene load_steps=28 format=2] [gd_scene load_steps=29 format=2]
[ext_resource path="res://src/levels/Level1.tscn" type="PackedScene" id=1] [ext_resource path="res://src/levels/Level1.tscn" type="PackedScene" id=1]
[ext_resource path="res://src/utils/TouchScrollContainer.gd" type="Script" id=2]
[ext_resource path="res://assets/sounds/bgm.ogg" type="AudioStream" id=5] [ext_resource path="res://assets/sounds/bgm.ogg" type="AudioStream" id=5]
[ext_resource path="res://assets/images/ground.png" type="Texture" id=6] [ext_resource path="res://assets/images/ground.png" type="Texture" id=6]
[ext_resource path="res://assets/images/icons_old.png" type="Texture" id=7] [ext_resource path="res://assets/images/icons_old.png" type="Texture" id=7]
@ -425,16 +426,23 @@ anchor_left = 0.5
anchor_top = 0.5 anchor_top = 0.5
anchor_right = 0.5 anchor_right = 0.5
anchor_bottom = 0.5 anchor_bottom = 0.5
margin_left = -208.0 margin_left = -200.0
margin_top = -200.0 margin_top = -200.0
margin_right = 232.0 margin_right = 197.0
margin_bottom = 152.0 margin_bottom = 152.0
size_flags_horizontal = 3
size_flags_vertical = 3
scroll_horizontal_enabled = false scroll_horizontal_enabled = false
script = ExtResource( 2 )
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="VBoxContainer" type="VBoxContainer" parent="HUD/BookDialog/ScrollContainer"] [node name="VBoxContainer" type="VBoxContainer" parent="HUD/BookDialog/ScrollContainer"]
margin_right = 397.0
margin_bottom = 352.0
size_flags_horizontal = 3
size_flags_vertical = 3
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }

View File

@ -0,0 +1,23 @@
extends ScrollContainer
var isDrag = false
var startPos = 0
var dragDir = 0
func _input(event):
if event is InputEventMouseButton:
if event.button_index != BUTTON_LEFT:
return
if event.is_pressed():
isDrag = true
startPos = event.position.y
print("pressed")
if !event.is_pressed():
isDrag = false
startPos = 0
print("not pressed")
if event is InputEventMouseMotion and isDrag:
var offset = event.position.y - startPos
self.scroll_vertical -= offset
startPos = event.position.y
print("drag")