#How to "tween" a sprite to make it breathe ('grow' and then 'shrink' over time).

3 messages · Page 1 of 1 (latest)

heavy monolith
heavy monolith
#

Site is back up and the solution works for me! No tweening for the approach and although I think that might be better, I'm happy with the solution as per the url.

heavy monolith
#

Just for posterity, here is what I've done, as per the link above...

var size_min = 1.0
var size_max = 1.1
var should_shrink = true
var rate = 0.005

func _ready():
$Sprite.scale.x = 1
$Sprite.scale.y = 1

func _process(delta):

if should_shrink:
    _shrink(rate)
    if scale.x <= size_min:
        should_shrink = false
        
if not should_shrink:
    _grow(rate)
    if scale.x >= size_max:
        should_shrink = true
print ($Sprite.scale.x)

func _shrink(amount):
$Sprite.scale.x -= amount
$Sprite.scale.y -= amount

func _grow(amount):
$Sprite.scale.x += amount
$Sprite.scale.y += amount