Counts how many seconds have passed since the program has started.
World.seconds
is a method that tracks how many seconds have passed since the program has started, or rather, how many seconds the program has been running for. This can method can be useful for changing elements of your game up until or after a certain amount of time, like a title screen that should play for three seconds before your game starts.
function draw() { background("white"); var count = World.seconds; if(count > 60){ textSize(20); fill("black"); background("red"); text("More than 1 minute has passed", 10, 200); } else{ background("green"); } }
function draw() { background("white"); var count = World.seconds; if(count > 2){ background("green"); } }
textSize(30); var screen_text; function draw() { background("white"); var count = World.seconds; if(count > 2){ screen_text = text("The game is starting!", 70, 200); if(count > 5){ titleScreen(); } } else{ screen_text = text("Welcome!",130, 200); } } function titleScreen() { textFont("Monospace"); stroke("green"); strokeWeight(3); textSize(25); background("red"); screen_text = text("Welcome to Map Blaster", 30, 200); }
World.seconds
The number of seconds (in full seconds, not milliseconds)
Found a bug in the documentation? Let us know at documentation@code.org