Legacy GM [SOLVED] Help with Change Instance

G

Guilherme Hernandez

Guest
I need some help with my project. I have a sun and a moon. They will remain in the same place, and I want them to change every 30 seconds. But I do not know how to do that.
Each of them has a sequence of 5 sprites.

I am new to the programming codes, I tried to do it with DnD but I could not, can anyone help me?

If anyone knows of a free course, by google or somewhere else, who teaches the basics of programming codes, I would be grateful!

Thank you for your attention!
 

DarthTenebris

Definitely not a Sith Lord
Use brain logic, move on to GML (or DnD, in your case).

1) Set up an alarm to 30x whatever your room speed is. That should be 30 seconds, as 1 room speed is equivalent to 1 second of real time.
2) When the alarm goes off, change sprites. Don't worry about the animation, just change the sprite.
3) To keep it continuous, set the alarm to 30 seconds again.

Hope it made sense :)
 
G

Guilherme Hernandez

Guest
Use brain logic, move on to GML (or DnD, in your case).

1) Set up an alarm to 30x whatever your room speed is. That should be 30 seconds, as 1 room speed is equivalent to 1 second of real time.
2) When the alarm goes off, change sprites. Don't worry about the animation, just change the sprite.
3) To keep it continuous, set the alarm to 30 seconds again.

Hope it made sense :)
My room speed is 30 fps... But i didnt undertand
To take 30 seconds i need to do 30x30, Right? But how can i do that with DnD

But i dont know how to use alarm to do that, can teach me?

I have an empty object who name is objSignal.
 
K

KaiXtr

Guest
What do you mean is that every 30 seconds the animation changes a frame? Then it does so:

Create Event
Code:
animation=1
alarm[0]=300
Alarm 0
Code:
animation+=1
alarm[0]=300
Step Event
Code:
if animation=1{draw_sprite(your sprite,0,x,y)
if animation=2{draw_sprite(your sprite,1,x,y)
if animation=3{draw_sprite(your sprite,2,x,y)
if animation=4{draw_sprite(your sprite,3,x,y)
if animation=5{draw_sprite(your sprite,4,x,y)
if animation>5{animation=1}
I hope I have helped!:p
 
G

Guilherme Hernandez

Guest
Its possible u
What do you mean is that every 30 seconds the animation changes a frame? Then it does so:

Create Event
Code:
animation=1
alarm[0]=300
Alarm 0
Code:
animation+=1
alarm[0]=300
Step Event
Code:
if animation=1{draw_sprite(your sprite,0,x,y)
if animation=2{draw_sprite(your sprite,1,x,y)
if animation=3{draw_sprite(your sprite,2,x,y)
if animation=4{draw_sprite(your sprite,3,x,y)
if animation=5{draw_sprite(your sprite,4,x,y)
if animation>5{animation=1}
I hope I have helped!:p

Hello KaiXtr, thanks to Replay. But no, I'm trying to change objects, Switch from sun to moon (example, as if it were day and night). I tried to do what Fat_Man said, but when the 30 seconds, the moon is behind the sun ... I tried to put "Destroy instance" in the sun, to put the moon but it, did not change anymore or destroyed ...
 
G

Guilherme Hernandez

Guest
I created Step event:
if(alarm[0] == -1)
{
alarm[0] = room_speed * 3; // I set 3 to dont wait all 30 seconds :D
}


Then i created Alarm 0 (DnD)
"Create Instance of Random Object" And set Sun object and Moon object at same positon
then
"Destroy the instance" and set do Self
 
G

Guilherme Hernandez

Guest
But it didnt work... i dont know what is the problem...
 
G

Guilherme Hernandez

Guest
HAHAA now its working!!

I changed position of destruction, and set
"Destroy the instance" and set do objSun
"Destroy the instance" and set do objMoon Then
"Create Instance of Random Object"
___________________________________________________________________________________

"Create Instance of Random Object" And set Sun object and Moon object at same positon
then
"Destroy the instance" and set do Self

Thanks so much to try help me KaiXtr!!
 
Top