Updated the bullet spawning position to beging from the sprite height
modified by the weapon's origin variable.
This commit is contained in:
parent
64e685a3c1
commit
9554af183c
7 changed files with 38 additions and 27 deletions
|
|
@ -6,7 +6,7 @@ class_name NotificationDisplay extends Control
|
|||
|
||||
var _player: Node2D = null
|
||||
var _sprite_size: Vector2 = Vector2.ZERO
|
||||
var _origin_offset: Vector2 = Vector2.ZERO
|
||||
var _origin_offset: float = 0.0
|
||||
var _follow_player: bool = false
|
||||
|
||||
var _connector_line: Line2D = null
|
||||
|
|
@ -23,7 +23,7 @@ func _ready() -> void:
|
|||
_container.add_theme_constant_override("margin_right", 4)
|
||||
|
||||
|
||||
func show_notification(weapon_name: String, player_node: Node2D, player_sprite_size: Vector2, origin_offset: Vector2) -> void:
|
||||
func show_notification(weapon_name: String, player_node: Node2D, player_sprite_size: Vector2, origin_offset: float) -> void:
|
||||
modulate.a = 0.0
|
||||
|
||||
label.add_theme_font_size_override("font_size", 8)
|
||||
|
|
@ -107,7 +107,7 @@ func _update_position() -> void:
|
|||
var player_pos = _player.position
|
||||
|
||||
# Y position uses the weapon origin offset from player center
|
||||
var notif_y = player_pos.y + _origin_offset.y - (size.y / 2.0)
|
||||
var notif_y = player_pos.y + _origin_offset - (size.y / 2.0)
|
||||
|
||||
# X position is 10px to the right of player's sprite edge
|
||||
var right_edge = player_pos.x + (_sprite_size.x / 2.0)
|
||||
|
|
@ -164,7 +164,7 @@ func _update_connector() -> void:
|
|||
|
||||
# Point 2: player's origin + ENDPOINT_OFFSET, converted to notification's local space
|
||||
const ENDPOINT_OFFSET = Vector2(4, 7) # offset from player's origin to connector endpoint
|
||||
var target = _player.position + Vector2(+ENDPOINT_OFFSET.x, _origin_offset.y + ENDPOINT_OFFSET.y)
|
||||
var target = _player.position + Vector2(+ENDPOINT_OFFSET.x, _origin_offset + ENDPOINT_OFFSET.y)
|
||||
var point2 = target - position
|
||||
|
||||
_connector_line.points = PackedVector2Array([point0, point1, point2])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue