var stageWidth = innerWidth;
var stageHeight = innerHeight;
var stage = new Hilo.Stage({
container: document.body,
width: stageWidth,
height: stageHeight,
renderType: 'canvas'
});
stage.enableDOMEvent([Hilo.event.POINTER_START, Hilo.event.POINTER_MOVE, Hilo.event.POINTER_END]);
var ticker = new Hilo.Ticker(60);
ticker.addTick(stage);
ticker.start();
var font = "14px arial";
var content = "Hello World! Hilo是一款HTML5 2D游戏引擎,欢迎使用。";
//text view
var textView = new Hilo.Container({
x: 40,
y: 50,
width:250,
height:100,
rotation:90,
background:'red'
}).addTo(stage);
var text = new Hilo.Text({
font: font,
text: content,
lineSpacing: 0,
width: 250,
// textAlign:'end',
height: 100,
x: 0,
y: 0
}).addTo(textView);
//text wrapped in dom element
elem = new Hilo.DOMElement({
element: Hilo.createElement('div', {
innerHTML: content,
style: {
position: 'absolute',
font: font
}
}),
width: 250,
height: 100,
x: 40,
y: 150,
}).addTo(textView);
// text 可以移除,但是elem无法移除
setTimeout(function(){
stage.removeChild(textView)
},2000)
Hilo.Container 包含DOMElement , stage.removeChild(Container) ,DOMElement 无法移除
demo
var stageWidth = innerWidth; var stageHeight = innerHeight; var stage = new Hilo.Stage({ container: document.body, width: stageWidth, height: stageHeight, renderType: 'canvas' }); stage.enableDOMEvent([Hilo.event.POINTER_START, Hilo.event.POINTER_MOVE, Hilo.event.POINTER_END]); var ticker = new Hilo.Ticker(60); ticker.addTick(stage); ticker.start(); var font = "14px arial"; var content = "Hello World! Hilo是一款HTML5 2D游戏引擎,欢迎使用。";
//text view
var textView = new Hilo.Container({ x: 40, y: 50, width:250, height:100, rotation:90, background:'red' }).addTo(stage); var text = new Hilo.Text({ font: font, text: content, lineSpacing: 0, width: 250, // textAlign:'end',
}).addTo(textView); //text wrapped in dom element elem = new Hilo.DOMElement({ element: Hilo.createElement('div', { innerHTML: content, style: { position: 'absolute', font: font } }), width: 250, height: 100, x: 40, y: 150, }).addTo(textView);
// text 可以移除,但是elem无法移除 setTimeout(function(){ stage.removeChild(textView) },2000)