mirror of
https://github.com/JHDev2006/Super-Mario-Bros.-Remastered-Public.git
synced 2025-10-22 15:38:14 +00:00
Added Coin Sparkle Effects (#350)
* Just the Coin Sparkle stuff FYI, if a property in the json is formatted like `exa.exb` then it reads `exa` as another object and `exb` as a property in `exa` assuming the root `property_node` contains this object. Also primarily for Resource Packs to change how the particles work and should explain how I got there with my personal SMAS skin. * Added Coin Sparkle Texture to Scene Of course I broke it in some form.
This commit is contained in:
@@ -168,7 +168,16 @@ func apply_properties(properties := {}) -> void:
|
||||
if value is Array:
|
||||
property_node.set(i, Vector2(value[0], value[1]))
|
||||
else:
|
||||
property_node.set(i, properties[i])
|
||||
var obj = property_node
|
||||
for p in i.split("."):
|
||||
if not is_instance_valid(obj): continue
|
||||
if obj.get(p) is Object:
|
||||
if obj.has_method("duplicate"):
|
||||
obj.set(p, obj[p].duplicate(true))
|
||||
obj = obj[p]
|
||||
else:
|
||||
obj.set(p, properties[i])
|
||||
continue
|
||||
|
||||
func get_variation_json(json := {}) -> Dictionary:
|
||||
var level_theme = Global.level_theme
|
||||
|
@@ -3,6 +3,8 @@ const COIN_SPARKLE = preload("res://Scenes/Prefabs/Particles/CoinSparkle.tscn")
|
||||
|
||||
@export var spinning_coin_scene: PackedScene = null
|
||||
|
||||
var can_spawn_particles := true
|
||||
|
||||
signal collected
|
||||
|
||||
func area_entered(area: Area2D) -> void:
|
||||
@@ -11,11 +13,16 @@ func area_entered(area: Area2D) -> void:
|
||||
|
||||
func collect() -> void:
|
||||
collected.emit()
|
||||
$Hitbox.area_entered.disconnect(area_entered)
|
||||
Global.coins += 1
|
||||
DiscoLevel.combo_meter += 10
|
||||
Global.score += 200
|
||||
AudioManager.play_sfx("coin", global_position)
|
||||
queue_free()
|
||||
if can_spawn_particles:
|
||||
summon_particle()
|
||||
$Sprite.queue_free()
|
||||
else:
|
||||
queue_free()
|
||||
|
||||
func summon_block_coin() -> void:
|
||||
var node = spinning_coin_scene.instantiate()
|
||||
@@ -25,5 +32,5 @@ func summon_block_coin() -> void:
|
||||
|
||||
func summon_particle() -> void:
|
||||
var node = COIN_SPARKLE.instantiate()
|
||||
node.global_position = global_position
|
||||
add_sibling(node)
|
||||
node.finished.connect(queue_free)
|
||||
add_child(node)
|
||||
|
@@ -2,19 +2,26 @@ extends Node2D
|
||||
const COIN_SPARKLE = preload("res://Scenes/Prefabs/Particles/CoinSparkle.tscn")
|
||||
var velocity := Vector2(0, -300)
|
||||
|
||||
var can_spawn_particles := true
|
||||
|
||||
func _ready() -> void:
|
||||
Global.coins += 1
|
||||
Global.score += 200
|
||||
AudioManager.play_sfx("coin", global_position)
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
global_position += velocity * delta
|
||||
velocity.y += (15 / delta) * delta
|
||||
if get_node_or_null("Sprite") != null:
|
||||
global_position += velocity * delta
|
||||
velocity.y += (15 / delta) * delta
|
||||
|
||||
func vanish() -> void:
|
||||
queue_free()
|
||||
if can_spawn_particles:
|
||||
summon_particle()
|
||||
$Sprite.queue_free()
|
||||
else:
|
||||
queue_free()
|
||||
|
||||
func summon_particle() -> void:
|
||||
var node = COIN_SPARKLE.instantiate()
|
||||
node.global_position = global_position
|
||||
add_sibling(node)
|
||||
node.finished.connect(queue_free)
|
||||
add_child(node)
|
||||
|
Reference in New Issue
Block a user