player flashing when using it's idle animation

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Surge

I’ve had this problem before with this engine, but the game wasn’t as complicated as my current project. Basically what keeps happening is the player has two (well three… but one of them is on a separate set of sprites) animations that relate to movement. An idle and a running animation.

The running animation works just fine, but for whatever reason, frame 0 for the idle animation does not show at all when running the game as it’s standalone version (exported as a release or debug version). The editor run of the game, however, does show the frame.

My setup for the animations is this: 10 AnimatedSprites, 5 for each horizontal flip. (Reason for this many of them is because the player is able to customize the colors of each part of the sprite, and the fact that the sprite is offset from the legs.)

Anyways… like I said: the running animation does show on the exported version of the project. It’s only frame 0 of the animation. I don’t know why this is happening.

Here’s the part of my player code that handles the animations:

func animation(flipped: bool, anim: String, attack_anim: bool):	
if flipped:
	get_node("sprites/flip").visible = true
	get_node("sprites/norm").visible = false
	get_node("sprites/flip").visible = false
	get_node("sprites/norm").visible = true

if !attack_anim:
	if !attacking:
		get_node("sprites/flip/norm/ir").visible = true
		get_node("sprites/norm/ir").visible = true
		get_node("sprites/flip/norm/atk").visible = false
		get_node("sprites/norm/atk").visible = false
		get_node("sprites/norm/ir/body").play(anim + "-body")
		get_node("sprites/norm/ir/body-shadow").play(anim + "-body-shadow")
		get_node("sprites/norm/ir/wings").play(anim + "-wings")
		get_node("sprites/norm/ir/horns").play(anim + "-horns")
		get_node("sprites/norm/ir/eyes").play(anim + "-eyes")
		get_node("sprites/flip/norm/ir/body").play(anim + "-body")
		get_node("sprites/flip/norm/ir/body-shadow").play(anim + "-body-shadow")
		get_node("sprites/flip/norm/ir/wings").play(anim + "-wings")
		get_node("sprites/flip/norm/ir/horns").play(anim + "-horns")
		get_node("sprites/flip/norm/ir/eyes").play(anim + "-eyes")
	if vel == Vector2.ZERO: #aka... the player is NOT running (this is TEMPORARY)
		attacking = true
		get_node("sprites/flip/norm/ir").visible = false
		get_node("sprites/norm/ir").visible = false
		get_node("sprites/flip/norm/atk").visible = true
		get_node("sprites/norm/atk").visible = true
		get_node("sprites/norm/atk/body").playing = true
		get_node("sprites/norm/atk/body-shadow").playing = true
		get_node("sprites/norm/atk/wings").playing = true
		get_node("sprites/norm/atk/horns").playing = true
		get_node("sprites/norm/atk/eyes").playing = true
		get_node("sprites/flip/norm/atk/body").playing = true
		get_node("sprites/flip/norm/atk/body-shadow").playing = true
		get_node("sprites/flip/norm/atk/wings").playing = true
		get_node("sprites/flip/norm/atk/horns").playing = true
		get_node("sprites/flip/norm/atk/eyes").playing = true

And everything is setup in a _ready function, not listed here (sets sprite colors, sets the attack animations to not be playing, and sets the regular animations to frame 0).

Can someone help me out? (I will provide any extra information as needed).

Should also note that every other aspect of the project works as its supposed to.

I almost never use animated sprites, especially not to this degree, so I can’t help you solve your problem given your current system. However… I think you’ll be relieved to find out there’s a MUCH easier way to handle animations with a sprite! I’d explain it, but this video will do a much better job
While it’s used in a top-down setting, and from the looks of your code you’re making a sidescroller, it’s still easy enough to apply this method to your game! I’ve never had any problems with this, so the flashing could be an issue with the animated sprite itself. Hope this helps even if it doesn’t necessarily answer the question

DigitalDrako | 2020-06-28 04:52