Hi! I'm trying to implement Gamepix SDK to my HTML game but I have no idea how to get the GamePix.pause function to pause my game. GamePix.pause = function () { / insert here the code to pause your game / } GamePix.resume = function () { / insert here the code to resume your game / }

How can I call my Godot function from the HTML file?

Welcome to the forums @Mark200!

I haven’t tried having Javascript code call Godot code, but I think it may be possible, if not now then in the future. This blog post on the Godot engine blog might be helpful for how it is (or is going to be?) possible to communicate between Javascript and Godot: Godot Web Progress Report 9

Thanks for the reply @TwistedTwigleg I tried to follow the instructions to create a callbacks function but it doesn't seem to work...

extends Node
var _pauseGame_callback = JavaScript.create_callback(self, "_on_pauseGame")


func _ready():
	var GamePix = JavaScript.get_interface("GamePix")
	GamePix.pause = _pauseGame_callback



func _on_pauseGame():
	get_tree().paused = true

I'm afraid I do not know right off. I have not really used it myself, so I can only guess as to why it is not working.

Are you using a dev snapshot of Godot 3.4? I think the new Javascript interface is only available in Godot 3.4 and Godot 4.0, if I am understanding the linked pull requests in the blog post correctly.

Also, did you include the GamePix library in the HTML head include? I'm not sure if its required, but it may be something to look at.

a month later

@TwistedTwigleg Sorry for the late reply, I tried it on Godot_v3.4-rc2 and it worked. Thanks!

@Mark200 said: @TwistedTwigleg Sorry for the late reply, I tried it on Godot_v3.4-rc2 and it worked. Thanks!

No problem! I’m glad it worked :)

a month later

Great teacher, I studied for a long time and finally succeeded! on_pauseGame This method must add parameters to succeed, like this func on_pauseGame (args):

Yes, that has tripped me up a few times because there is no error. You have to read the docs carefully.

a year later