How do I match the animations frames of two sprites

0 favourites
  • 5 posts
From the Asset Store
Selection frame like in RTS games, works both on mobile and desktop devices.
  • 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 .

    Thank you all so much

  • 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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • (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.

  • 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.

  • thank you rezagamertag...Jayjay already helped me figure this out

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