How do I set the same random animation for two sprites?

0 favourites
  • 5 posts
From the Asset Store
This is a Dungeon Master tool & the 1st of 12 Combat Engines from the Building Combat Engines for Browser Games workshop
  • Hello everyone, I'm making a game where you guess the country by it's map and flag

    I made two sprites one for the maps and the other for the flags, and put the u=images inside them as animations not frames, each image in a separate animation and named them

    I was able to select a random animation using : choose("0","1","2,"3",,,,) the numbers are the animations names, the thing is I want to store the random value he chose and set it for the other sprite how can I do that?

    Also how can I make it as a quiz, under the images there would be different selection of the country names but I want to make sure the correct country is shown in the selection ? can json help me? or some function would be able to make it easier?

  • Store the random value in a variable.

    Set randomAnim to choose("1", "2", "3")
    Country set animation to randomAnim
    Flag set animation to randomAnim
    

    It may be better to name the animations properly, by country name.

  • You could store the choose result in a variable like described above. Or use a function with a parameter. When calling the function you could use "choose" for the Parameter and the function then sets the animation for both sprites.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Store the random value in a variable.

    > Set randomAnim to choose("1", "2", "3")
    Country set animation to randomAnim
    Flag set animation to randomAnim
    

    It may be better to name the animations properly, by country name.

    Thank you so much.

    Do you have any idea how to set the correct answer into a random text and two wrong answers in different ones? Like I have three texts and want one of them randomly to have the correct answer while the others will take wrong answers from choose("Tunisia", "Ghana",..) except the correct answer, it would mean a lot to me.

  • It depends on how you designed your game. You can put all sprites with countries on the layout, outside of the visible area. Pick two random sprites and display their animation names as wrong answers. Destroy those sprites.

    Then pick one random sprite, move it to the visible area and display its animation as the right answer.

    .

    Or if you have an array with all country names, display three random names. Then pick one of them at random (correct answer) and set the sprite animation to it.

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