We will now create a For loop. Create within the On start of layout event another sub-event. Select System: For. Give this loop the name "Obstacles" (don't forget the quotation marks). Set the Start index to 0 and the End index to 3. This gives us a total of 4 iterations. Add a local variable and name it HammerAngle.
When the hammers are created, we want them to start swinging from different angles, otherwise all the hammers will look the same.
Select the For loop and add the Create object action.
-System: Create object
-Object to select: obj_Girder
-Y: -172 (loopindex*-280)
Int will make the random number an integer number (e.g. -90, 25, -2 etc.). Loopindex holds the current iteration, starting at 0. -172 (loopindex x -280) is -172 (0 x -280) which equals -172.
Add the following actions:
-obj_Girder: Spawn another object. Object to spawn obj_Hammer on the "Enemies" layer at image point "Right".
-obj_Hammer (Sine): Set cycle position. Set the value to the local variable HammerAngle.
-obj_Hammer: Set angle of motion. Set the angle to 90 degrees.
Now repeat the above steps for the second hammer. Start by creating another hammer. Spawn the second hammer from image point "Left".
When you are done you should end up with this.
Save the project.