How do I match the animations frames of two sprites

Get help using Construct 2

Post » Sat Jun 28, 2014 5:20 pm

Hello all,

I'm working on a game in witch I made the obstacles this way:
-one sprite, 5 frames, each frame is a different obstacle
-I made the sprite to display the 5 frames randomly

Now, my problem is that I want to match another sprite ( that also has 5 frames) to the first sprite.
frame1(sprite1) to frame 1(sprite2)
frame2(sprite1) to frame 2(sprite2)
frame3 (sprite1) to frame3(sprite2) and so on

But the first sprite displays it's frames randomly. How do I match the frames of this 2 sprites???
I already tryed
-------sprite 2 on created->set animation frame to sprite1.AnimationFrame

It dosen't work because sprite 1and2 spawns outside the layout just like flappy birds.....so I don't think sprite 2 knows to witch frame to set it's animation since sprite 1 spawns constantly and always has a different frame displayed.

Pls help. It's been already a week since I try to solve this . :cry:

Thank you all so much
B
5
S
1
Posts: 15
Reputation: 407

Post » Sat Jun 28, 2014 5:42 pm

Assuming that Sprite1 is always there (and is the only one of Sprite1 in the layout) and randomly sets its frame. Sprite2 is spawned and scrolls left, I'd do the following.

Every tick -> Sprite set animation frame to random(Sprite.AnimationFrameCount)

(spawning event) -> Create object Sprite 2 on Layer N at X and Y
-> Set animation frame to Sprite.AnimationFrame
"Construct 4 lets YOU make advanced games! (but not play them)" Construct Classic - Examples Kit Dropbox is a pile of trash and if you need my old files PM me! :)
B
124
S
42
G
17
Posts: 2,225
Reputation: 19,887

Post » Sat Jun 28, 2014 6:09 pm

(spawning event) -> Create object Sprite 2 on Layer N at X and Y
-> Set animation frame to Sprite.AnimationFrame

I already did this and dosen't work. Sprite 2 acts as if it dosen't know wich frame to choose so it plays all the frames it has as if searching for the right frame. That is because sprite 1 , every time it is created it displayes a different frame....and sprite 2 tryes to catch up.
B
5
S
1
Posts: 15
Reputation: 407

Post » Sun Jun 29, 2014 3:37 am

Can you add a capx file or tell us more about your 2 objects that you're trying to "match"?
Because I can't figure out what you're actually trying to do here.
You can try using 2 variables that contain the values of the frames of both objects.
You will have variable_object1_frame and variable_object2_frame which are both indicating what frame the objects are at.
Everytime you change the frame of 1 object, you will also change the variable to it's respective frame for instance if object 1 turns into frame 3,
you will change variable_object1_frame to "3".

With this variable you will be able to set the frame of object 2 when nessecary.

I hope this helps you with your issue.
B
6
S
1
Posts: 73
Reputation: 571

Post » Sun Jun 29, 2014 7:19 pm

thank you rezagamertag...Jayjay already helped me figure this out :D
B
5
S
1
Posts: 15
Reputation: 407


Return to How do I....?

Who is online

Users browsing this forum: MrQuickGame and 6 guests