mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 07:45:33 +00:00
Rotating prism sprite
This commit is contained in:
parent
dbca78c0b7
commit
ec64f272c4
6 changed files with 55 additions and 3 deletions
BIN
ExternalMaterial/Prism/Prism.png
(Stored with Git LFS)
Normal file
BIN
ExternalMaterial/Prism/Prism.png
(Stored with Git LFS)
Normal file
Binary file not shown.
34
ExternalMaterial/Prism/Prism.png.import
Normal file
34
ExternalMaterial/Prism/Prism.png.import
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://kpiqfphw2d2q"
|
||||
path="res://.godot/imported/Prism.png-4949829a99e4ae9ccbb82d10468e6a96.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://ExternalMaterial/Prism/Prism.png"
|
||||
dest_files=["res://.godot/imported/Prism.png-4949829a99e4ae9ccbb82d10468e6a96.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
BIN
ExternalMaterial/Prism/Prism.pxc
Normal file
BIN
ExternalMaterial/Prism/Prism.pxc
Normal file
Binary file not shown.
BIN
ExternalMaterial/Prism/Prism.pxc1
Normal file
BIN
ExternalMaterial/Prism/Prism.pxc1
Normal file
Binary file not shown.
|
|
@ -1,7 +1,7 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://pvpt2af54s1a"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://yf367y2o5oyh" path="res://Scripts/Actors/Prism.cs" id="1_gnsdu"]
|
||||
[ext_resource type="Texture2D" uid="uid://tm14o2xkomjb" path="res://Sprites/Icon.png" id="2_3vm23"]
|
||||
[ext_resource type="Texture2D" uid="uid://kpiqfphw2d2q" path="res://ExternalMaterial/Prism/Prism.png" id="2_3vm23"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_3vm23"]
|
||||
|
||||
|
|
@ -15,3 +15,4 @@ shape = SubResource("CircleShape2D_3vm23")
|
|||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("2_3vm23")
|
||||
hframes = 15
|
||||
|
|
|
|||
|
|
@ -4,12 +4,27 @@ namespace Cirno.Scripts.Actors;
|
|||
|
||||
public partial class Prism : Area2D
|
||||
{
|
||||
[Export] public float ReflectionAngle { get; set; } = 90f;
|
||||
[Export] public float ReflectionAngle { get; private set; } = 90f;
|
||||
[Export] public float RotationAngle { get; set; }
|
||||
|
||||
private Sprite2D _sprite;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
this.AreaEntered += OnCollision;
|
||||
_sprite = this.GetNode<Sprite2D>("Sprite2D");
|
||||
|
||||
SetReflectionAngle(ReflectionAngle);
|
||||
|
||||
}
|
||||
|
||||
public void SetReflectionAngle(float angle)
|
||||
{
|
||||
ReflectionAngle = angle;
|
||||
var frames = _sprite.Hframes;
|
||||
var frame = (int)(frames * angle / 360);
|
||||
|
||||
_sprite.Frame = frame - 1;
|
||||
}
|
||||
|
||||
private void OnCollision(Area2D other)
|
||||
|
|
@ -17,7 +32,6 @@ public partial class Prism : Area2D
|
|||
if (other is not Bullet bullet) return;
|
||||
|
||||
bullet.RotateBullet(ReflectionAngle);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue