Let system predict which random sprite it's going to spawn?

0 favourites
  • 3 posts
From the Asset Store
Lets Become Rich
$27.30 USD
30% off
Who wants to be a Millionaire Clone. An educational coding source
  • Hello community,

    I'm looking for a way to let the system predict which one of the three randomly chosen sprites it's going to spawn.

    I have a family with three sprites which are used as bullets. These sprites have different collors and are shot from a gun by click, picked randomly by the system. I need the system to predict which sprite it is going to "shoot" before I trigger this action. Is this in any way possible? The player should know which color his next bullet will be, so he can shoot the enemy with the same color.

    I'm sorry if this is unclear, I don't know how to explain it better haha.

    Hope to see some replies, thanks in advance!

    ~ Juneau.

  • When you spawn a family instance, family member will always be picked at random, you can't predict it.

    Why did you make them as separate objects anyway? If the only difference between bullets is their color, you can put them all in one sprite (as 3 frames or 3 animations). Then simply spawn this sprite and change its frame/animation.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • dop2000 is correct when he says it's probably better to handle the bullet with one object rather than three, presuming the bullets all behave the same otherwise. I like the idea by the way, only allowing the player to shoot matching enemies, that's cool.

    If you need to do this still (ie, bullets of different colours behave very differently and can't be handled using a single object) you can do it using a variable on the player. Make it a text variable, and whenever the player fires a weapon (or on the start of the layout) you fire the currently indicated colour of bullet, then set the variable to:

    choose( "red", "blue", "yellow" )[/code:3q68yvx4]
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)