Make a timer which counts up or down how much time is left to play.
Create an object. You do not need a sprite. Click on add event, create. Drag set the value of a variable, under the control tab, into the action section.When the popup appears, type mytime into the variable section. Type how long you want the timer to countdown into the value section (mine is 20). Drag set an alarm clock, under the main2 tab, into the action section. Type in room_speed, or 30, into the number of steps section. Select alarm0 in the alarm no. section.
Click on add event, alarm0. Drag set the value of a variable, under the control tab, into the action section. When the popup appears, type mytime in the variable section. Then type -1 in the value section. Tick the relative box.
Click on add event, draw. Drag draw a text, under the draw tab, into the action section. Type ‘Time left in game: ’+string(mytime)+’ seconds’ into the text section. Leave the x and y sections 0.
Put this object in a room, and play it, to see if it works.
stefen helped me with the mytime part, and then using the equal to and or else functions i was able to stop the timer at 0 seconds.
Information about object: obj_timer
Sprite: <no sprite>Solid: false Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Create Event:set variable mytime to 20set Alarm 0 to room_speed
Alarm Event for alarm 0:if mytime is larger than 0set variable mytime relative to -1
set Alarm 0 to room_speed
if mytime is equal to 0
set variable mytime relative to 0
Step Event:if number of objects obj_timer is Equal to 0Draw Event:at position (0,0) draw text: ‘Time left in game: ‘+string(mytime)+’ seconds’