Overlay object with HTML

Stats

1,016 visits, 1,472 views

Translations

This tutorial hasn't been translated.

Tools

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

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