Overlay object with HTML



2,016 visits, 2,716 views


This tutorial hasn't been translated.



This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

A quick and dirty way to add an HTML element to your game

We'll be using the browser plugin & the button plugin for this example.

-Give the button an id of my_div in the project bar

- Now on start of layout we want to 'Execute Javascript'

    "var HTML = '<p style=""color:white; width:inherit; height:inherit; background:red;"">Some Paragraph</p>';
        var new_div = document.createElement('div');
        if(html) new_div.innerHTML = html;  
        new_div.style.cssText = elem.style.cssText;
       elem.addEventListener('DOMAttrModified', function(e){
        if(e.attrName == 'style') new_div.style.cssText = elem.style.cssText;
        if(id)  new_div.id = id;

It creates a new div with an id of my_new_div and copies the style of button element (on change);

Notes : You could also sub the button plugin another form control that has an id property.


  • Order by
Want to leave a comment? Login or Register an account!