Display Time and Date?

Non-platform specific questions.

Display Time and Date?

Postby CrimsonTheDarkBat » Wed Dec 02, 2009 9:47 pm

Hi, is there a way to display the time and date on an actor? And if possible, can you do so with a selected font and size?
Sonic Velocity Development Thread --> http://game-editor.com/forum/viewtopic.php?f=4&t=11461

Completed Games:
Sonic: War of the Emeralds
Sonic: Empire of Nightmares
Sonic.EXE - The Game
Alice: Crimson Omen
Epsilon 27
User avatar
CrimsonTheDarkBat
 
Posts: 223
Joined: Fri Mar 21, 2008 10:54 am
Score: 20 Give a positive score

Re: Display Time and Date?

Postby GeoGia » Thu Dec 03, 2009 12:09 pm

Hi Crimson :)

I don't know what your skill level is. This isn't the simplest thing in the world to do, but it's not too bad

The first thing you wanna do is go to global code and create a variable to hold info about the time:

stTime Clock;

stTime is just like int or char, except it makes a very specialized variable that's tailored to hold time and date info. Clock is just a name you choose. Type something in the box on the bottom and click Add.

Create an actor and click the text button. Type something in so it knows it's a text actor.

Add an event: Draw Actor: Script Editor. The first line you want is this:

Clock = getTime();

This stores all kinds of info about the time and date in Clock. Now for instance, if we wanted the year, we'd type "Clock.year", for hour "Clock.hour". Here's all the possibilities:

Code: Select all
sec: Seconds after minute (0 - 59)
min: Minutes after hour (0 - 59)
hour: Hours since midnight (0 - 23)

mday: Day of month (1 - 31)
mon: Month (1 - 12; January = 1)
year: Year (current year)

wday: Day of week (0 - 6; Sunday = 0)
yday: Day of year (0 - 365)

sec_utc: Number of seconds elapsed since midnight (00:00:00), January 1, 1970 (coordinated universal time)


Now we need to send info to the text of our text actor. If it was just normal text, it would be easy, but since we need numbers, we have to use formatting tricks

sprintf(text,"Time: %i:%i",Clock.hour,Clock,sec);

The first argument, text, just tells it where to put the text, here it just means the text holder of the actor you're in

The %i thingies are special codes that correspond to the arguments after the text in quotes. hour goes into the first %i, sec goes into the second. There are all kinds of codes for different things. %i just accepts an integer

Hope that explains it well enough :) You can change fonts in the text menu, you should see the button there. Good luck!
You don't know what you can do unless you've already done it
GeoGia
 
Posts: 19
Joined: Wed Nov 04, 2009 1:30 am
Score: 2 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron