ok,
[quote:3o5mx22n]You need to assign a variable into the object player needed to collide with. You assign variables of these objects in a running number. (ex. 1st object created is assigned 1, 2nd object is assigned 2, etc.)
First, let's take care of the variables.
Create a global variable called "runningNumber" and give it value of 1 in your event sheet.
Create an instance variable for the object and call it indexNumber, set default value to 0.
[quote:3o5mx22n]You will also need to assign a variable to the player and assign a number that player needs to go for. (in the case, the 1st object, which has the variable value of 1, so you assign 1 to the player's variable, too.)
Since you want the player to go for the objects in the order they are created. We need to assign a number to these objects when these objects are created.
In the object's On Create event, set the object's indexNumber to the global variable runningNumber. Then, add 1 to the global variable runningNumber.
Why add 1 to the global variable runningNumber? This is so whenever another object that the player has to go for is created, it will have the succeeding number. (For example, when the first object is created, it will have indexNumber set to 1, the second object will have indexNumber as 2, and so on.)
[quote:3o5mx22n]When the collision occured between the player and the object, you checked for the numbers of both the player and the object. If both numbers are the same, you can destroy this object and assign the next number the player needs to go for, in this case 2. Else if the numbers are not the same, game over.
Now, the main crux. We have these objects created and each of them have indexNumber assigned in sequential order by the order they are created.
Create an instance variable for the player, call it "nextIndex" and assign it a value of 1.
Now, create a collision event for the player colliding with the object. In this collision event, you will check for the player's nextIndex and the object's IndexNumber. If these two numbers are equal, it means the player is touching the right object. Else, the player is touching the wrong object.
From this logic, you can create Collision event like this:
Player On collision with Object
> if Player.nextIndex = Object.IndexNumber : > > > Add 1 to Player.nextIndex
> > Object destroy
> else
> > Player destroy
The first time the player collides with Object, if the object has IndexNumber of 1, which is the same as the value of the player's Nextindex, this implies the player is touching the first Object correctly. If the object the player touches does not have IndexNumber of 1, the player touches the wrong object and will be destroyed.
Why do we put "Add 1 to Player.nextIndex" there? This is because the next Object the player should touch is 2. And the same logic from above can be applied. The player will survive as long as he keeps on touching the correct objects using these incremental numbers, but the player will be destroyed if he touches the incorrect object.
Is this explanation better?