Add dice roller
This commit is contained in:
parent
5fd21eefeb
commit
19fc024b4c
@ -1,22 +1,57 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
[gd_scene load_steps=16 format=2]
|
||||
|
||||
[ext_resource path="res://Assets/white-1.png" type="Texture" id=1]
|
||||
[ext_resource path="res://Assets/black-1.png" type="Texture" id=2]
|
||||
[ext_resource path="res://Assets/white-6.png" type="Texture" id=3]
|
||||
[ext_resource path="res://Assets/white-5.png" type="Texture" id=4]
|
||||
[ext_resource path="res://Assets/white-3.png" type="Texture" id=5]
|
||||
[ext_resource path="res://Assets/white-2.png" type="Texture" id=6]
|
||||
[ext_resource path="res://Assets/white-4.png" type="Texture" id=7]
|
||||
[ext_resource path="res://Assets/black-3.png" type="Texture" id=8]
|
||||
[ext_resource path="res://Assets/black-5.png" type="Texture" id=9]
|
||||
[ext_resource path="res://Assets/black-6.png" type="Texture" id=10]
|
||||
[ext_resource path="res://Assets/black-2.png" type="Texture" id=11]
|
||||
[ext_resource path="res://Assets/black-4.png" type="Texture" id=12]
|
||||
[ext_resource path="res://Scripts/DiceRoller.gd" type="Script" id=13]
|
||||
|
||||
[sub_resource type="SpriteFrames" id=1]
|
||||
animations = [ {
|
||||
"frames": [ ExtResource( 1 ), ExtResource( 6 ), ExtResource( 5 ), ExtResource( 7 ), ExtResource( 4 ), ExtResource( 3 ) ],
|
||||
"loop": true,
|
||||
"name": "default",
|
||||
"speed": 5.0
|
||||
} ]
|
||||
|
||||
[sub_resource type="SpriteFrames" id=2]
|
||||
animations = [ {
|
||||
"frames": [ ExtResource( 2 ), ExtResource( 11 ), ExtResource( 8 ), ExtResource( 12 ), ExtResource( 9 ), ExtResource( 10 ) ],
|
||||
"loop": true,
|
||||
"name": "default",
|
||||
"speed": 5.0
|
||||
} ]
|
||||
|
||||
[node name="HUD" type="CanvasLayer"]
|
||||
|
||||
[node name="Control" type="Control" parent="."]
|
||||
[node name="DiceRoller" type="Control" parent="."]
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
margin_left = -307.0
|
||||
margin_bottom = 65.0
|
||||
script = ExtResource( 13 )
|
||||
|
||||
[node name="Dice1" type="Sprite" parent="Control"]
|
||||
[node name="Dice1" type="AnimatedSprite" parent="DiceRoller"]
|
||||
position = Vector2( 179.876, 32.8762 )
|
||||
scale = Vector2( 0.0621776, 0.0621776 )
|
||||
texture = ExtResource( 1 )
|
||||
frames = SubResource( 1 )
|
||||
|
||||
[node name="Dice2" type="Sprite" parent="Control"]
|
||||
position = Vector2( 241.876, 32.8762 )
|
||||
[node name="Dice2" type="AnimatedSprite" parent="DiceRoller"]
|
||||
position = Vector2( 246, 33 )
|
||||
scale = Vector2( 0.0621776, 0.0621776 )
|
||||
texture = ExtResource( 2 )
|
||||
frames = SubResource( 2 )
|
||||
|
||||
[node name="Button" type="Button" parent="DiceRoller"]
|
||||
margin_left = 54.0
|
||||
margin_top = 9.0
|
||||
margin_right = 143.0
|
||||
margin_bottom = 57.0
|
||||
text = "Roll"
|
||||
|
10
Scripts/DiceRoller.gd
Normal file
10
Scripts/DiceRoller.gd
Normal file
@ -0,0 +1,10 @@
|
||||
extends Control
|
||||
|
||||
onready var rng = RandomNumberGenerator.new()
|
||||
|
||||
func _ready():
|
||||
$Button.connect("pressed", self, "roll")
|
||||
|
||||
func roll():
|
||||
$Dice1.frame = rng.randi_range(0, 6)
|
||||
$Dice2.frame = rng.randi_range(0, 6)
|
Loading…
Reference in New Issue
Block a user