Jump to content


Photo

sprite n time


  • Please log in to reply
4 replies to this topic

#1 Flygon12

Flygon12

    GMC Member

  • GMC Member
  • 103 posts
  • Version:Unknown

Posted 27 June 2012 - 04:58 PM

I wonder if i can do this:

1- i´ve: an ob_player with sp_Red ; 2 sprites (sp_Green, sp_Yellow)

2-If it's 12:00 (computer time) change to sp_Green ; 00:00 change to sp_Yellow ; 6:00 change to sp_Red.

3-I use GM lite.


EDIT: THANKS, oopl.x.beast.

Edited by Flygon12, 27 June 2012 - 05:29 PM.

  • 0

#2 oopl.x.beast

oopl.x.beast

    GMC Member

  • GMC Member
  • 77 posts
  • Version:GM8

Posted 27 June 2012 - 05:05 PM

There are time-related functions in GM, yes. You could do something like this:

if(current_hour==12){
    sprite_index = sp_Green;
}else if(current_hour==0){
    sprite_index = sp_Yellow;
}else if(current_hour==6){
    sprite_index = sp_Red;
}

  • 0

#3 Flygon12

Flygon12

    GMC Member

  • GMC Member
  • 103 posts
  • Version:Unknown

Posted 28 June 2012 - 08:24 AM

Now, if i want ob_play has sp_red between 12:00-16:59, between 17:00-05:59 change to sp_green ; between 6:00-11:59 change to sp_yellow,
how can i do it?
  • 0

#4 Flygon12

Flygon12

    GMC Member

  • GMC Member
  • 103 posts
  • Version:Unknown

Posted 28 June 2012 - 08:27 AM

sorry, i have sent twice the message. :tongue:

Edited by Flygon12, 28 June 2012 - 08:28 AM.

  • 0

#5 Untaken

Untaken

    GMC Member

  • GMC Member
  • 106 posts
  • Version:GM8

Posted 29 June 2012 - 12:01 PM

Going by the code above, change the conditions for the sprites:
if current_hour>11 and current_hour<17 then sprite_index=sp_Red
else if current_hour>16 and current_hour<6 then sprite_index=sp_Green
else if current_hour>5 and current_hour<12 then sprite_index=sp_Yellow
Should work assuming that GM uses a 24 hour clock and based on the clock changing the hours based on the minutes.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users