End of animation

Get help using Construct 2

Post » Sun Oct 28, 2012 8:34 am

Hi everybody,

I'm working on a step by step game and i would like to know how can i know when an "animation" is finish.

In my case, I apply a force to some balls, and i would like to detect when all balls have finish moving.
(= when they are no more "animation" in canvas).
Then i would like to make another event on this event "no more activity on canvas.

Sorry for my poor english.
And thanks you in advance.

Kind regards !
Thibaut.
B
8
Posts: 8
Reputation: 516

Post » Sun Oct 28, 2012 12:23 pm

Use the 'on animation finished' condition?
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Sun Oct 28, 2012 8:52 pm

Thanks for you reply but i must missed somerhing.

I thaght this condition was used for sprite animation, not for all canvas animation.
Because on animation finished is prompting for an animation name ??? What should i put in this animation name for looking for canvas animation ?

B
8
Posts: 8
Reputation: 516

Post » Sun Oct 28, 2012 9:21 pm

So you mean you want to know when the image stops moving in the game, not when the images animation is completed?
B
40
S
12
G
7
Posts: 603
Reputation: 7,656

Post » Sun Oct 28, 2012 9:30 pm

I've only just got in to construct...

If you tuck the objects position (self.X and self.Y) in to some new object instance variables (lastX and lastY), you could do a comparision (before you tuck them away) and see if the amount of change is small enough to warrant end of movement. Not sure how construct handles floating point numbers, but if the expression round(self.X-self.lastX)+round(self.Y-self.lastY) == 0 it has come to rest.
B
13
S
2
Posts: 27
Reputation: 1,899

Post » Sun Oct 28, 2012 9:44 pm

Yes, that's what I mean.
I would like to know when there is nothing moving any more on the screen.

Duckocide, your suggestion would probably solve my issue, good idea
I will try that and tell you.
But it means, i have to do that on every objects of my canvas... Or mayby create a family with all objects instead of having these variables an all my objects.

I will tell you.

Thanks you.
B
8
Posts: 8
Reputation: 516

Post » Mon Oct 29, 2012 1:12 pm

I try your solution but with no success.
In fact, even if I put variables on my objects, I have to test the LastX en LastY of all the instance of my project.

How could I do that ?
If I test on : ObjectsMonster "myVariable" lasX lasst Y, it only test one of the instance (I don't know which one, probably the last one created).
And I have to test on every instance.

Any suggestion ?

Thanks.
B
8
Posts: 8
Reputation: 516

Post » Tue Oct 30, 2012 3:02 pm

I all,

I'm looking for a workaround, but I really don't find any solutions...
Somebody must have encountered this case, no ?

Just would like to test the activity on the canvas.

Pleaseee, any help would be highhly appreciated :)
B
8
Posts: 8
Reputation: 516

Post » Wed Oct 31, 2012 11:50 am

@Thibaut - use the LastX and LastY instance variables as Duckocide said, but before you check them for all instances of the objects, set a global variable to 0, then when you check them, if they are different set the global variable to 1. Then all you have to do is have an event after this that checks the global variable, if it's still 0, then nothing is moving.

I've made an example capx for you to look at. You can drag the balls around to get them moving.

Check Moving Example CAPX(r108.2)
Vote for all the Construct 2 games on Steam Greenlight - Find them here
B
27
S
7
G
4
Posts: 314
Reputation: 4,928

Post » Thu Nov 01, 2012 6:42 pm

Hi, just to let you know your solution works perfectly
That was just what i expected.

Thank you very much !
B
8
Posts: 8
Reputation: 516

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 20 guests