clickable_add_ext

With this function you can create a custom, clickable, icon that acts as a "button" outside of the game canvas, but within the browser window itself. The function will return an ID value which must be stored in a variable to be used in all further button functions that reference the new clickable. This function is very useful to prevent the browser creating a pop-up window when clicking on the button as it is all done through GameMaker itself.

This function works exactly the same as the clickable_add() function, where you must set the position relative to the (0,0) of the browser window, give the texture page entry for the sprite you wish the button icon to have (see: sprite_get_tpe()), specify either a URL to open or a script (from the Asset Browser of GameMaker) to be opened or run then set the target and parameters to use. However this function also has two additional options that permit you to set the icon alpha from 0 (fully transparent) to 1 (fully opaque) and the scale of the icon, which is a multiplier value applied to the sprite used. So a value of 1 is the default scale, while (for example) 0.5 would be half scale and 2 would be double.

It is also worth noting that if the URL argument you pass in is the name of a script function (ie: it doesn't start with "http://") AND the script is called gmcallback_* then you can get direct feeds into an html5 event. GameMaker script function names are not obfuscated if they begin with gmcallback_.

 

Syntax:

clickable_add_ext(x, y, tpe, url, target, params, alpha, scale);

ArgumentTypeDescription
xRealThe x position within the window.
yRealThe y position within the window.
tpeTexture Page EntryThe texture page entry for the sprite to be used.
urlStringThe URL (website address) to link to, or the script to be run.
targetStringThis is the target area to open the URL in (see description).
paramsStringThe various parameters for the icon (see description).
alphaRealThe image alpha of the icon (default 1).
scaleRealThe scale of the icon (default 1).

 

Returns:

Clickable ID

 

Example:

home_but = clickable_add_ext(32, 32, sprite_get_tpe(spr_MS_Home, 0), "http://macsweeney_games.com", "_blank", "width=700, height=500, menubar=0, toolbar=0, scrollbars=0", 1, 2);

The above code creates a clickable DOM icon at the position (32, 32) of the page that the game canvas is running on. The icon uses the sprite referenced from the texture page as "spr_MS_Home" and when clicked the icon will open a new window for the specified URL and with the defined properties for that window. the button will also be scaled to twice the original sprite size and half an image alpha of 1.