0

有什么方法可以在 gml 文件中使用 html 锚标记。我想在 gml 文件中创建指向位置/点的超链接。我怎么能这样做???提前致谢..

4

2 回答 2

1

This is a little known GML technique that GREATLY increases the power of Game Maker, and is well worth learning, but as a note, it does NOT work in Studio, because of the countless new restrictions on commands. Go back to GM8.1 (I only ever use that now), and you should have no problem making use of this technique.

The technique is to write a program in another language through GML (batch, vbs, etc, or in this case, HTLM), execute it through GML, then delete the program.

Quite simply, use the file_text commands to create a file with the correct content and extension, execute it with execute_program, and then delete it with file_delete.

Specifically for this script:

  • argument0 is the link, including the protocol.

  • argument1 is the anchor, minus the # (that's handled for you).

  • argument2 is the full browser path.

  • argument3 is important. This is the time in milliseconds the program will wait before deleting the temporary link file.

(The execute_program command, even when told to wait for the program to complete, continues as soon as the temp file is loaded. If external, the redirect takes some time depending on your connection, so deleting the temporary file halfway through will cause it to fail. 10 milliseconds worked fine for me. The program will hang for this time in this setup, but if you would like to set up an alarm based system to stop it from hanging, that wouldn't be too hard.)

In other uses of this technique without the use of the internet (I use small batch and vbs files a lot), the "hang time" (pun not intended) is usually not necessary.

In addition, the browser location will need to be changed for each different computer

file=file_text_open_write(temp_directory+"\tempLink.html")
file_text_write_string(file,'<!DOCTYPE html>')
file_text_writeln(file)
file_text_write_string(file,'<html>')
file_text_writeln(file)
file_text_write_string(file,'<body onload="')
file_text_write_string(file,"location.href='")
file_text_write_string(file,argument0+"#"+argument1+"';")
file_text_write_string(file,'">')
file_text_writeln(file)
file_text_write_string(file,'</body>')
file_text_writeln(file)
file_text_write_string(file,'</html>')

file_text_close(file)

execute_program(argument2,temp_directory+"\tempLink.html",true)

sleep(argument3)

file_delete(temp_directory+"\tempLink.html")
于 2014-06-06T03:41:42.400 回答
0

对不起,我希望这是可能的,但除非你想花很多时间在 dll 上,否则它是不可能的。但是您可以创建一个脚本并在代码中的任何地方重用它......

脚本0(参数0,参数1 ...)

于 2012-03-03T04:58:42.907 回答