Simple Animation Frame Question

0 favourites
  • 12 posts
From the Asset Store
three fully animated characters ideal for your RPG side scroller projects
  • Sprite1 Animation frame[1] compared with Sprite1 Animation Frame[3]- Results always true- issue?

    Sprite1 Animation frame[1] compared with Sprite2 Animation Frame[3]- false Working as expected

  • You do realize that action 1 and 2 will be executed every tick, which is about 60 times per second?

    And if both conditions are equal, the browser will try to generate 120 warnings every second.

    Why do you use the browser's allert to check?

    Instead of it, put a variable increment and see in debug mode on global variables whether the condition will be fulfilled and if so, how fast the value of the variable will be incremented.

  • This is just two experiments.

    First: With two instances of a sprite, but each instance having different frames.

    Second: Two completely different sprites, each having different frames.

    What I'm trying to say is, if you compare both event blocks, you can see that the first block, if the condition is satisfied, still gives me the wrong result (which is not expected). And for the second block, if the condition is satisfied, it gives me the correct result (which is expected).

    The result of this experiment leads me to think that it's a C3 bug.

  • With two instances of a sprite, but each instance having different frames.

    You can't compare two instances like that! When you use an object in an expression like that, only the first instance is checked. So you are comparing it with itself.

    If you want to compare two instances, you need to pick each instance separately. With a single object it's tricky, a common workaround is to use a family. Then you pick 1 instance of the sprite and 1 instance of the family, and compare Sprite.animationFrame=Family.animationFrame

    Another option is to use IIDs:

    Sprite(0).animationFrame=Sprite(1).animationFrame

    But you need to be sure that there are only two instances on the layout.

  • You are right even though some of the measurement conditions may have introduced an error.

    I have created an experimental example with such conditions.

    I set the animation speed to 0. And I added a loop to loop through all sprites for comparison.

    The result showed that construct3 has a problem with comparing objects to themselves.

    Where the sprites are different, everything is fine.

    Where a sprite compares itself it always produces 3 instead of one.

    I did the same with local variables and the error was repeated.

    Example dropmefiles.com.ua/en/CReBDzZ4W2

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • a common workaround is to use a family. Then you pick 1 instance of the sprite and 1 instance of the family, and compare Sprite.animationFrame=Family.animationFrame

    It's still not working, What I'm doing wrong?

  • The result showed that construct3 has a problem with comparing objects to themselves.

    So, you also proved it in detail.

    Are you guys agreeing that it's a bug?

  • It's still not working, What I'm doing wrong?

    You are not picking the right instances.

    Before you do anything with instances in Construct you need to pick them. Otherwise the engine doesn't know which instances you need. Imagine you have 1000 instances of Sprite1. Which ones the engine should select to compare their animation frames? Which ones should become visible?

    Picking is possibly the most important concept in Construct. I suggest you start by reading the official documentation and studying some tutorials.

    .

    The result showed that construct3 has a problem with comparing objects to themselves.

    igortyhon I don't see any problem in your example. The condition "Sprite1.AnimationFrame=Sprite1.AnimationFrame" is always true, which is expected.

  • I suggest you start by reading the official documentation and studying some tutorials.

    Trust me, before asking it to the community, I went through many tutos, but everywhere I looked, it was only possible with distinct sprites. I couldn't find a way to make it work with the same sprite, so I tot it must be a bug, so I landed on the community.

    Here the c3p.

  • I don't understand why the family solution is not working for you. If you disable all other events you can see that it works fine:

    In this case the "Is overlapping" condition picks two instances - one Sprite1 and one Family. This allows to compare their frames.

    However, if more than two instances are overlapping, the event may not work. You will need to do more picking to select two specific instances for comparing.

  • Thank you, it was my bad, with Family it is working.

    Still, don't you think this is just a workaround for a bug?

  • There is no bug. The engine needs to know which instance you want to compare, that's why you need to pick the correct instance. If you don't pick, then the first available instance is used and the result may be different from what you expect.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)