1 decade ago by UziMonkey
I just wanted to embed my ImpactJS game (a Ludum Dare entry) onto a Wordpress page. I did it, but it took most of the evening to get everything just right.
At first I used an iframe. This works just fine, except there's a focus problem and you have to click the game or it won't receive any events. If you click outside of the iframe, you have to click it again. I wanted to avoid this confusion.
So I decided to go with a prefix prepended to all paths. You just define it in window.igprefix before you load your game and you're good to go. The ImpactJS source code has to be modified in a few key places, but it's not difficult.
The specifics are here on my blog: http://www.uzimonkey.com/?p=45
Dominic said he might include this in the next version of Impact, so this hack might not be needed for much longer.
Also, to everyone who says this should be a plugin, I couldn't figure out how to get that to work. The plugin needs to be loaded by the loader code, which needs to be patched by the plugin in order to find the plugin.
At first I used an iframe. This works just fine, except there's a focus problem and you have to click the game or it won't receive any events. If you click outside of the iframe, you have to click it again. I wanted to avoid this confusion.
So I decided to go with a prefix prepended to all paths. You just define it in window.igprefix before you load your game and you're good to go. The ImpactJS source code has to be modified in a few key places, but it's not difficult.
The specifics are here on my blog: http://www.uzimonkey.com/?p=45
Dominic said he might include this in the next version of Impact, so this hack might not be needed for much longer.
Also, to everyone who says this should be a plugin, I couldn't figure out how to get that to work. The plugin needs to be loaded by the loader code, which needs to be patched by the plugin in order to find the plugin.