Randomly select different sprites

0 favourites
  • 3 posts
From the Asset Store
This music pack covers differents situations for visual novels, anime games and many more!
  • Currently, I have a game that randomly selects a window (a sprite) in the viewport, and then spawns a "Guy" sprite on the image point of the window:

    This code works. However, I have a half-dozen different enemy images. I would like is to randomly select a window, and inside that window, select a random sprite (Guy1.png, Guy2.png, etc.) What is the proper way to do that?

    Tagged:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If you put all the enemies in a family you can just spawn an instance of the family object and it will randomly pick one of the Instances in the family.

    If it´s just a single Sprite with different animations, you can set the animation after creating it. Either with choose("animationA", "animationB",...) or if you have many animations you could use random like Set animation to "animation" & floor(random(100))

  • Or use "System Create by name" action, for example:

    Create by name "Guy"&int(random(10)) at Window.x, Window.y

    Note that int(random(10)) will return numbers from 0 to 9.

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