Shooting enemies in a certain order

This is my first go at Gdevelop. I am trying to create a game in which the shooter needs to destroy 12 enemies that are all in the scene at the same time and advancing towards him.
Basically, the player has to shoot the months of the year in the right order. When the right month is shot, that month is destroyed. If the player shoots the wrong month, the month stays in the scene until it is shot in the right order.
I can’t find any tutorials that will show me how to create this condition/action. It would be something like the “broadcast” block in Scratch.
Thank you for your help!

Check this example:
ClickOrder.gdg (9.82 KB)
Each text object has a different value for the ID variable, the ID determines the order to click and delete them. Then there is a scene variable storing the next ID you have to click at, with this variable you can decide if the clicked object can be deleted (and icrease the scene variable to be able to delete the next one), or ignore it :slight_smile:
To put the logic in your game you have to change the condition “mouse over object” + “mouse released” with your own conditions, for example “bullet collides with object”.

Hello Lizard-13!
Thank you so much for replying. I am trying to work it out. It seems so simple and YET I am so slow at making it work! I will post the end result when I get it right.

Also, check the text objects properties, I’ve set the ID variable for each instance manually, there isn’t an ID variable by default. You could rename the variable as you want, for example Order :slight_smile:

The thing is that my objects are not text objects, but png animated objects. So, I went to Object#1’s properties and I created the variable ID and gave it the value “1”. So, I can’t work out the equivalent of your first action for an object the “Text.VariableString (ID) to the text of Text”. Tell me if it’s too many questions! :confused:

You can do it with any object type, the important things are:

  • Each instance needs an unique ID variable, it determines the order.
  • A scene variable to track the next ID to delete, initialized with the first object ID (in my example, 1).
  • This event:
    Again, my condition is “click over YourObject”, change it with your own conditions.

This event changes the string of each text to display it’s ID, it is just visual debugging to make sure it works fine, if you are using sprites you can’t do it but you don’t need it at all :slight_smile:
Try deleting this action in my example, everything will work, but you won’t know the order to click the texts :wink:

Here is a screenshot of my events. The first 4 lines are just NinjaGirl’s moves and the creation of shots. I followed your instructions. Every Sprite has an ID number (Properties>Variables>Variable ID with Initial Value 1 for January/MonsterJan). After I deleted the Text/String of a Variable action, I managed to shoot January. But, it still doesn’t work with Feb and March. I only did 3 months to test. I changed Variable(IDtoClick) to Variable (IDtoCollision). I tried different values in the action side now +1, +2, +3).
Before I started to complicate things with the variables, I could destroy all 3. So, the collision and explosion conditions/actions were working.
Is it that I am not making the connection between ID and Collision somewhere?
Thanks for your help! :slight_smile:

Ok, I see, this is the problem:

  • The variable IDtoCollision is = 1 by default, so the first object that can be deleted has a variable ID = 1.
  • If you click January (it has ID = 1), it’s deleted, but you don’t increase the variable IDtoCollision, you set it again = 1. It is not the same to do “Do + 1 to variable IDtoCollision” (increase the variable by 1) and “Do = +1 to variable IDtoCollision” (set variable as +1 = positive 1 = 1.
  • The variable IDtoCollision is 1 so you can’t delete other months.

So, to fix it, you can do one of the following:
A - When you delete January, set IDtoCollision = 2, so you can delete February later. And when you delete February, set IDtoCollision = 3, to be able to delete March later.
B - When you delete January, add 1 to IDtoCollision, so it’ll be = 2. And when you delete February, add 1 IDtoCollision, so it will be = 3.

Finally, GD has something called “Object groups”, you can put multiple objects with the same mecanics inside a common group, then in the events you can select a group as an object to launch the conditions/actions over every object inside the group.
For example, you have a “Zombie” object and an “AcidSpitter” object, both of them walk slowly to the player, so you could add them to a group “Walkers”. Now you can add logic to move “Walkers” to the player, and both of them will walk. But the “AcidSpitter” can… spit acid duh, so you have to add more logic to spit acid, but selecting the “AcidSpitter” object only, not the group :slight_smile:

As you can guess, I have some free time, so I made another example file, it has two scenes:

  • In the first scene, there are 3 months moving toward the mouse, and you have to click them in order to detroy them (I don’t speak english natively, but it seems that “in order to” has double meaning here :confused: ), as you are doing right now. In one action I use set variable IDtoCollision = 2 to click the next month with ID = 2, and in other action add 1 is used, to increase IDtoCollision from 2 to 3, just to show the difference.
  • In the second scene, the logic is the same, but applied only once to the group “Months” to save code (it’s like a rule in programming, when you are copying and pasting the same code again and again, think it twice). Each month moves with a different speed because I’ve set a new variable for each instance, called “Speed” :wink: : (7.69 KB)

It works!!! :smiley: Thank you so much for your help and even making that mini-game for me. I couldn’t have done it without your help!
Now I “only” need to work on graphics, levels, lives, timer, etc…a piece of cake, I’m sure!