Opacity and Animation ID problem


#1

Hello all.
I’m trying to set to a hidden sprite (initial opacity set to 0, initial animation id set to 0) a certain animation ID and then set the opacity to 255 in order to display it. What I have seen so far, is that if i set the animation ID to 0 the sprite doesn’t show up at all, even though the opacity is set to 255. If I set the animation ID to anything other than 0 and set the opacity to 255 then the sprite shows up just fine.

I have verified the sprite images, deleted and re-created the sprite and I still get the same behavior. I have gone through the extended debug details for the first case (Animation ID is 0) and for the second case (Animation ID is 1). The changes on the debug output seem to be the proper one, only one or two lines change.

Anyone seen anything like that?


#2

I would recommend to reproduce your case in a sample project, it will make the troubleshooting easier.
Feel free to share a screenshot of the related events and your sprite animations so we can take a look.


#3

Hello.

I tried reproducing this behavior in a simpler project but it was working as it should.

In the main scene I have a 2 sprites (RunesBasic & RunesColored), each one copied 5 times. RunesColored are initially set to animation id 0 and opacity 0. RunesBasic are set to animation id 0 and opacity 255. The idea is to ‘hide’ the RuneBasic sprite, set the RuneColored to the proper animatiod id and then make it appear by setting the opacity to 255.

The value for the animation id comes from a backend script. I have also tried hard-coding the values in the ‘action’ instead of using the JSON data.

Setting up the scene:

Reading the value from the JSON variable, setting the animation id and the opacity:

Stelios


#4

You should use a debugging text object to display the various values you’re playing with, to make sure they are indeed what you expect them to be.
Reading again your description of the issue, the problem seems linked to GameDataJson.rune_anim, right?
Could it be that it’s a 0 string instead of a 0 number?
I would check that or try to use animation names (after assigning names of course) instead of animation numbers.


#5

Hello Gruk.

I’m using the debugger in the extended mode that provides quite a bit of information. I couldn’t figure out why using the id 0 for the animation didn’t work.
I was also setting the value hard-coded in the events and still got the same behavior. After 2 days trying to solve this issue I had to give up and use a workaround. I now have a single Sprite object that holds both the coloured and non-coloured images Works as it should.


#6

Does the image of animation 0 appear in the object properties?
If it’s not there, you need have to put the sprite back.


#7

Yes, it does.
I also deleted and re-created the Sprite. This Sprite is also used in another location (with variable id set to 10), which also receives the animation id number from the same JSON variable and works fine. This is what made believe that this might be a bug in the first place.


#8

On your screen 1 RuneBasic have id 1 and opacity 255, object RuneBasic should be visible.
But on screen 2 RuneBasic have id to 1 then the opacity is set on 0.
Then nothing is visible.

  • If this can help you for debugging :
    I’ve created a new event with function in extension.
    My new function write in console each time you call the event and this console is cool because you keep the history.
    Add this extension file :
    https://pastebin.com/tjk3WzPq

New action is in “Console Logger”
You need call is on each event where you change the animation of your sprite.
This way you can now track this value over time in realtime.

For open console use CTRL+MAJ+I in Preview


#9

Hello.

You are correct, RuneBasic is set to be visible with opacity 255 and then, as you can see on the second screen I set the opacity to 0 but I set the opacity for the RunesColored to 255 to be displayed instead of the RuneBasic. In the scene designer, those two sprites are placed one on top of the other with RunesColored having a greater Z-index.

Thanks for the extension, it will come very handy. As I don’t have the previous set up in place I cannot use it and log the actions. If you think that this might indeed be a bug I can try to bring the files back as they where and debug it again.

Stelios