Move battle sprites to new test scene

This commit is contained in:
Luke Hubmayer-Werner 2023-07-28 00:17:03 +09:30
parent 058f436a7d
commit 005152a8c3
4 changed files with 47 additions and 35 deletions

View File

@ -1,27 +1,4 @@
extends Node2D extends Node2D
var PC = load('PC.tscn')
var PCs = []
func _ready(): func _ready():
Engine.set_target_fps(60) Engine.set_target_fps(60)
var strips = len(SpriteLoader.strip_textures) # * 4 / 5
#var strip_divide = strips * 2 / 5
var strip_divide = strips * 1 / 5
for i in strips:
PCs.append(PC.instance())
#PCs[-1].set_position(Vector2((i%strip_divide)*16, (i/strip_divide)*24*11))
PCs[-1].set_position(Vector2((i%strip_divide)*24, (i/strip_divide)*32))
PCs[-1].material.set_shader_param('palette', SpriteLoader.character_battle_sprite_palette_textures[i])
PCs[-1].texture = SpriteLoader.strip_textures[i]
add_child(PCs[-1])
# PCs.append(PC.instance())
# PCs[-1].set_position(Vector2(0, 2*24*11))
# PCs[-1].material.set_shader_param('palette', SpriteLoader.character_battle_sprite_palette_textures[45])
# PCs[-1].texture = SpriteLoader.weapon_textures['Fist']
# add_child(PCs[-1])
func _on_OptionButton_item_selected(ID):
for pc in PCs:
pc.animation = ID

View File

@ -1,9 +1,10 @@
[gd_scene load_steps=5 format=2] [gd_scene load_steps=6 format=2]
[ext_resource path="res://palette_mat.tres" type="Material" id=1] [ext_resource path="res://palette_mat.tres" type="Material" id=1]
[ext_resource path="res://Node2D.gd" type="Script" id=2] [ext_resource path="res://Node2D.gd" type="Script" id=2]
[ext_resource path="res://test/audio_system.tscn" type="PackedScene" id=3] [ext_resource path="res://test/audio_system.tscn" type="PackedScene" id=3]
[ext_resource path="res://test/worldmap_system.tscn" type="PackedScene" id=4] [ext_resource path="res://test/worldmap_system.tscn" type="PackedScene" id=4]
[ext_resource path="res://test/battle_sprites.tscn" type="PackedScene" id=5]
[node name="Control" type="Control"] [node name="Control" type="Control"]
anchor_right = 1.0 anchor_right = 1.0
@ -15,19 +16,9 @@ position = Vector2( 16, 16 )
scale = Vector2( 2, 2 ) scale = Vector2( 2, 2 )
script = ExtResource( 2 ) script = ExtResource( 2 )
[node name="OptionButton" type="OptionButton" parent="Node2D"]
anchor_bottom = 0.67
margin_top = 180.0
margin_right = 100.0
margin_bottom = 170.0
rect_scale = Vector2( 0.5, 0.5 )
text = "Stand"
items = [ "Stand", null, false, 0, null, "Guard", null, false, 1, null, "Walk", null, false, 2, null, "Down", null, false, 3, null, "R_Swing", null, false, 4, null, "L_Swing", null, false, 5, null, "Cheer", null, false, 6, null, "Recoil", null, false, 7, null, "Chant", null, false, 8, null ]
selected = 0
[node name="audio_system" parent="." instance=ExtResource( 3 )] [node name="audio_system" parent="." instance=ExtResource( 3 )]
position = Vector2( 0, 400 ) position = Vector2( 0, 400 )
[node name="worldmap_system" parent="." instance=ExtResource( 4 )] [node name="worldmap_system" parent="." instance=ExtResource( 4 )]
[connection signal="item_selected" from="Node2D/OptionButton" to="Node2D" method="_on_OptionButton_item_selected"] [node name="battle_sprites" parent="." instance=ExtResource( 5 )]

25
test/battle_sprites.gd Normal file
View File

@ -0,0 +1,25 @@
extends Node2D
var PC = load('res://PC.tscn')
var PCs = []
func _ready() -> void:
var strips = len(SpriteLoader.strip_textures) # * 4 / 5
#var strip_divide = strips * 2 / 5
var strip_divide = strips * 1 / 5
for i in strips:
PCs.append(PC.instance())
#PCs[-1].set_position(Vector2((i%strip_divide)*16, (i/strip_divide)*24*11))
PCs[-1].set_position(Vector2((i%strip_divide)*24, (i/strip_divide)*32))
PCs[-1].material.set_shader_param('palette', SpriteLoader.character_battle_sprite_palette_textures[i])
PCs[-1].texture = SpriteLoader.strip_textures[i]
add_child(PCs[-1])
# PCs.append(PC.instance())
# PCs[-1].set_position(Vector2(0, 2*24*11))
# PCs[-1].material.set_shader_param('palette', SpriteLoader.character_battle_sprite_palette_textures[45])
# PCs[-1].texture = SpriteLoader.weapon_textures['Fist']
# add_child(PCs[-1])
func _on_OptionButton_item_selected(ID):
for pc in PCs:
pc.animation = ID

19
test/battle_sprites.tscn Normal file
View File

@ -0,0 +1,19 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://test/battle_sprites.gd" type="Script" id=1]
[node name="battle_sprites" type="Node2D"]
scale = Vector2( 2, 2 )
script = ExtResource( 1 )
[node name="OptionButton" type="OptionButton" parent="."]
anchor_bottom = 0.67
margin_top = 160.0
margin_right = 100.0
margin_bottom = 180.0
rect_scale = Vector2( 0.5, 0.5 )
text = "Stand"
items = [ "Stand", null, false, 0, null, "Guard", null, false, 1, null, "Walk", null, false, 2, null, "Down", null, false, 3, null, "R_Swing", null, false, 4, null, "L_Swing", null, false, 5, null, "Cheer", null, false, 6, null, "Recoil", null, false, 7, null, "Chant", null, false, 8, null ]
selected = 0
[connection signal="item_selected" from="OptionButton" to="." method="_on_OptionButton_item_selected"]