Global attribute not setting correctly, so animation won't display properly.

Phraustdesign

  • Posts: 7
Hello everyone.

I'm semi new to stencyl - but have started to get a pretty decent grasp of the drag and drop coding. I have an issue that for the life of me I CANNOT figure out. I'm having an actor animation issue. Bear with me here.

Here is the jist of it:

I have a scene with a coin actor on it with it's own scene layer. When you click on the actor, lets call it "pickedupcoin", it reveals a previously hidden scene layer with a different actor of a larger coin (to make it look like you picked it up), and hides the other layer with the original coin actor, let's call this one "inactivecoin", that you clicked on.

When you click on this new coin [pickedupcoin] it does an animation of flipping, plays a little sound, then stops on a random animation to display heads, 1, or tails, 0. Everything up to this point works perfectly as it should. Here is where the issue starts.

The code after this, as I have tried to write a dozen different ways trying to figure this out, essentially has an if statement after the final random animation is chosen. What is contained within this if statement is supposed to determine which animation the coin is at 0 or 1 and then set a global attribute to 1 or 0. The point of this is so that the original coin {inactivecoin],  should update it self itself to a 1 or 0 animation so it shows the proper side, heads or tail, when the layer is revealed again. However, it never updates itself.

Once the animation has played, the attribute never gets updated. I have its output being displayed as text for the purposes of debugging this issue, and the readout never changes, so the coin doesn't ever update its animation.

I can't figure out if this is using the wrong code pieces, if it is a drawing issue, update issue.. what. I think I am making it way harder than it should be. I have also included some screenshots of all the relevant code.

The first image (shorter code) is what is supposed to determine the animation to show the inactive coin at, heads or tails. This code is contained on the main play scene

The second image (longer code) is on the active flippable coin actor that tells it how to animate, and then (supposed to) how to set the attribute which will determine the animation to use. This code is contained on the picked up coin actor, only visible when the layer is revealed.

The only code on the inactive coin actor is just a mouse press that hides or undhides the other layer, nothing more. No animation related coding.

Sorry that was so long, but I'm sure I'm making it way harder than it should be and this may be a face palm moment for me. Because I ahve been working on this for 3 days now! And I can't see it.

« Last Edit: July 21, 2021, 02:34:01 pm by Phraustdesign »

Phraustdesign

  • Posts: 7
NEVERMIND! Figured it out, I was going about it a hard way. :)