How do I create sprite object instance that look different

0 favourites
  • 3 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • I have one type of enemy. They all have the same instance variables values. They all act the same, have the same health etc... and they spawn in every few seconds. How do I make it so that they spawn in with a slightly different looking uniform (different color)? Do I have to create a different object type of each different enemy color, even though they are really all the same (except for their look) or is there a simple way to make each new instance of the same object type look different?

    Thank you

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • neoflash1979

    There are many ways to go about this.

    You should add an instance variable for your sprites appearance: ex. Enemy.Skin.

    Now when you spawn your Enemy, add the action: set value of Enemy.Skin to choose("blue", "red", "green"....)

    If you plan on increasing the number of appearances, you might consider storing that info on an array and calling it by: set value of Enemy.Skin to SkinArray.At(ceil(random(0, (SkinArray.Width)))-1)

    Name your animations according to the skin names you might choose ex.: "blue", "red", "green"...

    Don't forget to call your Enemy's animation in the spawning process:

    Set animation to Enemy.Skin

    Does your enemy sprite need more than one animation to run? If so:

    Change your animation names from "Running", "Shooting", etc to "BlueRunning", "RedRunning", RedShooting"

    Set the animation to Enemy.Skin&Enemy.Action (Assuming Enemy.Action is the instance variable that dictates your sprites action states).

    Of course, if your sprite does not animate (has only one frame) you can just add difference frames, set animation speed to 0 and randomly choose a frame to be set to.

    I hope this helps!

  • Brilliant! That is exactly what I was looking for. Thank you.

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