|
|
|
 |
Reply From: |
njamster |
I’m hoping someone can help me out here with the correct way to do it
There really isn’t a “correct way” - it all depends on what exactly you want to do.
Here is an example of what I want
When referencing someone else’s work, I think it’s only fair to give them proper credit. Also, as you already know who did what you want, why don’t you reach out to them on reddit or twitter and simply ask how the did it?
That being said, here’s a quick version I hacked together using Tweens:
extends Node2D
var COIN_SCENE = preload("res://Coin.tscn")
const MIN_X = 10.0
const MAX_X = 150.0
const MIN_Y = -80.0
const MAX_Y = 80.0
func _ready():
randomize()
func _process(delta):
if Input.is_action_just_pressed("ui_accept"):
var coins = []
for i in range(5):
coins.append(COIN_SCENE.instance())
coins[i].position = Vector2(960, 540)
add_child(coins[i])
var tween = Tween.new()
add_child(tween)
for coin in coins:
var direction = 1 if randi() % 2 == 0 else -1
var goal = coin.position + Vector2(rand_range(MIN_X, MAX_X), rand_range(MIN_Y, MAX_Y)) * direction
tween.interpolate_property(coin, "position:x", null, goal.x, 1, Tween.TRANS_LINEAR, Tween.EASE_IN)
tween.interpolate_property(coin, "position:y", null, goal.y - 50, 0.4, Tween.TRANS_QUAD, Tween.EASE_OUT)
tween.interpolate_property(coin, "position:y", goal.y - 50, goal.y, 0.4, Tween.TRANS_QUAD, Tween.EASE_IN, 0.4)
tween.interpolate_property(coin, "position:y", goal.y, goal.y - 10, 0.1, Tween.TRANS_QUAD, Tween.EASE_IN, 0.8)
tween.interpolate_property(coin, "position:y", goal.y - 10, goal.y, 0.1, Tween.TRANS_QUAD, Tween.EASE_IN, 0.9)
tween.start()
That’s probably not exactly (or even close to) how they did it for “Helms of Fury” and misses further details like rotating the coin or showing shadows on the ground, but it should give you a rough idea anyways. Getting those things “right” is a lot of work and usually the things you’ll spend the most time with when developing a game.
and how to reference the enemy position, when he dies?