Pausing game

Please let me know if you received it

I’ve received it and had a look. You are indeed sending a “set_time_step” message but not to the correct place. From main.gui_script you do:

		msg.post("#main", "set_time_step", {factor = 0, mode = 0})

The use of “#main” as URL means that the “set_time_step” message will be sent to a component “main” on the same game object as “main.gui_script”. There is no component named main:

You need to send the “set_time_step” message to the collection proxy component that you want to pause. In your case it is “loader:/go#main”:

msg.post("loader:/go#main", "set_time_step", {factor = 0, mode = 0})
1 Like

Oh, yeah, and your background animation is NOT using dt:

function update(self, dt)
	local pos = go.get_position()
	pos.x = pos.x - 0.1
1 Like

Hi thanks for the help, I’ve implemented those things into my code and now its created a series of more issues. Now my player doesn’t move at all, and when I implement dt to my background animation it does not work.

Did you change from pos.x = pos.x - 0.1 to a larger value? Remember that dt is approx. 0.016 (1/60). You need to increase it. Try:

pos.x = pos.x - 6 * dt

What do you mean? After you paused and then resumed? Or does it not move even before pausing?

Yep it doesnt even move before pausing the game

ill give this a try

Do you still have my project downloaded? If so try add what you suggested, and you can see what i mean. Its hard to explain

I changed the background script to pos.x = pos.x - 6 * dt, and now it just moves even slower, and it still doesnt stop when i press pause

Is your background in the same proxy collection that you pause?
Does the player scipt acquires input? Like printing something when pressing a key.

Yes the background is in the same proxy collection, and the player ship is meant to move when i press W,A,S,D. I could perhaps send the zip file of my project to you on discord

Does your player scipt contains msg.post(".", “acquire_input_focus”) ?

image

yes

In the last image dosn’t seem that you adding amount to the movement, like in the one above “pos.x = pos.x + speed * dt”

are you talking about the background script?

Which image do you mean?

like this?
image

No, sry my bad. You are adding but are you chaning the self.direction in the input func?