Setting up the turrets
Now that we have a level, we need to add a turret. Double-click on the background, select add sprite, and then add the graphic. Make sure that the dimension of this graphic is 32
by 32
; everything that we had set up earlier needs to be on this grid. Your playing area should look like the following screenshot:
First, we will add some functionality using the following steps:
Add a Touch object from the Insert New Object window.
Then, go to your event sheet and add an event. This event is going to be a Touch event. Remember that touch events and mouse clicks are the same.
Tip
It's better to set up the touch event for simple clicks. Now, people on mobile devices can play your game.
When we touch the black area, a turret is spawned. This will spawn a turret on the screen. Add an On touched object event, as shown in the following screenshot:
The object we want to be touched is the
PlaceTurret
object, as shown in the following screenshot:Click on the Done button and your project...