mirror of
https://github.com/photonstorm/phaser
synced 2024-11-27 15:12:18 +00:00
Added willRender override and start of event handling
This commit is contained in:
parent
6a3274b483
commit
de4428ac52
1 changed files with 44 additions and 1 deletions
|
@ -58,6 +58,8 @@ var DOMElement = new Class({
|
||||||
|
|
||||||
this.parent = scene.sys.game.domContainer;
|
this.parent = scene.sys.game.domContainer;
|
||||||
|
|
||||||
|
this.cache = scene.sys.cache.html;
|
||||||
|
|
||||||
this.node;
|
this.node;
|
||||||
|
|
||||||
this.skewX = 0;
|
this.skewX = 0;
|
||||||
|
@ -94,6 +96,41 @@ var DOMElement = new Class({
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compares the renderMask with the renderFlags to see if this Game Object will render or not.
|
||||||
|
*
|
||||||
|
* @method Phaser.GameObjects.GameObject#willRender
|
||||||
|
* @since 3.0.0
|
||||||
|
*
|
||||||
|
* @return {boolean} True if the Game Object should be rendered, otherwise false.
|
||||||
|
*/
|
||||||
|
willRender: function ()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
|
listen: function (events)
|
||||||
|
{
|
||||||
|
if (!this.node)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
events = events.split(' ');
|
||||||
|
|
||||||
|
for (var i = 0; i < events.length; i++)
|
||||||
|
{
|
||||||
|
this.node.addEventListener(events[i], this.dispatchNativeEvent.bind(this), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
|
||||||
|
dispatchNativeEvent: function (event)
|
||||||
|
{
|
||||||
|
this.emit(event.type, event);
|
||||||
|
},
|
||||||
|
|
||||||
setElement: function (element)
|
setElement: function (element)
|
||||||
{
|
{
|
||||||
var target;
|
var target;
|
||||||
|
@ -118,6 +155,10 @@ var DOMElement = new Class({
|
||||||
target.style.display = 'inline';
|
target.style.display = 'inline';
|
||||||
target.style.position = 'absolute';
|
target.style.position = 'absolute';
|
||||||
|
|
||||||
|
// Node handler
|
||||||
|
|
||||||
|
target.phaserElement = this;
|
||||||
|
|
||||||
if (this.parent)
|
if (this.parent)
|
||||||
{
|
{
|
||||||
this.parent.appendChild(target);
|
this.parent.appendChild(target);
|
||||||
|
@ -132,13 +173,15 @@ var DOMElement = new Class({
|
||||||
|
|
||||||
createFromCache: function (key, elementType)
|
createFromCache: function (key, elementType)
|
||||||
{
|
{
|
||||||
return this.createFromHTML(this.scene.sys.cache.text.get(key), elementType);
|
return this.createFromHTML(this.cache.get(key), elementType);
|
||||||
},
|
},
|
||||||
|
|
||||||
createFromHTML: function (html, elementType)
|
createFromHTML: function (html, elementType)
|
||||||
{
|
{
|
||||||
if (elementType === undefined) { elementType = 'div'; }
|
if (elementType === undefined) { elementType = 'div'; }
|
||||||
|
|
||||||
|
console.log(html);
|
||||||
|
|
||||||
var element = document.createElement(elementType);
|
var element = document.createElement(elementType);
|
||||||
|
|
||||||
element.innerHTML = html;
|
element.innerHTML = html;
|
||||||
|
|
Loading…
Reference in a new issue