Overlay object with HTML

2

Stats

2,588 visits, 3,506 views

Tools

Translations

This tutorial hasn't been translated.

License

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.

Published on 14 Jul, 2014. Last updated 19 Feb, 2019

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>';
    (function(elem,html,id){
        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;
        },false);
        document.body.appendChild(new_div);
        if(id)  new_div.id = id;
    })(window['my_div'],HTML,'my_new_div');"


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.

  • 0 Comments

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